Browse Source

some wrapper script in utils

AllGroupDevicesShowHandshake
Volker Birk 6 years ago
parent
commit
a1e24dda7d
2 changed files with 17 additions and 9 deletions
  1. +4
    -0
      src/message.cc
  2. +13
    -9
      utils/pEp

+ 4
- 0
src/message.cc View File

@ -309,6 +309,10 @@ namespace pEp {
{
if (!(_msg && _msg->from))
throw invalid_argument("from must be a valid Identity()");
if (_msg->dir == PEP_dir_outgoing)
myself(session, _msg->from);
else
update_identity(session, _msg->from);
if (!(_msg->dir == PEP_dir_outgoing && _msg->from->user_id &&
strcmp(_msg->from->user_id, PEP_OWN_USERID) == 0))
throw invalid_argument("Message.dir must be outgoing");


+ 13
- 9
utils/pEp View File

@ -38,23 +38,27 @@ if not(args.encrypt) and not(args.decrypt) and not(args.version):
if args.version:
print(__doc__)
def crlf(line):
if line[-2:] == '\r\n':
return line
elif line[-1:] == '\n':
return line[:-1] + '\r\n'
else:
return line + '\r\n'
try:
if len(args.files) == 0:
args.files = ['-']
for filename in args.files:
text = ''
if filename == '-':
text = ''
for line in sys.stdin.readlines():
if line[-2:] == '\r\n':
text += line
elif line[-1:] == '\n':
text += line[:-1] + '\r\n'
else:
text += line + '\r\n'
text += line
else:
with open(filename, "r") as f:
text = f.readall()
for line in f:
text += line
src = Message(text)
@ -63,7 +67,7 @@ try:
dst = src.encrypt()
else:
src.dir = 0
dst, keys, rating, flags = src.decrypt()
dst, keys, rating, consumed, flags = src.decrypt()
print(str(dst))


Loading…
Cancel
Save