Skip to content
This repository was archived by the owner on Jan 24, 2018. It is now read-only.

Commit 686381c

Browse files
jh23453eighthave
authored andcommitted
Initial conversion to and from kopete keys (closes #27)
1 parent c030620 commit 686381c

File tree

6 files changed

+154
-5
lines changed

6 files changed

+154
-5
lines changed

icons/kopete.png

88.5 KB
Loading

otrapps/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
__version__ = _dist.version
1717

1818

19-
__all__ = ['adium', 'chatsecure', 'irssi', 'jitsi', 'pidgin', 'gajim', 'gnupg', 'xchat',]
19+
__all__ = ['adium', 'chatsecure', 'irssi', 'jitsi', 'pidgin', 'gajim', 'gnupg', 'xchat', 'kopete',]
2020

2121
if __name__ == '__main__':
2222
sys.path.insert(0, "../") # so the main() test suite can find otrapps module
@@ -28,6 +28,7 @@
2828
import otrapps.gajim
2929
import otrapps.gnupg
3030
import otrapps.xchat
31+
import otrapps.kopete
3132

3233
apps = { 'adium' : otrapps.adium.AdiumProperties,
3334
'chatsecure': otrapps.chatsecure.ChatSecureProperties,
@@ -37,6 +38,7 @@
3738
'gajim' : otrapps.gajim.GajimProperties,
3839
'gnupg' : otrapps.gnupg.GnuPGProperties,
3940
'xchat' : otrapps.xchat.XchatProperties,
41+
'kopete' : otrapps.kopete.KopeteProperties,
4042
}
4143
apps_supported = apps.keys()
4244

otrapps/kopete.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
'''a module for reading and writing Kopete's OTR key data'''
4+
5+
from __future__ import print_function
6+
import os
7+
import sys
8+
9+
if __name__ == '__main__':
10+
sys.path.insert(0, "../") # so the main() test suite can find otrapps module
11+
import otrapps.util
12+
from otrapps.otr_private_key import OtrPrivateKeys
13+
from otrapps.otr_fingerprints import OtrFingerprints
14+
15+
class KopeteProperties():
16+
17+
path = os.path.expanduser('~/.kde/share/apps/kopete_otr')
18+
keyfile = 'privkeys'
19+
fingerprintfile = 'fingerprints'
20+
files = (keyfile, fingerprintfile)
21+
22+
@staticmethod
23+
def _convert_protocol_name(protocol):
24+
if protocol == 'Jabber':
25+
return 'prpl-jabber'
26+
elif protocol == 'prpl-jabber':
27+
return 'Jabber'
28+
elif protocol == 'Google Talk':
29+
# this should also mark it as the gtalk variant
30+
return 'prpl-jabber'
31+
else:
32+
print('IMPLEMENTME')
33+
print(protocol)
34+
return 'IMPLEMENTME'
35+
36+
@staticmethod
37+
def parse(settingsdir=None):
38+
if settingsdir == None:
39+
settingsdir = KopeteProperties.path
40+
41+
kf = os.path.join(settingsdir, KopeteProperties.keyfile)
42+
if os.path.exists(kf):
43+
keydict = OtrPrivateKeys.parse(kf)
44+
for key in keydict:
45+
for value in keydict[key]:
46+
if value == 'protocol':
47+
keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])
48+
else:
49+
keydict = dict()
50+
51+
fpf = os.path.join(settingsdir, KopeteProperties.fingerprintfile)
52+
if os.path.exists(fpf):
53+
tmpdict = OtrFingerprints.parse(fpf)
54+
for key in tmpdict:
55+
for value in tmpdict[key]:
56+
if value == 'protocol':
57+
tmpdict[key][value] = KopeteProperties._convert_protocol_name(tmpdict[key][value])
58+
59+
otrapps.util.merge_keydicts(keydict, tmpdict)
60+
61+
return keydict
62+
63+
@staticmethod
64+
def write(keydict, savedir):
65+
if not os.path.exists(savedir):
66+
raise Exception('"' + savedir + '" does not exist!')
67+
68+
for key in keydict:
69+
for value in keydict[key]:
70+
if value == 'protocol':
71+
keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])
72+
73+
kf = os.path.join(savedir, KopeteProperties.keyfile)
74+
OtrPrivateKeys.write(keydict, kf)
75+
76+
accounts = []
77+
# look for all private keys and use them for the accounts list
78+
for name, key in keydict.items():
79+
if 'x' in key:
80+
accounts.append(name)
81+
fpf = os.path.join(savedir, KopeteProperties.fingerprintfile)
82+
OtrFingerprints.write(keydict, fpf, accounts)
83+
84+
85+
86+
if __name__ == '__main__':
87+
88+
import pprint
89+
90+
print('Kopete stores its files in ' + KopeteProperties.path)
91+
92+
if len(sys.argv) == 2:
93+
settingsdir = sys.argv[1]
94+
else:
95+
settingsdir = '../tests/kopete'
96+
97+
keydict = KopeteProperties.parse(settingsdir)
98+
pprint.pprint(keydict)
99+
100+
KopeteProperties.write(keydict, '/tmp')

tests/kopete/fingerprints

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gptest@jabber.ccc.de gptest@jabber.org/ prpl-jabber a2cd015572d256703e7624840f91209160185410
2+
gptest@jabber.ccc.de gptest@limun.org/ prpl-jabber a2cd015572d256703e7624840f91209160185410 verified
3+
hans@eds.org gptest@jabber.org/ prpl-jabber ff66e8c909c4deb51cbd4a02b9e6af4d6af215f8
4+
hans@eds.org gptest@limun.org/ prpl-jabber f83fe8c909c4deb51c234574bab3e4f66af215f8
5+
n8fr8@foo_com gptest@mycomputer prpl-bonjour 92967e4743bc730e0a3396be1a6ea365cc38f0f3
6+
gptest@jabber_ccc_de gptest@mycomputer prpl-bonjour a2cd015572d256703e7624840f91209160185410 verified

tests/kopete/privkeys

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
(privkeys
2+
(account
3+
(name "gptest@limun.org/")
4+
(protocol prpl-jabber)
5+
(private-key
6+
(dsa
7+
(p #00B20F6CADBA15D628E861586099F9C18E68C822D3C02E21B57B7464D5A664BF40E6EB45F1931E9CD3E098890BF2E09662DFBE2B530CBDE8FF1D542333C02DFEAA904A970C29A7403F9328B2BC6D8EA6233E484B4E9B28D63B83CB1FC13DFDF493D80DEE4AB52DDDC3C19AC9144C16E46B491327C09E688AE582B9F8D56E271A2B#)
8+
(q #00EAB4FEDFB2C033131204EADDFD9EFA21B50D0AE9#)
9+
(g #00AEC459E479F4A750672567E3B69F3461A54480222580EABF14DA0D520EB0F6D7A74B2287A5A4628C8F966FB5D2AD77C09F4053B9D08FA001BA167CA18CC05177B864FE2EED8C759C4475E2A6B4284B6BB0A2CB856EBD45BB299E30709F09D260672CC850E0A12AD8C507B34080377E9C0E401A3F84B0783EA87112B1DBDA9B0A#)
10+
(y #29A9DE8FD266F19188246B34B613F4717DF106CD8B2179C69CF4172196B0FD562DBB3069428B9315C819758A3CBF0977A7B2054600C43554DF12AFE496FEF79DF5A14300E3F5F2A0E26E8EBB576A52BD423929718D4EA689BD46A021BCD96A5BAE8F83E9C0FF46BE63BE0239A5FC1EE901AA56E2E98E4CDA7D069570E5BC3615#)
11+
(x #00B8787BA6DEEEC7496EACCA84FF723F6E9EA5F6A5#)
12+
)
13+
)
14+
)
15+
(account
16+
(name "gptest@jabber.org/")
17+
(protocol prpl-jabber)
18+
(private-key
19+
(dsa
20+
(p #00CD96479A2F404FB600F9C85EE3DCD69FDF93F217AEE54A1286069983BA7731D0C73C7CB3B8CFA482A0AF6FF906E470EB4EF7F4D201D087AEDBF0086710F3039CBF42358C1BFA7D86A36332E21D32BE31538571CBC8D4F281DDD1076BA2B29B549ED29B3C19C341AEF83C80157E87FF2930B5E15C84A09AFCE28A06E06A62BCEF#)
21+
(q #00D5B4647E688974D1B6B199E1A59AB2F985DBCE01#)
22+
(g #0093E333135FCBCE68FC6E410B304482F2F95D82BF53534C3636EADB0C22241CF35BD294B096070DC08138EFE73B03C88FD444595974E9455274F695147AF9D46B85286B4CFEF3D00BCA1D3BEB8C7EFFBA08132E1A1E4D9F115B863C52C72971F4695758354FC3BE3C4A45AF6A47747B59733905C33EE86ED68D9D90494877AE33#)
23+
(y #362C06B9CDD67FC4E7A7A62289D6C1E8BA061A024946A5ACC1A7DC70F6B03D99A1D3B3215D20BC4F8458EEC3F31E1391E9B519FDCDCC3CF0FBA38F8A7213551B32D59DE655F506633FB6B0EA94C4174D227DB614EF6723AB057B40CF36E2A414D0A8DCF223EE7EDD851793C4DC92282C79503030045D49A0ABCC3C6CC4080909#)
24+
(x #24FE542B1C7DC8337F6F8030C7D639B7BF091B40#)
25+
)
26+
)
27+
)
28+
(account
29+
(name "gptest@mycomputer")
30+
(protocol prpl-bonjour)
31+
(private-key
32+
(dsa
33+
(p #00B727869A051E6F00EA571BEC0A3EE8D9DBE91CBEA9AF8CE1122B18F9EBEBE6B2F4CA2D0A481D0EC9363C56F389EA7AC1F631798989797FE4868AAA18E005D3A7FAA631047F73EC9291246369495CB9ADD4E6447BF959B2FA6AA03DF5B781A40A40B7693AF5B1B466DB1BE14CFB92C5680D6CA9ADD1A4F134C02A0C4CA32AFEC7#)
34+
(q #008952F4EA8C624566E2B720734562EF2EA9ADE76D#)
35+
(g #2570F44667EC9FF45456EEEBC0A000FA9D24CD5DF1EBB59C897E07D4F98CB6798011235BC5075BE96AADE338D02CA31CCF6393ED2399CB4263429170B0C841A17BE2E2B43914C004AAAE05CA544723215D99D809E0C28C13D5DFFF8D381323D54C4B785E8C922DC7A4A78F9324161BAC2A9745E667594C89BEDE7997B9E2545F#)
36+
(y #009EEBE6739180FC47E744F1ECB4321B11255787890123578902350C052CE18985F1F6F37986A5D8EDBDB524264879128793489172475E60A20EACFDEB168D05921E242B5A3A78912389ABBADF742B4BAABE35345E3D9E5F13BBF5BB8806CEFABE9B227219724889AB897234D4295CFE7EF1DDCE997BA504304BB87F4EA18A4C1A#)
37+
(x #072349EAF19604CCE2FEDDBEA2342CCF93C71224#)
38+
)
39+
)
40+
)
41+
)

tests/run-tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ echo '========================================================================'
6060
echo "Run each python file's __main__ tests"
6161
echo '========================================================================'
6262
cd $projectbase/otrapps
63-
for app in adium chatsecure gajim gnupg irssi jitsi pidgin xchat util; do
63+
for app in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat util; do
6464
echo ''
6565
echo ''
6666
echo '------------------------------------------------------------------------'
@@ -73,7 +73,7 @@ echo '========================================================================'
7373
echo "Merge all test files into an app's format"
7474
echo '========================================================================'
7575
cd $projectbase
76-
for app in adium chatsecure gajim irssi jitsi pidgin xchat; do
76+
for app in adium chatsecure gajim irssi jitsi kopete pidgin xchat; do
7777
echo '------------------------------------------------------------------------'
7878
echo "Merge all test files into $app's format"
7979
echo '------------------------------------------------------------------------'
@@ -92,8 +92,8 @@ echo '========================================================================'
9292
echo "Convert each app to each other app"
9393
echo '========================================================================'
9494
cd $projectbase
95-
for inapp in adium chatsecure gajim gnupg irssi jitsi pidgin xchat; do
96-
for outapp in adium chatsecure gajim gnupg irssi jitsi pidgin xchat; do
95+
for inapp in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat; do
96+
for outapp in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat; do
9797
echo '------------------------------------------------------------------------'
9898
echo "Convert $inapp to $outapp "
9999
echo '------------------------------------------------------------------------'

0 commit comments

Comments
 (0)