def get_storage(): global storage if storage is None: # None is only in first time get_storage is called if gajim.config.get("use_gnomekeyring"): global gnomekeyring try: gnomekeyring = __import__("gnomekeyring") except ImportError: pass else: global USER_HAS_GNOMEKEYRING global USER_USES_GNOMEKEYRING USER_HAS_GNOMEKEYRING = True if gnomekeyring.is_available(): USER_USES_GNOMEKEYRING = True else: USER_USES_GNOMEKEYRING = False if USER_USES_GNOMEKEYRING: try: storage = GnomePasswordStorage() except (gnomekeyring.NoKeyringDaemonError, gnomekeyring.DeniedError, gnomekeyring.CancelledError): storage = None if storage is None: if gajim.config.get("use_kwalletcli"): global USER_HAS_KWALLETCLI if kwalletbinding.kwallet_available(): USER_HAS_KWALLETCLI = True if USER_HAS_KWALLETCLI: storage = KWalletPasswordStorage() if storage is None: storage = SimplePasswordStorage() return storage
def get_password(self, account_name): conf = gajim.config.get_per('accounts', account_name, 'password') if conf is None: return None if conf == '<kwallet>': # Migrate from kwallet if kwalletbinding.kwallet_available(): kw_storage = KWalletPasswordStorage() password = kw_storage.get_password(account_name) self.save_password(account_name, password) return password if not (conf.startswith('libsecret:') or conf.startswith('gnomekeyring:')): password = conf ## migrate the password over to keyring try: self.save_password(account_name, password, update=False) except Exception: ## no keyring daemon: in the future, stop using it set_storage(SimplePasswordStorage()) return password server = gajim.config.get_per('accounts', account_name, 'hostname') user = gajim.config.get_per('accounts', account_name, 'name') password = Secret.password_lookup_sync(self.GAJIM_SCHEMA, {'user': user, 'server': server, 'protocol': 'xmpp'}, None) return password
def get_password(self, account_name): conf = gajim.config.get_per('accounts', account_name, 'password') if conf is None: return None if conf == '<kwallet>': # Migrate from kwallet if kwalletbinding.kwallet_available(): kw_storage = KWalletPasswordStorage() password = kw_storage.get_password(account_name) self.save_password(account_name, password) return password if not (conf.startswith('libsecret:') or conf.startswith('gnomekeyring:')): password = conf ## migrate the password over to keyring try: self.save_password(account_name, password, update=False) except Exception: ## no keyring daemon: in the future, stop using it set_storage(SimplePasswordStorage()) return password server = gajim.config.get_per('accounts', account_name, 'hostname') user = gajim.config.get_per('accounts', account_name, 'name') password = Secret.password_lookup_sync(self.GAJIM_SCHEMA, { 'user': user, 'server': server, 'protocol': 'xmpp' }, None) return password
def get_storage(): global storage if storage is None: # None is only in first time get_storage is called if gajim.config.get('use_gnomekeyring'): global GnomeKeyring try: gir = __import__('gi.repository', globals(), locals(), ['GnomeKeyring'], 0) GnomeKeyring = gir.GnomeKeyring except (ImportError, AttributeError): pass else: global USER_HAS_GNOMEKEYRING global USER_USES_GNOMEKEYRING USER_HAS_GNOMEKEYRING = True if GnomeKeyring.is_available(): USER_USES_GNOMEKEYRING = True else: USER_USES_GNOMEKEYRING = False if USER_USES_GNOMEKEYRING: try: storage = GnomePasswordStorage() except GnomeKeyringError: storage = None if storage is None: if gajim.config.get('use_kwalletcli'): global USER_HAS_KWALLETCLI if kwalletbinding.kwallet_available(): USER_HAS_KWALLETCLI = True if USER_HAS_KWALLETCLI: storage = KWalletPasswordStorage() if storage is None: storage = SimplePasswordStorage() return storage
def some_keyring_available(self): if os.name == 'nt': return False if kwalletbinding.kwallet_available(): return True try: __import__('gnomekeyring') except Exception: return False return True
def some_keyring_available(self): if os.name == 'nt': return False if kwalletbinding.kwallet_available(): return True try: from gi.repository import GnomeKeyring except Exception: return False return True
def some_keyring_available(self): if os.name == 'nt': return False if kwalletbinding.kwallet_available(): return True try: gi.require_version('GnomeKeyring', '1.0') from gi.repository import GnomeKeyring except Exception: return False return True
def get_storage(): global storage if storage is None: # None is only in first time get_storage is called if gajim.config.get('use_gnomekeyring'): global Secret try: gi.require_version('Secret', '1') gir = __import__('gi.repository', globals(), locals(), ['Secret'], 0) Secret = gir.Secret except (ValueError, AttributeError): global GnomeKeyring try: gir = __import__('gi.repository', globals(), locals(), ['GnomeKeyring'], 0) GnomeKeyring = gir.GnomeKeyring except (ImportError, AttributeError): pass else: global USER_HAS_GNOMEKEYRING global USER_USES_GNOMEKEYRING USER_HAS_GNOMEKEYRING = True if GnomeKeyring.is_available(): USER_USES_GNOMEKEYRING = True else: USER_USES_GNOMEKEYRING = False else: global USER_HAS_LIBSECRET USER_HAS_LIBSECRET = True if USER_HAS_LIBSECRET: try: storage = SecretPasswordStorage() return storage except Exception: storage = None if USER_USES_GNOMEKEYRING: try: storage = GnomePasswordStorage() except GnomeKeyringError: storage = None if storage is None: if gajim.config.get('use_kwalletcli'): global USER_HAS_KWALLETCLI if kwalletbinding.kwallet_available(): USER_HAS_KWALLETCLI = True if USER_HAS_KWALLETCLI: storage = KWalletPasswordStorage() if storage is None: storage = SimplePasswordStorage() return storage