no need to do gnomekeyring -> libsecret conversion when using proper schema
This commit is contained in:
parent
a22a9573b8
commit
62bf23a587
|
@ -158,11 +158,12 @@ class GnomePasswordStorage(PasswordStorage):
|
||||||
|
|
||||||
class SecretPasswordStorage(PasswordStorage):
|
class SecretPasswordStorage(PasswordStorage):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.GAJIM_SCHEMA = Secret.Schema.new("Gajim",
|
self.GAJIM_SCHEMA = Secret.Schema.new("org.gnome.keyring.NetworkPassword",
|
||||||
Secret.SchemaFlags.NONE,
|
Secret.SchemaFlags.NONE,
|
||||||
{
|
{
|
||||||
'user': Secret.SchemaAttributeType.STRING,
|
'user': Secret.SchemaAttributeType.STRING,
|
||||||
'server': Secret.SchemaAttributeType.STRING,
|
'server': Secret.SchemaAttributeType.STRING,
|
||||||
|
'protocol': Secret.SchemaAttributeType.STRING,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -177,27 +178,7 @@ class SecretPasswordStorage(PasswordStorage):
|
||||||
password = kw_storage.get_password(account_name)
|
password = kw_storage.get_password(account_name)
|
||||||
self.save_password(account_name, password)
|
self.save_password(account_name, password)
|
||||||
return password
|
return password
|
||||||
if conf.startswith('gnomekeyring:'):
|
if not (conf.startswith('libsecret:') or conf.startswith('gnomekeyring:')):
|
||||||
# migrate from libgnomekeyring
|
|
||||||
GnomePasswordStorage
|
|
||||||
global GnomeKeyring
|
|
||||||
global USER_HAS_GNOMEKEYRING
|
|
||||||
if not USER_HAS_GNOMEKEYRING:
|
|
||||||
try:
|
|
||||||
gir = __import__('gi.repository', globals(), locals(),
|
|
||||||
['GnomeKeyring'], 0)
|
|
||||||
GnomeKeyring = gir.GnomeKeyring
|
|
||||||
except (ImportError, AttributeError):
|
|
||||||
return False
|
|
||||||
USER_HAS_GNOMEKEYRING = True
|
|
||||||
try:
|
|
||||||
gk_storage = GnomePasswordStorage()
|
|
||||||
except GnomeKeyringError:
|
|
||||||
return None
|
|
||||||
password = gk_storage.get_password(account_name)
|
|
||||||
self.save_password(account_name, password)
|
|
||||||
return password
|
|
||||||
if not conf.startswith('libsecret:'):
|
|
||||||
password = conf
|
password = conf
|
||||||
## migrate the password over to keyring
|
## migrate the password over to keyring
|
||||||
try:
|
try:
|
||||||
|
@ -209,7 +190,7 @@ class SecretPasswordStorage(PasswordStorage):
|
||||||
server = gajim.config.get_per('accounts', account_name, 'hostname')
|
server = gajim.config.get_per('accounts', account_name, 'hostname')
|
||||||
user = gajim.config.get_per('accounts', account_name, 'name')
|
user = gajim.config.get_per('accounts', account_name, 'name')
|
||||||
password = Secret.password_lookup_sync(self.GAJIM_SCHEMA, {'user': user,
|
password = Secret.password_lookup_sync(self.GAJIM_SCHEMA, {'user': user,
|
||||||
'server': server}, None)
|
'server': server, 'protocol': 'xmpp'}, None)
|
||||||
return password
|
return password
|
||||||
|
|
||||||
def save_password(self, account_name, password, update=True):
|
def save_password(self, account_name, password, update=True):
|
||||||
|
@ -218,7 +199,7 @@ class SecretPasswordStorage(PasswordStorage):
|
||||||
display_name = _('XMPP account %s@%s') % (user, server)
|
display_name = _('XMPP account %s@%s') % (user, server)
|
||||||
if password is None:
|
if password is None:
|
||||||
password = str()
|
password = str()
|
||||||
attributes = {'user': user, 'server': server}
|
attributes = {'user': user, 'server': server, 'protocol': 'xmpp'}
|
||||||
Secret.password_store_sync(self.GAJIM_SCHEMA, attributes,
|
Secret.password_store_sync(self.GAJIM_SCHEMA, attributes,
|
||||||
Secret.COLLECTION_DEFAULT, display_name, password, None)
|
Secret.COLLECTION_DEFAULT, display_name, password, None)
|
||||||
gajim.config.set_per('accounts', account_name, 'password',
|
gajim.config.set_per('accounts', account_name, 'password',
|
||||||
|
|
Loading…
Reference in New Issue