pEp macOS Desktop adapter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.8 KiB

//
// 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