|
@ -25,7 +25,7 @@ import pEp |
|
|
import minimail |
|
|
import minimail |
|
|
import miniimap |
|
|
import miniimap |
|
|
|
|
|
|
|
|
import sync_settings as settings |
|
|
import imap_settings |
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
from datetime import datetime |
|
|
|
|
|
|
|
@ -105,6 +105,7 @@ def messageToSend(msg): |
|
|
minimail.send(inbox, msg, device_name) |
|
|
minimail.send(inbox, msg, device_name) |
|
|
|
|
|
|
|
|
def messageImapToSend(msg): |
|
|
def messageImapToSend(msg): |
|
|
|
|
|
print("send imap message") |
|
|
if msg.enc_format: |
|
|
if msg.enc_format: |
|
|
m, keys, rating, flags = msg.decrypt(DONT_TRIGGER_SYNC) |
|
|
m, keys, rating, flags = msg.decrypt(DONT_TRIGGER_SYNC) |
|
|
else: |
|
|
else: |
|
@ -126,6 +127,7 @@ def getMessageToSend(msg): |
|
|
|
|
|
|
|
|
class UserInterface(pEp.UserInterface): |
|
|
class UserInterface(pEp.UserInterface): |
|
|
def notifyHandshake(self, me, partner, signal): |
|
|
def notifyHandshake(self, me, partner, signal): |
|
|
|
|
|
print('ui.notifyHandshake') |
|
|
print(colored(str(signal), "yellow"), end=" ") |
|
|
print(colored(str(signal), "yellow"), end=" ") |
|
|
output("on " + device_name + "" if not me.fpr else |
|
|
output("on " + device_name + "" if not me.fpr else |
|
|
"for identities " + str(me.fpr) + " " + str(partner.fpr)) |
|
|
"for identities " + str(me.fpr) + " " + str(partner.fpr)) |
|
@ -163,6 +165,8 @@ def run(name, color=None, imap=False): |
|
|
global device_name |
|
|
global device_name |
|
|
device_name = name |
|
|
device_name = name |
|
|
|
|
|
|
|
|
|
|
|
print("run sync_handhske") |
|
|
|
|
|
|
|
|
if color: |
|
|
if color: |
|
|
global output |
|
|
global output |
|
|
output = lambda x: print(colored(x, color)) |
|
|
output = lambda x: print(colored(x, color)) |
|
@ -174,7 +178,8 @@ def run(name, color=None, imap=False): |
|
|
pEp.debug_color(36) |
|
|
pEp.debug_color(36) |
|
|
|
|
|
|
|
|
if imap: |
|
|
if imap: |
|
|
me = pEp.Identity(settings.IMAP_EMAIL, name + " of " + settings.IMAP_USER, name) |
|
|
print("run handshake using imap") |
|
|
|
|
|
me = pEp.Identity(imap_settings.IMAP_EMAIL, name + " of " + imap_settings.IMAP_USER, name) |
|
|
pEp.myself(me) |
|
|
pEp.myself(me) |
|
|
pEp.messageToSend = messageImapToSend |
|
|
pEp.messageToSend = messageImapToSend |
|
|
else: |
|
|
else: |
|
@ -195,13 +200,14 @@ def run(name, color=None, imap=False): |
|
|
sync = Thread(target=sync_thread) |
|
|
sync = Thread(target=sync_thread) |
|
|
sync.start() |
|
|
sync.start() |
|
|
else: |
|
|
else: |
|
|
|
|
|
print('no threading') |
|
|
sync = None |
|
|
sync = None |
|
|
ui = UserInterface() |
|
|
ui = UserInterface() |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
while not the_end: |
|
|
while not the_end: |
|
|
if imap: |
|
|
if imap: |
|
|
l = miniimap.recv_all(inbox, 'start_time') |
|
|
l = miniimap.recv_all(inbox) |
|
|
else: |
|
|
else: |
|
|
l = minimail.recv_all(inbox, name) |
|
|
l = minimail.recv_all(inbox, name) |
|
|
for n, m in l: |
|
|
for n, m in l: |
|
@ -237,6 +243,10 @@ if __name__=="__main__": |
|
|
help="use multithreaded instead of single threaded implementation") |
|
|
help="use multithreaded instead of single threaded implementation") |
|
|
optParser.add_option("-n", "--noend", action="store_true", |
|
|
optParser.add_option("-n", "--noend", action="store_true", |
|
|
dest="noend", help="do not end") |
|
|
dest="noend", help="do not end") |
|
|
|
|
|
optParser.add_option("-i", "--imap", action="store_true", |
|
|
|
|
|
dest="imap", |
|
|
|
|
|
help="use imap instead of minimail") |
|
|
|
|
|
|
|
|
options, args = optParser.parse_args() |
|
|
options, args = optParser.parse_args() |
|
|
|
|
|
|
|
|
if not options.exec_for: |
|
|
if not options.exec_for: |
|
@ -252,5 +262,5 @@ if __name__=="__main__": |
|
|
end_on = (None,) |
|
|
end_on = (None,) |
|
|
|
|
|
|
|
|
multithreaded = options.multithreaded |
|
|
multithreaded = options.multithreaded |
|
|
run(options.exec_for, options.color) |
|
|
run(options.exec_for, options.color, options.imap) |
|
|
|
|
|
|
|
|