Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/gotr
diff options
context:
space:
mode:
authorKjell Braden <afflux.gajim@pentabarf.de>2012-10-13 20:50:35 +0400
committerKjell Braden <afflux.gajim@pentabarf.de>2012-10-13 20:50:35 +0400
commit09898b73ab904505ad5c963250d3186d0f90ea1e (patch)
treea8eba2db2f6e9a50d3515b530fc91bff0ef5637b /gotr
parent4b1a7e4bad107aef0a70ec88b9742a8ac2f12150 (diff)
merge in from git
Diffstat (limited to 'gotr')
-rw-r--r--gotr/config_dialog.ui53
-rw-r--r--gotr/contact_otr_window.ui75
-rw-r--r--gotr/otrmodule.py19
-rw-r--r--gotr/ui.py50
4 files changed, 118 insertions, 79 deletions
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 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkMenu" id="fprclipboard_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="ubuntu_local">True</property>
+ <child>
+ <object class="GtkMenuItem" id="copyfprclipboard_item">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes" comments="Context menu item">Copy to clipboard</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="clipboard_button_cb"/>
+ </object>
+ </child>
+ </object>
<object class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -53,7 +68,7 @@
<child>
<object class="GtkLabel" id="fingerprint_label_desc">
<property name="visible">True</property>
- <property name="label" translatable="yes">Fingerprint:</property>
+ <property name="label" translatable="yes" comments="Descriptive label">Fingerprint:</property>
</object>
<packing>
<property name="expand">False</property>
@@ -63,10 +78,9 @@
<child>
<object class="GtkLabel" id="fingerprint_label">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;tt&gt;-------- -------- -------- -------- -------- &lt;/tt&gt;</property>
+ <property name="label">&lt;tt&gt;-------- -------- -------- -------- -------- &lt;/tt&gt;</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
- <property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
@@ -80,7 +94,7 @@
</child>
<child>
<object class="GtkButton" id="regenerate_button">
- <property name="label" translatable="yes">(Re-)generate</property>
+ <property name="label" translatable="yes" comments="Generate Fingerprint button">(Re-)generate</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -107,7 +121,7 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="enable_check">
- <property name="label" translatable="yes">Enable private (Off-the-Record) messaging</property>
+ <property name="label" translatable="yes" comments="checkbox">Enable private (Off-the-Record) messaging</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -120,7 +134,7 @@
</child>
<child>
<object class="GtkCheckButton" id="advertise_check">
- <property name="label" translatable="yes">Advertise Off-the-Record messaging support</property>
+ <property name="label" translatable="yes" comments="checkbox">Advertise Off-the-Record messaging support</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -133,7 +147,7 @@
</child>
<child>
<object class="GtkCheckButton" id="autoinitiate_check">
- <property name="label" translatable="yes">Automatically start private messaging</property>
+ <property name="label" translatable="yes" comments="checkbox">Automatically start private messaging</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -146,7 +160,7 @@
</child>
<child>
<object class="GtkCheckButton" id="require_check">
- <property name="label" translatable="yes">Require private messaging</property>
+ <property name="label" translatable="yes" comments="checkbox">Require private messaging</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -164,7 +178,7 @@
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Default OTR Settings&lt;/b&gt;</property>
+ <property name="label" translatable="yes" comments="title above options">&lt;b&gt;Default OTR Settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
@@ -185,7 +199,7 @@
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Off-the-Record settings for:&lt;/b&gt;</property>
+ <property name="label" translatable="yes" comments="label for account selector">&lt;b&gt;Off-the-Record settings for:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
@@ -222,7 +236,7 @@
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
- <property name="label" translatable="yes">OTR Settings</property>
+ <property name="label" translatable="yes" comments="tab label">OTR Settings</property>
</object>
<packing>
<property name="tab_fill">False</property>
@@ -246,10 +260,11 @@
<property name="model">fingerprint_store</property>
<property name="search_column">0</property>
<property name="tooltip_column">5</property>
+ <signal name="button-press-event" handler="fpr_button_pressed_cb" swapped="no"/>
<child>
<object class="GtkTreeViewColumn" id="name_column">
<property name="resizable">True</property>
- <property name="title" translatable="yes">Name</property>
+ <property name="title">Name</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
@@ -261,7 +276,7 @@
<child>
<object class="GtkTreeViewColumn" id="status_column">
<property name="resizable">True</property>
- <property name="title" translatable="yes">Status</property>
+ <property name="title">Status</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
@@ -273,7 +288,7 @@
<child>
<object class="GtkTreeViewColumn" id="validated_column">
<property name="resizable">True</property>
- <property name="title" translatable="yes">Validated</property>
+ <property name="title">Validated</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
<attributes>
@@ -285,7 +300,7 @@
<child>
<object class="GtkTreeViewColumn" id="fingerprint_column">
<property name="resizable">True</property>
- <property name="title" translatable="yes">Fingerprint</property>
+ <property name="title">Fingerprint</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
<attributes>
@@ -297,7 +312,7 @@
<child>
<object class="GtkTreeViewColumn" id="account_column">
<property name="resizable">True</property>
- <property name="title" translatable="yes">Account</property>
+ <property name="title">Account</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
@@ -320,7 +335,7 @@
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="verify_button">
- <property name="label" translatable="yes">Verify Fingerprint</property>
+ <property name="label" translatable="yes" comments="button">Verify Fingerprint</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -332,7 +347,7 @@
</child>
<child>
<object class="GtkButton" id="forget_button">
- <property name="label" translatable="yes">Forget Fingerprint</property>
+ <property name="label" translatable="yes" comments="button">Forget Fingerprint</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -356,7 +371,7 @@
<child type="tab">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="label" translatable="yes">Known Fingerprints</property>
+ <property name="label" translatable="yes" comments="tab label">Known Fingerprints</property>
</object>
<packing>
<property name="position">1</property>
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 @@
<object class="GtkLabel" id="our_fp_label">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Your fingerprint:
+ <property name="label">Your fingerprint:
&lt;span weight="bold" face="monospace"&gt;01234567 89ABCDEF 01234567 89ABCDEF 01234567&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
@@ -29,7 +29,7 @@
<object class="GtkLabel" id="their_fp_label">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Purported fingerprint for asdfasdf@xyzxyzxyz.de:
+ <property name="label">Purported fingerprint for asdfasdf@xyzxyzxyz.de:
&lt;span weight="bold" face="monospace"&gt;01234567 89ABCDEF 01234567 89ABCDEF 01234567&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
@@ -39,37 +39,16 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkComboBox" id="verified_combobox">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">verifiedmodel</property>
+ <property name="active">0</property>
<child>
- <object class="GtkComboBox" id="verified_combobox">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">verifiedmodel</property>
- <property name="active">0</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="xalign">0.20000000298023224</property>
- <property name="label" translatable="yes">verified that the purported fingerprint is in fact the correct fingerprint for that contact.</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
</child>
</object>
<packing>
@@ -81,7 +60,7 @@
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
- <property name="label" translatable="yes">Authentication</property>
+ <property name="label" translatable="yes" comments="tab label">Authentication</property>
</object>
<packing>
<property name="position">1</property>
@@ -102,7 +81,7 @@
<property name="homogeneous">True</property>
<child>
<object class="GtkCheckButton" id="otr_policy_allow_v2_checkbutton">
- <property name="label" translatable="yes">OTR version 2 allowed</property>
+ <property name="label" translatable="yes" comments="checkbox">OTR version 2 allowed</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -115,7 +94,7 @@
</child>
<child>
<object class="GtkCheckButton" id="otr_policy_require_checkbutton">
- <property name="label" translatable="yes">Encryption required</property>
+ <property name="label" translatable="yes" comments="checkbox">Encryption required</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -127,7 +106,7 @@
</child>
<child>
<object class="GtkCheckButton" id="otr_policy_send_tag_checkbutton">
- <property name="label" translatable="yes">Show others we understand OTR</property>
+ <property name="label" translatable="yes" comments="checkbox">Show others we understand OTR</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -140,7 +119,7 @@
</child>
<child>
<object class="GtkCheckButton" id="otr_policy_start_on_tag_checkbutton">
- <property name="label" translatable="yes">Automatically initiate encryption if partner understands OTR</property>
+ <property name="label" translatable="yes" comments="checkbox">Automatically initiate encryption if partner understands OTR</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -155,7 +134,7 @@
</child>
<child type="label">
<object class="GtkCheckButton" id="otr_default_checkbutton">
- <property name="label" translatable="yes">Use the default settings</property>
+ <property name="label" translatable="yes" comments="checkbox">Use the default settings</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -171,7 +150,7 @@
<child type="tab">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="label" translatable="yes">OTR Settings</property>
+ <property name="label" translatable="yes" comments="tab label">OTR Settings</property>
</object>
<packing>
<property name="position">1</property>
@@ -186,10 +165,10 @@
</columns>
<data>
<row>
- <col id="0" translatable="yes">I have NOT</col>
+ <col id="0" translatable="yes" comments="unverified option (dropdown label)">I have NOT verified that the purported fingerprint is in fact the correct fingerprint for that contact.</col>
</row>
<row>
- <col id="0" translatable="yes">I have</col>
+ <col id="0" translatable="yes" comments="verified option (dropdown label)">I have verified that the purported fingerprint is in fact the correct fingerprint for that contact.</col>
</row>
</data>
</object>
@@ -208,7 +187,7 @@
<child>
<object class="GtkLabel" id="desclabel1">
<property name="visible">True</property>
- <property name="label" translatable="yes">label</property>
+ <property name="label">label</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</object>
@@ -221,7 +200,7 @@
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="qcheckbutton">
- <property name="label" translatable="yes">Use question: </property>
+ <property name="label" translatable="yes" comments="checkbox for socialist millionaire protocol with question support">Use question: </property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -250,7 +229,7 @@
<child>
<object class="GtkLabel" id="desclabel2">
<property name="visible">True</property>
- <property name="label" translatable="yes">label</property>
+ <property name="label">label</property>
</object>
<packing>
<property name="position">2</property>
@@ -333,14 +312,14 @@
<object class="GtkMenuItem" id="otr_submenu">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="label" translatable="yes">Off-the-Record Encryption</property>
+ <property name="label" translatable="yes" comments="contact's submenu entry">Off-the-Record Encryption</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="otr_submenu_menu">
<child>
<object class="GtkMenuItem" id="otr_settings_menuitem">
<property name="visible">True</property>
- <property name="label" translatable="yes">OTR settings / fingerprint</property>
+ <property name="label" translatable="yes" comments="menu entry for contact's otr settings">OTR settings / fingerprint</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_on_otr_settings_menuitem_activate"/>
</object>
@@ -348,7 +327,7 @@
<child>
<object class="GtkMenuItem" id="smp_otr_menuitem">
<property name="visible">True</property>
- <property name="label" translatable="yes">Authenticate contact</property>
+ <property name="label" translatable="yes" comments="menu entry for SMP authentication">Authenticate contact</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_on_smp_otr_menuitem_activate"/>
</object>
@@ -356,7 +335,7 @@
<child>
<object class="GtkMenuItem" id="start_otr_menuitem">
<property name="visible">True</property>
- <property name="label" translatable="yes">Start / Refresh OTR</property>
+ <property name="label" translatable="yes" comments="menu entry for starting OTR session">Start / Refresh OTR</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_on_start_otr_menuitem_activate"/>
</object>
@@ -365,7 +344,7 @@
<object class="GtkMenuItem" id="end_otr_menuitem">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="label" translatable="yes">End OTR </property>
+ <property name="label" translatable="yes" comments="menu entry for killing an OTR session">End OTR</property>
<property name="use_underline">True</property>
<signal name="activate" handler="_on_end_otr_menuitem_activate"/>
</object>
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]: