Browse Source

name files with device name

PYADPT-55
Volker Birk 6 years ago
parent
commit
06518e74ae
  1. 1
      src/pEpmodule.hh
  2. 4
      test/minimail.py
  3. 10
      test/sync_handshake.py

1
src/pEpmodule.hh

@ -8,6 +8,7 @@
namespace pEp { namespace pEp {
namespace PythonAdapter { namespace PythonAdapter {
extern string device_name;
void _throw_status(PEP_STATUS status); void _throw_status(PEP_STATUS status);
void messageToSend(Message msg); void messageToSend(Message msg);
PEP_STATUS _messageToSend(::message *msg); PEP_STATUS _messageToSend(::message *msg);

4
test/minimail.py

@ -49,11 +49,11 @@ class Lock:
lockfile.touch() lockfile.touch()
def send(inbox, msg): def send(inbox, msg, marker):
"send msg to inbox in MIME format" "send msg to inbox in MIME format"
with Lock(inbox): with Lock(inbox):
name = token_urlsafe(16) + ".eml" name = marker + "_" + token_urlsafe(16) + ".eml"
with open(inbox / name, "wb") as f: with open(inbox / name, "wb") as f:
f.write(str(msg).encode()) f.write(str(msg).encode())

10
test/sync_handshake.py

@ -24,7 +24,7 @@ import minimail
inbox = pathlib.Path("..") / "TestInbox" inbox = pathlib.Path("..") / "TestInbox"
device = "" device_name = ""
def messageToSend(msg): def messageToSend(msg):
@ -33,18 +33,18 @@ def messageToSend(msg):
else: else:
m = msg m = msg
print("<!-- " + str(m.from_) + " -->\n" + m.attachments[0].decode()) print("<!-- " + str(m.from_) + " -->\n" + m.attachments[0].decode())
minimail.send(inbox, msg) minimail.send(inbox, msg, device_name)
class UserInterface(pEp.UserInterface): class UserInterface(pEp.UserInterface):
def notifyHandshake(self, me, partner, signal): def notifyHandshake(self, me, partner, signal):
print("on " + device + " signal " + str(signal) + " for identities " + str(me.fpr) + " " + print("on " + device_name + " signal " + str(signal) + " for identities " + str(me.fpr) + " " +
str(partner.fpr)) str(partner.fpr))
def run(name): def run(name):
global device global device_name
device = name device_name = name
me = pEp.Identity("alice@peptest.ch", name + " of Alice Neuman") me = pEp.Identity("alice@peptest.ch", name + " of Alice Neuman")
pEp.myself(me) pEp.myself(me)
pEp.messageToSend = messageToSend pEp.messageToSend = messageToSend

Loading…
Cancel
Save