Browse Source

docu

works_for_me
Volker Birk 2 years ago
parent
commit
63daf7e392
6 changed files with 53 additions and 25 deletions
  1. +15
    -1
      README.md
  2. +1
    -0
      pEpMacOSAdapter/Subscriber.h
  3. +7
    -0
      pEpMacOSAdapter/pEpMacOSAdapter.m
  4. +11
    -20
      pEpMacOSAdapter/pEpMacOSAdapterProtocol.h
  5. +17
    -0
      pEpMacOSAdapter/pEpUpdater.h
  6. +2
    -4
      pEpNotifications/pEpNotifications/AppDelegate.swift

+ 15
- 1
README.md View File

@ -17,4 +17,18 @@ This adapter will sport three main features:
## Implementation
There's currently only one subscriber supported.
The implementation is split in to parts:
1. the working code is in pEpMacOSAdapter
1. the User Interface is in pEpNotifications
### pEpMacOSAdapterProtocol, implemented with XPC
@protocol pEpMacOSAdapterProtocol
- (void)subscribeForUpdate:(void (^)(NSString *))downloadArrived;
- (void)unsubscribeForUpdate;
- (void)updateNow;
@end
This protocol is provided to the User Interface to get informed when a download was happening.
When a subscription is active updateNow() can be used to search for immediate updates.

+ 1
- 0
pEpMacOSAdapter/Subscriber.h View File

@ -7,5 +7,6 @@
// This file is under GNU General Public License 3.0
//
/// make a type out of pEpMacOSAdapterSubscriberProtocol
@interface Subscriber : NSObject<pEpMacOSAdapterSubscriberProtocol>
@end

+ 7
- 0
pEpMacOSAdapter/pEpMacOSAdapter.m View File

@ -37,6 +37,13 @@ void (^_downloadArrived)(NSString *) = nil;
_downloadArrived = nil;
}
- (void)updateNow
{
if (_updater) {
[_updater updateAll:nil];
}
}
// end pEpMacOSAdapterProtocol
// begin pEpMacOSAdapterSubscriberProtocol


+ 11
- 20
pEpMacOSAdapter/pEpMacOSAdapterProtocol.h View File

@ -9,29 +9,20 @@
#import <Foundation/Foundation.h>
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
/// This protocol is providing the XPC interface to the User Interface program pEpNotifications
@protocol pEpMacOSAdapterProtocol
- (void)subscribeForUpdate:(void (^)(NSString *))downloadArrived;
- (void)unsubscribeForUpdate;
@end
/*
To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this:
/**
subscribe to the published notifications about downloads arriving
_connectionToService = [[NSXPCConnection alloc] initWithServiceName:@"pEp.foundation.pEpMacOSAdapter"];
_connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(pEpMacOSAdapterProtocol)];
[_connectionToService resume];
Once you have a connection to the service, you can use it like this:
- Parameter downloadArrived: block to call back when a download arrived
*/
- (void)subscribeForUpdate:(void (^)(NSString *))downloadArrived;
[[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) {
// We have received a response. Update our text field, but do it on the main thread.
NSLog(@"Result string was: %@", aString);
}];
/// unsubscribe from receiving notifications about downloads arriving
- (void)unsubscribeForUpdate;
And, when you are finished with the service, clean up the connection like this:
/// search for immediate updates
- (void)updateNow;
[_connectionToService invalidate];
*/
@end

+ 17
- 0
pEpMacOSAdapter/pEpUpdater.h View File

@ -11,16 +11,33 @@
#import "pEpMacOSAdapterSubscriberProtocol.h"
#import "Subscriber.h"
/// object encapsulating the update client functionality of downloadclient
@interface pEpUpdater : NSObject
/// default 2 hours = 7200 seconds
@property double cycle;
/// path with config files
@property NSString* configPath;
/// initializes the pEpUpdater
///
/// - parameter subscriber: object fulfilling the `pEpMacOSAdapterSubscriberProtocol`.
- (id)initWithSubscriber:(Subscriber*)subscriber;
/// switches the subscriber
- (void)setNewSubscriber:(Subscriber*)subscriber;
/// schedules updates each 2 hours
- (void)scheduleUpdates;
/// update all configured software
- (void)updateAll:(NSTimer*)timer;
/// update software described by config file
- (void)updateWithFile:(NSString*)configFile;
/// update a product from URL of update server
- (void)update:(NSString*)name usingUrl:(NSString*)url;
@end

+ 2
- 4
pEpNotifications/pEpNotifications/AppDelegate.swift View File

@ -13,12 +13,9 @@ import SwiftUI
typealias DownloadArrived = (_: NSString) -> Void
@objc(pEpMacOSAdapterProtocol) protocol pEpMacOSAdapterProtocol {
/*
- (void)subscribeForUpdate:(void (^)(NSString *))downloadArrived;
- (void)unsubscribeForUpdate;
*/
func subscribeForUpdate(downloadArrived: @escaping DownloadArrived)
func unsubscribeForUpdate()
func updateNow()
}
@NSApplicationMain
@ -36,6 +33,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
@objc func updateNow() {
proxy?.updateNow()
NSLog("pEpNotifications: %@", "update fired")
}


Loading…
Cancel
Save