use NEC to handle bad GPG passphrase events
This commit is contained in:
parent
b0189989a0
commit
da97249ef6
4 changed files with 23 additions and 13 deletions
|
@ -223,7 +223,8 @@ class CommonConnection:
|
||||||
if signed == 'BAD_PASSPHRASE':
|
if signed == 'BAD_PASSPHRASE':
|
||||||
self.USE_GPG = False
|
self.USE_GPG = False
|
||||||
signed = ''
|
signed = ''
|
||||||
self.dispatch('BAD_PASSPHRASE', ())
|
gajim.nec.push_incoming_event(BadGPGPassphrase(None,
|
||||||
|
conn=self))
|
||||||
return signed
|
return signed
|
||||||
|
|
||||||
def _on_disconnected(self):
|
def _on_disconnected(self):
|
||||||
|
|
|
@ -2027,7 +2027,8 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
if sign_msg and not signed:
|
if sign_msg and not signed:
|
||||||
signed = self.get_signed_presence(msg)
|
signed = self.get_signed_presence(msg)
|
||||||
if signed is None:
|
if signed is None:
|
||||||
self.dispatch('BAD_PASSPHRASE', ())
|
gajim.nec.push_incoming_event(BadGPGPassphraseEvent(None,
|
||||||
|
conn=self))
|
||||||
self.USE_GPG = False
|
self.USE_GPG = False
|
||||||
signed = ''
|
signed = ''
|
||||||
self.connected = gajim.SHOW_LIST.index(show)
|
self.connected = gajim.SHOW_LIST.index(show)
|
||||||
|
|
|
@ -1303,3 +1303,13 @@ class AgentRemovedEvent(nec.NetworkIncomingEvent):
|
||||||
if jid.endswith('@' + self.agent):
|
if jid.endswith('@' + self.agent):
|
||||||
self.jid_list.append(jid)
|
self.jid_list.append(jid)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class BadGPGPassphraseEvent(nec.NetworkIncomingEvent):
|
||||||
|
name = 'bad-gpg-passphrase'
|
||||||
|
base_network_events = []
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
self.account = self.conn.name
|
||||||
|
self.use_gpg_agent = gajim.config.get('use_gpg_agent')
|
||||||
|
self.keyID = gajim.config.get_per('accounts', account, 'keyid')
|
||||||
|
return True
|
||||||
|
|
|
@ -859,11 +859,9 @@ class Interface:
|
||||||
del self.gpg_passphrase[keyid]
|
del self.gpg_passphrase[keyid]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_event_bad_passphrase(self, account, array):
|
def handle_event_bad_gpg_passphrase(self, obj):
|
||||||
#('BAD_PASSPHRASE', account, ())
|
#('BAD_PASSPHRASE', account, ())
|
||||||
use_gpg_agent = gajim.config.get('use_gpg_agent')
|
if obj.use_gpg_agent:
|
||||||
sectext = ''
|
|
||||||
if use_gpg_agent:
|
|
||||||
sectext = _('You configured Gajim to use GPG agent, but there is no'
|
sectext = _('You configured Gajim to use GPG agent, but there is no'
|
||||||
' GPG agent running or it returned a wrong passphrase.\n')
|
' GPG agent running or it returned a wrong passphrase.\n')
|
||||||
sectext += _('You are currently connected without your OpenPGP '
|
sectext += _('You are currently connected without your OpenPGP '
|
||||||
|
@ -871,11 +869,11 @@ class Interface:
|
||||||
dialogs.WarningDialog(_('Your passphrase is incorrect'), sectext)
|
dialogs.WarningDialog(_('Your passphrase is incorrect'), sectext)
|
||||||
else:
|
else:
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-warning', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-warning', 48)
|
||||||
|
account = obj.conn.name
|
||||||
notify.popup('warning', account, account, 'warning', path,
|
notify.popup('warning', account, account, 'warning', path,
|
||||||
_('OpenGPG Passphrase Incorrect'),
|
_('OpenGPG Passphrase Incorrect'),
|
||||||
_('You are currently connected without your OpenPGP key.'))
|
_('You are currently connected without your OpenPGP key.'))
|
||||||
keyID = gajim.config.get_per('accounts', account, 'keyid')
|
self.forget_gpg_passphrase(obj.keyID)
|
||||||
self.forget_gpg_passphrase(keyID)
|
|
||||||
|
|
||||||
def handle_event_gpg_password_required(self, account, array):
|
def handle_event_gpg_password_required(self, account, array):
|
||||||
#('GPG_PASSWORD_REQUIRED', account, (callback,))
|
#('GPG_PASSWORD_REQUIRED', account, (callback,))
|
||||||
|
@ -1755,7 +1753,6 @@ class Interface:
|
||||||
'GC_NOTIFY': [self.handle_event_gc_notify],
|
'GC_NOTIFY': [self.handle_event_gc_notify],
|
||||||
'GC_SUBJECT': [self.handle_event_gc_subject],
|
'GC_SUBJECT': [self.handle_event_gc_subject],
|
||||||
'GC_CONFIG_CHANGE': [self.handle_event_gc_config_change],
|
'GC_CONFIG_CHANGE': [self.handle_event_gc_config_change],
|
||||||
'BAD_PASSPHRASE': [self.handle_event_bad_passphrase],
|
|
||||||
'CONNECTION_LOST': [self.handle_event_connection_lost],
|
'CONNECTION_LOST': [self.handle_event_connection_lost],
|
||||||
'FILE_REQUEST': [self.handle_event_file_request],
|
'FILE_REQUEST': [self.handle_event_file_request],
|
||||||
'FILE_REQUEST_ERROR': [self.handle_event_file_request_error],
|
'FILE_REQUEST_ERROR': [self.handle_event_file_request_error],
|
||||||
|
@ -1790,6 +1787,7 @@ class Interface:
|
||||||
'INSECURE_PASSWORD': [self.handle_event_insecure_password],
|
'INSECURE_PASSWORD': [self.handle_event_insecure_password],
|
||||||
'PEP_RECEIVED': [self.handle_event_pep_received],
|
'PEP_RECEIVED': [self.handle_event_pep_received],
|
||||||
'CAPS_RECEIVED': [self.handle_event_caps_received],
|
'CAPS_RECEIVED': [self.handle_event_caps_received],
|
||||||
|
'bad-gpg-passphrase': [self.handle_event_bad_gpg_passphrase],
|
||||||
'bookmarks-received': [self.handle_event_bookmarks],
|
'bookmarks-received': [self.handle_event_bookmarks],
|
||||||
'gc-invitation-received': [self.handle_event_gc_invitation],
|
'gc-invitation-received': [self.handle_event_gc_invitation],
|
||||||
'gc-presence-received': [self.handle_event_gc_presence],
|
'gc-presence-received': [self.handle_event_gc_presence],
|
||||||
|
|
Loading…
Add table
Reference in a new issue