IOSAD-61 + [PEPIdentity initWithDictionary] IOSAD-61
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 06 Nov 2017 10:41:00 +0100
branchIOSAD-61
changeset 342cbd67dba2ee7
parent 341 157bd9f2c973
child 343 a446b8346ef5
IOSAD-61 + [PEPIdentity initWithDictionary]
pEpObjCAdapter/PEPIdentity.h
pEpObjCAdapter/PEPIdentity.m
pEpObjCTests/iOSTests.m
     1.1 --- a/pEpObjCAdapter/PEPIdentity.h	Mon Nov 06 10:34:38 2017 +0100
     1.2 +++ b/pEpObjCAdapter/PEPIdentity.h	Mon Nov 06 10:41:00 2017 +0100
     1.3 @@ -66,6 +66,8 @@
     1.4  
     1.5  - (nonnull instancetype)initWithAddress:(NSString * _Nonnull)address;
     1.6  
     1.7 +- (nonnull instancetype)initWithDictionary:(NSDictionary *)dictionary;
     1.8 +
     1.9  /**
    1.10   Does this identity contain a PGP comm type? This can be used for determining
    1.11   if a communication partner is a pEp user or not.
     2.1 --- a/pEpObjCAdapter/PEPIdentity.m	Mon Nov 06 10:34:38 2017 +0100
     2.2 +++ b/pEpObjCAdapter/PEPIdentity.m	Mon Nov 06 10:41:00 2017 +0100
     2.3 @@ -60,6 +60,15 @@
     2.4                          commType:PEP_ct_unknown language:nil];
     2.5  }
     2.6  
     2.7 +- (nonnull instancetype)initWithDictionary:(NSDictionary *)dictionary
     2.8 +{
     2.9 +    return [self initWithAddress:dictionary[kPepAddress] userID:dictionary[kPepUserID]
    2.10 +                        userName:dictionary[kPepUsername]
    2.11 +                     fingerPrint:dictionary[kPepFingerprint]
    2.12 +                        commType:[dictionary[kPepCommType] intValue]
    2.13 +                        language:dictionary[@"lang"]];
    2.14 +}
    2.15 +
    2.16  - (BOOL)containsPGPCommType
    2.17  {
    2.18      PEP_comm_type val = (PEP_comm_type) self.commType;
     3.1 --- a/pEpObjCTests/iOSTests.m	Mon Nov 06 10:34:38 2017 +0100
     3.2 +++ b/pEpObjCTests/iOSTests.m	Mon Nov 06 10:41:00 2017 +0100
     3.3 @@ -1166,12 +1166,7 @@
     3.4      NSMutableDictionary *accountDict = [self unarchiveDictionary:@"account_A3FC7F0A.ser"].mutableCopy;
     3.5      [accountDict removeObjectForKey:kPepCommType];
     3.6      [accountDict removeObjectForKey:kPepFingerprint];
     3.7 -    PEPIdentity *identMe = [[PEPIdentity alloc]
     3.8 -                            initWithAddress:accountDict[kPepAddress] userID:accountDict[kPepUserID]
     3.9 -                            userName:accountDict[kPepUsername]
    3.10 -                            fingerPrint:accountDict[kPepFingerprint]
    3.11 -                            commType:[accountDict[kPepCommType] intValue]
    3.12 -                            language:accountDict[@"lang"]];
    3.13 +    PEPIdentity *identMe = [[PEPIdentity alloc] initWithDictionary:accountDict];
    3.14  
    3.15      [session mySelf:identMe];
    3.16      XCTAssertNotNil(identMe.fingerPrint);