Browse Source

APPLEMAIL-35 Add decrypt method to service.

APPLEMAIL-35
David Alarcon 1 year ago
parent
commit
a258368236
3 changed files with 60 additions and 0 deletions
  1. +23
    -0
      Subprojects/PEPObjCAdapterXPCService/PEPObjCAdapterXPCApiClient/XPCService/PEPObjCAdapterXPCApiClientService.m
  2. +32
    -0
      Subprojects/PEPObjCAdapterXPCService/PEPObjCAdapterXPCService/XPCService/PEPObjCAdapterXPCApi.m
  3. +5
    -0
      Subprojects/PEPObjCAdapterXPCService/Shared/PEPObjCAdapterXpcApiProtocol.h

+ 23
- 0
Subprojects/PEPObjCAdapterXPCService/PEPObjCAdapterXPCApiClient/XPCService/PEPObjCAdapterXPCApiClientService.m View File

@ -129,4 +129,27 @@ successCallback:(nonnull void (^)(PEPIdentity * _Nonnull))successCallback {
return color;
}
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList *_Nullable)extraKeys
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(PEPMessage *srcMessage,
PEPMessage *dstMessage,
PEPStringList *keyList,
PEPRating rating,
PEPDecryptFlags flags,
BOOL isFormerlyEncryptedReuploadedMessage))successCallback {
[[self.connection remoteObjectProxyWithErrorHandler:errorCallback] decryptMessage:message flags:flags extraKeys:extraKeys resultBlock:^(PEPObjCAdapterXpcApiResult * _Nonnull result) {
PEPMessage *srcMessage = result.result[0];
PEPMessage *dstMessage = result.result[1];
PEPStringList *keyList = result.result[2];
PEPRating rating = [(NSNumber *)result.result[3] intValue];
PEPDecryptFlags flags = [(NSNumber *)result.result[4] intValue];
BOOL isFormerlyEncryptedReuploadedMessage = [(NSNumber *)result.result[5] intValue];
successCallback(srcMessage, dstMessage, keyList, rating, flags, isFormerlyEncryptedReuploadedMessage);
}];
}
@end

+ 32
- 0
Subprojects/PEPObjCAdapterXPCService/PEPObjCAdapterXPCService/XPCService/PEPObjCAdapterXPCApi.m View File

@ -12,8 +12,20 @@
#import "PEPIdentity.h"
#import "PEPObjCAdapterXpcApiResult.h"
typedef void (^resultCallback)(PEPObjCAdapterXpcApiResult * _Nonnull);
typedef void (^resultErrorBlock)(NSError *, resultCallback);
@implementation PEPObjCAdapterXPCApi
//void resultErrorBlock = ^void(NSError * _Nonnull error, resultCallback resultCallback) {
// PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:nil error:error];
// resultCallback(result);
//};
//void (^resultErrorBlock)(NSError *, void (^)(PEPObjCAdapterXpcApiResult * _Nonnull)) = ^void(NSError * _Nonnull error, (void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback) {
// PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:nil error:error];
// resultCallback(result);
//};
- (void)myself:(PEPIdentity *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
PEPSession *session = [PEPSession new];
@ -95,4 +107,24 @@
}];
}
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList *)extraKeys
resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
NSLog(@"%s", __PRETTY_FUNCTION__);
PEPSession *session = [PEPSession new];
[session decryptMessage:message flags:flags extraKeys:extraKeys errorCallback:^(NSError * _Nonnull error) {
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc]
initWithResult:nil
error:error];
resultCallback(result);
} successCallback:^(PEPMessage * _Nonnull srcMessage, PEPMessage * _Nonnull dstMessage, PEPStringList * _Nonnull keyList, PEPRating rating, PEPDecryptFlags flags, BOOL isFormerlyEncryptedReuploadedMessage) {
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc]
initWithResult:@[srcMessage, dstMessage, keyList, @(rating), @(flags), @(isFormerlyEncryptedReuploadedMessage)]
error:nil];
resultCallback(result);
}];
}
@end

+ 5
- 0
Subprojects/PEPObjCAdapterXPCService/Shared/PEPObjCAdapterXpcApiProtocol.h View File

@ -35,6 +35,11 @@ NS_ASSUME_NONNULL_BEGIN
extraKeys:(PEPStringList *_Nullable)extraKeys
resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
- (void)decryptMessage:(PEPMessage *)message
flags:(PEPDecryptFlags)flags
extraKeys:(PEPStringList *_Nullable)extraKeys
resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save