Commit b224467c authored by Kjell Braden's avatar Kjell Braden

merge gotr plugin with upstream repo

parent 73b28ae6
[info]
name: Off-The-Record Encryption
short_name: gotr
version: 1.2
version: 1.4
description: See http://www.cypherpunks.ca/otr/
authors: Kjell Braden <afflux.gajim@pentabarf.de>
homepage: http://gajim-otr.pentabarf.de
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
## otrmodule.py
##
## Copyright (C) 2008-2010 Kjell Braden <fnord@pentabarf.de>
## Copyright 2008-2012 Kjell Braden <afflux@pentabarf.de>
##
## This file is part of Gajim.
##
......@@ -29,7 +29,7 @@ Off-The-Record encryption plugin.
:license: GPL
'''
MINVERSION = (1,0,0,'beta3')
MINVERSION = (1,0,0,'beta4')
IGNORE = True
PASS = False
......@@ -72,6 +72,8 @@ import pickle
HAS_POTR = True
try:
import potr
if not hasattr(potr, 'VERSION') or potr.VERSION < MINVERSION:
raise ImportError('old / unsupported python-otr version')
except ImportError:
HAS_POTR = False
......@@ -152,7 +154,7 @@ class GajimOtrAccount(potr.context.Account):
def dropPrivkey(self):
try:
os.remove(self.keyFilePath + '.key2')
os.remove(self.keyFilePath + '.key3')
except IOError, e:
if e.errno != 2:
log.exception('IOError occurred when removing key file for %s',
......@@ -161,8 +163,8 @@ class GajimOtrAccount(potr.context.Account):
def loadPrivkey(self):
try:
with open(self.keyFilePath + '.key2', 'r') as keyFile:
return pickle.load(keyFile)
with open(self.keyFilePath + '.key3', 'rb') as keyFile:
return potr.crypt.PK.parsePrivateKey(keyFile.read())[0]
except IOError, e:
if e.errno != 2:
log.exception('IOError occurred when loading key file for %s',
......@@ -171,8 +173,8 @@ class GajimOtrAccount(potr.context.Account):
def savePrivkey(self):
try:
with open(self.keyFilePath + '.key2', 'w') as keyFile:
pickle.dump(self.getPrivkey(), keyFile)
with open(self.keyFilePath + '.key3', 'wb') as keyFile:
keyFile.write(self.getPrivkey().serializePrivateKey())
except IOError, e:
log.exception('IOError occurred when loading key file for %s',
self.name)
......@@ -489,6 +491,12 @@ class OtrPlugin(GajimPlugin):
'jid': event.fjid, 'error': e},
account, event.fjid)
return IGNORE
if ctx is not None:
ctx.smpWindow.handle_tlv(tlvs)
if not msgtxt:
return IGNORE
event.msgtxt = unicode(msgtxt)
event.stanza.setBody(event.msgtxt)
......@@ -496,12 +504,6 @@ class OtrPlugin(GajimPlugin):
if html_node:
event.stanza.delChild(html_node)
if ctx is not None:
ctx.smpWindow.handle_tlv(tlvs)
if not msgtxt:
return IGNORE
return PASS
def handle_outgoing_msg(self, event):
......
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
## ui.py
##
## Copyright (C) 2008-2010 Kjell Braden <fnord@pentabarf.de>
## Copyright 2008-2012 Kjell Braden <afflux@pentabarf.de>
##
## This file is part of Gajim.
##
......@@ -214,6 +214,7 @@ class ContactOtrSmpWindow:
def __init__(self, ctx):
self.question = None
self.smp_running = False
self.ctx = ctx
self.account = ctx.user.accountname
......@@ -331,18 +332,19 @@ class ContactOtrSmpWindow:
if tlvs:
is1qtlv = self.get_tlv(tlvs, potr.proto.SMP1QTLV)
# check for TLV_SMP_ABORT or state = CHEATED
if not self.ctx.smpIsValid():
self._abort()
if self.smp_running and not self.ctx.smpIsValid():
self._finish(_('SMP verifying aborted'))
# check for TLV_SMP1
elif self.get_tlv(tlvs, potr.proto.SMP1TLV):
self.smp_running = True
self.question = None
self.show(True)
self.gw('progressbar').set_fraction(0.3)
# check for TLV_SMP1Q
elif is1qtlv:
self.smp_running = True
self.question = is1qtlv.msg
self.show(True)
self.gw('progressbar').set_fraction(0.3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment