IOSAD-93 first (internal) implementation
authorDirk Zimmermann <dirk@pep-project.org>
Wed, 16 May 2018 15:40:35 +0200
changeset 608e637354d3b7f
parent 607 885f4829bff0
child 609 7f464ac46e7a
IOSAD-93 first (internal) implementation
pEpObjCAdapter/PEPInternalSession.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Wed May 16 15:40:34 2018 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Wed May 16 15:40:35 2018 +0200
     1.3 @@ -401,6 +401,57 @@
     1.4      return encrypted;
     1.5  }
     1.6  
     1.7 +
     1.8 +- (PEPDict * _Nullable)encryptMessageDict:(PEPDict * _Nonnull)messageDict
     1.9 +                                    toFpr:(NSString * _Nonnull)toFpr
    1.10 +                                encFormat:(PEP_enc_format)encFormat
    1.11 +                                    flags:(PEP_decrypt_flags)flags
    1.12 +                                   status:(PEP_STATUS * _Nullable)status
    1.13 +                                    error:(NSError * _Nullable * _Nullable)error __deprecated
    1.14 +{
    1.15 +    message *src = PEP_messageDictToStruct([self removeEmptyRecipients:messageDict]);
    1.16 +    message *dst = NULL;
    1.17 +
    1.18 +    [self lockWrite];
    1.19 +    PEP_STATUS theStatus = encrypt_message_and_add_priv_key(_session, src, &dst,
    1.20 +                                     [[toFpr precomposedStringWithCanonicalMapping] UTF8String], encFormat, flags);
    1.21 +    [self unlockWrite];
    1.22 +
    1.23 +    if (status) {
    1.24 +        *status = theStatus;
    1.25 +    }
    1.26 +
    1.27 +    if ([NSError setError:error fromPEPStatus:theStatus]) {
    1.28 +        return nil;
    1.29 +    }
    1.30 +
    1.31 +    if (dst) {
    1.32 +        return PEP_messageDictFromStruct(dst);
    1.33 +    }
    1.34 +
    1.35 +    return nil;
    1.36 +}
    1.37 +
    1.38 +- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
    1.39 +                                   toFpr:(NSString * _Nonnull)toFpr
    1.40 +                               encFormat:(PEP_enc_format)encFormat
    1.41 +                                   flags:(PEP_decrypt_flags)flags
    1.42 +                                  status:(PEP_STATUS * _Nullable)status
    1.43 +                                   error:(NSError * _Nullable * _Nullable)error
    1.44 +{
    1.45 +    PEPDict *target = [self
    1.46 +                       encryptMessageDict:message.dictionary
    1.47 +                       toFpr:toFpr
    1.48 +                       encFormat:encFormat
    1.49 +                       flags:flags
    1.50 +                       status:status
    1.51 +                       error:error];
    1.52 +
    1.53 +    PEPMessage *encrypted = [PEPMessage new];
    1.54 +    [encrypted setValuesForKeysWithDictionary:target];
    1.55 +    return encrypted;
    1.56 +}
    1.57 +
    1.58  - (NSNumber * _Nullable)outgoingRatingForMessageDict:(PEPDict * _Nonnull)messageDict
    1.59                                                 error:(NSError * _Nullable * _Nullable)error
    1.60  {