Browse Source

IOS-714 NSDictionary.commType

IOSAD-49
Dirk Zimmermann 5 years ago
parent
commit
1adeb77d07
2 changed files with 30 additions and 17 deletions
  1. +8
    -0
      pEpObjCAdapter/NSDictionary+Extension.h
  2. +22
    -17
      pEpObjCAdapter/NSDictionary+Extension.m

+ 8
- 0
pEpObjCAdapter/NSDictionary+Extension.h View File

@ -8,8 +8,16 @@
#import <Foundation/Foundation.h>
#import "pEpEngine.h"
@interface NSDictionary (Extension)
/**
If we interpret the self as a dictionary denoting a pp Identity,
does the comm type denote a PGP user?
*/
@property (nonatomic, readonly) PEP_comm_type commType;
/**
If we interpret the self as a dictionary denoting a pp Identity,
does the comm type denote a PGP user?


+ 22
- 17
pEpObjCAdapter/NSDictionary+Extension.m View File

@ -14,12 +14,32 @@
@implementation NSDictionary (Extension)
- (PEP_comm_type)commType
{
NSNumber *ctNum = self[kPepCommType];
if (!ctNum) {
return PEP_ct_unknown;
}
return ctNum.intValue;
}
- (BOOL)containsPGPCommType
{
PEP_comm_type val = self.commType;
return
val == PEP_ct_OpenPGP_weak_unconfirmed ||
val == PEP_ct_OpenPGP_unconfirmed ||
val == PEP_ct_OpenPGP_weak ||
val == PEP_ct_OpenPGP;
}
- (void)debugSaveToFilePath:(NSString * _Nonnull)filePath
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *parentPath = [[fileManager
URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
firstObject];
URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
firstObject];
NSDate *now = [NSDate date];
NSString *nowDesc = [now description];
@ -31,19 +51,4 @@
[self writeToURL:writeURL atomically:YES];
}
- (BOOL)containsPGPCommType
{
NSNumber *ctNum = self[kPepCommType];
if (!ctNum) {
return NO;
}
NSInteger val = ctNum.integerValue;
return
val == PEP_ct_OpenPGP_weak_unconfirmed ||
val == PEP_ct_OpenPGP_unconfirmed ||
val == PEP_ct_OpenPGP_weak ||
val == PEP_ct_OpenPGP;
}
@end

Loading…
Cancel
Save