bigboard r7278 - in trunk/bigboard: . libbig stocks/files stocks/google_calendar stocks/mail
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7278 - in trunk/bigboard: . libbig stocks/files stocks/google_calendar stocks/mail
- Date: Fri, 4 Apr 2008 00:55:18 +0100 (BST)
Author: marinaz
Date: Fri Apr 4 00:55:17 2008
New Revision: 7278
URL: http://svn.gnome.org/viewvc/bigboard?rev=7278&view=rev
Log:
Re-display "Login to Google" button if we failed to connect to Google.
Display "Checking Login..." message on the button when we are trying to
log the user in (though ideally it will not be displayed, because
the other changes here, make the login almost immediate).
Only connect to signals that can add stock content once the stock is
fully initialized.
Remove an initial waiting time from the Google polling task.
Execute a new action if it is added to the Google polling task when it
is already running.
Re-start the polling task when start() is being called when it is running.
This will result in the task being executed sooner or right away (depending
on the initial waiting time).
Make sure we pick up an enabled flag when it is set to False from GConf.
Do not remove disabled accounts from the accounts dialog.
Modified:
trunk/bigboard/accounts.py
trunk/bigboard/accounts_dialog.py
trunk/bigboard/google.py
trunk/bigboard/google_stock.py
trunk/bigboard/libbig/polling.py
trunk/bigboard/stocks/files/FilesStock.py
trunk/bigboard/stocks/google_calendar/CalendarStock.py
trunk/bigboard/stocks/mail/MailStock.py
trunk/bigboard/stocks/mail/libgmail_patched.py
Modified: trunk/bigboard/accounts.py
==============================================================================
--- trunk/bigboard/accounts.py (original)
+++ trunk/bigboard/accounts.py Fri Apr 4 00:55:17 2008
@@ -120,7 +120,7 @@
def _update_from_origin(self, new_props):
"""This is the only way to modify an Account object. It should be invoked only on change notification or refreshed data from the original origin of the account."""
-
+ _logger.debug("updating account from origin %s" % new_props)
## check it out!
changed = False
for (key,value) in new_props.items():
@@ -453,11 +453,15 @@
except ValueError:
value = None
if value:
+ # _logger.debug("key %s, value %s" % (prop, value))
gconf_info[prop] = value
get_account_prop(self.__gconf, gconf_info, base_key, 'kind')
get_account_prop(self.__gconf, gconf_info, base_key, 'username')
get_account_prop(self.__gconf, gconf_info, base_key, 'url')
- get_account_prop(self.__gconf, gconf_info, base_key, 'enabled')
+ get_account_prop(self.__gconf, gconf_info, base_key, 'enabled')
+ # GConf returns None for get_value if the vale is False
+ if 'enabled' not in gconf_info:
+ gconf_info['enabled'] = False
return gconf_info
@log_except(_logger)
@@ -634,7 +638,6 @@
def save_account_changes(self, account, new_properties):
_logger.debug("Saving new props for account %s: %s" % (str(account), str(new_properties.keys())))
- set_password = False
## special-case handling of password since it goes in the keyring
if 'password' in new_properties:
@@ -658,13 +661,13 @@
url=url,
password=new_properties['password'])
- set_password = True
-
## now do everything else by stuffing it in gconf
self.__ensure_account_in_gconf(account, new_properties)
## keyring doesn't have change notification so we have to do the work for it
- if set_password:
+ ## if the password was the only thing that got updated, otherwise we should wait
+ ## till gconf is reloaded
+ if len(new_properties) == 1 and 'password' in new_properties:
## this should notice a new password
self.__update_account(account)
@@ -689,6 +692,9 @@
def get_all_accounts(self):
return self.__gconf_accounts
+ def has_account(self, account):
+ return account in self.__gconf_accounts
+
def get_accounts_with_kind(self, kind):
accounts = set()
for a in self.__enabled_accounts:
Modified: trunk/bigboard/accounts_dialog.py
==============================================================================
--- trunk/bigboard/accounts_dialog.py (original)
+++ trunk/bigboard/accounts_dialog.py Fri Apr 4 00:55:17 2008
@@ -293,6 +293,9 @@
@log_except(_logger)
def __on_account_removed(self, accts, a):
+ # we don't want to remove accounts that were disabled, but are still present in GConf here
+ if accts.has_account(a):
+ return
_logger.debug("account removed %s" % a)
if a in self.__model_tree_iter_by_account:
_logger.debug("will remove")
Modified: trunk/bigboard/google.py
==============================================================================
--- trunk/bigboard/google.py (original)
+++ trunk/bigboard/google.py Fri Apr 4 00:55:17 2008
@@ -338,7 +338,7 @@
class CheckGoogleTask(libbig.polling.Task):
def __init__(self, google):
- libbig.polling.Task.__init__(self, 1000 * 120, initial_interval=1000*5)
+ libbig.polling.Task.__init__(self, 1000 * 120, initial_interval=0) # initial_interval=1000*5
self.__google = google
self.__actions = {} ## hash from id to [add count, GooglePollAction object]
@@ -350,6 +350,9 @@
self.__actions[id][0] = self.__actions[id][0] + 1
_logger.debug("check count bumped to %d for google check action %s" % (self.__actions[id][0], id))
+
+ if self.is_running():
+ self.__actions[id][1].update()
def remove_action(self, id):
if id not in self.__actions:
@@ -366,6 +369,7 @@
class Google(gobject.GObject):
__gsignals__ = {
## "auth-badness-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_BOOLEAN,))
+ "checking-auth" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
}
def __init__(self, account):
@@ -405,6 +409,7 @@
self.__checker.stop()
else:
_logger.debug("Enabling google polling since auth credentials maybe good")
+ self.emit("checking-auth")
self.__checker.start()
def __auth_needs_retry(self):
Modified: trunk/bigboard/google_stock.py
==============================================================================
--- trunk/bigboard/google_stock.py (original)
+++ trunk/bigboard/google_stock.py Fri Apr 4 00:55:17 2008
@@ -13,6 +13,10 @@
## Some stuff in here is view-specific though, like the _create_login_button
## method.
+FAILED_TO_CONNECT_STRING = "Failed to connect."
+LOGIN_TO_GOOGLE_STRING = "Login to Google"
+CHECKING_LOGIN_STRING = "Checking Login..."
+
class GoogleStock(object):
def __init__(self, action_id, **kwargs):
super(GoogleStock, self).__init__(**kwargs)
@@ -26,14 +30,19 @@
self.__action_id = action_id
self.__connections = gutil.DisconnectSet()
+
+ self._login_button = hippo.CanvasButton(text=LOGIN_TO_GOOGLE_STRING)
+ self._login_button.connect('activated', lambda button: self.__open_login_dialog())
+ _logger.debug("done with google stock init")
+
+ def _post_init(self):
accts = accounts.get_accounts()
for a in accts.get_accounts_with_kind(accounts.KIND_GOOGLE):
self.__on_account_added(a)
id = accts.connect('account-added', lambda accounts, account: self.__on_account_added(account))
self.__connections.add(accts, id)
id = accts.connect('account-removed', lambda accounts, account: self.__on_account_removed(account))
- self.__connections.add(accts, id)
- _logger.debug("done with google stock init")
+ self.__connections.add(accts, id)
## we can't just override _on_delisted() because of multiple inheritance,
## so our subclasses have to override it then call this
@@ -52,6 +61,7 @@
gobj.add_poll_action_func(self.__action_id, lambda gobj: self.update_google_data(gobj))
self.googles.add(gobj)
self.__googles_by_account[acct] = gobj
+ gobj.connect("checking-auth", self._checking_google_auth)
## update_google_data() should be called in the poll action
def __on_account_removed(self, acct):
@@ -76,10 +86,8 @@
def __open_login_dialog(self):
accounts_dialog.open_dialog()
- def _create_login_button(self):
- button = hippo.CanvasButton(text="Login to Google")
- button.connect('activated', lambda button: self.__open_login_dialog())
- return button
+ def _checking_google_auth(self, gobj):
+ self._login_button.set_property("text", CHECKING_LOGIN_STRING)
def update_google_data(self, gobj=None):
pass
Modified: trunk/bigboard/libbig/polling.py
==============================================================================
--- trunk/bigboard/libbig/polling.py (original)
+++ trunk/bigboard/libbig/polling.py Fri Apr 4 00:55:17 2008
@@ -36,7 +36,7 @@
def start(self):
if self.__id != 0:
- return
+ self.stop()
self.__first_time = True
self.__id = gobject.timeout_add(self.__initial_interval, self.__do_periodic_task_if_not_pending)
Modified: trunk/bigboard/stocks/files/FilesStock.py
==============================================================================
--- trunk/bigboard/stocks/files/FilesStock.py (original)
+++ trunk/bigboard/stocks/files/FilesStock.py Fri Apr 4 00:55:17 2008
@@ -405,6 +405,7 @@
self.__drag_window = None
self.__drag_start_pos = None
+ # self._post_init()
def _on_delisted(self):
self._delist_google()
Modified: trunk/bigboard/stocks/google_calendar/CalendarStock.py
==============================================================================
--- trunk/bigboard/stocks/google_calendar/CalendarStock.py (original)
+++ trunk/bigboard/stocks/google_calendar/CalendarStock.py Fri Apr 4 00:55:17 2008
@@ -445,6 +445,7 @@
self.__notifications_proxy.connect_to_signal('ActionInvoked', self.__on_action)
self._add_more_button(self.__on_more_button)
+ self._post_init()
def _on_delisted(self):
self._delist_google()
@@ -751,9 +752,12 @@
self.__box.remove_all()
if not self.have_one_good_google():
- _logger.debug("Creating login button")
- button = self._create_login_button()
- self.__box.append(button)
+ _logger.debug("Adding login button")
+ if self._login_button.get_property("text") == google_stock.CHECKING_LOGIN_STRING:
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
+ self.__box.append(error)
+ self._login_button.set_property("text", google_stock.LOGIN_TO_GOOGLE_STRING)
+ self.__box.append(self._login_button)
return
_logger.debug("have a google login, refreshing events")
Modified: trunk/bigboard/stocks/mail/MailStock.py
==============================================================================
--- trunk/bigboard/stocks/mail/MailStock.py (original)
+++ trunk/bigboard/stocks/mail/MailStock.py Fri Apr 4 00:55:17 2008
@@ -1,4 +1,4 @@
-import logging, re, htmlentitydefs
+import logging, re, htmlentitydefs, time
import gobject, gtk
import hippo
@@ -122,7 +122,7 @@
class MailStock(Stock, google_stock.GoogleStock):
"""Shows recent emails"""
def __init__(self, *args, **kwargs):
- print "starting mail stock"
+ _logger.debug("in mail stock init")
Stock.__init__(self, *args, **kwargs)
google_stock.GoogleStock.__init__(self, 'gmail', **kwargs)
@@ -134,11 +134,12 @@
self.__folder = 'inbox'
self.__display_limit = 4
-
- button = self._create_login_button()
- self._box.append(button)
+
+ self._box.append(self._login_button)
self._add_more_button(self.__on_more_button)
+ _logger.debug("done with mail stock init")
+ self._post_init()
def get_content(self, size):
return self._box
@@ -146,16 +147,17 @@
def update_google_data(self, gobj):
username = gobj.get_account().get_username_as_google_email()
password = gobj.get_account().get_password()
- self.__update_email_box (username, password)
+ self.__update_email_box(username, password)
- def __update_email_box (self, username, password):
- self._box.remove_all()
-
+ def __update_email_box (self, username, password):
+ _logger.debug("will update mailbox")
try:
- if self.__google_account is None or username != self.__google_account.name:
+ if self.__google_account is None or username != self.__google_account.name or \
+ password != self.__google_account.password:
self.__google_account = libgmail.GmailAccount(username, password)
self.__google_account.login()
+ self._box.remove_all()
account = hippo.CanvasText(classes='header', text=self.__google_account.name)
self._box.append(account)
@@ -191,9 +193,13 @@
print "updated mailbox"
except libgmail.GmailLoginFailure:
- error = hippo.CanvasText(text="Error: Could not connect to gmail.", size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
- self._box.append(error)
-
+ self._box.remove_all()
+ if self._login_button.get_property("text") == google_stock.CHECKING_LOGIN_STRING:
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
+ self._box.append(error)
+ self._login_button.set_property('text', google_stock.LOGIN_TO_GOOGLE_STRING)
+ self._box.append(self._login_button)
+
def show_slideout(self, widget):
def on_slideout_close(s, action_taken):
if action_taken:
Modified: trunk/bigboard/stocks/mail/libgmail_patched.py
==============================================================================
--- trunk/bigboard/stocks/mail/libgmail_patched.py (original)
+++ trunk/bigboard/stocks/mail/libgmail_patched.py Fri Apr 4 00:55:17 2008
@@ -296,7 +296,7 @@
URL_GMAIL = GMAIL_URL_GMAIL
if name and pw:
self.name = name
- self._pw = pw
+ self.password = pw
self._cookieJar = CookieJar()
if PROXY_URL is not None:
@@ -332,12 +332,12 @@
'at' : 'null',
'service' : 'mail',
'userName': self.name,
- 'password': self._pw,
+ 'password': self.password,
})
else:
data = urllib.urlencode({'continue': URL_GMAIL,
'Email': self.name,
- 'Passwd': self._pw,
+ 'Passwd': self.password,
})
headers = {'Host': 'www.google.com',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]