online-desktop r7257 - trunk/weblogindriver
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: online-desktop r7257 - trunk/weblogindriver
- Date: Tue, 24 Jun 2008 17:14:39 +0000 (UTC)
Author: marinaz
Date: Tue Jun 24 17:14:38 2008
New Revision: 7257
URL: http://svn.gnome.org/viewvc/online-desktop?rev=7257&view=rev
Log:
Get external accounts from server in the web login driver.
Modified:
trunk/weblogindriver/web-login-driver
Modified: trunk/weblogindriver/web-login-driver
==============================================================================
--- trunk/weblogindriver/web-login-driver (original)
+++ trunk/weblogindriver/web-login-driver Tue Jun 24 17:14:38 2008
@@ -644,18 +644,29 @@
if self.__model.self_resource != None:
_logger.debug("will get online desktop accounts")
# TODO: get all gnomeExternalAccounts here later, googleEnabledEmails is just one case
- query = self.__model.query_resource(self.__model.self_resource, "googleEnabledEmails +")
- query.add_handler(self.__on_google_enabled_emails)
+ query = self.__model.query_resource(self.__model.self_resource, "googleEnabledEmails; lovedAccounts +")
+ query.add_handler(self.__on_datamodel_response)
query.add_error_handler(self.__on_datamodel_error)
query.execute()
+
+ # query = self.__model.query_resource(self.__model.self_resource, "lovedAccounts +")
+ # query.add_handler(self.__on_loved_accounts)
+ # query.execute()
def __on_datamodel_error(self, code, str):
_logger.error("datamodel error %s: %s", code, str)
- def __on_google_enabled_emails(self, myself):
- _logger.debug("received some google enabled emails")
+ def __on_datamodel_response(self, myself):
+ _logger.debug("received data model response")
myself.connect(self.__update_google_enabled_emails, 'googleEnabledEmails')
+ myself.connect(self.__update_loved_accounts, 'lovedAccounts')
self.__update_google_enabled_emails(myself)
+ self.__update_loved_accounts(myself)
+
+ # def __on_loved_accounts(self, myself):
+ # _logger.debug("received some loved accounts")
+ # myself.connect(self.__update_loved_accounts, 'lovedAccounts')
+ # self.__update_loved_accounts(myself)
def __update_google_enabled_emails(self, myself):
new_google_accounts = set()
@@ -665,12 +676,42 @@
_logger.debug("DDM identity has 0 googleEnabledEmails")
else:
for email in myself.googleEnabledEmails:
- username = str(email)
- _logger.debug("got a googleEnabledEmail %s", email)
- new_google_accounts.add(self.__create_online_account(KIND_GOOGLE, username))
+ username = str(email)
+ _logger.debug("got a googleEnabledEmail %s", email)
+ new_google_accounts.add(self.__create_online_account(KIND_GOOGLE, username))
self.update_accounts_from_server(KIND_GOOGLE, new_google_accounts)
+
+ def __update_loved_accounts(self, myself):
+ new_accounts_by_kind = {}
+ if not hasattr(myself, 'lovedAccounts'):
+ _logger.debug("No lovedAcccounts in DDM identity")
+ elif len(myself.lovedAccounts) == 0:
+ _logger.debug("DDM identity has 0 lovedAccounts")
+ else:
+ for account in myself.lovedAccounts:
+ accountType = str(account.accountType).lower()
+ _logger.debug("accountType is %s" % accountType)
+ if accountType in ONLINE_ACCOUNT_KINDS:
+ if account.username:
+ username = str(account.username)
+ if accountType not in new_accounts_by_kind:
+ new_accounts_by_kind[accountType] = set()
+ new_accounts_by_kind[accountType].add(self.__create_online_account(accountType, username))
+ _logger.debug("got username %s", username)
+ else:
+ _logger.warn("account.username for the account kind %s we expect data for is None" % accountType)
+
+ for (key, value) in new_accounts_by_kind.items():
+ self.update_accounts_from_server(key, value)
+ # make sure we remove accounts for kinds which we no longer are getting from the server,
+ # this will do it repeatedly since we never reset what's in self.__received_response_from_server,
+ # but that's ok
+ for key in self.__received_response_from_server:
+ if key != KIND_GOOGLE and key not in new_accounts_by_kind.keys():
+ self.update_accounts_from_server(key, set())
+
def update_accounts_from_server(self, account_kind, new_accounts):
existing_accounts = self.__get_server_accounts_by_kind(account_kind)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]