Browse Source

IOSAD-72 trustwords error handling

IOSAD-92
Dirk Zimmermann 4 years ago
parent
commit
70c829b88c
4 changed files with 25 additions and 22 deletions
  1. +9
    -5
      pEpObjCAdapter/PEPInternalSession.m
  2. +7
    -13
      pEpObjCAdapter/PEPSession.m
  3. +2
    -1
      pEpObjCAdapter/PEPSessionProtocol.h
  4. +7
    -3
      pEpObjCTests/PEPSessionTest.m

+ 9
- 5
pEpObjCAdapter/PEPInternalSession.m View File

@ -611,15 +611,15 @@
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error
{
NSString *result = nil;
char *trustwords = nil;
size_t sizeWritten = 0;
pEp_identity *ident1 = PEP_identityToStruct(identity1);
pEp_identity *ident2 = PEP_identityToStruct(identity2);
PEP_STATUS status;
char *trustwords = nil;
size_t sizeWritten = 0;
[self lockWrite];
status = get_trustwords(_session, ident1, ident2,
[[language precomposedStringWithCanonicalMapping]
@ -627,13 +627,17 @@
&trustwords, &sizeWritten, full);
[self unlockWrite];
if (status == PEP_STATUS_OK) {
NSString *result = nil;
if (![NSError setError:error fromPEPStatus:status]) {
result = [NSString stringWithCString:trustwords
encoding:NSUTF8StringEncoding];
}
if (trustwords) {
free(trustwords);
}
return result;
}


+ 7
- 13
pEpObjCAdapter/PEPSession.m View File

@ -234,11 +234,14 @@
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error
{
return [PEPSession getTrustwordsIdentity1:identity1
identity2:identity2
language:language
full:full];
PEPInternalSession *session = [PEPSessionProvider session];
return [session getTrustwordsIdentity1:identity1
identity2:identity2
language:language
full:full
error:error];
}
- (NSArray<PEPLanguage *> * _Nonnull)languageList
@ -274,15 +277,6 @@
#pragma mark Internal API (testing etc.)
+ (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
{
PEPInternalSession *session = [PEPSessionProvider session];
return [session getTrustwordsIdentity1:identity1 identity2:identity2 language:language full:full];
}
+ (NSArray<PEPLanguage *> * _Nonnull)languageList
{
PEPInternalSession *session = [PEPSessionProvider session];


+ 2
- 1
pEpObjCAdapter/PEPSessionProtocol.h View File

@ -181,7 +181,8 @@ typedef NSArray<NSString *> PEPStringList;
- (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full;
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error;
/**
@returns The list of supported languages for trustwords.


+ 7
- 3
pEpObjCTests/PEPSessionTest.m View File

@ -909,17 +909,21 @@
NSString *secKeyMe = [PEPTestUtils loadResourceByName:@"meATdontcare_E3BFBCA9248FC681_sec.asc"];
XCTAssertNotNil(secKeyMe);
NSError *error = nil;
NSString *trustwordsFull = [session getTrustwordsIdentity1:meOrig identity2:partner1Orig
language:nil full:YES];
language:nil full:YES error:&error];
XCTAssertNil(error);
XCTAssertEqualObjects(trustwordsFull,
@"EMERSON GASPER TOKENISM BOLUS COLLAGE DESPISE BEDDED ENCRYPTION IMAGINE BEDFORD");
NSString *trustwordsFullEnglish = [session getTrustwordsIdentity1:meOrig identity2:partner1Orig
language:@"en" full:YES];
language:@"en" full:YES error:&error];
XCTAssertNil(error);
XCTAssertEqualObjects(trustwordsFullEnglish, trustwordsFull);
NSString *trustwordsUndefined = [session getTrustwordsIdentity1:meOrig identity2:partner1Orig
language:@"ZZ" full:YES];
language:@"ZZ" full:YES error:&error];
XCTAssertNotNil(error);
XCTAssertNil(trustwordsUndefined);
}


Loading…
Cancel
Save