From 392cd3a77a25bc6a5d74634ef37b67199b709f63 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 2 Oct 2008 20:20:15 +0000 Subject: [PATCH] show GPG info dialog when we click on the shield icon in chat window. Fixes #4330 --- src/chat_control.py | 4 +++- src/dialogs.py | 52 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 6b0752eee..fdde777aa 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1593,7 +1593,9 @@ class ChatControl(ChatControlBase): self.lock_image.set_sensitive(enc_enabled) def _on_authentication_button_clicked(self, widget): - if self.session and self.session.enable_encryption: + if self.gpg_is_active: + dialogs.GPGInfoWindow(self) + elif self.session and self.session.enable_encryption: dialogs.ESessionInfoWindow(self.session) def _process_command(self, message): diff --git a/src/dialogs.py b/src/dialogs.py index de59bb1df..875a005f4 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1260,7 +1260,7 @@ class WarningDialog(HigDialog): class InformationDialog(HigDialog): def __init__(self, pritext, sectext=''): '''HIG compliant info dialog.''' - HigDialog.__init__( self, None, + HigDialog.__init__(self, None, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, pritext, sectext) self.set_modal(False) self.set_transient_for(gajim.interface.roster.window) @@ -3879,4 +3879,54 @@ class ESessionInfoWindow: YesNoDialog(pritext, sectext, on_response_yes=on_yes, on_response_no=on_no) +class GPGInfoWindow: + '''Class for displaying information about a XEP-0116 encrypted session''' + def __init__(self, control): + xml = gtkgui_helpers.get_glade('esession_info_window.glade') + security_image = xml.get_widget('security_image') + status_label = xml.get_widget('verification_status_label') + info_label = xml.get_widget('info_display') + verify_now_button = xml.get_widget('verify_now_button') + self.window = xml.get_widget('esession_info_window') + account = control.account + keyID = control.contact.keyID + error = None + + verify_now_button.set_no_show_all(True) + verify_now_button.hide() + + if keyID[8:] == 'MISMATCH': + verification_status = _('''Contact's identity NOT verified''') + info = _('The contact\'s key (%s) does not match the key ' + 'assigned in Gajim.') % keyID[:8] + image = 'security-low-big.png' + else: + msgenc, error = gajim.connections[account].gpg.encrypt('test', [keyID]) + if error: + verification_status = _('''Contact's identity NOT verified''') + info = _('GPG Key is assigned to this contact, but you do not ' + 'trust his key, so message cannot be encrypted. Use ' + 'your GPG client to trust this key.') + image = 'security-low-big.png' + else: + verification_status = _('''Contact's identity verified''') + info = _('GPG Key is assigned to this contact, and you trust his ' + 'key, so messages will be encrypted.') + image = 'security-high-big.png' + + status_label.set_markup('%s' % \ + verification_status) + info_label.set_markup(info) + + dir = os.path.join(gajim.DATA_DIR, 'pixmaps') + path = os.path.join(dir, image) + filename = os.path.abspath(path) + security_image.set_from_file(filename) + + xml.signal_autoconnect(self) + self.window.show_all() + + def on_close_button_clicked(self, widget): + self.window.destroy() + # vim: se ts=3: