summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2016-08-07 16:34:54 -0700
committerGrant Limberg <glimberg@gmail.com>2016-08-07 16:34:54 -0700
commit179324e44af06fbdb9316e9c1ef6f2f70e61eb5c (patch)
tree916a6905605dbf9a68caf2f591ab834d21621647
parentc6dba50e354e341c7f6a7a1ed6b5d2d2a5bee884 (diff)
downloadinfinitytier-179324e44af06fbdb9316e9c1ef6f2f70e61eb5c.tar.gz
infinitytier-179324e44af06fbdb9316e9c1ef6f2f70e61eb5c.zip
Replace Preferences view. Removed LaunchAtLoginController and replaced with simpler code
-rw-r--r--ZeroTier One.xcodeproj/project.pbxproj16
-rw-r--r--ZeroTier One/AppDelegate.swift25
-rw-r--r--ZeroTier One/LaunchAtLoginController.h34
-rw-r--r--ZeroTier One/LaunchAtLoginController.m123
-rw-r--r--ZeroTier One/PreferencesViewController.h21
-rw-r--r--ZeroTier One/PreferencesViewController.m102
-rw-r--r--ZeroTier One/PreferencesViewController.swift41
-rw-r--r--ZeroTier One/ShowNetworksViewController.xib6
-rw-r--r--ZeroTier One/ZeroTier One-Bridging-Header.h4
-rw-r--r--ZeroTier One/about.html10
10 files changed, 145 insertions, 237 deletions
diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj
index c9a4dac8..6387075c 100644
--- a/ZeroTier One.xcodeproj/project.pbxproj
+++ b/ZeroTier One.xcodeproj/project.pbxproj
@@ -9,10 +9,8 @@
/* Begin PBXBuildFile section */
932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */; };
932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; };
- 932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */; };
932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; };
932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */; };
- 932D473A1D220D63004BCFE2 /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 932D47391D220D63004BCFE2 /* LaunchAtLoginController.m */; };
9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; };
93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; };
93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; };
@@ -25,6 +23,7 @@
93D167621D541BC200330C99 /* ServiceCom.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167611D541BC200330C99 /* ServiceCom.m */; };
93D167661D54308200330C99 /* Network.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167651D54308200330C99 /* Network.m */; };
93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167681D57E7EA00330C99 /* AboutViewController.m */; };
+ 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */; };
93DAFB271D3F0BEE004D5417 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = 93DAFB261D3F0BEE004D5417 /* about.html */; };
93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */; };
/* End PBXBuildFile section */
@@ -32,11 +31,8 @@
/* Begin PBXFileReference section */
932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = "<group>"; };
932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = "<group>"; };
- 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = "<group>"; };
932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = "<group>"; };
932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AboutViewController.xib; sourceTree = "<group>"; };
- 932D47381D220D63004BCFE2 /* LaunchAtLoginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LaunchAtLoginController.h; sourceTree = "<group>"; };
- 932D47391D220D63004BCFE2 /* LaunchAtLoginController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LaunchAtLoginController.m; sourceTree = "<group>"; };
9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = "<group>"; };
93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; };
93326BDB1CE7C816005CA2AC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -55,6 +51,8 @@
93D167651D54308200330C99 /* Network.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Network.m; sourceTree = "<group>"; };
93D167671D57E7EA00330C99 /* AboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutViewController.h; sourceTree = "<group>"; };
93D167681D57E7EA00330C99 /* AboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutViewController.m; sourceTree = "<group>"; };
+ 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesViewController.h; sourceTree = "<group>"; };
+ 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesViewController.m; sourceTree = "<group>"; };
93DAFB261D3F0BEE004D5417 /* about.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = about.html; sourceTree = "<group>"; };
93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ZeroTier One-Bridging-Header.h"; sourceTree = "<group>"; };
93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthtokenCopy.m; sourceTree = "<group>"; };
@@ -105,11 +103,8 @@
93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */,
93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */,
932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */,
- 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */,
932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */,
932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */,
- 932D47381D220D63004BCFE2 /* LaunchAtLoginController.h */,
- 932D47391D220D63004BCFE2 /* LaunchAtLoginController.m */,
93DAFB261D3F0BEE004D5417 /* about.html */,
93D1675D1D54191C00330C99 /* NodeStatus.h */,
93D1675E1D54191C00330C99 /* NodeStatus.m */,
@@ -119,6 +114,8 @@
93D167651D54308200330C99 /* Network.m */,
93D167671D57E7EA00330C99 /* AboutViewController.h */,
93D167681D57E7EA00330C99 /* AboutViewController.m */,
+ 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */,
+ 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */,
);
path = "ZeroTier One";
sourceTree = "<group>";
@@ -201,8 +198,6 @@
files = (
93D167621D541BC200330C99 /* ServiceCom.m in Sources */,
932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */,
- 932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */,
- 932D473A1D220D63004BCFE2 /* LaunchAtLoginController.m in Sources */,
93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */,
93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */,
9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */,
@@ -210,6 +205,7 @@
93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */,
93D1675F1D54191C00330C99 /* NodeStatus.m in Sources */,
93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */,
+ 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */,
93D167661D54308200330C99 /* Network.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift
index 7fb42c82..f70cfcb3 100644
--- a/ZeroTier One/AppDelegate.swift
+++ b/ZeroTier One/AppDelegate.swift
@@ -38,19 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
let defaultsDict = ["firstRun": true]
defaults.registerDefaults(defaultsDict)
- let firstRun = defaults.boolForKey("firstRun")
-
- if firstRun {
- defaults.setBool(false, forKey: "firstRun")
- defaults.synchronize()
-
- let loginController = LaunchAtLoginController()
- let bundle = NSBundle.mainBundle()
- let bundleURL = bundle.bundleURL
-
- loginController.setLaunchAtLogin(true, forURL: bundleURL)
- }
let nc = NSNotificationCenter.defaultCenter()
@@ -72,14 +60,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
networkListPopover.contentViewController = showNetworksView
networkListPopover.behavior = .Transient
- preferencesPopover.contentViewController = PreferencesViewController(
- nibName: "PreferencesViewController", bundle: nil)
+ let prefsView = PreferencesViewController(nibName: "PreferencesViewController", bundle: nil)
+ preferencesPopover.contentViewController = prefsView
preferencesPopover.behavior = .Transient
aboutPopover.contentViewController = AboutViewController(
nibName: "AboutViewController", bundle: nil)
aboutPopover.behavior = .Transient
+ let firstRun = defaults.boolForKey("firstRun")
+
+ if firstRun {
+ defaults.setBool(false, forKey: "firstRun")
+ defaults.synchronize()
+
+ prefsView?.setLaunchAtLoginEnabled(true)
+ }
+
if firstRun {
NSOperationQueue.mainQueue().addOperationWithBlock() {
self.showAbout()
diff --git a/ZeroTier One/LaunchAtLoginController.h b/ZeroTier One/LaunchAtLoginController.h
deleted file mode 100644
index 8892c9fb..00000000
--- a/ZeroTier One/LaunchAtLoginController.h
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// LaunchAtLoginController.h
-//
-// Copyright 2011 Tomáš Znamenáček
-// Copyright 2010 Ben Clark-Robinson
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the ‘Software’),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-#import <Foundation/Foundation.h>
-
-@interface LaunchAtLoginController : NSObject {}
-
-@property(assign) BOOL launchAtLogin;
-
-- (BOOL) willLaunchAtLogin: (NSURL*) itemURL;
-- (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL;
-
-@end
diff --git a/ZeroTier One/LaunchAtLoginController.m b/ZeroTier One/LaunchAtLoginController.m
deleted file mode 100644
index 53eb2b08..00000000
--- a/ZeroTier One/LaunchAtLoginController.m
+++ /dev/null
@@ -1,123 +0,0 @@
-//
-// LaunchAtLoginController.m
-//
-// Copyright 2011 Tomáš Znamenáček
-// Copyright 2010 Ben Clark-Robinson
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the ‘Software’),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-#import "LaunchAtLoginController.h"
-
-static NSString *const StartAtLoginKey = @"launchAtLogin";
-
-@interface LaunchAtLoginController ()
-@property(assign) LSSharedFileListRef loginItems;
-@end
-
-@implementation LaunchAtLoginController
-@synthesize loginItems;
-
-#pragma mark Change Observing
-
-void sharedFileListDidChange(LSSharedFileListRef inList, void *context)
-{
- LaunchAtLoginController *self = (__bridge id) context;
- [self willChangeValueForKey:StartAtLoginKey];
- [self didChangeValueForKey:StartAtLoginKey];
-}
-
-#pragma mark Initialization
-
-- (id) init
-{
- self = [super init];
- if(self) {
- loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
- LSSharedFileListAddObserver(loginItems, CFRunLoopGetMain(),
- (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (__bridge void*)self);
- }
- return self;
-}
-
-- (void) dealloc
-{
- LSSharedFileListRemoveObserver(loginItems, CFRunLoopGetMain(),
- (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (__bridge void*)self);
- CFRelease(loginItems);
-}
-
-#pragma mark Launch List Control
-
-- (LSSharedFileListItemRef) findItemWithURL: (NSURL*) wantedURL inFileList: (LSSharedFileListRef) fileList
-{
- if (wantedURL == NULL || fileList == NULL)
- return NULL;
-
- NSArray *listSnapshot = (__bridge_transfer NSArray*)LSSharedFileListCopySnapshot(fileList, NULL);
- for (id itemObject in listSnapshot) {
- LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject;
- UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
- CFURLRef currentItemURL = NULL;
- LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
- if (currentItemURL && CFEqual(currentItemURL, (__bridge CFTypeRef)wantedURL)) {
- CFRelease(currentItemURL);
- return item;
- }
- if (currentItemURL)
- CFRelease(currentItemURL);
- }
-
- return NULL;
-}
-
-- (BOOL) willLaunchAtLogin: (NSURL*) itemURL
-{
- return !![self findItemWithURL:itemURL inFileList:loginItems];
-}
-
-- (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL
-{
- LSSharedFileListItemRef appItem = [self findItemWithURL:itemURL inFileList:loginItems];
- if (enabled && !appItem) {
- LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst,
- NULL, NULL, (__bridge CFURLRef)itemURL, NULL, NULL);
- } else if (!enabled && appItem)
- LSSharedFileListItemRemove(loginItems, appItem);
-}
-
-#pragma mark Basic Interface
-
-- (NSURL*) appURL
-{
- return [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
-}
-
-- (void) setLaunchAtLogin: (BOOL) enabled
-{
- [self willChangeValueForKey:StartAtLoginKey];
- [self setLaunchAtLogin:enabled forURL:[self appURL]];
- [self didChangeValueForKey:StartAtLoginKey];
-}
-
-- (BOOL) launchAtLogin
-{
- return [self willLaunchAtLogin:[self appURL]];
-}
-
-@end
diff --git a/ZeroTier One/PreferencesViewController.h b/ZeroTier One/PreferencesViewController.h
new file mode 100644
index 00000000..e9e4e4b1
--- /dev/null
+++ b/ZeroTier One/PreferencesViewController.h
@@ -0,0 +1,21 @@
+//
+// PreferencesViewController.h
+// ZeroTier One
+//
+// Created by Grant Limberg on 8/7/16.
+// Copyright © 2016 ZeroTier, Inc. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface PreferencesViewController : NSViewController
+
+@property (nonatomic, weak) IBOutlet NSButton *startupCheckBox;
+
+- (IBAction)onStartupCheckBoxChanged:(NSButton*)sender;
+
+- (BOOL)isLaunchAtStartup;
+- (LSSharedFileListItemRef)itemRefInLoginItems;
+- (void)setLaunchAtLoginEnabled:(BOOL)enabled;
+
+@end
diff --git a/ZeroTier One/PreferencesViewController.m b/ZeroTier One/PreferencesViewController.m
new file mode 100644
index 00000000..2292367d
--- /dev/null
+++ b/ZeroTier One/PreferencesViewController.m
@@ -0,0 +1,102 @@
+//
+// PreferencesViewController.m
+// ZeroTier One
+//
+// Created by Grant Limberg on 8/7/16.
+// Copyright © 2016 ZeroTier, Inc. All rights reserved.
+//
+
+#import "PreferencesViewController.h"
+
+@interface PreferencesViewController ()
+
+@end
+
+@implementation PreferencesViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ if([self isLaunchAtStartup]) {
+ self.startupCheckBox.state = NSOnState;
+ }
+ else {
+ self.startupCheckBox.state = NSOffState;
+ }
+}
+
+- (IBAction)onStartupCheckBoxChanged:(NSButton *)sender
+{
+ if(sender.state == NSOnState) {
+ [self setLaunchAtLoginEnabled:YES];
+ }
+ else {
+ [self setLaunchAtLoginEnabled:NO];
+ }
+
+}
+
+- (void)setLaunchAtLoginEnabled:(BOOL)enabled
+{
+ LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
+
+ if (enabled) {
+ // Add the app to the LoginItems list.
+ CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+ LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
+ if (itemRef) CFRelease(itemRef);
+ }
+ else {
+ // Remove the app from the LoginItems list.
+ LSSharedFileListItemRef itemRef = [self itemRefInLoginItems];
+ LSSharedFileListItemRemove(loginItemsRef,itemRef);
+ if (itemRef != nil) CFRelease(itemRef);
+ }
+}
+
+
+- (BOOL)isLaunchAtStartup {
+ // See if the app is currently in LoginItems.
+ LSSharedFileListItemRef itemRef = [self itemRefInLoginItems];
+ // Store away that boolean.
+ BOOL isInList = itemRef != nil;
+ // Release the reference if it exists.
+ if (itemRef != nil) CFRelease(itemRef);
+
+ return isInList;
+}
+
+- (LSSharedFileListItemRef)itemRefInLoginItems {
+ LSSharedFileListItemRef itemRef = nil;
+
+ NSString * appPath = [[NSBundle mainBundle] bundlePath];
+
+ // This will retrieve the path for the application
+ // For example, /Applications/test.app
+ CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:appPath];
+
+ // Create a reference to the shared file list.
+ LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
+
+ if (loginItems) {
+ UInt32 seedValue;
+ //Retrieve the list of Login Items and cast them to
+ // a NSArray so that it will be easier to iterate.
+ NSArray *loginItemsArray = (__bridge NSArray *)LSSharedFileListCopySnapshot(loginItems, &seedValue);
+ for(int i = 0; i< [loginItemsArray count]; i++){
+ LSSharedFileListItemRef currentItemRef = (__bridge LSSharedFileListItemRef)[loginItemsArray
+ objectAtIndex:i];
+ //Resolve the item with URL
+ if (LSSharedFileListItemResolve(currentItemRef, 0, (CFURLRef*) &url, NULL) == noErr) {
+ NSString * urlPath = [(__bridge NSURL*)url path];
+ if ([urlPath compare:appPath] == NSOrderedSame){
+ itemRef = currentItemRef;
+ }
+ }
+ }
+ }
+ CFRelease(loginItems);
+ return itemRef;
+}
+
+@end
diff --git a/ZeroTier One/PreferencesViewController.swift b/ZeroTier One/PreferencesViewController.swift
deleted file mode 100644
index 0fd10281..00000000
--- a/ZeroTier One/PreferencesViewController.swift
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// PreferencesViewController.swift
-// ZeroTier One
-//
-// Created by Grant Limberg on 6/23/16.
-// Copyright © 2016 ZeroTier, Inc. All rights reserved.
-//
-
-import Cocoa
-
-class PreferencesViewController: NSViewController {
-
- @IBOutlet var startupCheckBox: NSButton!
-
- let launchController = LaunchAtLoginController()
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- if launchController.launchAtLogin {
- startupCheckBox.state = NSOnState
- }
- else {
- startupCheckBox.state = NSOffState
- }
- }
-
- @IBAction func onStartupCheckBoxChanged(sender: NSButton) {
- let bundle = NSBundle.mainBundle()
- let bundleURL = bundle.bundleURL
-
- if sender.state == NSOnState {
- launchController.setLaunchAtLogin(true, forURL: bundleURL)
- }
- else {
- launchController.setLaunchAtLogin(false, forURL: bundleURL)
- }
- }
-
-}
diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib
index c9235430..6a5d7ae3 100644
--- a/ZeroTier One/ShowNetworksViewController.xib
+++ b/ZeroTier One/ShowNetworksViewController.xib
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
</dependencies>
@@ -19,11 +19,11 @@
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="369" horizontalPageScroll="10" verticalLineScroll="369" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="miH-DQ-i4L">
<rect key="frame" x="20" y="20" width="530" height="481"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="KXW-dX-mx6">
- <rect key="frame" x="0.5" y="0.0" width="530" height="481"/>
+ <rect key="frame" x="0.0" y="0.0" width="530" height="481"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="367" rowSizeStyle="automatic" viewBased="YES" id="w5O-vn-cYB">
- <rect key="frame" x="0.0" y="0.0" width="530" height="481"/>
+ <rect key="frame" x="0.0" y="0.0" width="530" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.59999999999999998" colorSpace="calibratedRGB"/>
diff --git a/ZeroTier One/ZeroTier One-Bridging-Header.h b/ZeroTier One/ZeroTier One-Bridging-Header.h
index 958806c9..3068e515 100644
--- a/ZeroTier One/ZeroTier One-Bridging-Header.h
+++ b/ZeroTier One/ZeroTier One-Bridging-Header.h
@@ -3,8 +3,8 @@
//
#import "AuthtokenCopy.h"
-#import "LaunchAtLoginController.h"
#import "NodeStatus.h"
#import "Network.h"
#import "ServiceCom.h"
-#import "AboutViewController.h" \ No newline at end of file
+#import "AboutViewController.h"
+#import "PreferencesViewController.h"
diff --git a/ZeroTier One/about.html b/ZeroTier One/about.html
index 3196ac48..7754cf8d 100644
--- a/ZeroTier One/about.html
+++ b/ZeroTier One/about.html
@@ -57,16 +57,6 @@
<p>For more information, visit <a href="http://www.zerotier.com">zerotier.com</a>.</p>
- <hr/>
- <h2>Acknowledgements</h2>
- <h3><a href="https://github.com/Mozketo/LaunchAtLoginController">LaunchAtLoginController</a></h3>
- <p>Copyright (c) 2010 Ben Clark-Robinson, ben.clarkrobinson@gmail.com</p>
-
- <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
-
- <p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
-
- <p>THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</div>
</body>
</html> \ No newline at end of file