This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Initial conversion to and from kopete keys (closes #27)

  • Loading branch information...
jh23453 authored and eighthave committed Jun 22, 2014
1 parent c030620 commit 686381ca5e019e96f368c0892df73e2c15238eb4
Showing with 154 additions and 5 deletions.
  1. BIN icons/kopete.png
  2. +3 −1 otrapps/__init__.py
  3. +100 −0 otrapps/kopete.py
  4. +6 −0 tests/kopete/fingerprints
  5. +41 −0 tests/kopete/privkeys
  6. +4 −4 tests/run-tests.sh
View
Binary file not shown.
View
@@ -16,7 +16,7 @@
__version__ = _dist.version
__all__ = ['adium', 'chatsecure', 'irssi', 'jitsi', 'pidgin', 'gajim', 'gnupg', 'xchat',]
__all__ = ['adium', 'chatsecure', 'irssi', 'jitsi', 'pidgin', 'gajim', 'gnupg', 'xchat', 'kopete',]
if __name__ == '__main__':
sys.path.insert(0, "../") # so the main() test suite can find otrapps module
@@ -28,6 +28,7 @@
import otrapps.gajim
import otrapps.gnupg
import otrapps.xchat
import otrapps.kopete
apps = { 'adium' : otrapps.adium.AdiumProperties,
'chatsecure': otrapps.chatsecure.ChatSecureProperties,
@@ -37,6 +38,7 @@
'gajim' : otrapps.gajim.GajimProperties,
'gnupg' : otrapps.gnupg.GnuPGProperties,
'xchat' : otrapps.xchat.XchatProperties,
'kopete' : otrapps.kopete.KopeteProperties,
}
apps_supported = apps.keys()
View
@@ -0,0 +1,100 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''a module for reading and writing Kopete's OTR key data'''
from __future__ import print_function
import os
import sys
if __name__ == '__main__':
sys.path.insert(0, "../") # so the main() test suite can find otrapps module
import otrapps.util
from otrapps.otr_private_key import OtrPrivateKeys
from otrapps.otr_fingerprints import OtrFingerprints
class KopeteProperties():
path = os.path.expanduser('~/.kde/share/apps/kopete_otr')
keyfile = 'privkeys'
fingerprintfile = 'fingerprints'
files = (keyfile, fingerprintfile)
@staticmethod
def _convert_protocol_name(protocol):
if protocol == 'Jabber':
return 'prpl-jabber'
elif protocol == 'prpl-jabber':
return 'Jabber'
elif protocol == 'Google Talk':
# this should also mark it as the gtalk variant
return 'prpl-jabber'
else:
print('IMPLEMENTME')
print(protocol)
return 'IMPLEMENTME'
@staticmethod
def parse(settingsdir=None):
if settingsdir == None:
settingsdir = KopeteProperties.path
kf = os.path.join(settingsdir, KopeteProperties.keyfile)
if os.path.exists(kf):
keydict = OtrPrivateKeys.parse(kf)
for key in keydict:
for value in keydict[key]:
if value == 'protocol':
keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])
else:
keydict = dict()
fpf = os.path.join(settingsdir, KopeteProperties.fingerprintfile)
if os.path.exists(fpf):
tmpdict = OtrFingerprints.parse(fpf)
for key in tmpdict:
for value in tmpdict[key]:
if value == 'protocol':
tmpdict[key][value] = KopeteProperties._convert_protocol_name(tmpdict[key][value])
otrapps.util.merge_keydicts(keydict, tmpdict)
return keydict
@staticmethod
def write(keydict, savedir):
if not os.path.exists(savedir):
raise Exception('"' + savedir + '" does not exist!')
for key in keydict:
for value in keydict[key]:
if value == 'protocol':
keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])
kf = os.path.join(savedir, KopeteProperties.keyfile)
OtrPrivateKeys.write(keydict, kf)
accounts = []
# look for all private keys and use them for the accounts list
for name, key in keydict.items():
if 'x' in key:
accounts.append(name)
fpf = os.path.join(savedir, KopeteProperties.fingerprintfile)
OtrFingerprints.write(keydict, fpf, accounts)
if __name__ == '__main__':
import pprint
print('Kopete stores its files in ' + KopeteProperties.path)
if len(sys.argv) == 2:
settingsdir = sys.argv[1]
else:
settingsdir = '../tests/kopete'
keydict = KopeteProperties.parse(settingsdir)
pprint.pprint(keydict)
KopeteProperties.write(keydict, '/tmp')
@@ -0,0 +1,6 @@
gptest@jabber.ccc.de gptest@jabber.org/ prpl-jabber a2cd015572d256703e7624840f91209160185410
gptest@jabber.ccc.de gptest@limun.org/ prpl-jabber a2cd015572d256703e7624840f91209160185410 verified
hans@eds.org gptest@jabber.org/ prpl-jabber ff66e8c909c4deb51cbd4a02b9e6af4d6af215f8
hans@eds.org gptest@limun.org/ prpl-jabber f83fe8c909c4deb51c234574bab3e4f66af215f8
n8fr8@foo_com gptest@mycomputer prpl-bonjour 92967e4743bc730e0a3396be1a6ea365cc38f0f3
gptest@jabber_ccc_de gptest@mycomputer prpl-bonjour a2cd015572d256703e7624840f91209160185410 verified
View
@@ -0,0 +1,41 @@
(privkeys
(account
(name "gptest@limun.org/")
(protocol prpl-jabber)
(private-key
(dsa
(p #00B20F6CADBA15D628E861586099F9C18E68C822D3C02E21B57B7464D5A664BF40E6EB45F1931E9CD3E098890BF2E09662DFBE2B530CBDE8FF1D542333C02DFEAA904A970C29A7403F9328B2BC6D8EA6233E484B4E9B28D63B83CB1FC13DFDF493D80DEE4AB52DDDC3C19AC9144C16E46B491327C09E688AE582B9F8D56E271A2B#)
(q #00EAB4FEDFB2C033131204EADDFD9EFA21B50D0AE9#)
(g #00AEC459E479F4A750672567E3B69F3461A54480222580EABF14DA0D520EB0F6D7A74B2287A5A4628C8F966FB5D2AD77C09F4053B9D08FA001BA167CA18CC05177B864FE2EED8C759C4475E2A6B4284B6BB0A2CB856EBD45BB299E30709F09D260672CC850E0A12AD8C507B34080377E9C0E401A3F84B0783EA87112B1DBDA9B0A#)
(y #29A9DE8FD266F19188246B34B613F4717DF106CD8B2179C69CF4172196B0FD562DBB3069428B9315C819758A3CBF0977A7B2054600C43554DF12AFE496FEF79DF5A14300E3F5F2A0E26E8EBB576A52BD423929718D4EA689BD46A021BCD96A5BAE8F83E9C0FF46BE63BE0239A5FC1EE901AA56E2E98E4CDA7D069570E5BC3615#)
(x #00B8787BA6DEEEC7496EACCA84FF723F6E9EA5F6A5#)
)
)
)
(account
(name "gptest@jabber.org/")
(protocol prpl-jabber)
(private-key
(dsa
(p #00CD96479A2F404FB600F9C85EE3DCD69FDF93F217AEE54A1286069983BA7731D0C73C7CB3B8CFA482A0AF6FF906E470EB4EF7F4D201D087AEDBF0086710F3039CBF42358C1BFA7D86A36332E21D32BE31538571CBC8D4F281DDD1076BA2B29B549ED29B3C19C341AEF83C80157E87FF2930B5E15C84A09AFCE28A06E06A62BCEF#)
(q #00D5B4647E688974D1B6B199E1A59AB2F985DBCE01#)
(g #0093E333135FCBCE68FC6E410B304482F2F95D82BF53534C3636EADB0C22241CF35BD294B096070DC08138EFE73B03C88FD444595974E9455274F695147AF9D46B85286B4CFEF3D00BCA1D3BEB8C7EFFBA08132E1A1E4D9F115B863C52C72971F4695758354FC3BE3C4A45AF6A47747B59733905C33EE86ED68D9D90494877AE33#)
(y #362C06B9CDD67FC4E7A7A62289D6C1E8BA061A024946A5ACC1A7DC70F6B03D99A1D3B3215D20BC4F8458EEC3F31E1391E9B519FDCDCC3CF0FBA38F8A7213551B32D59DE655F506633FB6B0EA94C4174D227DB614EF6723AB057B40CF36E2A414D0A8DCF223EE7EDD851793C4DC92282C79503030045D49A0ABCC3C6CC4080909#)
(x #24FE542B1C7DC8337F6F8030C7D639B7BF091B40#)
)
)
)
(account
(name "gptest@mycomputer")
(protocol prpl-bonjour)
(private-key
(dsa
(p #00B727869A051E6F00EA571BEC0A3EE8D9DBE91CBEA9AF8CE1122B18F9EBEBE6B2F4CA2D0A481D0EC9363C56F389EA7AC1F631798989797FE4868AAA18E005D3A7FAA631047F73EC9291246369495CB9ADD4E6447BF959B2FA6AA03DF5B781A40A40B7693AF5B1B466DB1BE14CFB92C5680D6CA9ADD1A4F134C02A0C4CA32AFEC7#)
(q #008952F4EA8C624566E2B720734562EF2EA9ADE76D#)
(g #2570F44667EC9FF45456EEEBC0A000FA9D24CD5DF1EBB59C897E07D4F98CB6798011235BC5075BE96AADE338D02CA31CCF6393ED2399CB4263429170B0C841A17BE2E2B43914C004AAAE05CA544723215D99D809E0C28C13D5DFFF8D381323D54C4B785E8C922DC7A4A78F9324161BAC2A9745E667594C89BEDE7997B9E2545F#)
(y #009EEBE6739180FC47E744F1ECB4321B11255787890123578902350C052CE18985F1F6F37986A5D8EDBDB524264879128793489172475E60A20EACFDEB168D05921E242B5A3A78912389ABBADF742B4BAABE35345E3D9E5F13BBF5BB8806CEFABE9B227219724889AB897234D4295CFE7EF1DDCE997BA504304BB87F4EA18A4C1A#)
(x #072349EAF19604CCE2FEDDBEA2342CCF93C71224#)
)
)
)
)
View
@@ -60,7 +60,7 @@ echo '========================================================================'
echo "Run each python file's __main__ tests"
echo '========================================================================'
cd $projectbase/otrapps
for app in adium chatsecure gajim gnupg irssi jitsi pidgin xchat util; do
for app in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat util; do
echo ''
echo ''
echo '------------------------------------------------------------------------'
@@ -73,7 +73,7 @@ echo '========================================================================'
echo "Merge all test files into an app's format"
echo '========================================================================'
cd $projectbase
for app in adium chatsecure gajim irssi jitsi pidgin xchat; do
for app in adium chatsecure gajim irssi jitsi kopete pidgin xchat; do
echo '------------------------------------------------------------------------'
echo "Merge all test files into $app's format"
echo '------------------------------------------------------------------------'
@@ -92,8 +92,8 @@ echo '========================================================================'
echo "Convert each app to each other app"
echo '========================================================================'
cd $projectbase
for inapp in adium chatsecure gajim gnupg irssi jitsi pidgin xchat; do
for outapp in adium chatsecure gajim gnupg irssi jitsi pidgin xchat; do
for inapp in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat; do
for outapp in adium chatsecure gajim gnupg irssi jitsi kopete pidgin xchat; do
echo '------------------------------------------------------------------------'
echo "Convert $inapp to $outapp "
echo '------------------------------------------------------------------------'

0 comments on commit 686381c

Please sign in to comment.