Add config setting for use of keyring

This commit is contained in:
Philipp Hörist 2017-01-23 19:02:21 +01:00
parent 5a2a83a3fd
commit e41a751c7b
2 changed files with 17 additions and 13 deletions

View file

@ -314,6 +314,7 @@ class Config:
'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')], 'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')],
'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')], 'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')],
'show_avatar_in_tabs': [ opt_bool, False, _('Show a mini avatar in chat window tabs and in window icon')], 'show_avatar_in_tabs': [ opt_bool, False, _('Show a mini avatar in chat window tabs and in window icon')],
'use_keyring': [opt_bool, True, _('If True, Gajim will use the Systems Keyring to store account passwords.')],
}, {}) }, {})
__options_per_key = { __options_per_key = {

View file

@ -140,19 +140,22 @@ def get_storage():
global storage global storage
if storage is None: # None is only in first time get_storage is called if storage is None: # None is only in first time get_storage is called
global Secret global Secret
try: if gajim.config.get('use_keyring'):
gi.require_version('Secret', '1') try:
gir = __import__('gi.repository', globals(), locals(), gi.require_version('Secret', '1')
['Secret'], 0) gir = __import__('gi.repository', globals(), locals(),
Secret = gir.Secret ['Secret'], 0)
except (ValueError, AttributeError): Secret = gir.Secret
pass except (ValueError, AttributeError):
try: pass
if os.name != 'nt': try:
storage = SecretPasswordStorage() if os.name != 'nt':
else: storage = SecretPasswordStorage()
storage = SecretWindowsPasswordStorage() else:
except Exception: storage = SecretWindowsPasswordStorage()
except Exception:
storage = SimplePasswordStorage()
else:
storage = SimplePasswordStorage() storage = SimplePasswordStorage()
return storage return storage