online-desktop r7263 - in trunk/weblogindriver: . weblogindriver
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: online-desktop r7263 - in trunk/weblogindriver: . weblogindriver
- Date: Mon, 25 Aug 2008 17:57:29 +0000 (UTC)
Author: marinaz
Date: Mon Aug 25 17:57:29 2008
New Revision: 7263
URL: http://svn.gnome.org/viewvc/online-desktop?rev=7263&view=rev
Log:
Change "kind" to "type" all around as it seems to be a less confusing word.
Remove "url" from the keyring properties we store.
Modified:
trunk/weblogindriver/web-login-driver
trunk/weblogindriver/weblogindriver/accounts_dialog.py
trunk/weblogindriver/weblogindriver/keyring.py
Modified: trunk/weblogindriver/web-login-driver
==============================================================================
--- trunk/weblogindriver/web-login-driver (original)
+++ trunk/weblogindriver/web-login-driver Mon Aug 25 17:57:29 2008
@@ -305,20 +305,20 @@
def GetSignon(self, signon):
return self.__signons[signon]
-KIND_GOOGLE = "google"
-KIND_TWITTER = "twitter"
-KIND_RTM = "rtm"
-KIND_LIBRARY_THING = "library"
+TYPE_GOOGLE = "google"
+TYPE_TWITTER = "twitter"
+TYPE_RTM = "rtm"
+TYPE_LIBRARY_THING = "library"
-ONLINE_ACCOUNT_KINDS = {KIND_GOOGLE : "Google", KIND_TWITTER : "Twitter", KIND_RTM : "Remember The Milk", KIND_LIBRARY_THING : "LibraryThing"}
+ONLINE_ACCOUNT_TYPES = {TYPE_GOOGLE : "Google", TYPE_TWITTER : "Twitter", TYPE_RTM : "Remember The Milk", TYPE_LIBRARY_THING : "LibraryThing"}
class OnlineAccount(dbus.service.Object):
- def __init__(self, account_id, bus_name, kind, username, password='', enabled=True, gconf_dir=None):
+ def __init__(self, account_id, bus_name, account_type, username, password='', enabled=True, gconf_dir=None):
dbus.service.Object.__init__(self, object_path = '/onlineaccount/' + str(account_id), bus_name = bus_name)
# TODO: check if dbus.service.Object really doesn't have bus_name as a field
self.__account_id = account_id
self.__bus_name = bus_name
- self.__kind = kind
+ self.__account_type = account_type
self.__username = username
self.__password = password
self.__enabled = enabled
@@ -329,18 +329,18 @@
# copy and deepcopy might not make much sense for this class, since each instance of the class should have
# a unique account_id
def __copy__(self):
- return OnlineAccount(self.__account_id, self.__bus_name, self.__kind, self.__username, self.__password, self.__enabled, self.__gconf_dir)
+ return OnlineAccount(self.__account_id, self.__bus_name, self.__account_type, self.__username, self.__password, self.__enabled, self.__gconf_dir)
def __deepcopy__(self, memo):
return OnlineAccount(copy.deepcopy(self.__account_id, memo), copy.deepcopy(self.__bus_name, memo), \
- copy.deepcopy(self.__kind, memo), copy.deepcopy(self.__username, memo), \
+ copy.deepcopy(self.__account_type, memo), copy.deepcopy(self.__username, memo), \
copy.deepcopy(self.__password, memo), copy.deepcopy(self.__enabled, memo), \
copy.deepcopy(self.__gconf_dir, memo))
@dbus.service.method(OA_BUS_IFACE_STR,
out_signature="s")
- def GetKind(self):
- return self.__kind
+ def GetType(self):
+ return self.__account_type
@dbus.service.method(OA_BUS_IFACE_STR,
out_signature="s")
@@ -397,7 +397,7 @@
self.Changed()
def __str__(self):
- return "<Account userame:%s, kind:%s, gconf_dir:%s, enabled:%s>" % (self.GetUsername(), self.GetKind(), self._get_gconf_dir(), self.GetEnabled())
+ return "<Account userame:%s, type:%s, gconf_dir:%s, enabled:%s>" % (self.GetUsername(), self.GetType(), self._get_gconf_dir(), self.GetEnabled())
_dialog = None
@@ -478,10 +478,10 @@
self.__all_accounts[account.GetObjectPath()] = account
return account
- def __find_weblogin_account(self, kind, username):
+ def __find_weblogin_account(self, account_type, username):
for a in self.__weblogin_accounts:
- _logger.debug("comparing to a weblogin account %s bool %s a.GetKind() %s kind %s" % (a, a.GetKind() == kind, a.GetKind(), kind))
- if a.GetKind() == kind and a.GetUsername() == username:
+ _logger.debug("comparing to a weblogin account %s bool %s a.GetType() %s account_type %s" % (a, a.GetType() == account_type, a.GetType(), account_type))
+ if a.GetType() == account_type and a.GetUsername() == username:
return a
return None
@@ -493,24 +493,24 @@
return None
- def __get_gconf_accounts_by_kind(self, kind):
- gconf_accounts_by_kind = set()
+ def __get_gconf_accounts_by_type(self, account_type):
+ gconf_accounts_by_type = set()
for a in self.__gconf_accounts:
- if a.GetKind() == kind:
- gconf_accounts_by_kind.add(a)
- return gconf_accounts_by_kind
+ if a.GetType() == account_type:
+ gconf_accounts_by_type.add(a)
+ return gconf_accounts_by_type
- def __get_server_accounts_by_kind(self, kind):
- server_accounts_by_kind = set()
+ def __get_server_accounts_by_type(self, account_type):
+ server_accounts_by_type = set()
for a in self.__server_accounts:
- if a.GetKind() == kind:
- server_accounts_by_kind.add(a)
- return server_accounts_by_kind
+ if a.GetType() == account_type:
+ server_accounts_by_type.add(a)
+ return server_accounts_by_type
def __update_account(self, account):
_logger.debug("Updating account %s" % (str(account)))
- ## note that "kind" and "username" are never updated (not allowed to change without
+ ## note that "type" and "username" are never updated (not allowed to change without
## making a new Account object)
was_enabled = account in self.__enabled_accounts
@@ -521,7 +521,7 @@
if account in self.__server_accounts:
self.__ensure_account_in_gconf(account)
- elif account.GetKind() in self.__received_response_from_server:
+ elif account.GetType() in self.__received_response_from_server:
#remove gconf dir if one exists
if gconf_dir:
self.__remove_gconf_dir(gconf_dir)
@@ -558,8 +558,8 @@
## second, look at weblogin driver, though we don't want to prefer
## its password over keyring, so there's some trickiness
weblogin_password = None
- _logger.debug("will look for a weblogin account with kind %s username %s" % (account.GetKind(), account.GetUsername()))
- weblogin_account = self.__find_weblogin_account(account.GetKind(), account.GetUsername())
+ _logger.debug("will look for a weblogin account with type %s username %s" % (account.GetType(), account.GetUsername()))
+ weblogin_account = self.__find_weblogin_account(account.GetType(), account.GetUsername())
if weblogin_account:
_logger.debug("weblogin account found")
weblogin_password = weblogin_account.GetPassword()
@@ -571,9 +571,8 @@
_logger.debug("here 1")
k = keyring.get_keyring()
_logger.debug("here 2")
- password = k.get_password(kind=account.GetKind(),
- username=account.GetUsername(),
- url="")
+ password = k.get_password(account_type=account.GetType(),
+ username=account.GetUsername())
_logger.debug("here 3")
if password:
_logger.debug("using password from keyring")
@@ -621,23 +620,23 @@
return
gconf_info = self.__gconf_info[gconf_dir]
- if 'kind' not in gconf_info or 'username' not in gconf_info:
- _logger.error("gconf account has no kind or username setting")
+ if 'type' not in gconf_info or 'username' not in gconf_info:
+ _logger.error("gconf account has no type or username setting")
self.__remove_gconf_dir(gconf_dir)
return
- kind = gconf_info['kind']
+ account_type = gconf_info['type']
username = gconf_info['username']
- if kind not in ONLINE_ACCOUNT_KINDS.keys():
- _logger.error("unknown account kind in gconf")
+ if account_type not in ONLINE_ACCOUNT_TYPES.keys():
+ _logger.error("unknown account type in gconf")
self.__remove_gconf_dir(gconf_dir)
return
- # account = self.__find_weblogin_account_by_kind(kind)
+ # account = self.__find_weblogin_account_by_type(account_type)
# if account:
# account._update_from_origin({"gconf_dir" : gconf_dir})
# else:
- account = self.__create_online_account(kind, username, gconf_dir=gconf_dir, enabled=False)
+ account = self.__create_online_account(account_type, username, gconf_dir=gconf_dir, enabled=False)
self.__gconf_accounts.add(account)
self.AccountAdded(account.GetObjectPath())
@@ -686,12 +685,12 @@
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))
+ new_google_accounts.add(self.__create_online_account(TYPE_GOOGLE, username))
- self.update_accounts_from_server(KIND_GOOGLE, new_google_accounts)
+ self.update_accounts_from_server(TYPE_GOOGLE, new_google_accounts)
def __update_loved_accounts(self, myself):
- new_accounts_by_kind = {}
+ new_accounts_by_type = {}
new_loved_data_model_accounts = set()
if not hasattr(myself, 'lovedAccounts'):
_logger.debug("No lovedAcccounts in DDM identity")
@@ -701,7 +700,7 @@
for account in myself.lovedAccounts:
accountType = str(account.accountType).lower()
_logger.debug("accountType is %s" % accountType)
- if accountType in ONLINE_ACCOUNT_KINDS:
+ if accountType in ONLINE_ACCOUNT_TYPES:
new_loved_data_model_accounts.add(account)
if account not in self.__loved_data_model_accounts:
_logger.debug("This is a new loved account %s" % account.resource_id)
@@ -709,21 +708,21 @@
account.connect(self.__update_loved_account, "username")
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))
+ if accountType not in new_accounts_by_type:
+ new_accounts_by_type[accountType] = set()
+ new_accounts_by_type[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)
+ _logger.warn("account.username for the account type %s we expect data for is None" % accountType)
- for (key, value) in new_accounts_by_kind.items():
+ for (key, value) in new_accounts_by_type.items():
self.update_accounts_from_server(key, value)
- # make sure we remove accounts for kinds which we no longer are getting from the server,
+ # make sure we remove accounts for types 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():
+ if key != TYPE_GOOGLE and key not in new_accounts_by_type.keys():
self.update_accounts_from_server(key, set())
for account in self.__loved_data_model_accounts:
@@ -743,8 +742,8 @@
query.add_error_handler(self.__on_datamodel_error)
query.execute()
- def update_accounts_from_server(self, account_kind, new_accounts):
- existing_accounts = self.__get_server_accounts_by_kind(account_kind)
+ def update_accounts_from_server(self, account_type, new_accounts):
+ existing_accounts = self.__get_server_accounts_by_type(account_type)
for new_account in new_accounts:
# if acccount already in the list of server_accounts, don't do anything
@@ -760,7 +759,7 @@
break
if not account_found:
- new_account_to_add = self.__find_account_in_gconf(new_account.GetKind(), new_account.GetUsername())
+ new_account_to_add = self.__find_account_in_gconf(new_account.GetType(), new_account.GetUsername())
if new_account_to_add is None:
new_account_to_add = new_account # we used to use copy.deepcopy here, not sure we need it
self.__server_accounts.add(new_account_to_add)
@@ -768,9 +767,9 @@
# we have a password for it
self.__update_account(new_account_to_add)
- self.__received_response_from_server.add(account_kind)
+ self.__received_response_from_server.add(account_type)
- # clear out accounts that are no longer found in the list of accounts of this kind from the server
+ # clear out accounts that are no longer found in the list of accounts of this type from the server
for existing_account in existing_accounts:
self.__server_accounts.remove(existing_account)
# this should remove the account from gconf and gconf_accounts
@@ -778,8 +777,8 @@
# make sure that all accounts in gconf correspond to the ones returned from the server;
# this will remove old accounts from gconf
- existing_accounts_in_gconf = self.__get_gconf_accounts_by_kind(account_kind)
- _logger.debug("existing_accounts_in_gconf of type %s: %d" % (account_kind, len(existing_accounts_in_gconf)))
+ existing_accounts_in_gconf = self.__get_gconf_accounts_by_type(account_type)
+ _logger.debug("existing_accounts_in_gconf of type %s: %d" % (account_type, len(existing_accounts_in_gconf)))
for gconf_account in existing_accounts_in_gconf:
self.__update_account(gconf_account)
@@ -794,7 +793,7 @@
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, 'type')
get_account_prop(self.__gconf, gconf_info, base_key, 'username')
get_account_prop(self.__gconf, gconf_info, base_key, 'enabled')
# GConf returns None for get_value if the vale is False
@@ -857,10 +856,10 @@
username = str(signon['username']) + "@gmail.com"
password = base64.b64decode(signon['password'])
_logger.debug("got signon information %s" % str(signon))
- account = self.__find_weblogin_account(KIND_GOOGLE, username)
+ account = self.__find_weblogin_account(TYPE_GOOGLE, username)
_logger.debug("found weblogin account %s" % str(account))
if not account:
- account = self.__create_online_account(KIND_GOOGLE, username, enabled=False, password=password)
+ account = self.__create_online_account(TYPE_GOOGLE, username, enabled=False, password=password)
self.__weblogin_accounts.add(account)
self.__update_account(account)
elif password != account.GetPassword():
@@ -891,20 +890,20 @@
def __on_dbus_error(self, err):
self.__logger.error("D-BUS error: %s", err)
- def __find_unused_gconf_dir(self, kind):
+ def __find_unused_gconf_dir(self, account_type):
## find an unused gconf dir
i = 0
while True:
- gconf_dir = kind + "_" + str(i)
+ gconf_dir = account_type + "_" + str(i)
if not self.__find_account_by_gconf_dir(gconf_dir):
_logger.debug("returning %s for unused gconf_dir" % gconf_dir)
return gconf_dir
else:
i = i + 1
- def __find_account_in_gconf(self, kind, username):
+ def __find_account_in_gconf(self, account_type, username):
for a in self.__gconf_accounts:
- if a.GetKind() == kind and a.GetUsername() == username:
+ if a.GetType() == account_type and a.GetUsername() == username:
return a
return None
@@ -919,11 +918,11 @@
# create a new GConf dir if it is a completely new account
if not gconf_dir:
- if self.__find_account_in_gconf(account.GetKind(), account.GetUsername()):
+ if self.__find_account_in_gconf(account.GetType(), account.GetUsername()):
_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.GetKind())
+ gconf_dir = self.__find_unused_gconf_dir(account.GetType())
new_gconf_dir = True
account._update_from_origin({"gconf_dir" : gconf_dir})
self.__gconf_accounts.add(account)
@@ -944,7 +943,7 @@
_logger.error("prop %s with value %s has an unexpected type %s" % (prop, str(value), type(value)))
if new_gconf_dir:
- set_account_prop(base_key, 'kind', account.GetKind())
+ set_account_prop(base_key, 'type', account.GetType())
set_account_prop(base_key, 'username', account.GetUsername())
## enable it last, so we ignore the other settings until we do this
@@ -982,14 +981,12 @@
## special-case handling of password since it goes in the keyring
if 'password' in properties:
- username = account.GetUsername()
- url=''
+ username = account.GetUsername()
_logger.debug("here 4")
k = keyring.get_keyring()
_logger.debug("here 5")
- k.store_login(kind=account.GetKind(),
+ k.store_login(account_type=account.GetType(),
username=username,
- url=url,
password=properties['password'])
_logger.debug("here 6")
@@ -1007,14 +1004,14 @@
@dbus.service.method(OA_BUS_IFACE_STR,
in_signature="ss",
out_signature="(ob)")
- def GetOrCreateAccount(self, kind, username):
- kind = str(kind)
+ def GetOrCreateAccount(self, account_type, username):
+ account_type = str(account_type)
username = str(username)
- account = self.__find_account_in_gconf(kind, username)
+ account = self.__find_account_in_gconf(account_type, username)
if account:
return (account.GetObjectPath(), False)
- account = self.__create_online_account(kind, username)
+ account = self.__create_online_account(account_type, username)
self.__ensure_account_in_gconf(account)
self.__update_account(account) # this might find a password for the account and emit AccountEnabled signal
return (account.GetObjectPath(), True)
@@ -1053,9 +1050,9 @@
@dbus.service.method(OA_BUS_IFACE_STR,
in_signature="as",
out_signature="ao")
- def GetEnabledAccountsWithKinds(self, kinds):
+ def GetEnabledAccountsWithTypes(self, account_types):
object_paths_list = [a.GetObjectPath() for a in \
- filter(lambda account: account.GetKind() in kinds, self.__enabled_accounts)]
+ filter(lambda account: account.GetType() in account_types, self.__enabled_accounts)]
return object_paths_list
@dbus.service.method(OA_BUS_IFACE_STR,
@@ -1069,16 +1066,16 @@
@dbus.service.method(OA_BUS_IFACE_STR,
in_signature="as",
out_signature="ao")
- def GetAllAccountsWithKinds(self, kinds):
+ def GetAllAccountsWithTypes(self, account_types):
object_paths_list = [a.GetObjectPath() for a in \
- filter(lambda account: account.GetKind() in kinds, self.__gconf_accounts)]
+ filter(lambda account: account.GetType() in account_types, self.__gconf_accounts)]
return object_paths_list
@dbus.service.method(OA_BUS_IFACE_STR,
out_signature="a{ss}")
- def GetAllAccountKinds(self):
- _logger.debug("in GetAllAccountKinds")
- return ONLINE_ACCOUNT_KINDS
+ def GetAllAccountTypes(self):
+ _logger.debug("in GetAllAccountTypes")
+ return ONLINE_ACCOUNT_TYPES
@dbus.service.method(OA_BUS_IFACE_STR)
def OpenAccountsDialog(self):
@@ -1090,11 +1087,11 @@
@dbus.service.method(OA_BUS_IFACE_STR,
in_signature="as")
- def OpenAccountsDialogWithKinds(self, accountKinds):
+ def OpenAccountsDialogWithTypes(self, account_types):
global _dialog
if _dialog:
_dialog.destroy()
- _dialog = accounts_dialog.Dialog(accountKinds, self)
+ _dialog = accounts_dialog.Dialog(account_types, self)
_dialog.present()
_driver = None
Modified: trunk/weblogindriver/weblogindriver/accounts_dialog.py
==============================================================================
--- trunk/weblogindriver/weblogindriver/accounts_dialog.py (original)
+++ trunk/weblogindriver/weblogindriver/accounts_dialog.py Mon Aug 25 17:57:29 2008
@@ -8,7 +8,7 @@
_logger = logging.getLogger("weblogindriver.AccountsDialog")
class Dialog(gtk.Window):
- def __init__(self, account_kinds, online_accounts_service, *args, **kwargs):
+ def __init__(self, account_types, online_accounts_service, *args, **kwargs):
super(Dialog, self).__init__(*args, **kwargs)
self.__online_accounts_service = online_accounts_service
@@ -20,7 +20,7 @@
_logger.error("onlineaccounts DBus service not available, can't manage accounts")
return
- self.__account_kinds = account_kinds
+ self.__account_types = account_types
self.set_title('Accounts')
self.set_position(gtk.WIN_POS_CENTER)
@@ -124,28 +124,28 @@
# stuff below gets added to the "Add Account" tab
- self.__account_kinds_model = gtk.ListStore(gobject.TYPE_STRING)
- self.__account_kinds_combo = gtk.ComboBox(self.__account_kinds_model)
- self.__new_account_vbox.pack_start(self.__account_kinds_combo, True, False)
- 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)
+ self.__account_types_model = gtk.ListStore(gobject.TYPE_STRING)
+ self.__account_types_combo = gtk.ComboBox(self.__account_types_model)
+ self.__new_account_vbox.pack_start(self.__account_types_combo, True, False)
+ account_types_textrender = gtk.CellRendererText()
+ self.__account_types_combo.pack_start(account_types_textrender, True)
+ self.__account_types_combo.add_attribute(account_types_textrender, 'text', 0)
- _logger.debug("will get accounts kinds")
- self.__all_account_kinds = self.__online_accounts_service.GetAllAccountKinds()
- _logger.debug("will get accounts kinds 2")
+ _logger.debug("will get accounts types")
+ self.__all_account_types = self.__online_accounts_service.GetAllAccountTypes()
+ _logger.debug("will get accounts types 2")
# 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])
+ # for type_full_name in self.__all_account_types.values():
+ # self.__account_types_model.append([type_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
# the existing dialog, for example, by adding stocks that require these account types
padding = 1
- if len(self.__account_kinds_model) > 0:
- self.__account_kinds_combo.set_active(0)
+ if len(self.__account_types_model) > 0:
+ self.__account_types_combo.set_active(0)
padding = 5
self.__username_entry = gtk.Entry()
@@ -175,15 +175,15 @@
self.__add_link_box = gtk.HBox()
self.__add_link = Link()
self.__add_link.connect("clicked", self.__open_account_page)
- if len(self.__account_kinds_model) > 0:
- self.__account_kinds_combo.set_active(0)
+ if len(self.__account_types_model) > 0:
+ self.__account_types_combo.set_active(0)
self.__add_link.set_text("Add other accounts online")
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 self.__account_kinds and len(self.__account_kinds) == 1 and \
- self.__account_kinds[0] in self.__all_account_kinds.keys():
- self.__add_link.set_text("Add " + self.__all_account_kinds[self.__account_kinds[0]] + " accounts online")
+ if self.__account_types and len(self.__account_types) == 1 and \
+ self.__account_types[0] in self.__all_account_types.keys():
+ self.__add_link.set_text("Add " + self.__all_account_types[self.__account_types[0]] + " accounts online")
else:
self.__add_link.set_text("Add accounts online")
self.__add_link_box.pack_start(self.__add_link)
@@ -195,15 +195,15 @@
self.show_all()
self.__set_no_accounts_state(True)
- if len(self.__account_kinds_model) == 0:
- self.__account_kinds_combo.hide()
+ if len(self.__account_types_model) == 0:
+ self.__account_types_combo.hide()
self.__username_label.hide()
self.__username_entry.hide()
self.__add_button.hide()
self.__notebook.set_current_page(1)
- # google_accounts = self.__online_accounts_service.GetAllAccountsWithKinds(["google"])
+ # google_accounts = self.__online_accounts_service.GetAllAccountsWithTypes(["google"])
all_account_paths = self.__online_accounts_service.GetAllAccounts()
if len(all_account_paths) == 0:
# TODO: do something else
@@ -225,18 +225,18 @@
gnome.url_show(urlparse.urljoin(get_baseurl(), "/account"))
def __on_account_added(self, a_path):
- # TODO: check for account kind when we have a per-account dialog
+ # TODO: check for account type when we have a per-account dialog
if a_path not in self.__model_tree_iter_by_account:
a = self.__online_accounts_service.get_existing_account(a_path)
if a is None:
_logger.error("onlineaccount for path %s was not found" % a_path)
return
- if self.__account_kinds and a.GetKind() not in self.__account_kinds:
+ if self.__account_types and a.GetType() not in self.__account_types:
return
_logger.debug("account added %s" % a)
- tree_iter = self.__model.append([self.__all_account_kinds[a.GetKind()] + ': ' + a.GetUsername()])
+ tree_iter = self.__model.append([self.__all_account_types[a.GetType()] + ': ' + a.GetUsername()])
self.__model_tree_iter_by_account[a_path] = tree_iter
@@ -339,10 +339,10 @@
if not username_entered:
return
- current_iter = self.__account_kinds_combo.get_active_iter()
- 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.__online_accounts_service.GetOrCreateAccount(kind, text)
+ current_iter = self.__account_types_combo.get_active_iter()
+ for (account_type, type_full_name) in self.__all_account_types:
+ if self.__account_types_model.get_value(current_iter, 0) == type_full_name:
+ account_tuple = self.__online_accounts_service.GetOrCreateAccount(account_type, 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
@@ -358,7 +358,7 @@
self.__accounts_combo.set_active_iter(account_iter)
return
- _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))
+ _logger.warn("Did not find an account type that matched the account type in the dropdown %s" % self.__account_types_model.get_value(current_iter, 0))
def __on_delete_event(self, dialog, event):
self.hide()
Modified: trunk/weblogindriver/weblogindriver/keyring.py
==============================================================================
--- trunk/weblogindriver/weblogindriver/keyring.py (original)
+++ trunk/weblogindriver/weblogindriver/keyring.py Mon Aug 25 17:57:29 2008
@@ -3,41 +3,34 @@
_logger = logging.getLogger("weblogindriver.Keyring")
class KeyringItem(object):
- def __init__(self, kind, username='', url='', password=''):
+ def __init__(self, account_type, username='', password=''):
super(KeyringItem, self).__init__()
- self.__kind = kind
+ self.__account_type = account_type
self.__username = username
- self.__url = url
self.__password = password
- def get_kind(self):
- return self.__kind
+ def get_type(self):
+ return self.__account_type
def get_username(self):
return self.__username
- def get_url(self):
- return self.__url
-
def get_password(self):
return self.__password
- def set_kind(self, kind):
- self.__kind = kind
+ def set_type(self, account_type):
+ self.__account_type = account_type
def set_username(self, username):
self.__username = username
- def set_url(self, url):
- self.__url = url
-
def set_password(self, password):
self.__password = password
def __repr__(self):
- return '{kind=%s username=%s url=%s len(password)=%d}' % (self.__kind, self.__username, self.__url, len(self.__password))
+ return '{account_type=%s username=%s len(password)=%d}' % (self.__account_type, self.__username, len(self.__password))
-### The keyring is a map from the tuple (kind,username,url) to a password.
+### The keyring is a map from the tuple (type,username) to a password.
### In gnome-keyring itself we add to the tuple appname=WebLoginDriver
class Keyring:
def __init__(self, is_singleton):
@@ -52,51 +45,45 @@
return gnomekeyring.is_available()
# Returns a set of KeyringItem
- def get_logins(self, kind, username, url):
+ def get_logins(self, account_type, username):
matches = set()
if not self.is_available():
for ki in self.__fallback_items:
- if ki.get_kind() == kind and \
- ki.get_username() == username and \
- ki.get_url() == url:
+ if ki.get_type() == account_type and \
+ ki.get_username() == username:
matches.add(ki)
-
else:
-
try:
found = gnomekeyring.find_items_sync(gnomekeyring.ITEM_GENERIC_SECRET,
dict(appname='WebLoginDriver',
- kind=kind,
- username=username,
- url=url))
+ type=account_type,
+ username=username))
except gnomekeyring.NoMatchError:
found = set()
for f in found:
- ki = KeyringItem(kind=f.attributes['kind'],
+ ki = KeyringItem(account_type=f.attributes['type'],
username=f.attributes['username'],
- url=f.attributes['url'],
password=f.secret)
matches.add(ki)
return matches
- def get_password(self, kind, username, url):
- logins = self.get_logins(kind, username, url)
+ def get_password(self, account_type, username):
+ logins = self.get_logins(account_type, username)
_logger.debug("got logins: %s" % (str(logins)))
if len(logins) > 0:
return logins.pop().get_password()
else:
return None
- def remove_logins(self, kind, username, url):
- _logger.debug("removing login (%s, %s, %s)" % (kind, username, url))
+ def remove_logins(self, account_type, username):
+ _logger.debug("removing login (%s, %s)" % (account_type, username))
new_fallbacks = set()
for ki in self.__fallback_items:
- if ki.get_kind() == kind and \
- ki.get_username() == username and \
- ki.get_url() == url:
+ if ki.get_type() == account_type and \
+ ki.get_username() == username:
pass
else:
new_fallbacks.add(ki)
@@ -107,36 +94,33 @@
try:
found = gnomekeyring.find_items_sync(gnomekeyring.ITEM_GENERIC_SECRET,
dict(appname='WebLoginDriver',
- kind=kind,
- username=username,
- url=url))
+ type=account_type,
+ username=username))
except gnomekeyring.NoMatchError:
found = set()
for f in found:
gnomekeyring.item_delete_sync('session', f.item_id)
- def store_login(self, kind, username, url, password):
+ def store_login(self, account_type, username, password):
if not password:
- self.remove_logins(kind, username, url)
+ self.remove_logins(account_type, username)
return
- _logger.debug("storing login (%s, %s, %s)" % (kind, username, url))
+ _logger.debug("storing login (%s, %s)" % (account_type, username))
if not self.is_available():
found = None
for ki in self.__fallback_items:
- if ki.get_kind() == kind and \
- ki.get_username() == username and \
- ki.get_url() == url:
+ if ki.get_type() == account_type and \
+ ki.get_username() == username:
found = ki
if found:
found.set_password(password)
else:
- ki = KeyringItem(kind=kind,
+ ki = KeyringItem(account_type=account_type,
username=username,
- url=url,
password=password)
self.__fallback_items.add(ki)
@@ -145,9 +129,8 @@
gnomekeyring.ITEM_GENERIC_SECRET,
"WebLoginDriver",
dict(appname="WebLoginDriver",
- kind=kind,
- username=username,
- url=url),
+ type=account_type,
+ username=username),
password, True)
keyring_inst = None
@@ -164,12 +147,10 @@
print ring.is_available()
print "storing"
- ring.store_login(kind='google', username='havoc pennington+foo gmail com',
- url='http://google.com/', password='frob')
+ ring.store_login(account_type='google', username='havoc pennington+foo gmail com', password='frob')
print "getting"
- print ring.get_logins(kind='google', username='havoc pennington+foo gmail com',
- url='http://google.com/')
+ print ring.get_logins(account_type='google', username='havoc pennington+foo gmail com')
print "done"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]