Ticket #3631: gajim-keyring.diff
| File gajim-keyring.diff, 1.9 kB (added by asterix, 11 months ago) |
|---|
-
src/common/passwords.py
19 19 20 20 __all__ = ['get_password', 'save_password'] 21 21 22 import warnings 22 23 from common import gajim 23 24 24 25 USER_HAS_GNOMEKEYRING = False … … 62 63 conf = gajim.config.get_per('accounts', account_name, 'password') 63 64 if conf is None: 64 65 return None 65 try: 66 unused, auth_token = conf.split('gnomekeyring:') 67 auth_token = int(auth_token) 68 except ValueError: 66 67 if not conf.startswith('gnomekeyring:'): 69 68 password = conf 70 69 ## migrate the password over to keyring 71 70 try: … … 75 74 set_storage(SimplePasswordStorage()) 76 75 return password 77 76 try: 78 return gnomekeyring.item_get_info_sync(self.keyring, 79 auth_token).get_secret() 77 attributes = dict(account_name=str(account_name), gajim=1) 78 try: 79 items = gnomekeyring.find_items_sync( 80 gnomekeyring.ITEM_GENERIC_SECRET, 81 attributes) 82 except gnomekeyring.Error: 83 items = [] 84 if len(items) > 1: 85 warnings.warn("multiple gnome keyring items found for account %s;" 86 " trying to use the first one..." 87 % account_name) 88 if items: 89 return items[0].secret 90 else: 91 return None 80 92 except gnomekeyring.DeniedError: 81 93 return None 82 94 except gnomekeyring.NoKeyringDaemonError: … … 95 107 set_storage(SimplePasswordStorage()) 96 108 storage.save_password(account_name, password) 97 109 return 98 token = 'gnomekeyring:%i' % auth_token99 gajim.config.set_per('accounts', account_name, 'password', token)110 ## Note: the auth token is in fact no longer used for anything 111 gajim.config.set_per('accounts', account_name, 'password', 'gnomekeyring:') 100 112 if gajim.connections.has_key(account_name): 101 113 gajim.connections[account_name].password = password 102 114
