ENGINE-179 added reEvaluateMessageRating, calling engine's re_evaluate_message_rating
authorEdouard Tisserant <edouard@pep-project.org>
Tue, 06 Jun 2017 15:32:01 +0200
changeset 196d660aae03056
parent 195 cbfe333e6df2
child 197 237a5eea0661
child 198 55e448e712a6
child 200 e619d4757dd7
ENGINE-179 added reEvaluateMessageRating, calling engine's re_evaluate_message_rating
pEpObjCAdapter/PEPSession.h
pEpObjCAdapter/PEPSession.m
pEpObjCTests/iOSTests.m
     1.1 --- a/pEpObjCAdapter/PEPSession.h	Mon May 22 13:40:33 2017 +0200
     1.2 +++ b/pEpObjCAdapter/PEPSession.h	Tue Jun 06 15:32:01 2017 +0200
     1.3 @@ -40,6 +40,9 @@
     1.4                              dest:(NSDictionary<NSString *, id> * _Nullable * _Nullable)dst
     1.5                              keys:(NSArray<NSString *> * _Nullable * _Nullable)keys;
     1.6  
     1.7 +/** Re-evaluate rating of decrypted message */
     1.8 +- (PEP_rating)reEvaluateMessageRating:(nonnull NSDictionary<NSString *, id> *)src;
     1.9 +
    1.10  /** Encrypt a message */
    1.11  - (PEP_STATUS)encryptMessageDict:(nonnull NSDictionary<NSString *, id> *)src
    1.12                             extra:(nullable NSArray<NSString *> *)keys
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Mon May 22 13:40:33 2017 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Tue Jun 06 15:32:01 2017 +0200
     2.3 @@ -118,6 +118,20 @@
     2.4      return color;
     2.5  }
     2.6  
     2.7 +- (PEP_rating)reEvaluateMessageRating:(nonnull NSDictionary<NSString *, id> *)src
     2.8 +{
     2.9 +    message * _src = PEP_messageDictToStruct(src);
    2.10 +    PEP_rating color = PEP_rating_undefined;
    2.11 +    
    2.12 +    @synchronized (self) {
    2.13 +        re_evaluate_message_rating(_session, _src, NULL, PEP_rating_undefined, &color);
    2.14 +    }
    2.15 +    
    2.16 +    free_message(_src);
    2.17 +    
    2.18 +    return color;
    2.19 +}
    2.20 +
    2.21  - (void)removeEmptyArrayKey:(NSString *)key inDict:(NSMutableDictionary<NSString *, id> *)dict
    2.22  {
    2.23      if ([[dict objectForKey:key] count] == 0) {
     3.1 --- a/pEpObjCTests/iOSTests.m	Mon May 22 13:40:33 2017 +0200
     3.2 +++ b/pEpObjCTests/iOSTests.m	Tue Jun 06 15:32:01 2017 +0200
     3.3 @@ -991,9 +991,13 @@
     3.4          
     3.5          
     3.6          PEP_rating clr = [session decryptMessageDict:encmsg dest:&decmsg keys:&keys];
     3.7 -        
     3.8 +
     3.9          XCTAssertEqual(clr, PEP_rating_reliable);
    3.10 -        
    3.11 +
    3.12 +        PEP_rating secondclr = [session reEvaluateMessageRating:decmsg];
    3.13 +
    3.14 +        XCTAssertEqual(secondclr, PEP_rating_reliable);
    3.15 +
    3.16          // Check Miro is in DB
    3.17          [session updateIdentity:identMiroAtPetra];
    3.18          
    3.19 @@ -1004,6 +1008,9 @@
    3.20          // Trust to that identity
    3.21          [session trustPersonalKey:identMiroAtPetra];
    3.22  
    3.23 +        secondclr = [session reEvaluateMessageRating:decmsg];
    3.24 +        XCTAssertEqual(secondclr, PEP_rating_trusted, @"Not trusted");
    3.25 +        
    3.26          clr = [session decryptMessageDict:encmsg dest:&decmsg keys:&keys];
    3.27          XCTAssertEqual(clr, PEP_rating_trusted, @"Not trusted");
    3.28