Browse Source

connect to XPC service

works_for_me
Volker Birk 2 years ago
parent
commit
48b8702798
2 changed files with 25 additions and 1 deletions
  1. +4
    -0
      README.md
  2. +21
    -1
      pEpNotifications/pEpNotifications/AppDelegate.swift

+ 4
- 0
README.md View File

@ -14,3 +14,7 @@ This adapter will sport three main features:
## Build
- set Header Search Paths and Library Search Paths to include and use Boost static libraries
## Implementation
There's currently only one subscriber supported.

+ 21
- 1
pEpNotifications/pEpNotifications/AppDelegate.swift View File

@ -10,22 +10,42 @@
import Cocoa
import SwiftUI
typealias DownloadArrived = (_: NSString) -> Void
@objc(pEpMacOSAdapterProtocol) protocol pEpMacOSAdapterProtocol {
/*
- (void)subscribeForUpdate:(void (^)(NSString *))downloadArrived;
- (void)unsubscribeForUpdate;
*/
func subscribeForUpdate(downloadArrived: DownloadArrived)
func unsubscribeForUpdate()
}
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var statusBarItem: NSStatusItem!
var statusText: NSMenuItem!
var connection: NSXPCConnection!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let statusBar = NSStatusBar.system
// configure Menu Item Extra
statusBarItem = statusBar.statusItem(withLength: NSStatusItem.squareLength)
statusBarItem.button?.title = "p≡p"
statusBarItem.menu = NSApp.menu?.item(at: 0)?.submenu
statusText = NSApp.menu?.item(at: 0)?.submenu?.item(at: 0)
// connect to XPC service
connection = NSXPCConnection.init(serviceName: "pEp.foundation.pEpMacOSAdapter")
connection.remoteObjectInterface = NSXPCInterface.init(with: pEpMacOSAdapterProtocol.self)
connection.resume()
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
connection.invalidate()
}
}

Loading…
Cancel
Save