diff --git a/gotr/config_dialog.ui b/gotr/config_dialog.ui index 2812833..b9dd8d9 100644 --- a/gotr/config_dialog.ui +++ b/gotr/config_dialog.ui @@ -24,6 +24,21 @@ + + True + False + True + + + True + False + False + Copy to clipboard + True + + + + True True @@ -53,7 +68,7 @@ True - Fingerprint: + Fingerprint: False @@ -63,10 +78,9 @@ True - <tt>-------- -------- -------- -------- -------- </tt> + <tt>-------- -------- -------- -------- -------- </tt> True True - end 1 @@ -80,7 +94,7 @@ - (Re-)generate + (Re-)generate True True True @@ -107,7 +121,7 @@ vertical - Enable private (Off-the-Record) messaging + Enable private (Off-the-Record) messaging True True False @@ -120,7 +134,7 @@ - Advertise Off-the-Record messaging support + Advertise Off-the-Record messaging support True True False @@ -133,7 +147,7 @@ - Automatically start private messaging + Automatically start private messaging True True False @@ -146,7 +160,7 @@ - Require private messaging + Require private messaging True True False @@ -164,7 +178,7 @@ True - <b>Default OTR Settings</b> + <b>Default OTR Settings</b> True @@ -185,7 +199,7 @@ True - <b>Off-the-Record settings for:</b> + <b>Off-the-Record settings for:</b> True @@ -222,7 +236,7 @@ True - OTR Settings + OTR Settings False @@ -246,10 +260,11 @@ fingerprint_store 0 5 + True - Name + Name @@ -261,7 +276,7 @@ True - Status + Status @@ -273,7 +288,7 @@ True - Validated + Validated @@ -285,7 +300,7 @@ True - Fingerprint + Fingerprint @@ -297,7 +312,7 @@ True - Account + Account @@ -320,7 +335,7 @@ True - Verify Fingerprint + Verify Fingerprint True True True @@ -332,7 +347,7 @@ - Forget Fingerprint + Forget Fingerprint True True True @@ -356,7 +371,7 @@ True - Known Fingerprints + Known Fingerprints 1 diff --git a/gotr/contact_otr_window.ui b/gotr/contact_otr_window.ui index 09feaa0..9e697b8 100644 --- a/gotr/contact_otr_window.ui +++ b/gotr/contact_otr_window.ui @@ -16,7 +16,7 @@ True 0 - Your fingerprint: + Your fingerprint: <span weight="bold" face="monospace">01234567 89ABCDEF 01234567 89ABCDEF 01234567</span> True True @@ -29,7 +29,7 @@ True 0 - Purported fingerprint for asdfasdf@xyzxyzxyz.de: + Purported fingerprint for asdfasdf@xyzxyzxyz.de: <span weight="bold" face="monospace">01234567 89ABCDEF 01234567 89ABCDEF 01234567</span> True True @@ -39,37 +39,16 @@ - + True + True + verifiedmodel + 0 - - True - True - verifiedmodel - 0 - - - - 0 - - - - - False - 0 - - - - - True - 0.20000000298023224 - verified that the purported fingerprint is in fact the correct fingerprint for that contact. - True - - - False - 1 - + + + 0 + @@ -81,7 +60,7 @@ True - Authentication + Authentication 1 @@ -102,7 +81,7 @@ True - OTR version 2 allowed + OTR version 2 allowed True True False @@ -115,7 +94,7 @@ - Encryption required + Encryption required True True False @@ -127,7 +106,7 @@ - Show others we understand OTR + Show others we understand OTR True True False @@ -140,7 +119,7 @@ - Automatically initiate encryption if partner understands OTR + Automatically initiate encryption if partner understands OTR True True False @@ -155,7 +134,7 @@ - Use the default settings + Use the default settings True True False @@ -171,7 +150,7 @@ True - OTR Settings + OTR Settings 1 @@ -186,10 +165,10 @@ - I have NOT + I have NOT verified that the purported fingerprint is in fact the correct fingerprint for that contact. - I have + I have verified that the purported fingerprint is in fact the correct fingerprint for that contact. @@ -208,7 +187,7 @@ True - label + label True True @@ -221,7 +200,7 @@ True - Use question: + Use question: True True False @@ -250,7 +229,7 @@ True - label + label 2 @@ -333,14 +312,14 @@ True False - Off-the-Record Encryption + Off-the-Record Encryption True True - OTR settings / fingerprint + OTR settings / fingerprint True @@ -348,7 +327,7 @@ True - Authenticate contact + Authenticate contact True @@ -356,7 +335,7 @@ True - Start / Refresh OTR + Start / Refresh OTR True @@ -365,7 +344,7 @@ True False - End OTR + End OTR True diff --git a/gotr/otrmodule.py b/gotr/otrmodule.py index 77f8c78..e9fb77d 100644 --- a/gotr/otrmodule.py +++ b/gotr/otrmodule.py @@ -58,6 +58,7 @@ import os import pickle import time import sys +import logging import common.xmpp from common import gajim @@ -89,6 +90,13 @@ try: if not hasattr(potr, 'VERSION') or potr.VERSION < MINVERSION: raise ImportError('old / unsupported python-otr version') + potrrootlog = logging.getLogger('potr') + potrrootlog.handlers = [] + potrrootlog.propagate = False + gajimrootlog = logging.getLogger('gajim') + for h in gajimrootlog.handlers: + potrrootlog.addHandler(h) + def get_jid_from_fjid(fjid): return gajim.get_room_and_nick_from_fjid(fjid)[0] @@ -540,7 +548,16 @@ class OtrPlugin(GajimPlugin): # got a protocol error self.gajim_log(_('We received the following OTR error ' 'message from %(jid)s: [%(error)s]') % {'jid': event.fjid, - 'error': e.args[0].error}) + 'error': e.args[0].error}, + account, event.fjid) + return IGNORE + except potr.crypt.InvalidParameterError, e: + # received a packet we cannot process (probably tampered or + # sent to wrong session) + self.gajim_log(_('We received an unreadable OTR message ' + 'from %(jid)s. It has probably been tampered with, ' + 'or was sent from an older OTR session.') + % {'jid':event.fjid}, account, event.fjid) return IGNORE except RuntimeError, e: # generic library bug? diff --git a/gotr/ui.py b/gotr/ui.py index 49f6679..31ce978 100644 --- a/gotr/ui.py +++ b/gotr/ui.py @@ -24,12 +24,11 @@ from common import gajim from plugins.gui import GajimPluginConfigDialog import otrmodule -HAS_PORT = True try: import potr import potr.proto -except: - HAS_POTR = False +except ImportError: + pass class OtrPluginConfigDialog(GajimPluginConfigDialog): @@ -49,9 +48,9 @@ class OtrPluginConfigDialog(GajimPluginConfigDialog): for account in sorted(gajim.contacts.get_accounts()): self.otr_account_store.append(row=(account,)) - fpr_view = self.B.get_object('fingerprint_view') - fpr_view.set_model(self.fpr_model) - fpr_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.fpr_view = self.B.get_object('fingerprint_view') + self.fpr_view.set_model(self.fpr_model) + self.fpr_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE) if len(self.otr_account_store) > 0: self.B.get_object('account_combobox').set_active(0) @@ -74,6 +73,38 @@ class OtrPluginConfigDialog(GajimPluginConfigDialog): self.plugin.update_context_list() self.account_combobox_changed_cb(self.B.get_object('account_combobox')) + def fpr_button_pressed_cb(self, tw, event): + if event.button == 3: + pthinfo = tw.get_path_at_pos(int(event.x), int(event.y)) + + if pthinfo is None: + # only show the popup when we right clicked on list content + # ie. don't show it when we click at empty rows + return False + + # if the row under the mouse is already selected, we keep the + # selection, otherwise we only select the new item + keep_selection = tw.get_selection().path_is_selected(pthinfo[0]) + + pop = self.B.get_object('fprclipboard_menu') + pop.popup(None, None, None, event.button, event.time) + + # keep_selection=True -> no further processing of click event + # keep_selection=False-> further processing -> GTK usually selects + # the item below the cursor + return keep_selection + + def clipboard_button_cb(self, menuitem): + mod, paths = self.fpr_view.get_selection().get_selected_rows() + + fprs = [] + for path in paths: + it = mod.get_iter(path) + jid, fpr = mod.get(it, 0, 6) + fprs.append('%s: %s' % (jid, potr.human_hash(fpr))) + gtk.Clipboard().set_text('\n'.join(fprs)) + gtk.Clipboard(selection='PRIMARY').set_text('\n'.join(fprs)) + def flags_toggled_cb(self, button): if button == self.B.get_object('enable_check'): new_status = button.get_active() @@ -127,9 +158,8 @@ class OtrPluginConfigDialog(GajimPluginConfigDialog): for acc in gajim.connections.iterkeys(): accounts[gajim.get_jid_from_account(acc)] = acc - tw = self.B.get_object('fingerprint_view') - mod, paths = tw.get_selection().get_selected_rows() + mod, paths = self.fpr_view.get_selection().get_selected_rows() for path in paths: it = mod.get_iter(path) @@ -161,9 +191,7 @@ class OtrPluginConfigDialog(GajimPluginConfigDialog): for acc in gajim.connections.iterkeys(): accounts[gajim.get_jid_from_account(acc)] = acc - tw = self.B.get_object('fingerprint_view') - - mod, paths = tw.get_selection().get_selected_rows() + mod, paths = self.fpr_view.get_selection().get_selected_rows() # open the window for the first selected row for path in paths[0:1]: