Browse Source

APPLEMAIL-33 Use PEPIdentity in protocol in xpc connection.

APPLEMAIL-33
David Alarcon 2 years ago
parent
commit
71af24a8e4
3 changed files with 10 additions and 9 deletions
  1. +8
    -7
      pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApi.m
  2. +1
    -1
      pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApiProtocol.h
  3. +1
    -1
      pEpMacOSAdapter/main.m

+ 8
- 7
pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApi.m View File

@ -10,7 +10,7 @@
#import "PEPObjCAdapterXpcApiResult.h"
#import "PEPSession.h"
#import "PEPIdentity.h"
#import "PEPIdentity+SecureCoding.h"
@interface PEPObjCAdapterXpcApi ()
@property (nonatomic, strong, readwrite) NSXPCListener *listener;
@ -52,16 +52,13 @@
#pragma mark - PEPObjCAdapterXpcApiProtocol
- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
- (void)myself:(PEPIdentity *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
PEPSession *session = [PEPSession new];
PEPIdentity *pepIdentity = [[PEPIdentity alloc] initWithAddress:identity];
[session mySelf:pepIdentity errorCallback:^(NSError * _Nonnull error) {
[session mySelf:identity errorCallback:^(NSError * _Nonnull error) {
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:nil andError:error];
resultCallback(result);
} successCallback:^(PEPIdentity * _Nonnull identity) {
NSString *fingerprint = identity.fingerPrint;
fingerprint = fingerprint ? fingerprint : @"empty";
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:@[fingerprint] andError:nil];
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:@[identity] andError:nil];
resultCallback(result);
}];
}
@ -79,6 +76,10 @@
forSelector:@selector(myself:resultBlock:)
argumentIndex:0
ofReply:YES];
[adapterInterface setClasses:[NSSet setWithObject:[PEPIdentity class]]
forSelector:@selector(myself:resultBlock:)
argumentIndex:0
ofReply:NO];
newConnection.exportedInterface = adapterInterface;
newConnection.exportedObject = self;


+ 1
- 1
pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApiProtocol.h View File

@ -14,7 +14,7 @@ static NSString *daemonLabel = @"pEp.foundation.pEpXPCAdapter_OpenStep";
@class PEPIdentity, PEPObjCAdapterXpcApiResult;
@protocol PEPObjCAdapterXpcApiProtocol
- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
- (void)myself:(PEPIdentity *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
@end


+ 1
- 1
pEpMacOSAdapter/main.m View File

@ -78,7 +78,7 @@ int main(int argc, const char *argv[])
ServiceDelegate *delegate = [ServiceDelegate new];
// Set up the one NSXPCListener for this service. It will handle all incoming connections.
NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName:@"foundation.pEp.adapter.macOS"];
NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName:@"foundation.pEp.adapter.macOS_OpenStep"];
NSLog(@"starting agent");
listener.delegate = delegate;
[listener resume];


Loading…
Cancel
Save