IOSAD-134 New: queryKeySyncEnabled. IOSAD-134
authorDirk Zimmermann <dz@pep.security>
Mon, 02 Sep 2019 16:47:25 +0200
branchIOSAD-134
changeset 11903a53851cc0b9
parent 1189 56a9b49d42eb
child 1191 31441cbef9ef
IOSAD-134 New: queryKeySyncEnabled.
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPSession.m
pEpObjCAdapterFramework/PEPSessionProtocol.h
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Mon Sep 02 14:01:14 2019 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Mon Sep 02 16:47:25 2019 +0200
     1.3 @@ -682,6 +682,29 @@
     1.4      return YES;
     1.5  }
     1.6  
     1.7 +- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
     1.8 +                                                 error:(NSError * _Nullable * _Nullable)error
     1.9 +{
    1.10 +    pEp_identity *ident = PEP_identityToStruct(identity);
    1.11 +
    1.12 +    PEPStatus status = (PEPStatus) myself(_session, ident);
    1.13 +
    1.14 +    if ([NSError setError:error fromPEPStatus:status]) {
    1.15 +        free_identity(ident);
    1.16 +        return NO;
    1.17 +    }
    1.18 +
    1.19 +    identity_flags_t flags = ident->flags;
    1.20 +
    1.21 +    free_identity(ident);
    1.22 +
    1.23 +    if (flags & PEP_idf_not_for_sync) {
    1.24 +        return [NSNumber numberWithBool:NO];
    1.25 +    } else {
    1.26 +        return [NSNumber numberWithBool:YES];
    1.27 +    }
    1.28 +}
    1.29 +
    1.30  - (NSArray<PEPIdentity *> * _Nullable)importKey:(NSString * _Nonnull)keydata
    1.31                                            error:(NSError * _Nullable * _Nullable)error
    1.32  {
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Mon Sep 02 14:01:14 2019 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Mon Sep 02 16:47:25 2019 +0200
     2.3 @@ -310,6 +310,14 @@
     2.4      return [session disableSyncForIdentity:identity error:error];
     2.5  }
     2.6  
     2.7 +- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
     2.8 +                                                 error:(NSError * _Nullable * _Nullable)error
     2.9 +{
    2.10 +    PEPInternalSession *session = [PEPSessionProvider session];
    2.11 +    RETURN_ON_ERROR(session, error, nil);
    2.12 +    return [session queryKeySyncEnabledForIdentity:identity error:error];
    2.13 +}
    2.14 +
    2.15  #pragma mark Internal API (testing etc.)
    2.16  
    2.17  - (NSArray * _Nullable)importKey:(NSString * _Nonnull)keydata
     3.1 --- a/pEpObjCAdapterFramework/PEPSessionProtocol.h	Mon Sep 02 14:01:14 2019 +0200
     3.2 +++ b/pEpObjCAdapterFramework/PEPSessionProtocol.h	Mon Sep 02 16:47:25 2019 +0200
     3.3 @@ -204,6 +204,17 @@
     3.4  - (BOOL)disableSyncForIdentity:(PEPIdentity * _Nonnull)identity
     3.5                           error:(NSError * _Nullable * _Nullable)error;
     3.6  
     3.7 +/**
     3.8 + Queries the given own identity on whether it has key sync enabled or not.
     3.9 +
    3.10 + @param identity The (own) identity to query.
    3.11 + @param error The usual cocoa error handling.
    3.12 + @return An NSNumber containing a boolean denoting whether key sync is enabled or not, or
    3.13 +         nil on error.
    3.14 + */
    3.15 +- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
    3.16 +                                                 error:(NSError * _Nullable * _Nullable)error;
    3.17 +
    3.18  #pragma mark -- Internal API (testing etc.)
    3.19  
    3.20  /** For testing purpose, manual key import */