IOSAD-72 getLogWithError
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 23 Mar 2018 09:38:37 +0100
changeset 5520f362cd2de6a
parent 551 6b7914602bc6
child 553 3d19b5814b15
IOSAD-72 getLogWithError
pEpObjCAdapter/PEPInternalSession.m
pEpObjCAdapter/PEPSession.m
pEpObjCAdapter/PEPSessionProtocol.h
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Thu Mar 22 15:38:12 2018 +0100
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Fri Mar 23 09:38:37 2018 +0100
     1.3 @@ -572,16 +572,19 @@
     1.4      [self unlockWrite];
     1.5  }
     1.6  
     1.7 -- (NSString * _Nullable)getLog
     1.8 +- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error
     1.9  {
    1.10      char *theChars = NULL;
    1.11 -    @synchronized(self) {
    1.12 -        get_crashdump_log(_session, 0, &theChars);
    1.13 +    PEP_STATUS status = get_crashdump_log(_session, 0, &theChars);
    1.14 +
    1.15 +    if ([NSError setError:error fromPEPStatus:status]) {
    1.16 +        return nil;
    1.17      }
    1.18  
    1.19      if (theChars) {
    1.20          return [NSString stringWithUTF8String:theChars];
    1.21      } else {
    1.22 +        [NSError setError:error fromPEPStatus:PEP_UNKNOWN_ERROR];
    1.23          return nil;
    1.24      }
    1.25  }
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Thu Mar 22 15:38:12 2018 +0100
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Fri Mar 23 09:38:37 2018 +0100
     2.3 @@ -203,9 +203,10 @@
     2.4      [PEPSession logTitle:title entity:entity description:description comment:comment];
     2.5  }
     2.6  
     2.7 -- (NSString * _Nullable)getLog
     2.8 +- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error
     2.9  {
    2.10 -    return [PEPSession getLog];
    2.11 +    PEPInternalSession *session = [PEPSessionProvider session];
    2.12 +    return [session getLogWithError:error];
    2.13  }
    2.14  
    2.15  - (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
    2.16 @@ -259,12 +260,6 @@
    2.17      [session logTitle:title entity:entity description:description comment:comment];
    2.18  }
    2.19  
    2.20 -+ (NSString * _Nullable)getLog
    2.21 -{
    2.22 -    PEPInternalSession *session = [PEPSessionProvider session];
    2.23 -    return [session getLog];
    2.24 -}
    2.25 -
    2.26  + (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
    2.27                                       identity2:(PEPIdentity * _Nonnull)identity2
    2.28                                        language:(NSString * _Nullable)language
     3.1 --- a/pEpObjCAdapter/PEPSessionProtocol.h	Thu Mar 22 15:38:12 2018 +0100
     3.2 +++ b/pEpObjCAdapter/PEPSessionProtocol.h	Fri Mar 23 09:38:37 2018 +0100
     3.3 @@ -170,7 +170,7 @@
     3.4  /**
     3.5   Retrieves the log from the engine, or nil, if there is nothing yet.
     3.6   */
     3.7 -- (NSString * _Nullable)getLog;
     3.8 +- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error;
     3.9  
    3.10  /** Determine trustwords for two identities */
    3.11  - (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
     4.1 --- a/pEpObjCTests/PEPSessionTest.m	Thu Mar 22 15:38:12 2018 +0100
     4.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Mar 23 09:38:37 2018 +0100
     4.3 @@ -41,7 +41,9 @@
     4.4  
     4.5      // Dummy to set up the DB, since this is currenty only triggered by session use,
     4.6      // which PEPObjCAdapter.startSync does not trigger.
     4.7 -    [session getLog];
     4.8 +    NSError *error = nil;
     4.9 +    XCTAssertNotNil([session getLogWithError:&error]);
    4.10 +    XCTAssertNil(error);
    4.11  
    4.12      PEPTestSyncDelegate *syncDelegate = [[PEPTestSyncDelegate alloc] init];
    4.13  
    4.14 @@ -54,7 +56,6 @@
    4.15                              userName:@"pEp Test iOS GenKey"
    4.16                              isOwn:YES];
    4.17  
    4.18 -    NSError *error = nil;
    4.19      XCTAssertTrue([session mySelf:identMe error:&error]);
    4.20      XCTAssertNil(error);
    4.21