Browse Source

closure

works_for_me
Volker Birk 2 years ago
parent
commit
39a26a1ee4
7 changed files with 33 additions and 9 deletions
  1. +2
    -0
      pEpMacOSAdapter.xcodeproj/project.pbxproj
  2. +1
    -1
      pEpMacOSAdapter/Subscriber.h
  3. +3
    -3
      pEpMacOSAdapter/pEpUpdater.mm
  4. +4
    -0
      pEpNotifications/pEpNotifications.xcodeproj/project.pbxproj
  5. +4
    -4
      pEpNotifications/pEpNotifications/AppDelegate.swift
  6. +18
    -0
      pEpNotifications/pEpNotifications/Notification.swift
  7. +1
    -1
      pEpUpdater Test/pEpUpdater_Test.m

+ 2
- 0
pEpMacOSAdapter.xcodeproj/project.pbxproj View File

@ -497,6 +497,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 99R5U9VEWH;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Users/vb/dev/boost_1_72_0,
@ -524,6 +525,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 99R5U9VEWH;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Users/vb/dev/boost_1_72_0,


+ 1
- 1
pEpMacOSAdapter/Subscriber.h View File

@ -10,4 +10,4 @@
#pragma once
enum DNType { downloading, downloadArrived, noDownloadAvailable };
typedef void (^DownloadNotification)(enum DNType, NSString *);
typedef void (^DownloadNotification)(enum DNType, NSString *, NSString*);

+ 3
- 3
pEpMacOSAdapter/pEpUpdater.mm View File

@ -90,7 +90,7 @@ DownloadNotification _subscriber = nil;
pEp::notifyRead_t notifyRead = nullptr;
if (_subscriber) {
notifyRead = []() { _subscriber(downloading, nil); };
notifyRead = [=]() { _subscriber(downloading, name, nil); };
}
_filename = pEp::UpdateClient::update(p, keyfile, notifyRead);
if (_filename.length()) {
@ -101,12 +101,12 @@ DownloadNotification _subscriber = nil;
NSLog(@"pEpMacOSAdapter: download arrived %@", download);
if (_subscriber) {
_subscriber(downloadArrived, download);
_subscriber(downloadArrived, name, download);
}
}
else {
if (_subscriber) {
_subscriber(noDownloadAvailable, nil);
_subscriber(noDownloadAvailable, nil, nil);
}
}
}


+ 4
- 0
pEpNotifications/pEpNotifications.xcodeproj/project.pbxproj View File

@ -12,6 +12,7 @@
3527B2B924802F87007A6276 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3527B2B824802F87007A6276 /* Preview Assets.xcassets */; };
3527B2C824802F87007A6276 /* pEpNotificationsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3527B2C724802F87007A6276 /* pEpNotificationsTests.swift */; };
3527B2D324802F87007A6276 /* pEpNotificationsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3527B2D224802F87007A6276 /* pEpNotificationsUITests.swift */; };
356BD4BD2486A90E007CFAFE /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356BD4BC2486A90E007CFAFE /* Notification.swift */; };
3594303F2483011000DCBD65 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3594303D2483011000DCBD65 /* Main.storyboard */; };
359430482483264F00DCBD65 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3594304A2483264F00DCBD65 /* Localizable.strings */; };
/* End PBXBuildFile section */
@ -46,6 +47,7 @@
3527B2CE24802F87007A6276 /* pEpNotificationsUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = pEpNotificationsUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3527B2D224802F87007A6276 /* pEpNotificationsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = pEpNotificationsUITests.swift; sourceTree = "<group>"; };
3527B2D424802F87007A6276 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
356BD4BC2486A90E007CFAFE /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = "<group>"; };
3594303E2483011000DCBD65 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
359430432483081B00DCBD65 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
35943044248309BE00DCBD65 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = "<group>"; };
@ -104,6 +106,7 @@
3594304A2483264F00DCBD65 /* Localizable.strings */,
3594303D2483011000DCBD65 /* Main.storyboard */,
3527B2B124802F84007A6276 /* AppDelegate.swift */,
356BD4BC2486A90E007CFAFE /* Notification.swift */,
3527B2B524802F87007A6276 /* Assets.xcassets */,
3527B2BD24802F87007A6276 /* Info.plist */,
3527B2BE24802F87007A6276 /* pEpNotifications.entitlements */,
@ -271,6 +274,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
356BD4BD2486A90E007CFAFE /* Notification.swift in Sources */,
3527B2B224802F84007A6276 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;


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

@ -11,7 +11,7 @@ import Cocoa
import SwiftUI
@objc enum DNType : Int { case downloading, downloadArrived, noDownloadAvailable }
typealias DownloadNotification = (_: DNType, NSString) -> Void
typealias DownloadNotification = (_: DNType, NSString, NSString) -> Void
@objc(pEpMacOSAdapterProtocol) protocol pEpMacOSAdapterProtocol {
func subscribeForUpdate(downloadNotification: @escaping DownloadNotification)
@ -28,7 +28,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var connection: NSXPCConnection!
var proxy: pEpMacOSAdapterProtocol!
func notifyDownload(notification: DNType, download: NSString)
func notifyDownload(notification: DNType, name: NSString, download: NSString)
{
switch notification {
case .downloading:
@ -45,7 +45,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSLog("pEpNotifications: %@", "update fired")
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
private func applicationDidFinishLaunching(_ aNotification: Notification) {
let statusBar = NSStatusBar.system
// configure Menu Item Extra
@ -73,7 +73,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
func applicationWillTerminate(_ aNotification: Notification) {
private func applicationWillTerminate(_ aNotification: Notification) {
proxy?.unsubscribeForUpdate()
connection?.invalidate()
}


+ 18
- 0
pEpNotifications/pEpNotifications/Notification.swift View File

@ -0,0 +1,18 @@
//
// Notification.swift
// pEpNotifications
//
// Created by Volker Birk on 02.06.20.
// Copyright © 2020 pp foundation. All rights reserved.
//
import Foundation
class Notification {
var nc = NSUserNotificationCenter.default
func downloadAvailable(name: String, path: String) {
}
}

+ 1
- 1
pEpUpdater Test/pEpUpdater_Test.m View File

@ -22,7 +22,7 @@ XCTestExpectation* downloadingExpectation;
- (void)setUp {
downloadingExpectation = [XCTestExpectation alloc];
updater = [[pEpUpdater alloc] initWithSubscriber:^(enum DNType notification, NSString *download) { NSLog(@"notification: %d %@", notification, download); [downloadingExpectation fulfill]; }];
updater = [[pEpUpdater alloc] initWithSubscriber:^(enum DNType notification, NSString* name, NSString* download) { NSLog(@"notification: %d %@", notification, download); [downloadingExpectation fulfill]; }];
NSString *path = [[NSBundle bundleForClass:[pEpUpdater_Test class]] pathForResource:@"test.der" ofType:nil];
updater.configPath = [path stringByDeletingLastPathComponent];


Loading…
Cancel
Save