From 089da2a24a00d0145ff148c31dc795007171aaaf Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Sun, 29 Jan 2017 20:22:45 +0100 Subject: [PATCH] New macOS App (#4345) --- .gitlab-ci.yml | 3 + mac/Parity Ethereum.app/Contents/Info.plist | 11 - mac/Parity Ethereum.app/Contents/MacOS/go.sh | 3 - mac/Parity Ethereum.xcodeproj/project.pbxproj | 318 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + mac/Parity.pkgproj | 120 +------ mac/Parity/AppDelegate.swift | 228 +++++++++++++ .../AppIcon.appiconset/Contents.json | 59 ++++ .../AppIcon.appiconset}/Parity.png | Bin mac/Parity/Assets.xcassets/Contents.json | 6 + .../statusIcon.imageset/Contents.json | 23 ++ .../statusIcon.imageset/Parity-1.png | Bin 0 -> 372 bytes .../statusIcon.imageset/Parity-2.png | Bin 0 -> 1326 bytes .../statusIcon.imageset/Parity.png | Bin 0 -> 707 bytes mac/Parity/Base.lproj/MainMenu.xib | 48 +++ mac/Parity/GetBSDProcessList.swift | 59 ++++ mac/Parity/Info.plist | 36 ++ mac/install-readme.txt | 12 +- mac/post-install.sh | 39 +-- 19 files changed, 795 insertions(+), 177 deletions(-) delete mode 100644 mac/Parity Ethereum.app/Contents/Info.plist delete mode 100755 mac/Parity Ethereum.app/Contents/MacOS/go.sh create mode 100644 mac/Parity Ethereum.xcodeproj/project.pbxproj create mode 100644 mac/Parity Ethereum.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 mac/Parity/AppDelegate.swift create mode 100644 mac/Parity/Assets.xcassets/AppIcon.appiconset/Contents.json rename mac/{Parity Ethereum.app/Contents => Parity/Assets.xcassets/AppIcon.appiconset}/Parity.png (100%) create mode 100644 mac/Parity/Assets.xcassets/Contents.json create mode 100644 mac/Parity/Assets.xcassets/statusIcon.imageset/Contents.json create mode 100644 mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-1.png create mode 100644 mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-2.png create mode 100644 mac/Parity/Assets.xcassets/statusIcon.imageset/Parity.png create mode 100644 mac/Parity/Base.lproj/MainMenu.xib create mode 100644 mac/Parity/GetBSDProcessList.swift create mode 100644 mac/Parity/Info.plist diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 889b88c82..f70fa7503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -382,6 +382,9 @@ darwin: - rm -rf parity.md5 - md5sum target/release/parity > parity.md5 - export SHA3=$(target/release/parity tools hash target/release/parity) + - cd mac + - xcodebuild -configuration Release + - cd .. - packagesbuild -v mac/Parity.pkgproj - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - mv target/release/Parity\ Ethereum.pkg "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" diff --git a/mac/Parity Ethereum.app/Contents/Info.plist b/mac/Parity Ethereum.app/Contents/Info.plist deleted file mode 100644 index 6732cf753..000000000 --- a/mac/Parity Ethereum.app/Contents/Info.plist +++ /dev/null @@ -1,11 +0,0 @@ -CFBundleIconFilesParity.pngCFBundlePackageTypeAPPLCFBundleInfoDictionaryVersion6.0 - - CFBundleName Parity Ethereum - CFBundleExecutable go.sh - CFBundleIdentifier io.parity.ethereum - - CFBundleVersion 1.4.0 - CFBundleGetInfoString Parity 1.4.0 - CFBundleShortVersionString 1.4.0 - - diff --git a/mac/Parity Ethereum.app/Contents/MacOS/go.sh b/mac/Parity Ethereum.app/Contents/MacOS/go.sh deleted file mode 100755 index 3392515c4..000000000 --- a/mac/Parity Ethereum.app/Contents/MacOS/go.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -open http://127.0.0.1:8080/ diff --git a/mac/Parity Ethereum.xcodeproj/project.pbxproj b/mac/Parity Ethereum.xcodeproj/project.pbxproj new file mode 100644 index 000000000..f7879f41b --- /dev/null +++ b/mac/Parity Ethereum.xcodeproj/project.pbxproj @@ -0,0 +1,318 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0A7A475D1E3D2CDD0093D1AB /* parity in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0A7A475C1E3D2CDD0093D1AB /* parity */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 0ACF9AC21E30FAB600D5C935 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACF9AC11E30FAB600D5C935 /* AppDelegate.swift */; }; + 0ACF9AC41E30FAB600D5C935 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0ACF9AC31E30FAB600D5C935 /* Assets.xcassets */; }; + 0ACF9AC71E30FAB600D5C935 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0ACF9AC51E30FAB600D5C935 /* MainMenu.xib */; }; + 0AE564F11E3CE42C00BD01F7 /* GetBSDProcessList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE564F01E3CE42C00BD01F7 /* GetBSDProcessList.swift */; }; + 0AED4DA01E3E22F800BF87C0 /* ethstore in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0AED4D9F1E3E22F800BF87C0 /* ethstore */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 0A7A475B1E3D2C800093D1AB /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 6; + files = ( + 0AED4DA01E3E22F800BF87C0 /* ethstore in CopyFiles */, + 0A7A475D1E3D2CDD0093D1AB /* parity in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0A7A475C1E3D2CDD0093D1AB /* parity */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = parity; path = ../target/release/parity; sourceTree = ""; }; + 0ACF9ABE1E30FAB600D5C935 /* Parity Ethereum.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Parity Ethereum.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0ACF9AC11E30FAB600D5C935 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 0ACF9AC31E30FAB600D5C935 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0ACF9AC61E30FAB600D5C935 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 0ACF9AC81E30FAB600D5C935 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0AE564F01E3CE42C00BD01F7 /* GetBSDProcessList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetBSDProcessList.swift; sourceTree = ""; }; + 0AED4D9F1E3E22F800BF87C0 /* ethstore */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = ethstore; path = ../target/release/deps/ethstore; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0ACF9ABB1E30FAB600D5C935 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0ACF9AB51E30FAB600D5C935 = { + isa = PBXGroup; + children = ( + 0AED4D9F1E3E22F800BF87C0 /* ethstore */, + 0A7A475C1E3D2CDD0093D1AB /* parity */, + 0ACF9AC01E30FAB600D5C935 /* Parity Ethereum */, + 0ACF9ABF1E30FAB600D5C935 /* Products */, + ); + sourceTree = ""; + }; + 0ACF9ABF1E30FAB600D5C935 /* Products */ = { + isa = PBXGroup; + children = ( + 0ACF9ABE1E30FAB600D5C935 /* Parity Ethereum.app */, + ); + name = Products; + sourceTree = ""; + }; + 0ACF9AC01E30FAB600D5C935 /* Parity Ethereum */ = { + isa = PBXGroup; + children = ( + 0ACF9AC11E30FAB600D5C935 /* AppDelegate.swift */, + 0ACF9AC31E30FAB600D5C935 /* Assets.xcassets */, + 0ACF9AC51E30FAB600D5C935 /* MainMenu.xib */, + 0ACF9AC81E30FAB600D5C935 /* Info.plist */, + 0AE564F01E3CE42C00BD01F7 /* GetBSDProcessList.swift */, + ); + name = "Parity Ethereum"; + path = Parity; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0ACF9ABD1E30FAB600D5C935 /* Parity Ethereum */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0ACF9ACB1E30FAB600D5C935 /* Build configuration list for PBXNativeTarget "Parity Ethereum" */; + buildPhases = ( + 0ACF9ABA1E30FAB600D5C935 /* Sources */, + 0ACF9ABB1E30FAB600D5C935 /* Frameworks */, + 0ACF9ABC1E30FAB600D5C935 /* Resources */, + 0A7A475B1E3D2C800093D1AB /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Parity Ethereum"; + productName = Parity; + productReference = 0ACF9ABE1E30FAB600D5C935 /* Parity Ethereum.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0ACF9AB61E30FAB600D5C935 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0800; + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = "Parity Technologies"; + TargetAttributes = { + 0ACF9ABD1E30FAB600D5C935 = { + CreatedOnToolsVersion = 8.0; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 0ACF9AB91E30FAB600D5C935 /* Build configuration list for PBXProject "Parity Ethereum" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0ACF9AB51E30FAB600D5C935; + productRefGroup = 0ACF9ABF1E30FAB600D5C935 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0ACF9ABD1E30FAB600D5C935 /* Parity Ethereum */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0ACF9ABC1E30FAB600D5C935 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0ACF9AC41E30FAB600D5C935 /* Assets.xcassets in Resources */, + 0ACF9AC71E30FAB600D5C935 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0ACF9ABA1E30FAB600D5C935 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0AE564F11E3CE42C00BD01F7 /* GetBSDProcessList.swift in Sources */, + 0ACF9AC21E30FAB600D5C935 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 0ACF9AC51E30FAB600D5C935 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 0ACF9AC61E30FAB600D5C935 /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 0ACF9AC91E30FAB600D5C935 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 0ACF9ACA1E30FAB600D5C935 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + 0ACF9ACC1E30FAB600D5C935 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; + INFOPLIST_FILE = Parity/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.parity.ethereum; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 0ACF9ACD1E30FAB600D5C935 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; + INFOPLIST_FILE = Parity/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.parity.ethereum; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0ACF9AB91E30FAB600D5C935 /* Build configuration list for PBXProject "Parity Ethereum" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0ACF9AC91E30FAB600D5C935 /* Debug */, + 0ACF9ACA1E30FAB600D5C935 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0ACF9ACB1E30FAB600D5C935 /* Build configuration list for PBXNativeTarget "Parity Ethereum" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0ACF9ACC1E30FAB600D5C935 /* Debug */, + 0ACF9ACD1E30FAB600D5C935 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0ACF9AB61E30FAB600D5C935 /* Project object */; +} diff --git a/mac/Parity Ethereum.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/mac/Parity Ethereum.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..8297038e3 --- /dev/null +++ b/mac/Parity Ethereum.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/mac/Parity.pkgproj b/mac/Parity.pkgproj index 892d0212f..caecc7c0d 100755 --- a/mac/Parity.pkgproj +++ b/mac/Parity.pkgproj @@ -22,7 +22,7 @@ GID 80 PATH - Parity Ethereum.app + build/release/Parity Ethereum.app PATH_TYPE 3 PERMISSIONS @@ -416,122 +416,6 @@ UID 0 - - CHILDREN - - - CHILDREN - - - CHILDREN - - - CHILDREN - - GID - 0 - PATH - ../target/release/deps/ethstore - PATH_TYPE - 3 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - - GID - 0 - PATH - bin - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - - - CHILDREN - - - CHILDREN - - GID - 0 - PATH - ../target/release/parity - PATH_TYPE - 3 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - - CHILDREN - - GID - 0 - PATH - uninstall-parity.sh - PATH_TYPE - 3 - PERMISSIONS - 493 - TYPE - 3 - UID - 0 - - - GID - 0 - PATH - libexec - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - - - GID - 0 - PATH - local - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - - - GID - 0 - PATH - usr - PATH_TYPE - 0 - PERMISSIONS - 493 - TYPE - 2 - UID - 0 - GID 0 @@ -572,7 +456,7 @@ CONCLUSION_ACTION 0 IDENTIFIER - io.parity.pkg.parity-ethereum + io.parity.ethereum NAME Parity OVERWRITE_PERMISSIONS diff --git a/mac/Parity/AppDelegate.swift b/mac/Parity/AppDelegate.swift new file mode 100644 index 000000000..3bf3bdd31 --- /dev/null +++ b/mac/Parity/AppDelegate.swift @@ -0,0 +1,228 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import Cocoa + +@NSApplicationMain +@available(macOS, deprecated: 10.11) + +class AppDelegate: NSObject, NSApplicationDelegate { + @IBOutlet weak var statusMenu: NSMenu! + @IBOutlet weak var startAtLogonMenuItem: NSMenuItem! + + let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength) + var parityPid: Int32? = nil + var commandLine: [String] = [] + let defaultConfig = "[network]\nwarp = true" + let defaultDefaults = "{\"fat_db\":false,\"mode\":\"passive\",\"mode.alarm\":3600,\"mode.timeout\":300,\"pruning\":\"fast\",\"tracing\":false}" + + func menuAppPath() -> String { + return Bundle.main.executablePath! + } + + func parityPath() -> String { + return Bundle.main.bundlePath + "/Contents/MacOS/parity" + } + + func isAlreadyRunning() -> Bool { + return NSRunningApplication.runningApplications(withBundleIdentifier: Bundle.main.bundleIdentifier!).count > 1 + + } + + func isParityRunning() -> Bool { + if let pid = self.parityPid { + return kill(pid, 0) == 0 + } + return false + } + + func killParity() { + if let pid = self.parityPid { + kill(pid, SIGINT) + } + } + + func openUI() { + let parity = Process() + parity.launchPath = self.parityPath() + parity.arguments = self.commandLine + parity.arguments!.append("ui") + parity.launch() + } + + func writeConfigFiles() { + let basePath = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first? + .appendingPathComponent(Bundle.main.bundleIdentifier!, isDirectory: true) + + if FileManager.default.fileExists(atPath: basePath!.path) { + return + } + + do { + let defaultsFileDir = basePath?.appendingPathComponent("chains").appendingPathComponent("ethereum") + let defaultsFile = defaultsFileDir?.appendingPathComponent("user_defaults") + + try FileManager.default.createDirectory(atPath: (defaultsFileDir?.path)!, withIntermediateDirectories: true, attributes: nil) + if !FileManager.default.fileExists(atPath: defaultsFile!.path) { + try defaultDefaults.write(to: defaultsFile!, atomically: false, encoding: String.Encoding.utf8) + } + + let configFile = basePath?.appendingPathComponent("config.toml") + if !FileManager.default.fileExists(atPath: configFile!.path) { + try defaultConfig.write(to: configFile!, atomically: false, encoding: String.Encoding.utf8) + } + } + catch {} + } + + func autostartEnabled() -> Bool { + return itemReferencesInLoginItems().existingReference != nil + } + + func itemReferencesInLoginItems() -> (existingReference: LSSharedFileListItem?, lastReference: LSSharedFileListItem?) { + let itemUrl: UnsafeMutablePointer?> = UnsafeMutablePointer?>.allocate(capacity: 1) + if let appUrl: NSURL = NSURL.fileURL(withPath: Bundle.main.bundlePath) as NSURL? { + let loginItemsRef = LSSharedFileListCreate( + nil, + kLSSharedFileListSessionLoginItems.takeRetainedValue(), + nil + ).takeRetainedValue() as LSSharedFileList? + if loginItemsRef != nil { + let loginItems: NSArray = LSSharedFileListCopySnapshot(loginItemsRef, nil).takeRetainedValue() as NSArray + if(loginItems.count > 0) + { + let lastItemRef: LSSharedFileListItem = loginItems.lastObject as! LSSharedFileListItem + for i in 0 ..< loginItems.count { + let currentItemRef: LSSharedFileListItem = loginItems.object(at: i) as! LSSharedFileListItem + if LSSharedFileListItemResolve(currentItemRef, 0, itemUrl, nil) == noErr { + if let urlRef: NSURL = itemUrl.pointee?.takeRetainedValue() { + if urlRef.isEqual(appUrl) { + return (currentItemRef, lastItemRef) + } + } + } + } + //The application was not found in the startup list + return (nil, lastItemRef) + } + else + { + let addAtStart: LSSharedFileListItem = kLSSharedFileListItemBeforeFirst.takeRetainedValue() + return(nil, addAtStart) + } + } + } + return (nil, nil) + } + + func toggleLaunchAtStartup() { + let itemReferences = itemReferencesInLoginItems() + let shouldBeToggled = (itemReferences.existingReference == nil) + let loginItemsRef = LSSharedFileListCreate( + nil, + kLSSharedFileListSessionLoginItems.takeRetainedValue(), + nil + ).takeRetainedValue() as LSSharedFileList? + if loginItemsRef != nil { + if shouldBeToggled { + if let appUrl : CFURL = NSURL.fileURL(withPath: Bundle.main.bundlePath) as CFURL? { + LSSharedFileListInsertItemURL( + loginItemsRef, + itemReferences.lastReference, + nil, + nil, + appUrl, + nil, + nil + ) + } + } else { + if let itemRef = itemReferences.existingReference { + LSSharedFileListItemRemove(loginItemsRef,itemRef) + } + } + } + } + + func launchParity() { + self.commandLine = CommandLine.arguments.dropFirst().filter({ $0 != "ui"}) + + let processes = GetBSDProcessList()! + let parityProcess = processes.index(where: { + var name = $0.kp_proc.p_comm + let str = withUnsafePointer(to: &name) { + $0.withMemoryRebound(to: UInt8.self, capacity: MemoryLayout.size(ofValue: name)) { + String(cString: $0) + } + } + return str == "parity" + }) + + if parityProcess == nil { + let parity = Process() + let p = self.parityPath() + parity.launchPath = p//self.parityPath() + parity.arguments = self.commandLine + parity.launch() + self.parityPid = parity.processIdentifier + } else { + self.parityPid = processes[parityProcess!].kp_proc.p_pid + } + } + + func applicationDidFinishLaunching(_ aNotification: Notification) { + if self.isAlreadyRunning() { + openUI() + NSApplication.shared().terminate(self) + return + } + + self.writeConfigFiles() + self.launchParity() + Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: {_ in + if !self.isParityRunning() { + NSApplication.shared().terminate(self) + } + }) + + let icon = NSImage(named: "statusIcon") + icon?.isTemplate = true // best for dark mode + statusItem.image = icon + statusItem.menu = statusMenu + } + + override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { + if menuItem == self.startAtLogonMenuItem! { + menuItem.state = self.autostartEnabled() ? NSOnState : NSOffState + } + return true + } + + @IBAction func quitClicked(_ sender: NSMenuItem) { + self.killParity() + NSApplication.shared().terminate(self) + } + + @IBAction func openClicked(_ sender: NSMenuItem) { + self.openUI() + } + + @IBAction func startAtLogonClicked(_ sender: NSMenuItem) { + self.toggleLaunchAtStartup() + } + +} + diff --git a/mac/Parity/Assets.xcassets/AppIcon.appiconset/Contents.json b/mac/Parity/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..9d59e8b3a --- /dev/null +++ b/mac/Parity/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,59 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "Parity.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/mac/Parity Ethereum.app/Contents/Parity.png b/mac/Parity/Assets.xcassets/AppIcon.appiconset/Parity.png similarity index 100% rename from mac/Parity Ethereum.app/Contents/Parity.png rename to mac/Parity/Assets.xcassets/AppIcon.appiconset/Parity.png diff --git a/mac/Parity/Assets.xcassets/Contents.json b/mac/Parity/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/mac/Parity/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/mac/Parity/Assets.xcassets/statusIcon.imageset/Contents.json b/mac/Parity/Assets.xcassets/statusIcon.imageset/Contents.json new file mode 100644 index 000000000..b709bf58b --- /dev/null +++ b/mac/Parity/Assets.xcassets/statusIcon.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Parity-1.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Parity.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Parity-2.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-1.png b/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-1.png new file mode 100644 index 0000000000000000000000000000000000000000..040d444e2bfc2dc39b2715cf187226f0dd324249 GIT binary patch literal 372 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|wj^(N7l!{JxM1({$v_d#0*}aI zppNSx%;=;sy864H~?lbs_Lq&$_Hkn`mKvlWIj-(SwL z{QB*h<@3sO^Pj(cdjHiL@ttW6cUL6Iz5mfs-1zbSq%DuwE;HV93I7rPq3xi~Br%!A zP1ZUs^+LC29M;*kspC}O)~>nok5(7XUp{fmV>#73$1J{@b+NR2a$RIwmo#(vjob<0 z2dZx6eRF=awdW(h!8MH??VM*4R=DkDs=6TmPnD;;%ks%bsfN^;$1KbiPSHo^eQZ*< zd8AmR`l8#lFG0(p`{Kn^-|0syX2`zaITJad?zX4llwU#$z8z2aYuV>_?$Z45`)1xP QVE8b2y85}Sb4q9e0PT9A;Q#;t literal 0 HcmV?d00001 diff --git a/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-2.png b/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity-2.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4d72b2961cb6c63928deaee31df6bbe3c01433 GIT binary patch literal 1326 zcmV+}1=0G6P)gTv zO_0QbV9_0_g%);^S{La;q03xtmb#2GyDYcUAAVl=aoS#&?|bHi^M#jp?{m(1e!u5D z&+q$O1}RdcNRc8%iWL2YK?8h$gMl*l*#-Q0AR1N-`~wUDjt9m7qk!QW*a>U{T7hqY zjT$>34XXm`fDG`Bzpn)@2afFJnccv9z$?J3K+8ZftQ2|tSmSxj-n#?12`JegMjZ~k?nXWZCMbVCX3$Q<>m1J>eh&_GjRWR; zzOv8#2+Ztnqso9rH?SS3SAJW}sLgsM8&*?+Rlpm1`T<}{p!Zzhli>Mx4fTG*{ZexT zT&-*p@N=-K?}4*pIcx%O2k=&K-7}f<+LbQ~N~L_8Z1ucl?d0=9PP;__`d=mzdBq{+-LKMH14X zdZ!)uAXecQ1SJ-?k)yD&!L^Z6`@BAcN3Bigna&d{4DW+HqgCoV6}Zce`6DM>nI7_4 z-s879z#|S)X4~b4`K;EqVp|VuM!o191DtF{f25clpALy;h^QnjH&t^`%12q8zy1x7O}k%Sf*?fN9PImjh1% zf5b**)7bN0kk$e)Zlz&gWS-ibgK+k0SU4=1WrbYnIoR&oY6QOOWg0ces=k{80Hqq1 kB1MW6DN>|Jk)l`p3qHR)i~+iE@&Et;07*qoM6N<$f&|!T8UO$Q literal 0 HcmV?d00001 diff --git a/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity.png b/mac/Parity/Assets.xcassets/statusIcon.imageset/Parity.png new file mode 100644 index 0000000000000000000000000000000000000000..19479998875e60919a20dcc7cf3972029cf47cdf GIT binary patch literal 707 zcmV;!0zCbRP)3RfB63kG;X;T4qbMYhYNZ)vme}Sq4%2(~X6EU}`CwqaGv}Ur=KQ(mLVy4P zwirU2utx@v1(XB1z#=dWd;@-N){nLV=YSgE6|frTc>}ay28w~-X4Ch;Dang~qrhGB{ZXo&X_4U`@mcX-K!;?9s_&}*e<7f@o1UrC_90~nRg3CXUB_xW|E zU4~l4pPE8l4-sGrcrIS7sJ-;#OcXh_l6Cq6D- z=fcKK)AG->-V-XcctE^fyxXOnn0fyQ%y@NZ*hD7;JORD{yFJ>=QTq>gSsarym&DgP z>!gqLH_OIxw+qvOPiplwOaOO$4)|H%wx1LEw0NC(p$~^9ffxE&S4dNyM~v)&IfI2&B`aGCCiuCg&lHj=vJS1Vej pz&p*C4-VsDze6xUfB*pu{s3Gui>wgh0(1ZX002ovPDHLkV1m{%K1Kil literal 0 HcmV?d00001 diff --git a/mac/Parity/Base.lproj/MainMenu.xib b/mac/Parity/Base.lproj/MainMenu.xib new file mode 100644 index 000000000..2f52c80ad --- /dev/null +++ b/mac/Parity/Base.lproj/MainMenu.xib @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mac/Parity/GetBSDProcessList.swift b/mac/Parity/GetBSDProcessList.swift new file mode 100644 index 000000000..6ee1956e7 --- /dev/null +++ b/mac/Parity/GetBSDProcessList.swift @@ -0,0 +1,59 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + + +// Based on https://github.com/soh335/GetBSDProcessList + +import Foundation +import Darwin + +public func GetBSDProcessList() -> ([kinfo_proc]?) { + + var done = false + var result: [kinfo_proc]? + var err: Int32 + + repeat { + let name = [CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0]; + let namePointer = name.withUnsafeBufferPointer { UnsafeMutablePointer(mutating: $0.baseAddress) } + var length: Int = 0 + + err = sysctl(namePointer, u_int(name.count), nil, &length, nil, 0) + if err == -1 { + err = errno + } + + if err == 0 { + let count = length / MemoryLayout.stride + result = [kinfo_proc](repeating: kinfo_proc(), count: count) + err = result!.withUnsafeMutableBufferPointer({ ( p: inout UnsafeMutableBufferPointer) -> Int32 in + return sysctl(namePointer, u_int(name.count), p.baseAddress, &length, nil, 0) + }) + switch err { + case 0: + done = true + case -1: + err = errno + case ENOMEM: + err = 0 + default: + fatalError() + } + } + } while err == 0 && !done + + return result +} diff --git a/mac/Parity/Info.plist b/mac/Parity/Info.plist new file mode 100644 index 000000000..017939aec --- /dev/null +++ b/mac/Parity/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.6 + CFBundleVersion + 1 + LSApplicationCategoryType + public.app-category.finance + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSHumanReadableCopyright + Copyright © 2017 Parity Technologies. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/mac/install-readme.txt b/mac/install-readme.txt index 5a6de4580..a68d18ae9 100644 --- a/mac/install-readme.txt +++ b/mac/install-readme.txt @@ -5,16 +5,6 @@ Welcome to Parity Wallet, your all-in-one Ethereum node and wallet. WARNING: This installer is **EXPERIMENTAL**. Use it at your own risk. -If you continue, Parity will be installed as a system service. You will be able to use the Parity Wallet through your browser by following the shortcut in the Launchpad or navigating to http://localhost:8080/ in your browser. - -To temporarily disable Parity Wallet (and stop Parity) use: - - launchctl stop io.parity.ethereum - - -To completely uninstall Parity Wallet use: - - sudo /usr/local/libexec/uninstall-parity.sh - +If you continue, Parity will be installed as a user service. You will be able to use the Parity Wallet through your browser by using the menu bar icon, following the shortcut in the Launchpad or navigating to http://localhost:8080/ in your browser. Parity is distributed under the terms of the GPL. diff --git a/mac/post-install.sh b/mac/post-install.sh index 24eb7d5f9..835d2ceda 100755 --- a/mac/post-install.sh +++ b/mac/post-install.sh @@ -1,37 +1,8 @@ #!/bin/bash - -mkdir -p $HOME/Library/LaunchAgents -cat > $HOME/Library/LaunchAgents/io.parity.ethereum.plist < - - - - Label - io.parity.ethereum - ProgramArguments - - /usr/local/libexec/parity - --warp - - KeepAlive - - RunAtLoad - - StandardOutPath - $HOME/.parity/log.out - StandardErrorPath - $HOME/.parity/log.err - - -EOF - -mkdir -p $HOME/.parity/906a34e69aec8c0d -echo -n '{"fat_db":false,"mode":"passive","mode.alarm":3600,"mode.timeout":300,"pruning":"fast","tracing":false}' > $HOME/.parity/906a34e69aec8c0d/user_defaults - -chown -R $USER $HOME/.parity $HOME/Library/LaunchAgents $HOME/Library/LaunchAgents/io.parity.ethereum.plist - -su $USER -c "launchctl load $HOME/Library/LaunchAgents/io.parity.ethereum.plist" +# uninstall any ancient version +test -f /usr/local/libexec/uninstall-parity.sh && /usr/local/libexec/uninstall-parity.sh || true +killall -9 parity && sleep 5 +su $USER -c "open /Applications/Parity\ Ethereum.app" sleep 5 - su $USER -c "open http://127.0.0.1:8080/" - +exit 0