Browse Source

APPLEMAIL-33 Add myself method in xpc interface (input as nsstring and output as PEPObjCAdapterXpcApiResult). Add pEpObjCAdapter static libraries to pEpMacOSAdapter. Call PEPSession from pEpObjcAdapter.

APPLEMAIL-33
David Alarcon 2 years ago
parent
commit
169b825a2d
7 changed files with 63 additions and 108 deletions
  1. +28
    -16
      pEpMacOSAdapter.xcodeproj/project.pbxproj
  2. +0
    -15
      pEpMacOSAdapter.xcodeproj/xcshareddata/xcschemes/All.xcscheme
  3. +0
    -14
      pEpMacOSAdapter.xcodeproj/xcshareddata/xcschemes/pEpMacOSAdapter.xcscheme
  4. +0
    -25
      pEpMacOSAdapter/ObjCAdapterXpcApi/Launchd-plist/foundation.pEp.adapter.macOS.plist
  5. +20
    -20
      pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApi.m
  6. +2
    -5
      pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApiProtocol.h
  7. +13
    -13
      pEpMacOSAdapter/main.m

+ 28
- 16
pEpMacOSAdapter.xcodeproj/project.pbxproj View File

@ -13,8 +13,10 @@
35DC18D8244DA19100FB2002 /* pEpMacOSAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 35DC18D7244DA19100FB2002 /* pEpMacOSAdapter.m */; };
35DC18DA244DA19100FB2002 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 35DC18D9244DA19100FB2002 /* main.m */; };
4E49289E25B200BD00A3A47C /* PEPObjCAdapterXpcApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E49289D25B200BD00A3A47C /* PEPObjCAdapterXpcApi.m */; };
4E5FC0EB25B9D212000DF12C /* libiconv.2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E5FC0EA25B9D212000DF12C /* libiconv.2.tbd */; };
4E5FC0F225B9D2E0000DF12C /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E5FC0F025B9D2CF000DF12C /* libz.tbd */; };
4E67789725B71680003591E6 /* PEPObjCAdapterXpcApiResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E67789625B71680003591E6 /* PEPObjCAdapterXpcApiResult.m */; };
4E90353025B58FC400F3471A /* foundation.pEp.adapter.macOS.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4E90352F25B58FC400F3471A /* foundation.pEp.adapter.macOS.plist */; };
4E85771425BB227A007B6ECB /* libPEPObjCAdapter_macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E5FC0CF25B9C351000DF12C /* libPEPObjCAdapter_macOS.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -35,10 +37,12 @@
35DC18DB244DA19100FB2002 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4E49289C25B200BD00A3A47C /* PEPObjCAdapterXpcApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterXpcApi.h; sourceTree = "<group>"; };
4E49289D25B200BD00A3A47C /* PEPObjCAdapterXpcApi.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPObjCAdapterXpcApi.m; sourceTree = "<group>"; };
4E5FC0CF25B9C351000DF12C /* libPEPObjCAdapter_macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libPEPObjCAdapter_macOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E5FC0EA25B9D212000DF12C /* libiconv.2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.2.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk/usr/lib/libiconv.2.tbd; sourceTree = DEVELOPER_DIR; };
4E5FC0F025B9D2CF000DF12C /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
4E67789425B71680003591E6 /* PEPObjCAdapterXpcApiProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterXpcApiProtocol.h; sourceTree = "<group>"; };
4E67789525B71680003591E6 /* PEPObjCAdapterXpcApiResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPObjCAdapterXpcApiResult.h; sourceTree = "<group>"; };
4E67789625B71680003591E6 /* PEPObjCAdapterXpcApiResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPObjCAdapterXpcApiResult.m; sourceTree = "<group>"; };
4E90352F25B58FC400F3471A /* foundation.pEp.adapter.macOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = foundation.pEp.adapter.macOS.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -47,6 +51,9 @@
buildActionMask = 2147483647;
files = (
15AC46BC254EE19600AA18DE /* libdownloadclient.a in Frameworks */,
4E85771425BB227A007B6ECB /* libPEPObjCAdapter_macOS.a in Frameworks */,
4E5FC0EB25B9D212000DF12C /* libiconv.2.tbd in Frameworks */,
4E5FC0F225B9D2E0000DF12C /* libz.tbd in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -89,7 +96,10 @@
35F06969247D58C800543884 /* Frameworks */ = {
isa = PBXGroup;
children = (
4E5FC0F025B9D2CF000DF12C /* libz.tbd */,
15AC46BB254EE19600AA18DE /* libdownloadclient.a */,
4E5FC0CF25B9C351000DF12C /* libPEPObjCAdapter_macOS.a */,
4E5FC0EA25B9D212000DF12C /* libiconv.2.tbd */,
150D91D82547331D00010463 /* libssl.a */,
150D91D62547330100010463 /* libcrypto.a */,
150D91D4254732E800010463 /* libcryptopp.a */,
@ -102,7 +112,6 @@
4E49289625B1DCB600A3A47C /* ObjCAdapterXpcApi */ = {
isa = PBXGroup;
children = (
4E6778AC25B71DDA003591E6 /* Launchd-plist */,
4E67789425B71680003591E6 /* PEPObjCAdapterXpcApiProtocol.h */,
4E67789525B71680003591E6 /* PEPObjCAdapterXpcApiResult.h */,
4E67789625B71680003591E6 /* PEPObjCAdapterXpcApiResult.m */,
@ -112,14 +121,6 @@
path = ObjCAdapterXpcApi;
sourceTree = "<group>";
};
4E6778AC25B71DDA003591E6 /* Launchd-plist */ = {
isa = PBXGroup;
children = (
4E90352F25B58FC400F3471A /* foundation.pEp.adapter.macOS.plist */,
);
path = "Launchd-plist";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -178,7 +179,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4E90353025B58FC400F3471A /* foundation.pEp.adapter.macOS.plist in Resources */,
35380AE7247BD13A004A08A6 /* README.md in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -273,13 +273,19 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../local/include";
HEADER_SEARCH_PATHS = (
"${PROJECT_DIR}/../local/include",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/PEPObjCAdapterTypes/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/pEpObjCAdapter/PublicHeaders",
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS)",
"-ObjC",
"${PROJECT_DIR}/../local/lib/libcrypto.a",
"${PROJECT_DIR}/../local/lib/libssl.a",
"${PROJECT_DIR}/../local/lib/libcryptopp.a",
@ -333,12 +339,18 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../local/include";
HEADER_SEARCH_PATHS = (
"${PROJECT_DIR}/../local/include",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/PEPObjCAdapterTypes/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/pEpObjCAdapter/PublicHeaders",
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = (
"$(OTHER_LDFLAGS)",
"-ObjC",
"${PROJECT_DIR}/../local/lib/libcrypto.a",
"${PROJECT_DIR}/../local/lib/libssl.a",
"${PROJECT_DIR}/../local/lib/libcryptopp.a",
@ -351,7 +363,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CODE_SIGN_ENTITLEMENTS = foundation.pEp.adapter.macOS.entitlements;
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
@ -376,7 +388,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CODE_SIGN_ENTITLEMENTS = foundation.pEp.adapter.macOS.entitlements;
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;


+ 0
- 15
pEpMacOSAdapter.xcodeproj/xcshareddata/xcschemes/All.xcscheme View File

@ -68,21 +68,6 @@
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Users/vb/Library/Developer/Xcode/DerivedData/pEpMacOSAdapter-fdkuxqnmbllhyqepcwbjgbectwfc/Build/Products/Debug/pEpMacOSAdapter.xpc">
</PathRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"


+ 0
- 14
pEpMacOSAdapter.xcodeproj/xcshareddata/xcschemes/pEpMacOSAdapter.xcscheme View File

@ -28,16 +28,6 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35F06976247DC95A00543884"
BuildableName = "pEpUpdater Test.xctest"
BlueprintName = "pEpUpdater Test"
ReferencedContainer = "container:pEpMacOSAdapter.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
@ -50,10 +40,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Users/vb/Library/Developer/Xcode/DerivedData/pEpMacOSAdapter-fdkuxqnmbllhyqepcwbjgbectwfc/Build/Products/Debug/pEpMacOSAdapter.xpc">
</PathRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"


+ 0
- 25
pEpMacOSAdapter/ObjCAdapterXpcApi/Launchd-plist/foundation.pEp.adapter.macOS.plist View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>foundation.pEp.adapter.macOS</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Application Support/pEp/pEp.app/Contents/MacOS/foundation.pEp.adapter.macOS</string>
</array>
<key>MachServices</key>
<dict>
<key>foundation.pEp.adapter.pEpObjCXPC_OpenStep</key>
<true/>
</dict>
<key>StandardOutPath</key>
<string>/tmp/foundation.pEp.adapter.macOS.log</string>
<key>StandardErrorPath</key>
<string>/tmp/foundation.pEp.adapter.macOS.log</string>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

+ 20
- 20
pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApi.m View File

@ -9,6 +9,9 @@
#import "PEPObjCAdapterXpcApi.h"
#import "PEPObjCAdapterXpcApiResult.h"
#import "PEPSession.h"
#import "PEPIdentity.h"
@interface PEPObjCAdapterXpcApi ()
@property (nonatomic, strong, readwrite) NSXPCListener *listener;
@property (nonatomic, readwrite) BOOL started;
@ -20,7 +23,6 @@
// Launch daemons must configure their listener with the machServiceName initializer
self.listener = [[NSXPCListener alloc] initWithMachServiceName:daemonLabel];
self.listener.delegate = self;
NSLog(@"initializing ObjC Xpc Api: %@", self.listener);
self.started = NO;
return self;
@ -32,8 +34,10 @@
// Begin listening for incoming XPC connections
[self.listener resume];
NSLog(@"starting ObjC Xpc Api: %@", daemonLabel);
self.started = YES;
NSLog(@"started PEPSessionProtocol wrapper api service: %@", daemonLabel);
}
@ -48,37 +52,33 @@
#pragma mark - PEPObjCAdapterXpcApiProtocol
//- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
// PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:@[@"MySelf"] andError:nil];
//
// resultCallback(result);
//}
- (void)myself:(NSString *)myself withReply:(void (^)(NSString * _Nonnull))replyBlock {
replyBlock(@"myself");
- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
PEPSession *session = [PEPSession new];
PEPIdentity *pepIdentity = [[PEPIdentity alloc] initWithAddress:identity];
[session mySelf:pepIdentity 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];
resultCallback(result);
}];
}
#pragma mark - NSXPCListenerDelegate
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// Sanity checks
NSLog(@"Accepting connection from: %@", newConnection);
assert(listener == self.listener);
assert(newConnection != nil);
NSLog(@"Accepting connection after asserts from: %@", newConnection);
// Configure the incoming connection
NSXPCInterface *adapterInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PEPObjCAdapterXpcApiProtocol)];
/*[adapterInterface setClasses:[NSSet setWithObject:[PEPObjCAdapterXpcApiResult class]]
forSelector:@selector(myself:resultBlock:)
argumentIndex:0
ofReply:YES];*/
/*[adapterInterface setClasses:[NSSet setWithObject:[NSString class]]
[adapterInterface setClasses:[NSSet setWithObject:[PEPObjCAdapterXpcApiResult class]]
forSelector:@selector(myself:resultBlock:)
argumentIndex:0
ofReply:NO];*/
ofReply:YES];
newConnection.exportedInterface = adapterInterface;
newConnection.exportedObject = self;


+ 2
- 5
pEpMacOSAdapter/ObjCAdapterXpcApi/PEPObjCAdapterXpcApiProtocol.h View File

@ -11,13 +11,10 @@ NS_ASSUME_NONNULL_BEGIN
//static NSString *daemonLabel = @"foundation.pEp.adapter.PEPObjCAdapterXpcApi_OpenStep";
static NSString *daemonLabel = @"pEp.foundation.pEpXPCAdapter_OpenStep";
@class PEPObjCAdapterXpcApiResult;
@class PEPIdentity, PEPObjCAdapterXpcApiResult;
@protocol PEPObjCAdapterXpcApiProtocol
//- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
- (void)myself:(NSString *)myself withReply:(void (^)(NSString *))replyBlock;
- (void)myself:(NSString *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
@end


+ 13
- 13
pEpMacOSAdapter/main.m View File

@ -72,28 +72,28 @@ void signal_TERM(int signal)
int main(int argc, const char *argv[])
{
signal(SIGTERM, signal_TERM);
//updater = [pEpUpdater new];
// Create an instance of the Objc Xpc Api daemon and start it
PEPObjCAdapterXpcApi *adapter = [[PEPObjCAdapterXpcApi alloc] init];
[adapter start];
updater = [pEpUpdater new];
// Create the delegate for the service.
//ServiceDelegate *delegate = [ServiceDelegate new];
ServiceDelegate *delegate = [ServiceDelegate new];
// Set up the one NSXPCListener for this service. It will handle all incoming connections.
// NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName:@"q.macOS_OpenStep"];
// NSLog(@"starting agent");
// listener.delegate = delegate;
// [listener resume];
NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName:@"foundation.pEp.adapter.macOS"];
NSLog(@"starting agent");
listener.delegate = delegate;
[listener resume];
// start the GUI helper app
// BOOL opened = start_helper();
// assert(opened);
BOOL opened = start_helper();
assert(opened);
// Create an instance of the PEP ObjC wrapper Adapter and start it
PEPObjCAdapterXpcApi *adapter = [[PEPObjCAdapterXpcApi alloc] init];
[adapter start];
NSLog(@"going into main runLoop");
NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
[runLoop run];
return EXIT_FAILURE;
}

Loading…
Cancel
Save