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