Commit e4cd9205 authored by jo-so's avatar jo-so

PasswordStorageManager: Merge methods in __init__

The body of the methods `connect_backends` and `set_preferred_backend` is
so small, that it has more value to see all these code in `__init__`
instead of scattered across methods.
parent f13ff8ac
......@@ -74,20 +74,16 @@ class PasswordStorageManager(PasswordStorage):
Also implements storing directly in gajim config."""
def __init__(self):
self.preferred_backend = None
self.secret = None
self.connect_backends()
self.set_preferred_backend()
def connect_backends(self):
"""Initialize backend connections, determining which ones are available.
"""
# TODO: handle disappearing backends
if app.config.get('use_keyring') and keyring:
self.secret = SecretPasswordStorage()
else:
self.secret = None
if self.secret:
self.preferred_backend = self.secret
else:
self.preferred_backend = None
def get_password(self, account_name):
pw = app.config.get_per('accounts', account_name, 'password')
......@@ -120,12 +116,6 @@ class PasswordStorageManager(PasswordStorage):
app.connections[account_name].password = password
return True
def set_preferred_backend(self):
if self.secret:
self.preferred_backend = self.secret
else:
self.preferred_backend = None
passwordStorageManager = None
def get_storage():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment