From 401cac4cf936f16cd9a25eac62b8c497a95578ae Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Tue, 3 Jul 2018 21:34:42 +0200 Subject: [PATCH 1/9] syncthing/STApplication.m: Sort folders submenu ascending (fixes #49) --- syncthing/STApplication.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 8b41f13..45f3b8c 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -163,7 +163,13 @@ - (IBAction) clickedOpen:(id)sender { - (void) updateFoldersMenu:(NSMenu *)menu { [menu removeAllItems]; - for (id dir in [self.syncthing getFolders]) { + // Get folders from syncthing and sort ascending + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"label" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + return [(NSString *)obj1 compare:(NSString *)obj2 options:NSNumericSearch]; + }]; + NSArray *folders = [[self.syncthing getFolders] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]]; + + for (id dir in folders) { NSString *name = [dir objectForKey:@"label"]; if ([name length] == 0) name = [dir objectForKey:@"id"]; From 74fc8a66c399dc7fc54c220b5e1726475c863baf Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Tue, 3 Jul 2018 22:38:49 +0200 Subject: [PATCH 2/9] Initial work which fixes #52 --- syncthing/Info.plist | 2 ++ syncthing/STApplication.m | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/syncthing/Info.plist b/syncthing/Info.plist index a11ed55..a6b1351 100644 --- a/syncthing/Info.plist +++ b/syncthing/Info.plist @@ -47,6 +47,8 @@ https://xor-gate.github.io/syncthing-macosx/appcast.xml SUScheduledCheckInterval 86400 + NSUserNotificationAlertStyle + alert CFBundleGetInfoString syncthing project Group diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 45f3b8c..6f18aff 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -16,6 +16,8 @@ @interface STAppDelegate () @implementation STAppDelegate - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { + [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; + _syncthing = [[XGSyncthing alloc] init]; [self applicationLoadConfiguration]; @@ -25,6 +27,28 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { _statusMonitor.syncthing = _syncthing; _statusMonitor.delegate = self; [_statusMonitor startMonitoring]; + + NSUserNotification *n = [[NSUserNotification alloc] init]; + n.title = @"Syncthing"; + n.informativeText = @"Add folder NewFolder"; + n.hasActionButton = true; + n.actionButtonTitle = @"Accept"; + n.otherButtonTitle = @"Decline"; + // XXX: Seems undocumented API hack or else the buttons are not shown + [n setValue:@YES forKey:@"_showsButtons"]; + + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; +} + +- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{ + return YES; +} + +- (void) userNotificationCenter:(NSUserNotificationCenter *)center + didActivateNotification:(NSUserNotification *)notification +{ + + NSLog(@"geklikt"); } - (void) clickedFolder:(id)sender { @@ -125,9 +149,7 @@ - (void) syncMonitorStatusChanged:(SyncthingStatus)status { } - (void) syncMonitorEventReceived:(NSDictionary *)event { - NSNumber *eventId = [event objectForKey:@"id"]; NSString *eventType = [event objectForKey:@"type"]; - NSDictionary *eventData = [event objectForKey:@"data"]; if ([eventType isEqualToString:@"ConfigSaved"]) { [self refreshDevices]; From 9e8d6fec23a7fe3c1f1d38ddcf9a007447073550 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Tue, 3 Jul 2018 22:45:43 +0200 Subject: [PATCH 3/9] doc/xcode.md: Add xcode tips and tricks --- doc/xcode.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/xcode.md diff --git a/doc/xcode.md b/doc/xcode.md new file mode 100644 index 0000000..30e06f0 --- /dev/null +++ b/doc/xcode.md @@ -0,0 +1,13 @@ +# XCode tips and tricks + +## xcodebuild requires Xcode + +``` +xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance +``` + +fixed with + +``` +sudo xcode-select -s /Applications/Xcode.app/Contents/Developer +``` From f22d2c3169db73bf5481632492b452c0da30e6e0 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 4 Jul 2018 00:12:51 +0200 Subject: [PATCH 4/9] Initial working event to notification translation --- syncthing/STApplication.m | 14 +------------- syncthing/STStatusMonitor.m | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 6f18aff..5f2981e 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -27,17 +27,6 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { _statusMonitor.syncthing = _syncthing; _statusMonitor.delegate = self; [_statusMonitor startMonitoring]; - - NSUserNotification *n = [[NSUserNotification alloc] init]; - n.title = @"Syncthing"; - n.informativeText = @"Add folder NewFolder"; - n.hasActionButton = true; - n.actionButtonTitle = @"Accept"; - n.otherButtonTitle = @"Decline"; - // XXX: Seems undocumented API hack or else the buttons are not shown - [n setValue:@YES forKey:@"_showsButtons"]; - - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; } - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{ @@ -47,8 +36,7 @@ - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentN - (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification { - - NSLog(@"geklikt"); + NSDictionary *ui = notification.userInfo; } - (void) clickedFolder:(id)sender { diff --git a/syncthing/STStatusMonitor.m b/syncthing/STStatusMonitor.m index 73ab5f0..b5aaf1d 100644 --- a/syncthing/STStatusMonitor.m +++ b/syncthing/STStatusMonitor.m @@ -90,6 +90,30 @@ - (void) processEvent:(NSDictionary *)event { self.folderStates[folder] = newState; [self updateCurrentStatus]; + } else if ([eventType isEqualToString:@"FolderRejected"]) { + NSUserNotification *n = [[NSUserNotification alloc] init]; + n.title = @"Syncthing"; + n.informativeText = [NSString stringWithFormat:@"New folder %@", [eventData objectForKey:@"folderLabel"]]; + n.hasActionButton = true; + n.actionButtonTitle = @"Accept"; + n.otherButtonTitle = @"Decline"; + n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; + // XXX: Seems undocumented API hack or else the custom buttons are not shown + [n setValue:@YES forKey:@"_showsButtons"]; + + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; + } else if ([eventType isEqualToString:@"DeviceRejected"]) { + NSUserNotification *n = [[NSUserNotification alloc] init]; + n.title = @"Syncthing"; + n.informativeText = [NSString stringWithFormat:@"New device %@", [eventData objectForKey:@"name"]]; + n.hasActionButton = true; + n.actionButtonTitle = @"Accept"; + n.otherButtonTitle = @"Decline"; + n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; + // XXX: Seems undocumented API hack or else the custom buttons are not shown + [n setValue:@YES forKey:@"_showsButtons"]; + + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; } [self.delegate syncMonitorEventReceived:event]; } From 236a46f4d8143a19c11353f39f5fb28df6ba263d Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Fri, 13 Jul 2018 11:18:58 +0200 Subject: [PATCH 5/9] Silence stderr/stdout of NSTask, event type attach and poll for decline --- syncthing/STApplication.m | 27 +++++++++++++++++++++++++++ syncthing/STStatusMonitor.m | 2 ++ syncthing/XGSyncthing.m | 2 ++ 3 files changed, 31 insertions(+) diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 5f2981e..5048189 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -30,6 +30,32 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { } - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{ + NSLog(@"shouldPresent: %@", notification); + + // Taken from https://stackoverflow.com/questions/21110714/mac-os-x-nsusernotificationcenter-notification-get-dismiss-event-callback + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), + ^{ + BOOL notificationStillPresent; + do { + notificationStillPresent = NO; + for (NSUserNotification *nox in [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications]) { + if ([nox.identifier isEqualToString:notification.identifier]) notificationStillPresent = YES; + } + + if (notificationStillPresent) { + NSLog(@"still present %@", notification.identifier); + [NSThread sleepForTimeInterval:1.0f]; + } else { + NSLog(@"not present %@", notification.identifier); + } + } while (notificationStillPresent); + dispatch_async(dispatch_get_main_queue(), ^{ + NSLog(@"gone %@", notification.identifier); + //[self notificationHandlerForNotification:notification]; + }); + }); + + return YES; } @@ -37,6 +63,7 @@ - (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification { NSDictionary *ui = notification.userInfo; + NSLog(@"ui %@", ui); } - (void) clickedFolder:(id)sender { diff --git a/syncthing/STStatusMonitor.m b/syncthing/STStatusMonitor.m index b5aaf1d..2f613cb 100644 --- a/syncthing/STStatusMonitor.m +++ b/syncthing/STStatusMonitor.m @@ -97,6 +97,7 @@ - (void) processEvent:(NSDictionary *)event { n.hasActionButton = true; n.actionButtonTitle = @"Accept"; n.otherButtonTitle = @"Decline"; + n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; // XXX: Seems undocumented API hack or else the custom buttons are not shown [n setValue:@YES forKey:@"_showsButtons"]; @@ -109,6 +110,7 @@ - (void) processEvent:(NSDictionary *)event { n.hasActionButton = true; n.actionButtonTitle = @"Accept"; n.otherButtonTitle = @"Decline"; + n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; // XXX: Seems undocumented API hack or else the custom buttons are not shown [n setValue:@YES forKey:@"_showsButtons"]; diff --git a/syncthing/XGSyncthing.m b/syncthing/XGSyncthing.m index 2130a37..ccc24a0 100644 --- a/syncthing/XGSyncthing.m +++ b/syncthing/XGSyncthing.m @@ -20,6 +20,8 @@ - (bool) runExecutable [_StTask setLaunchPath:_Executable]; [_StTask setArguments:@[@"-no-browser"]]; + [_StTask setStandardOutput:NULL]; + [_StTask setStandardError:NULL]; [_StTask setQualityOfService:NSQualityOfServiceBackground]; [_StTask launch]; From 574218ec91bef2f39d5844dbadff998e71230261 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 18 Jul 2018 21:11:43 +0200 Subject: [PATCH 6/9] Cleanup some stuff --- syncthing.xcodeproj/project.pbxproj | 66 +---------------------------- syncthing/Tests/main.m | 22 ---------- xgsyncthing/main.m | 17 -------- 3 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 syncthing/Tests/main.m delete mode 100644 xgsyncthing/main.m diff --git a/syncthing.xcodeproj/project.pbxproj b/syncthing.xcodeproj/project.pbxproj index 73fe1bc..1771cfe 100644 --- a/syncthing.xcodeproj/project.pbxproj +++ b/syncthing.xcodeproj/project.pbxproj @@ -26,10 +26,8 @@ C4460A801D0DD2D500200C21 /* STPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4460A7D1D0DD2D500200C21 /* STPreferencesWindowController.m */; }; C4460A811D0DD2D500200C21 /* STStatusBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4460A7F1D0DD2D500200C21 /* STStatusBarController.m */; }; C4460A831D0DD38F00200C21 /* STPreferencesWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4460A821D0DD38F00200C21 /* STPreferencesWindowController.xib */; }; - C4576BE41D11E43C0031BCFD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C4576BE31D11E43C0031BCFD /* main.m */; }; C4576BE61D11E79F0031BCFD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE51D11E79F0031BCFD /* Foundation.framework */; }; C4576BEA1D11E7E10031BCFD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE91D11E7E10031BCFD /* CoreFoundation.framework */; }; - C4576BEB1D11E9280031BCFD /* XGSyncthing.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */; }; C47F6C3A1D0DE68D00F36CF6 /* syncthing.icns in Resources */ = {isa = PBXBuildFile; fileRef = C47F6C391D0DE68D00F36CF6 /* syncthing.icns */; }; C48B83B61DA444BC0052A172 /* STConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = C48B83B51DA444BC0052A172 /* STConfiguration.m */; }; C4946B011D5877F2008447A2 /* STAboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4946B001D5877F2008447A2 /* STAboutWindowController.xib */; }; @@ -97,9 +95,6 @@ C4460A7F1D0DD2D500200C21 /* STStatusBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STStatusBarController.m; path = Controllers/STStatusBarController.m; sourceTree = ""; }; C4460A821D0DD38F00200C21 /* STPreferencesWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesWindowController.xib; path = UI/STPreferencesWindowController.xib; sourceTree = ""; }; C4576BD51D11E3210031BCFD /* create-dmg.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "create-dmg.sh"; path = "syncthing/Scripts/create-dmg.sh"; sourceTree = ""; }; - C4576BDB1D11E3BB0031BCFD /* xgsyncthing */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = xgsyncthing; sourceTree = BUILT_PRODUCTS_DIR; }; - C4576BDD1D11E3BB0031BCFD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - C4576BE31D11E43C0031BCFD /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = syncthing/Tests/main.m; sourceTree = ""; }; C4576BE51D11E79F0031BCFD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; C4576BE71D11E7C00031BCFD /* libobjc.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libobjc.tbd; path = usr/lib/libobjc.tbd; sourceTree = SDKROOT; }; C4576BE91D11E7E10031BCFD /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; @@ -180,22 +175,6 @@ name = Docs; sourceTree = ""; }; - C4576BDC1D11E3BB0031BCFD /* xgsyncthing */ = { - isa = PBXGroup; - children = ( - C4576BDD1D11E3BB0031BCFD /* main.m */, - ); - path = xgsyncthing; - sourceTree = ""; - }; - C4576BE21D11E40E0031BCFD /* Test */ = { - isa = PBXGroup; - children = ( - C4576BE31D11E43C0031BCFD /* main.m */, - ); - name = Test; - sourceTree = ""; - }; C46261361D578DA800B16BC6 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -244,6 +223,8 @@ C4A415641D0D579D00DC6018 /* STApplication.m */, C4D567A11D3A8DFE002AD881 /* STLoginItem.m */, C4D567A31D3A8E34002AD881 /* STLoginItem.h */, + C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */, + C4FFB0631D0D7E440015D14A /* XGSyncthing.h */, C48B83B41DA444BC0052A172 /* STConfiguration.h */, C48B83B51DA444BC0052A172 /* STConfiguration.m */, 0BE9B8881F050E93002883E2 /* STStatusMonitor.h */, @@ -259,9 +240,7 @@ C4576BE71D11E7C00031BCFD /* libobjc.tbd */, C4D896141D0DF90E00D42F73 /* Scripts */, C4460A881D0DE58B00200C21 /* Docs */, - C4FFB0621D0D7E360015D14A /* Library */, C4A415621D0D579D00DC6018 /* Sources */, - C4576BDC1D11E3BB0031BCFD /* xgsyncthing */, C4A415611D0D579D00DC6018 /* Products */, 37B4D367252EC0BC94949322 /* Pods */, ); @@ -271,7 +250,6 @@ isa = PBXGroup; children = ( C4A415601D0D579D00DC6018 /* Syncthing.app */, - C4576BDB1D11E3BB0031BCFD /* xgsyncthing */, ); name = Products; sourceTree = ""; @@ -330,37 +308,9 @@ name = Scripts; sourceTree = ""; }; - C4FFB0621D0D7E360015D14A /* Library */ = { - isa = PBXGroup; - children = ( - C4576BE21D11E40E0031BCFD /* Test */, - C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */, - C4FFB0631D0D7E440015D14A /* XGSyncthing.h */, - ); - name = Library; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - C4576BDA1D11E3BB0031BCFD /* xgsyncthing */ = { - isa = PBXNativeTarget; - buildConfigurationList = C4576BDF1D11E3BB0031BCFD /* Build configuration list for PBXNativeTarget "xgsyncthing" */; - buildPhases = ( - 45CC8E0944A58A08F2F95479 /* [CP] Check Pods Manifest.lock */, - C4576BD71D11E3BB0031BCFD /* Sources */, - C4576BD81D11E3BB0031BCFD /* Frameworks */, - C4576BD91D11E3BB0031BCFD /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = xgsyncthing; - productName = xgsyncthing; - productReference = C4576BDB1D11E3BB0031BCFD /* xgsyncthing */; - productType = "com.apple.product-type.tool"; - }; C4A4155F1D0D579D00DC6018 /* syncthing */ = { isa = PBXNativeTarget; buildConfigurationList = C4A415711D0D579D00DC6018 /* Build configuration list for PBXNativeTarget "syncthing" */; @@ -419,7 +369,6 @@ projectRoot = ""; targets = ( C4A4155F1D0D579D00DC6018 /* syncthing */, - C4576BDA1D11E3BB0031BCFD /* xgsyncthing */, 0B9C6B051F144DF1009C68CA /* syncthing-dmg */, ); }; @@ -536,8 +485,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C4576BEB1D11E9280031BCFD /* XGSyncthing.m in Sources */, - C4576BE41D11E43C0031BCFD /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -772,15 +719,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - C4576BDF1D11E3BB0031BCFD /* Build configuration list for PBXNativeTarget "xgsyncthing" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C4576BE01D11E3BB0031BCFD /* Debug */, - C4576BE11D11E3BB0031BCFD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; C4A4155B1D0D579D00DC6018 /* Build configuration list for PBXProject "syncthing" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/syncthing/Tests/main.m b/syncthing/Tests/main.m deleted file mode 100644 index 5d04e4a..0000000 --- a/syncthing/Tests/main.m +++ /dev/null @@ -1,22 +0,0 @@ -#import -#import - -int main (int argc, const char * argv[]) -{ - XGSyncthing *st = [[XGSyncthing alloc] init]; - - [st setURI:@"http://localhost:8384"]; - [st setApiKey:@"83GgPHZcHFSi-GEj03mv8tEix6WUXW-K"]; - - if ([st ping]) - NSLog(@"Syncthing OK!"); - else - NSLog(@"Syncthing borken!"); - - /* Configured folder ids */ - for (id dir in [st getFolders]) { - NSLog(@"id: %@", [dir objectForKey:@"id"]); - } - - return 0; -} \ No newline at end of file diff --git a/xgsyncthing/main.m b/xgsyncthing/main.m deleted file mode 100644 index 2bfae70..0000000 --- a/xgsyncthing/main.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.m -// xgsyncthing -// -// Created by Jerry Jacobs on 15/06/16. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import - -int main(int argc, const char * argv[]) { - @autoreleasepool { - // insert code here... - NSLog(@"Hello, World!"); - } - return 0; -} From fa72719dc57db9da9821246198ad7710d1a34606 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 18 Jul 2018 21:43:34 +0200 Subject: [PATCH 7/9] Cleanup unused code --- syncthing.xcodeproj/project.pbxproj | 2 -- syncthing/STApplication.m | 45 ++--------------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/syncthing.xcodeproj/project.pbxproj b/syncthing.xcodeproj/project.pbxproj index 1771cfe..2de3940 100644 --- a/syncthing.xcodeproj/project.pbxproj +++ b/syncthing.xcodeproj/project.pbxproj @@ -667,7 +667,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", - "$(PROJECT_DIR)/3thparty/frameworks", ); INFOPLIST_FILE = syncthing/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; @@ -693,7 +692,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", - "$(PROJECT_DIR)/3thparty/frameworks", ); INFOPLIST_FILE = syncthing/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 617f6fc..0bdf8db 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -29,41 +29,14 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { [_statusMonitor startMonitoring]; } -- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{ - NSLog(@"shouldPresent: %@", notification); - - // Taken from https://stackoverflow.com/questions/21110714/mac-os-x-nsusernotificationcenter-notification-get-dismiss-event-callback - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - BOOL notificationStillPresent; - do { - notificationStillPresent = NO; - for (NSUserNotification *nox in [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications]) { - if ([nox.identifier isEqualToString:notification.identifier]) notificationStillPresent = YES; - } - - if (notificationStillPresent) { - NSLog(@"still present %@", notification.identifier); - [NSThread sleepForTimeInterval:1.0f]; - } else { - NSLog(@"not present %@", notification.identifier); - } - } while (notificationStillPresent); - dispatch_async(dispatch_get_main_queue(), ^{ - NSLog(@"gone %@", notification.identifier); - //[self notificationHandlerForNotification:notification]; - }); - }); - - - return YES; -} - - (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification { NSDictionary *ui = notification.userInfo; NSLog(@"ui %@", ui); + + [center removeDeliveredNotification:notification]; + notification = nil; } - (void) clickedFolder:(id)sender { @@ -71,10 +44,6 @@ - (void) clickedFolder:(id)sender { [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""]; } -- (void) applicationWillTerminate:(NSNotification *)aNotification { - // TODO: is this needed -> remove? -} - - (void) awakeFromNib { _statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; _statusItem.menu = _Menu; @@ -82,7 +51,6 @@ - (void) awakeFromNib { [self updateStatusIcon:@"StatusIconNotify"]; } -// TODO: move to STConfiguration class - (void)applicationLoadConfiguration { static int configLoadAttempt = 1; @@ -130,13 +98,6 @@ - (void)applicationLoadConfiguration { } } -- (void) sendNotification:(NSString *)text { - NSUserNotification *notification = [[NSUserNotification alloc] init]; - notification.title = @"Syncthing"; - notification.informativeText = text; - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; -} - - (void) updateStatusIcon:(NSString *)icon { _statusItem.button.image = [NSImage imageNamed:icon]; [_statusItem.button.image setTemplate:YES]; From c440c416f2b9ff49f45bfc9fa4d9f63a2e2a0443 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 18 Jul 2018 21:57:06 +0200 Subject: [PATCH 8/9] Remove more dead code --- syncthing.xcodeproj/project.pbxproj | 102 +-------------- .../STPreferencesWindowController.m | 116 ------------------ syncthing/STStatusMonitor.m | 4 - .../STPreferencesDevicesViewController.h | 13 -- .../STPreferencesDevicesViewController.m | 26 ---- .../STPreferencesDevicesViewController.xib | 31 ----- .../STPreferencesFoldersViewController.h | 13 -- .../STPreferencesFoldersViewController.m | 26 ---- .../STPreferencesFoldersViewController.xib | 31 ----- .../STPreferencesInfoViewController.h | 13 -- .../STPreferencesInfoViewController.m | 26 ---- .../STPreferencesInfoViewController.xib | 31 ----- 12 files changed, 1 insertion(+), 431 deletions(-) delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.h delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.m delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.xib delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.h delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.m delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.xib delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.h delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.m delete mode 100644 syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.xib diff --git a/syncthing.xcodeproj/project.pbxproj b/syncthing.xcodeproj/project.pbxproj index 2de3940..ddc901b 100644 --- a/syncthing.xcodeproj/project.pbxproj +++ b/syncthing.xcodeproj/project.pbxproj @@ -26,8 +26,6 @@ C4460A801D0DD2D500200C21 /* STPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4460A7D1D0DD2D500200C21 /* STPreferencesWindowController.m */; }; C4460A811D0DD2D500200C21 /* STStatusBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4460A7F1D0DD2D500200C21 /* STStatusBarController.m */; }; C4460A831D0DD38F00200C21 /* STPreferencesWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4460A821D0DD38F00200C21 /* STPreferencesWindowController.xib */; }; - C4576BE61D11E79F0031BCFD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE51D11E79F0031BCFD /* Foundation.framework */; }; - C4576BEA1D11E7E10031BCFD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE91D11E7E10031BCFD /* CoreFoundation.framework */; }; C47F6C3A1D0DE68D00F36CF6 /* syncthing.icns in Resources */ = {isa = PBXBuildFile; fileRef = C47F6C391D0DE68D00F36CF6 /* syncthing.icns */; }; C48B83B61DA444BC0052A172 /* STConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = C48B83B51DA444BC0052A172 /* STConfiguration.m */; }; C4946B011D5877F2008447A2 /* STAboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4946B001D5877F2008447A2 /* STAboutWindowController.xib */; }; @@ -38,15 +36,9 @@ C4A4156D1D0D579D00DC6018 /* STApplication.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4A4156B1D0D579D00DC6018 /* STApplication.xib */; }; C4D36D801DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4D36D7E1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m */; }; C4D36D811DA3D53F0061FD08 /* STPreferencesAdvancedViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4D36D7F1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.xib */; }; - C4D36D851DA3E2820061FD08 /* STPreferencesDevicesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4D36D831DA3E2820061FD08 /* STPreferencesDevicesViewController.m */; }; - C4D36D861DA3E2820061FD08 /* STPreferencesDevicesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4D36D841DA3E2820061FD08 /* STPreferencesDevicesViewController.xib */; }; C4D567A21D3A8DFE002AD881 /* STLoginItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C4D567A11D3A8DFE002AD881 /* STLoginItem.m */; }; C4F0E82E1DA1B9CF00435310 /* STPreferencesGeneralViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F0E82C1DA1B9CF00435310 /* STPreferencesGeneralViewController.m */; }; C4F0E82F1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E82D1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib */; }; - C4F0E8331DA1C7A800435310 /* STPreferencesFoldersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F0E8311DA1C7A800435310 /* STPreferencesFoldersViewController.m */; }; - C4F0E8341DA1C7A800435310 /* STPreferencesFoldersViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E8321DA1C7A800435310 /* STPreferencesFoldersViewController.xib */; }; - C4F0E8381DA1CB0900435310 /* STPreferencesInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F0E8361DA1CB0900435310 /* STPreferencesInfoViewController.m */; }; - C4F0E8391DA1CB0900435310 /* STPreferencesInfoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E8371DA1CB0900435310 /* STPreferencesInfoViewController.xib */; }; C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */; }; /* End PBXBuildFile section */ @@ -61,15 +53,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - C4576BD91D11E3BB0031BCFD /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; C462613D1D57944400B16BC6 /* Copy Files */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -114,9 +97,6 @@ C4D36D7D1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesAdvancedViewController.h; path = UI/STPreferencesWindow/STPreferencesAdvancedViewController.h; sourceTree = ""; }; C4D36D7E1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesAdvancedViewController.m; path = UI/STPreferencesWindow/STPreferencesAdvancedViewController.m; sourceTree = ""; }; C4D36D7F1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesAdvancedViewController.xib; path = UI/STPreferencesWindow/STPreferencesAdvancedViewController.xib; sourceTree = ""; }; - C4D36D821DA3E2820061FD08 /* STPreferencesDevicesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesDevicesViewController.h; path = UI/STPreferencesWindow/STPreferencesDevicesViewController.h; sourceTree = ""; }; - C4D36D831DA3E2820061FD08 /* STPreferencesDevicesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesDevicesViewController.m; path = UI/STPreferencesWindow/STPreferencesDevicesViewController.m; sourceTree = ""; }; - C4D36D841DA3E2820061FD08 /* STPreferencesDevicesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesDevicesViewController.xib; path = UI/STPreferencesWindow/STPreferencesDevicesViewController.xib; sourceTree = ""; }; C4D567A11D3A8DFE002AD881 /* STLoginItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STLoginItem.m; sourceTree = ""; }; C4D567A31D3A8E34002AD881 /* STLoginItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STLoginItem.h; sourceTree = ""; }; C4D6DD581D0D93D80024D20A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -124,27 +104,12 @@ C4F0E82B1DA1B9CF00435310 /* STPreferencesGeneralViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STPreferencesGeneralViewController.h; sourceTree = ""; }; C4F0E82C1DA1B9CF00435310 /* STPreferencesGeneralViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPreferencesGeneralViewController.m; sourceTree = ""; }; C4F0E82D1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = STPreferencesGeneralViewController.xib; sourceTree = ""; }; - C4F0E8301DA1C7A800435310 /* STPreferencesFoldersViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesFoldersViewController.h; path = UI/STPreferencesWindow/STPreferencesFoldersViewController.h; sourceTree = ""; }; - C4F0E8311DA1C7A800435310 /* STPreferencesFoldersViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesFoldersViewController.m; path = UI/STPreferencesWindow/STPreferencesFoldersViewController.m; sourceTree = ""; }; - C4F0E8321DA1C7A800435310 /* STPreferencesFoldersViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesFoldersViewController.xib; path = UI/STPreferencesWindow/STPreferencesFoldersViewController.xib; sourceTree = ""; }; - C4F0E8351DA1CB0900435310 /* STPreferencesInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesInfoViewController.h; path = UI/STPreferencesWindow/STPreferencesInfoViewController.h; sourceTree = ""; }; - C4F0E8361DA1CB0900435310 /* STPreferencesInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesInfoViewController.m; path = UI/STPreferencesWindow/STPreferencesInfoViewController.m; sourceTree = ""; }; - C4F0E8371DA1CB0900435310 /* STPreferencesInfoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesInfoViewController.xib; path = UI/STPreferencesWindow/STPreferencesInfoViewController.xib; sourceTree = ""; }; C4FFB0631D0D7E440015D14A /* XGSyncthing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XGSyncthing.h; path = syncthing/XGSyncthing.h; sourceTree = SOURCE_ROOT; }; C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XGSyncthing.m; path = syncthing/XGSyncthing.m; sourceTree = SOURCE_ROOT; }; FB3E4EE48CFC608AD4FBDE77 /* Pods-syncthing.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-syncthing.debug.xcconfig"; path = "Pods/Target Support Files/Pods-syncthing/Pods-syncthing.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - C4576BD81D11E3BB0031BCFD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C4576BEA1D11E7E10031BCFD /* CoreFoundation.framework in Frameworks */, - C4576BE61D11E79F0031BCFD /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; C4A4155D1D0D579D00DC6018 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -191,19 +156,9 @@ C4460A7D1D0DD2D500200C21 /* STPreferencesWindowController.m */, C4F0E82B1DA1B9CF00435310 /* STPreferencesGeneralViewController.h */, C4F0E82C1DA1B9CF00435310 /* STPreferencesGeneralViewController.m */, - C4F0E82D1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib */, - C4F0E8301DA1C7A800435310 /* STPreferencesFoldersViewController.h */, - C4F0E8311DA1C7A800435310 /* STPreferencesFoldersViewController.m */, - C4F0E8321DA1C7A800435310 /* STPreferencesFoldersViewController.xib */, - C4F0E8351DA1CB0900435310 /* STPreferencesInfoViewController.h */, - C4F0E8361DA1CB0900435310 /* STPreferencesInfoViewController.m */, - C4F0E8371DA1CB0900435310 /* STPreferencesInfoViewController.xib */, C4D36D7D1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.h */, C4D36D7E1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m */, C4D36D7F1DA3D53F0061FD08 /* STPreferencesAdvancedViewController.xib */, - C4D36D821DA3E2820061FD08 /* STPreferencesDevicesViewController.h */, - C4D36D831DA3E2820061FD08 /* STPreferencesDevicesViewController.m */, - C4D36D841DA3E2820061FD08 /* STPreferencesDevicesViewController.xib */, ); name = STPreferencesWindow; sourceTree = ""; @@ -212,6 +167,7 @@ isa = PBXGroup; children = ( C4460A821D0DD38F00200C21 /* STPreferencesWindowController.xib */, + C4F0E82D1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib */, ); name = STPreferencesWindow; sourceTree = ""; @@ -345,9 +301,6 @@ CreatedOnToolsVersion = 8.3.3; ProvisioningStyle = Automatic; }; - C4576BDA1D11E3BB0031BCFD = { - CreatedOnToolsVersion = 7.3.1; - }; C4A4155F1D0D579D00DC6018 = { CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = C24U83K674; @@ -379,13 +332,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C4F0E8391DA1CB0900435310 /* STPreferencesInfoViewController.xib in Resources */, C4D36D811DA3D53F0061FD08 /* STPreferencesAdvancedViewController.xib in Resources */, - C4D36D861DA3E2820061FD08 /* STPreferencesDevicesViewController.xib in Resources */, C47F6C3A1D0DE68D00F36CF6 /* syncthing.icns in Resources */, C4A4156A1D0D579D00DC6018 /* Assets.xcassets in Resources */, C4A4156D1D0D579D00DC6018 /* STApplication.xib in Resources */, - C4F0E8341DA1C7A800435310 /* STPreferencesFoldersViewController.xib in Resources */, C4460A831D0DD38F00200C21 /* STPreferencesWindowController.xib in Resources */, C4946B011D5877F2008447A2 /* STAboutWindowController.xib in Resources */, C4F0E82F1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib in Resources */, @@ -408,24 +358,6 @@ shellPath = /bin/sh; shellScript = "${SOURCE_ROOT}/syncthing/Scripts/create-dmg.sh\n"; }; - 45CC8E0944A58A08F2F95479 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-xgsyncthing-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; 76C4F2C92ED96E367934A99B /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -481,30 +413,20 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - C4576BD71D11E3BB0031BCFD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; C4A4155C1D0D579D00DC6018 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( C4D567A21D3A8DFE002AD881 /* STLoginItem.m in Sources */, C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */, - C4F0E8331DA1C7A800435310 /* STPreferencesFoldersViewController.m in Sources */, C4A415681D0D579D00DC6018 /* main.m in Sources */, C4946B031D587878008447A2 /* STAboutWindowController.m in Sources */, C4D36D801DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m in Sources */, - C4D36D851DA3E2820061FD08 /* STPreferencesDevicesViewController.m in Sources */, C4460A811D0DD2D500200C21 /* STStatusBarController.m in Sources */, C48B83B61DA444BC0052A172 /* STConfiguration.m in Sources */, 0BE9B88A1F050E93002883E2 /* STStatusMonitor.m in Sources */, C4460A801D0DD2D500200C21 /* STPreferencesWindowController.m in Sources */, C4F0E82E1DA1B9CF00435310 /* STPreferencesGeneralViewController.m in Sources */, - C4F0E8381DA1CB0900435310 /* STPreferencesInfoViewController.m in Sources */, C4A415651D0D579D00DC6018 /* STApplication.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -545,28 +467,6 @@ }; name = Release; }; - C4576BE01D11E3BB0031BCFD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 8936500B5F25163F49F1401D /* Pods-xgsyncthing.debug.xcconfig */; - buildSettings = { - DEAD_CODE_STRIPPING = YES; - GCC_DYNAMIC_NO_PIC = NO; - OTHER_CFLAGS = ""; - "OTHER_LDFLAGS[arch=*]" = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - C4576BE11D11E3BB0031BCFD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5BE33EE7B1F21764C8AA4890 /* Pods-xgsyncthing.release.xcconfig */; - buildSettings = { - DEAD_CODE_STRIPPING = YES; - OTHER_CFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; C4A4156F1D0D579D00DC6018 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { diff --git a/syncthing/Controllers/STPreferencesWindowController.m b/syncthing/Controllers/STPreferencesWindowController.m index 5ff95d5..38cd784 100644 --- a/syncthing/Controllers/STPreferencesWindowController.m +++ b/syncthing/Controllers/STPreferencesWindowController.m @@ -8,9 +8,6 @@ #import "STPreferencesWindowController.h" #import "STPreferencesGeneralViewController.h" -#import "STPreferencesFoldersViewController.h" -#import "STPreferencesInfoViewController.h" -#import "STPreferencesDevicesViewController.h" #import "STPreferencesAdvancedViewController.h" @interface STPreferencesWindowController () @@ -22,9 +19,6 @@ @implementation STPreferencesWindowController enum { kGeneralView = 0, - kFoldersView, - kDevicesView, - kInfoView, kAdvancedView }; @@ -51,21 +45,6 @@ - (void) setViewFromId:(NSInteger) tag { _generalView = [[STPreferencesGeneralViewController alloc] init]; _currentViewController = self.generalView; break; - case kFoldersView: - if (self.foldersView == nil) - _foldersView = [[STPreferencesFoldersViewController alloc] init]; - _currentViewController = self.foldersView; - break; - case kDevicesView: - if (self.devicesView == nil) - _devicesView = [[STPreferencesDevicesViewController alloc] init]; - _currentViewController = self.devicesView; - break; - case kInfoView: - if (self.infoView == nil) - _infoView = [[STPreferencesInfoViewController alloc] init]; - _currentViewController = self.infoView; - break; case kAdvancedView: if (self.advancedView == nil) _advancedView = [[STPreferencesAdvancedViewController alloc] init]; @@ -89,99 +68,4 @@ - (IBAction) toolbarButtonClicked:(id)sender { [self setViewFromId:[button tag]]; } -/* - TODO: some day I will know how to dynamic resize the views without - views window height get broken - - //[[self window] setFrame:[currentView bounds] display:YES animate:YES]; - - // embed the current view to our host view - //[currentView addSubview:_currentViewController.view]; - - //[self resizeWindowWithContentSize:_currentViewController.view.frame.size animated:YES]; - //[self.window setContentSize:_currentViewController.view.frame.size]; - //[self setContentView:[_currentViewController view]]; - - // make sure we automatically resize the controller's view to the current window size - - //[self.window setContentSize:_currentViewController.view.frame.size]; - -- (CGFloat)toolbarHeight { - NSToolbar *toolbar = [self.window toolbar]; - CGFloat toolbarHeight = 0.0; - NSRect windowFrame; - - if (toolbar && [toolbar isVisible]) { - windowFrame = [self.window contentRectForFrameRect:self.window.frame - ]; - toolbarHeight = NSHeight(windowFrame) - - NSHeight([self.window.contentView frame]); - } - return toolbarHeight; -} - -- (void)resizeToSize:(NSSize)newSize { - CGFloat newHeight = newSize.height + [self toolbarHeight]; - CGFloat newWidth = newSize.width; - - NSRect aFrame = [self.window contentRectForFrameRect:self.window.frame - ]; - - aFrame.origin.y += aFrame.size.height; - aFrame.origin.y -= newHeight; - aFrame.size.height = newHeight; - aFrame.size.width = newWidth; - - aFrame = [self.window frameRectForContentRect:aFrame - ]; - [self.window setFrame:aFrame display:YES animate:YES]; -} - -- (void) setContentView:(NSView *)view { - //[self resizeToSize:view.frame.size]; - //[self.window setFrame:view.frame.size display:YES animate:YES]; - [self resizeWindowWithContentSize:view.frame.size animated:YES]; - [self.window setContentView:view]; -} - -- (void) resizeWindowWithContentSize:(NSSize)contentSize animated:(BOOL)animated { - CGFloat titleBarHeight = self.window.frame.size.height - ((NSView*)self.window.contentView).frame.size.height; - CGSize windowSize = windowSize = CGSizeMake(contentSize.width, contentSize.height + titleBarHeight); - - // Optional: keep it centered - float originX = self.window.frame.origin.x + (self.window.frame.size.width - windowSize.width) / 2; - float originY = self.window.frame.origin.y + (self.window.frame.size.height - windowSize.height) / 2; - NSRect windowFrame = CGRectMake(originX, originY, windowSize.width, windowSize.height); - - [self.window setFrame:windowFrame display:YES animate:animated]; -} - -- (void)resizeWindowForContentSize:(NSSize) size { - NSWindow *window = [self window]; - - NSRect windowFrame = [window contentRectForFrameRect:[window frame]]; - NSRect newWindowFrame = [window frameRectForContentRect: - NSMakeRect( NSMinX( windowFrame ), NSMaxY( windowFrame ) - size.height, size.width, size.height )]; - [window setFrame:newWindowFrame display:YES animate:[window isVisible]]; -} - - -- (void) setContentView:(NSView *)view { - - //NSRect wndFrame = [self.window frameRectForContentRect:[view bounds]]; - - //NSLog(@"wndFrame: %@", NSStringFromRect(wndFrame)); - //wndFrame.origin.x = self.window.frame.origin.x + (self.window.frame.size.width - view.frame.size.width) / 2; - //wndFrame.origin.y = self.window.frame.origin.y + (self.window.frame.size.height - view.frame.size.height) / 2; - - //[view setFrameOrigin:window.frame.origin]; - [self resizeWindowWithContentSize:view.frame.size animated:YES]; - //[self.window setFrame:wndFrame display:YES animate:YES]; - [[self window] setContentView:view]; - - //[[self window] setFrame:newWindowFrame display:YES animate:YES]; - //[[self window] setContentView:view]; -} -*/ - @end diff --git a/syncthing/STStatusMonitor.m b/syncthing/STStatusMonitor.m index 2f25fe7..d08d3a7 100644 --- a/syncthing/STStatusMonitor.m +++ b/syncthing/STStatusMonitor.m @@ -105,8 +105,6 @@ - (void) processEvent:(NSDictionary *)event { n.otherButtonTitle = @"Decline"; n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; - // XXX: Seems undocumented API hack or else the custom buttons are not shown - [n setValue:@YES forKey:@"_showsButtons"]; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; } else if ([eventType isEqualToString:@"DeviceRejected"]) { @@ -118,8 +116,6 @@ - (void) processEvent:(NSDictionary *)event { n.otherButtonTitle = @"Decline"; n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; - // XXX: Seems undocumented API hack or else the custom buttons are not shown - [n setValue:@YES forKey:@"_showsButtons"]; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; } diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.h b/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.h deleted file mode 100644 index 47bc0ff..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// STPreferencesDevicesViewController.h -// syncthing -// -// Created by Jerry Jacobs on 04/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import - -@interface STPreferencesDevicesViewController : NSViewController - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.m b/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.m deleted file mode 100644 index 3641dd4..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// STPreferencesDevicesViewController.m -// syncthing -// -// Created by Jerry Jacobs on 04/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import "STPreferencesDevicesViewController.h" - -@interface STPreferencesDevicesViewController () - -@end - -@implementation STPreferencesDevicesViewController - -- (void)viewDidLoad { - [super viewDidLoad]; -} - -- (id) init { - self = [super initWithNibName:NSStringFromClass(self.class) bundle:nil]; - return self; -} - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.xib b/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.xib deleted file mode 100644 index 6dc294b..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesDevicesViewController.xib +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.h b/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.h deleted file mode 100644 index cd5f643..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// STPreferencesFoldersViewController.h -// syncthing -// -// Created by Jerry Jacobs on 03/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import - -@interface STPreferencesFoldersViewController : NSViewController - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.m b/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.m deleted file mode 100644 index 845351e..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// STPreferencesFoldersViewController.m -// syncthing -// -// Created by Jerry Jacobs on 03/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import "STPreferencesFoldersViewController.h" - -@interface STPreferencesFoldersViewController () - -@end - -@implementation STPreferencesFoldersViewController - -- (void)viewDidLoad { - [super viewDidLoad]; -} - -- (id) init { - self = [super initWithNibName:NSStringFromClass(self.class) bundle:nil]; - return self; -} - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.xib b/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.xib deleted file mode 100644 index 4b6afe3..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesFoldersViewController.xib +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.h b/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.h deleted file mode 100644 index 504169e..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// STPreferencesInfoViewController.h -// syncthing -// -// Created by Jerry Jacobs on 03/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import - -@interface STPreferencesInfoViewController : NSViewController - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.m b/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.m deleted file mode 100644 index 5bb94ad..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// STPreferencesInfoViewController.m -// syncthing -// -// Created by Jerry Jacobs on 03/10/2016. -// Copyright © 2016 Jerry Jacobs. All rights reserved. -// - -#import "STPreferencesInfoViewController.h" - -@interface STPreferencesInfoViewController () - -@end - -@implementation STPreferencesInfoViewController - -- (void) viewDidLoad { - [super viewDidLoad]; -} - -- (id) init { - self = [super initWithNibName:NSStringFromClass(self.class) bundle:nil]; - return self; -} - -@end diff --git a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.xib b/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.xib deleted file mode 100644 index 6162062..0000000 --- a/syncthing/UI/STPreferencesWindow/STPreferencesInfoViewController.xib +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 2cda2aef4a9e6b6d2f6fd5e1a06b6baed1522a18 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 18 Jul 2018 22:27:06 +0200 Subject: [PATCH 9/9] Create notification function --- syncthing/STStatusMonitor.m | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/syncthing/STStatusMonitor.m b/syncthing/STStatusMonitor.m index d08d3a7..c29a97e 100644 --- a/syncthing/STStatusMonitor.m +++ b/syncthing/STStatusMonitor.m @@ -97,31 +97,28 @@ - (void) processEvent:(NSDictionary *)event { self.folderStates[folder] = newState; [self updateCurrentStatus]; } else if ([eventType isEqualToString:@"FolderRejected"]) { - NSUserNotification *n = [[NSUserNotification alloc] init]; - n.title = @"Syncthing"; - n.informativeText = [NSString stringWithFormat:@"New folder %@", [eventData objectForKey:@"folderLabel"]]; - n.hasActionButton = true; - n.actionButtonTitle = @"Accept"; - n.otherButtonTitle = @"Decline"; - n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; - n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; - - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; + [self processEventNotificationAcceptDecline:[NSString stringWithFormat:@"New folder %@", [eventData objectForKey:@"folderLabel"]] identifier:[NSString stringWithFormat:@"%@-%@", eventId, eventType] userInfo:[[NSDictionary alloc] initWithDictionary:event]]; } else if ([eventType isEqualToString:@"DeviceRejected"]) { - NSUserNotification *n = [[NSUserNotification alloc] init]; - n.title = @"Syncthing"; - n.informativeText = [NSString stringWithFormat:@"New device %@", [eventData objectForKey:@"name"]]; - n.hasActionButton = true; - n.actionButtonTitle = @"Accept"; - n.otherButtonTitle = @"Decline"; - n.identifier = [NSString stringWithFormat:@"%@-%@", eventId, eventType]; - n.userInfo = [[NSDictionary alloc] initWithDictionary:event]; - - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; + [self processEventNotificationAcceptDecline:[NSString stringWithFormat:@"New device %@", [eventData objectForKey:@"name"]] identifier:[NSString stringWithFormat:@"%@-%@", eventId, eventType] userInfo:[[NSDictionary alloc] initWithDictionary:event]]; } [self.delegate syncMonitorEventReceived:event]; } +- (void) processEventNotificationAcceptDecline: (NSString *) informativeText identifier:(NSString *)identifier userInfo:(NSDictionary *)userInfo { + NSUserNotification *n = [[NSUserNotification alloc] init]; + + n.informativeText = informativeText; + n.identifier = identifier; + n.userInfo = userInfo; + + n.title = @"Syncthing"; + n.hasActionButton = true; + n.actionButtonTitle = @"Accept"; + n.otherButtonTitle = @"Decline"; + + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n]; +} + - (void) updateStatusFromTimer { if (![_syncthing ping]) { self.currentStatus = SyncthingStatusOffline;