Browse Source

APPLEMAIL-33 Refactor PEPUpdatesXPCService. Add PEPNotificationXPCService. Delete unused code in pEpMacOSAdapter.

APPLEMAIL-33
David Alarcon 2 years ago
parent
commit
edcb1d51c6
24 changed files with 312 additions and 568 deletions
  1. +92
    -6
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService.xcodeproj/project.pbxproj
  2. +25
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCApiClient/Interface/PEPNotificationApiClientService.h
  3. +77
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCApiClient/XPCService/PEPNotificationApiClientService.m
  4. +5
    -1
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCService.h
  5. +21
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCServiceDelegate.h
  6. +21
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCApi.h
  7. +44
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCApi.m
  8. +15
    -23
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m
  9. +7
    -1
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/Shared/PEPNotificationXPCApiProtocol.h
  10. +0
    -13
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m
  11. +1
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCService.h
  12. +3
    -32
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m
  13. +0
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/Shared/PEPUpdateDownloader.h
  14. +0
    -78
      pEpMacOSAdapter.xcodeproj/project.pbxproj
  15. +0
    -30
      pEpMacOSAdapter/PEPNotificationXPCService/Interface/PEPNotificationXPCApiProtocol.h
  16. +0
    -20
      pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.h
  17. +0
    -13
      pEpMacOSAdapter/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m
  18. +0
    -35
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCApiProtocol.h
  19. +0
    -43
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/PEPUpdateDownloader.h
  20. +0
    -147
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/PEPUpdateDownloader.mm
  21. +0
    -19
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.h
  22. +0
    -67
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m
  23. +0
    -20
      pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.h
  24. +1
    -20
      pEpMacOSAdapter/main.m

+ 92
- 6
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService.xcodeproj/project.pbxproj View File

@ -9,11 +9,14 @@
/* Begin PBXBuildFile section */
4E61821525D58162007E040F /* PEPUpdateDownloadApiClientService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E61821325D58162007E040F /* PEPUpdateDownloadApiClientService.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E61821625D58162007E040F /* PEPUpdateDownloadApiClientService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E61821425D58162007E040F /* PEPUpdateDownloadApiClientService.m */; };
4E61823A25D59701007E040F /* PEPNotificationApiClientService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E61823825D59701007E040F /* PEPNotificationApiClientService.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E61823B25D59701007E040F /* PEPNotificationApiClientService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E61823925D59701007E040F /* PEPNotificationApiClientService.m */; };
4E61824D25D5A4C5007E040F /* PEPNotificationXPCServiceDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E61824C25D5A4C5007E040F /* PEPNotificationXPCServiceDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E797B9725D523FD0090F900 /* PEPUpdatesXPCService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797B9625D523FD0090F900 /* PEPUpdatesXPCService.h */; };
4E797B9925D523FD0090F900 /* PEPUpdatesXPCService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E797B9825D523FD0090F900 /* PEPUpdatesXPCService.m */; };
4E797BB825D5255F0090F900 /* PEPNotificationXPCApiProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BAA25D5255F0090F900 /* PEPNotificationXPCApiProtocol.h */; };
4E797BB925D5255F0090F900 /* PEPNotificationXPCService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E797BAC25D5255F0090F900 /* PEPNotificationXPCService.m */; };
4E797BBA25D5255F0090F900 /* PEPNotificationXPCService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BAD25D5255F0090F900 /* PEPNotificationXPCService.h */; };
4E797BBA25D5255F0090F900 /* PEPNotificationXPCService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BAD25D5255F0090F900 /* PEPNotificationXPCService.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E797BBB25D5255F0090F900 /* PEPUpdateDownloadXPCApiProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BB025D5255F0090F900 /* PEPUpdateDownloadXPCApiProtocol.h */; };
4E797BBC25D5255F0090F900 /* PEPUpdateDownloader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4E797BB125D5255F0090F900 /* PEPUpdateDownloader.mm */; };
4E797BBD25D5255F0090F900 /* PEPUpdateDownloadXPCApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BB325D5255F0090F900 /* PEPUpdateDownloadXPCApi.h */; };
@ -22,11 +25,16 @@
4E797BC025D5255F0090F900 /* PEPUpdateDownloadXPCService.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BB625D5255F0090F900 /* PEPUpdateDownloadXPCService.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E797BC125D5255F0090F900 /* PEPUpdateDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E797BB725D5255F0090F900 /* PEPUpdateDownloader.h */; };
4E797D8C25D543520090F900 /* libdownloadclient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E797D2225D53CCC0090F900 /* libdownloadclient.a */; };
4EA193EA25D6829B00F5D802 /* PEPNotificationXPCApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EA193E825D6829B00F5D802 /* PEPNotificationXPCApi.h */; };
4EA193EB25D6829B00F5D802 /* PEPNotificationXPCApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA193E925D6829B00F5D802 /* PEPNotificationXPCApi.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
4E61821325D58162007E040F /* PEPUpdateDownloadApiClientService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloadApiClientService.h; sourceTree = "<group>"; };
4E61821425D58162007E040F /* PEPUpdateDownloadApiClientService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPUpdateDownloadApiClientService.m; sourceTree = "<group>"; };
4E61823825D59701007E040F /* PEPNotificationApiClientService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPNotificationApiClientService.h; sourceTree = "<group>"; };
4E61823925D59701007E040F /* PEPNotificationApiClientService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPNotificationApiClientService.m; sourceTree = "<group>"; };
4E61824C25D5A4C5007E040F /* PEPNotificationXPCServiceDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPNotificationXPCServiceDelegate.h; sourceTree = "<group>"; };
4E797B9325D523FD0090F900 /* libPEPUpdatesXPCService.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPEPUpdatesXPCService.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E797B9625D523FD0090F900 /* PEPUpdatesXPCService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdatesXPCService.h; sourceTree = "<group>"; };
4E797B9825D523FD0090F900 /* PEPUpdatesXPCService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPUpdatesXPCService.m; sourceTree = "<group>"; };
@ -42,6 +50,8 @@
4E797BB725D5255F0090F900 /* PEPUpdateDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloader.h; sourceTree = "<group>"; };
4E797BC625D526640090F900 /* libdownloadclient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libdownloadclient.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E797D2225D53CCC0090F900 /* libdownloadclient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libdownloadclient.a; sourceTree = BUILT_PRODUCTS_DIR; };
4EA193E825D6829B00F5D802 /* PEPNotificationXPCApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPNotificationXPCApi.h; sourceTree = "<group>"; };
4EA193E925D6829B00F5D802 /* PEPNotificationXPCApi.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPNotificationXPCApi.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -104,12 +114,62 @@
4E61823525D591A2007E040F /* UpdateDownloader */ = {
isa = PBXGroup;
children = (
4E797BB725D5255F0090F900 /* PEPUpdateDownloader.h */,
4E797BB125D5255F0090F900 /* PEPUpdateDownloader.mm */,
);
path = UpdateDownloader;
sourceTree = "<group>";
};
4E61823725D59683007E040F /* Shared */ = {
isa = PBXGroup;
children = (
4E797BAA25D5255F0090F900 /* PEPNotificationXPCApiProtocol.h */,
);
path = Shared;
sourceTree = "<group>";
};
4E61823E25D59737007E040F /* PEPNotificationXPCApiClient */ = {
isa = PBXGroup;
children = (
4E797BA925D5255F0090F900 /* Interface */,
4E61824025D5976F007E040F /* XPCService */,
);
path = PEPNotificationXPCApiClient;
sourceTree = "<group>";
};
4E61823F25D5974F007E040F /* PEPNotificationXPCService */ = {
isa = PBXGroup;
children = (
4E61824B25D5A498007E040F /* Interface */,
4E797BAB25D5255F0090F900 /* XPCService */,
);
path = PEPNotificationXPCService;
sourceTree = "<group>";
};
4E61824025D5976F007E040F /* XPCService */ = {
isa = PBXGroup;
children = (
4E61823925D59701007E040F /* PEPNotificationApiClientService.m */,
);
path = XPCService;
sourceTree = "<group>";
};
4E61824525D59EC9007E040F /* Shared */ = {
isa = PBXGroup;
children = (
4E797BB725D5255F0090F900 /* PEPUpdateDownloader.h */,
);
path = Shared;
sourceTree = "<group>";
};
4E61824B25D5A498007E040F /* Interface */ = {
isa = PBXGroup;
children = (
4E61824C25D5A4C5007E040F /* PEPNotificationXPCServiceDelegate.h */,
4E797BAD25D5255F0090F900 /* PEPNotificationXPCService.h */,
);
path = Interface;
sourceTree = "<group>";
};
4E797B8A25D523FD0090F900 = {
isa = PBXGroup;
children = (
@ -130,6 +190,7 @@
4E797B9525D523FD0090F900 /* PEPUpdatesXPCService */ = {
isa = PBXGroup;
children = (
4E61824525D59EC9007E040F /* Shared */,
4E797BAE25D5255F0090F900 /* PEPUpdateDownloadXPCService */,
4E797BA825D5255F0090F900 /* PEPNotificationXPCService */,
4E797B9625D523FD0090F900 /* PEPUpdatesXPCService.h */,
@ -141,8 +202,9 @@
4E797BA825D5255F0090F900 /* PEPNotificationXPCService */ = {
isa = PBXGroup;
children = (
4E797BA925D5255F0090F900 /* Interface */,
4E797BAB25D5255F0090F900 /* XPCService */,
4E61823725D59683007E040F /* Shared */,
4E61823E25D59737007E040F /* PEPNotificationXPCApiClient */,
4E61823F25D5974F007E040F /* PEPNotificationXPCService */,
);
path = PEPNotificationXPCService;
sourceTree = "<group>";
@ -150,7 +212,7 @@
4E797BA925D5255F0090F900 /* Interface */ = {
isa = PBXGroup;
children = (
4E797BAA25D5255F0090F900 /* PEPNotificationXPCApiProtocol.h */,
4E61823825D59701007E040F /* PEPNotificationApiClientService.h */,
);
path = Interface;
sourceTree = "<group>";
@ -159,7 +221,8 @@
isa = PBXGroup;
children = (
4E797BAC25D5255F0090F900 /* PEPNotificationXPCService.m */,
4E797BAD25D5255F0090F900 /* PEPNotificationXPCService.h */,
4EA193E825D6829B00F5D802 /* PEPNotificationXPCApi.h */,
4EA193E925D6829B00F5D802 /* PEPNotificationXPCApi.m */,
);
path = XPCService;
sourceTree = "<group>";
@ -212,8 +275,11 @@
4E61821525D58162007E040F /* PEPUpdateDownloadApiClientService.h in Headers */,
4E797BBD25D5255F0090F900 /* PEPUpdateDownloadXPCApi.h in Headers */,
4E797BC025D5255F0090F900 /* PEPUpdateDownloadXPCService.h in Headers */,
4E61824D25D5A4C5007E040F /* PEPNotificationXPCServiceDelegate.h in Headers */,
4EA193EA25D6829B00F5D802 /* PEPNotificationXPCApi.h in Headers */,
4E797BBB25D5255F0090F900 /* PEPUpdateDownloadXPCApiProtocol.h in Headers */,
4E797B9725D523FD0090F900 /* PEPUpdatesXPCService.h in Headers */,
4E61823A25D59701007E040F /* PEPNotificationApiClientService.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -247,6 +313,7 @@
TargetAttributes = {
4E797B9225D523FD0090F900 = {
CreatedOnToolsVersion = 12.4;
LastSwiftMigration = 1240;
};
};
};
@ -273,8 +340,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4E61823B25D59701007E040F /* PEPNotificationApiClientService.m in Sources */,
4E797BBE25D5255F0090F900 /* PEPUpdateDownloadXPCService.m in Sources */,
4E797BB925D5255F0090F900 /* PEPNotificationXPCService.m in Sources */,
4EA193EB25D6829B00F5D802 /* PEPNotificationXPCApi.m in Sources */,
4E61821625D58162007E040F /* PEPUpdateDownloadApiClientService.m in Sources */,
4E797BBF25D5255F0090F900 /* PEPUpdateDownloadXPCApi.m in Sources */,
4E797B9925D523FD0090F900 /* PEPUpdatesXPCService.m in Sources */,
@ -411,15 +480,24 @@
4E797B9D25D523FD0090F900 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = NQLYU6MGPN;
EXECUTABLE_PREFIX = lib;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPUpdatesXPCService-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
USER_HEADER_SEARCH_PATHS = "$(inherited)";
};
name = Debug;
@ -427,15 +505,23 @@
4E797B9E25D523FD0090F900 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = NQLYU6MGPN;
EXECUTABLE_PREFIX = lib;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPUpdatesXPCService-Bridging-Header.h";
SWIFT_VERSION = 5.0;
USER_HEADER_SEARCH_PATHS = "$(inherited)";
};
name = Release;


+ 25
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCApiClient/Interface/PEPNotificationApiClientService.h View File

@ -0,0 +1,25 @@
//
// PEPNotificationApiClientService.h
// PEPUpdatesXPCService
//
// Created by David Alarcon on 11/2/21.
//
#import <Foundation/Foundation.h>
#import "PEPNotificationXPCApiProtocol.h"
@class PEPUpdateDownloader;
NS_ASSUME_NONNULL_BEGIN
@interface PEPNotificationApiClientService : NSObject <PEPNotificationXPCApiProtocol>
- (instancetype)initWithListenerEndpoint:(NSXPCListenerEndpoint *)endpoint
updateDownloader:(PEPUpdateDownloader *)updateDownloader;
- (void)start ;
- (void)stop;
@end
NS_ASSUME_NONNULL_END

+ 77
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCApiClient/XPCService/PEPNotificationApiClientService.m View File

@ -0,0 +1,77 @@
//
// PEPNotificationApiClientService.m
// PEPUpdatesXPCService
//
// Created by David Alarcon on 11/2/21.
//
#import "PEPNotificationApiClientService.h"
#import "PEPUpdateDownloader.h"
@interface PEPNotificationApiClientService ()
@property (nonatomic) NSXPCConnection *connection;
@property (nonatomic) id<PEPNotificationXPCApiProtocol> pEpDownloadNotification;
@property (nonatomic) NSXPCListenerEndpoint *endpoint;
@property (nonatomic) PEPUpdateDownloader *updateDownloader;
@end
@implementation PEPNotificationApiClientService
- (instancetype)initWithListenerEndpoint:(NSXPCListenerEndpoint *)endpoint
updateDownloader:(PEPUpdateDownloader *)updateDownloader {
if (self = [self init]) {
_endpoint = endpoint;
_updateDownloader = updateDownloader;
}
return self;
}
- (void)start {
[self connectToXPCService];
}
- (void)stop {
self.connection = nil;
}
// MARK: - Private
- (void)connectToXPCService {
self.connection = [[NSXPCConnection alloc] initWithListenerEndpoint:self.endpoint];
NSXPCInterface *remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PEPNotificationXPCApiProtocol)];
self.connection.remoteObjectInterface = remoteObjectInterface;
__weak typeof(self) weakSelf = self;
self.connection.invalidationHandler = ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.connection = nil;
NSLog(@"Connection has been invalidated.\n");
};
self.connection.interruptionHandler = ^{
__strong typeof(self) strongSelf = weakSelf;
strongSelf.connection.interruptionHandler = nil;
NSLog(@"Connection has been interrupted.\n");
};
// New connections always start in a suspended state
[self.connection resume];
// The remote object
self.pEpDownloadNotification = [self.connection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
}];
self.updateDownloader.subscriber = self.pEpDownloadNotification;
if (self.pEpDownloadNotification) {
[self.pEpDownloadNotification notifyDownload:ready withName:@"" withFilename:@""];
}
}
// MARK: - PEPNotificationXPCApiProtocol
- (void)notifyDownload:(int)type withName:(NSString *)name withFilename:(NSString *)filename {
[self.pEpDownloadNotification notifyDownload:type withName:name withFilename:filename];
}
@end

Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.h → Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCService.h View File


+ 21
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCServiceDelegate.h View File

@ -0,0 +1,21 @@
//
// PEPNotificationXPCServiceDelegate.h
// PEPUpdatesXPCService
//
// Created by David Alarcon on 11/2/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol PEPNotificationXPCServiceDelegate <NSObject>
- (void)pEpNotificationIsDownloadingWithName:(NSString *)name;
- (void)pEpNotificationDownloadDidArriveWithName:(NSString *)name filename:(NSString *)filename;
- (void)pEpNotificationNoDownloadAvailable;
- (void)pEpNotificationReady;
@end
NS_ASSUME_NONNULL_END

+ 21
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCApi.h View File

@ -0,0 +1,21 @@
//
// PEPNotificationXPCApi.h
// PEPUpdatesXPCService
//
// Created by David Alarcon on 12/2/21.
//
#import <Foundation/Foundation.h>
#import "PEPNotificationXPCApiProtocol.h"
#import "PEPNotificationXPCServiceDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface PEPNotificationXPCApi : NSObject <PEPNotificationXPCApiProtocol>
- (instancetype)initWithDelegate:(id<PEPNotificationXPCServiceDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

+ 44
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCApi.m View File

@ -0,0 +1,44 @@
//
// PEPNotificationXPCApi.m
// PEPUpdatesXPCService
//
// Created by David Alarcon on 12/2/21.
//
#import "PEPNotificationXPCApi.h"
@interface PEPNotificationXPCApi ()
@property (nonatomic, weak) id<PEPNotificationXPCServiceDelegate> delegate;
@end
@implementation PEPNotificationXPCApi
- (instancetype)initWithDelegate:(id<PEPNotificationXPCServiceDelegate>)delegate {
if (self = [self init]) {
_delegate = delegate;
}
return self;
}
// MARK: - PEPNotificationXPCApiProtocol
- (void)notifyDownload:(int)type
withName:(nonnull NSString *)name
withFilename:(nonnull NSString *)filename {
switch (type) {
case downloading:
[self.delegate pEpNotificationIsDownloadingWithName:name];
break;
case downloadArrived:
[self.delegate pEpNotificationDownloadDidArriveWithName:name filename:filename];
break;
case noDownloadAvailable:
[self.delegate pEpNotificationNoDownloadAvailable];
break;
case ready:
[self.delegate pEpNotificationReady];
}
}
@end

pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCService.m → Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m View File


Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCApiProtocol.h → Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/Shared/PEPNotificationXPCApiProtocol.h View File


+ 0
- 13
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m View File

@ -1,13 +0,0 @@
//
// 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

+ 1
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCService.h View File

@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Begin listening for incoming XPC connections
- (void)start;
- (void)stop;
@end


+ 3
- 32
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m View File

@ -9,6 +9,7 @@
#import "PEPUpdateDownloadXPCApi.h"
#import "PEPNotificationXPCApiProtocol.h"
#import "PEPUpdateDownloader.h"
#import "PEPNotificationApiClientService.h"
//extern PEPUpdateDownloader* updater;
@interface PEPUpdateDownloadXPCApi ()
@ -24,38 +25,8 @@
self.updater = [PEPUpdateDownloader new];
}
///NotificationXPCService *service = ....
///[service start];
if (self.updater) {
_clientConnection = [[NSXPCConnection alloc] initWithListenerEndpoint:endpoint];
_clientConnection.remoteObjectInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(PEPNotificationXPCApiProtocol)];
__weak typeof(self) weakSelf = self;
_clientConnection.interruptionHandler = ^(){
__strong typeof(self) strongSelf = weakSelf;
NSLog(@"interruption");
strongSelf.updater.subscriber = nil;
};
_clientConnection.invalidationHandler = ^(){
__strong typeof(self) strongSelf = weakSelf;
NSLog(@"invalidation");
strongSelf.updater.subscriber = nil;
};
[_clientConnection resume];
PEPNotification* downloadNotification = [_clientConnection remoteObjectProxyWithErrorHandler:^(NSError*err) {
NSLog(@"%@", err);
}];
self.updater.subscriber = downloadNotification;
if (downloadNotification) {
[downloadNotification notifyDownload:ready withName:@"" withFilename:@""];
}
}
PEPNotificationApiClientService *service = [[PEPNotificationApiClientService alloc] initWithListenerEndpoint:endpoint updateDownloader:self.updater];
[service start];
}
- (void)unsubscribeForUpdate {


Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCService/UpdateDownloader/PEPUpdateDownloader.h → Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/Shared/PEPUpdateDownloader.h View File


+ 0
- 78
pEpMacOSAdapter.xcodeproj/project.pbxproj View File

@ -8,14 +8,9 @@
/* Begin PBXBuildFile section */
35380AE7247BD13A004A08A6 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 35380AE6247BD13A004A08A6 /* README.md */; };
35380AEA247C784E004A08A6 /* PEPUpdateDownloader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35380AE9247C784E004A08A6 /* PEPUpdateDownloader.mm */; };
35DC18DA244DA19100FB2002 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 35DC18D9244DA19100FB2002 /* main.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 */; };
4E797BCB25D526740090F900 /* libPEPUpdatesXPCService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E797BCA25D526740090F900 /* libPEPUpdatesXPCService.a */; };
4E9F55D025D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E9F55CF25D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a */; };
/* End PBXBuildFile section */
@ -27,19 +22,9 @@
15AC46BB254EE19600AA18DE /* libdownloadclient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libdownloadclient.a; sourceTree = BUILT_PRODUCTS_DIR; };
15CC85A62546D71A00DC43A1 /* libdownloadclient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libdownloadclient.a; sourceTree = BUILT_PRODUCTS_DIR; };
35380AE6247BD13A004A08A6 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
35380AE8247C784E004A08A6 /* PEPUpdateDownloader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPUpdateDownloader.h; sourceTree = "<group>"; };
35380AE9247C784E004A08A6 /* PEPUpdateDownloader.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PEPUpdateDownloader.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 /* 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>"; };
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; };
@ -55,7 +40,6 @@
files = (
4E5FC0EB25B9D212000DF12C /* libiconv.2.tbd in Frameworks */,
4E5FC0F225B9D2E0000DF12C /* libz.tbd in Frameworks */,
4E797BCB25D526740090F900 /* libPEPUpdatesXPCService.a in Frameworks */,
4E9F55D025D3D4B8005BD46F /* libPEPObjCAdapterXPCService.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -83,8 +67,6 @@
35DC18D4244DA19100FB2002 /* pEpMacOSAdapter */ = {
isa = PBXGroup;
children = (
4E2F30E725D2A3EC002AFD0C /* PEPUpdateDownloadXPCService */,
4E2F30ED25D2A7E8002AFD0C /* PEPNotificationXPCService */,
35380AE6247BD13A004A08A6 /* README.md */,
35DC18D9244DA19100FB2002 /* main.m */,
35DC18DB244DA19100FB2002 /* Info.plist */,
@ -111,62 +93,6 @@
name = Frameworks;
sourceTree = "<group>";
};
4E2F30E725D2A3EC002AFD0C /* PEPUpdateDownloadXPCService */ = {
isa = PBXGroup;
children = (
4E2F30E825D2A43C002AFD0C /* Interface */,
4E2F30E925D2A444002AFD0C /* XPCService */,
35380AE8247C784E004A08A6 /* PEPUpdateDownloader.h */,
35380AE9247C784E004A08A6 /* PEPUpdateDownloader.mm */,
);
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 */
/* Begin PBXNativeTarget section */
@ -257,11 +183,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
35380AEA247C784E004A08A6 /* PEPUpdateDownloader.mm in Sources */,
35DC18DA244DA19100FB2002 /* main.m in Sources */,
4E2F30F425D2A9B0002AFD0C /* PEPUpdateDownloadXPCService.m in Sources */,
4E2F30F925D2A9CC002AFD0C /* PEPNotificationXPCService.m in Sources */,
4E2F30FE25D2AE1E002AFD0C /* PEPUpdateDownloadXPCApi.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};


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

@ -1,30 +0,0 @@
//
// 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

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

@ -1,20 +0,0 @@
//
// 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

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

@ -1,13 +0,0 @@
//
// 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

+ 0
- 35
pEpMacOSAdapter/PEPUpdateDownloadXPCService/Interface/PEPUpdateDownloadXPCApiProtocol.h View File

@ -1,35 +0,0 @@
//
// PEPMacOSAdapterProtocol.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>
/// This protocol is providing the XPC interface to the User Interface program pEpNotifications
@protocol PEPUpdateDownloadXPCApiProtocol
/**
subscribe to the published notifications about downloads arriving
- Parameter downloading: block to call back when a download is going to happen
- Parameter downloadArrived: block to call back when a download arrived
*/
- (void)subscribeForUpdate:(NSXPCListenerEndpoint*)endpoint;
/// unsubscribe from receiving notifications about downloads arriving
- (void)unsubscribeForUpdate;
/// search for immediate updates
- (void)updateNow;
/// schedules updates each 2 hours
- (void)scheduleUpdates;
/// stop auto updates
- (void)stopUpdates;
@end

+ 0
- 43
pEpMacOSAdapter/PEPUpdateDownloadXPCService/PEPUpdateDownloader.h View File

@ -1,43 +0,0 @@
//
// PEPUpdateDownloader.h
// pEpMacOSAdapter
//
// Created by Volker Birk on 26.05.20.
// Copyright © 2020 pp foundation. All rights reserved.
// This file is under GNU General Public License 3.0
//
#import <Foundation/Foundation.h>
#import "PEPNotificationXPCApiProtocol.h"
/// object encapsulating the update client functionality of downloadclient
@interface PEPUpdateDownloader : NSObject
/// default 2 hours = 7200 seconds
@property (retain) NSTimer* timer;
/// path with config files
@property (retain) NSString* configPath;
/// subscriber for notifications
@property (retain) PEPNotification* subscriber;
/// initializes the PEPUpdateDownloader
- (id)init;
/// schedules updates each 2 hours
- (void)scheduleUpdates;
/// stop auto updates
- (void)stopUpdates;
/// update all configured software
- (void)updateAll;
/// update software described by config file
- (void)updateWithFile:(NSString*)configFile error:(NSError **)err;
/// update a product from URL of update server
- (void)update:(NSString*)name usingUrl:(NSString*)url;
@end

+ 0
- 147
pEpMacOSAdapter/PEPUpdateDownloadXPCService/PEPUpdateDownloader.mm View File

@ -1,147 +0,0 @@
//
// PEPUpdateDownloader.mm
// pEpMacOSAdapter
//
// Created by Volker Birk on 26.05.20.
// Copyright © 2020 p≡p foundation. All rights reserved.
// This file is under GNU General Public License 3.0
//
#import "PEPUpdateDownloader.h"
#include "../../downloadclient/downloadclient.hh"
const double CYCLE = 7200.0; // 7200 seconds = 2 hours
NSString* CONFIG_PATH = @"/Library/Application Support/pEp/Updater";
@implementation PEPUpdateDownloader
- (id)init
{
self = [super init];
if (self) {
self.configPath = CONFIG_PATH;
}
return self;
}
- (void)scheduleUpdates
{
if (!self.timer) {
NSLog(@"schedule updates");
dispatch_async(dispatch_get_main_queue(), ^{
self.timer = [NSTimer scheduledTimerWithTimeInterval:CYCLE
target:self
selector:@selector(updateAll)
userInfo:nil
repeats:YES];
});
}
else {
NSLog(@"timer already there");
}
}
- (void)stopUpdates
{
if (self.timer) {
NSLog(@"stop auto updates");
[self.timer invalidate];
self.timer = nil;
}
}
- (void)updateAll
{
NSLog(@"update all registered products");
NSFileManager *localFileManager=[NSFileManager new];
NSDirectoryEnumerator *dirEnum = [localFileManager enumeratorAtPath:_configPath];
NSString *configFile;
while (dirEnum && (configFile = [dirEnum nextObject])) {
if ([[configFile pathExtension] isEqualToString: @"plist"]) {
NSError *err = nil;
[self updateWithFile:[NSString stringWithFormat:@"%@/%@", _configPath, configFile] error:&err];
}
}
}
- (void)updateWithFile:(NSString*)configFile error:(NSError **)err
{
NSLog(@"update product with config file %@", configFile);
NSInputStream *is = [NSInputStream inputStreamWithFileAtPath:configFile];
[is open];
NSDictionary* plist = [NSPropertyListSerialization
propertyListWithStream:is options:NSPropertyListMutableContainers
format:nil error:err];
[is close];
if (plist) {
NSString* name = [plist objectForKey:@"name"];
NSString* url = [plist objectForKey:@"url"];
if (name && url) {
[self update:name usingUrl:url];
}
}
else if (err) {
NSLog(@"%@ %@ %@ %@", (*err).localizedDescription,
(*err).localizedFailureReason, (*err).localizedRecoveryOptions,
(*err).localizedRecoverySuggestion);
}
}
- (void)update:(NSString*)name usingUrl:(NSString*)url
{
NSLog(@"update %@ using %@", name, url);
pEp::UpdateClient::product p = { name.UTF8String, url.UTF8String };
std::string keyfile = _configPath.UTF8String;
keyfile += std::string("/");
keyfile += p.name;
keyfile += std::string(".der");
NSLog(@"using key from %s", keyfile.c_str());
NSString* cwd = [NSFileManager defaultManager].currentDirectoryPath;
NSString* dir = @"/tmp";
[[NSFileManager defaultManager] changeCurrentDirectoryPath:dir];
std::string _filename;
pEp::notifyRead_t notifyRead = [=]()->void{
NSLog(@"downloading: %@", name);
if (_subscriber) {
[_subscriber notifyDownload:(int)downloading withName:name withFilename:@""];
}
};
try {
_filename = pEp::UpdateClient::update(p, keyfile, notifyRead);
if (_filename.length()) {
NSString* filename = [NSString stringWithUTF8String:_filename.c_str()];
NSString* download = [NSString stringWithFormat:@"%@/%@", dir, filename];
[[NSFileManager defaultManager] changeCurrentDirectoryPath:cwd];
NSLog(@"download arrived %@", download);
if (_subscriber) {
[_subscriber notifyDownload:(int)downloadArrived withName:name withFilename:download];
}
}
else {
NSLog(@"no download available for %@", name);
if (_subscriber) {
[_subscriber notifyDownload:(int)noDownloadAvailable withName:name withFilename:@""];
}
}
}
catch (std::exception& e) {
NSLog(@"pEp::UpdateClient::update({\"%s\", \"%s\"}, \"%s\"): %s",
p.name.c_str(), p.url.c_str(), keyfile.c_str(), e.what());
}
}
@end

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

@ -1,19 +0,0 @@
//
// 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

+ 0
- 67
pEpMacOSAdapter/PEPUpdateDownloadXPCService/XPCService/PEPUpdateDownloadXPCApi.m View File

@ -1,67 +0,0 @@
//
// PEPUpdateDownloadXPCApi.m
// foundation.pEp.adapter.macOS
//
// Created by David Alarcon on 9/2/21.
// Copyright © 2021 pp foundation. All rights reserved.
//
#import "PEPUpdateDownloadXPCApi.h"
#import "PEPNotificationXPCApiProtocol.h"
#import "PEPUpdateDownloader.h"
extern PEPUpdateDownloader* updater;
@implementation PEPUpdateDownloadXPCApi
- (void)subscribeForUpdate:(NSXPCListenerEndpoint*)endpoint {
NSLog(@"subscribeForUpdate called");
if (!updater) {
updater = [PEPUpdateDownloader new];
}
///NotificationXPCService *service = ....
///[service start];
if (updater) {
_clientConnection = [[NSXPCConnection alloc] initWithListenerEndpoint:endpoint];
_clientConnection.remoteObjectInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(PEPNotificationXPCApiProtocol)];
_clientConnection.interruptionHandler = ^(){NSLog(@"interruption"); updater.subscriber=nil;};
_clientConnection.invalidationHandler = ^(){NSLog(@"invalidation"); updater.subscriber=nil;};
[_clientConnection resume];
PEPNotification* downloadNotification = [_clientConnection remoteObjectProxyWithErrorHandler:^(NSError*err) {
NSLog(@"%@", err);
}];
updater.subscriber = downloadNotification;
if (downloadNotification) {
[downloadNotification notifyDownload:ready withName:@"" withFilename:@""];
}
}
}
- (void)unsubscribeForUpdate {
NSLog(@"unsubscribeForUpdate called");
if (updater) updater.subscriber = nil;
}
- (void)updateNow {
NSLog(@"updateNow called");
if (updater) [updater updateAll];
}
- (void)scheduleUpdates {
NSLog(@"scheduleUpdates called");
if (updater) [updater scheduleUpdates];
}
- (void)stopUpdates {
NSLog(@"stopUpdates called");
if (updater) [updater stopUpdates];
}
@end

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

@ -1,20 +0,0 @@
//
// 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

+ 1
- 20
pEpMacOSAdapter/main.m View File

@ -9,23 +9,8 @@
@import Foundation;
#import "PEPObjcAdapterXPCService.h"
#import "PEPObjCAdapterXPCService.h"
#include <signal.h>
#import "PEPUpdateDownloader.h"
PEPUpdateDownloader* updater = nil;
@interface ServiceDelegate : NSObject <NSXPCListenerDelegate>
@end
@implementation ServiceDelegate
- (id)init{
self = [super init];
return self;
}
@end
void signal_TERM(int signal)
{
@ -36,10 +21,6 @@ void signal_TERM(int signal)
int main(int argc, const char *argv[])
{
signal(SIGTERM, signal_TERM);
updater = [PEPUpdateDownloader new];
// Create the delegate for the service.
ServiceDelegate *delegate = [ServiceDelegate new];
// Create an instance of the PEP ObjC wrapper Adapter and start it
PEPObjCAdapterXPCService *adapter = [[PEPObjCAdapterXPCService alloc] init];


Loading…
Cancel
Save