Browse Source

APPLEMAIL-33 No link with pEpObjCAdapter anymore. Refactor services structure. Add PEPObjCAdapterXPCService static library.

APPLEMAIL-33
David Alarcon 2 years ago
parent
commit
3b7819433a
17 changed files with 272 additions and 339 deletions
  1. +73
    -31
      pEpMacOSAdapter.xcodeproj/project.pbxproj
  2. +0
    -25
      pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApi.h
  3. +0
    -92
      pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApi.m
  4. +0
    -21
      pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiProtocol.h
  5. +0
    -22
      pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiResult.h
  6. +0
    -41
      pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiResult.m
  7. +30
    -0
      pEpMacOSAdapter/PEPNotificationXPCService/Interface/PEPNotificationXPCApiProtocol.h
  8. +20
    -0
      pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.h
  9. +13
    -0
      pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m
  10. +1
    -16
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCApiProtocol.h
  11. +19
    -0
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.h
  12. +13
    -22
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m
  13. +20
    -0
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.h
  14. +78
    -0
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.m
  15. +4
    -50
      pEpMacOSAdapter/main.m
  16. +0
    -18
      pEpMacOSAdapter/pEpMacOSAdapter.h
  17. +1
    -1
      pEpMacOSAdapter/pEpUpdater.h

+ 73
- 31
pEpMacOSAdapter.xcodeproj/project.pbxproj View File

@ -10,13 +10,13 @@
15AC46BC254EE19600AA18DE /* libdownloadclient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15AC46BB254EE19600AA18DE /* libdownloadclient.a */; };
35380AE7247BD13A004A08A6 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 35380AE6247BD13A004A08A6 /* README.md */; };
35380AEA247C784E004A08A6 /* pEpUpdater.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35380AE9247C784E004A08A6 /* pEpUpdater.mm */; };
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 */; };
4E2F30F425D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2F30F325D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m */; };
4E2F30F925D2A9CC002AFD0C /* PEPNotificationXPCService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2F30F825D2A9CC002AFD0C /* PEPNotificationXPCService.m */; };
4E2F30FE25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2F30FD25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.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 */; };
4E85771425BB227A007B6ECB /* libPEPObjCAdapter_macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E5FC0CF25B9C351000DF12C /* libPEPObjCAdapter_macOS.a */; };
4E9F55D025D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E9F55CF25D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -30,19 +30,21 @@
35380AE8247C784E004A08A6 /* pEpUpdater.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pEpUpdater.h; sourceTree = "<group>"; };
35380AE9247C784E004A08A6 /* pEpUpdater.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = pEpUpdater.mm; sourceTree = "<group>"; };
35DC18D2244DA19100FB2002 /* foundation.pEp.adapter.macOS.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = foundation.pEp.adapter.macOS.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
35DC18D5244DA19100FB2002 /* PEPMacOSAdapterProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPMacOSAdapterProtocol.h; sourceTree = "<group>"; };
35DC18D6244DA19100FB2002 /* pEpMacOSAdapter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pEpMacOSAdapter.h; sourceTree = "<group>"; };
35DC18D7244DA19100FB2002 /* pEpMacOSAdapter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = pEpMacOSAdapter.m; sourceTree = "<group>"; };
35DC18D5244DA19100FB2002 /* PEPUpdateDownloadXPCApiProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloadXPCApiProtocol.h; sourceTree = "<group>"; };
35DC18D9244DA19100FB2002 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
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>"; };
4E2F30F125D2A906002AFD0C /* PEPNotificationXPCApiProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPNotificationXPCApiProtocol.h; sourceTree = "<group>"; };
4E2F30F225D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloadXPCService.h; sourceTree = "<group>"; };
4E2F30F325D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPUpdateDownloadXPCService.m; sourceTree = "<group>"; };
4E2F30F725D2A9CC002AFD0C /* PEPNotificationXPCService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPNotificationXPCService.h; sourceTree = "<group>"; };
4E2F30F825D2A9CC002AFD0C /* PEPNotificationXPCService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPNotificationXPCService.m; sourceTree = "<group>"; };
4E2F30FC25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloadXPCApi.h; sourceTree = "<group>"; };
4E2F30FD25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPUpdateDownloadXPCApi.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>"; };
4E9F55CF25D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libPEPObjCAdapterXPCService.a; sourceTree = BUILT_PRODUCTS_DIR; };
4ED6F6CF25D2E283008BCE79 /* PEPObjCAdapterXPCService.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PEPObjCAdapterXPCService.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -51,9 +53,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 */,
4E9F55D025D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -80,11 +82,9 @@
35DC18D4244DA19100FB2002 /* pEpMacOSAdapter */ = {
isa = PBXGroup;
children = (
4E49289625B1DCB600A3A47C /* ObjCAdapterXpcWrapper */,
4E2F30E725D2A3EC002AFD0C /* PEPUpdateDownloadXPCService */,
4E2F30ED25D2A7E8002AFD0C /* PEPNotificationXPCService */,
35380AE6247BD13A004A08A6 /* README.md */,
35DC18D5244DA19100FB2002 /* PEPMacOSAdapterProtocol.h */,
35DC18D6244DA19100FB2002 /* pEpMacOSAdapter.h */,
35DC18D7244DA19100FB2002 /* pEpMacOSAdapter.m */,
35380AE8247C784E004A08A6 /* pEpUpdater.h */,
35380AE9247C784E004A08A6 /* pEpUpdater.mm */,
35DC18D9244DA19100FB2002 /* main.m */,
@ -96,6 +96,8 @@
35F06969247D58C800543884 /* Frameworks */ = {
isa = PBXGroup;
children = (
4E9F55CF25D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a */,
4ED6F6CF25D2E283008BCE79 /* PEPObjCAdapterXPCService.framework */,
4E5FC0F025B9D2CF000DF12C /* libz.tbd */,
15AC46BB254EE19600AA18DE /* libdownloadclient.a */,
4E5FC0CF25B9C351000DF12C /* libPEPObjCAdapter_macOS.a */,
@ -109,16 +111,58 @@
name = Frameworks;
sourceTree = "<group>";
};
4E49289625B1DCB600A3A47C /* ObjCAdapterXpcWrapper */ = {
4E2F30E725D2A3EC002AFD0C /* PEPUpdateDownloadXPCService */ = {
isa = PBXGroup;
children = (
4E67789425B71680003591E6 /* PEPObjCAdapterXpcApiProtocol.h */,
4E67789525B71680003591E6 /* PEPObjCAdapterXpcApiResult.h */,
4E67789625B71680003591E6 /* PEPObjCAdapterXpcApiResult.m */,
4E49289C25B200BD00A3A47C /* PEPObjCAdapterXpcApi.h */,
4E49289D25B200BD00A3A47C /* PEPObjCAdapterXpcApi.m */,
4E2F30E825D2A43C002AFD0C /* Interface */,
4E2F30E925D2A444002AFD0C /* XPCService */,
);
path = ObjCAdapterXpcWrapper;
path = PEPUpdateDownloadXPCService;
sourceTree = "<group>";
};
4E2F30E825D2A43C002AFD0C /* Interface */ = {
isa = PBXGroup;
children = (
35DC18D5244DA19100FB2002 /* PEPUpdateDownloadXPCApiProtocol.h */,
);
path = Interface;
sourceTree = "<group>";
};
4E2F30E925D2A444002AFD0C /* XPCService */ = {
isa = PBXGroup;
children = (
4E2F30F225D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.h */,
4E2F30F325D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m */,
4E2F30FC25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.h */,
4E2F30FD25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.m */,
);
path = XPCService;
sourceTree = "<group>";
};
4E2F30ED25D2A7E8002AFD0C /* PEPNotificationXPCService */ = {
isa = PBXGroup;
children = (
4E2F30EE25D2A7FA002AFD0C /* Interface */,
4E2F30EF25D2A800002AFD0C /* XPCService */,
);
path = PEPNotificationXPCService;
sourceTree = "<group>";
};
4E2F30EE25D2A7FA002AFD0C /* Interface */ = {
isa = PBXGroup;
children = (
4E2F30F125D2A906002AFD0C /* PEPNotificationXPCApiProtocol.h */,
);
path = Interface;
sourceTree = "<group>";
};
4E2F30EF25D2A800002AFD0C /* XPCService */ = {
isa = PBXGroup;
children = (
4E2F30F725D2A9CC002AFD0C /* PEPNotificationXPCService.h */,
4E2F30F825D2A9CC002AFD0C /* PEPNotificationXPCService.m */,
);
path = XPCService;
sourceTree = "<group>";
};
/* End PBXGroup section */
@ -213,9 +257,9 @@
files = (
35380AEA247C784E004A08A6 /* pEpUpdater.mm in Sources */,
35DC18DA244DA19100FB2002 /* main.m in Sources */,
4E49289E25B200BD00A3A47C /* PEPObjCAdapterXpcApi.m in Sources */,
4E67789725B71680003591E6 /* PEPObjCAdapterXpcApiResult.m in Sources */,
35DC18D8244DA19100FB2002 /* pEpMacOSAdapter.m in Sources */,
4E2F30F425D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m in Sources */,
4E2F30F925D2A9CC002AFD0C /* PEPNotificationXPCService.m in Sources */,
4E2F30FE25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -275,8 +319,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"${PROJECT_DIR}/../local/include",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/PEPObjCAdapterTypes/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/pEpObjCAdapter/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEp4AppleMail/pep4applemail/PEPObjCAdapterXpcApiClient/PEPObjCAdapterXPCService/Interface",
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.10;
@ -341,8 +384,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"${PROJECT_DIR}/../local/include",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/PEPObjCAdapterTypes/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEpObjCAdapter/pEpObjCAdapter/pEpObjCAdapter/PublicHeaders",
"$(PROJECT_DIR)/../../src_pEp4AppleMail/pep4applemail/PEPObjCAdapterXpcApiClient/PEPObjCAdapterXPCService/Interface",
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 10.10;


+ 0
- 25
pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApi.h View File

@ -1,25 +0,0 @@
//
// PEPObjCAdapterXpcApi.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 15/1/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
@import Foundation;
#import "PEPObjCAdapterXpcApiProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface PEPObjCAdapterXpcApi : NSObject <NSXPCListenerDelegate, PEPObjCAdapterXpcApiProtocol>
- (id) init;
// Begin listening for incoming XPC connections
- (void) start;
// Stop listening for incoming XPC connections
- (void) stop;
@end
NS_ASSUME_NONNULL_END

+ 0
- 92
pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApi.m View File

@ -1,92 +0,0 @@
//
// PEPObjCAdapterXpcApi.m
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 15/1/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import "PEPObjCAdapterXpcApi.h"
#import "PEPObjCAdapterXpcApiResult.h"
#import "PEPSession.h"
#import "PEPIdentity+SecureCoding.h"
@interface PEPObjCAdapterXpcApi ()
@property (nonatomic, strong, readwrite) NSXPCListener *listener;
@property (nonatomic, readwrite) BOOL started;
@end
@implementation PEPObjCAdapterXpcApi
- (id)init {
self.listener = [[NSXPCListener alloc] initWithMachServiceName:daemonLabel];
self.listener.delegate = self;
self.started = NO;
return self;
}
- (void)start {
assert(self.started == NO);
// Begin listening for incoming XPC connections
[self.listener resume];
self.started = YES;
NSLog(@"Started objc adapter wrapper api service: %@", daemonLabel);
}
- (void)stop {
assert(self.started == YES);
// Stop listening for incoming XPC connections
[self.listener suspend];
self.started = NO;
}
#pragma mark - PEPObjCAdapterXpcApiProtocol
- (void)myself:(PEPIdentity *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult * _Nonnull))resultCallback {
PEPSession *session = [PEPSession new];
[session mySelf:identity errorCallback:^(NSError * _Nonnull error) {
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:nil error:error];
resultCallback(result);
} successCallback:^(PEPIdentity * _Nonnull identity) {
PEPObjCAdapterXpcApiResult *result = [[PEPObjCAdapterXpcApiResult alloc] initWithResult:@[identity] error:nil];
resultCallback(result);
}];
}
#pragma mark - NSXPCListenerDelegate
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// Sanity checks
assert(listener == self.listener);
assert(newConnection != nil);
// 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:[PEPIdentity class]]
forSelector:@selector(myself:resultBlock:)
argumentIndex:0
ofReply:NO];
newConnection.exportedInterface = adapterInterface;
newConnection.exportedObject = self;
// New connections always start in a suspended state
[newConnection resume];
return YES;
}
@end

+ 0
- 21
pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiProtocol.h View File

@ -1,21 +0,0 @@
//
// PEPObjCAdapterXpcApi.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 15/1/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
static NSString *daemonLabel = @"pEp.foundation.pEpXPCAdapter_OpenStep";
@class PEPIdentity, PEPObjCAdapterXpcApiResult;
NS_ASSUME_NONNULL_BEGIN
@protocol PEPObjCAdapterXpcApiProtocol <NSObject>
- (void)myself:(PEPIdentity *)identity resultBlock:(void (^)(PEPObjCAdapterXpcApiResult *))resultCallback;
@end
NS_ASSUME_NONNULL_END

+ 0
- 22
pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiResult.h View File

@ -1,22 +0,0 @@
//
// PEPObjCAdapterXpcApiResult.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 15/1/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface PEPObjCAdapterXpcApiResult : NSObject <NSSecureCoding>
@property (readonly, nonatomic, strong) NSError *error;
@property (readonly, nonatomic, copy) NSArray* result;
- (instancetype)initWithResult:(NSArray* __nullable)result error:(NSError * __nullable)error;
@end
NS_ASSUME_NONNULL_END

+ 0
- 41
pEpMacOSAdapter/ObjCAdapterXpcWrapper/PEPObjCAdapterXpcApiResult.m View File

@ -1,41 +0,0 @@
//
// PEPObjCAdapterXpcApiResult.m
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 15/1/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import "PEPObjCAdapterXpcApiResult.h"
@implementation PEPObjCAdapterXpcApiResult
- (instancetype)initWithResult:(NSArray *)result error:(NSError *)error {
if (self = [self init]) {
_result = result;
_error = error;
}
return self;
}
- (void)encodeWithCoder:(nonnull NSCoder *)coder {
[coder encodeObject:self.result forKey:@"result"];
[coder encodeObject:self.error forKey:@"error"];
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder {
if (self = [self init]) {
NSArray<Class> *classes = @[[NSArray class], [NSObject class]];
_result = [coder decodeObjectOfClasses:[NSSet setWithArray:classes] forKey:@"result"];
_error = [coder decodeObjectOfClass:[NSError class] forKey:@"error"];
}
return self;
}
+ (BOOL)supportsSecureCoding {
return YES;
}
@end

+ 30
- 0
pEpMacOSAdapter/PEPNotificationXPCService/Interface/PEPNotificationXPCApiProtocol.h View File

@ -0,0 +1,30 @@
//
// PEPNotificationXPCApiProtocol.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Notification types
// TODO: Maybe does not belong to this protocol
typedef enum { ready = 0, downloading, downloadArrived, noDownloadAvailable } DNType;
/// Callback protocol to notify about download events
@protocol PEPNotificationXPCApiProtocol <NSObject>
/// notification about download events
- (void)notifyDownload:(int)type withName:(NSString*)name withFilename:(NSString*)filename;
@end
/// This is the object from the client where we deliver notifications to
@interface PEPNotification : NSObject <PEPNotificationXPCApiProtocol>
@end
NS_ASSUME_NONNULL_END

+ 20
- 0
pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.h View File

@ -0,0 +1,20 @@
//
// PEPNotificationXPCService.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface PEPNotificationXPCService : NSObject
/// Begin listening for incoming XPC connections
- (void)start;
@end
NS_ASSUME_NONNULL_END

+ 13
- 0
pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m View File

@ -0,0 +1,13 @@
//
// PEPNotificationXPCService.m
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import "PEPNotificationXPCService.h"
@implementation PEPNotificationXPCService
@end

pEpMacOSAdapter/PEPMacOSAdapterProtocol.h → pEpMacOSAdapter/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCApiProtocol.h View File


+ 19
- 0
pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.h View File

@ -0,0 +1,19 @@
//
// PEPUpdateDownloadXPCApi.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PEPUpdateDownloadXPCApiProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface PEPUpdateDownloadXPCApi : NSObject <PEPUpdateDownloadXPCApiProtocol>
@property (retain) NSXPCConnection* clientConnection;
@end
NS_ASSUME_NONNULL_END

pEpMacOSAdapter/pEpMacOSAdapter.m → pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m View File


+ 20
- 0
pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.h View File

@ -0,0 +1,20 @@
//
// PEPUpdateDownloadXPCService.h
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface PEPUpdateDownloadXPCService : NSObject <NSXPCListenerDelegate>
/// Begin listening for incoming XPC connections
- (void)start;
@end
NS_ASSUME_NONNULL_END

+ 78
- 0
pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.m View File

@ -0,0 +1,78 @@
//
// PEPUpdateDownloadXPCService.m
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import "PEPUpdateDownloadXPCService.h"
@import AppKit;
#import "PEPUpdateDownloadXPCApiProtocol.h"
#import "PEPUpdateDownloadXPCApi.h"
@interface PEPUpdateDownloadXPCService ()
@property (nonatomic, strong, readwrite) NSXPCListener *listener;
@end
@implementation PEPUpdateDownloadXPCService
- (instancetype)init {
if (self = [super init]) {
_listener = [[NSXPCListener alloc] initWithMachServiceName:@"foundation.pEp.adapter.macOS_OpenStep"];
NSLog(@"starting agent");
_listener.delegate = self;
}
return self;
}
- (void)start {
[self.listener resume];
BOOL opened = [self startPEPUpdatesApp];
assert(opened);
}
// MARK: - Private
- (BOOL)startPEPUpdatesApp {
NSURL *url = [NSURL
fileURLWithPath:@"/Library/Application Support/pEp/pEp.app/Contents/Library/LoginItems/pp updates.app"];
return [[NSWorkspace sharedWorkspace] openURL:url];
}
// MARK: - NSXPCListenerDelegate
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection.
NSLog(@"incoming connection");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PEPUpdateDownloadXPCApiProtocol)];
// Next, set the object that the connection exports. All messages sent on
// the connection to this service will be sent to the exported object to
// handle. The connection retains the exported object.
PEPUpdateDownloadXPCApi *exportedObject = [PEPUpdateDownloadXPCApi new];
newConnection.exportedObject = exportedObject;
if (!newConnection.exportedInterface || !newConnection.exportedObject) {
NSLog(@"failed to allocate object and interface");
return NO;
}
// Resuming the connection allows the system to deliver more incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO.
NSLog(@"connection accepted");
return YES;
}
@end

+ 4
- 50
pEpMacOSAdapter/main.m View File

@ -7,12 +7,11 @@
// This file is under GNU General Public License 3.0
//
@import Foundation;
#import "PEPObjcAdapterXPCService.h"
#include <signal.h>
#import <Foundation/Foundation.h>
#import <AppKit/NSWorkspace.h>
#import "pEpMacOSAdapter.h"
#import "pEpUpdater.h"
#import "PEPObjCAdapterXpcApi.h"
pEpUpdater* updater = nil;
@ -26,43 +25,8 @@ pEpUpdater* updater = nil;
return self;
}
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection.
NSLog(@"incoming connection");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PEPMacOSAdapterProtocol)];
// Next, set the object that the connection exports. All messages sent on
// the connection to this service will be sent to the exported object to
// handle. The connection retains the exported object.
pEpMacOSAdapter *exportedObject = [pEpMacOSAdapter new];
newConnection.exportedObject = exportedObject;
if (!newConnection.exportedInterface || !newConnection.exportedObject) {
NSLog(@"failed to allocate object and interface");
return NO;
}
// Resuming the connection allows the system to deliver more incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO.
NSLog(@"connection accepted");
return YES;
}
@end
BOOL start_helper(void)
{
NSURL *url = [NSURL
fileURLWithPath:@"/Library/Application Support/pEp/pEp.app/Contents/Library/LoginItems/pp updates.app"];
return [[NSWorkspace sharedWorkspace] openURL:url];
}
void signal_TERM(int signal)
{
NSLog(@"stopping agent");
@ -76,19 +40,9 @@ int main(int argc, const char *argv[])
// Create the delegate for the service.
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_OpenStep"];
NSLog(@"starting agent");
listener.delegate = delegate;
[listener resume];
// start the GUI helper app
BOOL opened = start_helper();
assert(opened);
// Create an instance of the PEP ObjC wrapper Adapter and start it
PEPObjCAdapterXpcApi *adapter = [[PEPObjCAdapterXpcApi alloc] init];
PEPObjCAdapterXPCService *adapter = [[PEPObjCAdapterXPCService alloc] init];
[adapter start];
NSLog(@"going into main runLoop");


+ 0
- 18
pEpMacOSAdapter/pEpMacOSAdapter.h View File

@ -1,18 +0,0 @@
//
// pEpMacOSAdapter.h
// pEpMacOSAdapter
//
// Created by Volker Birk on 20.04.20.
// Copyleft © 2020 pp foundation.
// This file is under GNU General Public License 3.0
//
#import <Foundation/Foundation.h>
#import "PEPMacOSAdapterProtocol.h"
/// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
@interface pEpMacOSAdapter : NSObject <PEPMacOSAdapterProtocol>
@property (retain) NSXPCConnection* clientConnection;
@end

+ 1
- 1
pEpMacOSAdapter/pEpUpdater.h View File

@ -8,7 +8,7 @@
//
#import <Foundation/Foundation.h>
#import "PEPMacOSAdapterProtocol.h"
#import "PEPNotificationXPCApiProtocol.h"
/// object encapsulating the update client functionality of downloadclient
@interface pEpUpdater : NSObject


Loading…
Cancel
Save