Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d86b67be21 | |||
| 26aad152f9 | |||
| 03381f7029 | |||
| 5eb1e444b2 | |||
| 05b62e442b | |||
| eb3cc85403 | |||
| 51b171fcb7 | |||
| 87106601a7 | |||
| 316d576715 | |||
| c6a1c3e785 | |||
| 20ceff19fe | |||
| 93ae7d634f | |||
| 766356d4a3 | |||
| bd68ecfbab | |||
| f1ebfa05bd | |||
| c8231a15ae | |||
| 4c81f92105 | |||
| 14a2f4077f | |||
| 9be8b62dc9 | |||
| 4b5448a4b6 | |||
| 7cb3bf5e4d | |||
| c3ca122b27 | |||
| f4af791fac | |||
| adbdc52603 | |||
| ef7341e9a5 | |||
| 6705cd100b | |||
| e5c9f80318 | |||
| caa96f7634 | |||
| a0acf3e309 | |||
| d546366b63 | |||
| 1997006727 | |||
| d6a007b7bc | |||
| c076b3cf79 | |||
| bd81825eb6 | |||
| c67bf82f1c | |||
| edbfb57081 | |||
| 15ef64fad1 | |||
| 335a978ea3 | |||
| 29f8316c7d | |||
| 163c257ad3 | |||
| 155f350ec3 | |||
| 21ad6e8422 | |||
| 75372a3bf4 | |||
| e1c5eb2028 | |||
| 5a7e71b582 | |||
| 4c8911d2a6 | |||
| f013fc21dd | |||
| d7aac44aaf | |||
| e9251946ba | |||
| 294aa4c785 | |||
| 6e8235f48c | |||
| e033c54c75 | |||
| 024b0afdcb | |||
| 4d53fab0c1 | |||
| f162c98605 | |||
| f226596bd6 | |||
| 5b35ff2f9b | |||
| 4758e691da | |||
| 6dd451e087 | |||
| 5dd498dede | |||
| a3378b906c | |||
| 852fe9bd5d | |||
| 19dea1e43e | |||
| af88a9973c | |||
| e6ded71f59 | |||
| 2dd27e0262 | |||
| 54e375531e | |||
| a0cc64fd46 | |||
| 11d0edcbeb | |||
| 1940e7bda0 | |||
| e46f756922 | |||
| 61294177cf | |||
| b5f7636e14 | |||
| 3ad365a2f1 | |||
| 8a4e433b1a | |||
| f60a953cf4 | |||
| 2c9ec6340b | |||
| f6f4931aaa | |||
| 1c7b8df605 | |||
| 86a00af5cf | |||
| 6a6e2d00dc |
+68
@@ -0,0 +1,68 @@
|
||||
|
||||
*.xcuserstate
|
||||
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xcuserstate
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
@@ -7,6 +7,8 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0A2BF1F81E460F170002C5B7 /* optionsTextfield.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A2BF1F71E460F170002C5B7 /* optionsTextfield.swift */; };
|
||||
0A2BF1FA1E4619230002C5B7 /* secureOptionsTextfield.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A2BF1F91E4619230002C5B7 /* secureOptionsTextfield.swift */; };
|
||||
0A3153191CF37A660020DBB8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A3153181CF37A660020DBB8 /* AppDelegate.swift */; };
|
||||
0A31531B1CF37A660020DBB8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A31531A1CF37A660020DBB8 /* ViewController.swift */; };
|
||||
0A31531D1CF37A660020DBB8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A31531C1CF37A660020DBB8 /* Assets.xcassets */; };
|
||||
@@ -16,13 +18,16 @@
|
||||
0A59C2721E3D09CE00E40A2B /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A59C2711E3D09CE00E40A2B /* Constants.swift */; };
|
||||
0A59C2741E3D0C0E00E40A2B /* GetIt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A59C2731E3D0C0E00E40A2B /* GetIt.swift */; };
|
||||
0A8DA5DA1E3E808500148315 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8DA5D91E3E808500148315 /* AboutViewController.swift */; };
|
||||
0AAAC76C208664EB009C6ACB /* progressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAAC76B208664EB009C6ACB /* progressView.swift */; };
|
||||
0AAC75B61E3E24800086BB87 /* DownloadButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAC75B51E3E24800086BB87 /* DownloadButton.swift */; };
|
||||
0AAC75B81E3E25820086BB87 /* GrayButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAC75B71E3E25820086BB87 /* GrayButton.swift */; };
|
||||
57A713EE30F5529EC97CABA2 /* Pods_Youtube_dl_GUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 685C0FDD28B58EDB6BF51860 /* Pods_Youtube_dl_GUI.framework */; };
|
||||
656FE9E68E618252B653F728 /* Pods_Get_It.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F840AEEA491FC0DE6DE63CC /* Pods_Get_It.framework */; };
|
||||
0AFE6EDE20ACB49E002C7693 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFE6EDD20ACB49E002C7693 /* Logger.swift */; };
|
||||
89FEC36FE494806C0C0FAF5E /* Pods_Get_It.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F840AEEA491FC0DE6DE63CC /* Pods_Get_It.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0A2BF1F71E460F170002C5B7 /* optionsTextfield.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = optionsTextfield.swift; sourceTree = "<group>"; };
|
||||
0A2BF1F91E4619230002C5B7 /* secureOptionsTextfield.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = secureOptionsTextfield.swift; sourceTree = "<group>"; };
|
||||
0A3153151CF37A660020DBB8 /* Get It.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Get It.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0A3153181CF37A660020DBB8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
0A31531A1CF37A660020DBB8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
@@ -34,8 +39,10 @@
|
||||
0A59C2711E3D09CE00E40A2B /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||
0A59C2731E3D0C0E00E40A2B /* GetIt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetIt.swift; sourceTree = "<group>"; };
|
||||
0A8DA5D91E3E808500148315 /* AboutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
|
||||
0AAAC76B208664EB009C6ACB /* progressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = progressView.swift; sourceTree = "<group>"; };
|
||||
0AAC75B51E3E24800086BB87 /* DownloadButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadButton.swift; sourceTree = "<group>"; };
|
||||
0AAC75B71E3E25820086BB87 /* GrayButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GrayButton.swift; sourceTree = "<group>"; };
|
||||
0AFE6EDD20ACB49E002C7693 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
2F2FF097A134B03DBD16D354 /* Pods-Youtube-dl-GUI.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Youtube-dl-GUI.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Youtube-dl-GUI/Pods-Youtube-dl-GUI.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
3D0235652B5434027EFB9C78 /* Pods-Get It.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Get It.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Get It/Pods-Get It.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
3F840AEEA491FC0DE6DE63CC /* Pods_Get_It.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Get_It.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -49,8 +56,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57A713EE30F5529EC97CABA2 /* Pods_Youtube_dl_GUI.framework in Frameworks */,
|
||||
656FE9E68E618252B653F728 /* Pods_Get_It.framework in Frameworks */,
|
||||
89FEC36FE494806C0C0FAF5E /* Pods_Get_It.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -106,6 +112,9 @@
|
||||
0A31531E1CF37A660020DBB8 /* Main.storyboard */,
|
||||
0AAC75B51E3E24800086BB87 /* DownloadButton.swift */,
|
||||
0AAC75B71E3E25820086BB87 /* GrayButton.swift */,
|
||||
0A2BF1F71E460F170002C5B7 /* optionsTextfield.swift */,
|
||||
0A2BF1F91E4619230002C5B7 /* secureOptionsTextfield.swift */,
|
||||
0AAAC76B208664EB009C6ACB /* progressView.swift */,
|
||||
);
|
||||
name = View;
|
||||
sourceTree = "<group>";
|
||||
@@ -114,6 +123,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0A59C2731E3D0C0E00E40A2B /* GetIt.swift */,
|
||||
0AFE6EDD20ACB49E002C7693 /* Logger.swift */,
|
||||
);
|
||||
name = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -158,7 +168,6 @@
|
||||
0A3153121CF37A660020DBB8 /* Frameworks */,
|
||||
0A3153131CF37A660020DBB8 /* Resources */,
|
||||
A74C311D5C3277F0388523F0 /* [CP] Embed Pods Frameworks */,
|
||||
9D05C236239CF9791F408CA6 /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -176,7 +185,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0730;
|
||||
LastUpgradeCheck = 0820;
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = "Kevin De Koninck";
|
||||
TargetAttributes = {
|
||||
0A3153141CF37A660020DBB8 = {
|
||||
@@ -195,6 +204,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@@ -227,28 +237,16 @@
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-Get It-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../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";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9D05C236239CF9791F408CA6 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Get It/Pods-Get It-resources.sh\"\n";
|
||||
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;
|
||||
};
|
||||
A74C311D5C3277F0388523F0 /* [CP] Embed Pods Frameworks */ = {
|
||||
@@ -257,14 +255,20 @@
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Get It/Pods-Get It-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/ITSwitch/ITSwitch.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/LetsMove/LetsMove.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/STPrivilegedTask/STPrivilegedTask.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ITSwitch.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LetsMove.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/STPrivilegedTask.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Get It/Pods-Get It-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Get It/Pods-Get It-frameworks.sh\"\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -277,11 +281,15 @@
|
||||
0A59C2721E3D09CE00E40A2B /* Constants.swift in Sources */,
|
||||
0AAC75B81E3E25820086BB87 /* GrayButton.swift in Sources */,
|
||||
0A8DA5DA1E3E808500148315 /* AboutViewController.swift in Sources */,
|
||||
0A2BF1FA1E4619230002C5B7 /* secureOptionsTextfield.swift in Sources */,
|
||||
0A2BF1F81E460F170002C5B7 /* optionsTextfield.swift in Sources */,
|
||||
0AFE6EDE20ACB49E002C7693 /* Logger.swift in Sources */,
|
||||
0A31531B1CF37A660020DBB8 /* ViewController.swift in Sources */,
|
||||
0A59C2701E3D01F400E40A2B /* OptionsViewController.swift in Sources */,
|
||||
0A59C26E1E3D01A700E40A2B /* WindowController.swift in Sources */,
|
||||
0A3153191CF37A660020DBB8 /* AppDelegate.swift in Sources */,
|
||||
0A59C2741E3D0C0E00E40A2B /* GetIt.swift in Sources */,
|
||||
0AAAC76C208664EB009C6ACB /* progressView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -303,19 +311,28 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
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_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@@ -338,7 +355,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
@@ -350,19 +367,28 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
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_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@@ -379,7 +405,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
@@ -397,7 +423,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.KevinDeKoninck.GetIt;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -412,7 +438,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.KevinDeKoninck.GetIt;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0820"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -23,16 +23,25 @@ class AboutViewController: NSViewController {
|
||||
}
|
||||
|
||||
@IBAction func githubBtnClicked(_ sender: Any) {
|
||||
open(website: "https://github.com/Kevin-De-Koninck/Get-It")
|
||||
open(website: "https://kevin-de-koninck.github.io/Get-It/")
|
||||
}
|
||||
|
||||
@IBAction func kBtnClicked(_ sender: Any) {
|
||||
open(website: "https://kevindekoninck.com")
|
||||
@IBAction func supportedSitesBtnClicked(_ sender: Any) {
|
||||
open(website: "https://rg3.github.io/youtube-dl/supportedsites.html")
|
||||
}
|
||||
|
||||
@IBAction func githubYTBtnClicked(_ sender: Any) {
|
||||
open(website: "https://github.com/rg3/youtube-dl")
|
||||
}
|
||||
|
||||
@IBAction func donateBtnClicked(_ sender: Any) {
|
||||
open(website: "https://rg3.github.io/youtube-dl/donations.html")
|
||||
}
|
||||
|
||||
func open(website: String){
|
||||
if let url = URL(string: website), NSWorkspace.shared().open(url) {
|
||||
if let url = URL(string: website), NSWorkspace.shared.open(url) {
|
||||
print("default browser was successfully opened")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,16 +7,13 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import LetsMove
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Insert code here to initialize your application
|
||||
|
||||
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
@@ -27,7 +24,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
PFMoveToApplicationsFolderIfNecessary()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Folder-icon.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "left arrow.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "paypal-icon-614x460.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "r4.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "right arrow.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "safari-icon.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 925 KiB |
+934
-465
File diff suppressed because it is too large
Load Diff
+11
-4
@@ -7,13 +7,19 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Cocoa
|
||||
|
||||
// Command
|
||||
let DEFAULT_COMMAND = "export PATH=$PATH:/usr/local/bin && youtube-dl —yes-playlist —extract-audio —audio-format mp3 —audio-quality 5 —youtube-skip-dash-manifest —sub-format srt —max-filesize 15M —ignore-errors -o ~/Downloads/‘%(title)s.%(ext)s’"
|
||||
let EXPORT_PATH = "export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
|
||||
let DEFAULT_COMMAND = EXPORT_PATH + " && youtube-dl --prefer-ffmpeg --newline —yes-playlist —extract-audio —audio-format mp3 —audio-quality 5 —youtube-skip-dash-manifest —sub-format srt —ignore-errors --no-colorhttps://www.youtube.com/watch?v=LrAx8ZuCFyU -o ~/Downloads/‘%(title)s.%(ext)s’"
|
||||
let DEFAULT_OUTPUTPATH = "~/Downloads/"
|
||||
let REGEX_PATTERN = "(?<=^\\[download\\].)[0-9.]+\\%"
|
||||
|
||||
//Color
|
||||
var blueColor = NSColor.init(red: 45.0/255, green: 135.0/255, blue: 250.0/255, alpha: 1)
|
||||
|
||||
// Settings
|
||||
|
||||
let DEFAULT_SETTINGS = [ "maxFileSize" : "15",
|
||||
let DEFAULT_SETTINGS = [ "maxFileSize" : "",
|
||||
"ignoreErrors" : "1", //bool
|
||||
"path" : "~/Downloads/",
|
||||
"outputTemplate" : "Title.extension",
|
||||
@@ -32,7 +38,6 @@ let DEFAULT_SETTINGS = [ "maxFileSize" : "15",
|
||||
"embedSubs" : "0", //bool
|
||||
"downloadPlaylist" : "1", //bool
|
||||
"reversePlaylist" : "0", //bool
|
||||
// "flatPlaylist" : "0", //bool
|
||||
"startAtVideo" : "",
|
||||
"stopAtVideo" : "",
|
||||
"downloadSpecificVideos": "",
|
||||
@@ -46,3 +51,5 @@ let DEFAULT_SETTINGS = [ "maxFileSize" : "15",
|
||||
// User Defaults - keys
|
||||
let SAVED_COMMAND = "savedCommand"
|
||||
let SETTINGS_KEY = "settings"
|
||||
let OUTPUT_PATH = "outputPath"
|
||||
let OUTPUT_TEMPLATE = "outputTemplate"
|
||||
|
||||
@@ -12,17 +12,20 @@ class DownloadButton: NSButton {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
//GUI
|
||||
self.layer?.backgroundColor = CGColor.init(red: 45.0/255, green: 135.0/255, blue: 250.0/255, alpha: 1)
|
||||
|
||||
self.layer?.backgroundColor = blueColor.cgColor
|
||||
self.layer?.cornerRadius = 15.0
|
||||
self.layer?.masksToBounds = true
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
//text
|
||||
let style = NSMutableParagraphStyle()
|
||||
style.alignment = .center
|
||||
self.attributedTitle = NSAttributedString(string: "Download", attributes: [ NSForegroundColorAttributeName : NSColor.white,
|
||||
NSParagraphStyleAttributeName : style,
|
||||
NSFontAttributeName: NSFont(name: "Arial", size: 18)!])
|
||||
self.attributedTitle = NSAttributedString(string: "Download", attributes: [ NSAttributedString.Key.foregroundColor : NSColor.white,
|
||||
NSAttributedString.Key.paragraphStyle : style,
|
||||
NSAttributedString.Key.font: NSFont(name: "Arial", size: 18)!])
|
||||
}
|
||||
}
|
||||
|
||||
+47
-7
@@ -7,24 +7,64 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import STPrivilegedTask
|
||||
|
||||
class GetIt {
|
||||
var command: String!
|
||||
var isYTDLInstalled: Bool = false
|
||||
var isBrewInstalled: Bool = false
|
||||
var isFfmpegInstalled: Bool = false
|
||||
var isPythonInstalled: Bool = false
|
||||
var isXcodeInstalled: Bool = false
|
||||
var isPycryptoInstalled: Bool = false
|
||||
|
||||
|
||||
init() {
|
||||
loadCmdFromSettings()
|
||||
func getCommand() -> String {
|
||||
if let cmd = UserDefaults.standard.value(forKey: SAVED_COMMAND) as? String {
|
||||
return cmd
|
||||
} else {
|
||||
return DEFAULT_COMMAND
|
||||
}
|
||||
}
|
||||
|
||||
func loadCmdFromSettings(){
|
||||
if let cmd = UserDefaults.standard.value(forKey: SAVED_COMMAND) as? String {
|
||||
self.command = cmd
|
||||
func getOutputPath() -> String {
|
||||
if let path = UserDefaults.standard.value(forKey: OUTPUT_PATH) as? String {
|
||||
return path + "/"
|
||||
} else {
|
||||
self.command = DEFAULT_COMMAND
|
||||
return DEFAULT_SETTINGS["path"]! + "/"
|
||||
}
|
||||
}
|
||||
|
||||
func getOutputTemplate() -> String {
|
||||
if let template = UserDefaults.standard.value(forKey: OUTPUT_TEMPLATE) as? String {
|
||||
return template + " "
|
||||
} else {
|
||||
return DEFAULT_SETTINGS["outputTemplate"]! + " "
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func open(folder: String){
|
||||
_ = self.execute(commandSynchronous: "open \(folder)")
|
||||
}
|
||||
|
||||
|
||||
func execute(commandSynchronous: String) -> String {
|
||||
var arguments:[String] = []
|
||||
arguments.append("-c")
|
||||
arguments.append( EXPORT_PATH + " && " + commandSynchronous + " 2>&1")
|
||||
|
||||
let task = Process()
|
||||
task.launchPath = "/bin/sh"
|
||||
task.arguments = arguments
|
||||
|
||||
let pipe = Pipe()
|
||||
task.standardOutput = pipe
|
||||
task.standardError = pipe
|
||||
task.launch()
|
||||
task.waitUntilExit()
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
|
||||
return(NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ class GrayButton: NSButton {
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
// self.appearance = NSAppearanceNameAqua
|
||||
|
||||
//GUI
|
||||
self.layer?.backgroundColor = CGColor.init(red: 0.3, green: 0.3, blue: 0.3, alpha: 0.3)
|
||||
self.layer?.cornerRadius = 15.0
|
||||
self.layer?.masksToBounds = true
|
||||
|
||||
+3
-3
@@ -17,17 +17,17 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.2</string>
|
||||
<string>0.7</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2</string>
|
||||
<string>69</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2017 Kevin De Koninck. All rights reserved.</string>
|
||||
<string>Copyright © 2019 Kevin De Koninck. All rights reserved.</string>
|
||||
<key>NSMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Logger.swift
|
||||
// Get It
|
||||
//
|
||||
// Created by Kevin De Koninck on 16/05/2018.
|
||||
// Copyright © 2018 Kevin De Koninck. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class Logger {
|
||||
let log_file: String = "/tmp/getit_logs"
|
||||
let install_log_file: String = "/tmp/getit_install"
|
||||
|
||||
func reset() {
|
||||
let cmd = "echo '' > \(self.log_file)"
|
||||
_ = self.execute(commandSynchronous: cmd)
|
||||
}
|
||||
|
||||
func log(tag: String, str: String) {
|
||||
print("\(tag) \(str)")
|
||||
let str_ = str.replacingOccurrences(of: "'", with: "")
|
||||
var cmd = "echo '\(tag)\t\(str_)' >> \(self.log_file)"
|
||||
cmd = cmd.replacingOccurrences(of: "\"", with: "")
|
||||
cmd = cmd.replacingOccurrences(of: "`", with: "")
|
||||
_ = self.execute(commandSynchronous: cmd)
|
||||
}
|
||||
|
||||
func resetInstallLog() {
|
||||
let cmd = "echo '' > \(self.install_log_file)"
|
||||
_ = self.execute(commandSynchronous: cmd)
|
||||
}
|
||||
|
||||
func logInstall(tag: String, str: String) {
|
||||
print("\(tag) \(str)")
|
||||
let str_ = str.replacingOccurrences(of: "'", with: "")
|
||||
var cmd = "echo '\(tag)\t\(str_)' >> \(self.install_log_file)"
|
||||
cmd = cmd.replacingOccurrences(of: "\"", with: "")
|
||||
cmd = cmd.replacingOccurrences(of: "`", with: "")
|
||||
_ = self.execute(commandSynchronous: cmd)
|
||||
}
|
||||
|
||||
func execute(commandSynchronous: String) -> String {
|
||||
var arguments:[String] = []
|
||||
arguments.append("-c")
|
||||
arguments.append( EXPORT_PATH + " && " + commandSynchronous + " 2>&1")
|
||||
|
||||
let task = Process()
|
||||
task.launchPath = "/bin/sh"
|
||||
task.arguments = arguments
|
||||
|
||||
let pipe = Pipe()
|
||||
task.standardOutput = pipe
|
||||
task.standardError = pipe
|
||||
task.launch()
|
||||
task.waitUntilExit()
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
|
||||
return(NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String)
|
||||
}
|
||||
|
||||
}
|
||||
+231
-404
@@ -7,40 +7,43 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import ITSwitch
|
||||
|
||||
class OptionsViewController: NSViewController {
|
||||
|
||||
var getIt = GetIt()
|
||||
|
||||
//General tab
|
||||
@IBOutlet weak var maxFileSize: NSTextField!
|
||||
@IBOutlet weak var ignoreErrors: NSButton!
|
||||
@IBOutlet weak var pathChooser: NSPathCell!
|
||||
@IBOutlet weak var ignoreErrors: ITSwitch!
|
||||
@IBOutlet weak var outputTemplate: NSPopUpButton!
|
||||
@IBOutlet weak var selectedPath: NSTextField!
|
||||
|
||||
@IBOutlet var installProgressView: progressView!
|
||||
@IBOutlet weak var installProgressText: NSTextField!
|
||||
|
||||
//audio tab
|
||||
@IBOutlet weak var extractAudio: NSButton!
|
||||
@IBOutlet weak var extractAudio: ITSwitch!
|
||||
@IBOutlet weak var audioFormat: NSPopUpButton!
|
||||
@IBOutlet weak var audioQuality: NSPopUpButton!
|
||||
@IBOutlet weak var keepVideo: NSButton!
|
||||
@IBOutlet weak var keepVideo: ITSwitch!
|
||||
|
||||
//Video tab
|
||||
@IBOutlet weak var videoFormat: NSPopUpButton!
|
||||
@IBOutlet weak var downloadAllFormats: NSButton!
|
||||
@IBOutlet weak var preferFreeFormats: NSButton!
|
||||
@IBOutlet weak var skipDashManifest: NSButton!
|
||||
@IBOutlet weak var downloadAllFormats: ITSwitch!
|
||||
@IBOutlet weak var preferFreeFormats: ITSwitch!
|
||||
@IBOutlet weak var skipDashManifest: ITSwitch!
|
||||
|
||||
//subtitles tab
|
||||
|
||||
@IBOutlet weak var downloadSubs: NSButton!
|
||||
@IBOutlet weak var downloadAutoSubs: NSButton!
|
||||
@IBOutlet weak var downloadAllSubs: NSButton!
|
||||
@IBOutlet weak var downloadSubs: ITSwitch!
|
||||
@IBOutlet weak var downloadAutoSubs: ITSwitch!
|
||||
@IBOutlet weak var downloadAllSubs: ITSwitch!
|
||||
@IBOutlet weak var languageSubs: NSPopUpButton!
|
||||
@IBOutlet weak var embedSubs: NSButton!
|
||||
@IBOutlet weak var embedSubs: ITSwitch!
|
||||
|
||||
//playlist tab
|
||||
@IBOutlet weak var downloadPlaylist: NSButton!
|
||||
@IBOutlet weak var reversePlaylist: NSButton!
|
||||
// @IBOutlet weak var flatPlaylist: NSButton!
|
||||
@IBOutlet weak var downloadPlaylist: ITSwitch!
|
||||
@IBOutlet weak var reversePlaylist: ITSwitch!
|
||||
@IBOutlet weak var startAtVideo: NSTextField!
|
||||
@IBOutlet weak var stopAtVideo: NSTextField!
|
||||
@IBOutlet weak var downloadSpecificVideos: NSTextField!
|
||||
@@ -49,21 +52,43 @@ class OptionsViewController: NSViewController {
|
||||
@IBOutlet weak var username: NSTextField!
|
||||
@IBOutlet weak var password: NSSecureTextField!
|
||||
@IBOutlet weak var twoFactorCode: NSSecureTextField!
|
||||
@IBOutlet weak var netrc: NSButton!
|
||||
@IBOutlet weak var netrc: ITSwitch!
|
||||
@IBOutlet weak var videoPassword: NSSecureTextField!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.view.wantsLayer = true
|
||||
|
||||
//Switch color
|
||||
ignoreErrors.tintColor = blueColor
|
||||
extractAudio.tintColor = blueColor
|
||||
keepVideo.tintColor = blueColor
|
||||
downloadAllFormats.tintColor = blueColor
|
||||
preferFreeFormats.tintColor = blueColor
|
||||
skipDashManifest.tintColor = blueColor
|
||||
downloadSubs.tintColor = blueColor
|
||||
downloadAutoSubs.tintColor = blueColor
|
||||
downloadAllSubs.tintColor = blueColor
|
||||
embedSubs.tintColor = blueColor
|
||||
downloadPlaylist.tintColor = blueColor
|
||||
reversePlaylist.tintColor = blueColor
|
||||
netrc.tintColor = blueColor
|
||||
|
||||
// progress view
|
||||
installProgressView.isHidden = true
|
||||
installProgressText.isHidden = true
|
||||
|
||||
pathChooser.pathComponentCells.removeAll()
|
||||
//placeholders
|
||||
maxFileSize.placeholderString = "In MB"
|
||||
username.placeholderString = "Enter your username"
|
||||
password.placeholderString = "Enter your password"
|
||||
twoFactorCode.placeholderString = "2FA code"
|
||||
videoPassword.placeholderString = "Enter the password"
|
||||
startAtVideo.placeholderString = "From"
|
||||
stopAtVideo.placeholderString = "To"
|
||||
downloadSpecificVideos.placeholderString = "E.g. 1-3,7,10-13"
|
||||
|
||||
loadSettingsAndSetElements()
|
||||
}
|
||||
@@ -75,30 +100,48 @@ class OptionsViewController: NSViewController {
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillDisappear() {
|
||||
super.viewWillDisappear()
|
||||
|
||||
//we want to save the settings
|
||||
saveSettings()
|
||||
UserDefaults.standard.setValue(createCommand(), forKey: SAVED_COMMAND)
|
||||
|
||||
//save output template
|
||||
var template: String = ""
|
||||
switch outputTemplate.selectedItem!.tag {
|
||||
case 0: template = "'%(title)s.%(ext)s'"
|
||||
case 1: template = "'%(playlist)s/%(title)s.%(ext)s'"
|
||||
case 2: template = "'%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'"
|
||||
default: template = "'%(title)s.%(ext)s'"
|
||||
}
|
||||
|
||||
UserDefaults.standard.setValue(template, forKey: OUTPUT_TEMPLATE)
|
||||
UserDefaults.standard.synchronize()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@IBAction func installSoftwareBtnClicked(_ sender: Any) {
|
||||
installProgressView.isHidden = false
|
||||
installProgressText.isHidden = false
|
||||
_ = getIt.execute(commandSynchronous: "if ! xcode-select -v &> /dev/null; then xcode-select --install; fi; if brew -v &> /dev/null; then brew update; else echo /usr/bin/ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'; fi; if brew ls --versions python &> /dev/null; then brew upgrade python; else brew install python; brew link python; fi; if brew ls --versions python3 &> /dev/null; then brew upgrade python3; else brew install python3; fi; if pip2.7 list | grep -i pycrypt &> /dev/null; then pip2.7 install pycrypt --upgrade; else pip2.7 install pycrypt; fi; if youtube-dl --version &> /dev/null; then brew upgrade youtube-dl; else brew install youtube-dl; fi; if brew list libav &> /dev/null; then brew upgrade libav; else brew install libav; fi; if brew list ffmpeg &> /dev/null; then brew upgrade ffmpeg; else brew install ffmpeg; fi")
|
||||
installProgressView.isHidden = true
|
||||
installProgressText.isHidden = true
|
||||
}
|
||||
|
||||
@IBAction func loadDefaultsBtnClicked(_ sender: Any) {
|
||||
UserDefaults.standard.set(DEFAULT_SETTINGS, forKey: SETTINGS_KEY)
|
||||
UserDefaults.standard.setValue(DEFAULT_SETTINGS["path"]!, forKey: OUTPUT_PATH)
|
||||
UserDefaults.standard.synchronize()
|
||||
loadSettingsAndSetElements()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func saveSettings() {
|
||||
var settingsDict = [String: String]()
|
||||
|
||||
let pathString = pathChooser.url?.path.characters.split{$0 == "\""}.map(String.init) //item to string
|
||||
|
||||
|
||||
settingsDict["maxFileSize"] = maxFileSize.stringValue
|
||||
settingsDict["ignoreErrors"] = String(ignoreErrors.state)
|
||||
settingsDict["path"] = pathString![0]
|
||||
|
||||
settingsDict["maxFileSize"] = maxFileSize.stringValue.replacingOccurrences(of: ".", with: "").replacingOccurrences(of: ",", with: "")
|
||||
settingsDict["ignoreErrors"] = String(ignoreErrors.checked) == "true" ? "1" : "0"
|
||||
settingsDict["path"] = UserDefaults.standard.value(forKey: OUTPUT_PATH) as? String
|
||||
settingsDict["outputTemplate"] = outputTemplate.itemTitle(at: outputTemplate.indexOfSelectedItem)
|
||||
settingsDict["audioFormat"] = audioFormat.itemTitle(at: audioFormat.indexOfSelectedItem)
|
||||
settingsDict["audioQuality"] = audioQuality.itemTitle(at: audioQuality.indexOfSelectedItem)
|
||||
@@ -111,364 +154,164 @@ class OptionsViewController: NSViewController {
|
||||
settingsDict["password"] = password.stringValue
|
||||
settingsDict["twoFactorCode"] = twoFactorCode.stringValue
|
||||
settingsDict["videoPassword"] = videoPassword.stringValue
|
||||
settingsDict["extractAudio"] = String(extractAudio.state)
|
||||
settingsDict["keepVideo"] = String(keepVideo.state)
|
||||
settingsDict["downloadAllFormats"] = String(downloadAllFormats.state)
|
||||
settingsDict["preferFreeFormats"] = String(preferFreeFormats.state)
|
||||
settingsDict["skipDashManifest"] = String(skipDashManifest.state)
|
||||
settingsDict["downloadSubs"] = String(downloadSubs.state)
|
||||
settingsDict["downloadAutoSubs"] = String(downloadAutoSubs.state)
|
||||
settingsDict["downloadAllSubs"] = String(downloadAllSubs.state)
|
||||
settingsDict["embedSubs"] = String(embedSubs.state)
|
||||
settingsDict["downloadPlaylist"] = String(downloadPlaylist.state)
|
||||
settingsDict["reversePlaylist"] = String(reversePlaylist.state)
|
||||
// settingsDict["flatPlaylist"] = String(flatPlaylist.state)
|
||||
settingsDict["netrc"] = String(netrc.state)
|
||||
settingsDict["extractAudio"] = String(extractAudio.checked) == "true" ? "1" : "0"
|
||||
settingsDict["keepVideo"] = String(keepVideo.checked) == "true" ? "1" : "0"
|
||||
settingsDict["downloadAllFormats"] = String(downloadAllFormats.checked) == "true" ? "1" : "0"
|
||||
settingsDict["preferFreeFormats"] = String(preferFreeFormats.checked) == "true" ? "1" : "0"
|
||||
settingsDict["skipDashManifest"] = String(skipDashManifest.checked) == "true" ? "1" : "0"
|
||||
settingsDict["downloadSubs"] = String(downloadSubs.checked) == "true" ? "1" : "0"
|
||||
settingsDict["downloadAutoSubs"] = String(downloadAutoSubs.checked) == "true" ? "1" : "0"
|
||||
settingsDict["downloadAllSubs"] = String(downloadAllSubs.checked) == "true" ? "1" : "0"
|
||||
settingsDict["embedSubs"] = String(embedSubs.checked) == "true" ? "1" : "0"
|
||||
settingsDict["downloadPlaylist"] = String(downloadPlaylist.checked) == "true" ? "1" : "0"
|
||||
settingsDict["reversePlaylist"] = String(reversePlaylist.checked) == "true" ? "1" : "0"
|
||||
settingsDict["netrc"] = String(netrc.checked) == "true" ? "1" : "0"
|
||||
|
||||
UserDefaults.standard.set(settingsDict, forKey: SETTINGS_KEY)
|
||||
UserDefaults.standard.synchronize()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func loadSettingsAndSetElements() {
|
||||
|
||||
if let arr = UserDefaults.standard.value(forKey: SETTINGS_KEY) as? [String:String] {
|
||||
|
||||
if let val = arr["maxFileSize"] {
|
||||
maxFileSize.stringValue = val
|
||||
} else {
|
||||
maxFileSize.stringValue = DEFAULT_SETTINGS["maxFileSize"]!
|
||||
}
|
||||
|
||||
if let val = arr["ignoreErrors"], val != "" {
|
||||
ignoreErrors.state = Int(val)!
|
||||
} else {
|
||||
ignoreErrors.state = Int(DEFAULT_SETTINGS["ignoreErrors"]!)!
|
||||
}
|
||||
|
||||
//TODO: fix the path
|
||||
if let val = arr["path"] {
|
||||
pathChooser.url = URL.init(fileURLWithPath: val)
|
||||
} else {
|
||||
pathChooser.url = URL.init(fileURLWithPath: DEFAULT_SETTINGS["path"]!)
|
||||
}
|
||||
|
||||
if let val = arr["outputTemplate"] {
|
||||
outputTemplate.select(outputTemplate.item(withTitle: val))
|
||||
} else {
|
||||
outputTemplate.select(outputTemplate.item(withTitle: DEFAULT_SETTINGS["outputTemplate"]!))
|
||||
}
|
||||
|
||||
if let val = arr["extractAudio"] {
|
||||
extractAudio.state = Int(val)!
|
||||
} else {
|
||||
extractAudio.state = Int(DEFAULT_SETTINGS["extractAudio"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["audioFormat"] {
|
||||
audioFormat.select(audioFormat.item(withTitle: val))
|
||||
} else {
|
||||
audioFormat.select(audioFormat.item(withTitle: DEFAULT_SETTINGS["audioFormat"]!))
|
||||
}
|
||||
|
||||
if let val = arr["audioQuality"] {
|
||||
audioQuality.select(audioQuality.item(withTitle: val))
|
||||
} else {
|
||||
audioQuality.select(audioQuality.item(withTitle: DEFAULT_SETTINGS["audioQuality"]!))
|
||||
}
|
||||
|
||||
if let val = arr["keepVideo"] {
|
||||
keepVideo.state = Int(val)!
|
||||
} else {
|
||||
keepVideo.state = Int(DEFAULT_SETTINGS["keepVideo"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["videoFormat"] {
|
||||
videoFormat.selectItem(at: Int(val)!)
|
||||
} else {
|
||||
videoFormat.selectItem(at: Int(DEFAULT_SETTINGS["videoFormat"]!)!)
|
||||
}
|
||||
|
||||
if let val = arr["downloadAllFormats"] {
|
||||
downloadAllFormats.state = Int(val)!
|
||||
} else {
|
||||
downloadAllFormats.state = Int(DEFAULT_SETTINGS["downloadAllFormats"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["preferFreeFormats"] {
|
||||
preferFreeFormats.state = Int(val)!
|
||||
} else {
|
||||
preferFreeFormats.state = Int(DEFAULT_SETTINGS["preferFreeFormats"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["skipDashManifest"] {
|
||||
skipDashManifest.state = Int(val)!
|
||||
} else {
|
||||
skipDashManifest.state = Int(DEFAULT_SETTINGS["skipDashManifest"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["downloadSubs"] {
|
||||
downloadSubs.state = Int(val)!
|
||||
} else {
|
||||
downloadSubs.state = Int(DEFAULT_SETTINGS["downloadSubs"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["downloadAutoSubs"] {
|
||||
downloadAutoSubs.state = Int(val)!
|
||||
} else {
|
||||
downloadAutoSubs.state = Int(DEFAULT_SETTINGS["downloadAutoSubs"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["downloadAllSubs"] {
|
||||
downloadAllSubs.state = Int(val)!
|
||||
} else {
|
||||
downloadAllSubs.state = Int(DEFAULT_SETTINGS["downloadAllSubs"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["embedSubs"] {
|
||||
embedSubs.state = Int(val)!
|
||||
} else {
|
||||
embedSubs.state = Int(DEFAULT_SETTINGS["embedSubs"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["languageSubs"] {
|
||||
languageSubs.selectItem(at: Int(val)!)
|
||||
} else {
|
||||
languageSubs.selectItem(at: Int(DEFAULT_SETTINGS["languageSubs"]!)!)
|
||||
}
|
||||
|
||||
if let val = arr["downloadPlaylist"] {
|
||||
downloadPlaylist.state = Int(val)!
|
||||
} else {
|
||||
downloadPlaylist.state = Int(DEFAULT_SETTINGS["downloadPlaylist"]!)!
|
||||
}
|
||||
|
||||
if let val = arr["reversePlaylist"] {
|
||||
reversePlaylist.state = Int(val)!
|
||||
} else {
|
||||
reversePlaylist.state = Int(DEFAULT_SETTINGS["reversePlaylist"]!)!
|
||||
//Get and set all saved settings
|
||||
if arr["path"] != nil {
|
||||
if let temp = UserDefaults.standard.value(forKey: OUTPUT_PATH) as? String {
|
||||
selectedPath.stringValue = NSURL(fileURLWithPath: temp).lastPathComponent!
|
||||
} else { // BUG FIX
|
||||
UserDefaults.standard.setValue(DEFAULT_OUTPUTPATH, forKey: OUTPUT_PATH)
|
||||
UserDefaults.standard.synchronize()
|
||||
selectedPath.stringValue = NSURL(fileURLWithPath: DEFAULT_OUTPUTPATH).lastPathComponent!
|
||||
}
|
||||
}
|
||||
else { selectedPath.stringValue = DEFAULT_SETTINGS["path"]! }
|
||||
|
||||
// if let val = arr["flatPlaylist"] {
|
||||
// flatPlaylist.state = Int(val)!
|
||||
// } else {
|
||||
// flatPlaylist.state = Int(DEFAULT_SETTINGS["flatPlaylist"]!)!
|
||||
// }
|
||||
if let val = arr["maxFileSize"] { maxFileSize.stringValue = val }
|
||||
else { maxFileSize.stringValue = DEFAULT_SETTINGS["maxFileSize"]! }
|
||||
|
||||
if let val = arr["startAtVideo"] {
|
||||
startAtVideo.stringValue = val
|
||||
} else {
|
||||
startAtVideo.stringValue = DEFAULT_SETTINGS["startAtVideo"]!
|
||||
}
|
||||
if let val = arr["ignoreErrors"] { ignoreErrors.checked = val == "1" ? true : false }
|
||||
else { ignoreErrors.checked = DEFAULT_SETTINGS["ignoreErrors"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["stopAtVideo"] {
|
||||
stopAtVideo.stringValue = val
|
||||
} else {
|
||||
stopAtVideo.stringValue = DEFAULT_SETTINGS["stopAtVideo"]!
|
||||
}
|
||||
if let val = arr["outputTemplate"] { outputTemplate.select(outputTemplate.item(withTitle: val)) }
|
||||
else { outputTemplate.select(outputTemplate.item(withTitle: DEFAULT_SETTINGS["outputTemplate"]!)) }
|
||||
|
||||
if let val = arr["downloadSpecificVideos"] {
|
||||
downloadSpecificVideos.stringValue = val
|
||||
} else {
|
||||
downloadSpecificVideos.stringValue = DEFAULT_SETTINGS["downloadSpecificVideos"]!
|
||||
}
|
||||
if let val = arr["extractAudio"] { extractAudio.checked = val == "1" ? true : false }
|
||||
else { extractAudio.checked = DEFAULT_SETTINGS["extractAudio"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["username"] {
|
||||
username.stringValue = val
|
||||
} else {
|
||||
username.stringValue = DEFAULT_SETTINGS["username"]!
|
||||
}
|
||||
if let val = arr["audioFormat"] { audioFormat.select(audioFormat.item(withTitle: val)) }
|
||||
else { audioFormat.select(audioFormat.item(withTitle: DEFAULT_SETTINGS["audioFormat"]!)) }
|
||||
|
||||
if let val = arr["password"] {
|
||||
password.stringValue = val
|
||||
} else {
|
||||
password.stringValue = DEFAULT_SETTINGS["password"]!
|
||||
}
|
||||
if let val = arr["audioQuality"] { audioQuality.select(audioQuality.item(withTitle: val)) }
|
||||
else { audioQuality.select(audioQuality.item(withTitle: DEFAULT_SETTINGS["audioQuality"]!)) }
|
||||
|
||||
if let val = arr["twoFactorCode"] {
|
||||
twoFactorCode.stringValue = val
|
||||
} else {
|
||||
twoFactorCode.stringValue = DEFAULT_SETTINGS["twoFactorCode"]!
|
||||
}
|
||||
if let val = arr["keepVideo"] { keepVideo.checked = val == "1" ? true : false }
|
||||
else { keepVideo.checked = DEFAULT_SETTINGS["keepVideo"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["netrc"] {
|
||||
netrc.state = Int(val)!
|
||||
} else {
|
||||
netrc.state = Int(DEFAULT_SETTINGS["netrc"]!)!
|
||||
}
|
||||
if let val = arr["videoFormat"] { videoFormat.selectItem(at: Int(val)!) }
|
||||
else { videoFormat.selectItem(at: Int(DEFAULT_SETTINGS["videoFormat"]!)!) }
|
||||
|
||||
if let val = arr["videoPassword"] {
|
||||
videoPassword.stringValue = val
|
||||
} else {
|
||||
videoPassword.stringValue = DEFAULT_SETTINGS["videoPassword"]!
|
||||
}
|
||||
if let val = arr["downloadAllFormats"] { downloadAllFormats.checked = val == "1" ? true : false }
|
||||
else { downloadAllFormats.checked = DEFAULT_SETTINGS["downloadAllFormats"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["preferFreeFormats"] { preferFreeFormats.checked = val == "1" ? true : false }
|
||||
else { preferFreeFormats.checked = DEFAULT_SETTINGS["preferFreeFormats"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["skipDashManifest"] { skipDashManifest.checked = val == "1" ? true : false }
|
||||
else { skipDashManifest.checked = DEFAULT_SETTINGS["skipDashManifest"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["downloadSubs"] { downloadSubs.checked = val == "1" ? true : false }
|
||||
else { downloadSubs.checked = DEFAULT_SETTINGS["downloadSubs"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["downloadAutoSubs"] { downloadAutoSubs.checked = val == "1" ? true : false }
|
||||
else { downloadAutoSubs.checked = DEFAULT_SETTINGS["downloadAutoSubs"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["downloadAllSubs"] { downloadAllSubs.checked = val == "1" ? true : false }
|
||||
else { downloadAllSubs.checked = DEFAULT_SETTINGS["downloadAllSubs"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["embedSubs"] { embedSubs.checked = val == "1" ? true : false }
|
||||
else { embedSubs.checked = DEFAULT_SETTINGS["embedSubs"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["languageSubs"] { languageSubs.selectItem(at: Int(val)!) }
|
||||
else { languageSubs.selectItem(at: Int(DEFAULT_SETTINGS["languageSubs"]!)!) }
|
||||
|
||||
if let val = arr["downloadPlaylist"] { downloadPlaylist.checked = val == "1" ? true : false }
|
||||
else { downloadPlaylist.checked = DEFAULT_SETTINGS["downloadPlaylist"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["reversePlaylist"] { reversePlaylist.checked = val == "1" ? true : false }
|
||||
else { reversePlaylist.checked = DEFAULT_SETTINGS["reversePlaylist"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["startAtVideo"] { startAtVideo.stringValue = val }
|
||||
else { startAtVideo.stringValue = DEFAULT_SETTINGS["startAtVideo"]! }
|
||||
|
||||
if let val = arr["stopAtVideo"] { stopAtVideo.stringValue = val }
|
||||
else { stopAtVideo.stringValue = DEFAULT_SETTINGS["stopAtVideo"]! }
|
||||
|
||||
if let val = arr["downloadSpecificVideos"] { downloadSpecificVideos.stringValue = val }
|
||||
else { downloadSpecificVideos.stringValue = DEFAULT_SETTINGS["downloadSpecificVideos"]! }
|
||||
|
||||
if let val = arr["username"] { username.stringValue = val }
|
||||
else { username.stringValue = DEFAULT_SETTINGS["username"]! }
|
||||
|
||||
if let val = arr["password"] { password.stringValue = val }
|
||||
else { password.stringValue = DEFAULT_SETTINGS["password"]! }
|
||||
|
||||
if let val = arr["twoFactorCode"] { twoFactorCode.stringValue = val }
|
||||
else { twoFactorCode.stringValue = DEFAULT_SETTINGS["twoFactorCode"]! }
|
||||
|
||||
if let val = arr["netrc"] { netrc.checked = val == "1" ? true : false }
|
||||
else { netrc.checked = DEFAULT_SETTINGS["netrc"]! == "1" ? true : false }
|
||||
|
||||
if let val = arr["videoPassword"] { videoPassword.stringValue = val }
|
||||
else { videoPassword.stringValue = DEFAULT_SETTINGS["videoPassword"]!}
|
||||
|
||||
} else {
|
||||
// No saved settings, save the defaults and retry
|
||||
// No saved settings?, save the defaults and retry
|
||||
UserDefaults.standard.setValue(DEFAULT_SETTINGS, forKey: SETTINGS_KEY)
|
||||
UserDefaults.standard.synchronize()
|
||||
loadSettingsAndSetElements()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func createCommand() -> String {
|
||||
|
||||
/*****************
|
||||
* create command *
|
||||
******************/
|
||||
//Start of creating the command
|
||||
var command = EXPORT_PATH + " && youtube-dl --newline --prefer-ffmpeg";
|
||||
|
||||
var command = "export PATH=$PATH:/usr/local/bin && youtube-dl";
|
||||
|
||||
/*****************
|
||||
* Playlist tab *
|
||||
******************/
|
||||
|
||||
//append "download playlist" to command
|
||||
if downloadPlaylist.state == 1 {
|
||||
command += " --yes-playlist"
|
||||
}
|
||||
else{
|
||||
command += " --no-playlist"
|
||||
}
|
||||
|
||||
//append "download playlist in reverse" to command
|
||||
if reversePlaylist.state == 1 {
|
||||
command += " --playlist-reverse"
|
||||
}
|
||||
|
||||
// //append "flat playlist" to command
|
||||
// if flatPlaylist.state == 1 {
|
||||
// command += " --flat-playlist"
|
||||
// }
|
||||
|
||||
//append ""start at video" to command
|
||||
if !startAtVideo.stringValue.isEmpty {
|
||||
command += " --playlist-start \(startAtVideo.stringValue)"
|
||||
}
|
||||
|
||||
//append "stop at video" to command
|
||||
if !stopAtVideo.stringValue.isEmpty {
|
||||
command += " --playlist-end \(stopAtVideo.stringValue)"
|
||||
}
|
||||
|
||||
//append "download specific videos" to command
|
||||
if !downloadSpecificVideos.stringValue.isEmpty {
|
||||
command += " --playlist-items \(downloadSpecificVideos.stringValue)"
|
||||
}
|
||||
|
||||
|
||||
/***********************
|
||||
* Authentication tab *
|
||||
************************/
|
||||
|
||||
//append "username" to command
|
||||
if !username.stringValue.isEmpty {
|
||||
command += " --username \(username.stringValue)"
|
||||
}
|
||||
|
||||
//append "password" to command
|
||||
if !password.stringValue.isEmpty {
|
||||
command += " --password \(password.stringValue)"
|
||||
}
|
||||
|
||||
//append "2 factor authentication code" to command
|
||||
if !twoFactorCode.stringValue.isEmpty {
|
||||
command += " --twofactor \(twoFactorCode.stringValue)"
|
||||
}
|
||||
|
||||
//append "video password" to command
|
||||
if !videoPassword.stringValue.isEmpty {
|
||||
command += " --video-password \(videoPassword.stringValue)"
|
||||
}
|
||||
|
||||
//append "netrc" to command
|
||||
if netrc.state == 1 {
|
||||
command += " --netrc"
|
||||
}
|
||||
|
||||
|
||||
/*****************
|
||||
* Audio tab *
|
||||
******************/
|
||||
|
||||
//append extract audio to command
|
||||
if extractAudio.state == 1 {
|
||||
command += " --extract-audio"
|
||||
}
|
||||
|
||||
//append audio format to command
|
||||
let audioFormatString = audioFormat.selectedItem?.title.characters.split{$0 == "\""}.map(String.init) //item to string
|
||||
command += " --audio-format \(audioFormatString![0])"
|
||||
|
||||
//append audio quality to command
|
||||
let audioQualityString = audioQuality.selectedItem!.title.characters.split{$0 == "\""}.map(String.init) //item to string
|
||||
let audioQ = audioQualityString.first!.characters.first
|
||||
command += " --audio-quality \(audioQ!)"
|
||||
|
||||
//append "keep video" to command
|
||||
if keepVideo.state == 1 {
|
||||
command += " --keep-video"
|
||||
}
|
||||
|
||||
/*****************
|
||||
* Video tab *
|
||||
******************/
|
||||
|
||||
//append "video format" to command
|
||||
//Preprocessing
|
||||
let audioFormatString = audioFormat.selectedItem?.title.split{$0 == "\""}.map(String.init)
|
||||
let audioQualityString = audioQuality.selectedItem!.title.split{$0 == "\""}.map(String.init)
|
||||
let videoFormatString = videoFormat.selectedItem!.tag
|
||||
if videoFormatString > 0 {
|
||||
command += " --format \(videoFormatString)"
|
||||
}
|
||||
let audioQ = audioQualityString.first!.first
|
||||
|
||||
//append "download all formats" to command
|
||||
if downloadAllFormats.state == 1 {
|
||||
command += " --all-formats"
|
||||
}
|
||||
|
||||
//append "prefer free formats" to command
|
||||
if preferFreeFormats.state == 1 {
|
||||
command += " --prefer-free-formats "
|
||||
}
|
||||
|
||||
//append "skip dash manifest" to command
|
||||
if skipDashManifest.state == 1 {
|
||||
command += " --youtube-skip-dash-manifest"
|
||||
}
|
||||
|
||||
|
||||
/********************
|
||||
* Subtitles tab *
|
||||
*********************/
|
||||
//Creating the command
|
||||
if downloadPlaylist.checked { command += " --yes-playlist" } else { command += " --no-playlist" }
|
||||
if reversePlaylist.checked { command += " --playlist-reverse" }
|
||||
if !startAtVideo.stringValue.isEmpty { command += " --playlist-start \(startAtVideo.stringValue)" }
|
||||
if !stopAtVideo.stringValue.isEmpty { command += " --playlist-end \(stopAtVideo.stringValue)" }
|
||||
if !downloadSpecificVideos.stringValue.isEmpty { command += " --playlist-items \(downloadSpecificVideos.stringValue)" }
|
||||
if !username.stringValue.isEmpty { command += " --username \(username.stringValue)" }
|
||||
if !password.stringValue.isEmpty { command += " --password \(password.stringValue)" }
|
||||
if !twoFactorCode.stringValue.isEmpty { command += " --twofactor \(twoFactorCode.stringValue)" }
|
||||
if !videoPassword.stringValue.isEmpty { command += " --video-password \(videoPassword.stringValue)" }
|
||||
if netrc.checked { command += " --netrc" }
|
||||
if extractAudio.checked { command += " --extract-audio" }
|
||||
if keepVideo.checked { command += " --keep-video" }
|
||||
if videoFormatString > 0 { command += " --format \(videoFormatString)" }
|
||||
if downloadAllFormats.checked { command += " --all-formats" }
|
||||
if preferFreeFormats.checked { command += " --prefer-free-formats " }
|
||||
if skipDashManifest.checked { command += " --youtube-skip-dash-manifest" }
|
||||
if downloadSubs.checked { command += " --write-sub" }
|
||||
if downloadAutoSubs.checked { command += " --write-auto-sub" }
|
||||
if downloadAllSubs.checked { command += " --all-subs" }
|
||||
if embedSubs.checked { command += " --embed-subs" }
|
||||
if !maxFileSize.stringValue.isEmpty { command += " --max-filesize \(maxFileSize.stringValue.replacingOccurrences(of: ".", with: "").replacingOccurrences(of: ",", with: ""))M" }
|
||||
if ignoreErrors.checked == true { command += " --ignore-errors" } else { command += " --abort-on-error" }
|
||||
|
||||
command += " --audio-format \(audioFormatString![0])"
|
||||
command += " --audio-quality \(audioQ!)"
|
||||
command += " --sub-format srt" //always SRT
|
||||
|
||||
//append "download subtitles" to command
|
||||
if downloadSubs.state == 1 {
|
||||
command += " --write-sub"
|
||||
}
|
||||
|
||||
//append "download auto subtitles" to command
|
||||
if downloadAutoSubs.state == 1 {
|
||||
command += " --write-auto-sub"
|
||||
}
|
||||
|
||||
//append "download all subtitles" to command
|
||||
if downloadAllSubs.state == 1 {
|
||||
command += " --all-subs"
|
||||
}
|
||||
|
||||
//append "embed subtitles" to command
|
||||
if embedSubs.state == 1 {
|
||||
command += " --embed-subs"
|
||||
}
|
||||
|
||||
//append "language subs" to command
|
||||
if languageSubs.selectedItem!.tag > 0 {
|
||||
var subLanguage = ""
|
||||
switch languageSubs.selectedItem!.tag {
|
||||
@@ -481,58 +324,42 @@ class OptionsViewController: NSViewController {
|
||||
case 7: subLanguage = "es"
|
||||
case 8: subLanguage = "de"
|
||||
case 9: subLanguage = "nl"
|
||||
case 10: subLanguage = "zh-Hans"
|
||||
case 11: subLanguage = "zh-Hant"
|
||||
default: subLanguage = "en"
|
||||
}
|
||||
command += " --sub-lang \(subLanguage)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************
|
||||
* General tab *
|
||||
******************/
|
||||
|
||||
//append max file size to command
|
||||
if !maxFileSize.stringValue.isEmpty {
|
||||
command += " --max-filesize \(maxFileSize.stringValue)M"
|
||||
}
|
||||
|
||||
//append ignore errors to command
|
||||
if ignoreErrors.state == 1 {
|
||||
command += " --ignore-errors"
|
||||
}
|
||||
else{
|
||||
command += " --abort-on-error"
|
||||
}
|
||||
|
||||
//append output destination to command
|
||||
let pathString = pathChooser.url?.path.characters.split{$0 == "\""}.map(String.init) //item to string
|
||||
command += " -o \(pathString![0])/"
|
||||
|
||||
//append output template
|
||||
switch outputTemplate.selectedItem!.tag {
|
||||
case 0: command += "'%(title)s.%(ext)s'"
|
||||
case 1: command += "'%(playlist)s/%(title)s.%(ext)s'"
|
||||
case 2: command += "'%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'"
|
||||
default: command += "'%(title)s.%(ext)s'"
|
||||
|
||||
}
|
||||
|
||||
//append input URLs to the command
|
||||
// for url in inputURLS_array {
|
||||
// command += " \(url)"
|
||||
// }
|
||||
//
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
override func viewWillDisappear() {
|
||||
super.viewWillDisappear()
|
||||
//we want to save the settings
|
||||
saveSettings()
|
||||
UserDefaults.standard.setValue(createCommand(), forKey: SAVED_COMMAND)
|
||||
UserDefaults.standard.synchronize()
|
||||
}
|
||||
|
||||
@IBAction func folderIconClicked(_ sender: Any) {
|
||||
let dialog = NSOpenPanel();
|
||||
|
||||
dialog.title = "Choose a folder"
|
||||
dialog.showsResizeIndicator = true
|
||||
dialog.showsHiddenFiles = false
|
||||
dialog.canChooseFiles = false
|
||||
dialog.canChooseDirectories = true
|
||||
dialog.canCreateDirectories = true
|
||||
dialog.allowsMultipleSelection = false
|
||||
|
||||
if (dialog.runModal() == NSApplication.ModalResponse.OK) {
|
||||
let result = dialog.url
|
||||
if (result != nil) {
|
||||
let path = result!.path
|
||||
UserDefaults.standard.setValue(path, forKey: OUTPUT_PATH)
|
||||
UserDefaults.standard.synchronize()
|
||||
|
||||
selectedPath.stringValue = NSURL(fileURLWithPath: path).lastPathComponent!
|
||||
}
|
||||
}
|
||||
|
||||
//post notification to viewcontroller.swift to open the settingsview again (segue)
|
||||
NotificationCenter.default.post(NSNotification(name: NSNotification.Name(rawValue: "openSettingsView"), object: nil) as Notification)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+171
-94
@@ -7,23 +7,9 @@
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO: youtube-dl --extract-audio --audio-quality 0 --newline https://www.youtube.com/playlist?list=PL1C815DB73EC2678E | perl -nle 'print $& if m{^\[download\].*?\K([0-9.]+\%|#\d+ of \d)}'
|
||||
// voor progress bar
|
||||
// beginnen met file 1 en bij elke 100% 1 optellen en wnnr op 100% dan postprocess zetten tot next % gekregen
|
||||
|
||||
|
||||
//TODO: check if youtube-dl is installed on boot up: if brew ls --versions youtube-dl > /dev/null; then echo INSTALLED; else echo NOT INSTALLED; fi
|
||||
// if not, then disable all buttons except the package icon that will start a guide on how to install it.
|
||||
|
||||
//TODO: check if homebrew is installed: [ ! -f "`which breww`" ] && echo NOT INSTALLED (check on output: NOT INSTALLED)
|
||||
|
||||
//TODO: make a guide
|
||||
|
||||
//TODO: create about screen
|
||||
|
||||
//TODO: regex check for urls in input field
|
||||
|
||||
|
||||
@@ -31,43 +17,107 @@ import Cocoa
|
||||
|
||||
class ViewController: NSViewController {
|
||||
|
||||
//input and output GUI elements
|
||||
@IBOutlet var inputURLS: NSTextView!
|
||||
// @IBOutlet var outputWindow: NSTextView!
|
||||
@IBOutlet weak var settingsBtn: NSButton!
|
||||
@IBOutlet weak var openDestinationFolderBtn: GrayButton!
|
||||
@IBOutlet weak var downloadBtn: DownloadButton!
|
||||
@IBOutlet weak var progressV: progressView!
|
||||
@IBOutlet weak var progressTitle: NSTextField!
|
||||
@IBOutlet weak var progressDetails: NSTextField!
|
||||
|
||||
|
||||
|
||||
//global variables
|
||||
var getIt = GetIt()
|
||||
var logger = Logger()
|
||||
var downloadingFileNr: Int = 1
|
||||
var previousProgress: CGFloat = 0.0
|
||||
var currentProgress: CGFloat = 0.0
|
||||
var downloadsDidStart: Bool = false
|
||||
|
||||
//****************************************************************************************************************
|
||||
//****************************************************************************************************************
|
||||
|
||||
override func awakeFromNib() {
|
||||
if self.view.layer != nil {
|
||||
let color : CGColor = CGColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
||||
self.view.layer?.backgroundColor = color
|
||||
}
|
||||
}
|
||||
|
||||
//will excecute when we psuh on the download-button
|
||||
@IBAction func downloadButton(_ sender: AnyObject) {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(openSettingsView), name: NSNotification.Name(rawValue: "openSettingsView"), object: nil)
|
||||
}
|
||||
@objc func openSettingsView(notif: AnyObject) {
|
||||
self.performSegue(withIdentifier: "settingsSegue", sender: self)
|
||||
}
|
||||
|
||||
//get input URLs and devide them in an array
|
||||
let tempString = inputURLS.string!
|
||||
let inputURLS_array = tempString.characters.split{$0 == "\n"}.map(String.init) //array: inputURL[0] inputURL[1] ...
|
||||
|
||||
override func viewWillAppear() {
|
||||
super.viewWillAppear()
|
||||
dismissProgressView()
|
||||
}
|
||||
|
||||
func activateComponents(activate: Bool) {
|
||||
inputURLS.isEditable = activate
|
||||
settingsBtn.isEnabled = activate
|
||||
openDestinationFolderBtn.isEnabled = activate
|
||||
downloadBtn.isEnabled = activate
|
||||
}
|
||||
|
||||
func dismissProgressView() {
|
||||
self.activateComponents(activate: true)
|
||||
progressV.isHidden = true
|
||||
progressTitle.isHidden = true
|
||||
progressDetails.isHidden = true
|
||||
}
|
||||
|
||||
func showInProgressView(title: String, details: String) {
|
||||
self.activateComponents(activate: false)
|
||||
progressV.isHidden = false
|
||||
progressTitle.isHidden = false
|
||||
progressDetails.isHidden = false
|
||||
progressTitle.stringValue = title
|
||||
progressDetails.stringValue = details
|
||||
logger.log(tag: "[PROGRESS VIEW]", str: "\(title): \(details)")
|
||||
}
|
||||
|
||||
@IBAction func openDestinationFolderBtnClicked(_ sender: Any) {
|
||||
_ = getIt.open(folder: UserDefaults.standard.value(forKey: OUTPUT_PATH) as! String)
|
||||
}
|
||||
|
||||
|
||||
/********************
|
||||
* EXCECUTE COMMAND *
|
||||
*********************/
|
||||
@IBAction func downloadButton(_ sender: AnyObject) {
|
||||
logger.reset()
|
||||
|
||||
func execute(command: String){
|
||||
//get input URLs
|
||||
let tempString = inputURLS.string
|
||||
let urls = tempString.split{$0 == "\n"}.map(String.init)
|
||||
if(urls.count > 0){
|
||||
var urlStr = " "
|
||||
for url in urls { urlStr = urlStr + url + " " }
|
||||
|
||||
//start download
|
||||
downloadsDidStart = false
|
||||
self.showInProgressView(title: "Gathering information", details: "Please wait")
|
||||
execute(commmandAsynchronous: getIt.getCommand() + " -o " + getIt.getOutputPath() + getIt.getOutputTemplate() + urlStr)
|
||||
} else {
|
||||
self.showInProgressView(title: "Whoops", details: "Can't download nothing")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute: {
|
||||
self.dismissProgressView()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func execute(commmandAsynchronous: String){
|
||||
|
||||
//the following code (from stackoverflow) will excecute the youtube-dl command and will add the output from the command
|
||||
//to the output window (real time output)
|
||||
// http://stackoverflow.com/questions/29548811/real-time-nstask-output-to-nstextview-with-swift
|
||||
var receivedStr = "" // variable to keep the received string (usefull to display it at the end)
|
||||
downloadingFileNr = 1 // reset file nr
|
||||
|
||||
//Prepare command
|
||||
var arguments:[String] = []
|
||||
arguments.append("-c")
|
||||
arguments.append( command )
|
||||
arguments.append(commmandAsynchronous + " 2>&1")
|
||||
logger.log(tag: "[COMMAND]", str: "\(commmandAsynchronous) 2>&1")
|
||||
|
||||
|
||||
//Start execution of command
|
||||
let task = Process()
|
||||
task.launchPath = "/bin/sh"
|
||||
task.arguments = arguments
|
||||
@@ -78,69 +128,96 @@ class ViewController: NSViewController {
|
||||
outHandle.waitForDataInBackgroundAndNotify()
|
||||
|
||||
var obs1 : NSObjectProtocol!
|
||||
obs1 = NotificationCenter.default.addObserver(forName: NSNotification.Name.NSFileHandleDataAvailable,
|
||||
object: outHandle, queue: nil) { notification -> Void in
|
||||
let data = outHandle.availableData
|
||||
if data.count > 0 {
|
||||
if let str = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
|
||||
//print("got output: \(str)")
|
||||
//RECEIVED OUTPUT
|
||||
//self.outputWindow.insertText( "\(str)" )
|
||||
|
||||
}
|
||||
outHandle.waitForDataInBackgroundAndNotify()
|
||||
} else {
|
||||
//print("EOF on stdout from process")
|
||||
//self.outputWindow.insertText( "\nEOF on stdout from process" )
|
||||
NotificationCenter.default.removeObserver(obs1)
|
||||
}
|
||||
obs1 = NotificationCenter.default.addObserver(forName: NSNotification.Name.NSFileHandleDataAvailable, object: outHandle, queue: nil) { notification -> Void in
|
||||
let data = outHandle.availableData
|
||||
if data.count > 0 {
|
||||
if let s = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
|
||||
//RECEIVED OUTPUT
|
||||
self.logger.log(tag: "[RECEIVED]", str: "\(s)")
|
||||
|
||||
var status: String!
|
||||
let matchesError = [String]()
|
||||
|
||||
//Received value preprocessing
|
||||
receivedStr = s.components(separatedBy: "\n")[0]
|
||||
var str = receivedStr.replacingOccurrences(of: " ", with: "")
|
||||
|
||||
//Get percentage using a regular expression
|
||||
do{
|
||||
//regex for downloadbar
|
||||
let regex = try NSRegularExpression(pattern: REGEX_PATTERN, options: [])
|
||||
let matches = regex.matches(in: str, options: [], range: NSRange(location: 0, length: str.count))
|
||||
//regex for error
|
||||
let regexError = try NSRegularExpression(pattern: "ERROR", options: [])
|
||||
_ = regexError.matches(in: str, options: [], range: NSRange(location: 0, length: str.count))
|
||||
|
||||
if matches.count > 0 {
|
||||
let rangeOfMatch = matches[0].range(at: 0)
|
||||
var index = str.index(str.startIndex, offsetBy: rangeOfMatch.location + rangeOfMatch.length - 1)
|
||||
str = String(str[..<index])
|
||||
index = str.index(str.startIndex, offsetBy: rangeOfMatch.location - 1)
|
||||
str = String(str[index...])
|
||||
|
||||
self.currentProgress = CGFloat(Double(round(100 * (str as NSString).doubleValue) / 100 ))
|
||||
if( self.currentProgress < self.previousProgress){
|
||||
self.currentProgress = self.previousProgress
|
||||
} else {
|
||||
self.previousProgress = self.currentProgress
|
||||
}
|
||||
|
||||
} else {
|
||||
str = "-1"
|
||||
}
|
||||
} catch _ { } // don't care
|
||||
|
||||
//Set and update the waiting screen based on the received percentage/data/error
|
||||
if matchesError.count == 0 {
|
||||
if(str == "100"){
|
||||
self.downloadingFileNr = self.downloadingFileNr + 1
|
||||
status = "Processing file \(self.downloadingFileNr)"
|
||||
self.previousProgress = 0.0
|
||||
} else if (str == "-1" && self.downloadingFileNr > 1){
|
||||
status = "Processing file \(self.downloadingFileNr - 1)"
|
||||
} else if (str == "-1") {
|
||||
status = "Downloading file \(self.downloadingFileNr)"
|
||||
} else if (self.currentProgress <= 100){
|
||||
status = "Downloading file \(self.downloadingFileNr)"
|
||||
self.previousProgress = self.currentProgress
|
||||
self.downloadsDidStart = true
|
||||
} else {
|
||||
status = "Processing file \(self.downloadingFileNr)"
|
||||
self.previousProgress = self.currentProgress
|
||||
}
|
||||
if(self.downloadsDidStart) {
|
||||
self.showInProgressView(title: status, details: "\(self.currentProgress)%")
|
||||
}
|
||||
}
|
||||
//error received
|
||||
else {
|
||||
self.showInProgressView(title: "Error!", details: "\(receivedStr)")
|
||||
}
|
||||
}
|
||||
outHandle.waitForDataInBackgroundAndNotify()
|
||||
} else {
|
||||
//EOF ON STDOUT FROM PROCESS
|
||||
NotificationCenter.default.removeObserver(obs1 as Any)
|
||||
if(self.downloadingFileNr < 2){
|
||||
self.showInProgressView(title: "Failed...", details: "Something went wrong. Please try other settings or report this issue on github if the problem doesn't magically disappears.")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(4), execute: {
|
||||
self.dismissProgressView()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var obs2 : NSObjectProtocol!
|
||||
obs2 = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification,
|
||||
object: task, queue: nil) { notification -> Void in
|
||||
//print("terminated")
|
||||
// self.outputWindow.insertText( "\n\nDONE.\n" )
|
||||
NotificationCenter.default.removeObserver(obs2)
|
||||
obs2 = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: task, queue: nil) { notification -> Void in
|
||||
//PROCESS TERMINATED
|
||||
NotificationCenter.default.removeObserver(obs2 as Any)
|
||||
self.dismissProgressView()
|
||||
}
|
||||
|
||||
task.launch()
|
||||
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************
|
||||
//****************************************************************************************************************
|
||||
|
||||
|
||||
//this function will excecute once when the view has been loaded
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
//set texts
|
||||
// inputURLS.insertText("\n\nInsert your URLs here. Seperate multiple URLS with a breakline (enter).")
|
||||
// outputWindow.insertText( "\n\nThis will contain some debugging information when downloading your requested files.\n\nThe default settings will download the input URLs as MP3-files.\n\nENJOY!" )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getIt.loadCmdFromSettings()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
override func awakeFromNib() {
|
||||
if self.view.layer != nil {
|
||||
let color : CGColor = CGColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
||||
self.view.layer?.backgroundColor = color
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// openTerminalButton.swift
|
||||
// Get It
|
||||
//
|
||||
// Created by Kevin De Koninck on 05/02/2017.
|
||||
// Copyright © 2017 Kevin De Koninck. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class installButton: NSButton {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
self.layer?.backgroundColor = blueColor.cgColor
|
||||
self.layer?.cornerRadius = 15.0
|
||||
self.layer?.masksToBounds = true
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
//text
|
||||
let style = NSMutableParagraphStyle()
|
||||
style.alignment = .center
|
||||
self.attributedTitle = NSAttributedString(string: "Install", attributes: [ NSAttributedString.Key.foregroundColor : NSColor.white,
|
||||
NSAttributedString.Key.paragraphStyle : style,
|
||||
NSAttributedString.Key.font: NSFont(name: "Arial", size: 18)!])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// optionsTextfield.swift
|
||||
// Get It
|
||||
//
|
||||
// Created by Kevin De Koninck on 04/02/2017.
|
||||
// Copyright © 2017 Kevin De Koninck. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class optionsTextfield: NSTextField {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
var bgColor = NSColor(red: 251/255.0, green: 251/255.0, blue: 251/255.0, alpha: 1.0)
|
||||
bgColor = NSColor(red: 245/255.0, green: 245/255.0, blue: 245/255.0, alpha: 1.0)
|
||||
|
||||
self.focusRingType = .none
|
||||
self.isBordered = false
|
||||
self.drawsBackground = false
|
||||
self.backgroundColor = bgColor
|
||||
self.layer?.backgroundColor = bgColor.cgColor
|
||||
|
||||
//underline
|
||||
let border = CALayer()
|
||||
let width = CGFloat(1.0)
|
||||
border.borderColor = blueColor.cgColor
|
||||
border.frame = CGRect(x: 0, y: self.frame.size.height - width, width: self.frame.size.width, height: self.frame.size.height)
|
||||
border.borderWidth = width
|
||||
self.layer?.addSublayer(border)
|
||||
self.layer?.masksToBounds = true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// progressView.swift
|
||||
// Get It
|
||||
//
|
||||
// Created by Kevin De Koninck on 17/04/2018.
|
||||
// Copyright © 2018 Kevin De Koninck. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class progressView: NSView {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
self.alphaValue = 0.7
|
||||
self.layer?.backgroundColor = NSColor.black.cgColor
|
||||
self.layer?.cornerRadius = 15.0
|
||||
self.layer?.masksToBounds = true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// secureOptionsTextfield.swift
|
||||
// Get It
|
||||
//
|
||||
// Created by Kevin De Koninck on 04/02/2017.
|
||||
// Copyright © 2017 Kevin De Koninck. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class secureOptionsTextfield: NSSecureTextField {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
var bgColor = NSColor(red: 251/255.0, green: 251/255.0, blue: 251/255.0, alpha: 1.0)
|
||||
bgColor = NSColor(red: 245/255.0, green: 245/255.0, blue: 245/255.0, alpha: 1.0)
|
||||
|
||||
self.focusRingType = .none
|
||||
self.isBordered = false
|
||||
self.drawsBackground = false
|
||||
self.backgroundColor = bgColor
|
||||
self.layer?.backgroundColor = bgColor.cgColor
|
||||
|
||||
//underline
|
||||
let border = CALayer()
|
||||
let width = CGFloat(1.0)
|
||||
border.borderColor = blueColor.cgColor
|
||||
border.frame = CGRect(x: 0, y: self.frame.size.height - width, width: self.frame.size.width, height: self.frame.size.height)
|
||||
border.borderWidth = width
|
||||
self.layer?.addSublayer(border)
|
||||
self.layer?.masksToBounds = true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
target ‘Get It’ do
|
||||
use_frameworks!
|
||||
pod 'ITSwitch'
|
||||
pod 'DJProgressHUD_OSX'
|
||||
end
|
||||
pod 'STPrivilegedTask'
|
||||
pod 'LetsMove'
|
||||
end
|
||||
|
||||
+14
-5
@@ -1,15 +1,24 @@
|
||||
PODS:
|
||||
- DJProgressHUD_OSX (0.0.1)
|
||||
- ITSwitch (1.0)
|
||||
- LetsMove (1.24)
|
||||
- STPrivilegedTask (1.0.1)
|
||||
|
||||
DEPENDENCIES:
|
||||
- DJProgressHUD_OSX
|
||||
- ITSwitch
|
||||
- LetsMove
|
||||
- STPrivilegedTask
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/cocoapods/specs.git:
|
||||
- ITSwitch
|
||||
- LetsMove
|
||||
- STPrivilegedTask
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
DJProgressHUD_OSX: a8de6d2da8750dbf671fcddc649a44a9cd2807c4
|
||||
ITSwitch: 7ff745d6f2a6910e9194b23e4eab9a843258a478
|
||||
LetsMove: fefe56bc7bc7fb7d37049e28a14f297961229fc5
|
||||
STPrivilegedTask: 103f97827454e786074640cf89d303be344498c7
|
||||
|
||||
PODFILE CHECKSUM: 97344994ab3e567a791a6ce5365cd84d23f7c5fa
|
||||
PODFILE CHECKSUM: 4dca32d4d6791341e27820d98c0efe1419299b51
|
||||
|
||||
COCOAPODS: 1.1.1
|
||||
COCOAPODS: 1.7.0.rc.1
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// DJProgressIndicator.h
|
||||
// Playground
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface DJActivityIndicator : NSView
|
||||
|
||||
@property BOOL isAnimating;
|
||||
|
||||
- (void)setColor:(NSColor *)value;
|
||||
- (void)setBackgroundColor:(NSColor *)value;
|
||||
|
||||
- (void)stopAnimation:(id)sender;
|
||||
- (void)startAnimation:(id)sender;
|
||||
|
||||
@end
|
||||
@@ -1,208 +0,0 @@
|
||||
//
|
||||
// DJProgressIndicator.m
|
||||
// Playground
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DJActivityIndicator.h"
|
||||
|
||||
#define kAlphaWhenStopped 0.15
|
||||
#define kFadeMultiplier 0.85
|
||||
|
||||
@interface DJActivityIndicator ()
|
||||
{
|
||||
int position;
|
||||
NSMutableArray* finColors;
|
||||
|
||||
BOOL isFadingOut;
|
||||
NSTimer* animationTimer;
|
||||
|
||||
NSColor* foreColor;
|
||||
NSColor* backColor;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation DJActivityIndicator
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
position = 0;
|
||||
int numFins = 12;
|
||||
|
||||
finColors = [[NSMutableArray alloc] initWithCapacity:numFins];
|
||||
|
||||
_isAnimating = NO;
|
||||
isFadingOut = NO;
|
||||
|
||||
foreColor = [NSColor blackColor];
|
||||
backColor = [NSColor clearColor];
|
||||
|
||||
for(int i=0; i<numFins; i++)
|
||||
{
|
||||
[finColors addObject:foreColor];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
[super drawRect:dirtyRect];
|
||||
|
||||
NSSize size = [self bounds].size;
|
||||
CGFloat theMaxSize;
|
||||
if(size.width >= size.height)
|
||||
theMaxSize = size.height;
|
||||
else
|
||||
theMaxSize = size.width;
|
||||
|
||||
[backColor set];
|
||||
[NSBezierPath fillRect:[self bounds]];
|
||||
|
||||
CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
[NSGraphicsContext saveGraphicsState];
|
||||
|
||||
CGContextTranslateCTM(currentContext,[self bounds].size.width/2,[self bounds].size.height/2);
|
||||
|
||||
NSBezierPath *path = [[NSBezierPath alloc] init];
|
||||
CGFloat lineWidth = 0.0859375 * theMaxSize;
|
||||
CGFloat lineStart = 0.234375 * theMaxSize;
|
||||
CGFloat lineEnd = 0.421875 * theMaxSize;
|
||||
[path setLineWidth:lineWidth];
|
||||
[path setLineCapStyle:NSRoundLineCapStyle];
|
||||
[path moveToPoint:NSMakePoint(0,lineStart)];
|
||||
[path lineToPoint:NSMakePoint(0,lineEnd)];
|
||||
|
||||
for (int i=0; i<finColors.count; i++) {
|
||||
if(_isAnimating) {
|
||||
[(NSColor*)finColors[i] set];
|
||||
}
|
||||
else {
|
||||
[[foreColor colorWithAlphaComponent:kAlphaWhenStopped] set];
|
||||
}
|
||||
|
||||
[path stroke];
|
||||
|
||||
CGContextRotateCTM(currentContext, 6.282185/finColors.count);
|
||||
}
|
||||
path = nil;
|
||||
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
}
|
||||
|
||||
- (void)startAnimation:(id)sender
|
||||
{
|
||||
if (_isAnimating && !isFadingOut) return;
|
||||
|
||||
[self actuallyStartAnimation];
|
||||
}
|
||||
|
||||
- (void)stopAnimation:(id)sender
|
||||
{
|
||||
isFadingOut = YES;
|
||||
}
|
||||
|
||||
- (void)setColor:(NSColor *)value
|
||||
{
|
||||
if (foreColor != value) {
|
||||
foreColor = nil;
|
||||
foreColor = value;
|
||||
|
||||
for (int i=0; i<finColors.count; i++) {
|
||||
CGFloat alpha = [finColors[i] alphaComponent];
|
||||
[finColors setObject:[foreColor colorWithAlphaComponent:alpha] atIndexedSubscript:i];
|
||||
}
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)value
|
||||
{
|
||||
if (backColor != value) {
|
||||
backColor = nil;
|
||||
backColor = value;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateFrame:(NSTimer *)timer
|
||||
{
|
||||
if(position > 0) {
|
||||
position--;
|
||||
}
|
||||
else {
|
||||
position = (int)finColors.count - 1;
|
||||
}
|
||||
|
||||
CGFloat minAlpha = kAlphaWhenStopped;
|
||||
for (int i=0; i<finColors.count; i++) {
|
||||
CGFloat newAlpha = [finColors[i] alphaComponent] * kFadeMultiplier;
|
||||
if (newAlpha < minAlpha)
|
||||
newAlpha = minAlpha;
|
||||
|
||||
finColors[i] = [foreColor colorWithAlphaComponent:newAlpha];
|
||||
}
|
||||
|
||||
if (isFadingOut) {
|
||||
BOOL done = YES;
|
||||
for (int i=0; i<finColors.count; i++) {
|
||||
if (fabs([finColors[i] alphaComponent] - minAlpha) > 0.01) {
|
||||
done = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
[self actuallyStopAnimation];
|
||||
}
|
||||
}
|
||||
else {
|
||||
finColors[position] = foreColor;
|
||||
}
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)actuallyStartAnimation
|
||||
{
|
||||
[self actuallyStopAnimation];
|
||||
|
||||
_isAnimating = YES;
|
||||
isFadingOut = NO;
|
||||
|
||||
position = 1;
|
||||
|
||||
animationTimer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05
|
||||
target:self
|
||||
selector:@selector(updateFrame:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
|
||||
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSRunLoopCommonModes];
|
||||
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSDefaultRunLoopMode];
|
||||
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSEventTrackingRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)actuallyStopAnimation
|
||||
{
|
||||
_isAnimating = NO;
|
||||
isFadingOut = NO;
|
||||
|
||||
if (animationTimer) {
|
||||
// we were using timer-based animation
|
||||
[animationTimer invalidate];
|
||||
animationTimer = nil;
|
||||
}
|
||||
//[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// CPBezierPath.h
|
||||
// Cloud Play OSX
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface DJBezierPath : NSBezierPath
|
||||
|
||||
- (CGPathRef)quartzPath;
|
||||
|
||||
@end
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
//
|
||||
// CPBezierPath.m
|
||||
// Cloud Play OSX
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DJBezierPath.h"
|
||||
|
||||
@implementation DJBezierPath
|
||||
|
||||
- (CGPathRef)quartzPath
|
||||
{
|
||||
int i, numElements;
|
||||
|
||||
// Need to begin a path here.
|
||||
CGPathRef immutablePath = NULL;
|
||||
|
||||
// Then draw the path elements.
|
||||
numElements = (int)[self elementCount];
|
||||
if (numElements > 0)
|
||||
{
|
||||
CGMutablePathRef path = CGPathCreateMutable();
|
||||
NSPoint points[3];
|
||||
BOOL didClosePath = YES;
|
||||
|
||||
for (i = 0; i < numElements; i++)
|
||||
{
|
||||
switch ([self elementAtIndex:i associatedPoints:points])
|
||||
{
|
||||
case NSMoveToBezierPathElement:
|
||||
CGPathMoveToPoint(path, NULL, points[0].x, points[0].y);
|
||||
break;
|
||||
|
||||
case NSLineToBezierPathElement:
|
||||
CGPathAddLineToPoint(path, NULL, points[0].x, points[0].y);
|
||||
didClosePath = NO;
|
||||
break;
|
||||
|
||||
case NSCurveToBezierPathElement:
|
||||
CGPathAddCurveToPoint(path, NULL, points[0].x, points[0].y,
|
||||
points[1].x, points[1].y,
|
||||
points[2].x, points[2].y);
|
||||
didClosePath = NO;
|
||||
break;
|
||||
|
||||
case NSClosePathBezierPathElement:
|
||||
CGPathCloseSubpath(path);
|
||||
didClosePath = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Be sure the path is closed or Quartz may not do valid hit detection.
|
||||
if (!didClosePath)
|
||||
CGPathCloseSubpath(path);
|
||||
|
||||
immutablePath = CGPathCreateCopy(path);
|
||||
CGPathRelease(path);
|
||||
}
|
||||
|
||||
return immutablePath;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,66 +0,0 @@
|
||||
//
|
||||
// CPProgressView.h
|
||||
// Cloud Play OSX
|
||||
//
|
||||
// Created by Daniel Jackson on 4/22/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
/*#define popupWidth 120
|
||||
#define popupHeight 120
|
||||
|
||||
#define popupAlpha 0.9
|
||||
|
||||
#define xOffset 0
|
||||
#define yOffset 0
|
||||
|
||||
#define indicatorSize 40*/
|
||||
|
||||
@class DJProgressIndicator;
|
||||
@class DJActivityIndicator;
|
||||
|
||||
@interface DJProgressHUD : NSView
|
||||
|
||||
+ (void)setBackgroundAlpha:(CGFloat)bgAlph disableActions:(BOOL)disActions;
|
||||
|
||||
+ (void)showStatus:(NSString*)status FromView:(NSView*)view;
|
||||
+ (void)showProgress:(CGFloat)progress withStatus:(NSString*)status FromView:(NSView*)view;
|
||||
|
||||
+ (void)dismiss;
|
||||
|
||||
//+ (void)popActivity;
|
||||
@property (nonatomic) BOOL keepActivityCount;
|
||||
|
||||
@property (nonatomic, readonly) BOOL animatingDismiss;
|
||||
@property (nonatomic, readonly) BOOL animatingShow;
|
||||
@property (nonatomic, readonly) BOOL displaying;
|
||||
@property (nonatomic, readonly) NSUInteger activityCount;
|
||||
|
||||
/*
|
||||
-----Customization----
|
||||
|
||||
Make all changes to [CPProgressView instance]
|
||||
Prior to showing popup, call -(void)orientPopup
|
||||
*/
|
||||
|
||||
#define pMaxWidth1 250
|
||||
#define pMaxHeight1 200
|
||||
|
||||
|
||||
|
||||
//General Popup Values
|
||||
@property (nonatomic) CGVector pOffset;
|
||||
@property (nonatomic) CGFloat pAlpha;
|
||||
|
||||
//Padding
|
||||
@property (nonatomic) CGFloat pPadding;
|
||||
|
||||
@property (nonatomic) CGSize indicatorSize;
|
||||
@property (nonatomic) CGVector indicatorOffset;
|
||||
@property (nonatomic) CGSize labelSize;
|
||||
@property (nonatomic) CGVector labelOffset;
|
||||
|
||||
@end
|
||||
-425
@@ -1,425 +0,0 @@
|
||||
//
|
||||
// CPProgressView.m
|
||||
// Cloud Play OSX
|
||||
//
|
||||
// Created by Daniel Jackson on 4/22/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DJProgressHUD.h"
|
||||
#import "DJActivityIndicator.h"
|
||||
#import "DJProgressIndicator.h"
|
||||
|
||||
#define DEBUG_LOGS 1
|
||||
|
||||
typedef void (^CompletionHander)(void);
|
||||
|
||||
@interface DJProgressHUD ()
|
||||
{
|
||||
NSView* parentView;
|
||||
|
||||
CGSize pSize; //This is set automatically based on the content
|
||||
DJActivityIndicator* activityIndicator;
|
||||
DJProgressIndicator* progressIndicator;
|
||||
NSTextField* label;
|
||||
|
||||
NSButton* backgroundMask;
|
||||
NSView* MainHUD;
|
||||
}
|
||||
|
||||
@property CGFloat backgroundAlpha;
|
||||
@property BOOL actionsEnabled;
|
||||
|
||||
@end
|
||||
|
||||
@implementation DJProgressHUD
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class Methods
|
||||
|
||||
+ (void)showStatus:(NSString*)status FromView:(NSView*)view
|
||||
{
|
||||
[[self instance] showStatus:status FromView:view];
|
||||
}
|
||||
|
||||
+ (void)setBackgroundAlpha:(CGFloat)bgAlph disableActions:(BOOL)disActions
|
||||
{
|
||||
DJProgressHUD* theHUD = [self instance];
|
||||
theHUD.backgroundAlpha = bgAlph;
|
||||
|
||||
[theHUD setBackground];
|
||||
|
||||
}
|
||||
|
||||
+ (void)showProgress:(CGFloat)progress withStatus:(NSString*)status FromView:(NSView*)view
|
||||
{
|
||||
[[self instance] showProgress:progress withStatus:status FromView:view];
|
||||
}
|
||||
|
||||
+ (void)dismiss
|
||||
{
|
||||
if([[self instance] keepActivityCount]) {
|
||||
[[self instance] popActivity];
|
||||
}
|
||||
else {
|
||||
[[self instance] hideViewAnimated];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)popActivity
|
||||
{
|
||||
[[self instance] popActivity];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Master Methods
|
||||
|
||||
- (void)showStatus:(NSString*)status FromView:(NSView*)view
|
||||
{
|
||||
parentView = view;
|
||||
|
||||
label.stringValue = status;
|
||||
|
||||
[activityIndicator setHidden:FALSE];
|
||||
[progressIndicator setHidden:TRUE];
|
||||
[activityIndicator startAnimation:nil];
|
||||
|
||||
if(![self displaying])
|
||||
[self showViewAnimated];
|
||||
else
|
||||
[self replaceViewQuick];
|
||||
}
|
||||
|
||||
- (void)addMask {
|
||||
|
||||
[backgroundMask removeFromSuperview];
|
||||
[backgroundMask setFrame:parentView.frame];
|
||||
[backgroundMask setEnabled:!_actionsEnabled];
|
||||
if(!backgroundMask.wantsLayer) {
|
||||
CALayer* layer = [CALayer layer];
|
||||
[backgroundMask setLayer:layer];
|
||||
}
|
||||
[backgroundMask.layer setOpacity:0.0];
|
||||
[parentView addSubview:backgroundMask positioned:NSWindowAbove relativeTo:self];
|
||||
}
|
||||
|
||||
- (void)removeMask {
|
||||
|
||||
[backgroundMask removeFromSuperview];
|
||||
// [backgroundMask.animator.layer setOpacity:0.0];
|
||||
}
|
||||
|
||||
- (void)showProgress:(CGFloat)progress withStatus:(NSString*)status FromView:(NSView*)view
|
||||
{
|
||||
parentView = view;
|
||||
|
||||
label.stringValue = status;
|
||||
|
||||
[activityIndicator setHidden:TRUE];
|
||||
[progressIndicator setHidden:FALSE];
|
||||
[activityIndicator stopAnimation:nil];
|
||||
[progressIndicator showProgress:progress];
|
||||
|
||||
if(![self displaying])
|
||||
[self showViewAnimated];
|
||||
else
|
||||
[self replaceViewQuick];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Instance Methods
|
||||
|
||||
-(void)replaceViewQuick
|
||||
{
|
||||
[self beginShowView];
|
||||
[MainHUD.layer setOpacity:_pAlpha];
|
||||
}
|
||||
|
||||
- (void)beginShowView
|
||||
{
|
||||
[self updateLayout];
|
||||
|
||||
if(!self.superview) [parentView addSubview:self];
|
||||
[self.layer setFrame:parentView.frame];
|
||||
[self addSubview:MainHUD];
|
||||
NSRect size = [self getCenterWithinRect:parentView.frame scale:1.0];
|
||||
[MainHUD.layer setFrame:size];
|
||||
|
||||
_displaying = true;
|
||||
_activityCount++;
|
||||
|
||||
[self addMask];
|
||||
|
||||
[activityIndicator.layer setOpacity:1.0];
|
||||
[progressIndicator.layer setOpacity:1.0];
|
||||
[label.layer setOpacity:1.0];
|
||||
}
|
||||
|
||||
-(void)finishHideView
|
||||
{
|
||||
[MainHUD removeFromSuperview];
|
||||
[self removeFromSuperview];
|
||||
parentView = nil;
|
||||
_displaying = false;
|
||||
|
||||
[self removeMask];
|
||||
|
||||
[activityIndicator stopAnimation:nil];
|
||||
}
|
||||
|
||||
- (void)showViewAnimated
|
||||
{
|
||||
if(![parentView wantsLayer])
|
||||
{
|
||||
[parentView setWantsLayer:TRUE];
|
||||
[parentView setLayer:[CALayer layer]];
|
||||
}
|
||||
if(![MainHUD wantsLayer])
|
||||
{
|
||||
[MainHUD setWantsLayer:TRUE];
|
||||
[MainHUD setLayer:[CALayer layer]];
|
||||
}
|
||||
|
||||
[self beginShowView];
|
||||
MainHUD.layer.opacity = 0.0;
|
||||
|
||||
NSRect sizeBefore = [self getCenterWithinRect:parentView.frame scale:0.75];
|
||||
[MainHUD.layer setFrame:sizeBefore];
|
||||
|
||||
_animatingShow = true;
|
||||
|
||||
[CATransaction flush];
|
||||
[CATransaction begin];
|
||||
[CATransaction setValue:[NSNumber numberWithFloat:0.15f]
|
||||
forKey:kCATransactionAnimationDuration];
|
||||
[CATransaction setCompletionBlock:^{
|
||||
_animatingShow = false;
|
||||
}];
|
||||
|
||||
[MainHUD.layer setFrame:[self getCenterWithinRect:parentView.frame scale:1.0]];
|
||||
[MainHUD.layer setOpacity:_pAlpha];
|
||||
[CATransaction commit];
|
||||
|
||||
[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
|
||||
- (void)hideViewAnimated
|
||||
{
|
||||
if(![parentView wantsLayer])
|
||||
{
|
||||
[parentView setWantsLayer:TRUE];
|
||||
[parentView setLayer:[CALayer layer]];
|
||||
}
|
||||
if(![MainHUD wantsLayer])
|
||||
{
|
||||
[MainHUD setWantsLayer:TRUE];
|
||||
[MainHUD setLayer:[CALayer layer]];
|
||||
}
|
||||
|
||||
NSRect newSize = [self getCenterWithinRect:parentView.frame scale:0.75];
|
||||
|
||||
//The ring doesnt resize easily. Clear it.
|
||||
[progressIndicator clear];
|
||||
|
||||
_animatingDismiss = true;
|
||||
_animatingShow = true;
|
||||
|
||||
[CATransaction flush];
|
||||
[CATransaction begin];
|
||||
[CATransaction setValue:[NSNumber numberWithFloat:0.15f] forKey:kCATransactionAnimationDuration];
|
||||
[CATransaction setCompletionBlock:^{
|
||||
_animatingShow = false;
|
||||
if(MainHUD.layer.opacity == 0.0)
|
||||
{
|
||||
[self finishHideView];
|
||||
//[self updateLayout];
|
||||
[MainHUD addSubview:progressIndicator];
|
||||
}
|
||||
}];
|
||||
[activityIndicator.layer setOpacity:0.0];
|
||||
[label.layer setOpacity:0.0];
|
||||
[MainHUD.layer setFrame:newSize];
|
||||
[MainHUD.layer setOpacity:0.0];
|
||||
[CATransaction commit];
|
||||
|
||||
[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
|
||||
- (void)popActivity
|
||||
{
|
||||
_activityCount--;
|
||||
if(_activityCount == 0)
|
||||
[self hideViewAnimated];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Laying It Out
|
||||
|
||||
- (void)updateLayout
|
||||
{
|
||||
[self setBackground];
|
||||
|
||||
CGSize maxContentSize = CGSizeMake(pMaxWidth1-(_pPadding*2), pMaxHeight1-(_pPadding*2));
|
||||
CGSize minContentSize = CGSizeMake(_indicatorSize.width, _indicatorSize.height);
|
||||
|
||||
CGFloat stringWidth = [label.stringValue sizeWithAttributes:@{ NSFontAttributeName : label.font }].width + 5;
|
||||
float stringHeight = [self heightForString:label.stringValue font:label.font width:maxContentSize.width] + 8;
|
||||
|
||||
if(label.stringValue == nil || label.stringValue.length == 0)
|
||||
stringHeight = 0;
|
||||
|
||||
stringWidth = (stringWidth > minContentSize.width) ? stringWidth : minContentSize.width;
|
||||
if(stringWidth > maxContentSize.width)
|
||||
stringWidth = maxContentSize.width;
|
||||
|
||||
CGFloat maxStringHeight = maxContentSize.height-_indicatorSize.height-(_pPadding+(_pPadding/2));
|
||||
stringHeight = (stringHeight > maxStringHeight) ? maxStringHeight : stringHeight;
|
||||
|
||||
CGFloat popupWidth = stringWidth+(_pPadding*2);
|
||||
|
||||
CGFloat lW = stringWidth;
|
||||
CGFloat lH = stringHeight;
|
||||
CGFloat lX = _pPadding;
|
||||
CGFloat lY = (stringHeight == 0) ? 0 : _pPadding;
|
||||
[label setFrame:NSMakeRect(lX, lY, lW, lH)];
|
||||
|
||||
CGFloat spaceBetween = (stringHeight != 0) ? _pPadding/3 : _pPadding;
|
||||
|
||||
CGFloat iW = _indicatorSize.width;
|
||||
CGFloat iH = _indicatorSize.height;
|
||||
CGFloat iX = ((lW+(_pPadding*2))/2)-(iW/2); //center it
|
||||
CGFloat iY = lY+lH+(spaceBetween);
|
||||
NSRect indicatorRect = NSMakeRect(iX, iY, iW, iH);
|
||||
activityIndicator.frame = progressIndicator.frame = indicatorRect;
|
||||
|
||||
CGFloat spaceOnTop = (stringHeight != 0) ? _pPadding/3 : 0;
|
||||
|
||||
[progressIndicator setRingThickness:6];
|
||||
[progressIndicator sizeToFit];
|
||||
[activityIndicator setColor:[NSColor whiteColor]];
|
||||
|
||||
pSize.width = popupWidth;
|
||||
pSize.height = iY+iH+_pPadding+spaceOnTop;//+(_pPadding/2);
|
||||
|
||||
[self setAutoresizesSubviews:YES];
|
||||
[MainHUD setAutoresizesSubviews:YES];
|
||||
|
||||
[self setNeedsDisplay:TRUE];
|
||||
[MainHUD setNeedsDisplay:TRUE];
|
||||
}
|
||||
|
||||
- (void)setBackground
|
||||
{
|
||||
CGColorRef bgcolor = CGColorCreateGenericRGB(0.05, 0.05, 0.05, _pAlpha);
|
||||
if(![MainHUD wantsLayer])
|
||||
{
|
||||
CALayer* bgLayer = [CALayer layer];
|
||||
[bgLayer setBackgroundColor:bgcolor];
|
||||
[bgLayer setCornerRadius:15.0];
|
||||
[MainHUD setWantsLayer:TRUE];
|
||||
[MainHUD setLayer:bgLayer];
|
||||
}
|
||||
else {
|
||||
[MainHUD.layer setBackgroundColor:bgcolor];
|
||||
[MainHUD.layer setCornerRadius:15.0];
|
||||
}
|
||||
|
||||
if(![self layer]) {
|
||||
CALayer* bgLayer = [CALayer layer];
|
||||
[self setLayer:bgLayer];
|
||||
[self setWantsLayer:TRUE];
|
||||
}
|
||||
|
||||
[self.layer setBackgroundColor:CGColorCreateGenericRGB(0, 0, 0, _backgroundAlpha)];
|
||||
|
||||
[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Other
|
||||
|
||||
-(CGFloat) heightForString:(NSString *)myString font:(NSFont*) myFont width:(CGFloat)myWidth
|
||||
{
|
||||
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:myString];
|
||||
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(myWidth, FLT_MAX)];
|
||||
;
|
||||
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
||||
[layoutManager addTextContainer:textContainer];
|
||||
[textStorage addLayoutManager:layoutManager];
|
||||
[textStorage addAttribute:NSFontAttributeName value:myFont
|
||||
range:NSMakeRange(0, [textStorage length])];
|
||||
[textContainer setLineFragmentPadding:0.0];
|
||||
|
||||
(void) [layoutManager glyphRangeForTextContainer:textContainer];
|
||||
return [layoutManager
|
||||
usedRectForTextContainer:textContainer].size.height;
|
||||
}
|
||||
|
||||
- (NSRect)getCenterWithinRect:(NSRect)parentFrame scale:(CGFloat)scale
|
||||
{
|
||||
NSRect result;
|
||||
CGFloat newWidth = pSize.width*scale;
|
||||
CGFloat newHeight = pSize.height*scale;
|
||||
result.origin.x = parentFrame.size.width/2 - newWidth/2 + _pOffset.dx;
|
||||
result.origin.y = parentFrame.size.height/2 - newHeight/2 + _pOffset.dy;
|
||||
result.size.width = newWidth;
|
||||
result.size.height = newHeight;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)initializePopup
|
||||
{
|
||||
self.autoresizingMask = NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin;
|
||||
MainHUD.autoresizingMask = NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin;
|
||||
|
||||
MainHUD = [[NSView alloc] init];
|
||||
activityIndicator = [[DJActivityIndicator alloc] init];
|
||||
progressIndicator = [[DJProgressIndicator alloc] init];
|
||||
backgroundMask = [[NSButton alloc] init];
|
||||
label = [[NSTextField alloc] init];
|
||||
|
||||
[self addSubview:MainHUD];
|
||||
[MainHUD addSubview:label];
|
||||
[MainHUD addSubview:activityIndicator];
|
||||
[MainHUD addSubview:progressIndicator];
|
||||
|
||||
//----DEFAULT VALUES----
|
||||
|
||||
_backgroundAlpha = 0.4;
|
||||
_actionsEnabled = FALSE;
|
||||
|
||||
_pOffset = CGVectorMake(0, 0);
|
||||
_pAlpha = 0.9;
|
||||
_pPadding = 10;
|
||||
|
||||
_indicatorSize = CGSizeMake(40, 40);
|
||||
_indicatorOffset = CGVectorMake(0, 0);
|
||||
|
||||
_indicatorSize = CGSizeMake(40, 40);
|
||||
_indicatorOffset = CGVectorMake(0, 0);
|
||||
|
||||
[label setBezeled:NO];
|
||||
[label setDrawsBackground:NO];
|
||||
[label setEditable:NO];
|
||||
[label setSelectable:NO];
|
||||
|
||||
label.font = [NSFont boldSystemFontOfSize:12.0];
|
||||
[label setTextColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.85]];
|
||||
}
|
||||
|
||||
+ (DJProgressHUD *) instance
|
||||
{
|
||||
static dispatch_once_t once;
|
||||
static DJProgressHUD *sharedView;
|
||||
dispatch_once(&once, ^ {
|
||||
sharedView = [[self alloc] init];
|
||||
[sharedView initializePopup];
|
||||
});
|
||||
|
||||
return sharedView;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// DJProgressIndicator.h
|
||||
// Playground
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@interface DJProgressIndicator : NSView
|
||||
|
||||
@property (nonatomic,readonly) CGFloat currentProgress;
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)value;
|
||||
- (void)setRingColor:(NSColor *)value backgroundRingColor:(NSColor*)value2;
|
||||
- (void)setRingThickness:(CGFloat)thick;
|
||||
- (void)setRingRadius:(CGFloat)radius;
|
||||
|
||||
- (void)showProgress:(float)progress;
|
||||
|
||||
-(void)sizeToFit;
|
||||
|
||||
-(void)clear;
|
||||
|
||||
@property (nonatomic, readonly) CGFloat ringRadius;
|
||||
@property (nonatomic, readonly) CGFloat ringThickness;
|
||||
|
||||
@end
|
||||
@@ -1,249 +0,0 @@
|
||||
//
|
||||
// DJProgressIndicator.m
|
||||
// Playground
|
||||
//
|
||||
// Created by Daniel Jackson on 5/11/14.
|
||||
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DJProgressIndicator.h"
|
||||
#import "DJBezierPath.h"
|
||||
|
||||
@interface DJProgressIndicator ()
|
||||
{
|
||||
NSColor* backRingColor;
|
||||
NSColor* ringColor;
|
||||
NSColor* backColor;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) CAShapeLayer *backgroundRingLayer;
|
||||
@property (nonatomic, strong) CAShapeLayer *ringLayer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation DJProgressIndicator
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_currentProgress = 0;
|
||||
|
||||
_ringThickness = 6;
|
||||
_ringRadius = self.frame.size.width/2 - (_ringThickness);
|
||||
|
||||
backRingColor = [NSColor darkGrayColor];
|
||||
ringColor = [NSColor whiteColor];
|
||||
backColor = [NSColor clearColor];
|
||||
|
||||
[self setAutoresizesSubviews:YES];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
[super drawRect:dirtyRect];
|
||||
|
||||
//NSLog(@"Drawing");
|
||||
|
||||
[self setBackground];
|
||||
|
||||
[self resetRings];
|
||||
}
|
||||
|
||||
- (void)setBackground
|
||||
{
|
||||
if(![self wantsLayer])
|
||||
{
|
||||
CALayer* bgLayer = [CALayer layer];
|
||||
[bgLayer setBackgroundColor:backColor.CGColor];
|
||||
[self setWantsLayer:TRUE];
|
||||
[self setLayer:bgLayer];
|
||||
}
|
||||
else {
|
||||
[self.layer setBackgroundColor:backColor.CGColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resetRings
|
||||
{
|
||||
[_ringLayer removeFromSuperlayer];
|
||||
_ringLayer = nil;
|
||||
[_backgroundRingLayer removeFromSuperlayer];
|
||||
_backgroundRingLayer = nil;
|
||||
|
||||
[self updateLayout];
|
||||
self.ringLayer.strokeEnd = _currentProgress;
|
||||
}
|
||||
|
||||
-(void)updateLayout
|
||||
{
|
||||
self.backgroundRingLayer.position = self.ringLayer.position = CGPointMake((CGRectGetWidth(self.bounds)/2), CGRectGetHeight(self.bounds)/2);
|
||||
}
|
||||
|
||||
- (void)showProgress:(float)progress {
|
||||
|
||||
NSLog(@"-----%f",progress);
|
||||
|
||||
_currentProgress = progress;
|
||||
|
||||
[self updateLayout];
|
||||
|
||||
if(progress >= 0) {
|
||||
self.ringLayer.strokeEnd = progress;
|
||||
}
|
||||
else {
|
||||
[self cancelRingLayerAnimation];
|
||||
}
|
||||
|
||||
//[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
|
||||
- (CAShapeLayer *)ringLayer {
|
||||
if(!_ringLayer) {
|
||||
CGPoint center = CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);
|
||||
_ringLayer = [self createRingLayerWithCenter:center radius:_ringRadius lineWidth:_ringThickness color:ringColor];
|
||||
[self.layer addSublayer:_ringLayer];
|
||||
}
|
||||
return _ringLayer;
|
||||
}
|
||||
|
||||
- (CAShapeLayer *)backgroundRingLayer {
|
||||
if(!_backgroundRingLayer) {
|
||||
CGPoint center = CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);
|
||||
_backgroundRingLayer = [self createRingLayerWithCenter:center radius:_ringRadius lineWidth:_ringThickness color:backRingColor];
|
||||
_backgroundRingLayer.strokeEnd = 1;
|
||||
[self.layer addSublayer:_backgroundRingLayer];
|
||||
}
|
||||
return _backgroundRingLayer;
|
||||
}
|
||||
|
||||
- (void)cancelRingLayerAnimation {
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
[self.layer removeAllAnimations];
|
||||
|
||||
_ringLayer.strokeEnd = 0.0f;
|
||||
if (_ringLayer.superlayer) {
|
||||
[_ringLayer removeFromSuperlayer];
|
||||
}
|
||||
_ringLayer = nil;
|
||||
|
||||
if (_backgroundRingLayer.superlayer) {
|
||||
[_backgroundRingLayer removeFromSuperlayer];
|
||||
}
|
||||
_backgroundRingLayer = nil;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
-(void)clear
|
||||
{
|
||||
[self cancelRingLayerAnimation];
|
||||
}
|
||||
|
||||
- (CGPoint)pointOnCircleWithCenter:(CGPoint)center radius:(double)radius angleInDegrees:(double)angleInDegrees {
|
||||
float x = (float)(radius * cos(angleInDegrees * M_PI / 180)) + radius;
|
||||
float y = (float)(radius * sin(angleInDegrees * M_PI / 180)) + radius;
|
||||
return CGPointMake(x, y);
|
||||
}
|
||||
|
||||
|
||||
- (DJBezierPath *)createCirclePathWithCenter:(CGPoint)center radius:(CGFloat)radius sampleCount:(NSInteger)sampleCount {
|
||||
|
||||
DJBezierPath *smoothedPath = [[DJBezierPath alloc] init];
|
||||
CGPoint startPoint = [self pointOnCircleWithCenter:center radius:radius angleInDegrees:90];
|
||||
|
||||
[smoothedPath moveToPoint:startPoint];
|
||||
|
||||
CGFloat delta = 360.0f/sampleCount;
|
||||
CGFloat angleInDegrees = 90;
|
||||
for (NSInteger i=1; i<sampleCount; i++) {
|
||||
angleInDegrees -= delta;
|
||||
CGPoint point = [self pointOnCircleWithCenter:center radius:radius angleInDegrees:angleInDegrees];
|
||||
[smoothedPath lineToPoint:point];
|
||||
}
|
||||
|
||||
[smoothedPath lineToPoint:startPoint];
|
||||
|
||||
return smoothedPath;
|
||||
}
|
||||
|
||||
|
||||
- (CAShapeLayer *)createRingLayerWithCenter:(CGPoint)center radius:(CGFloat)radius lineWidth:(CGFloat)lineWidth color:(NSColor *)color {
|
||||
|
||||
DJBezierPath *smoothedPath = [self createCirclePathWithCenter:center radius:radius sampleCount:72];
|
||||
|
||||
CAShapeLayer *slice = [CAShapeLayer layer];
|
||||
slice.frame = CGRectMake(center.x-radius, center.y-radius, radius*2, radius*2);
|
||||
slice.fillColor = [NSColor clearColor].CGColor;
|
||||
slice.strokeColor = color.CGColor;
|
||||
slice.lineWidth = lineWidth;
|
||||
slice.lineCap = kCALineJoinBevel;
|
||||
slice.lineJoin = kCALineJoinBevel;
|
||||
|
||||
CGPathRef path = smoothedPath.quartzPath;
|
||||
slice.path = path;
|
||||
CGPathRelease(path);
|
||||
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
||||
|
||||
- (void)setRingColor:(NSColor *)value backgroundRingColor:(NSColor*)value2
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if (ringColor != value) {
|
||||
ringColor = nil;
|
||||
ringColor= value;
|
||||
changed = true;
|
||||
}
|
||||
if (backRingColor != value2) {
|
||||
backRingColor = nil;
|
||||
backRingColor = value2;
|
||||
changed = true;
|
||||
}
|
||||
if(changed) {
|
||||
[self resetRings];
|
||||
[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)value
|
||||
{
|
||||
if (backColor != value) {
|
||||
//[backColor release];
|
||||
backColor = nil;
|
||||
backColor = value;
|
||||
[self setBackground];
|
||||
//[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setRingThickness:(CGFloat)thick
|
||||
{
|
||||
if(_ringThickness != thick) {
|
||||
_ringThickness = thick;
|
||||
[self resetRings];
|
||||
//[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setRingRadius:(CGFloat)radius
|
||||
{
|
||||
if(_ringRadius != radius) {
|
||||
_ringRadius = radius;
|
||||
[self resetRings];
|
||||
//[self setNeedsDisplay:TRUE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sizeToFit {
|
||||
_ringRadius = self.frame.size.width/2 - (_ringThickness);
|
||||
}
|
||||
|
||||
@end
|
||||
Generated
-338
@@ -1,338 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
DJProgressHUD_OSX
|
||||
Copyright (C) 2014 Daniel Jackson
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
Generated
-46
@@ -1,46 +0,0 @@
|
||||
DJProgressHUD
|
||||
=================
|
||||
|
||||
Progress and Activity HUD for OSX.
|
||||
|
||||
I am really excited to introduce this ProgressHUD for osx. When I started my first osx app, I noticed that there was not good alternative to SVProgressHUD for the mac. Because this is a such a great tool for displaying a process, I decided to write it for the mac.
|
||||
|
||||
Please let me know if you find this helpfull!
|
||||
|
||||

|
||||
|
||||
##Setup
|
||||
1. Add DJProgressHUD to your application directory
|
||||
2. Ensure ARC is enabled on the project
|
||||
3. Import the control you want to use
|
||||
4. Refer to the samples below for possible display options
|
||||
|
||||
##Whats included:
|
||||
- DJProgressHUD: A class to show a popup view to the user displaying the current progress or an activity indicator.
|
||||
- DJActivityIndicator: A customizable activity indicator. The mac's version, NSProgressIndicator, just doesn't cut it.
|
||||
- DJProgressIndicator: A customizable circular progress view. Change the thickness, radius, size and color. I couldnt find one for the mac. So again, I made one.
|
||||
|
||||
##Code Sample
|
||||
|
||||
Simple Progress - uses progress indicator
|
||||
|
||||
CGFloat currentProgress = 0.33;
|
||||
[DJProgressHUD showProgress:currentProgress withStatus:@"The Progress!" FromView:self.view];
|
||||
...
|
||||
[DJProgressHUD dismiss];
|
||||
|
||||
Simple Status - uses activity indicator
|
||||
|
||||
[DJProgressHUD showStatus:@"INDICATOR" FromView:self.view];
|
||||
...
|
||||
[DJProgressHUD dismiss];
|
||||
|
||||
Progress Indicator - Customizing
|
||||
|
||||
DJProgressIndicator* progress = [[DJProgressIndicator alloc] initWithFrame: ... ];
|
||||
[progress setRingThickness:8];
|
||||
[progress setRingRadius:15];
|
||||
[progress setBackgroundColor:[NSColor clearColor]];
|
||||
[progress setRingColor:[NSColor whiteColor] backgroundRingColor:[NSColor darkGrayColor]];
|
||||
[self.view addSubview:progress];
|
||||
[progress showProgress: 0.33 ];
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// LetsMove.h
|
||||
// LetsMove
|
||||
//
|
||||
// Created by Matt Prowse on 14/05/2016.
|
||||
//
|
||||
// The contents of this file are dedicated to the public domain.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <LetsMove/PFMoveApplication.h>
|
||||
Generated
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// PFMoveApplication.h, version 1.24
|
||||
// LetsMove
|
||||
//
|
||||
// Created by Andy Kim at Potion Factory LLC on 9/17/09
|
||||
//
|
||||
// The contents of this file are dedicated to the public domain.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
Moves the running application to ~/Applications or /Applications if the former does not exist.
|
||||
After the move, it relaunches app from the new location.
|
||||
DOES NOT work for sandboxed applications.
|
||||
|
||||
Call from \c NSApplication's delegate method \c -applicationWillFinishLaunching: method. */
|
||||
void PFMoveToApplicationsFolderIfNecessary(void);
|
||||
|
||||
/**
|
||||
Check whether an app move is currently in progress.
|
||||
Returns YES if LetsMove is currently in-progress trying to move the app to the Applications folder, or NO otherwise.
|
||||
This can be used to work around a crash with apps that terminate after last window is closed.
|
||||
See https://github.com/potionfactory/LetsMove/issues/64 for details. */
|
||||
BOOL PFMoveIsInProgress(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Generated
+567
@@ -0,0 +1,567 @@
|
||||
//
|
||||
// PFMoveApplication.m, version 1.24
|
||||
// LetsMove
|
||||
//
|
||||
// Created by Andy Kim at Potion Factory LLC on 9/17/09
|
||||
//
|
||||
// The contents of this file are dedicated to the public domain.
|
||||
|
||||
#import "PFMoveApplication.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Security/Security.h>
|
||||
#import <dlfcn.h>
|
||||
#import <sys/mount.h>
|
||||
|
||||
@interface LetsMove : NSObject
|
||||
@end
|
||||
|
||||
@implementation LetsMove
|
||||
+ (NSBundle *)bundle {
|
||||
return [NSBundle bundleForClass:self];
|
||||
}
|
||||
@end
|
||||
|
||||
// Strings
|
||||
// These are macros to be able to use custom i18n tools
|
||||
#define _I10NS(nsstr) NSLocalizedStringFromTableInBundle(nsstr, @"MoveApplication", [LetsMove bundle], nil)
|
||||
#define kStrMoveApplicationCouldNotMove _I10NS(@"Could not move to Applications folder")
|
||||
#define kStrMoveApplicationQuestionTitle _I10NS(@"Move to Applications folder?")
|
||||
#define kStrMoveApplicationQuestionTitleHome _I10NS(@"Move to Applications folder in your Home folder?")
|
||||
#define kStrMoveApplicationQuestionMessage _I10NS(@"I can move myself to the Applications folder if you'd like.")
|
||||
#define kStrMoveApplicationButtonMove _I10NS(@"Move to Applications Folder")
|
||||
#define kStrMoveApplicationButtonDoNotMove _I10NS(@"Do Not Move")
|
||||
#define kStrMoveApplicationQuestionInfoWillRequirePasswd _I10NS(@"Note that this will require an administrator password.")
|
||||
#define kStrMoveApplicationQuestionInfoInDownloadsFolder _I10NS(@"This will keep your Downloads folder uncluttered.")
|
||||
|
||||
// Needs to be defined for compiling under 10.5 SDK
|
||||
#ifndef NSAppKitVersionNumber10_5
|
||||
#define NSAppKitVersionNumber10_5 949
|
||||
#endif
|
||||
|
||||
// By default, we use a small control/font for the suppression button.
|
||||
// If you prefer to use the system default (to match your other alerts),
|
||||
// set this to 0.
|
||||
#define PFUseSmallAlertSuppressCheckbox 1
|
||||
|
||||
|
||||
static NSString *AlertSuppressKey = @"moveToApplicationsFolderAlertSuppress";
|
||||
static BOOL MoveInProgress = NO;
|
||||
|
||||
// Helper functions
|
||||
static NSString *PreferredInstallLocation(BOOL *isUserDirectory);
|
||||
static BOOL IsInApplicationsFolder(NSString *path);
|
||||
static BOOL IsInDownloadsFolder(NSString *path);
|
||||
static BOOL IsApplicationAtPathRunning(NSString *path);
|
||||
static BOOL IsApplicationAtPathNested(NSString *path);
|
||||
static NSString *ContainingDiskImageDevice(NSString *path);
|
||||
static BOOL Trash(NSString *path);
|
||||
static BOOL DeleteOrTrash(NSString *path);
|
||||
static BOOL AuthorizedInstall(NSString *srcPath, NSString *dstPath, BOOL *canceled);
|
||||
static BOOL CopyBundle(NSString *srcPath, NSString *dstPath);
|
||||
static NSString *ShellQuotedString(NSString *string);
|
||||
static void Relaunch(NSString *destinationPath);
|
||||
|
||||
// Main worker function
|
||||
void PFMoveToApplicationsFolderIfNecessary(void) {
|
||||
|
||||
// Make sure to do our work on the main thread.
|
||||
// Apparently Electron apps need this for things to work properly.
|
||||
if (![NSThread isMainThread]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
PFMoveToApplicationsFolderIfNecessary();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if user suppressed the alert before
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:AlertSuppressKey]) return;
|
||||
|
||||
// Path of the bundle
|
||||
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
|
||||
|
||||
// Check if the bundle is embedded in another application
|
||||
BOOL isNestedApplication = IsApplicationAtPathNested(bundlePath);
|
||||
|
||||
// Skip if the application is already in some Applications folder,
|
||||
// unless it's inside another app's bundle.
|
||||
if (IsInApplicationsFolder(bundlePath) && !isNestedApplication) return;
|
||||
|
||||
// OK, looks like we'll need to do a move - set the status variable appropriately
|
||||
MoveInProgress = YES;
|
||||
|
||||
// File Manager
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
// Are we on a disk image?
|
||||
NSString *diskImageDevice = ContainingDiskImageDevice(bundlePath);
|
||||
|
||||
// Since we are good to go, get the preferred installation directory.
|
||||
BOOL installToUserApplications = NO;
|
||||
NSString *applicationsDirectory = PreferredInstallLocation(&installToUserApplications);
|
||||
NSString *bundleName = [bundlePath lastPathComponent];
|
||||
NSString *destinationPath = [applicationsDirectory stringByAppendingPathComponent:bundleName];
|
||||
|
||||
// Check if we need admin password to write to the Applications directory
|
||||
BOOL needAuthorization = ([fm isWritableFileAtPath:applicationsDirectory] == NO);
|
||||
|
||||
// Check if the destination bundle is already there but not writable
|
||||
needAuthorization |= ([fm fileExistsAtPath:destinationPath] && ![fm isWritableFileAtPath:destinationPath]);
|
||||
|
||||
// Setup the alert
|
||||
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
|
||||
{
|
||||
NSString *informativeText = nil;
|
||||
|
||||
[alert setMessageText:(installToUserApplications ? kStrMoveApplicationQuestionTitleHome : kStrMoveApplicationQuestionTitle)];
|
||||
|
||||
informativeText = kStrMoveApplicationQuestionMessage;
|
||||
|
||||
if (needAuthorization) {
|
||||
informativeText = [informativeText stringByAppendingString:@" "];
|
||||
informativeText = [informativeText stringByAppendingString:kStrMoveApplicationQuestionInfoWillRequirePasswd];
|
||||
}
|
||||
else if (IsInDownloadsFolder(bundlePath)) {
|
||||
// Don't mention this stuff if we need authentication. The informative text is long enough as it is in that case.
|
||||
informativeText = [informativeText stringByAppendingString:@" "];
|
||||
informativeText = [informativeText stringByAppendingString:kStrMoveApplicationQuestionInfoInDownloadsFolder];
|
||||
}
|
||||
|
||||
[alert setInformativeText:informativeText];
|
||||
|
||||
// Add accept button
|
||||
[alert addButtonWithTitle:kStrMoveApplicationButtonMove];
|
||||
|
||||
// Add deny button
|
||||
NSButton *cancelButton = [alert addButtonWithTitle:kStrMoveApplicationButtonDoNotMove];
|
||||
[cancelButton setKeyEquivalent:[NSString stringWithFormat:@"%C", 0x1b]]; // Escape key
|
||||
|
||||
// Setup suppression button
|
||||
[alert setShowsSuppressionButton:YES];
|
||||
|
||||
if (PFUseSmallAlertSuppressCheckbox) {
|
||||
NSCell *cell = [[alert suppressionButton] cell];
|
||||
[cell setControlSize:NSSmallControlSize];
|
||||
[cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
}
|
||||
}
|
||||
|
||||
// Activate app -- work-around for focus issues related to "scary file from internet" OS dialog.
|
||||
if (![NSApp isActive]) {
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
||||
NSLog(@"INFO -- Moving myself to the Applications folder");
|
||||
|
||||
// Move
|
||||
if (needAuthorization) {
|
||||
BOOL authorizationCanceled;
|
||||
|
||||
if (!AuthorizedInstall(bundlePath, destinationPath, &authorizationCanceled)) {
|
||||
if (authorizationCanceled) {
|
||||
NSLog(@"INFO -- Not moving because user canceled authorization");
|
||||
MoveInProgress = NO;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
NSLog(@"ERROR -- Could not copy myself to /Applications with authorization");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If a copy already exists in the Applications folder, put it in the Trash
|
||||
if ([fm fileExistsAtPath:destinationPath]) {
|
||||
// But first, make sure that it's not running
|
||||
if (IsApplicationAtPathRunning(destinationPath)) {
|
||||
// Give the running app focus and terminate myself
|
||||
NSLog(@"INFO -- Switching to an already running version");
|
||||
[[NSTask launchedTaskWithLaunchPath:@"/usr/bin/open" arguments:[NSArray arrayWithObject:destinationPath]] waitUntilExit];
|
||||
MoveInProgress = NO;
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
if (!Trash([applicationsDirectory stringByAppendingPathComponent:bundleName]))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CopyBundle(bundlePath, destinationPath)) {
|
||||
NSLog(@"ERROR -- Could not copy myself to %@", destinationPath);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
// Trash the original app. It's okay if this fails.
|
||||
// NOTE: This final delete does not work if the source bundle is in a network mounted volume.
|
||||
// Calling rm or file manager's delete method doesn't work either. It's unlikely to happen
|
||||
// but it'd be great if someone could fix this.
|
||||
if (!isNestedApplication && diskImageDevice == nil && !DeleteOrTrash(bundlePath)) {
|
||||
NSLog(@"WARNING -- Could not delete application after moving it to Applications folder");
|
||||
}
|
||||
|
||||
// Relaunch.
|
||||
Relaunch(destinationPath);
|
||||
|
||||
// Launched from within a disk image? -- unmount (if no files are open after 5 seconds,
|
||||
// otherwise leave it mounted).
|
||||
if (diskImageDevice && !isNestedApplication) {
|
||||
NSString *script = [NSString stringWithFormat:@"(/bin/sleep 5 && /usr/bin/hdiutil detach %@) &", ShellQuotedString(diskImageDevice)];
|
||||
[NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", script, nil]];
|
||||
}
|
||||
|
||||
MoveInProgress = NO;
|
||||
exit(0);
|
||||
}
|
||||
// Save the alert suppress preference if checked
|
||||
else if ([[alert suppressionButton] state] == NSOnState) {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:AlertSuppressKey];
|
||||
}
|
||||
|
||||
MoveInProgress = NO;
|
||||
return;
|
||||
|
||||
fail:
|
||||
{
|
||||
// Show failure message
|
||||
alert = [[[NSAlert alloc] init] autorelease];
|
||||
[alert setMessageText:kStrMoveApplicationCouldNotMove];
|
||||
[alert runModal];
|
||||
MoveInProgress = NO;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL PFMoveIsInProgress() {
|
||||
return MoveInProgress;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Helper Functions
|
||||
|
||||
static NSString *PreferredInstallLocation(BOOL *isUserDirectory) {
|
||||
// Return the preferred install location.
|
||||
// Assume that if the user has a ~/Applications folder, they'd prefer their
|
||||
// applications to go there.
|
||||
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
NSArray *userApplicationsDirs = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES);
|
||||
|
||||
if ([userApplicationsDirs count] > 0) {
|
||||
NSString *userApplicationsDir = [userApplicationsDirs objectAtIndex:0];
|
||||
BOOL isDirectory;
|
||||
|
||||
if ([fm fileExistsAtPath:userApplicationsDir isDirectory:&isDirectory] && isDirectory) {
|
||||
// User Applications directory exists. Get the directory contents.
|
||||
NSArray *contents = [fm contentsOfDirectoryAtPath:userApplicationsDir error:NULL];
|
||||
|
||||
// Check if there is at least one ".app" inside the directory.
|
||||
for (NSString *contentsPath in contents) {
|
||||
if ([[contentsPath pathExtension] isEqualToString:@"app"]) {
|
||||
if (isUserDirectory) *isUserDirectory = YES;
|
||||
return [userApplicationsDir stringByResolvingSymlinksInPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No user Applications directory in use. Return the machine local Applications directory
|
||||
if (isUserDirectory) *isUserDirectory = NO;
|
||||
|
||||
return [[NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSLocalDomainMask, YES) lastObject] stringByResolvingSymlinksInPath];
|
||||
}
|
||||
|
||||
static BOOL IsInApplicationsFolder(NSString *path) {
|
||||
// Check all the normal Application directories
|
||||
NSArray *applicationDirs = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES);
|
||||
for (NSString *appDir in applicationDirs) {
|
||||
if ([path hasPrefix:appDir]) return YES;
|
||||
}
|
||||
|
||||
// Also, handle the case that the user has some other Application directory (perhaps on a separate data partition).
|
||||
if ([[path pathComponents] containsObject:@"Applications"]) return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL IsInDownloadsFolder(NSString *path) {
|
||||
NSArray *downloadDirs = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSAllDomainsMask, YES);
|
||||
for (NSString *downloadsDirPath in downloadDirs) {
|
||||
if ([path hasPrefix:downloadsDirPath]) return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL IsApplicationAtPathRunning(NSString *bundlePath) {
|
||||
bundlePath = [bundlePath stringByStandardizingPath];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
|
||||
// Use the new API on 10.6 or higher to determine if the app is already running
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
|
||||
for (NSRunningApplication *runningApplication in [[NSWorkspace sharedWorkspace] runningApplications]) {
|
||||
NSString *runningAppBundlePath = [[[runningApplication bundleURL] path] stringByStandardizingPath];
|
||||
if ([runningAppBundlePath isEqualToString:bundlePath]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
#endif
|
||||
// Use the shell to determine if the app is already running on systems 10.5 or lower
|
||||
NSString *script = [NSString stringWithFormat:@"/bin/ps ax -o comm | /usr/bin/grep %@/ | /usr/bin/grep -v grep >/dev/null", ShellQuotedString(bundlePath)];
|
||||
NSTask *task = [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", script, nil]];
|
||||
[task waitUntilExit];
|
||||
|
||||
// If the task terminated with status 0, it means that the final grep produced 1 or more lines of output.
|
||||
// Which means that the app is already running
|
||||
return [task terminationStatus] == 0;
|
||||
}
|
||||
|
||||
static BOOL IsApplicationAtPathNested(NSString *path) {
|
||||
NSString *containingPath = [path stringByDeletingLastPathComponent];
|
||||
|
||||
NSArray *components = [containingPath pathComponents];
|
||||
for (NSString *component in components) {
|
||||
if ([[component pathExtension] isEqualToString:@"app"]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static NSString *ContainingDiskImageDevice(NSString *path) {
|
||||
NSString *containingPath = [path stringByDeletingLastPathComponent];
|
||||
|
||||
struct statfs fs;
|
||||
if (statfs([containingPath fileSystemRepresentation], &fs) || (fs.f_flags & MNT_ROOTFS))
|
||||
return nil;
|
||||
|
||||
NSString *device = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:fs.f_mntfromname length:strlen(fs.f_mntfromname)];
|
||||
|
||||
NSTask *hdiutil = [[[NSTask alloc] init] autorelease];
|
||||
[hdiutil setLaunchPath:@"/usr/bin/hdiutil"];
|
||||
[hdiutil setArguments:[NSArray arrayWithObjects:@"info", @"-plist", nil]];
|
||||
[hdiutil setStandardOutput:[NSPipe pipe]];
|
||||
[hdiutil launch];
|
||||
[hdiutil waitUntilExit];
|
||||
|
||||
NSData *data = [[[hdiutil standardOutput] fileHandleForReading] readDataToEndOfFile];
|
||||
NSDictionary *info = nil;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
|
||||
info = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:NULL];
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
|
||||
info = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:NULL];
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
|
||||
}
|
||||
#endif
|
||||
|
||||
if (![info isKindOfClass:[NSDictionary class]]) return nil;
|
||||
|
||||
NSArray *images = (NSArray *)[info objectForKey:@"images"];
|
||||
if (![images isKindOfClass:[NSArray class]]) return nil;
|
||||
|
||||
for (NSDictionary *image in images) {
|
||||
if (![image isKindOfClass:[NSDictionary class]]) return nil;
|
||||
|
||||
id systemEntities = [image objectForKey:@"system-entities"];
|
||||
if (![systemEntities isKindOfClass:[NSArray class]]) return nil;
|
||||
|
||||
for (NSDictionary *systemEntity in systemEntities) {
|
||||
if (![systemEntity isKindOfClass:[NSDictionary class]]) return nil;
|
||||
|
||||
NSString *devEntry = [systemEntity objectForKey:@"dev-entry"];
|
||||
if (![devEntry isKindOfClass:[NSString class]]) return nil;
|
||||
|
||||
if ([devEntry isEqualToString:device])
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
static BOOL Trash(NSString *path) {
|
||||
BOOL result = NO;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
||||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_8) {
|
||||
if (@available(macOS 10.8, *)) {
|
||||
result = [[NSFileManager defaultManager] trashItemAtURL:[NSURL fileURLWithPath:path] resultingItemURL:NULL error:NULL];
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
|
||||
if (!result) {
|
||||
result = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation
|
||||
source:[path stringByDeletingLastPathComponent]
|
||||
destination:@""
|
||||
files:[NSArray arrayWithObject:[path lastPathComponent]]
|
||||
tag:NULL];
|
||||
}
|
||||
#endif
|
||||
|
||||
// As a last resort try trashing with AppleScript.
|
||||
// This allows us to trash the app in macOS Sierra even when the app is running inside
|
||||
// an app translocation image.
|
||||
if (!result) {
|
||||
NSAppleScript *appleScript = [[[NSAppleScript alloc] initWithSource:
|
||||
[NSString stringWithFormat:@"\
|
||||
set theFile to POSIX file \"%@\" \n\
|
||||
tell application \"Finder\" \n\
|
||||
move theFile to trash \n\
|
||||
end tell", path]] autorelease];
|
||||
NSDictionary *errorDict = nil;
|
||||
NSAppleEventDescriptor *scriptResult = [appleScript executeAndReturnError:&errorDict];
|
||||
if (scriptResult == nil) {
|
||||
NSLog(@"Trash AppleScript error: %@", errorDict);
|
||||
}
|
||||
result = (scriptResult != nil);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
NSLog(@"ERROR -- Could not trash '%@'", path);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static BOOL DeleteOrTrash(NSString *path) {
|
||||
NSError *error;
|
||||
|
||||
if ([[NSFileManager defaultManager] removeItemAtPath:path error:&error]) {
|
||||
return YES;
|
||||
}
|
||||
else {
|
||||
// Don't log warning if on Sierra and running inside App Translocation path
|
||||
if ([path rangeOfString:@"/AppTranslocation/"].location == NSNotFound)
|
||||
NSLog(@"WARNING -- Could not delete '%@': %@", path, [error localizedDescription]);
|
||||
|
||||
return Trash(path);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL AuthorizedInstall(NSString *srcPath, NSString *dstPath, BOOL *canceled) {
|
||||
if (canceled) *canceled = NO;
|
||||
|
||||
// Make sure that the destination path is an app bundle. We're essentially running 'sudo rm -rf'
|
||||
// so we really don't want to fuck this up.
|
||||
if (![[dstPath pathExtension] isEqualToString:@"app"]) return NO;
|
||||
|
||||
// Do some more checks
|
||||
if ([[dstPath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0) return NO;
|
||||
if ([[srcPath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] == 0) return NO;
|
||||
|
||||
int pid, status;
|
||||
AuthorizationRef myAuthorizationRef;
|
||||
|
||||
// Get the authorization
|
||||
OSStatus err = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &myAuthorizationRef);
|
||||
if (err != errAuthorizationSuccess) return NO;
|
||||
|
||||
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
|
||||
AuthorizationRights myRights = {1, &myItems};
|
||||
AuthorizationFlags myFlags = (AuthorizationFlags)(kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||
|
||||
err = AuthorizationCopyRights(myAuthorizationRef, &myRights, NULL, myFlags, NULL);
|
||||
if (err != errAuthorizationSuccess) {
|
||||
if (err == errAuthorizationCanceled && canceled)
|
||||
*canceled = YES;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
static OSStatus (*security_AuthorizationExecuteWithPrivileges)(AuthorizationRef authorization, const char *pathToTool,
|
||||
AuthorizationFlags options, char * const *arguments,
|
||||
FILE **communicationsPipe) = NULL;
|
||||
if (!security_AuthorizationExecuteWithPrivileges) {
|
||||
// On 10.7, AuthorizationExecuteWithPrivileges is deprecated. We want to still use it since there's no
|
||||
// good alternative (without requiring code signing). We'll look up the function through dyld and fail
|
||||
// if it is no longer accessible. If Apple removes the function entirely this will fail gracefully. If
|
||||
// they keep the function and throw some sort of exception, this won't fail gracefully, but that's a
|
||||
// risk we'll have to take for now.
|
||||
security_AuthorizationExecuteWithPrivileges = (OSStatus (*)(AuthorizationRef, const char*,
|
||||
AuthorizationFlags, char* const*,
|
||||
FILE **)) dlsym(RTLD_DEFAULT, "AuthorizationExecuteWithPrivileges");
|
||||
}
|
||||
if (!security_AuthorizationExecuteWithPrivileges) goto fail;
|
||||
|
||||
// Delete the destination
|
||||
{
|
||||
char *args[] = {"-rf", (char *)[dstPath fileSystemRepresentation], NULL};
|
||||
err = security_AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/bin/rm", kAuthorizationFlagDefaults, args, NULL);
|
||||
if (err != errAuthorizationSuccess) goto fail;
|
||||
|
||||
// Wait until it's done
|
||||
pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status)) goto fail; // We don't care about exit status as the destination most likely does not exist
|
||||
}
|
||||
|
||||
// Copy
|
||||
{
|
||||
char *args[] = {"-pR", (char *)[srcPath fileSystemRepresentation], (char *)[dstPath fileSystemRepresentation], NULL};
|
||||
err = security_AuthorizationExecuteWithPrivileges(myAuthorizationRef, "/bin/cp", kAuthorizationFlagDefaults, args, NULL);
|
||||
if (err != errAuthorizationSuccess) goto fail;
|
||||
|
||||
// Wait until it's done
|
||||
pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) goto fail;
|
||||
}
|
||||
|
||||
AuthorizationFree(myAuthorizationRef, kAuthorizationFlagDefaults);
|
||||
return YES;
|
||||
|
||||
fail:
|
||||
AuthorizationFree(myAuthorizationRef, kAuthorizationFlagDefaults);
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL CopyBundle(NSString *srcPath, NSString *dstPath) {
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
if ([fm copyItemAtPath:srcPath toPath:dstPath error:&error]) {
|
||||
return YES;
|
||||
}
|
||||
else {
|
||||
NSLog(@"ERROR -- Could not copy '%@' to '%@' (%@)", srcPath, dstPath, error);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
static NSString *ShellQuotedString(NSString *string) {
|
||||
return [NSString stringWithFormat:@"'%@'", [string stringByReplacingOccurrencesOfString:@"'" withString:@"'\\''"]];
|
||||
}
|
||||
|
||||
static void Relaunch(NSString *destinationPath) {
|
||||
// The shell script waits until the original app process terminates.
|
||||
// This is done so that the relaunched app opens as the front-most app.
|
||||
int pid = [[NSProcessInfo processInfo] processIdentifier];
|
||||
|
||||
// Command run just before running open /final/path
|
||||
NSString *preOpenCmd = @"";
|
||||
|
||||
NSString *quotedDestinationPath = ShellQuotedString(destinationPath);
|
||||
|
||||
// OS X >=10.5:
|
||||
// Before we launch the new app, clear xattr:com.apple.quarantine to avoid
|
||||
// duplicate "scary file from the internet" dialog.
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
|
||||
// Add the -r flag on 10.6
|
||||
preOpenCmd = [NSString stringWithFormat:@"/usr/bin/xattr -d -r com.apple.quarantine %@", quotedDestinationPath];
|
||||
}
|
||||
else {
|
||||
preOpenCmd = [NSString stringWithFormat:@"/usr/bin/xattr -d com.apple.quarantine %@", quotedDestinationPath];
|
||||
}
|
||||
|
||||
NSString *script = [NSString stringWithFormat:@"(while /bin/kill -0 %d >&/dev/null; do /bin/sleep 0.1; done; %@; /usr/bin/open %@) &", pid, preOpenCmd, quotedDestinationPath];
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:[NSArray arrayWithObjects:@"-c", script, nil]];
|
||||
}
|
||||
Generated
+206
@@ -0,0 +1,206 @@
|
||||
LetsMove
|
||||
========
|
||||
|
||||
A sample project that demonstrates how to move a running Mac OS X application to the Applications folder.
|
||||
|
||||

|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
Builds and runs on Mac OS X 10.6 or higher. Does NOT support sandboxed applications.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Option 1:
|
||||
|
||||
Build then embed LetsMove.framework into your app.
|
||||
|
||||
Option 2:
|
||||
|
||||
Copy the following files into your project:
|
||||
|
||||
- PFMoveApplication.h
|
||||
- PFMoveApplication.m
|
||||
|
||||
If your project has ARC enabled, you'll want to disable ARC on the above files. You can do so by adding -fno-objc-arc compiler flag to your PFMoveApplication.m source file. See http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project/6658549#6658549
|
||||
|
||||
If your application is localized, also copy the 'MoveApplication.string' files into your project.
|
||||
|
||||
Link your application against Security.framework.
|
||||
|
||||
In your app delegate's "-[applicationWillFinishLaunching:]" method, call the PFMoveToApplicationsFolderIfNecessary function at the very top.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
Public domain
|
||||
|
||||
|
||||
|
||||
Version History
|
||||
---------------
|
||||
|
||||
* 1.24
|
||||
- Add PFMoveIsInProgress function
|
||||
- Update project for Xcode 9.1
|
||||
|
||||
* 1.23
|
||||
- Fix localization not being used when built as a framework
|
||||
- Fix backwards compatibility with OS X 10.9 and earlier being broken
|
||||
- Make usable for Electron based apps or other apps that do not have access to the main thread dispatch queue
|
||||
- Update Russian localization
|
||||
|
||||
* 1.22
|
||||
- Fix not deleting or trashing itself after copying to /Applications in macOS Sierra
|
||||
|
||||
* 1.21
|
||||
- Support for [Carthage](https://github.com/Carthage/Carthage) added
|
||||
- Project now support OS X 10.6 and higher
|
||||
|
||||
* 1.20
|
||||
- Support for applications bundled inside another application
|
||||
- Brazilian Portuguese localization slightly updated
|
||||
- Build warnings fixed
|
||||
|
||||
* 1.19
|
||||
- Slovak localization added
|
||||
|
||||
* 1.18
|
||||
- Catalan localization added
|
||||
|
||||
* 1.17
|
||||
- Tranditional Chinese localization added.
|
||||
|
||||
* 1.16
|
||||
- Deprecation warning that appears when minimum deployment target is set to OS X 10.10 taken care of
|
||||
|
||||
* 1.15
|
||||
- Swedish localization added
|
||||
|
||||
* 1.14
|
||||
- Hugarian, Serbian, and Turkish localizations added
|
||||
- Macedonian localization added
|
||||
|
||||
* 1.13
|
||||
- Polish localization added
|
||||
|
||||
* 1.12
|
||||
- Use country code based .lproj directories
|
||||
- Make it compile for projects that don't use precompiled headers to import AppKit.framework
|
||||
- Minor adjustment to Dutch localization
|
||||
- Warning fixes in example project
|
||||
|
||||
* 1.11
|
||||
- Objective-C++ compatibility
|
||||
|
||||
* 1.10
|
||||
- Fixed deprecation warnings that show up when building against the OS X 10.9 SDK.
|
||||
|
||||
* 1.9
|
||||
- Removed OS X 10.4 support
|
||||
- Properly detect if the running app is in a disk image
|
||||
- Fixed a bug where if the app's name contained a quote, the app could not be moved
|
||||
- After a successful move, delete the application instead of moving it to the Trash.
|
||||
- Other fixes and improvements
|
||||
|
||||
* 1.8
|
||||
- If the app is already there in the Applications folder but not writable, request authentication from user
|
||||
- Added Korean localization
|
||||
|
||||
* 1.7.2
|
||||
- Fixed an exception that could happen.
|
||||
|
||||
* 1.7.1
|
||||
- Refactoring
|
||||
|
||||
* 1.7
|
||||
- Only move to ~/Appilcations directory if an app is already in there.
|
||||
|
||||
* 1.6.3
|
||||
- Function calls deprecated in 10.7 no longer cause compile time warnings.
|
||||
- Added Simplified Chinese and European Portuguese localizations
|
||||
|
||||
* 1.6.2
|
||||
- Garbage collection compatibility added
|
||||
- Use a new method to check if an application is already running on Mac OS X 10.6 systems or higher
|
||||
|
||||
* 1.6.1
|
||||
- Use exit(0) to terminate the app before relaunching instead of [NSApp terminate:]. We don't want applicationShouldTerminate or applicationWillTerminate NSApplication delegate methods to be called, possibly introducing side effects.
|
||||
|
||||
* 1.6
|
||||
- Resolve any aliases when finding the Applications directory
|
||||
|
||||
* 1.5.2
|
||||
- Cleaned up the code a bit. Almost functionally equivalent to 1.5.1.
|
||||
|
||||
* 1.5.1
|
||||
- Fixed a bug with clearing the quarantine file attribute on Mac OS X 10.5
|
||||
|
||||
* 1.5
|
||||
- Don't prompt to move the application if it has "Applications" in its path somewhere
|
||||
|
||||
* 1.4
|
||||
- Mac OS X 10.5 compatibility fixes
|
||||
|
||||
* 1.3
|
||||
- Fixed a rare bug in the shell script that checks to see if the app is already running
|
||||
- Clear quarantine flag after copying
|
||||
- Compile time option to show normal sized alert supress checkbox button
|
||||
- German, Danish, and Norwegian localizations added
|
||||
|
||||
* 1.2
|
||||
- Copy application from disk image then unmount disk image
|
||||
- Spanish, French, Dutch, and Russian localizations
|
||||
|
||||
* 1.1
|
||||
- Prefers ~/Applications over /Applications if it exists
|
||||
- Escape key pushes the "Do Not Move" button
|
||||
|
||||
* 1.0
|
||||
- First release
|
||||
|
||||
|
||||
Code Contributors:
|
||||
-------------
|
||||
* Andy Kim
|
||||
* John Brayton
|
||||
* Chad Sellers
|
||||
* Kevin LaCoste
|
||||
* Rasmus Andersson
|
||||
* Timothy J. Wood
|
||||
* Matt Gallagher
|
||||
* Whitney Young
|
||||
* Nick Moore
|
||||
* Nicholas Riley
|
||||
* Matt Prowse
|
||||
* Maxim Ananov
|
||||
* Charlie Stigler
|
||||
|
||||
|
||||
Translators:
|
||||
------------
|
||||
* Eita Hayashi (Japanese)
|
||||
* Gleb M. Borisov, Maxim Ananov (Russian)
|
||||
* Wouter Broekhof (Dutch)
|
||||
* Rasmus Andersson / Spotify (French and Spanish)
|
||||
* Markus Kirschner (German)
|
||||
* Fredrik Nannestad (Danish)
|
||||
* Georg Alexander Bøe (Norwegian)
|
||||
* Marco Improda (Italian)
|
||||
* Venj Chu (Simplified Chinese)
|
||||
* Sérgio Miranda (European Portuguese)
|
||||
* Victor Figueiredo and BR Lingo (Brazilian Portuguese)
|
||||
* AppLingua (Korean)
|
||||
* Czech X Team (Czech)
|
||||
* Marek Telecki (Polish)
|
||||
* Petar Vlahu (Macedonian)
|
||||
* Václav Slavík (Hungarian, Serbian, and Turkish)
|
||||
* Erik Vikström (Swedish)
|
||||
* Inndy Lin (Traditional Chinese)
|
||||
* aONe (Catalan)
|
||||
* Marek Hrusovsky (Slovak)
|
||||
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
+2
@@ -0,0 +1,2 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
Generated
+4208
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
+14
-5
@@ -1,15 +1,24 @@
|
||||
PODS:
|
||||
- DJProgressHUD_OSX (0.0.1)
|
||||
- ITSwitch (1.0)
|
||||
- LetsMove (1.24)
|
||||
- STPrivilegedTask (1.0.1)
|
||||
|
||||
DEPENDENCIES:
|
||||
- DJProgressHUD_OSX
|
||||
- ITSwitch
|
||||
- LetsMove
|
||||
- STPrivilegedTask
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/cocoapods/specs.git:
|
||||
- ITSwitch
|
||||
- LetsMove
|
||||
- STPrivilegedTask
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
DJProgressHUD_OSX: a8de6d2da8750dbf671fcddc649a44a9cd2807c4
|
||||
ITSwitch: 7ff745d6f2a6910e9194b23e4eab9a843258a478
|
||||
LetsMove: fefe56bc7bc7fb7d37049e28a14f297961229fc5
|
||||
STPrivilegedTask: 103f97827454e786074640cf89d303be344498c7
|
||||
|
||||
PODFILE CHECKSUM: 97344994ab3e567a791a6ce5365cd84d23f7c5fa
|
||||
PODFILE CHECKSUM: 4dca32d4d6791341e27820d98c0efe1419299b51
|
||||
|
||||
COCOAPODS: 1.1.1
|
||||
COCOAPODS: 1.7.0.rc.1
|
||||
|
||||
Generated
+803
-472
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -13,11 +13,11 @@
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = '1D1277B04944214E28E206D65F005710'
|
||||
BlueprintName = 'ITSwitch'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'ITSwitch.framework'>
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9A32BAE58F8E5FFB7BE8A59E9B216786"
|
||||
BuildableName = "ITSwitch.framework"
|
||||
BlueprintName = "ITSwitch"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -13,11 +13,11 @@
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = '429E750368B61ABCD8DFF8293D466E7D'
|
||||
BlueprintName = 'DJProgressHUD_OSX'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'DJProgressHUD_OSX.framework'>
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F83960005EA88D0C24A1D277DD0E8667"
|
||||
BuildableName = "LetsMove.framework"
|
||||
BlueprintName = "LetsMove"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -14,7 +14,7 @@
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E3B3A11A3DCF36F6D76E43CB8FB686CB"
|
||||
BlueprintIdentifier = "6822A3C6F352B3FBBC37114BBA826EB3"
|
||||
BuildableName = "Pods_Get_It.framework"
|
||||
BlueprintName = "Pods-Get It"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
@@ -45,7 +45,7 @@
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "E3B3A11A3DCF36F6D76E43CB8FB686CB"
|
||||
BlueprintIdentifier = "6822A3C6F352B3FBBC37114BBA826EB3"
|
||||
BuildableName = "Pods_Get_It.framework"
|
||||
BlueprintName = "Pods-Get It"
|
||||
ReferencedContainer = "container:Pods.xcodeproj">
|
||||
|
||||
+8
-19
@@ -4,12 +4,12 @@
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>DJProgressHUD_OSX.xcscheme</key>
|
||||
<key>ITSwitch.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>ITSwitch.xcscheme</key>
|
||||
<key>LetsMove.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
@@ -19,24 +19,13 @@
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>STPrivilegedTask.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>1D1277B04944214E28E206D65F005710</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>429E750368B61ABCD8DFF8293D466E7D</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>E3B3A11A3DCF36F6D76E43CB8FB686CB</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Generated
+22
@@ -0,0 +1,22 @@
|
||||
# BSD License
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Sveinbjorn Thordarson nor that of any other
|
||||
# contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Generated
+58
@@ -0,0 +1,58 @@
|
||||
# STPrivilegedTask - Objective C class
|
||||
|
||||
An NSTask-like wrapper around AuthorizationExecuteWithPrivileges() in the Security API to run shell commands with root privileges in Mac OS X.
|
||||
|
||||
Example of usage:
|
||||
|
||||
```objective-c
|
||||
STPrivilegedTask *privilegedTask = [[STPrivilegedTask alloc] init];
|
||||
|
||||
[privilegedTask setLaunchPath:@"/usr/bin/touch"];
|
||||
NSArray *args = [NSArray arrayWithObject:@"/etc/my_test_file"];
|
||||
[privilegedTask setArguments:args];
|
||||
[privilegedTask setCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
|
||||
|
||||
//set it off
|
||||
OSStatus err = [privilegedTask launch];
|
||||
if (err != errAuthorizationSuccess) {
|
||||
if (err == errAuthorizationCanceled) {
|
||||
NSLog(@"User cancelled");
|
||||
} else {
|
||||
NSLog(@"Something went wrong");
|
||||
}
|
||||
}
|
||||
|
||||
// Read output file handle for data
|
||||
NSFileHandle *readHandle = [privilegedTask outputFileHandle];
|
||||
NSData *outputData = [readHandle readDataToEndOfFile];
|
||||
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
|
||||
|
||||
```
|
||||
|
||||
# BSD License
|
||||
|
||||
```
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Sveinbjorn Thordarson nor that of any other
|
||||
# contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
```
|
||||
Generated
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
#
|
||||
# STPrivilegedTask - NSTask-like wrapper around AuthorizationExecuteWithPrivileges
|
||||
# Copyright (C) 2009-2015 Sveinbjorn Thordarson <sveinbjornt@gmail.com>
|
||||
#
|
||||
# BSD License
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Sveinbjorn Thordarson nor that of any other
|
||||
# contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
#import <Security/Authorization.h>
|
||||
#import <Security/AuthorizationTags.h>
|
||||
|
||||
#define STPrivilegedTaskDidTerminateNotification @"STPrivilegedTaskDidTerminateNotification"
|
||||
//#define TMP_STDERR_TEMPLATE @".authStderr.XXXXXX"
|
||||
|
||||
// Defines error value for when AuthorizationExecuteWithPrivilleges no longer
|
||||
// exists anyplace. Rather than defining a new enum, we just create a global
|
||||
// constant
|
||||
extern const OSStatus errAuthorizationFnNoLongerExists;
|
||||
|
||||
@interface STPrivilegedTask : NSObject
|
||||
{
|
||||
NSArray *arguments;
|
||||
NSString *cwd;
|
||||
NSString *launchPath;
|
||||
BOOL isRunning;
|
||||
pid_t pid;
|
||||
int terminationStatus;
|
||||
NSFileHandle *outputFileHandle;
|
||||
NSTimer *checkStatusTimer;
|
||||
}
|
||||
-(id)initWithLaunchPath:(NSString *)path;
|
||||
-(id)initWithLaunchPath:(NSString *)path arguments: (NSArray *)args;
|
||||
+(STPrivilegedTask *)launchedPrivilegedTaskWithLaunchPath:(NSString *)path;
|
||||
+(STPrivilegedTask *)launchedPrivilegedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments;
|
||||
-(NSArray *)arguments;
|
||||
-(NSString *)currentDirectoryPath;
|
||||
-(BOOL)isRunning;
|
||||
-(int)launch;
|
||||
-(NSString *)launchPath;
|
||||
-(int)processIdentifier;
|
||||
-(void)setArguments:(NSArray *)arguments;
|
||||
-(void)setCurrentDirectoryPath:(NSString *)path;
|
||||
-(void)setLaunchPath:(NSString *)path;
|
||||
-(NSFileHandle *)outputFileHandle;
|
||||
-(void)terminate; // doesn't work
|
||||
-(int)terminationStatus;
|
||||
-(void)_checkTaskStatus;
|
||||
-(void)waitUntilExit;
|
||||
@end
|
||||
/*static OSStatus AuthorizationExecuteWithPrivilegesStdErrAndPid (
|
||||
AuthorizationRef authorization,
|
||||
const char *pathToTool,
|
||||
AuthorizationFlags options,
|
||||
char * const *arguments,
|
||||
FILE **communicationsPipe,
|
||||
FILE **errPipe,
|
||||
pid_t* processid
|
||||
);*/
|
||||
Generated
+461
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
#
|
||||
# STPrivilegedTask - NSTask-like wrapper around AuthorizationExecuteWithPrivileges
|
||||
# Copyright (C) 2009-2015 Sveinbjorn Thordarson <sveinbjornt@gmail.com>
|
||||
#
|
||||
# BSD License
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Sveinbjorn Thordarson nor that of any other
|
||||
# contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "STPrivilegedTask.h"
|
||||
#import <stdio.h>
|
||||
#import <unistd.h>
|
||||
#import <dlfcn.h>
|
||||
|
||||
/* New error code denoting that AuthorizationExecuteWithPrivileges no longer exists */
|
||||
OSStatus const errAuthorizationFnNoLongerExists = -70001;
|
||||
|
||||
@implementation STPrivilegedTask
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
launchPath = @"";
|
||||
cwd = [[NSString alloc] initWithString:[[NSFileManager defaultManager] currentDirectoryPath]];
|
||||
arguments = [[NSArray alloc] init];
|
||||
isRunning = NO;
|
||||
outputFileHandle = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
#if !__has_feature(objc_arc)
|
||||
[launchPath release];
|
||||
[arguments release];
|
||||
[cwd release];
|
||||
|
||||
if (outputFileHandle != nil) {
|
||||
[outputFileHandle release];
|
||||
}
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
-(id)initWithLaunchPath:(NSString *)path arguments:(NSArray *)args
|
||||
{
|
||||
if ((self = [self initWithLaunchPath:path])) {
|
||||
[self setArguments:args];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithLaunchPath:(NSString *)path
|
||||
{
|
||||
if ((self = [self init])) {
|
||||
[self setLaunchPath:path];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
+(STPrivilegedTask *)launchedPrivilegedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)args
|
||||
{
|
||||
STPrivilegedTask *task = [[STPrivilegedTask alloc] initWithLaunchPath:path arguments:args];
|
||||
#if !__has_feature(objc_arc)
|
||||
[task autorelease];
|
||||
#endif
|
||||
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
return task;
|
||||
}
|
||||
|
||||
+(STPrivilegedTask *)launchedPrivilegedTaskWithLaunchPath:(NSString *)path
|
||||
{
|
||||
STPrivilegedTask *task = [[STPrivilegedTask alloc] initWithLaunchPath:path];
|
||||
#if !__has_feature(objc_arc)
|
||||
[task autorelease];
|
||||
#endif
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
return task;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSArray *)arguments
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
|
||||
- (NSString *)currentDirectoryPath;
|
||||
{
|
||||
return cwd;
|
||||
}
|
||||
|
||||
- (BOOL)isRunning
|
||||
{
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
- (NSString *)launchPath
|
||||
{
|
||||
return launchPath;
|
||||
}
|
||||
|
||||
- (int)processIdentifier
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
|
||||
- (int)terminationStatus
|
||||
{
|
||||
return terminationStatus;
|
||||
}
|
||||
|
||||
- (NSFileHandle *)outputFileHandle;
|
||||
{
|
||||
return outputFileHandle;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
-(void)setArguments:(NSArray *)args
|
||||
{
|
||||
#if !__has_feature(objc_arc)
|
||||
[arguments release];
|
||||
[args retain];
|
||||
#endif
|
||||
arguments = args;
|
||||
}
|
||||
|
||||
-(void)setCurrentDirectoryPath:(NSString *)path
|
||||
{
|
||||
#if !__has_feature(objc_arc)
|
||||
[cwd release];
|
||||
[path retain];
|
||||
#endif
|
||||
cwd = path;
|
||||
}
|
||||
|
||||
-(void)setLaunchPath:(NSString *)path
|
||||
{
|
||||
#if !__has_feature(objc_arc)
|
||||
[launchPath release];
|
||||
[path retain];
|
||||
#endif
|
||||
launchPath = path;
|
||||
}
|
||||
|
||||
# pragma mark -
|
||||
|
||||
// return 0 for success
|
||||
-(int)launch
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
const char *toolPath = [launchPath fileSystemRepresentation];
|
||||
|
||||
AuthorizationRef authorizationRef;
|
||||
AuthorizationItem myItems = {kAuthorizationRightExecute, strlen(toolPath), &toolPath, 0};
|
||||
AuthorizationRights myRights = {1, &myItems};
|
||||
AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
|
||||
|
||||
NSUInteger numberOfArguments = [arguments count];
|
||||
char *args[numberOfArguments + 1];
|
||||
FILE *outputFile;
|
||||
|
||||
// Create fn pointer to AuthorizationExecuteWithPrivileges in case it doesn't exist
|
||||
// in this version of MacOS
|
||||
static OSStatus (*_AuthExecuteWithPrivsFn)(
|
||||
AuthorizationRef authorization, const char *pathToTool, AuthorizationFlags options,
|
||||
char * const *arguments, FILE **communicationsPipe) = NULL;
|
||||
|
||||
// Check to see if we have the correct function in our loaded libraries
|
||||
if (!_AuthExecuteWithPrivsFn) {
|
||||
// On 10.7, AuthorizationExecuteWithPrivileges is deprecated. We want
|
||||
// to still use it since there's no good alternative (without requiring
|
||||
// code signing). We'll look up the function through dyld and fail if
|
||||
// it is no longer accessible. If Apple removes the function entirely
|
||||
// this will fail gracefully. If they keep the function and throw some
|
||||
// sort of exception, this won't fail gracefully, but that's a risk
|
||||
// we'll have to take for now.
|
||||
// Pattern by Andy Kim from Potion Factory LLC
|
||||
_AuthExecuteWithPrivsFn = dlsym(RTLD_DEFAULT, "AuthorizationExecuteWithPrivileges");
|
||||
if (!_AuthExecuteWithPrivsFn) {
|
||||
// This version of OS X has finally removed this function. Exit with an error.
|
||||
err = errAuthorizationFnNoLongerExists;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
// Use Apple's Authentication Manager APIs to get an Authorization Reference
|
||||
// These Apple APIs are quite possibly the most horrible of the Mac OS X APIs
|
||||
|
||||
// create authorization reference
|
||||
err = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef);
|
||||
if (err != errAuthorizationSuccess) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// pre-authorize the privileged operation
|
||||
err = AuthorizationCopyRights(authorizationRef, &myRights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||
if (err != errAuthorizationSuccess) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// OK, at this point we have received authorization for the task.
|
||||
// Let's prepare to launch it
|
||||
|
||||
// first, construct an array of c strings from NSArray w. arguments
|
||||
for (int i = 0; i < numberOfArguments; i++) {
|
||||
NSString *argString = arguments[i];
|
||||
NSUInteger stringLength = [argString length];
|
||||
|
||||
args[i] = malloc((stringLength + 1) * sizeof(char));
|
||||
snprintf(args[i], stringLength + 1, "%s", [argString fileSystemRepresentation]);
|
||||
}
|
||||
args[numberOfArguments] = NULL;
|
||||
|
||||
// change to the current dir specified
|
||||
char *prevCwd = (char *)getcwd(nil, 0);
|
||||
chdir([cwd fileSystemRepresentation]);
|
||||
|
||||
//use Authorization Reference to execute script with privileges
|
||||
err = _AuthExecuteWithPrivsFn(authorizationRef, [launchPath fileSystemRepresentation], kAuthorizationFlagDefaults, args, &outputFile);
|
||||
|
||||
// OK, now we're done executing, let's change back to old dir
|
||||
chdir(prevCwd);
|
||||
|
||||
// free the malloc'd argument strings
|
||||
for (int i = 0; i < numberOfArguments; i++) {
|
||||
free(args[i]);
|
||||
}
|
||||
|
||||
// free the auth ref
|
||||
AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
|
||||
|
||||
// we return err if execution failed
|
||||
if (err != errAuthorizationSuccess) {
|
||||
return err;
|
||||
} else {
|
||||
isRunning = YES;
|
||||
}
|
||||
|
||||
// get file handle for the command output
|
||||
outputFileHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileno(outputFile) closeOnDealloc:YES];
|
||||
pid = fcntl(fileno(outputFile), F_GETOWN, 0);
|
||||
|
||||
// start monitoring task
|
||||
checkStatusTimer = [NSTimer scheduledTimerWithTimeInterval:0.10 target:self selector:@selector(_checkTaskStatus) userInfo:nil repeats:YES];
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
- (void)terminate
|
||||
{
|
||||
// This doesn't work without a PID, and we can't get one. Stupid Security API
|
||||
/* int ret = kill(pid, SIGKILL);
|
||||
|
||||
if (ret != 0)
|
||||
NSLog(@"Error %d", errno);*/
|
||||
}
|
||||
|
||||
// hang until task is done
|
||||
- (void)waitUntilExit
|
||||
{
|
||||
waitpid([self processIdentifier], &terminationStatus, 0);
|
||||
isRunning = NO;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// check if privileged task is still running
|
||||
- (void)_checkTaskStatus
|
||||
{
|
||||
// see if task has terminated
|
||||
int mypid = waitpid([self processIdentifier], &terminationStatus, WNOHANG);
|
||||
if (mypid != 0) {
|
||||
isRunning = NO;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:STPrivilegedTaskDidTerminateNotification object:self];
|
||||
[checkStatusTimer invalidate];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSArray *args = [self arguments];
|
||||
NSString *cmd = [[self launchPath] copy];
|
||||
|
||||
for (int i = 0; i < [args count]; i++) {
|
||||
cmd = [cmd stringByAppendingFormat:@" %@", args[i]];
|
||||
}
|
||||
|
||||
return [[super description] stringByAppendingFormat:@" %@", cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
*
|
||||
* Add the Standard err Pipe and Pid support to AuthorizationExecuteWithPrivileges()
|
||||
* method
|
||||
*
|
||||
* @Author: Miklós Fazekas
|
||||
* Modified Aug 10 2010 by Sveinbjorn Thordarson
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*static OSStatus AuthorizationExecuteWithPrivilegesStdErrAndPid (
|
||||
AuthorizationRef authorization,
|
||||
const char *pathToTool,
|
||||
AuthorizationFlags options,
|
||||
char * const *arguments,
|
||||
FILE **communicationsPipe,
|
||||
FILE **errPipe,
|
||||
pid_t* processid
|
||||
)
|
||||
{
|
||||
// get the Apple-approved secure temp directory
|
||||
NSString *tempFileTemplate = [NSTemporaryDirectory() stringByAppendingPathComponent: TMP_STDERR_TEMPLATE];
|
||||
|
||||
// copy it into a C string
|
||||
const char *tempFileTemplateCString = [tempFileTemplate fileSystemRepresentation];
|
||||
char *stderrpath = (char *)malloc(strlen(tempFileTemplateCString) + 1);
|
||||
strcpy(stderrpath, tempFileTemplateCString);
|
||||
|
||||
printf("%s\n", stderrpath);
|
||||
|
||||
// this is the command, it echoes pid and directs stderr output to pipe before running the tool w. args
|
||||
const char *commandtemplate = "echo $$; \"$@\" 2>%s";
|
||||
|
||||
if (communicationsPipe == errPipe)
|
||||
commandtemplate = "echo $$; \"$@\" 2>1";
|
||||
else if (errPipe == 0)
|
||||
commandtemplate = "echo $$; \"$@\"";
|
||||
|
||||
char command[1024];
|
||||
char **args;
|
||||
OSStatus result;
|
||||
int argcount = 0;
|
||||
int i;
|
||||
int stderrfd = 0;
|
||||
FILE *commPipe = 0;
|
||||
|
||||
// First, create temporary file for stderr
|
||||
if (errPipe)
|
||||
{
|
||||
// create temp file
|
||||
stderrfd = mkstemp(stderrpath);
|
||||
|
||||
// close and remove it
|
||||
close(stderrfd);
|
||||
unlink(stderrpath);
|
||||
|
||||
// create a pipe on the path of the temp file
|
||||
if (mkfifo(stderrpath,S_IRWXU | S_IRWXG) != 0)
|
||||
{
|
||||
fprintf(stderr,"Error mkfifo:%d\n", errno);
|
||||
return errAuthorizationInternal;
|
||||
}
|
||||
|
||||
if (stderrfd < 0)
|
||||
return errAuthorizationInternal;
|
||||
}
|
||||
|
||||
// Create command to be executed
|
||||
for (argcount = 0; arguments[argcount] != 0; ++argcount) {}
|
||||
args = (char**)malloc (sizeof(char*)*(argcount + 5));
|
||||
args[0] = "-c";
|
||||
snprintf (command, sizeof (command), commandtemplate, stderrpath);
|
||||
args[1] = command;
|
||||
args[2] = "";
|
||||
args[3] = (char*)pathToTool;
|
||||
for (i = 0; i < argcount; ++i) {
|
||||
args[i+4] = arguments[i];
|
||||
}
|
||||
args[argcount+4] = 0;
|
||||
|
||||
// for debugging: log the executed command
|
||||
printf ("Exec:\n%s", "/bin/sh"); for (i = 0; args[i] != 0; ++i) { printf (" \"%s\"", args[i]); } printf ("\n");
|
||||
|
||||
// Execute command
|
||||
result = AuthorizationExecuteWithPrivileges(authorization, "/bin/sh", options, args, &commPipe );
|
||||
if (result != noErr)
|
||||
{
|
||||
unlink (stderrpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Read the first line of stdout => it's the pid
|
||||
{
|
||||
int stdoutfd = fileno (commPipe);
|
||||
char pidnum[1024];
|
||||
pid_t pid = 0;
|
||||
int i = 0;
|
||||
char ch = 0;
|
||||
|
||||
while ((read(stdoutfd, &ch, sizeof(ch)) == 1) && (ch != '\n') && (i < sizeof(pidnum)))
|
||||
{
|
||||
pidnum[i++] = ch;
|
||||
}
|
||||
pidnum[i] = 0;
|
||||
|
||||
if (ch != '\n')
|
||||
{
|
||||
// we shouldn't get there
|
||||
unlink (stderrpath);
|
||||
return errAuthorizationInternal;
|
||||
}
|
||||
sscanf(pidnum, "%d", &pid);
|
||||
if (processid)
|
||||
{
|
||||
*processid = pid;
|
||||
}
|
||||
NSLog(@"Have PID %d", pid);
|
||||
}
|
||||
|
||||
//
|
||||
if (errPipe) {
|
||||
stderrfd = open(stderrpath, O_RDONLY, 0);
|
||||
// *errPipe = fdopen(stderrfd, "r");
|
||||
//Now it's safe to unlink the stderr file, as the opened handle will be still valid
|
||||
unlink (stderrpath);
|
||||
} else {
|
||||
unlink(stderrpath);
|
||||
}
|
||||
|
||||
if (communicationsPipe)
|
||||
*communicationsPipe = commPipe;
|
||||
else
|
||||
fclose (commPipe);
|
||||
|
||||
NSLog(@"AuthExecNew function over");
|
||||
|
||||
return noErr;
|
||||
}*/
|
||||
@@ -1,5 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_DJProgressHUD_OSX : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_DJProgressHUD_OSX
|
||||
@end
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#import "DJActivityIndicator.h"
|
||||
#import "DJBezierPath.h"
|
||||
#import "DJProgressHUD.h"
|
||||
#import "DJProgressIndicator.h"
|
||||
|
||||
FOUNDATION_EXPORT double DJProgressHUD_OSXVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char DJProgressHUD_OSXVersionString[];
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module DJProgressHUD_OSX {
|
||||
umbrella header "DJProgressHUD_OSX-umbrella.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
CODE_SIGN_IDENTITY =
|
||||
CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/DJProgressHUD_OSX
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public"
|
||||
OTHER_LDFLAGS = -framework "QuartzCore"
|
||||
PODS_BUILD_DIR = $BUILD_DIR
|
||||
PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
|
||||
SKIP_INSTALL = YES
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.1</string>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
@@ -1,4 +1,12 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "ITSwitch.h"
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
CODE_SIGN_IDENTITY =
|
||||
CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/ITSwitch
|
||||
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ITSwitch
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public"
|
||||
OTHER_LDFLAGS = -framework "QuartzCore"
|
||||
PODS_BUILD_DIR = $BUILD_DIR
|
||||
PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
OTHER_LDFLAGS = $(inherited) -framework "QuartzCore"
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
PODS_TARGET_SRCROOT = ${PODS_ROOT}/ITSwitch
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
|
||||
SKIP_INSTALL = YES
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.24.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.24.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_LetsMove : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_LetsMove
|
||||
@end
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user