fix plugins initialization

This commit is contained in:
ThomasV 2015-01-31 18:09:50 +01:00
parent 36a5e09532
commit 78ce20b0b8
3 changed files with 15 additions and 19 deletions

View File

@ -46,6 +46,9 @@ def run_hook(name, *args):
for p, f in f_list:
if name == 'load_wallet':
p.wallet = args[0]
if name == 'init_qt':
gui = args[0]
p.window = gui.main_window
if name in SPECIAL_HOOKS or p.is_enabled():
try:
r = f(*args)

View File

@ -55,11 +55,13 @@ class Plugin(BasePlugin):
return TREZOR
def is_available(self):
if self.wallet is None:
return self._is_available
if self.wallet.storage.get('wallet_type') == 'trezor':
return True
return False
if not self._is_available:
return False
if not self.wallet:
return False
if self.wallet.storage.get('wallet_type') != 'trezor':
return False
return True
def requires_settings(self):
return self._requires_settings
@ -70,11 +72,9 @@ class Plugin(BasePlugin):
def is_enabled(self):
if not self.is_available():
return False
if not self.wallet or self.wallet.storage.get('wallet_type') == 'trezor':
return True
return self.wallet.storage.get('use_' + self.name) is True
if self.wallet.has_seed():
return False
return True
def enable(self):
return BasePlugin.enable(self)
@ -98,9 +98,6 @@ class Plugin(BasePlugin):
@hook
def load_wallet(self, wallet):
self.wallet = wallet
if self.wallet.has_seed():
return
if self.trezor_is_connected():
if not self.wallet.check_proper_device():
QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))

View File

@ -223,8 +223,8 @@ class Plugin(BasePlugin):
+ _("For more information, visit") + " <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>"
def is_available(self):
if self.wallet is None:
return True
if not self.wallet:
return False
if self.wallet.storage.get('wallet_type') == '2fa':
return True
return False
@ -238,10 +238,6 @@ class Plugin(BasePlugin):
def is_enabled(self):
if not self.is_available():
return False
if not self.wallet:
return True
if self.wallet.storage.get('wallet_type') != '2fa':
return False
if self.wallet.master_private_keys.get('x2/'):
return False
return True