1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import os
import threading
from twisted.internet import reactor
from leap.mail.imap.service import imap
from leap.keymanager import KeyManager
from util import log
class IMAPServerThread(threading.Thread):
def __init__(self, imap_service):
threading.Thread.__init__(self)
self._imap_service = imap_service
def run(self):
self._imap_service.start_loop()
reactor.run()
def stop(self):
self._imap_service.stop()
reactor.stop()
def get_imap_server(soledad, uuid, address, token):
log("Starting imap... ", line_break=False)
keymanager = KeyManager(address, '', soledad, token=token, uid=uuid)
with open(
os.path.join(
os.path.dirname(__file__),
'keys/5447A9AD50E3075ECCE432711B450E665FE63573.sec'), 'r') as f:
pubkey, privkey = keymanager.parse_openpgp_ascii_key(f.read())
keymanager.put_key(privkey)
imap_service, imap_port, imap_factory = imap.run_service(
soledad, keymanager, userid=address, offline=False)
imap_service.start_loop()
log("started.")
return imap_service
#imap_server = IMAPServerThread(imap_service)
#try:
# imap_server.start()
#except Exception as e:
# print str(e)
#return imap_server
|