IOSAD-50 renames PEPSession to be able to create a fake PEPSession class for clients IOSAD-50
authorbuff <andreas@pep-project.org>
Wed, 11 Oct 2017 09:59:01 +0200
branchIOSAD-50
changeset 2695a187b6cf883
parent 268 afba0883d4d9
child 270 e500cb5119bd
IOSAD-50 renames PEPSession to be able to create a fake PEPSession class for clients
pEpObjCAdapter.xcodeproj/project.pbxproj
pEpObjCAdapter/PEPInternalSession+Internal.h
pEpObjCAdapter/PEPInternalSession.h
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPObjCAdapter+Internal.h
pEpObjCAdapter/PEPObjCAdapter.m
pEpObjCAdapter/PEPSession+Internal.h
pEpObjCAdapter/PEPSession.h
pEpObjCAdapter/PEPSession.m
pEpObjCAdapter/PEPSessionProvider.h
pEpObjCAdapter/PEPSessionProvider.m
pEpObjCTests/iOSTests.m
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Tue Oct 10 18:56:57 2017 +0200
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Wed Oct 11 09:59:01 2017 +0200
     1.3 @@ -15,7 +15,7 @@
     1.4  		43209B401ECC2DB4007E7E2E /* PEPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B2D1ECC2ACD007E7E2E /* PEPMessage.m */; };
     1.5  		43209B411ECC2DB8007E7E2E /* PEPObjCAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B301ECC2ACD007E7E2E /* PEPObjCAdapter.m */; };
     1.6  		43209B421ECC2DBC007E7E2E /* PEPQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B321ECC2ACD007E7E2E /* PEPQueue.m */; };
     1.7 -		43209B431ECC2DC0007E7E2E /* PEPSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B351ECC2ACD007E7E2E /* PEPSession.m */; };
     1.8 +		43209B431ECC2DC0007E7E2E /* PEPInternalSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B351ECC2ACD007E7E2E /* PEPInternalSession.m */; };
     1.9  		432EF60C1C58B77900B6782A /* 0xB623F674.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432EF6091C58B77900B6782A /* 0xB623F674.asc */; };
    1.10  		432EF60E1C58B77900B6782A /* msg_to_B623F674.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432EF60B1C58B77900B6782A /* msg_to_B623F674.asc */; };
    1.11  		432FA2D21C884C5F00DDF874 /* partner1_F2D281C2789DD7F6_pub.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432FA2CF1C884C5F00DDF874 /* partner1_F2D281C2789DD7F6_pub.asc */; };
    1.12 @@ -125,9 +125,9 @@
    1.13  		43209B301ECC2ACD007E7E2E /* PEPObjCAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPObjCAdapter.m; sourceTree = "<group>"; };
    1.14  		43209B311ECC2ACD007E7E2E /* PEPQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPQueue.h; sourceTree = "<group>"; };
    1.15  		43209B321ECC2ACD007E7E2E /* PEPQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPQueue.m; sourceTree = "<group>"; };
    1.16 -		43209B331ECC2ACD007E7E2E /* PEPSession+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PEPSession+Internal.h"; sourceTree = "<group>"; };
    1.17 -		43209B341ECC2ACD007E7E2E /* PEPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPSession.h; sourceTree = "<group>"; };
    1.18 -		43209B351ECC2ACD007E7E2E /* PEPSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPSession.m; sourceTree = "<group>"; };
    1.19 +		43209B331ECC2ACD007E7E2E /* PEPInternalSession+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PEPInternalSession+Internal.h"; sourceTree = "<group>"; };
    1.20 +		43209B341ECC2ACD007E7E2E /* PEPInternalSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPInternalSession.h; sourceTree = "<group>"; };
    1.21 +		43209B351ECC2ACD007E7E2E /* PEPInternalSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPInternalSession.m; sourceTree = "<group>"; };
    1.22  		432EF6091C58B77900B6782A /* 0xB623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 0xB623F674.asc; sourceTree = "<group>"; };
    1.23  		432EF60A1C58B77900B6782A /* B623F674_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = B623F674_sec.asc; sourceTree = "<group>"; };
    1.24  		432EF60B1C58B77900B6782A /* msg_to_B623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = msg_to_B623F674.asc; sourceTree = "<group>"; };
    1.25 @@ -221,9 +221,9 @@
    1.26  				43209B301ECC2ACD007E7E2E /* PEPObjCAdapter.m */,
    1.27  				43209B311ECC2ACD007E7E2E /* PEPQueue.h */,
    1.28  				43209B321ECC2ACD007E7E2E /* PEPQueue.m */,
    1.29 -				43209B331ECC2ACD007E7E2E /* PEPSession+Internal.h */,
    1.30 -				43209B341ECC2ACD007E7E2E /* PEPSession.h */,
    1.31 -				43209B351ECC2ACD007E7E2E /* PEPSession.m */,
    1.32 +				43209B331ECC2ACD007E7E2E /* PEPInternalSession+Internal.h */,
    1.33 +				43209B341ECC2ACD007E7E2E /* PEPInternalSession.h */,
    1.34 +				43209B351ECC2ACD007E7E2E /* PEPInternalSession.m */,
    1.35  				43D27DE41F5DA78700795687 /* NSDictionary+Extension.h */,
    1.36  				43D27DE51F5DA7B700795687 /* NSDictionary+Extension.m */,
    1.37  				1508AEAD1F8792AC001D5230 /* PEPCopyableThread.h */,
    1.38 @@ -415,7 +415,7 @@
    1.39  				15206CAA1F8BA183003FF880 /* PEPSessionProvider.m in Sources */,
    1.40  				43209B411ECC2DB8007E7E2E /* PEPObjCAdapter.m in Sources */,
    1.41  				43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */,
    1.42 -				43209B431ECC2DC0007E7E2E /* PEPSession.m in Sources */,
    1.43 +				43209B431ECC2DC0007E7E2E /* PEPInternalSession.m in Sources */,
    1.44  				43209B3F1ECC2DB0007E7E2E /* PEPLanguage.m in Sources */,
    1.45  				43209B401ECC2DB4007E7E2E /* PEPMessage.m in Sources */,
    1.46  				43209B3D1ECC2DA7007E7E2E /* NSArray+Extension.m in Sources */,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pEpObjCAdapter/PEPInternalSession+Internal.h	Wed Oct 11 09:59:01 2017 +0200
     2.3 @@ -0,0 +1,136 @@
     2.4 +//
     2.5 +//  PEPSession+Internal.h
     2.6 +//  pEpiOSAdapter
     2.7 +//
     2.8 +//  Created by Edouard Tisserant on 16.05.17.
     2.9 +//  Copyright © 2017 p≡p. All rights reserved.
    2.10 +//
    2.11 +
    2.12 +#ifndef PEPSession_internal_h
    2.13 +#define PEPSession_internal_h
    2.14 +
    2.15 +#import "PEPObjCAdapter.h"
    2.16 +
    2.17 +@interface PEPInternalSession ()
    2.18 +
    2.19 +@property (nonatomic) PEP_SESSION _Nullable session;
    2.20 +
    2.21 +- (id _Nullable)initInternal;
    2.22 +
    2.23 +/** Decrypt a message */
    2.24 +- (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
    2.25 +                            dest:(PEPDict * _Nullable * _Nullable)dst
    2.26 +                            keys:(PEPStringList * _Nullable * _Nullable)keys;
    2.27 +
    2.28 +/** Re-evaluate rating of decrypted message */
    2.29 +- (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src;
    2.30 +
    2.31 +/** Encrypt a message */
    2.32 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    2.33 +                           extra:(nullable PEPStringList *)keys
    2.34 +                            dest:(PEPDict * _Nullable * _Nullable)dst;
    2.35 +
    2.36 +/** Encrypt a message for the given identity, which is usually a mySelf identity */
    2.37 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    2.38 +                        identity:(nonnull PEPDict *)identity
    2.39 +                            dest:(PEPDict * _Nullable * _Nullable)dst;
    2.40 +
    2.41 +/** Determine the status color of a message to be sent */
    2.42 +- (PEP_rating)outgoingMessageColor:(nonnull PEPDict *)msg;
    2.43 +
    2.44 +/** Determine the rating of an identity */
    2.45 +- (PEP_rating)identityRating:(nonnull PEPDict *)identity;
    2.46 +
    2.47 +/** Get trustwords for a fingerprint */
    2.48 +- (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
    2.49 +                      shortened:(BOOL)shortened;
    2.50 +
    2.51 +/**
    2.52 + Supply an account used by our user himself. The identity is supplemented with the missing parts
    2.53 + 
    2.54 + An identity is a `NSDictionary` mapping a field name as `NSString` to different values.
    2.55 + An identity can have the following fields (all other keys are ignored).
    2.56 + It is not necessary to supply all fields; missing fields are supplemented by p≡p engine.
    2.57 + 
    2.58 + @"username": real name or nick name (if pseudonymous) of identity
    2.59 + @"address": URI or SMTP address
    2.60 + @"user_id": persistent unique ID for identity
    2.61 + @"lang": preferred languageID for communication with this ID (default: @"en")
    2.62 + @"fpr": fingerprint of key to use for communication with this ID
    2.63 + @"comm_type": communication type code (usually not needed)
    2.64 + 
    2.65 + As an example:
    2.66 + 
    2.67 + User has a mailbox. The mail address is "Dipul Khatri <dipul@inboxcube.com>". Then this would be:
    2.68 + 
    2.69 + NSDictionary *ident = [NSDictionary dictionaryWithObjectsAndKeys:
    2.70 + @"Dipul Khatri", @"username", @"dipul@inboxcube.com", @"address",
    2.71 + @"23", @"user_id", nil];
    2.72 + 
    2.73 + */
    2.74 +- (void)mySelf:(nonnull PEPMutableDict *)identity;
    2.75 +
    2.76 +/**
    2.77 + Supplement missing information for an arbitrary identity (used for communication partners).
    2.78 + See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    2.79 + */
    2.80 +- (void)updateIdentity:(nonnull PEPMutableDict *)identity;
    2.81 +
    2.82 +/**
    2.83 + Mark a key as trusted with a person.
    2.84 + See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    2.85 + */
    2.86 +- (void)trustPersonalKey:(nonnull PEPMutableDict *)identity;
    2.87 +
    2.88 +/**
    2.89 + if a key is not trusted by the user tell this using this message
    2.90 + See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    2.91 + */
    2.92 +- (void)keyMistrusted:(nonnull PEPMutableDict *)identity;
    2.93 +
    2.94 +/**
    2.95 + Use this to undo keyCompromized or trustPersonalKey
    2.96 + See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    2.97 + */
    2.98 +- (void)keyResetTrust:(nonnull PEPMutableDict *)identity;
    2.99 +
   2.100 +#pragma mark -- Internal API (testing etc.)
   2.101 +
   2.102 +/** For testing purpose, manual key import */
   2.103 +- (void)importKey:(nonnull NSString *)keydata;
   2.104 +
   2.105 +- (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
   2.106 +     description:(nullable NSString *)description comment:(nullable NSString *)comment;
   2.107 +
   2.108 +/**
   2.109 + Retrieves the log from the engine.
   2.110 + */
   2.111 +- (nonnull NSString *)getLog;
   2.112 +
   2.113 +/** Determine trustwords for two identities */
   2.114 +- (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
   2.115 +                                    identity2:(nonnull PEPDict *)identity2
   2.116 +                                     language:(nullable NSString *)language
   2.117 +                                         full:(BOOL)full;
   2.118 +
   2.119 +/** Determine trustwords between sender of a message and receiving identity */
   2.120 +- (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
   2.121 +                                   receiverDict:(nonnull PEPDict *)receiverDict
   2.122 +                                      keysArray:(PEPStringList * _Nullable)keysArray
   2.123 +                                       language:(nullable NSString *)language
   2.124 +                                           full:(BOOL)full
   2.125 +                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus;
   2.126 +
   2.127 +/**
   2.128 + @returns The list of supported languages for trustwords.
   2.129 + */
   2.130 +- (NSArray<PEPLanguage *> * _Nonnull)languageList;
   2.131 +
   2.132 +/**
   2.133 + Directly invokes the engine's undo_last_mistrust() function
   2.134 + */
   2.135 +- (PEP_STATUS)undoLastMistrust;
   2.136 +
   2.137 +@end
   2.138 +
   2.139 +#endif /* PEPSession_internal_h */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pEpObjCAdapter/PEPInternalSession.h	Wed Oct 11 09:59:01 2017 +0200
     3.3 @@ -0,0 +1,18 @@
     3.4 +//
     3.5 +//  PEPSession.h
     3.6 +//  pEpiOSAdapter
     3.7 +//
     3.8 +//  Created by Volker Birk on 08.07.15.
     3.9 +//  Copyright (c) 2015 p≡p. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +#import <Foundation/Foundation.h>
    3.13 +
    3.14 +/**
    3.15 + N threads <-> N sessions, with the constraint that a session is never used
    3.16 + in a pEpEngine call more than once at the same time.
    3.17 + */
    3.18 +@interface PEPInternalSession : NSObject
    3.19 +// We do not want the client to use a PEPSession. The client is supposed to use PEPObjCAdapter() only.
    3.20 +// Find everything in PEPSession+Internal.h
    3.21 +@end
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Wed Oct 11 09:59:01 2017 +0200
     4.3 @@ -0,0 +1,483 @@
     4.4 +//
     4.5 +//  PEPSession.m
     4.6 +//  pEpiOSAdapter
     4.7 +//
     4.8 +//  Created by Volker Birk on 08.07.15.
     4.9 +//  Copyright (c) 2015 p≡p. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +#import "PEPInternalSession.h"
    4.13 +#import "PEPInternalSession+Internal.h"
    4.14 +#import "PEPObjCAdapter.h"
    4.15 +#import "PEPObjCAdapter+Internal.h"
    4.16 +#import "PEPMessage.h"
    4.17 +#import "PEPLanguage.h"
    4.18 +#import "PEPCSVScanner.h"
    4.19 +#import "NSArray+Extension.h"
    4.20 +#import "NSDictionary+Extension.h"
    4.21 +
    4.22 +@implementation PEPInternalSession
    4.23 +
    4.24 ++ (void)setupTrustWordsDB
    4.25 +{
    4.26 +    static dispatch_once_t once;
    4.27 +    dispatch_once(&once, ^{
    4.28 +        [PEPObjCAdapter setupTrustWordsDB:[NSBundle bundleForClass:[self class]]];
    4.29 +    });
    4.30 +}
    4.31 +
    4.32 +- (id)init
    4.33 +{
    4.34 +    //"Denied access to assure clients do not call [PEPSession new] accidentally. Use initInternal instead.
    4.35 +    NSAssert(false, @"Dear client. You must not use PEPSession. Use PEPObjCAdapter instead");
    4.36 +    return nil;
    4.37 +}
    4.38 +
    4.39 +- (id)initInternal
    4.40 +{
    4.41 +    [PEPInternalSession setupTrustWordsDB];
    4.42 +
    4.43 +    [[PEPObjCAdapter initLock] lock];
    4.44 +    PEP_STATUS status = init(&_session);
    4.45 +    [[PEPObjCAdapter initLock] unlock];
    4.46 +
    4.47 +    if (status != PEP_STATUS_OK) {
    4.48 +        return nil;
    4.49 +    }
    4.50 +
    4.51 +    [PEPObjCAdapter bindSession:self];
    4.52 +
    4.53 +    return self;
    4.54 +}
    4.55 +
    4.56 +- (void)dealloc
    4.57 +{
    4.58 +    [PEPObjCAdapter unbindSession:self];
    4.59 +
    4.60 +    [[PEPObjCAdapter initLock] lock];
    4.61 +    release(_session);
    4.62 +    [[PEPObjCAdapter initLock] unlock];
    4.63 +
    4.64 +}
    4.65 +
    4.66 +/**
    4.67 + Saves the given message dict as a plist to the local filesystem
    4.68 + (directly under NSApplicationSupportDirectory).
    4.69 + Since the complete output file will be logged by `debugSaveToFilePath`,
    4.70 + you can get access to the files easily when it's the simulator.
    4.71 + */
    4.72 +- (void)debugOutPutMessageDict:(nonnull PEPDict *)src
    4.73 +{
    4.74 +    NSString *from = src[kPepFrom][kPepAddress];
    4.75 +    NSArray *tos = src[kPepTo];
    4.76 +    NSString *to = tos[0][kPepAddress];
    4.77 +    NSString *msgID = src[kPepID];
    4.78 +    NSString *fileName = [NSString stringWithFormat:@"%@_from(%@)_%@",
    4.79 +                          to, from, msgID];
    4.80 +    [src debugSaveToFilePath:fileName];
    4.81 +}
    4.82 +
    4.83 +- (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
    4.84 +                            dest:(PEPDict * _Nullable * _Nullable)dst
    4.85 +                            keys:(PEPStringList * _Nullable * _Nullable)keys
    4.86 +{
    4.87 +    message * _src = PEP_messageDictToStruct(src);
    4.88 +    message * _dst = NULL;
    4.89 +    stringlist_t * _keys = NULL;
    4.90 +    PEP_rating color = PEP_rating_undefined;
    4.91 +    PEP_decrypt_flags_t flags = 0;
    4.92 +
    4.93 +    @synchronized (self) {
    4.94 +        decrypt_message(_session, _src, &_dst, &_keys, &color, &flags);
    4.95 +    }
    4.96 +
    4.97 +    NSDictionary * dst_;
    4.98 +
    4.99 +    if (_dst) {
   4.100 +        dst_ = PEP_messageDictFromStruct(_dst);
   4.101 +    }
   4.102 +    else {
   4.103 +        dst_ = PEP_messageDictFromStruct(_src);
   4.104 +    }
   4.105 +
   4.106 +    NSArray * keys_ = nil;
   4.107 +    if (_keys)
   4.108 +        keys_ = PEP_arrayFromStringlist(_keys);
   4.109 +
   4.110 +    free_message(_src);
   4.111 +    free_message(_dst);
   4.112 +    free_stringlist(_keys);
   4.113 +
   4.114 +    if (dst) {
   4.115 +        *dst = dst_;
   4.116 +    }
   4.117 +    if (keys) {
   4.118 +        *keys = keys_;
   4.119 +    }
   4.120 +    return color;
   4.121 +}
   4.122 +
   4.123 +- (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src
   4.124 +{
   4.125 +    message * _src = PEP_messageDictToStruct(src);
   4.126 +    PEP_rating color = PEP_rating_undefined;
   4.127 +
   4.128 +    @synchronized (self) {
   4.129 +        re_evaluate_message_rating(_session, _src, NULL, PEP_rating_undefined, &color);
   4.130 +    }
   4.131 +
   4.132 +    free_message(_src);
   4.133 +
   4.134 +    return color;
   4.135 +}
   4.136 +
   4.137 +- (void)removeEmptyArrayKey:(NSString *)key inDict:(PEPMutableDict *)dict
   4.138 +{
   4.139 +    if ([[dict objectForKey:key] count] == 0) {
   4.140 +        [dict removeObjectForKey:key];
   4.141 +    }
   4.142 +}
   4.143 +
   4.144 +- (NSDictionary *)removeEmptyRecipients:(PEPDict *)src
   4.145 +{
   4.146 +    NSMutableDictionary *dest = src.mutableCopy;
   4.147 +
   4.148 +    [self removeEmptyArrayKey:kPepTo inDict:dest];
   4.149 +    [self removeEmptyArrayKey:kPepCC inDict:dest];
   4.150 +    [self removeEmptyArrayKey:kPepBCC inDict:dest];
   4.151 +
   4.152 +    return [NSDictionary dictionaryWithDictionary:dest];
   4.153 +}
   4.154 +
   4.155 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
   4.156 +                           extra:(nullable NSArray *)keys
   4.157 +                            dest:(PEPDict * _Nullable * _Nullable)dst
   4.158 +{
   4.159 +    PEP_STATUS status;
   4.160 +    PEP_encrypt_flags_t flags = 0;
   4.161 +
   4.162 +    message * _src = PEP_messageDictToStruct([self removeEmptyRecipients:src]);
   4.163 +    message * _dst = NULL;
   4.164 +    stringlist_t * _keys = PEP_arrayToStringlist(keys);
   4.165 +
   4.166 +    @synchronized (self) {
   4.167 +        status = encrypt_message(_session, _src, _keys, &_dst, PEP_enc_PGP_MIME, flags);
   4.168 +    }
   4.169 +
   4.170 +    NSDictionary * dst_;
   4.171 +
   4.172 +    if (_dst) {
   4.173 +        dst_ = PEP_messageDictFromStruct(_dst);
   4.174 +    }
   4.175 +    else {
   4.176 +        dst_ = PEP_messageDictFromStruct(_src);
   4.177 +    }
   4.178 +    if (dst) {
   4.179 +        *dst = dst_;
   4.180 +    }
   4.181 +
   4.182 +    free_message(_src);
   4.183 +    free_message(_dst);
   4.184 +    free_stringlist(_keys);
   4.185 +
   4.186 +    return status;
   4.187 +}
   4.188 +
   4.189 +- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
   4.190 +                        identity:(nonnull PEPDict *)identity
   4.191 +                            dest:(PEPDict * _Nullable * _Nullable)dst
   4.192 +{
   4.193 +    PEP_STATUS status;
   4.194 +    PEP_encrypt_flags_t flags = 0;
   4.195 +
   4.196 +    message * _src = PEP_messageDictToStruct([self removeEmptyRecipients:src]);
   4.197 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.198 +    message * _dst = NULL;
   4.199 +
   4.200 +    @synchronized (self) {
   4.201 +        status = encrypt_message_for_self(_session, ident, _src, &_dst, PEP_enc_PGP_MIME, flags);
   4.202 +    }
   4.203 +
   4.204 +    NSDictionary * dst_;
   4.205 +
   4.206 +    if (_dst) {
   4.207 +        dst_ = PEP_messageDictFromStruct(_dst);
   4.208 +    }
   4.209 +    else {
   4.210 +        dst_ = PEP_messageDictFromStruct(_src);
   4.211 +    }
   4.212 +
   4.213 +    if (dst) {
   4.214 +        *dst = dst_;
   4.215 +    }
   4.216 +
   4.217 +    free_message(_src);
   4.218 +    free_message(_dst);
   4.219 +    free_identity(ident);
   4.220 +
   4.221 +    return status;
   4.222 +}
   4.223 +
   4.224 +- (PEP_rating)outgoingMessageColor:(PEPDict *)msg
   4.225 +{
   4.226 +    message * _msg = PEP_messageDictToStruct(msg);
   4.227 +    PEP_rating color = PEP_rating_undefined;
   4.228 +
   4.229 +    @synchronized (self) {
   4.230 +        outgoing_message_rating(_session, _msg, &color);
   4.231 +    }
   4.232 +
   4.233 +    free_message(_msg);
   4.234 +
   4.235 +    return color;
   4.236 +}
   4.237 +
   4.238 +- (PEP_rating)identityRating:(nonnull PEPDict *)identity
   4.239 +{
   4.240 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.241 +    PEP_rating color = PEP_rating_undefined;
   4.242 +
   4.243 +    @synchronized (self) {
   4.244 +        identity_rating(_session, ident, &color);
   4.245 +    }
   4.246 +
   4.247 +    free_identity(ident);
   4.248 +
   4.249 +    return color;
   4.250 +}
   4.251 +
   4.252 +DYNAMIC_API PEP_STATUS identity_rating(PEP_SESSION session, pEp_identity *ident, PEP_rating *color);
   4.253 +
   4.254 +- (NSArray *)trustwords:(NSString *)fpr forLanguage:(NSString *)languageID shortened:(BOOL)shortened
   4.255 +{
   4.256 +    NSMutableArray *array = [NSMutableArray array];
   4.257 +
   4.258 +    for (int i = 0; i < [fpr length]; i += 4) {
   4.259 +        if (shortened && i >= 20)
   4.260 +            break;
   4.261 +
   4.262 +        NSString *str = [fpr substringWithRange:NSMakeRange(i, 4)];
   4.263 +
   4.264 +        unsigned int value;
   4.265 +        [[NSScanner scannerWithString:str] scanHexInt:&value];
   4.266 +
   4.267 +        char *word;
   4.268 +        size_t size;
   4.269 +
   4.270 +        @synchronized (self) {
   4.271 +            trustword(_session, value, [languageID UTF8String], &word, &size);
   4.272 +        }
   4.273 +
   4.274 +        [array addObject:[NSString stringWithUTF8String:word]];
   4.275 +        free(word);
   4.276 +    }
   4.277 +
   4.278 +    return array;
   4.279 +}
   4.280 +
   4.281 +- (void)mySelf:(PEPMutableDict *)identity
   4.282 +{
   4.283 +    [identity removeObjectForKey:kPepUserID];
   4.284 +
   4.285 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.286 +
   4.287 +    @synchronized(self) {
   4.288 +        myself(_session, ident);
   4.289 +    }
   4.290 +
   4.291 +    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   4.292 +    free_identity(ident);
   4.293 +}
   4.294 +
   4.295 +- (void)updateIdentity:(PEPMutableDict *)identity
   4.296 +{
   4.297 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.298 +
   4.299 +    @synchronized(self) {
   4.300 +        update_identity(_session, ident);
   4.301 +    }
   4.302 +
   4.303 +    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   4.304 +    free_identity(ident);
   4.305 +}
   4.306 +
   4.307 +- (void)trustPersonalKey:(PEPMutableDict *)identity
   4.308 +{
   4.309 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.310 +
   4.311 +    @synchronized(self) {
   4.312 +        trust_personal_key(_session, ident);
   4.313 +    }
   4.314 +
   4.315 +    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   4.316 +    free_identity(ident);
   4.317 +}
   4.318 +
   4.319 +- (void)keyResetTrust:(PEPMutableDict *)identity
   4.320 +{
   4.321 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.322 +
   4.323 +    @synchronized(self) {
   4.324 +        key_reset_trust(_session, ident);
   4.325 +    }
   4.326 +
   4.327 +    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   4.328 +    free_identity(ident);
   4.329 +}
   4.330 +
   4.331 +- (void)keyMistrusted:(PEPMutableDict *)identity
   4.332 +{
   4.333 +    pEp_identity *ident = PEP_identityDictToStruct(identity);
   4.334 +
   4.335 +    @synchronized(self) {
   4.336 +        key_mistrusted(_session, ident);
   4.337 +    }
   4.338 +
   4.339 +    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   4.340 +    free_identity(ident);
   4.341 +}
   4.342 +
   4.343 +- (void)importKey:(NSString *)keydata
   4.344 +{
   4.345 +    @synchronized(self) {
   4.346 +        import_key(_session, [keydata UTF8String], [keydata length], NULL);
   4.347 +    }
   4.348 +
   4.349 +}
   4.350 +
   4.351 +- (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
   4.352 +     description:(nullable NSString *)description comment:(nullable NSString *)comment
   4.353 +{
   4.354 +    @synchronized(self) {
   4.355 +
   4.356 +        log_event(_session, [[title precomposedStringWithCanonicalMapping] UTF8String],
   4.357 +                  [[entity precomposedStringWithCanonicalMapping] UTF8String],
   4.358 +                  [[description precomposedStringWithCanonicalMapping] UTF8String],
   4.359 +                  [[comment precomposedStringWithCanonicalMapping] UTF8String]);
   4.360 +
   4.361 +    }
   4.362 +}
   4.363 +
   4.364 +- (nonnull NSString *)getLog
   4.365 +{
   4.366 +    char *data;
   4.367 +    @synchronized(self) {
   4.368 +        get_crashdump_log(_session, 0, &data);
   4.369 +    }
   4.370 +    
   4.371 +    NSString *logString = [NSString stringWithUTF8String:data];
   4.372 +    return logString;
   4.373 +}
   4.374 +
   4.375 +- (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
   4.376 +                                    identity2:(nonnull PEPDict *)identity2
   4.377 +                                     language:(nullable NSString *)language
   4.378 +                                         full:(BOOL)full
   4.379 +{
   4.380 +    NSString *result = nil;
   4.381 +    char *trustwords = nil;
   4.382 +    size_t sizeWritten = 0;
   4.383 +
   4.384 +    pEp_identity *ident1 = PEP_identityDictToStruct(identity1);
   4.385 +    pEp_identity *ident2 = PEP_identityDictToStruct(identity2);
   4.386 +    PEP_STATUS status;
   4.387 +    @synchronized(self) {
   4.388 +
   4.389 +        status = get_trustwords(_session, ident1, ident2,
   4.390 +                                [[language precomposedStringWithCanonicalMapping]
   4.391 +                                 UTF8String],
   4.392 +                                &trustwords, &sizeWritten, full);
   4.393 +    }
   4.394 +    if (status == PEP_STATUS_OK) {
   4.395 +        result = [NSString stringWithCString:trustwords
   4.396 +                                    encoding:NSUTF8StringEncoding];
   4.397 +    }
   4.398 +    if (trustwords) {
   4.399 +        free(trustwords);
   4.400 +    }
   4.401 +    return result;
   4.402 +}
   4.403 +
   4.404 +- (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
   4.405 +                                   receiverDict:(nonnull PEPDict *)receiverDict
   4.406 +                                      keysArray:(PEPStringList * _Nullable)keysArray
   4.407 +                                       language:(nullable NSString *)language
   4.408 +                                           full:(BOOL)full
   4.409 +                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
   4.410 +{
   4.411 +    NSString *result = nil;
   4.412 +    char *trustwords = nil;
   4.413 +
   4.414 +    message *theMessage = PEP_messageDictToStruct(messageDict);
   4.415 +
   4.416 +    stringlist_t *keyList = nil;
   4.417 +    if (keysArray) {
   4.418 +        keyList = PEP_arrayToStringlist(keysArray);
   4.419 +    }
   4.420 +
   4.421 +    pEp_identity *receiver = PEP_identityDictToStruct(receiverDict);
   4.422 +    PEP_STATUS status;
   4.423 +    @synchronized(self) {
   4.424 +        status = get_message_trustwords(_session, theMessage, keyList, receiver,
   4.425 +                                        [[language
   4.426 +                                          precomposedStringWithCanonicalMapping] UTF8String],
   4.427 +                                        &trustwords, full);
   4.428 +    }
   4.429 +    
   4.430 +    if (resultingStatus) {
   4.431 +        *resultingStatus = status;
   4.432 +    }
   4.433 +
   4.434 +    if (status == PEP_STATUS_OK) {
   4.435 +        result = [NSString stringWithCString:trustwords
   4.436 +                                    encoding:NSUTF8StringEncoding];
   4.437 +    }
   4.438 +    if (trustwords) {
   4.439 +        free(trustwords);
   4.440 +    }
   4.441 +    return result;
   4.442 +}
   4.443 +
   4.444 +- (NSArray<PEPLanguage *> * _Nonnull)languageList
   4.445 +{
   4.446 +    char *chLangs;
   4.447 +    @synchronized(self) {
   4.448 +        get_languagelist(_session, &chLangs);
   4.449 +    }
   4.450 +    NSString *parserInput = [NSString stringWithUTF8String:chLangs];
   4.451 +
   4.452 +    NSMutableArray<NSString *> *tokens = [NSMutableArray array];
   4.453 +    PEPCSVScanner *scanner = [[PEPCSVScanner alloc] initWithString:parserInput];
   4.454 +    while (YES) {
   4.455 +        NSString *token = [scanner nextString];
   4.456 +        if (!token) {
   4.457 +            break;
   4.458 +        }
   4.459 +        [tokens addObject:token];
   4.460 +    }
   4.461 +    
   4.462 +    NSArray *theTokens = [NSArray arrayWithArray:tokens];
   4.463 +    NSMutableArray<PEPLanguage *> *langs = [NSMutableArray new];
   4.464 +    while (YES) {
   4.465 +        ArrayTake *take = [theTokens takeOrNil:3];
   4.466 +        if (!take) {
   4.467 +            break;
   4.468 +        }
   4.469 +        NSArray *elements = take.elements;
   4.470 +        PEPLanguage *lang = [[PEPLanguage alloc]
   4.471 +                             initWithCode:[elements objectAtIndex:0]
   4.472 +                             name:[elements objectAtIndex:1]
   4.473 +                             sentence:[elements objectAtIndex:2]];
   4.474 +        [langs addObject:lang];
   4.475 +        theTokens = take.rest;
   4.476 +    }
   4.477 +    
   4.478 +    return [NSArray arrayWithArray:langs];
   4.479 +}
   4.480 +
   4.481 +- (PEP_STATUS)undoLastMistrust
   4.482 +{
   4.483 +    return undo_last_mistrust(_session);
   4.484 +}
   4.485 +
   4.486 +@end
     5.1 --- a/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Tue Oct 10 18:56:57 2017 +0200
     5.2 +++ b/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Wed Oct 11 09:59:01 2017 +0200
     5.3 @@ -12,8 +12,8 @@
     5.4  #import "sync.h"
     5.5  
     5.6  #import "PEPQueue.h"
     5.7 -#import "PEPSession.h"
     5.8 -#import "PEPSession+Internal.h"
     5.9 +#import "PEPInternalSession.h"
    5.10 +#import "PEPInternalSession+Internal.h"
    5.11  
    5.12  @interface PEPObjCAdapter ()
    5.13  
    5.14 @@ -29,8 +29,8 @@
    5.15  
    5.16  + (PEPQueue*)getSyncQueue;
    5.17  + (id <PEPSyncDelegate>)getSyncDelegate;
    5.18 -+ (void)bindSession:(PEPSession*)session;
    5.19 -+ (void)unbindSession:(PEPSession*)session;
    5.20 ++ (void)bindSession:(PEPInternalSession*)session;
    5.21 ++ (void)unbindSession:(PEPInternalSession*)session;
    5.22  
    5.23  
    5.24  @end
     6.1 --- a/pEpObjCAdapter/PEPObjCAdapter.m	Tue Oct 10 18:56:57 2017 +0200
     6.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.m	Wed Oct 11 09:59:01 2017 +0200
     6.3 @@ -378,7 +378,7 @@
     6.4      
     6.5      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
     6.6      NSValue* v;
     6.7 -    PEPSession* session;
     6.8 +    PEPInternalSession* session;
     6.9      @synchronized (sessionList) {
    6.10          for (v in sessionList) {
    6.11              session = [v nonretainedObjectValue];
    6.12 @@ -391,7 +391,7 @@
    6.13  {
    6.14      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    6.15      NSValue* v;
    6.16 -    PEPSession* session;
    6.17 +    PEPInternalSession* session;
    6.18      @synchronized (sessionList) {
    6.19          for (v in sessionList) {
    6.20              session = [v nonretainedObjectValue];
    6.21 @@ -432,7 +432,7 @@
    6.22      return syncDelegate;
    6.23  }
    6.24  
    6.25 -+ (void)bindSession:(PEPSession*)session
    6.26 ++ (void)bindSession:(PEPInternalSession*)session
    6.27  {
    6.28      NSMutableArray* sessionList = [PEPObjCAdapter boundSessions];
    6.29      @synchronized (sessionList) {
    6.30 @@ -443,7 +443,7 @@
    6.31      [PEPObjCAdapter attachSyncSession:[session session]];
    6.32  }
    6.33  
    6.34 -+ (void)unbindSession:(PEPSession*)session
    6.35 ++ (void)unbindSession:(PEPInternalSession*)session
    6.36  {
    6.37      [PEPObjCAdapter detachSyncSession:[session session]];
    6.38      
    6.39 @@ -584,13 +584,13 @@
    6.40                              dest:(PEPDict * _Nullable * _Nullable)dst
    6.41                              keys:(PEPStringList * _Nullable * _Nullable)keys
    6.42  {
    6.43 -    PEPSession *session = [PEPSessionProvider session];
    6.44 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.45      return [session decryptMessageDict:src dest:dst keys:keys];
    6.46  }
    6.47  
    6.48  + (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src
    6.49  {
    6.50 -    PEPSession *session = [PEPSessionProvider session];
    6.51 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.52      return [session reEvaluateMessageRating:src];
    6.53  }
    6.54  
    6.55 @@ -598,7 +598,7 @@
    6.56                             extra:(nullable PEPStringList *)keys
    6.57                              dest:(PEPDict * _Nullable * _Nullable)dst
    6.58  {
    6.59 -    PEPSession *session = [PEPSessionProvider session];
    6.60 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.61      return [session encryptMessageDict:src extra:keys dest:dst];
    6.62  }
    6.63  
    6.64 @@ -606,56 +606,56 @@
    6.65                          identity:(nonnull PEPDict *)identity
    6.66                              dest:(PEPDict * _Nullable * _Nullable)dst
    6.67  {
    6.68 -    PEPSession *session = [PEPSessionProvider session];
    6.69 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.70      return [session encryptMessageDict:src identity:identity dest:dst];
    6.71  }
    6.72  
    6.73  + (PEP_rating)outgoingMessageColor:(nonnull PEPDict *)msg
    6.74  {
    6.75 -    PEPSession *session = [PEPSessionProvider session];
    6.76 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.77      return [session outgoingMessageColor:msg];
    6.78  }
    6.79  
    6.80  + (PEP_rating)identityRating:(nonnull PEPDict *)identity
    6.81  {
    6.82 -    PEPSession *session = [PEPSessionProvider session];
    6.83 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.84      return [session identityRating:identity];
    6.85  }
    6.86  
    6.87  + (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
    6.88                        shortened:(BOOL)shortened
    6.89  {
    6.90 -    PEPSession *session = [PEPSessionProvider session];
    6.91 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.92      return [session trustwords:fpr forLanguage:languageID shortened:shortened];
    6.93  }
    6.94  
    6.95  + (void)mySelf:(nonnull PEPMutableDict *)identity
    6.96  {
    6.97 -    PEPSession *session = [PEPSessionProvider session];
    6.98 +    PEPInternalSession *session = [PEPSessionProvider session];
    6.99      [session mySelf:identity];
   6.100  }
   6.101  
   6.102  + (void)updateIdentity:(nonnull PEPMutableDict *)identity
   6.103  {
   6.104 -    PEPSession *session = [PEPSessionProvider session];
   6.105 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.106      [session updateIdentity:identity];
   6.107  }
   6.108  
   6.109  + (void)trustPersonalKey:(nonnull PEPMutableDict *)identity
   6.110  {
   6.111 -    PEPSession *session = [PEPSessionProvider session];
   6.112 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.113      [session trustPersonalKey:identity];
   6.114  }
   6.115  
   6.116  + (void)keyMistrusted:(nonnull PEPMutableDict *)identity
   6.117  {
   6.118 -    PEPSession *session = [PEPSessionProvider session];
   6.119 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.120      [session keyMistrusted:identity];
   6.121  }
   6.122  
   6.123  + (void)keyResetTrust:(nonnull PEPMutableDict *)identity
   6.124  {
   6.125 -    PEPSession *session = [PEPSessionProvider session];
   6.126 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.127      [session keyResetTrust:identity];
   6.128  }
   6.129  
   6.130 @@ -663,20 +663,20 @@
   6.131  
   6.132  + (void)importKey:(nonnull NSString *)keydata
   6.133  {
   6.134 -    PEPSession *session = [PEPSessionProvider session];
   6.135 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.136      [session importKey:keydata];
   6.137  }
   6.138  
   6.139  + (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
   6.140       description:(nullable NSString *)description comment:(nullable NSString *)comment
   6.141  {
   6.142 -    PEPSession *session = [PEPSessionProvider session];
   6.143 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.144      [session logTitle:title entity:entity description:description comment:comment];
   6.145  }
   6.146  
   6.147  + (nonnull NSString *)getLog
   6.148  {
   6.149 -    PEPSession *session = [PEPSessionProvider session];
   6.150 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.151      return [session getLog];
   6.152  }
   6.153  
   6.154 @@ -685,7 +685,7 @@
   6.155                                       language:(nullable NSString *)language
   6.156                                           full:(BOOL)full
   6.157  {
   6.158 -    PEPSession *session = [PEPSessionProvider session];
   6.159 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.160      return [session getTrustwordsIdentity1:identity1 identity2:identity2 language:language full:full];
   6.161  }
   6.162  
   6.163 @@ -696,19 +696,19 @@
   6.164                                             full:(BOOL)full
   6.165                                  resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
   6.166  {
   6.167 -    PEPSession *session = [PEPSessionProvider session];
   6.168 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.169      return [session getTrustwordsMessageDict:messageDict receiverDict:receiverDict keysArray:keysArray language:language full:full resultingStatus:resultingStatus];
   6.170  }
   6.171  
   6.172  + (NSArray<PEPLanguage *> * _Nonnull)languageList
   6.173  {
   6.174 -    PEPSession *session = [PEPSessionProvider session];
   6.175 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.176      return [session languageList];
   6.177  }
   6.178  
   6.179  + (PEP_STATUS)undoLastMistrust
   6.180  {
   6.181 -    PEPSession *session = [PEPSessionProvider session];
   6.182 +    PEPInternalSession *session = [PEPSessionProvider session];
   6.183      return [session undoLastMistrust];
   6.184  }
   6.185  
     7.1 --- a/pEpObjCAdapter/PEPSession+Internal.h	Tue Oct 10 18:56:57 2017 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,136 +0,0 @@
     7.4 -//
     7.5 -//  PEPSession+Internal.h
     7.6 -//  pEpiOSAdapter
     7.7 -//
     7.8 -//  Created by Edouard Tisserant on 16.05.17.
     7.9 -//  Copyright © 2017 p≡p. All rights reserved.
    7.10 -//
    7.11 -
    7.12 -#ifndef PEPSession_internal_h
    7.13 -#define PEPSession_internal_h
    7.14 -
    7.15 -#import "PEPObjCAdapter.h"
    7.16 -
    7.17 -@interface PEPSession ()
    7.18 -
    7.19 -@property (nonatomic) PEP_SESSION _Nullable session;
    7.20 -
    7.21 -- (id _Nullable)initInternal;
    7.22 -
    7.23 -/** Decrypt a message */
    7.24 -- (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
    7.25 -                            dest:(PEPDict * _Nullable * _Nullable)dst
    7.26 -                            keys:(PEPStringList * _Nullable * _Nullable)keys;
    7.27 -
    7.28 -/** Re-evaluate rating of decrypted message */
    7.29 -- (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src;
    7.30 -
    7.31 -/** Encrypt a message */
    7.32 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    7.33 -                           extra:(nullable PEPStringList *)keys
    7.34 -                            dest:(PEPDict * _Nullable * _Nullable)dst;
    7.35 -
    7.36 -/** Encrypt a message for the given identity, which is usually a mySelf identity */
    7.37 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
    7.38 -                        identity:(nonnull PEPDict *)identity
    7.39 -                            dest:(PEPDict * _Nullable * _Nullable)dst;
    7.40 -
    7.41 -/** Determine the status color of a message to be sent */
    7.42 -- (PEP_rating)outgoingMessageColor:(nonnull PEPDict *)msg;
    7.43 -
    7.44 -/** Determine the rating of an identity */
    7.45 -- (PEP_rating)identityRating:(nonnull PEPDict *)identity;
    7.46 -
    7.47 -/** Get trustwords for a fingerprint */
    7.48 -- (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
    7.49 -                      shortened:(BOOL)shortened;
    7.50 -
    7.51 -/**
    7.52 - Supply an account used by our user himself. The identity is supplemented with the missing parts
    7.53 - 
    7.54 - An identity is a `NSDictionary` mapping a field name as `NSString` to different values.
    7.55 - An identity can have the following fields (all other keys are ignored).
    7.56 - It is not necessary to supply all fields; missing fields are supplemented by p≡p engine.
    7.57 - 
    7.58 - @"username": real name or nick name (if pseudonymous) of identity
    7.59 - @"address": URI or SMTP address
    7.60 - @"user_id": persistent unique ID for identity
    7.61 - @"lang": preferred languageID for communication with this ID (default: @"en")
    7.62 - @"fpr": fingerprint of key to use for communication with this ID
    7.63 - @"comm_type": communication type code (usually not needed)
    7.64 - 
    7.65 - As an example:
    7.66 - 
    7.67 - User has a mailbox. The mail address is "Dipul Khatri <dipul@inboxcube.com>". Then this would be:
    7.68 - 
    7.69 - NSDictionary *ident = [NSDictionary dictionaryWithObjectsAndKeys:
    7.70 - @"Dipul Khatri", @"username", @"dipul@inboxcube.com", @"address",
    7.71 - @"23", @"user_id", nil];
    7.72 - 
    7.73 - */
    7.74 -- (void)mySelf:(nonnull PEPMutableDict *)identity;
    7.75 -
    7.76 -/**
    7.77 - Supplement missing information for an arbitrary identity (used for communication partners).
    7.78 - See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    7.79 - */
    7.80 -- (void)updateIdentity:(nonnull PEPMutableDict *)identity;
    7.81 -
    7.82 -/**
    7.83 - Mark a key as trusted with a person.
    7.84 - See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    7.85 - */
    7.86 -- (void)trustPersonalKey:(nonnull PEPMutableDict *)identity;
    7.87 -
    7.88 -/**
    7.89 - if a key is not trusted by the user tell this using this message
    7.90 - See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    7.91 - */
    7.92 -- (void)keyMistrusted:(nonnull PEPMutableDict *)identity;
    7.93 -
    7.94 -/**
    7.95 - Use this to undo keyCompromized or trustPersonalKey
    7.96 - See `mySelf:(NSMutableDictionary *)identity` for an explanation of identities.
    7.97 - */
    7.98 -- (void)keyResetTrust:(nonnull PEPMutableDict *)identity;
    7.99 -
   7.100 -#pragma mark -- Internal API (testing etc.)
   7.101 -
   7.102 -/** For testing purpose, manual key import */
   7.103 -- (void)importKey:(nonnull NSString *)keydata;
   7.104 -
   7.105 -- (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
   7.106 -     description:(nullable NSString *)description comment:(nullable NSString *)comment;
   7.107 -
   7.108 -/**
   7.109 - Retrieves the log from the engine.
   7.110 - */
   7.111 -- (nonnull NSString *)getLog;
   7.112 -
   7.113 -/** Determine trustwords for two identities */
   7.114 -- (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
   7.115 -                                    identity2:(nonnull PEPDict *)identity2
   7.116 -                                     language:(nullable NSString *)language
   7.117 -                                         full:(BOOL)full;
   7.118 -
   7.119 -/** Determine trustwords between sender of a message and receiving identity */
   7.120 -- (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
   7.121 -                                   receiverDict:(nonnull PEPDict *)receiverDict
   7.122 -                                      keysArray:(PEPStringList * _Nullable)keysArray
   7.123 -                                       language:(nullable NSString *)language
   7.124 -                                           full:(BOOL)full
   7.125 -                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus;
   7.126 -
   7.127 -/**
   7.128 - @returns The list of supported languages for trustwords.
   7.129 - */
   7.130 -- (NSArray<PEPLanguage *> * _Nonnull)languageList;
   7.131 -
   7.132 -/**
   7.133 - Directly invokes the engine's undo_last_mistrust() function
   7.134 - */
   7.135 -- (PEP_STATUS)undoLastMistrust;
   7.136 -
   7.137 -@end
   7.138 -
   7.139 -#endif /* PEPSession_internal_h */
     8.1 --- a/pEpObjCAdapter/PEPSession.h	Tue Oct 10 18:56:57 2017 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,18 +0,0 @@
     8.4 -//
     8.5 -//  PEPSession.h
     8.6 -//  pEpiOSAdapter
     8.7 -//
     8.8 -//  Created by Volker Birk on 08.07.15.
     8.9 -//  Copyright (c) 2015 p≡p. All rights reserved.
    8.10 -//
    8.11 -
    8.12 -#import <Foundation/Foundation.h>
    8.13 -
    8.14 -/**
    8.15 - N threads <-> N sessions, with the constraint that a session is never used
    8.16 - in a pEpEngine call more than once at the same time.
    8.17 - */
    8.18 -@interface PEPSession : NSObject
    8.19 -// We do not want the client to use a PEPSession. The client is supposed to use PEPObjCAdapter() only.
    8.20 -// Find everything in PEPSession+Internal.h
    8.21 -@end
     9.1 --- a/pEpObjCAdapter/PEPSession.m	Tue Oct 10 18:56:57 2017 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,483 +0,0 @@
     9.4 -//
     9.5 -//  PEPSession.m
     9.6 -//  pEpiOSAdapter
     9.7 -//
     9.8 -//  Created by Volker Birk on 08.07.15.
     9.9 -//  Copyright (c) 2015 p≡p. All rights reserved.
    9.10 -//
    9.11 -
    9.12 -#import "PEPSession.h"
    9.13 -#import "PEPSession+Internal.h"
    9.14 -#import "PEPObjCAdapter.h"
    9.15 -#import "PEPObjCAdapter+Internal.h"
    9.16 -#import "PEPMessage.h"
    9.17 -#import "PEPLanguage.h"
    9.18 -#import "PEPCSVScanner.h"
    9.19 -#import "NSArray+Extension.h"
    9.20 -#import "NSDictionary+Extension.h"
    9.21 -
    9.22 -@implementation PEPSession
    9.23 -
    9.24 -+ (void)setupTrustWordsDB
    9.25 -{
    9.26 -    static dispatch_once_t once;
    9.27 -    dispatch_once(&once, ^{
    9.28 -        [PEPObjCAdapter setupTrustWordsDB:[NSBundle bundleForClass:[self class]]];
    9.29 -    });
    9.30 -}
    9.31 -
    9.32 -- (id)init
    9.33 -{
    9.34 -    //"Denied access to assure clients do not call [PEPSession new] accidentally. Use initInternal instead.
    9.35 -    NSAssert(false, @"Dear client. You must not use PEPSession. Use PEPObjCAdapter instead");
    9.36 -    return nil;
    9.37 -}
    9.38 -
    9.39 -- (id)initInternal
    9.40 -{
    9.41 -    [PEPSession setupTrustWordsDB];
    9.42 -
    9.43 -    [[PEPObjCAdapter initLock] lock];
    9.44 -    PEP_STATUS status = init(&_session);
    9.45 -    [[PEPObjCAdapter initLock] unlock];
    9.46 -
    9.47 -    if (status != PEP_STATUS_OK) {
    9.48 -        return nil;
    9.49 -    }
    9.50 -
    9.51 -    [PEPObjCAdapter bindSession:self];
    9.52 -
    9.53 -    return self;
    9.54 -}
    9.55 -
    9.56 -- (void)dealloc
    9.57 -{
    9.58 -    [PEPObjCAdapter unbindSession:self];
    9.59 -
    9.60 -    [[PEPObjCAdapter initLock] lock];
    9.61 -    release(_session);
    9.62 -    [[PEPObjCAdapter initLock] unlock];
    9.63 -
    9.64 -}
    9.65 -
    9.66 -/**
    9.67 - Saves the given message dict as a plist to the local filesystem
    9.68 - (directly under NSApplicationSupportDirectory).
    9.69 - Since the complete output file will be logged by `debugSaveToFilePath`,
    9.70 - you can get access to the files easily when it's the simulator.
    9.71 - */
    9.72 -- (void)debugOutPutMessageDict:(nonnull PEPDict *)src
    9.73 -{
    9.74 -    NSString *from = src[kPepFrom][kPepAddress];
    9.75 -    NSArray *tos = src[kPepTo];
    9.76 -    NSString *to = tos[0][kPepAddress];
    9.77 -    NSString *msgID = src[kPepID];
    9.78 -    NSString *fileName = [NSString stringWithFormat:@"%@_from(%@)_%@",
    9.79 -                          to, from, msgID];
    9.80 -    [src debugSaveToFilePath:fileName];
    9.81 -}
    9.82 -
    9.83 -- (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
    9.84 -                            dest:(PEPDict * _Nullable * _Nullable)dst
    9.85 -                            keys:(PEPStringList * _Nullable * _Nullable)keys
    9.86 -{
    9.87 -    message * _src = PEP_messageDictToStruct(src);
    9.88 -    message * _dst = NULL;
    9.89 -    stringlist_t * _keys = NULL;
    9.90 -    PEP_rating color = PEP_rating_undefined;
    9.91 -    PEP_decrypt_flags_t flags = 0;
    9.92 -
    9.93 -    @synchronized (self) {
    9.94 -        decrypt_message(_session, _src, &_dst, &_keys, &color, &flags);
    9.95 -    }
    9.96 -
    9.97 -    NSDictionary * dst_;
    9.98 -
    9.99 -    if (_dst) {
   9.100 -        dst_ = PEP_messageDictFromStruct(_dst);
   9.101 -    }
   9.102 -    else {
   9.103 -        dst_ = PEP_messageDictFromStruct(_src);
   9.104 -    }
   9.105 -
   9.106 -    NSArray * keys_ = nil;
   9.107 -    if (_keys)
   9.108 -        keys_ = PEP_arrayFromStringlist(_keys);
   9.109 -
   9.110 -    free_message(_src);
   9.111 -    free_message(_dst);
   9.112 -    free_stringlist(_keys);
   9.113 -
   9.114 -    if (dst) {
   9.115 -        *dst = dst_;
   9.116 -    }
   9.117 -    if (keys) {
   9.118 -        *keys = keys_;
   9.119 -    }
   9.120 -    return color;
   9.121 -}
   9.122 -
   9.123 -- (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src
   9.124 -{
   9.125 -    message * _src = PEP_messageDictToStruct(src);
   9.126 -    PEP_rating color = PEP_rating_undefined;
   9.127 -
   9.128 -    @synchronized (self) {
   9.129 -        re_evaluate_message_rating(_session, _src, NULL, PEP_rating_undefined, &color);
   9.130 -    }
   9.131 -
   9.132 -    free_message(_src);
   9.133 -
   9.134 -    return color;
   9.135 -}
   9.136 -
   9.137 -- (void)removeEmptyArrayKey:(NSString *)key inDict:(PEPMutableDict *)dict
   9.138 -{
   9.139 -    if ([[dict objectForKey:key] count] == 0) {
   9.140 -        [dict removeObjectForKey:key];
   9.141 -    }
   9.142 -}
   9.143 -
   9.144 -- (NSDictionary *)removeEmptyRecipients:(PEPDict *)src
   9.145 -{
   9.146 -    NSMutableDictionary *dest = src.mutableCopy;
   9.147 -
   9.148 -    [self removeEmptyArrayKey:kPepTo inDict:dest];
   9.149 -    [self removeEmptyArrayKey:kPepCC inDict:dest];
   9.150 -    [self removeEmptyArrayKey:kPepBCC inDict:dest];
   9.151 -
   9.152 -    return [NSDictionary dictionaryWithDictionary:dest];
   9.153 -}
   9.154 -
   9.155 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
   9.156 -                           extra:(nullable NSArray *)keys
   9.157 -                            dest:(PEPDict * _Nullable * _Nullable)dst
   9.158 -{
   9.159 -    PEP_STATUS status;
   9.160 -    PEP_encrypt_flags_t flags = 0;
   9.161 -
   9.162 -    message * _src = PEP_messageDictToStruct([self removeEmptyRecipients:src]);
   9.163 -    message * _dst = NULL;
   9.164 -    stringlist_t * _keys = PEP_arrayToStringlist(keys);
   9.165 -
   9.166 -    @synchronized (self) {
   9.167 -        status = encrypt_message(_session, _src, _keys, &_dst, PEP_enc_PGP_MIME, flags);
   9.168 -    }
   9.169 -
   9.170 -    NSDictionary * dst_;
   9.171 -
   9.172 -    if (_dst) {
   9.173 -        dst_ = PEP_messageDictFromStruct(_dst);
   9.174 -    }
   9.175 -    else {
   9.176 -        dst_ = PEP_messageDictFromStruct(_src);
   9.177 -    }
   9.178 -    if (dst) {
   9.179 -        *dst = dst_;
   9.180 -    }
   9.181 -
   9.182 -    free_message(_src);
   9.183 -    free_message(_dst);
   9.184 -    free_stringlist(_keys);
   9.185 -
   9.186 -    return status;
   9.187 -}
   9.188 -
   9.189 -- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
   9.190 -                        identity:(nonnull PEPDict *)identity
   9.191 -                            dest:(PEPDict * _Nullable * _Nullable)dst
   9.192 -{
   9.193 -    PEP_STATUS status;
   9.194 -    PEP_encrypt_flags_t flags = 0;
   9.195 -
   9.196 -    message * _src = PEP_messageDictToStruct([self removeEmptyRecipients:src]);
   9.197 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.198 -    message * _dst = NULL;
   9.199 -
   9.200 -    @synchronized (self) {
   9.201 -        status = encrypt_message_for_self(_session, ident, _src, &_dst, PEP_enc_PGP_MIME, flags);
   9.202 -    }
   9.203 -
   9.204 -    NSDictionary * dst_;
   9.205 -
   9.206 -    if (_dst) {
   9.207 -        dst_ = PEP_messageDictFromStruct(_dst);
   9.208 -    }
   9.209 -    else {
   9.210 -        dst_ = PEP_messageDictFromStruct(_src);
   9.211 -    }
   9.212 -
   9.213 -    if (dst) {
   9.214 -        *dst = dst_;
   9.215 -    }
   9.216 -
   9.217 -    free_message(_src);
   9.218 -    free_message(_dst);
   9.219 -    free_identity(ident);
   9.220 -
   9.221 -    return status;
   9.222 -}
   9.223 -
   9.224 -- (PEP_rating)outgoingMessageColor:(PEPDict *)msg
   9.225 -{
   9.226 -    message * _msg = PEP_messageDictToStruct(msg);
   9.227 -    PEP_rating color = PEP_rating_undefined;
   9.228 -
   9.229 -    @synchronized (self) {
   9.230 -        outgoing_message_rating(_session, _msg, &color);
   9.231 -    }
   9.232 -
   9.233 -    free_message(_msg);
   9.234 -
   9.235 -    return color;
   9.236 -}
   9.237 -
   9.238 -- (PEP_rating)identityRating:(nonnull PEPDict *)identity
   9.239 -{
   9.240 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.241 -    PEP_rating color = PEP_rating_undefined;
   9.242 -
   9.243 -    @synchronized (self) {
   9.244 -        identity_rating(_session, ident, &color);
   9.245 -    }
   9.246 -
   9.247 -    free_identity(ident);
   9.248 -
   9.249 -    return color;
   9.250 -}
   9.251 -
   9.252 -DYNAMIC_API PEP_STATUS identity_rating(PEP_SESSION session, pEp_identity *ident, PEP_rating *color);
   9.253 -
   9.254 -- (NSArray *)trustwords:(NSString *)fpr forLanguage:(NSString *)languageID shortened:(BOOL)shortened
   9.255 -{
   9.256 -    NSMutableArray *array = [NSMutableArray array];
   9.257 -
   9.258 -    for (int i = 0; i < [fpr length]; i += 4) {
   9.259 -        if (shortened && i >= 20)
   9.260 -            break;
   9.261 -
   9.262 -        NSString *str = [fpr substringWithRange:NSMakeRange(i, 4)];
   9.263 -
   9.264 -        unsigned int value;
   9.265 -        [[NSScanner scannerWithString:str] scanHexInt:&value];
   9.266 -
   9.267 -        char *word;
   9.268 -        size_t size;
   9.269 -
   9.270 -        @synchronized (self) {
   9.271 -            trustword(_session, value, [languageID UTF8String], &word, &size);
   9.272 -        }
   9.273 -
   9.274 -        [array addObject:[NSString stringWithUTF8String:word]];
   9.275 -        free(word);
   9.276 -    }
   9.277 -
   9.278 -    return array;
   9.279 -}
   9.280 -
   9.281 -- (void)mySelf:(PEPMutableDict *)identity
   9.282 -{
   9.283 -    [identity removeObjectForKey:kPepUserID];
   9.284 -
   9.285 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.286 -
   9.287 -    @synchronized(self) {
   9.288 -        myself(_session, ident);
   9.289 -    }
   9.290 -
   9.291 -    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   9.292 -    free_identity(ident);
   9.293 -}
   9.294 -
   9.295 -- (void)updateIdentity:(PEPMutableDict *)identity
   9.296 -{
   9.297 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.298 -
   9.299 -    @synchronized(self) {
   9.300 -        update_identity(_session, ident);
   9.301 -    }
   9.302 -
   9.303 -    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   9.304 -    free_identity(ident);
   9.305 -}
   9.306 -
   9.307 -- (void)trustPersonalKey:(PEPMutableDict *)identity
   9.308 -{
   9.309 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.310 -
   9.311 -    @synchronized(self) {
   9.312 -        trust_personal_key(_session, ident);
   9.313 -    }
   9.314 -
   9.315 -    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   9.316 -    free_identity(ident);
   9.317 -}
   9.318 -
   9.319 -- (void)keyResetTrust:(PEPMutableDict *)identity
   9.320 -{
   9.321 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.322 -
   9.323 -    @synchronized(self) {
   9.324 -        key_reset_trust(_session, ident);
   9.325 -    }
   9.326 -
   9.327 -    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   9.328 -    free_identity(ident);
   9.329 -}
   9.330 -
   9.331 -- (void)keyMistrusted:(PEPMutableDict *)identity
   9.332 -{
   9.333 -    pEp_identity *ident = PEP_identityDictToStruct(identity);
   9.334 -
   9.335 -    @synchronized(self) {
   9.336 -        key_mistrusted(_session, ident);
   9.337 -    }
   9.338 -
   9.339 -    [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
   9.340 -    free_identity(ident);
   9.341 -}
   9.342 -
   9.343 -- (void)importKey:(NSString *)keydata
   9.344 -{
   9.345 -    @synchronized(self) {
   9.346 -        import_key(_session, [keydata UTF8String], [keydata length], NULL);
   9.347 -    }
   9.348 -
   9.349 -}
   9.350 -
   9.351 -- (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
   9.352 -     description:(nullable NSString *)description comment:(nullable NSString *)comment
   9.353 -{
   9.354 -    @synchronized(self) {
   9.355 -
   9.356 -        log_event(_session, [[title precomposedStringWithCanonicalMapping] UTF8String],
   9.357 -                  [[entity precomposedStringWithCanonicalMapping] UTF8String],
   9.358 -                  [[description precomposedStringWithCanonicalMapping] UTF8String],
   9.359 -                  [[comment precomposedStringWithCanonicalMapping] UTF8String]);
   9.360 -
   9.361 -    }
   9.362 -}
   9.363 -
   9.364 -- (nonnull NSString *)getLog
   9.365 -{
   9.366 -    char *data;
   9.367 -    @synchronized(self) {
   9.368 -        get_crashdump_log(_session, 0, &data);
   9.369 -    }
   9.370 -    
   9.371 -    NSString *logString = [NSString stringWithUTF8String:data];
   9.372 -    return logString;
   9.373 -}
   9.374 -
   9.375 -- (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
   9.376 -                                    identity2:(nonnull PEPDict *)identity2
   9.377 -                                     language:(nullable NSString *)language
   9.378 -                                         full:(BOOL)full
   9.379 -{
   9.380 -    NSString *result = nil;
   9.381 -    char *trustwords = nil;
   9.382 -    size_t sizeWritten = 0;
   9.383 -
   9.384 -    pEp_identity *ident1 = PEP_identityDictToStruct(identity1);
   9.385 -    pEp_identity *ident2 = PEP_identityDictToStruct(identity2);
   9.386 -    PEP_STATUS status;
   9.387 -    @synchronized(self) {
   9.388 -
   9.389 -        status = get_trustwords(_session, ident1, ident2,
   9.390 -                                [[language precomposedStringWithCanonicalMapping]
   9.391 -                                 UTF8String],
   9.392 -                                &trustwords, &sizeWritten, full);
   9.393 -    }
   9.394 -    if (status == PEP_STATUS_OK) {
   9.395 -        result = [NSString stringWithCString:trustwords
   9.396 -                                    encoding:NSUTF8StringEncoding];
   9.397 -    }
   9.398 -    if (trustwords) {
   9.399 -        free(trustwords);
   9.400 -    }
   9.401 -    return result;
   9.402 -}
   9.403 -
   9.404 -- (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
   9.405 -                                   receiverDict:(nonnull PEPDict *)receiverDict
   9.406 -                                      keysArray:(PEPStringList * _Nullable)keysArray
   9.407 -                                       language:(nullable NSString *)language
   9.408 -                                           full:(BOOL)full
   9.409 -                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
   9.410 -{
   9.411 -    NSString *result = nil;
   9.412 -    char *trustwords = nil;
   9.413 -
   9.414 -    message *theMessage = PEP_messageDictToStruct(messageDict);
   9.415 -
   9.416 -    stringlist_t *keyList = nil;
   9.417 -    if (keysArray) {
   9.418 -        keyList = PEP_arrayToStringlist(keysArray);
   9.419 -    }
   9.420 -
   9.421 -    pEp_identity *receiver = PEP_identityDictToStruct(receiverDict);
   9.422 -    PEP_STATUS status;
   9.423 -    @synchronized(self) {
   9.424 -        status = get_message_trustwords(_session, theMessage, keyList, receiver,
   9.425 -                                        [[language
   9.426 -                                          precomposedStringWithCanonicalMapping] UTF8String],
   9.427 -                                        &trustwords, full);
   9.428 -    }
   9.429 -    
   9.430 -    if (resultingStatus) {
   9.431 -        *resultingStatus = status;
   9.432 -    }
   9.433 -
   9.434 -    if (status == PEP_STATUS_OK) {
   9.435 -        result = [NSString stringWithCString:trustwords
   9.436 -                                    encoding:NSUTF8StringEncoding];
   9.437 -    }
   9.438 -    if (trustwords) {
   9.439 -        free(trustwords);
   9.440 -    }
   9.441 -    return result;
   9.442 -}
   9.443 -
   9.444 -- (NSArray<PEPLanguage *> * _Nonnull)languageList
   9.445 -{
   9.446 -    char *chLangs;
   9.447 -    @synchronized(self) {
   9.448 -        get_languagelist(_session, &chLangs);
   9.449 -    }
   9.450 -    NSString *parserInput = [NSString stringWithUTF8String:chLangs];
   9.451 -
   9.452 -    NSMutableArray<NSString *> *tokens = [NSMutableArray array];
   9.453 -    PEPCSVScanner *scanner = [[PEPCSVScanner alloc] initWithString:parserInput];
   9.454 -    while (YES) {
   9.455 -        NSString *token = [scanner nextString];
   9.456 -        if (!token) {
   9.457 -            break;
   9.458 -        }
   9.459 -        [tokens addObject:token];
   9.460 -    }
   9.461 -    
   9.462 -    NSArray *theTokens = [NSArray arrayWithArray:tokens];
   9.463 -    NSMutableArray<PEPLanguage *> *langs = [NSMutableArray new];
   9.464 -    while (YES) {
   9.465 -        ArrayTake *take = [theTokens takeOrNil:3];
   9.466 -        if (!take) {
   9.467 -            break;
   9.468 -        }
   9.469 -        NSArray *elements = take.elements;
   9.470 -        PEPLanguage *lang = [[PEPLanguage alloc]
   9.471 -                             initWithCode:[elements objectAtIndex:0]
   9.472 -                             name:[elements objectAtIndex:1]
   9.473 -                             sentence:[elements objectAtIndex:2]];
   9.474 -        [langs addObject:lang];
   9.475 -        theTokens = take.rest;
   9.476 -    }
   9.477 -    
   9.478 -    return [NSArray arrayWithArray:langs];
   9.479 -}
   9.480 -
   9.481 -- (PEP_STATUS)undoLastMistrust
   9.482 -{
   9.483 -    return undo_last_mistrust(_session);
   9.484 -}
   9.485 -
   9.486 -@end
    10.1 --- a/pEpObjCAdapter/PEPSessionProvider.h	Tue Oct 10 18:56:57 2017 +0200
    10.2 +++ b/pEpObjCAdapter/PEPSessionProvider.h	Wed Oct 11 09:59:01 2017 +0200
    10.3 @@ -8,11 +8,11 @@
    10.4  
    10.5  #import <Foundation/Foundation.h>
    10.6  
    10.7 -@class PEPSession;
    10.8 +@class PEPInternalSession;
    10.9  
   10.10  @interface PEPSessionProvider : NSObject
   10.11  
   10.12 -+ (PEPSession * _Nonnull)session;
   10.13 ++ (PEPInternalSession * _Nonnull)session;
   10.14  
   10.15  + (void)cleanup;
   10.16  
    11.1 --- a/pEpObjCAdapter/PEPSessionProvider.m	Tue Oct 10 18:56:57 2017 +0200
    11.2 +++ b/pEpObjCAdapter/PEPSessionProvider.m	Wed Oct 11 09:59:01 2017 +0200
    11.3 @@ -8,26 +8,26 @@
    11.4  
    11.5  #import "PEPSessionProvider.h"
    11.6  
    11.7 -#import "PEPSession.h"
    11.8 -#import "PEPSession+Internal.h"
    11.9 +#import "PEPInternalSession.h"
   11.10 +#import "PEPInternalSession+Internal.h"
   11.11  #import "PEPCopyableThread.h"
   11.12  
   11.13  @implementation PEPSessionProvider
   11.14  
   11.15  static NSLock *s_sessionForThreadLock = nil;
   11.16 -static NSMutableDictionary<PEPCopyableThread*,PEPSession*> *s_sessionForThreadDict;
   11.17 +static NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *s_sessionForThreadDict;
   11.18  
   11.19  #pragma mark - Public API
   11.20  
   11.21 -+ (PEPSession * _Nonnull)session
   11.22 ++ (PEPInternalSession * _Nonnull)session
   11.23  {
   11.24      [[self sessionForThreadLock] lock];
   11.25  
   11.26      PEPCopyableThread *currentThread = [[PEPCopyableThread alloc] initWithThread:[NSThread currentThread]];
   11.27 -    NSMutableDictionary<PEPCopyableThread*,PEPSession*> *dict = [self sessionForThreadDict];
   11.28 -    PEPSession *session = dict[currentThread];
   11.29 +    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
   11.30 +    PEPInternalSession *session = dict[currentThread];
   11.31      if (!session) {
   11.32 -        session = [[PEPSession alloc] initInternal];
   11.33 +        session = [[PEPInternalSession alloc] initInternal];
   11.34          dict[currentThread] = session;
   11.35      }
   11.36      [self nullifySesssionOfFinishedThreads];
   11.37 @@ -41,7 +41,7 @@
   11.38  {
   11.39      [[self sessionForThreadLock] lock];
   11.40  
   11.41 -    NSMutableDictionary<PEPCopyableThread*,PEPSession*> *dict = [self sessionForThreadDict];
   11.42 +    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
   11.43      for (PEPCopyableThread *thread in dict.allKeys) {
   11.44          [thread cancel];
   11.45          [self nullifySessionForThread:thread];
   11.46 @@ -75,7 +75,7 @@
   11.47  
   11.48  + (void)nullifySesssionOfFinishedThreads
   11.49  {
   11.50 -    NSMutableDictionary<PEPCopyableThread*,PEPSession*> *dict = [self sessionForThreadDict];
   11.51 +    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
   11.52      for (PEPCopyableThread *thread in dict.allKeys) {
   11.53          if (thread.isFinished) {
   11.54              [self nullifySessionForThread:thread];
   11.55 @@ -85,8 +85,8 @@
   11.56  
   11.57  + (void)nullifySessionForThread:(PEPCopyableThread *)thread
   11.58  {
   11.59 -    NSMutableDictionary<PEPCopyableThread*,PEPSession*> *dict = [self sessionForThreadDict];
   11.60 -    PEPSession *session = dict[thread];
   11.61 +    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
   11.62 +    PEPInternalSession *session = dict[thread];
   11.63      [self performSelector:@selector(nullifySession:)
   11.64                   onThread:thread.thread
   11.65                 withObject:session
   11.66 @@ -94,7 +94,7 @@
   11.67      dict[thread] = nil;
   11.68  }
   11.69  
   11.70 -+ (void)nullifySession:(PEPSession *)session
   11.71 ++ (void)nullifySession:(PEPInternalSession *)session
   11.72  {
   11.73      session = nil;
   11.74  }
    12.1 --- a/pEpObjCTests/iOSTests.m	Tue Oct 10 18:56:57 2017 +0200
    12.2 +++ b/pEpObjCTests/iOSTests.m	Wed Oct 11 09:59:01 2017 +0200
    12.3 @@ -9,7 +9,7 @@
    12.4  #import <XCTest/XCTest.h>
    12.5  
    12.6  #import "PEPObjCAdapter.h"
    12.7 -#import "PEPSession.h"
    12.8 +#import "PEPInternalSession.h"
    12.9  
   12.10  #import "NSDictionary+Extension.h"
   12.11  
   12.12 @@ -92,7 +92,7 @@
   12.13  
   12.14  @implementation iOSTests
   12.15  
   12.16 -PEPSession *session;
   12.17 +PEPInternalSession *session;
   12.18  
   12.19  #pragma mark -- Helpers
   12.20  
   12.21 @@ -171,7 +171,7 @@
   12.22          for(id path in [self pEpWorkFiles])
   12.23              [self undelFile:path:restore];
   12.24  
   12.25 -    session = [[PEPSession alloc]init];
   12.26 +    session = [[PEPInternalSession alloc]init];
   12.27      XCTAssert(session);
   12.28      
   12.29  }
   12.30 @@ -194,7 +194,7 @@
   12.31      return txtFileContents;
   12.32  }
   12.33  
   12.34 -- (void)importBundledKey:(NSString *)item intoSession:(PEPSession *)theSession
   12.35 +- (void)importBundledKey:(NSString *)item intoSession:(PEPInternalSession *)theSession
   12.36  {
   12.37  
   12.38      NSString *txtFileContents = [self loadStringFromFileName:item];
   12.39 @@ -228,7 +228,7 @@
   12.40  - (void)testNestedSessions {
   12.41      [self pEpSetUp];
   12.42  
   12.43 -    PEPSession *session2 = [[PEPSession alloc] init];
   12.44 +    PEPInternalSession *session2 = [[PEPInternalSession alloc] init];
   12.45  
   12.46      session2 = nil;
   12.47  
   12.48 @@ -349,7 +349,7 @@
   12.49  
   12.50      dispatch_queue_t queue = dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0);
   12.51      dispatch_sync(queue, ^{
   12.52 -        PEPSession *session2 = [[PEPSession alloc] init];
   12.53 +        PEPInternalSession *session2 = [[PEPInternalSession alloc] init];
   12.54  
   12.55          // Now simulate an update from the app, which usually only caches
   12.56          // kPepUsername, kPepAddress and optionally kPepUserID.
   12.57 @@ -1256,7 +1256,7 @@
   12.58      [self pEpCleanUp];
   12.59  }
   12.60  
   12.61 -- (void)doSomeWorkOnSession:(PEPSession *)session count:(NSInteger)count
   12.62 +- (void)doSomeWorkOnSession:(PEPInternalSession *)session count:(NSInteger)count
   12.63  {
   12.64      NSMutableDictionary *me = @{ kPepAddress: [NSString stringWithFormat:@"me%ld@dontcare.me",
   12.65                                                 (long)count],
   12.66 @@ -1280,7 +1280,7 @@
   12.67  
   12.68      for (int i = 1; i < 3; ++i) {
   12.69          dispatch_group_async(group, queue, ^{
   12.70 -            PEPSession *innerSession = [[PEPSession alloc] init];
   12.71 +            PEPInternalSession *innerSession = [[PEPInternalSession alloc] init];
   12.72              [self doSomeWorkOnSession:innerSession count:i];
   12.73              innerSession = nil;
   12.74          });
   12.75 @@ -1571,7 +1571,7 @@
   12.76      // me
   12.77      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
   12.78  
   12.79 -    PEPSession *someSession = [[PEPSession alloc] init];
   12.80 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
   12.81      //Some key
   12.82      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
   12.83      // This is the secret key for test001@peptest.ch
   12.84 @@ -1582,7 +1582,7 @@
   12.85                                                     DISPATCH_QUEUE_CONCURRENT);
   12.86      dispatch_group_t group = dispatch_group_create();
   12.87      void (^decryptionBlock)(int) = ^(int index) {
   12.88 -        PEPSession *innerSession = [[PEPSession alloc] init];
   12.89 +        PEPInternalSession *innerSession = [[PEPInternalSession alloc] init];
   12.90          NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
   12.91          [innerSession mySelf:innerAccountDict]; //Random Assertion failed: (status == PEP_STATUS_OK), function _myself, file /Users/buff/workspace/pEp/src/pEpEngine/src/keymanagement.c, line 619.
   12.92          XCTAssertNotNil(innerAccountDict[kPepFingerprint]);
   12.93 @@ -1618,7 +1618,7 @@
   12.94      // me
   12.95      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
   12.96  
   12.97 -    PEPSession *someSession = [[PEPSession alloc] init];
   12.98 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
   12.99      //Some key
  12.100      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
  12.101      // This is the secret key for test001@peptest.ch
  12.102 @@ -1628,7 +1628,7 @@
  12.103      dispatch_queue_t queue = dispatch_queue_create("Concurrent test queue",
  12.104                                                     DISPATCH_QUEUE_CONCURRENT);
  12.105      dispatch_group_t group = dispatch_group_create();
  12.106 -    PEPSession *oneSessionCopiedToBlock = [[PEPSession alloc] init];
  12.107 +    PEPInternalSession *oneSessionCopiedToBlock = [[PEPInternalSession alloc] init];
  12.108      void (^decryptionBlock)(int) = ^(int index) {
  12.109          NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.110          [oneSessionCopiedToBlock mySelf:innerAccountDict];        XCTAssertNotNil(innerAccountDict[kPepFingerprint]);
  12.111 @@ -1660,7 +1660,7 @@
  12.112      // me
  12.113      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
  12.114  
  12.115 -    PEPSession *someSession = [[PEPSession alloc] init];
  12.116 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
  12.117      //Some key
  12.118      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
  12.119      // This is the secret key for test001@peptest.ch
  12.120 @@ -1670,7 +1670,7 @@
  12.121      dispatch_queue_t queue = dispatch_queue_create("Concurrent test queue",
  12.122                                                     DISPATCH_QUEUE_CONCURRENT);
  12.123      dispatch_group_t group = dispatch_group_create();
  12.124 -    __block PEPSession *oneSessionCopiedToBlock = [[PEPSession alloc] init];
  12.125 +    __block PEPInternalSession *oneSessionCopiedToBlock = [[PEPInternalSession alloc] init];
  12.126      void (^decryptionBlock)(int) = ^(int index) {
  12.127          NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.128          [oneSessionCopiedToBlock mySelf:innerAccountDict];        XCTAssertNotNil(innerAccountDict[kPepFingerprint]);
  12.129 @@ -1704,7 +1704,7 @@
  12.130      msgDict[kPepUsername] = @"some unkown user";
  12.131      // me
  12.132      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
  12.133 -    PEPSession *someSession = [[PEPSession alloc] init];
  12.134 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
  12.135      //Some key
  12.136      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
  12.137      // This is the secret key for test001@peptest.ch
  12.138 @@ -1714,7 +1714,7 @@
  12.139      dispatch_queue_t queue = dispatch_queue_create("Concurrent test queue",
  12.140                                                     DISPATCH_QUEUE_CONCURRENT);
  12.141      __block dispatch_group_t group = dispatch_group_create();
  12.142 -    PEPSession *decryptSession = [[PEPSession alloc] init];
  12.143 +    PEPInternalSession *decryptSession = [[PEPInternalSession alloc] init];
  12.144      void (^decryptionBlock)(int) = ^(int index) {
  12.145          NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.146          [decryptSession mySelf:innerAccountDict];         XCTAssertNotNil(innerAccountDict[kPepFingerprint]);
  12.147 @@ -1724,7 +1724,7 @@
  12.148                                                           keys:&keys];
  12.149      };
  12.150  
  12.151 -    PEPSession *decryptSession2 = [[PEPSession alloc] init];
  12.152 +    PEPInternalSession *decryptSession2 = [[PEPInternalSession alloc] init];
  12.153      void (^decryptionBlock2)() = ^() {
  12.154          NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.155          [decryptSession2 mySelf:innerAccountDict];         XCTAssertNotNil(innerAccountDict[kPepFingerprint]);
  12.156 @@ -1736,7 +1736,7 @@
  12.157  
  12.158      void (^initBlock)() = ^() {
  12.159          for (int i = 0; i < 100; ++i) {
  12.160 -            PEPSession *tmp = [[PEPSession alloc] init];
  12.161 +            PEPInternalSession *tmp = [[PEPInternalSession alloc] init];
  12.162          }
  12.163      };
  12.164  
  12.165 @@ -1775,7 +1775,7 @@
  12.166      // me
  12.167      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
  12.168  
  12.169 -    PEPSession *someSession = [[PEPSession alloc] init];
  12.170 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
  12.171  
  12.172      // This is the pub key for test001@peptest.ch
  12.173      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
  12.174 @@ -1785,7 +1785,7 @@
  12.175  
  12.176      someSession = nil;
  12.177  
  12.178 -    PEPSession *workSession = [[PEPSession alloc] init];
  12.179 +    PEPInternalSession *workSession = [[PEPInternalSession alloc] init];
  12.180  
  12.181      NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.182      [workSession mySelf:innerAccountDict];
  12.183 @@ -1814,7 +1814,7 @@
  12.184      // me
  12.185      NSDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"];
  12.186  
  12.187 -    PEPSession *someSession = [[PEPSession alloc] init];
  12.188 +    PEPInternalSession *someSession = [[PEPInternalSession alloc] init];
  12.189  
  12.190      //This is the pub key for test001@peptest.ch
  12.191      [self importBundledKey:@"5CB2C182.asc" intoSession:someSession];
  12.192 @@ -1824,7 +1824,7 @@
  12.193  
  12.194      someSession = nil;
  12.195  
  12.196 -    PEPSession *workSession = [[PEPSession alloc] init];
  12.197 +    PEPInternalSession *workSession = [[PEPInternalSession alloc] init];
  12.198  
  12.199      NSMutableDictionary *innerAccountDict = [accountDict mutableCopy];
  12.200      [workSession mySelf:innerAccountDict]; //Random Assertion failed: (status == PEP_STATUS_OK), function _myself, file /Users/buff/workspace/pEp/src/pEpEngine/src/keymanagement.c, line 619.