From 220552af62cb229d70a62851a35c6b38a0bc3345 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 16 Nov 2015 14:30:25 -0800 Subject: GitHub issue #241 -- and also some appearance updates. Eventually this might get replaced by a native Mac app. --- .../src/MacGap.xcodeproj/project.pbxproj | 7 +- .../src/MacGap/AppDelegate.m | 28 +- .../src/MacGap/Classes/ContentView.m | 10 +- .../src/MacGap/MacGap-Info.plist | 11 +- .../src/MacGap/en.lproj/Window.xib | 381 +++------------------ 5 files changed, 82 insertions(+), 355 deletions(-) (limited to 'ext/mac-ui-macgap1-wrapper/src') diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj b/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj index 08d72d06..775c5964 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj @@ -269,7 +269,7 @@ FAE451B114BA79C600190544 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = Twitter; }; buildConfigurationList = FAE451B414BA79C600190544 /* Build configuration list for PBXProject "MacGap" */; @@ -374,9 +374,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -402,7 +402,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -434,6 +433,7 @@ GCC_VERSION = ""; INFOPLIST_FILE = "MacGap/MacGap-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "ZeroTier One"; SDKROOT = macosx; WRAPPER_EXTENSION = app; @@ -455,6 +455,7 @@ GCC_VERSION = ""; INFOPLIST_FILE = "MacGap/MacGap-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "ZeroTier One"; SDKROOT = macosx; WRAPPER_EXTENSION = app; diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m b/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m index 3e25ca13..45923bb3 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m @@ -32,6 +32,7 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { char buf[16384],userAuthTokenPath[4096]; + struct stat systemAuthTokenStat,userAuthTokenStat; FILE *pf = fopen("/Library/Application Support/ZeroTier/One/zerotier-one.port","r"); long port = 9993; // default @@ -50,14 +51,27 @@ const char *homeDir = getenv("HOME"); if (homeDir) { snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier/One/authtoken.secret",homeDir); - pf = fopen(userAuthTokenPath,"r"); - if (pf) { - long n = fread(buf,1,sizeof(buf)-1,pf); - if (n > 0) { - buf[n] = (char)0; - snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf); + + bool userAuthTokenOutOfDate = false; + memset(&systemAuthTokenStat,0,sizeof(systemAuthTokenStat)); + memset(&userAuthTokenStat,0,sizeof(userAuthTokenStat)); + if (stat("/Library/Application Support/ZeroTier/One/authtoken.secret",&systemAuthTokenStat) == 0) { + if (stat(userAuthTokenPath,&userAuthTokenStat) == 0) { + if (userAuthTokenStat.st_mtimespec.tv_sec < systemAuthTokenStat.st_mtimespec.tv_sec) + userAuthTokenOutOfDate = true; + } + } + + if (!userAuthTokenOutOfDate) { + pf = fopen(userAuthTokenPath,"r"); + if (pf) { + long n = fread(buf,1,sizeof(buf)-1,pf); + if (n > 0) { + buf[n] = (char)0; + snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf); + } + fclose(pf); } - fclose(pf); } } diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m b/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m index 24e58cd1..6558a191 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m @@ -39,11 +39,11 @@ [self.webView setApplicationNameForUserAgent: @"MacGap"]; self.delegate = [[WebViewDelegate alloc] initWithMenu:[NSApp mainMenu]]; - [self.webView setFrameLoadDelegate:self.delegate]; - [self.webView setUIDelegate:self.delegate]; - [self.webView setResourceLoadDelegate:self.delegate]; - [self.webView setDownloadDelegate:self.delegate]; - [self.webView setPolicyDelegate:self.delegate]; +// [self.webView setFrameLoadDelegate:self.delegate]; +// [self.webView setUIDelegate:self.delegate]; +// [self.webView setResourceLoadDelegate:self.delegate]; +// [self.webView setDownloadDelegate:self.delegate]; +// [self.webView setPolicyDelegate:self.delegate]; [self.webView setDrawsBackground:NO]; [self.webView setShouldCloseWithWindow:NO]; diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist b/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist index 7e10a7a6..7f71ea22 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist @@ -2,14 +2,14 @@ - CFBundleIconFile - ZeroTierIcon CFBundleDevelopmentRegion en CFBundleExecutable ZeroTier One + CFBundleIconFile + ZeroTierIcon CFBundleIdentifier - com.zerotier.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -30,5 +30,10 @@ MainMenu NSPrincipalClass NSApplication + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib index 70d0c57b..2c46b79f 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib @@ -1,337 +1,44 @@ - - - - 1070 - 11C74 - 1938 - 1138.23 - 567.00 - - YES - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - YES - 1938 - 822 - - - - YES - NSWindowTemplate - NSView - NSCustomObject - WebView - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - PluginDependencyRecalculationVersion - - - - YES - - WindowController - - - FirstResponder - - - NSApplication - - - 15 - 2 - {{196, 240}, {758, 410}} - 544735232 - Window - NSWindow - - - - - 256 - - YES - - - 274 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name - - - {758, 410} - - - - 2 - _NS:51 - - - - - - YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - - - YES - - - - - - - YES - YES - - - {758, 410} - - - - - {{0, 0}, {1920, 1178}} - {10000000000000, 10000000000000} - 128 - YES - - - - - YES - - - contentView - - - - 23 - - - - window - - - - 25 - - - - title: contentView.webView.mainFrameTitle - - - - - - title: contentView.webView.mainFrameTitle - title - contentView.webView.mainFrameTitle - 2 - - - 31 - - - - webView - - - - 19 - - - - - YES - - 0 - - YES - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - YES - - - - - - 2 - - - YES - - - - - - 5 - - - - - - - YES - - YES - -1.IBPluginDependency - -2.IBPluginDependency - -3.IBPluginDependency - 1.IBPluginDependency - 1.IBWindowTemplateEditedContentRect - 1.NSWindowTemplate.visibleAtLaunch - 2.CustomClassName - 2.IBPluginDependency - 5.IBPluginDependency - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{357, 418}, {480, 270}} - - ContentView - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - - YES - - - - - - YES - - - - - 31 - - - - YES - - ContentView - NSView - - webView - WebView - - - webView - - webView - WebView - - - - IBProjectSource - ./Classes/ContentView.h - - - - WebView - - reloadFromOrigin: - id - - - reloadFromOrigin: - - reloadFromOrigin: - id - - - - IBProjectSource - ./Classes/WebView.h - - - - WindowController - NSWindowController - - contentView - ContentView - - - contentView - - contentView - ContentView - - - - IBProjectSource - ./Classes/WindowController.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - 3 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3