bigboard r7303 - in trunk/bigboard: . stocks/google_calendar stocks/mail
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7303 - in trunk/bigboard: . stocks/google_calendar stocks/mail
- Date: Wed, 16 Apr 2008 00:39:25 +0100 (BST)
Author: marinaz
Date: Wed Apr 16 00:39:25 2008
New Revision: 7303
URL: http://svn.gnome.org/viewvc/bigboard?rev=7303&view=rev
Log:
Display "Cannot connect to Google" message in the Mail Stock when we are not connected to the internet.
Do not create new account objects when we have accounts with the same credentials in the GConf. This way we won't emit an "account-removed" signal follwed by an "account-added" signal that caused the Mail Stock display a "login" button momentarily when we get the Google-enabled accounts from the server.
Modified:
trunk/bigboard/accounts.py
trunk/bigboard/google_stock.py
trunk/bigboard/stocks/google_calendar/CalendarStock.py
trunk/bigboard/stocks/mail/MailStock.py
Modified: trunk/bigboard/accounts.py
==============================================================================
--- trunk/bigboard/accounts.py (original)
+++ trunk/bigboard/accounts.py Wed Apr 16 00:39:25 2008
@@ -429,7 +429,9 @@
break
if not account_found:
- new_account_to_add = copy.deepcopy(new_account)
+ new_account_to_add = self.__find_account_in_gconf(new_account.get_kind(), new_account.get_username(), new_account.get_url())
+ if new_account_to_add is None:
+ new_account_to_add = copy.deepcopy(new_account)
self.__server_accounts.add(new_account_to_add)
# this will add the account to gconf and enabled accounts, and check if
# we have a password for it
@@ -579,25 +581,18 @@
# new_properties is optional, it should be passed in if there are changes
# to an existing account and we will update other data constructs that contain
# this account based on the information from gconf
+ #
+ # an account object passed in to this method must have the gconf_dir set or must not be found in gconf
def __ensure_account_in_gconf(self, account, new_properties={}):
gconf_dir = account._get_gconf_dir()
new_gconf_dir = False
-
- # first see if an account with the same credentials exists in GConf
- if not gconf_dir:
- gconf_account = self.__find_account_in_gconf(account.get_kind(), account.get_username(), account.get_url())
- if gconf_account:
- gconf_dir = gconf_account._get_gconf_dir()
- account._set_gconf_dir(gconf_dir)
- account._set_enabled(gconf_account.get_enabled())
- self.__gconf_accounts.remove(gconf_account)
- if gconf_account in self.__enabled_accounts:
- self.__enabled_accounts.remove(gconf_account)
- self.emit('account-removed', gconf_account)
- self.__gconf_accounts.add(account)
# create a new GConf dir if it is a completely new account
if not gconf_dir:
+ if self.__find_account_in_gconf(account.get_kind(), account.get_username(), account.get_url()):
+ _logger.error("found an account in gconf that matches the passed in account object %s, but the passed in account object is missing a gconf_dir" % str(account))
+ return
+
gconf_dir = self.__find_unused_gconf_dir(account.get_kind())
new_gconf_dir = True
account._set_gconf_dir(gconf_dir)
Modified: trunk/bigboard/google_stock.py
==============================================================================
--- trunk/bigboard/google_stock.py (original)
+++ trunk/bigboard/google_stock.py Wed Apr 16 00:39:25 2008
@@ -13,7 +13,8 @@
## Some stuff in here is view-specific though, like the _create_login_button
## method.
-FAILED_TO_CONNECT_STRING = "Failed to connect."
+FAILED_TO_LOGIN_STRING = "Failed to login."
+FAILED_TO_CONNECT_STRING = "Cannot connect to Google."
LOGIN_TO_GOOGLE_STRING = "Login to Google"
CHECKING_LOGIN_STRING = "Checking Login..."
Modified: trunk/bigboard/stocks/google_calendar/CalendarStock.py
==============================================================================
--- trunk/bigboard/stocks/google_calendar/CalendarStock.py (original)
+++ trunk/bigboard/stocks/google_calendar/CalendarStock.py Wed Apr 16 00:39:25 2008
@@ -755,7 +755,7 @@
if not self.have_one_good_google():
_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)
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_LOGIN_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)
Modified: trunk/bigboard/stocks/mail/MailStock.py
==============================================================================
--- trunk/bigboard/stocks/mail/MailStock.py (original)
+++ trunk/bigboard/stocks/mail/MailStock.py Wed Apr 16 00:39:25 2008
@@ -98,8 +98,14 @@
account_text = hippo.CanvasText(classes='header', text=ga.name)
header.append(account_text, hippo.PACK_EXPAND)
vbox.append(header)
- folderCounts = ga.getFolderCounts()
- folderCounts["unread"] = ga.getUnreadMsgCount()
+ try:
+ folderCounts = ga.getFolderCounts()
+ folderCounts["unread"] = ga.getUnreadMsgCount()
+ except urllib2.URLError:
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING)
+ vbox.append(error)
+ return
+
for label, number in folderCounts.iteritems():
box = PrelightingCanvasBox()
box.connect('button-release-event', self.on_button_release_event, label)
@@ -134,6 +140,7 @@
if type(value) is list:
s = ", ".join(value)
if type(value) is str:
+ _logger.debug("passing in %s" % value)
s = gmail_jshtml_str_parse(value)
box = hippo.CanvasText(text=s, xalign=hippo.ALIGNMENT_START)
@@ -162,6 +169,7 @@
self.__current_gobj = None
self.__google_account = None
self.__folder = 'inbox'
+ self.__logged_in = False
self.__display_limit = 4
@@ -185,6 +193,8 @@
self._box.remove_all()
self._login_button.set_property('text', google_stock.LOGIN_TO_GOOGLE_STRING)
self._box.append(self._login_button)
+ self.__google_account = None
+ self.__logged_in = False
def __update_email_box (self, username, password):
_logger.debug("will update mailbox")
@@ -193,7 +203,18 @@
password != self.__google_account.password:
self.__google_account = libgmail.GmailAccount(username, password)
self.__google_account.login()
-
+ elif not self.__logged_in:
+ self.__google_account.login()
+
+ self.__logged_in = True
+
+ if self.__folder == 'inbox':
+ threads = self.__google_account.getMessagesByFolder(self.__folder)
+ elif self.__folder == 'unread':
+ threads = self.__google_account.getUnreadMessages()
+ else:
+ threads = self.__google_account.getMessagesByLabel(self.__folder)
+
self._box.remove_all()
account = hippo.CanvasText(classes='header', text=self.__google_account.name)
self._box.append(account)
@@ -204,14 +225,6 @@
label = hippo.CanvasText(text=self.__folder, font="14px Bold Italic")
box.append(label)
- if self.__folder == 'inbox':
- threads = self.__google_account.getMessagesByFolder(self.__folder)
-
- elif self.__folder == 'unread':
- threads = self.__google_account.getUnreadMessages()
- else:
- threads = self.__google_account.getMessagesByLabel(self.__folder)
-
i = 0
for thread in threads:
if i >= self.__display_limit: break
@@ -229,13 +242,22 @@
self._box.append(footer)
print "updated mailbox"
- except (libgmail.GmailLoginFailure, urllib2.URLError):
+ except libgmail.GmailLoginFailure:
self._box.remove_all()
+ self.__logged_in = False
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)
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_LOGIN_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)
+ except urllib2.URLError:
+ if not self.__logged_in:
+ self._box.remove_all()
+
+ if len(self._box.get_children()) == 0 or \
+ self._box.get_children()[0].get_property("text") != google_stock.FAILED_TO_CONNECT_STRING:
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
+ self._box.prepend(error)
def show_slideout(self, widget):
def on_slideout_close(s, action_taken):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]