Browse Source

APPLEMAIL-33 Add PEPUpdateDownloadApiClientService to PEPUpdatesApp. Create enpoint property in PEPNotificationXPCService.

APPLEMAIL-33
David Alarcon 3 months ago
parent
commit
a9403e9f86
4 changed files with 17 additions and 16 deletions
  1. +2
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/Interface/PEPNotificationXPCService.h
  2. +1
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPNotificationXPCService/PEPNotificationXPCService/XPCService/PEPNotificationXPCService.m
  3. +1
    -0
      Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCApiClient/XPCService/PEPUpdateDownloadApiClientService.m
  4. +13
    -16
      Submodules/pEpNotifications/PEPUpdatesApp/AppDelegate.swift

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

@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface PEPNotificationXPCService : NSObject <NSXPCListenerDelegate>
@property (nonatomic) NSXPCListenerEndpoint *notificationEndpoint;
- (instancetype)initWithDelegate:(id<PEPNotificationXPCServiceDelegate>)delegate;
/// Begin listening for incoming XPC connections
- (void)start;


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

@ -25,6 +25,7 @@
NSLog(@"starting agent");
_listener.delegate = self;
_delegate = delegate;
_notificationEndpoint = _listener.endpoint;
}
return self;


+ 1
- 0
Submodules/PEPUpdatesXPCService/PEPUpdatesXPCService/PEPUpdateDownloadXPCService/PEPUpdateDownloadXPCApiClient/XPCService/PEPUpdateDownloadApiClientService.m View File

@ -19,6 +19,7 @@
}
- (void)stop {
[self.connection invalidate];
self.connection = nil;
}


+ 13
- 16
Submodules/pEpNotifications/PEPUpdatesApp/AppDelegate.swift View File

@ -35,8 +35,7 @@ class AppDelegate: NSObject {
// MARK: - Properties
private var statusBarItem: NSStatusItem? = nil
private lazy var connection: NSXPCConnection = NSXPCConnection.init(machServiceName: "foundation.pEp.adapter.macOS_OpenStep")
private var service: PEPMacOSAdapterProtocol?
private lazy var updateDownloadService = PEPUpdateDownloadApiClientService()
private var nc = NSUserNotificationCenter.default
private lazy var clientListener: NSXPCListener = NSXPCListener.anonymous()
private var receiver: PEPNotification?
@ -50,11 +49,11 @@ class AppDelegate: NSObject {
if sender.state == NSControl.StateValue.on {
sender.state = NSControl.StateValue.off
UserDefaults.standard.set(false, forKey: "ScheduleUpdates")
service?.stopUpdates()
updateDownloadService.stopUpdates()
} else {
sender.state = NSControl.StateValue.on
UserDefaults.standard.set(true, forKey: "ScheduleUpdates")
service?.scheduleUpdates()
updateDownloadService.scheduleUpdates()
}
}
@ -100,7 +99,7 @@ extension AppDelegate {
@objc
private func updateNow() {
nc.removeAllDeliveredNotifications()
service?.updateNow()
updateDownloadService.updateNow()
}
private func setupAppDefaults() {
@ -114,10 +113,8 @@ extension AppDelegate {
}
}
private func initXPCConnection() {
connection.remoteObjectInterface = NSXPCInterface.init(with: PEPMacOSAdapterProtocol.self)
connection.resume()
service = connection.remoteObjectProxyWithErrorHandler(proxyErrorHandler) as? PEPMacOSAdapterProtocol
private func initUpdateDownloadXPCConnection() {
updateDownloadService.start()
}
private func initClientService() {
@ -126,13 +123,13 @@ extension AppDelegate {
}
private func setupServiceSubscription() {
service?.subscribeForUpdate(clientListener.endpoint)
updateDownloadService.subscribe(forUpdate:clientListener.endpoint)
if UserDefaults.standard.bool(forKey: "ScheduleUpdates") {
service?.scheduleUpdates()
updateDownloadService.scheduleUpdates()
scheduleUpdatesMenuItem.state = NSControl.StateValue.on
}
else {
service?.stopUpdates()
updateDownloadService.stopUpdates()
scheduleUpdatesMenuItem.state = NSControl.StateValue.off
}
}
@ -259,7 +256,7 @@ extension AppDelegate: NSApplicationDelegate {
downloadStateNotifier.notify(.Connecting)
// connect to XPC service
initXPCConnection()
initUpdateDownloadXPCConnection()
// init client callback service
initClientService()
@ -267,14 +264,14 @@ extension AppDelegate: NSApplicationDelegate {
// subscribe and schedule updates
setupServiceSubscription()
service?.updateNow()
updateDownloadService.updateNow()
initNotificationCenter()
}
func applicationWillTerminate(_ aNotification: Notification) {
service?.unsubscribeForUpdate()
connection.invalidate()
updateDownloadService.unsubscribeForUpdate()
updateDownloadService.stop()
}
}


Loading…
Cancel
Save