// // pEpMacOSAdapter.m // pEpMacOSAdapter // // Created by Volker Birk on 20.04.20. // Copyleft © 2020 p≡p foundation. // This file is under GNU General Public License 3.0 // #import "pEpMacOSAdapter.h" #import "pEpUpdater.h" extern pEpUpdater* updater; @implementation pEpMacOSAdapter // begin PEPMacOSAdapterProtocol - (void)subscribeForUpdate:(NSXPCListenerEndpoint*)endpoint { NSLog(@"subscribeForUpdate called"); if (!updater) { updater = [pEpUpdater new]; } if (updater) { _clientConnection = [[NSXPCConnection alloc] initWithListenerEndpoint:endpoint]; _clientConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PEPNotificationProtocol)]; _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:nil]; } - (void)scheduleUpdates { NSLog(@"scheduleUpdates called"); if (updater) [updater scheduleUpdates]; } - (void)stopUpdates { NSLog(@"stopUpdates called"); if (updater) [updater stopUpdates]; } // end PEPMacOSAdapterProtocol @end