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.
pEpMacOSAdapter/pEpMacOSAdapter/pEpMacOSAdapter.m

74 lines
1.8 KiB

3 years ago
//
// pEpMacOSAdapter.m
// pEpMacOSAdapter
//
// Created by Volker Birk on 20.04.20.
// Copyleft © 2020 pp foundation.
// This file is under GNU General Public License 3.0
//
#import "pEpMacOSAdapter.h"
3 years ago
#import "pEpUpdater.h"
extern pEpUpdater* updater;
3 years ago
@implementation pEpMacOSAdapter
// begin PEPMacOSAdapterProtocol
3 years ago
3 years ago
- (void)subscribeForUpdate:(NSXPCListenerEndpoint*)endpoint
{
NSLog(@"subscribeForUpdate called");
if (!updater) {
updater = [pEpUpdater new];
}
3 years ago
if (updater) {
_clientConnection = [[NSXPCConnection alloc] initWithListenerEndpoint:endpoint];
_clientConnection.remoteObjectInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(PEPNotificationProtocol)];
3 years ago
_clientConnection.interruptionHandler = ^(){NSLog(@"interruption"); updater.subscriber=nil;};
_clientConnection.invalidationHandler = ^(){NSLog(@"invalidation"); updater.subscriber=nil;};
[_clientConnection resume];
PEPNotification* downloadNotification = [_clientConnection remoteObjectProxyWithErrorHandler:^(NSError*err) {
3 years ago
NSLog(@"%@", err);
}];
updater.subscriber = downloadNotification;
if (downloadNotification) {
[downloadNotification notifyDownload:ready withName:@"" withFilename:@""];
}
3 years ago
}
}
- (void)unsubscribeForUpdate
{
NSLog(@"unsubscribeForUpdate called");
3 years ago
if (updater) updater.subscriber = nil;
}
3 years ago
- (void)updateNow
{
NSLog(@"updateNow called");
3 years ago
if (updater) [updater updateAll:nil];
3 years ago
}
- (void)scheduleUpdates
{
NSLog(@"scheduleUpdates called");
if (updater) [updater scheduleUpdates];
}
- (void)stopUpdates
{
NSLog(@"stopUpdates called");
if (updater) [updater stopUpdates];
}
// end PEPMacOSAdapterProtocol
3 years ago
3 years ago
@end