bigboard r7395 - in trunk/bigboard: . stocks/files stocks/google_calendar stocks/mail



Author: marinaz
Date: Fri Jun 20 17:59:37 2008
New Revision: 7395
URL: http://svn.gnome.org/viewvc/bigboard?rev=7395&view=rev

Log:
Switch accounts dialog and Google stocks to using onlineaccounts DBus service.


Modified:
   trunk/bigboard/accounts_dialog.py
   trunk/bigboard/google.py
   trunk/bigboard/google_stock.py
   trunk/bigboard/stocks/files/FilesStock.py
   trunk/bigboard/stocks/files/filebrowser.py
   trunk/bigboard/stocks/google_calendar/CalendarStock.py
   trunk/bigboard/stocks/mail/MailStock.py
   trunk/bigboard/stocks/mail/stock.css

Modified: trunk/bigboard/accounts_dialog.py
==============================================================================
--- trunk/bigboard/accounts_dialog.py	(original)
+++ trunk/bigboard/accounts_dialog.py	Fri Jun 20 17:59:37 2008
@@ -1,7 +1,6 @@
 import sys, logging, urlparse
 
-import gobject, gtk
-import bigboard.accounts as accounts
+import gobject, gtk, dbus
 
 import bigboard.globals as globals
 import libbig.logutil
@@ -10,71 +9,17 @@
 
 _logger = logging.getLogger("bigboard.AccountsDialog")
 
-# this class will probably be removed since we are changing the layot of the accounts dialog
-class AccountEditor(gtk.VBox):
-    def __init__(self, *args, **kwargs):
-        if 'account' in kwargs:
-            self.__account = kwargs['account']
-            del kwargs['account']
-        else:
-            raise Error("must provide account to AccountEditor")
-        
-        super(AccountEditor, self).__init__(*args, **kwargs)
-
-        self.__username_entry = gtk.Entry()
-        self.__password_entry = gtk.Entry()
-        self.__password_entry.set_visibility(False)
-
-        self.__username_entry.connect('changed',
-                                      self.__on_username_entry_changed)
-        self.__password_entry.connect('changed',
-                                      self.__on_password_entry_changed)
-
-        hbox = gtk.HBox(spacing=10)
-        label = gtk.Label("Email")
-        label.set_alignment(0.0, 0.5)
-        hbox.pack_start(label)
-        hbox.pack_end(self.__username_entry, False)
-        self.pack_start(hbox)
-
-        hbox = gtk.HBox(spacing=10)
-        label = gtk.Label("Password")
-        label.set_alignment(0.0, 0.5)
-        hbox.pack_start(label)    
-        hbox.pack_end(self.__password_entry, False)
-        self.pack_start(hbox)
-
-        self.show_all()
-
-        self.__on_account_changed(self.__account)
-        self.__changed_id = self.__account.connect('changed', self.__on_account_changed)
-
-        self.__password_entry.set_activates_default(True)
-
-        self.connect('destroy', self.__on_destroy)
-
-    def __on_destroy(self, self2):
-        self.__account.disconnect(self.__changed_id)
-
-    def __on_account_changed(self, account):
-        self.__username_entry.set_text(account.get_username())
-        self.__password_entry.set_text(account.get_password())
-
-    def __on_username_entry_changed(self, entry):
-        text = entry.get_text()
-        accounts.get_accounts().save_account_changes(self.__account,
-                                                     { 'username' : text })
-
-    def __on_password_entry_changed(self, entry):
-        text = entry.get_text()
-        accounts.get_accounts().save_account_changes(self.__account,
-                                                     { 'password' : text })
-
 class Dialog(gtk.Window):
     @log_except(_logger)      
     def __init__(self, *args, **kwargs):
         super(Dialog, self).__init__(*args, **kwargs)        
         
+        try:
+            self.__onlineaccounts_proxy = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', '/onlineaccounts')
+        except dbus.DBusException, e:
+            _logger.error("onlineaccounts DBus service not available, can't manage accounts")
+            return
+
         self.set_title('Accounts')
         self.set_position(gtk.WIN_POS_CENTER)
 
@@ -183,9 +128,13 @@
         account_kinds_textrender = gtk.CellRendererText()
         self.__account_kinds_combo.pack_start(account_kinds_textrender, True)
         self.__account_kinds_combo.add_attribute(account_kinds_textrender, 'text', 0)
-        for kind in accounts.ALL_ACCOUNT_KINDS:
-            if not kind.get_provided_by_server():
-                self.__account_kinds_model.append([kind.get_name()])
+        
+        self.__all_account_kinds = self.__onlineaccounts_proxy.GetAllAccountKinds()
+
+        # TODO: once we save accounts added locally on server, we will allow adding all account types
+        # in the dialog, but for now we don't allow adding any
+        # for kind_full_name in self.__all_account_kinds.values():
+        #     self.__account_kinds_model.append([kind_full_name])
             
         # Setting padding to 1 here is a hack to get the content of both tabs to be aligned,
         # we'll need to change this when it will become possible to add new account types to
@@ -228,8 +177,8 @@
             self.__add_link_box.pack_end(self.__add_link, expand=False, fill=False)
             self.__outer_new_account_vbox.pack_end(self.__add_link_box, False, False)
         else:  
-            if len(accounts.ALL_ACCOUNT_KINDS) == 1 and \
-               accounts.KIND_GOOGLE in accounts.ALL_ACCOUNT_KINDS:           
+            if len(self.__all_account_kinds) == 1 and \
+               "google" in self.__all_account_kinds.keys():           
                 self.__add_link.set_text("Add Google accounts online")
             else:
                 self.__add_link.set_text("Add accounts online")
@@ -250,22 +199,23 @@
  
         self.__notebook.set_current_page(1)
 
-        self.__connections = gutil.DisconnectSet()
-
-        accts = accounts.get_accounts()
-        id = accts.connect('account-added', self.__on_account_added)
-        self.__connections.add(accts, id)
-        id = accts.connect('account-removed', self.__on_account_removed)
-        self.__connections.add(accts, id)
-
-        # google_accounts = accts.get_accounts_with_kind(accounts.KIND_GOOGLE)
-        all_accounts = accts.get_all_accounts()
-        if len(all_accounts) == 0:
-            # do something else
+        # google_accounts = self.__onlineaccounts_proxy.GetAllAccountsWithKinds(["google"])
+        all_account_paths = self.__onlineaccounts_proxy.GetAllAccounts()
+        if len(all_account_paths) == 0:
+            # TODO: do something else
             pass
         else:
-            for a in all_accounts:
-                self.__on_account_added(accts, a)
+            for a_path in all_account_paths:
+                self.__on_account_added(a_path)
+
+        self.__connections = gutil.DisconnectSet()
+
+        id = self.__onlineaccounts_proxy.connect_to_signal('AccountAdded',
+                                                           self.__on_account_added)
+        self.__connections.add(self.__onlineaccounts_proxy, id)
+        id = self.__onlineaccounts_proxy.connect_to_signal('AccountRemoved',
+                                                           self.__on_account_removed)
+        self.__connections.add(self.__onlineaccounts_proxy, id)
 
     ## should be a destroy() that disconnects connections, but we never destroy anyway
 
@@ -273,17 +223,19 @@
         libbig.show_url(urlparse.urljoin(globals.get_baseurl(), "/account"))
    
     @log_except(_logger)      
-    def __on_account_added(self, accts, a):
+    def __on_account_added(self, a_path):
         # TODO: check for account kind when we have a per-account dialog
-        if a not in self.__model_tree_iter_by_account:
+        if a_path not in self.__model_tree_iter_by_account:
+            try:
+                a = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', a_path)
+            except dbus.DBusException, e:
+                _logger.error("onlineaccount for path %s was not found" % a_path)
+                return
+
             _logger.debug("account added %s" % a) 
-            tree_iter = None
-            if a.get_url() and a.get_url() != '':
-                tree_iter = self.__model.append([a.get_kind().get_name() + ': ' + a.get_username() + '@' + a.get_url()])
-            else:
-                tree_iter = self.__model.append([a.get_kind().get_name() + ': ' + a.get_username()])
+            tree_iter = self.__model.append([self.__all_account_kinds[a.GetKind()] + ': ' + a.GetUsername()])
                 
-            self.__model_tree_iter_by_account[a] = tree_iter
+            self.__model_tree_iter_by_account[a_path] = tree_iter
 
             if len(self.__model_tree_iter_by_account) == 1:
                 self.__set_no_accounts_state(False)
@@ -292,19 +244,24 @@
                 self.__notebook.set_current_page(0)     
 
     @log_except(_logger)      
-    def __on_account_removed(self, accts, a):
+    def __on_account_removed(self, a_path):
         # 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:
+        # if accts.has_account(a):
+        #     return 
+ 
+        _logger.debug("account removed %s" % a_path) 
+        if a_path in self.__model_tree_iter_by_account:
             _logger.debug("will remove")
-            self.__model.remove(self.__model_tree_iter_by_account[a])
-            del self.__model_tree_iter_by_account[a]
+            self.__model.remove(self.__model_tree_iter_by_account[a_path])
+            del self.__model_tree_iter_by_account[a_path]
             # TODO: possibly can get the index of the deleted selection, and move to the next one 
-            if self.__current_account == a and len(self.__model_tree_iter_by_account) > 0:                
-                self.__current_account = self.__model_tree_iter_by_account.keys()[0]
-                self.__accounts_combo.set_active_iter(self.__model_tree_iter_by_account.values()[0]) 
+            if self.__current_account.GetObjectPath() == a_path and len(self.__model_tree_iter_by_account) > 0:  
+                new_current_account_path = self.__model_tree_iter_by_account.keys()[0]
+                try:
+                    self.__current_account = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', new_current_account_path)
+                    self.__accounts_combo.set_active_iter(self.__model_tree_iter_by_account.values()[0]) 
+                except dbus.DBusException, e:
+                    _logger.error("onlineaccount for path %s was not found" % new_current_account_path)
    
         if len(self.__model_tree_iter_by_account) == 0:   
             self.__set_no_accounts_state(True)
@@ -328,21 +285,26 @@
     def __on_edited_account_changed(self, *args):
         new_iter = self.__accounts_combo.get_active_iter()
         _logger.debug("account changed to %s" % self.__model.get_value(new_iter, 0))        
-        for (a, tree_iter) in self.__model_tree_iter_by_account.items():
+        for (a_path, tree_iter) in self.__model_tree_iter_by_account.items():
             # this assumes that text for each entry in the drop down box is different, which it should be       
             if self.__model.get_value(tree_iter, 0) == self.__model.get_value(new_iter, 0):
-                self.__current_account = a
+                try:
+                    self.__current_account = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', a_path)
+                except dbus.DBusException, e:
+                    _logger.error("onlineaccount for path %s was not found" % a_path)
+                    return
                 # TODO: this will trigger __on_password_entry_changed, make sure that is harmless
-                self.__password_entry.set_text(a.get_password())
-                self.__check_box.set_active(a.get_enabled())
-                self.__remove_button.set_sensitive(not a.get_kind().get_provided_by_server()) 
-                self.__remove_link.set_enabled(a.get_kind().get_provided_by_server())
+                self.__password_entry.set_text(self.__current_account.GetPassword())
+                self.__check_box.set_active(self.__current_account.GetEnabled())
+                # TODO: set the remove button to be sensitive once we enable removing accounts on server
+                self.__remove_button.set_sensitive(False) 
+                self.__remove_link.set_enabled(True)
                 return
         _logger.error("new edited account was not found in self.__model_tree_iter_by_account")
 
     def __on_account_settings_changed(self, widget):
-        if self.__password_entry.get_text().strip() != self.__current_account.get_password() or \
-           self.__check_box.get_active() != self.__current_account.get_enabled():
+        if self.__password_entry.get_text().strip() != self.__current_account.GetPassword() or \
+           self.__check_box.get_active() != self.__current_account.GetEnabled():
             self.__undo_button.set_sensitive(True)  
             self.__apply_button.set_sensitive(True)  
         else:
@@ -352,17 +314,17 @@
     def __on_account_settings_applied(self, widget):
         text = self.__password_entry.get_text()
         enabled = self.__check_box.get_active()
-        accounts.get_accounts().save_account_changes(self.__current_account,
-                                                     { 'password' : text, 'enabled' : enabled })
+        self.__onlineaccounts_proxy.SaveAccountChanges(self.__current_account.GetObjectPath(),
+                                                       { 'password' : str(text), 'enabled' : str(enabled) })
         self.__undo_button.set_sensitive(False)  
         self.__apply_button.set_sensitive(False)  
 
     def __on_account_settings_reset(self, widget):
-        self.__password_entry.set_text(self.__current_account.get_password())
-        self.__check_box.set_active(self.__current_account.get_enabled())
+        self.__password_entry.set_text(self.__current_account.GetPassword())
+        self.__check_box.set_active(self.__current_account.GetEnabled())
   
     def __on_account_remove_clicked(self, widget):
-        accounts.get_accounts().remove_account(self.__current_account)
+        self.__onlineaccounts_proxy.RemoveAccount(self.__current_account.GetObjectPath())
 
     def __on_new_username_changed(self, widget):
         # in the future can check if the input is of the desired form here
@@ -377,9 +339,9 @@
             return
         
         current_iter = self.__account_kinds_combo.get_active_iter()
-        for kind in accounts.ALL_ACCOUNT_KINDS:
-            if not kind.get_provided_by_server() and self.__account_kinds_model.get_value(current_iter, 0) == kind.get_name():
-                account_tuple = accounts.get_accounts().get_or_create_account(kind, text)
+        for (kind, kind_full_name) in self.__all_account_kinds:
+            if self.__account_kinds_model.get_value(current_iter, 0) == kind_full_name:
+                account_tuple = self.__onlineaccounts_proxy.GetOrCreateAccount(kind, text)
                 self.__username_entry.set_text("")
                 self.__notebook.set_current_page(0)
                 # TODO: Display a special message if the account aready existed (account_tuple[1] is False), also
@@ -390,12 +352,12 @@
                 else:
                     # acounts system will emit a signal that will cause __on_account_added to be called again, 
                     # but it's ok to call this from here so that we can switch to the new account in the combo box right away
-                    self.__on_account_added(None, account_tuple[0])
+                    self.__on_account_added(account_tuple[0])
                     account_iter = self.__model_tree_iter_by_account[account_tuple[0]]   
                     self.__accounts_combo.set_active_iter(account_iter)
                 return 
                 
-        _logger.warn("Did not find an account kind which is not provided by the server that matched the account kind in the dropdown %s" % self.__account_kinds_model.get_value(current_iter, 0))
+        _logger.warn("Did not find an account kind that matched the account kind in the dropdown %s" % self.__account_kinds_model.get_value(current_iter, 0))
 
     def __on_delete_event(self, dialog, event):
         self.hide()

Modified: trunk/bigboard/google.py
==============================================================================
--- trunk/bigboard/google.py	(original)
+++ trunk/bigboard/google.py	Fri Jun 20 17:59:37 2008
@@ -14,7 +14,6 @@
 from libbig.struct import AutoStruct, AutoSignallingStruct
 import libbig.polling
 import htmllib
-import bigboard.accounts as accounts
 import gdata.docs as gdocs
 
 _logger = logging.getLogger("bigboard.Google")
@@ -387,7 +386,7 @@
         self.__checker = CheckGoogleTask(self)
         self.add_poll_action('mail', lambda: MailPollAction(self))
 
-        self.__account.connect('changed', lambda account: self.__on_account_changed())
+        self.__account.connect_to_signal('Changed', self.__on_account_changed)
         self.__on_account_changed()
 
     def get_account(self):
@@ -417,8 +416,8 @@
 
     def __auth_needs_retry(self):
 
-        username = self.__account.get_username_as_google_email()
-        password = self.__account.get_password()
+        username = self.__account.GetUsername()
+        password = self.__account.GetPassword()
 
         _logger.debug("auth retry for google username %s" % (username))
 
@@ -439,14 +438,16 @@
         errcb({ 'status' : 401, 'message' : 'Bad or missing username or password' })
 
     def get_current_auth_credentials_known_bad(self):
-        return self.__account.get_username_as_google_email() == '' or \
+        return self.__account.GetUsername() == '' or \
                self.__last_auth_attempt_failed
 
+    @log_except(_logger)
     def __on_account_changed(self):
+        _logger.debug("got Changed signal!")
         auth_changed = False
-        if self.__last_username_tried != self.__account.get_username_as_google_email():
+        if self.__last_username_tried != self.__account.GetUsername():
             auth_changed = True
-        if self.__last_password_tried != self.__account.get_password():
+        if self.__last_password_tried != self.__account.GetPassword():
             auth_changed = True
 
         _logger.debug("google account changed, auth_changed=%d" % (auth_changed))
@@ -464,8 +465,8 @@
 
     def __have_login_fetch_calendar_list(self, cb, errcb):
 
-        username = self.__account.get_username_as_google_email()
-        password = self.__account.get_password()
+        username = self.__account.GetUsername()
+        password = self.__account.GetPassword()
 
         # there is a chance that someone might have access to more than 25 calendars, so let's
         # specify 1000 for max-results to make sure we get information about all calendars 
@@ -481,8 +482,8 @@
 
     def __have_login_fetch_calendar(self, cb, errcb, calendar_feed_url, event_range_start, event_range_end):
 
-        username = self.__account.get_username_as_google_email()
-        password = self.__account.get_password()        
+        username = self.__account.GetUsername()
+        password = self.__account.GetPassword()        
 
         min_and_max_str = ""
         if event_range_start is not None and event_range_end is not None:
@@ -517,8 +518,8 @@
         errcb(exc_info)
 
     def __have_login_fetch_documents(self, cb, errcb):
-        username = self.__account.get_username_as_google_email()
-        password = self.__account.get_password()        
+        username = self.__account.GetUsername()
+        password = self.__account.GetPassword()        
         
         uri = 'http://docs.google.com/feeds/documents/private/full'
         # uri = 'http://spreadsheets.google.com/feeds/spreadsheets/private/full'
@@ -534,7 +535,7 @@
     ### New Mail
 
     def get_mail_base_url(self):
-        username = self.__account.get_username_as_google_email()
+        username = self.__account.GetUsername()
         
         if not username:
             return None
@@ -566,8 +567,8 @@
 
     def __have_login_fetch_new_mail(self, cb, errcb):
 
-        username = self.__account.get_username_as_google_email()
-        password = self.__account.get_password()        
+        username = self.__account.GetUsername()
+        password = self.__account.GetPassword()        
 
         uri = self.get_mail_base_url() + '/feed/atom'
 
@@ -588,34 +589,55 @@
 
 def get_google_for_account(account):
     global __googles_by_account
-    if not __googles_by_account.has_key(account):
+    if not __googles_by_account.has_key(account.GetObjectPath()):
         _logger.debug("calling refresh googles from get google for account")
-        __refresh_googles(accounts.get_accounts())
+        __refresh_googles()
+ 
+    for key in __googles_by_account.keys():
+        _logger.debug("key in __googles_by_account %s" % key)
+ 
+    return __googles_by_account[account.GetObjectPath()]
 
-    return __googles_by_account[account]
-
-def __refresh_googles(a):
+def __refresh_googles():
     _logger.debug("refresh googles was called")
-    global __googles_by_account    
-    gaccounts = a.get_accounts_with_kind(accounts.KIND_GOOGLE)
+    global __googles_by_account 
+    try:
+        __onlineaccounts_proxy = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', '/onlineaccounts')
+    except dbus.DBusException, e:
+        _logger.error("onlineaccounts DBus service not available, can't refresh googles")   
+    gaccount_paths = __onlineaccounts_proxy.GetEnabledAccountsWithKinds(['google'])
     new_googles = {}
-    for g in gaccounts:
-        if g in __googles_by_account:
-            new_googles[g] = __googles_by_account[g]
+    for g_path in gaccount_paths:
+        if g_path in __googles_by_account:
+                new_googles[g_path] = __googles_by_account[g_path]
         else:
-            new_googles[g] = Google(g)
+            try:
+                g = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', g_path)  
+                new_googles[g_path] = Google(g)
+            except dbus.DBusException, e:
+                _logger.error("onlineaccount for path %s was not found" % g_path)
 
-    for (g, old) in __googles_by_account.items():
-        if g not in new_googles:
+    for (g_path, old) in __googles_by_account.items():
+        if g_path not in new_googles:
             old.destroy()
             
     __googles_by_account = new_googles
 
-def __on_account_added(a, account):
-    __refresh_googles(a)
+def __on_account_added(account_path):
+    try:
+        a = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', account_path)
+        if a.GetKind() == "google":
+            __refresh_googles()      
+    except dbus.DBusException, e:
+        _logger.error("onlineaccount for path %s was not found" % account_path)
 
-def __on_account_removed(a, account):
-    __refresh_googles(a)
+def __on_account_removed(account_path):
+    try:
+        a = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', account_path)
+        if a.GetKind() == "google":
+            __refresh_googles()      
+    except dbus.DBusException, e:
+        _logger.error("onlineaccount for path %s was not found" % account_path)
 
 def init():
     global __initialized
@@ -624,10 +646,14 @@
         return
     __initialized = True
     _logger.debug("THE google is being initialized")
-    a = accounts.get_accounts()
-    __refresh_googles(a)
-    a.connect('account-added', __on_account_added)
-    a.connect('account-removed', __on_account_removed)
+    __refresh_googles()
+
+    try:
+        __onlineaccounts_proxy = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', '/onlineaccounts')
+        __onlineaccounts_proxy.connect_to_signal('AccountEnabled', __on_account_added)
+        __onlineaccounts_proxy.connect_to_signal('AccountDisabled', __on_account_removed)
+    except dbus.DBusException, e:
+        _logger.error("onlineaccounts DBus service not available, can't connect to signals")
         
 if __name__ == '__main__':
 

Modified: trunk/bigboard/google_stock.py
==============================================================================
--- trunk/bigboard/google_stock.py	(original)
+++ trunk/bigboard/google_stock.py	Fri Jun 20 17:59:37 2008
@@ -1,7 +1,6 @@
-import logging
+import logging, dbus
 import hippo
 import bigboard.google as google
-import bigboard.accounts as accounts
 import accounts_dialog
 import bigboard.libbig.gutil as gutil
 from bigboard.libbig.logutil import log_except
@@ -25,7 +24,7 @@
         _logger.debug("in google stock init")
         # a set of enabled google accounts to be used in the stock
         self.googles = set()
-        self.__googles_by_account = {} ## map accounts.Account => google.Google
+        self.__googles_by_account = {} ## maps OnlineAccount ObjectPath => google.Google
 
         _logger.debug("in google stock init action_id is %s", str(action_id))         
         self.__action_id = action_id
@@ -37,13 +36,22 @@
         _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)   
+        try:
+            onlineaccounts_proxy = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', '/onlineaccounts')
+        except dbus.DBusException, e:
+            _logger.error("onlineaccounts DBus service not available, can't get google accounts")
+            return
+
+        all_google_account_paths = onlineaccounts_proxy.GetEnabledAccountsWithKinds(["google"])
+        for a_path in all_google_account_paths:
+            self.__on_account_added(a_path)
+
+        self.__connections = gutil.DisconnectSet()
+
+        id = onlineaccounts_proxy.connect_to_signal('AccountEnabled', self.__on_account_added)
+        self.__connections.add(onlineaccounts_proxy, id)
+        id = onlineaccounts_proxy.connect_to_signal('AccountDisabled', self.__on_account_removed)
+        self.__connections.add(onlineaccounts_proxy, id)
 
     ## we can't just override _on_delisted() because of multiple inheritance,
     ## so our subclasses have to override it then call this
@@ -51,28 +59,47 @@
         self.__connections.disconnect_all()
 
         ## detach from all the accounts
-        accts = self.__googles_by_account.keys()
-        for a in accts:
-            self.__on_account_removed(a)
+        acct_paths = self.__googles_by_account.keys()
+        for a_path in acct_paths:
+            self.__on_account_removed(a_path)
 
     @log_except(_logger)
-    def __on_account_added(self, acct):
+    def __on_account_added(self, acct_path):
+        try:
+            _logger.debug("acct_path is %s" % acct_path)
+            acct = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', acct_path)
+        except dbus.DBusException, e:
+            _logger.error("onlineaccount for path %s was not found" % acct_path)
+            return
+
+        if acct.GetKind() != "google":
+            return
+       
         _logger.debug("in __on_account_added for %s", str(acct))         
         gobj = google.get_google_for_account(acct)
         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
+        self.__googles_by_account[acct_path] = 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):
+    def __on_account_removed(self, acct_path):
+        try:
+            acct = dbus.SessionBus().get_object('org.gnome.WebLoginDriver', acct_path)
+        except dbus.DBusException, e:
+            _logger.error("onlineaccount for path %s was not found" % acct_path)
+            return
+
+        if acct.GetKind() != "google":
+            return
+
         _logger.debug("in __on_account_removed for %s", str(acct))  
         ## we keep our own __googles_by_account because google.get_google_for_account()
         ## will have dropped the Google before this point
-        gobj = self.__googles_by_account[acct]
+        gobj = self.__googles_by_account[acct_path]
         gobj.remove_poll_action(self.__action_id)
         self.googles.remove(gobj)
-        del self.__googles_by_account[acct]
+        del self.__googles_by_account[acct_path]
 
         ## hook for derived classes
         self.remove_google_data(gobj)

Modified: trunk/bigboard/stocks/files/FilesStock.py
==============================================================================
--- trunk/bigboard/stocks/files/FilesStock.py	(original)
+++ trunk/bigboard/stocks/files/FilesStock.py	Fri Jun 20 17:59:37 2008
@@ -487,7 +487,7 @@
     def __on_documents_load(self, document_entries, gobj):
         self.__remove_files_for_key(gobj) 
         for document_entry in document_entries:
-            google_file = GoogleFile(gobj, gobj.get_account().get_username_as_google_email(),
+            google_file = GoogleFile(gobj, gobj.get_account().GetUsername(),
                                      document_entry)
             # google_file.connect('activated', self.on_file_activated)
             self.__files.append(google_file)

Modified: trunk/bigboard/stocks/files/filebrowser.py
==============================================================================
--- trunk/bigboard/stocks/files/filebrowser.py	(original)
+++ trunk/bigboard/stocks/files/filebrowser.py	Fri Jun 20 17:59:37 2008
@@ -63,8 +63,9 @@
             # don't list invalid accounts we might have picked up from the signons file
             if google_account.get_current_auth_credentials_known_bad():
                 continue  
-            google_docs_link = ActionLink(text=google_account.get_account().get_username_as_google_email() + " Docs", padding_bottom=4, xalign=hippo.ALIGNMENT_START, yalign=hippo.ALIGNMENT_START)
-            google_docs_link.connect("activated", webbrowser.open, create_account_url(google_account.get_account().get_username_as_google_email()))
+
+            google_docs_link = ActionLink(text=google_account.get_account().GetUsername() + " Docs", padding_bottom=4, xalign=hippo.ALIGNMENT_START, yalign=hippo.ALIGNMENT_START)
+            google_docs_link.connect("activated", webbrowser.open, create_account_url(google_account.get_account().GetUsername()))
             browse_options.append(google_docs_link)
 
         self.__search_box = CanvasHBox(padding_top=4, padding_bottom=4)        

Modified: trunk/bigboard/stocks/google_calendar/CalendarStock.py
==============================================================================
--- trunk/bigboard/stocks/google_calendar/CalendarStock.py	(original)
+++ trunk/bigboard/stocks/google_calendar/CalendarStock.py	Fri Jun 20 17:59:37 2008
@@ -556,7 +556,7 @@
                 #  you must first close the existing Firefox process, or restart your system."
                 time.sleep(2)
                 done_with_sleep_state = 2  
-            libbig.show_url(create_account_url(google_account.get_account().get_username_as_google_email()))
+            libbig.show_url(create_account_url(google_account.get_account().GetUsername()))
             if done_with_sleep_state == 0:
                 done_with_sleep_state = 1
         

Modified: trunk/bigboard/stocks/mail/MailStock.py
==============================================================================
--- trunk/bigboard/stocks/mail/MailStock.py	(original)
+++ trunk/bigboard/stocks/mail/MailStock.py	Fri Jun 20 17:59:37 2008
@@ -196,15 +196,14 @@
     
     def update_google_data(self, gobj):
         # self.__current_gobj = gobj
-        # username = gobj.get_account().get_username()
-        # password = gobj.get_account().get_password()
-        # domain = gobj.get_account().get_url() 
+        # username = gobj.get_account().GetUsername()
+        # password = gobj.get_account().GetPassword()
         self.__update_email_box(gobj)
    
     def remove_google_data(self, gobj):
         if self.__google_accounts.has_key(gobj):
             self._box.remove(self.__google_accounts[gobj].get_google_account_box())
-            _logger.debug("will remove key for %s" % gobj.get_account().get_username())
+            _logger.debug("will remove key for %s" % gobj.get_account().GetUsername())
             del self.__google_accounts[gobj]
         
         # sometimes we don't even get the self.__google_accounts because the polling task didn't start, so 
@@ -220,11 +219,12 @@
     @log_except(_logger)
     def __update_email_box (self, gobj):       
         _logger.debug("will update mailbox")
-        username = gobj.get_account().get_username()
-        password = gobj.get_account().get_password()
-        domain = gobj.get_account().get_url()
-        if domain and (len(domain) == 0 or domain == "gmail.com"):
+        (username, domain) = gobj.get_account().GetUsername().split('@', 1)
+        username = str(username)
+        domain = str(domain) 
+        if domain == "gmail.com":
             domain = None  
+        password = gobj.get_account().GetPassword()
 
         if not self.__google_accounts.has_key(gobj):
             self.__google_accounts[gobj] = GoogleAccountInfo()
@@ -247,7 +247,7 @@
             # just calling the login() function again doesn't work
             if google_account is None or username != google_account.name or \
                password != google_account.password or domain != google_account.domain or self.__last_login_gobj != gobj:                 
-                _logger.debug("username %s domain %s password %s" % (username, domain, password))
+                _logger.debug("username %s domain %s password length %s" % (username, domain, len(password)))
                 google_account = libgmail.GmailAccount(username, password, domain = domain)
                 google_account.login()
             elif not logged_in_flag:
@@ -274,10 +274,10 @@
             google_account_box.remove_all()
             account = CanvasHBox(xalign=hippo.ALIGNMENT_START)
  
-            account_name = ActionLink(text=gobj.get_account().get_username_as_google_email(), size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
-            account_name.connect("activated", on_visit_mail_account, gobj.get_account().get_username_as_google_email())
+            account_name = ActionLink(text=gobj.get_account().GetUsername(), size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
+            account_name.connect("activated", on_visit_mail_account, gobj.get_account().GetUsername())
             unread_message_count = ActionLink(text=" (%s)" % labelsDict['inbox'], xalign=hippo.ALIGNMENT_START)
-            unread_message_count.connect("activated", on_visit_mail_account, gobj.get_account().get_username_as_google_email())
+            unread_message_count.connect("activated", on_visit_mail_account, gobj.get_account().GetUsername())
             # connecting to this signal once per GoogleAccountInfo did not work in all cases, and connecting multiple
             # times means that the function would be called multiple times, so we need to keep the expand_arrow_signal_id
             # to use it for disconnecting, and then connect again each time
@@ -330,8 +330,9 @@
         except libgmail.GmailLoginFailure:
             self._box.set_child_visible(self.__failed_to_connect_message, False) 
             google_account_box.remove_all()
-            account = ActionLink(text=gobj.get_account().get_username_as_google_email(), xalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
-            account.connect("activated", on_visit_mail_account, gobj.get_account().get_username_as_google_email())
+
+            account = ActionLink(text=gobj.get_account().GetUsername(), xalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
+            account.connect("activated", on_visit_mail_account, gobj.get_account().GetUsername())
             google_account_box.append(account)
             
             logged_in_flag = False
@@ -341,8 +342,9 @@
         except urllib2.URLError:
             if not logged_in_flag:
                 google_account_box.remove_all()
-                account = ActionLink(text=gobj.get_account().get_username_as_google_email(), xalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
-                account.connect("activated", on_visit_mail_account, gobj.get_account().get_username_as_google_email())
+
+                account = ActionLink(text=gobj.get_account().GetUsername(), xalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
+                account.connect("activated", on_visit_mail_account, gobj.get_account().GetUsername())
                 google_account_box.append(account) 
  
             self._box.set_child_visible(self.__failed_to_connect_message, True) 
@@ -405,7 +407,7 @@
         self.show_slideout(widget)
     
     def on_label_changed(self, slideout, label, gobj):
-        _logger.debug("will get new folder for %s" % gobj.get_account().get_username_as_google_email())
+        _logger.debug("will get new folder for %s" % gobj.get_account().GetUsername())
         self.__google_accounts[gobj].update({'current_folder' : label})
         self.__update_email_box(gobj)
     
@@ -432,7 +434,7 @@
                 #  you must first close the existing Firefox process, or restart your system."
                 time.sleep(2)
                 done_with_sleep_state = 2  
-            libbig.show_url(create_account_url(google_account.get_account().get_username_as_google_email()))
+            libbig.show_url(create_account_url(google_account.get_account().GetUsername()))
             if done_with_sleep_state == 0:
                 done_with_sleep_state = 1
 

Modified: trunk/bigboard/stocks/mail/stock.css
==============================================================================
--- trunk/bigboard/stocks/mail/stock.css	(original)
+++ trunk/bigboard/stocks/mail/stock.css	Fri Jun 20 17:59:37 2008
@@ -1,4 +1,4 @@
 .action {
-    font-size: 0.8em;
+    font-size: 1.0em;
     font-style: italic;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]