IOS-714 NSDictionary.commType
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 14 Sep 2017 12:35:05 +0200
changeset 2277f6770ed38ea
parent 226 aebc0fdcb859
child 228 ef03cff2e1c4
IOS-714 NSDictionary.commType
pEpObjCAdapter/NSDictionary+Extension.h
pEpObjCAdapter/NSDictionary+Extension.m
     1.1 --- a/pEpObjCAdapter/NSDictionary+Extension.h	Thu Sep 14 12:14:48 2017 +0200
     1.2 +++ b/pEpObjCAdapter/NSDictionary+Extension.h	Thu Sep 14 12:35:05 2017 +0200
     1.3 @@ -8,12 +8,20 @@
     1.4  
     1.5  #import <Foundation/Foundation.h>
     1.6  
     1.7 +#import "pEpEngine.h"
     1.8 +
     1.9  @interface NSDictionary (Extension)
    1.10  
    1.11  /**
    1.12   If we interpret the self as a dictionary denoting a p≡p Identity,
    1.13   does the comm type denote a PGP user?
    1.14   */
    1.15 +@property (nonatomic, readonly) PEP_comm_type commType;
    1.16 +
    1.17 +/**
    1.18 + If we interpret the self as a dictionary denoting a p≡p Identity,
    1.19 + does the comm type denote a PGP user?
    1.20 + */
    1.21  @property (nonatomic, readonly) BOOL containsPGPCommType;
    1.22  
    1.23  /**
     2.1 --- a/pEpObjCAdapter/NSDictionary+Extension.m	Thu Sep 14 12:14:48 2017 +0200
     2.2 +++ b/pEpObjCAdapter/NSDictionary+Extension.m	Thu Sep 14 12:35:05 2017 +0200
     2.3 @@ -14,12 +14,32 @@
     2.4  
     2.5  @implementation NSDictionary (Extension)
     2.6  
     2.7 +- (PEP_comm_type)commType
     2.8 +{
     2.9 +    NSNumber *ctNum = self[kPepCommType];
    2.10 +    if (!ctNum) {
    2.11 +        return PEP_ct_unknown;
    2.12 +    }
    2.13 +    return ctNum.intValue;
    2.14 +}
    2.15 +
    2.16 +- (BOOL)containsPGPCommType
    2.17 +{
    2.18 +    PEP_comm_type val = self.commType;
    2.19 +
    2.20 +    return
    2.21 +    val == PEP_ct_OpenPGP_weak_unconfirmed ||
    2.22 +    val == PEP_ct_OpenPGP_unconfirmed ||
    2.23 +    val == PEP_ct_OpenPGP_weak ||
    2.24 +    val == PEP_ct_OpenPGP;
    2.25 +}
    2.26 +
    2.27  - (void)debugSaveToFilePath:(NSString * _Nonnull)filePath
    2.28  {
    2.29      NSFileManager *fileManager = [NSFileManager defaultManager];
    2.30      NSURL *parentPath = [[fileManager
    2.31 -                       URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
    2.32 -                      firstObject];
    2.33 +                          URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
    2.34 +                         firstObject];
    2.35  
    2.36      NSDate *now = [NSDate date];
    2.37      NSString *nowDesc = [now description];
    2.38 @@ -31,19 +51,4 @@
    2.39      [self writeToURL:writeURL atomically:YES];
    2.40  }
    2.41  
    2.42 -- (BOOL)containsPGPCommType
    2.43 -{
    2.44 -    NSNumber *ctNum = self[kPepCommType];
    2.45 -    if (!ctNum) {
    2.46 -        return NO;
    2.47 -    }
    2.48 -    NSInteger val = ctNum.integerValue;
    2.49 -
    2.50 -    return
    2.51 -    val == PEP_ct_OpenPGP_weak_unconfirmed ||
    2.52 -    val == PEP_ct_OpenPGP_unconfirmed ||
    2.53 -    val == PEP_ct_OpenPGP_weak ||
    2.54 -    val == PEP_ct_OpenPGP;
    2.55 -}
    2.56 -
    2.57  @end