mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b186dc939 | ||
|
|
22dff08b8d | ||
|
|
b9e94d49ae | ||
|
|
867a91cbe4 | ||
|
|
aadadeef5b | ||
|
|
7b7e3f6e23 | ||
|
|
e2e37da3ce | ||
|
|
6d861c5d92 | ||
|
|
80dee159de | ||
|
|
de9ec2a849 | ||
|
|
7a1f627c79 | ||
|
|
cf7711fb83 | ||
|
|
c7ec996c23 | ||
|
|
a8c2a98379 | ||
|
|
7148c0f3e6 | ||
|
|
05b5758058 | ||
|
|
c2f498f157 | ||
|
|
e11f8387b2 | ||
|
|
d3198961d7 | ||
|
|
3f37fe7674 | ||
|
|
245b4e1608 | ||
|
|
9516d6d667 | ||
|
|
b13b57e800 | ||
|
|
9480f40522 | ||
|
|
32d4de464d | ||
|
|
578666e9e6 | ||
|
|
591d7d0049 | ||
|
|
417e018432 | ||
|
|
fa2a121217 | ||
|
|
5a3fd1e12a | ||
|
|
cb19fe8864 | ||
|
|
fb206d9f71 | ||
|
|
83c93809c4 | ||
|
|
b95f5bc83c | ||
|
|
35efebf76f | ||
|
|
cca13834ca | ||
|
|
c36aee449d | ||
|
|
2d15514466 | ||
|
|
2471a5f05d | ||
|
|
d61e0d57a9 | ||
|
|
7dc42eb6ea | ||
|
|
59114fb9dc | ||
|
|
8f73838fa0 | ||
|
|
fce6957a66 | ||
|
|
def8cfa1ff | ||
|
|
99df53ba96 | ||
|
|
77d16de08a | ||
|
|
e040ccfef1 | ||
|
|
f2ca019cb0 | ||
|
|
336db58e96 | ||
|
|
6826505d3e | ||
|
|
8e41993ead | ||
|
|
19c3d2ebf3 | ||
|
|
c9a631d2e4 | ||
|
|
f2cd127729 | ||
|
|
b001a3e52e | ||
|
|
c9bb1bf81c | ||
|
|
d9c287c899 | ||
|
|
18d7c5f8cd | ||
|
|
4697623be6 | ||
|
|
4f1cfa0d9c | ||
|
|
697a3436e5 | ||
|
|
ae72844847 | ||
|
|
8385dfd0f4 | ||
|
|
31ee181ad2 | ||
|
|
0e14c9ca6a | ||
|
|
aac2a91833 | ||
|
|
ce10ccd97e | ||
|
|
77a58843fe | ||
|
|
3b1f97a298 | ||
|
|
7e4f74af14 | ||
|
|
4ac95c9560 | ||
|
|
6d7092f10a | ||
|
|
c209639c4d | ||
|
|
9ec502f5ab | ||
|
|
8ae0f10162 | ||
|
|
6b86508d38 | ||
|
|
841e14e8b8 | ||
|
|
2bc1de6f1f | ||
|
|
3604e36917 | ||
|
|
69f349397b | ||
|
|
c778dff301 | ||
|
|
51a012896f | ||
|
|
66962fe8d8 | ||
|
|
b463afee27 | ||
|
|
71c7e2f9a2 | ||
|
|
969622840d | ||
|
|
6910ce4413 | ||
|
|
1c5523ed83 | ||
|
|
b87a89c24d | ||
|
|
5106d7010a | ||
|
|
1a968424db | ||
|
|
000c4a9832 | ||
|
|
66b734322d | ||
|
|
93e339f32e |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
language: objective-c
|
||||
script: make travis
|
||||
@@ -1,3 +1,14 @@
|
||||
# 1.8.0
|
||||
|
||||
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
|
||||
* Detailed error log for failed signature checks (Kornel Lesiński)
|
||||
* Converted Sparkle to ARC (C.W. Betts)
|
||||
* Converted ivars to properties. (Jake Petroules)
|
||||
* Cocoapod support (Xhacker Liu)
|
||||
* Quarantine removal on OS X 10.10 (C.W. Betts)
|
||||
* Updated Japanese localization (1024jp)
|
||||
* Added Greek localization
|
||||
|
||||
# 1.7.1
|
||||
|
||||
* Removed option to install unverified updates (Kornel Lesiński)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
FINISH_INSTALL_TOOL_NAME = Autoupdate
|
||||
|
||||
SPARKLE_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 7
|
||||
SPARKLE_VERSION_PATCH = 1
|
||||
SPARKLE_VERSION_MINOR = 8
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
|
||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||
@@ -15,6 +15,7 @@ ARCHS = $(ARCHS_STANDARD)
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
|
||||
// Enable warnings
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
||||
@@ -55,7 +56,7 @@ GCC_WARN_UNUSED_PARAMETER = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
|
||||
// These should be removed once the conversion to ARC is complete
|
||||
WARNING_CFLAGS_EXTRA = -Wno-objc-interface-ivars -Wno-direct-ivar-access -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
|
||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression $(WARNING_CFLAGS_EXTRA)
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak $(WARNING_CFLAGS_EXTRA)
|
||||
@@ -9,3 +9,4 @@ FRAMEWORK_VERSION = A
|
||||
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
|
||||
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
|
||||
SKIP_INSTALL = YES
|
||||
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
|
||||
@@ -5,3 +5,4 @@ PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
GCC_PREFIX_HEADER = Sparkle/Autoupdate/Autoupdate.pch
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
|
||||
@@ -4,3 +4,4 @@ INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
|
||||
PRODUCT_NAME = Sparkle Test App
|
||||
WRAPPER_EXTENSION = app
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||
CLANG_ENABLE_OBJC_ARC = NO
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.zip"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
@@ -16,6 +16,7 @@ if [ "$ACTION" = "" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||
zip --symlinks -r "../Sparkle-$CURRENT_PROJECT_VERSION.zip" .
|
||||
# Sorted file list groups similar files together, which improves tar compression
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
fi
|
||||
@@ -1,6 +1,10 @@
|
||||
Copyright (c) 2006-2014 Andy Matuschak
|
||||
Copyright (c) 2013-2014 Kornel Lesinski
|
||||
Copyright (c) 2014 Petroules Corporation, Sparkle Project contributors
|
||||
© 2006-2013 Andy Matuschak
|
||||
© 2009-2013 Elgato Systems GmbH.
|
||||
© 2011-2014 Kornel Lesiński
|
||||
© 2014 C.W. Betts
|
||||
© 2014 Petroules Corporation, Sparkle Project contributors
|
||||
© 2014 Big Nerd Ranch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -23,10 +27,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
EXTERNAL LICENSES
|
||||
=================
|
||||
|
||||
License for bsdiff.c and bspatch.c, from bsdiff 4.3 (<http://www.daemonology.net/bsdiff/>):
|
||||
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>: © 2003-2005 Colin Percival.
|
||||
SUDSAVerifier.m: © 2011 Mark Hamlin.
|
||||
|
||||
Copyright 2003-2005 Colin Percival
|
||||
All rights reserved
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted providing that the following conditions
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
.PHONY: all localizable-strings
|
||||
.PHONY: all localizable-strings release build test travis
|
||||
|
||||
builddir := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
||||
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
||||
|
||||
localizable-strings:
|
||||
rm Sparkle/en.lproj/Sparkle.strings || TRUE
|
||||
rm -f Sparkle/en.lproj/Sparkle.strings
|
||||
genstrings -o Sparkle/en.lproj -s SULocalizedString Sparkle/*.m Sparkle/*.h
|
||||
iconv -f UTF-16 -t UTF-8 < Sparkle/en.lproj/Localizable.strings > Sparkle/en.lproj/Sparkle.strings
|
||||
rm Sparkle/en.lproj/Localizable.strings
|
||||
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(builddir)"
|
||||
open -R "$(builddir)/Build/Products/Release/Sparkle-"*.zip
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)"
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||
|
||||
build:
|
||||
xcodebuild clean build
|
||||
|
||||
test:
|
||||
xcodebuild -target 'Sparkle Unit Tests' -scheme 'Sparkle' test
|
||||
|
||||
travis: test
|
||||
+15
-16
@@ -1,31 +1,30 @@
|
||||
# Sparkle <img src="Resources/Sparkle.png" width=48 height=48 alt=""/>
|
||||
is an easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
## Changes since 1.5
|
||||
[](https://travis-ci.org/sparkle-project/Sparkle)
|
||||
|
||||
* Up to date with 10.9 SDK and Xcode 5/6. Supports OS X 10.7+.
|
||||
## Changes since 1.5b
|
||||
|
||||
* Up-to-date with 10.10 SDK and Xcode 6. Supports OS X 10.7+.
|
||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
||||
* Merged official Sparkle branch with truly automatic background updates (no UI at all)
|
||||
when user agreed to "Automatically download and install updates in the future."
|
||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
* Name of finish_installation.app can be configured to match your app's name.
|
||||
|
||||
## Features
|
||||
|
||||
* True self-updating—no work required from the user.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* True self-updating—the user can choose to automatically download and install all updates.
|
||||
* Displays a detailed progress window to the user.
|
||||
* Supports authentication for installing in secure locations.
|
||||
* Really, really easy to install.
|
||||
* Uses appcasts for release information.
|
||||
* The user can choose to automatically download and install all updates.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Supports DSA signatures for ultra-secure updates.
|
||||
* Sparkle requires no code in your app, so it's trivial to upgrade or remove the module.
|
||||
* Optionally sends user demographic information to the server when checking for updates.
|
||||
* Supports Apple code signing and DSA signatures for ultra-secure updates.
|
||||
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
|
||||
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
||||
* Sparkle can install .pkg files for more complicated products.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Deep delegate support to make Sparkle work exactly as you need.
|
||||
* Optionally sends system information to the server when checking for updates.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
@@ -0,0 +1,26 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.7.1"
|
||||
s.summary = "A software update framework for OS X"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "https://github.com/sparkle-project/Sparkle"
|
||||
s.license = {
|
||||
:type => 'MIT',
|
||||
:file => 'LICENSE'
|
||||
}
|
||||
s.authors = {
|
||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||
'Kornel Lesiński' => 'pornel@pornel.net',
|
||||
'C.W. Betts' => 'computers57@hotmail.com',
|
||||
'Jake Petroules' => 'jake.petroules@petroules.com',
|
||||
}
|
||||
|
||||
s.platform = :osx
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.zip" }
|
||||
|
||||
s.public_header_files = 'Sparkle.framework/Headers/*.h'
|
||||
s.vendored_framework = 'Sparkle.framework'
|
||||
s.resources = 'Sparkle.framework'
|
||||
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
|
||||
s.requires_arc = false
|
||||
end
|
||||
@@ -25,11 +25,9 @@
|
||||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1420DE301962082C00203BB0 /* (null) in Resources */ = {isa = PBXBuildFile; };
|
||||
1420DE3119620A6600203BB0 /* (null) in Resources */ = {isa = PBXBuildFile; };
|
||||
1420DF50196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
|
||||
1420DF51196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
|
||||
14732BC01960F2C200593899 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14732BBF1960F0AC00593899 /* dsa_pub.pem */; };
|
||||
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */; };
|
||||
14732BD019610A0D00593899 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
14732BD119610A1200593899 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
14732BD319610A1800593899 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14732BD219610A1800593899 /* XCTest.framework */; };
|
||||
@@ -65,6 +63,7 @@
|
||||
55C14F7E136F005000649790 /* SUPlainInstallerInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */; };
|
||||
55C14F9A136F045400649790 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
|
||||
55C14FC7136F05E100649790 /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; };
|
||||
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; };
|
||||
5D06E8D80FD68C8E005AE3F6 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
|
||||
5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */; };
|
||||
@@ -76,7 +75,7 @@
|
||||
5D06E9050FD68D7D005AE3F6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */; };
|
||||
5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */; };
|
||||
5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
|
||||
5D1AF58B0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
|
||||
5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; };
|
||||
5D1AF59A0FD767E50065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
|
||||
@@ -89,7 +88,6 @@
|
||||
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
|
||||
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; };
|
||||
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; };
|
||||
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */; };
|
||||
610EC1E00CF3A5FE00AE239E /* NTSynchronousTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */; };
|
||||
611142E910FB1BE5009810AA /* bspatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 611142E810FB1BE5009810AA /* bspatch.h */; };
|
||||
61177A1F0D1112E900749C97 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6117796E0D1112E000749C97 /* IOKit.framework */; };
|
||||
@@ -108,7 +106,7 @@
|
||||
61299B3609CB04E000B7442F /* Sparkle.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299B3509CB04E000B7442F /* Sparkle.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
612DCBAF0D488BC60015DBEA /* SUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */; settings = {ATTRIBUTES = (); }; };
|
||||
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */ = {isa = PBXBuildFile; fileRef = 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */; };
|
||||
61407C390A4099050009F71F /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
61407C390A4099050009F71F /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6158A1C4137904B300487EC1 /* SUUpdater_Private.h */; };
|
||||
615AE3D00D64DC40001CA7BD /* SUModelTranslation.plist in Resources */ = {isa = PBXBuildFile; fileRef = 615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */; };
|
||||
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */; settings = {ATTRIBUTES = (); }; };
|
||||
@@ -255,14 +253,15 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
61B5FB4D09C4E9FA00B25A18 /* CopyFiles */ = {
|
||||
61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
61407C390A4099050009F71F /* Sparkle.framework in CopyFiles */,
|
||||
61407C390A4099050009F71F /* Sparkle.framework in Copy Frameworks */,
|
||||
);
|
||||
name = "Copy Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
@@ -285,20 +284,23 @@
|
||||
14732BB91960EEEE00593899 /* SampleAppcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SampleAppcast.xml; sourceTree = "<group>"; };
|
||||
14732BBA1960EF7100593899 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = SOURCE_ROOT; };
|
||||
14732BBC1960EFB500593899 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = SOURCE_ROOT; };
|
||||
14732BBE1960F0A600593899 /* dsa_priv.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = dsa_priv.pem; sourceTree = "<group>"; };
|
||||
14732BBF1960F0AC00593899 /* dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
|
||||
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = test_app_only_dsa_pub.pem; sourceTree = "<group>"; };
|
||||
14732BC11960F3B200593899 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = SOURCE_ROOT; usesTabs = 1; };
|
||||
14732BC31960F3FF00593899 /* generate_keys.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_keys.sh; sourceTree = "<group>"; };
|
||||
14732BC41960F3FF00593899 /* sign_update.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update.sh; sourceTree = "<group>"; };
|
||||
14732BC91960F70A00593899 /* make-release-package.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "make-release-package.sh"; sourceTree = "<group>"; };
|
||||
14732BD219610A1800593899 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
||||
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdaterTest.m; path = Tests/SUUpdaterTest.m; sourceTree = "<group>"; };
|
||||
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdaterTest.m; path = Tests/SUUpdaterTest.m; sourceTree = "<group>"; usesTabs = 0; };
|
||||
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = "<group>"; };
|
||||
4607BEA21948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
4607BEA31948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUAutomaticUpdateAlert.xib; sourceTree = "<group>"; };
|
||||
4607BEA41948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUUpdateAlert.xib; sourceTree = "<group>"; };
|
||||
4607BEA51948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUUpdatePermissionPrompt.xib; sourceTree = "<group>"; };
|
||||
525A278F133D6AE900FD8D70 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
555CF29A196C52330000B31E /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
555CF29B196C523E0000B31E /* el */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = el; path = el.lproj/SUAutomaticUpdateAlert.xib; sourceTree = "<group>"; };
|
||||
555CF29C196C52460000B31E /* el */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = el; path = el.lproj/SUUpdateAlert.xib; sourceTree = "<group>"; };
|
||||
555CF29D196C524C0000B31E /* el */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = el; path = el.lproj/SUUpdatePermissionPrompt.xib; sourceTree = "<group>"; };
|
||||
55C14BB7136EEF1500649790 /* Autoupdate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Autoupdate.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
55C14BB9136EEF1500649790 /* Autoupdate-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Autoupdate-Info.plist"; sourceTree = "<group>"; };
|
||||
55C14BD3136EEFCE00649790 /* Autoupdate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Autoupdate.m; sourceTree = "<group>"; };
|
||||
@@ -362,6 +364,7 @@
|
||||
55C14F0E136EF73600649790 /* Autoupdate.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autoupdate.pch; sourceTree = "<group>"; };
|
||||
55C14F31136EFC2400649790 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUDSAVerifierTest.m; path = Tests/SUDSAVerifierTest.m; sourceTree = "<group>"; };
|
||||
5D06E8D00FD68C7C005AE3F6 /* BinaryDelta */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = BinaryDelta; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */ = {isa = PBXFileReference; comments = "-Wno-shorten-64-to-32"; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bsdiff.c; sourceTree = "<group>"; };
|
||||
5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bspatch.c; sourceTree = "<group>"; };
|
||||
@@ -387,7 +390,6 @@
|
||||
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = "<group>"; };
|
||||
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = "<group>"; };
|
||||
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver_Private.h; sourceTree = "<group>"; };
|
||||
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUnarchiver_Private.m; sourceTree = "<group>"; };
|
||||
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTSynchronousTask.m; sourceTree = "<group>"; };
|
||||
610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTSynchronousTask.h; sourceTree = "<group>"; };
|
||||
611142E810FB1BE5009810AA /* bspatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bspatch.h; sourceTree = "<group>"; };
|
||||
@@ -750,7 +752,6 @@
|
||||
61299A8B09CA790200B7442F /* SUUnarchiver.h */,
|
||||
61299A8C09CA790200B7442F /* SUUnarchiver.m */,
|
||||
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */,
|
||||
6102FE5A0E08C7EC00F85D09 /* SUUnarchiver_Private.m */,
|
||||
);
|
||||
name = Unarchiving;
|
||||
sourceTree = "<group>";
|
||||
@@ -759,6 +760,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */,
|
||||
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */,
|
||||
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */,
|
||||
61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */,
|
||||
);
|
||||
@@ -833,8 +835,7 @@
|
||||
61B5F91D09C4CF7F00B25A18 /* Test Application */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
14732BBE1960F0A600593899 /* dsa_priv.pem */,
|
||||
14732BBF1960F0AC00593899 /* dsa_pub.pem */,
|
||||
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */,
|
||||
61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */,
|
||||
61B5F92409C4CFC900B25A18 /* main.m */,
|
||||
61B5F92C09C4CFD800B25A18 /* MainMenu.xib */,
|
||||
@@ -1063,7 +1064,7 @@
|
||||
61B5F8FE09C4CEE200B25A18 /* Resources */,
|
||||
61B5F8FF09C4CEE200B25A18 /* Sources */,
|
||||
61B5F90009C4CEE200B25A18 /* Frameworks */,
|
||||
61B5FB4D09C4E9FA00B25A18 /* CopyFiles */,
|
||||
61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -1105,7 +1106,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
CLASSPREFIX = SU;
|
||||
LastUpgradeCheck = 0510;
|
||||
LastUpgradeCheck = 0600;
|
||||
ORGANIZATIONNAME = "Sparkle Project";
|
||||
TargetAttributes = {
|
||||
612279D80DB5470200AB99EA = {
|
||||
@@ -1158,6 +1159,7 @@
|
||||
uk,
|
||||
ar,
|
||||
nb,
|
||||
el,
|
||||
);
|
||||
mainGroup = 0867D691FE84028FC02AAC07 /* Sparkle */;
|
||||
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
|
||||
@@ -1181,7 +1183,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1420DE3119620A6600203BB0 /* (null) in Resources */,
|
||||
1420DF51196247F900203BB0 /* Images.xcassets in Resources */,
|
||||
55C14FC7136F05E100649790 /* Sparkle.strings in Resources */,
|
||||
55C14BD9136EF00C00649790 /* SUStatus.xib in Resources */,
|
||||
@@ -1199,8 +1200,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1420DE301962082C00203BB0 /* (null) in Resources */,
|
||||
14732BC01960F2C200593899 /* dsa_pub.pem in Resources */,
|
||||
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */,
|
||||
1420DF50196247F900203BB0 /* Images.xcassets in Resources */,
|
||||
61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */,
|
||||
61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */,
|
||||
@@ -1337,6 +1337,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */,
|
||||
14950075195FDF5900BC5B5B /* SUUpdaterTest.m in Sources */,
|
||||
61227A160DB548B800AB99EA /* SUVersionComparisonTest.m in Sources */,
|
||||
);
|
||||
@@ -1382,7 +1383,6 @@
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
|
||||
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
|
||||
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */,
|
||||
6102FE5C0E08C7EC00F85D09 /* SUUnarchiver_Private.m in Sources */,
|
||||
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */,
|
||||
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */,
|
||||
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
|
||||
@@ -1470,6 +1470,7 @@
|
||||
55C14BDB136EF20D00649790 /* cs */,
|
||||
55C14BDC136EF20D00649790 /* da */,
|
||||
55C14BDD136EF20D00649790 /* de */,
|
||||
555CF29B196C523E0000B31E /* el */,
|
||||
55C14BDE136EF20D00649790 /* en */,
|
||||
55C14BDF136EF20D00649790 /* es */,
|
||||
55C14BE0136EF20D00649790 /* fr */,
|
||||
@@ -1503,6 +1504,7 @@
|
||||
55C14BF1136EF26100649790 /* cs */,
|
||||
55C14BF2136EF26100649790 /* da */,
|
||||
55C14BF3136EF26100649790 /* de */,
|
||||
555CF29C196C52460000B31E /* el */,
|
||||
55C14BF4136EF26100649790 /* en */,
|
||||
55C14BF5136EF26100649790 /* es */,
|
||||
55C14BF6136EF26100649790 /* fr */,
|
||||
@@ -1536,6 +1538,7 @@
|
||||
55C14C06136EF2C700649790 /* cs */,
|
||||
55C14C07136EF2C700649790 /* da */,
|
||||
55C14C08136EF2C700649790 /* de */,
|
||||
555CF29D196C524C0000B31E /* el */,
|
||||
55C14C09136EF2C700649790 /* en */,
|
||||
55C14C0A136EF2C700649790 /* es */,
|
||||
55C14C0B136EF2C700649790 /* fr */,
|
||||
@@ -1569,6 +1572,7 @@
|
||||
615409C4103BBC4000125AF1 /* cs */,
|
||||
61131A050F846CE600E97AF6 /* da */,
|
||||
619B17200E1E9D0800E72754 /* de */,
|
||||
555CF29A196C52330000B31E /* el */,
|
||||
61AAE8230A321A7F00D8810D /* en */,
|
||||
61AAE84F0A321AF700D8810D /* es */,
|
||||
61AAE8590A321B0400D8810D /* fr */,
|
||||
@@ -1670,6 +1674,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */;
|
||||
buildSettings = {
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0600"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "612279D80DB5470200AB99EA"
|
||||
BuildableName = "Sparkle Unit Tests.xctest"
|
||||
BlueprintName = "Sparkle Unit Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugXPCServices = "NO"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
<key>LSBackgroundOnly</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.6</string>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>LSUIElement</key>
|
||||
<string>1</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
||||
Vendored
+146
-147
@@ -16,179 +16,176 @@ static const NSTimeInterval SUInstallationTimeLimit = 5;
|
||||
/*!
|
||||
* Time this app uses to recheck if the parent has already died.
|
||||
*/
|
||||
static const NSTimeInterval SUParentQuitCheckInterval = .5;
|
||||
static const NSTimeInterval SUParentQuitCheckInterval = .25;
|
||||
|
||||
@interface TerminationListener : NSObject <SUInstallerDelegate>
|
||||
{
|
||||
const char *hostpath;
|
||||
const char *executablepath;
|
||||
pid_t parentprocessid;
|
||||
const char *folderpath;
|
||||
NSString *selfPath;
|
||||
NSString *installationPath;
|
||||
NSTimer *watchdogTimer;
|
||||
NSTimer *longInstallationTimer;
|
||||
SUHost *host;
|
||||
BOOL shouldRelaunch;
|
||||
BOOL shouldShowUI;
|
||||
}
|
||||
|
||||
- (void) parentHasQuit;
|
||||
@property (assign) const char *hostpath;
|
||||
@property (assign) const char *executablepath;
|
||||
@property (assign) pid_t parentprocessid;
|
||||
@property (assign) const char *folderpath;
|
||||
|
||||
- (void) relaunch;
|
||||
- (void) install;
|
||||
@property (copy) NSString *selfPath;
|
||||
@property (copy) NSString *installationPath;
|
||||
@property (strong) NSTimer *watchdogTimer;
|
||||
@property (strong) NSTimer *longInstallationTimer;
|
||||
@property (strong) SUHost *host;
|
||||
@property (assign) BOOL shouldRelaunch;
|
||||
@property (assign) BOOL shouldShowUI;
|
||||
|
||||
- (void) showAppIconInDock:(NSTimer *)aTimer;
|
||||
- (void) watchdog:(NSTimer *)aTimer;
|
||||
- (void)parentHasQuit;
|
||||
|
||||
- (void)relaunch;
|
||||
- (void)install;
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *)aTimer;
|
||||
- (void)watchdog:(NSTimer *)aTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
|
||||
- (instancetype) initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath:(const char*)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString*)inSelfPath
|
||||
@synthesize hostpath;
|
||||
@synthesize executablepath;
|
||||
@synthesize parentprocessid;
|
||||
@synthesize folderpath;
|
||||
|
||||
@synthesize selfPath;
|
||||
@synthesize installationPath;
|
||||
@synthesize watchdogTimer;
|
||||
@synthesize longInstallationTimer;
|
||||
@synthesize host;
|
||||
@synthesize shouldRelaunch;
|
||||
@synthesize shouldShowUI;
|
||||
|
||||
- (instancetype)initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath:(const char *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
hostpath = inhostpath;
|
||||
executablepath = execpath;
|
||||
parentprocessid = ppid;
|
||||
folderpath = infolderpath;
|
||||
selfPath = [inSelfPath retain];
|
||||
shouldRelaunch = relaunch;
|
||||
shouldShowUI = showUI;
|
||||
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
|
||||
if( alreadyTerminated )
|
||||
[self parentHasQuit];
|
||||
else
|
||||
watchdogTimer = [[NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES] retain];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[longInstallationTimer invalidate];
|
||||
[longInstallationTimer release];
|
||||
longInstallationTimer = nil;
|
||||
|
||||
[selfPath release];
|
||||
selfPath = nil;
|
||||
|
||||
[installationPath release];
|
||||
|
||||
[watchdogTimer release];
|
||||
watchdogTimer = nil;
|
||||
|
||||
[host release];
|
||||
host = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
-(void) parentHasQuit
|
||||
{
|
||||
[watchdogTimer invalidate];
|
||||
longInstallationTimer = [[NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
|
||||
target: self selector: @selector(showAppIconInDock:)
|
||||
userInfo:nil repeats:NO] retain];
|
||||
|
||||
if( folderpath )
|
||||
[self install];
|
||||
else
|
||||
[self relaunch];
|
||||
}
|
||||
|
||||
- (void)watchdog:(NSTimer *) __unused aTimer
|
||||
{
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:parentprocessid]) {
|
||||
[self parentHasQuit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *) __unused aTimer
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType( &psn, kProcessTransformToForegroundApplication );
|
||||
}
|
||||
|
||||
|
||||
- (void) relaunch __attribute__((noreturn))
|
||||
{
|
||||
if (shouldRelaunch)
|
||||
{
|
||||
NSString *appPath = nil;
|
||||
if( !folderpath || strcmp(executablepath, hostpath) != 0 )
|
||||
appPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:executablepath length:strlen(executablepath)];
|
||||
else
|
||||
appPath = installationPath;
|
||||
[[NSWorkspace sharedWorkspace] openFile: appPath];
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (folderpath)
|
||||
hostpath = inhostpath;
|
||||
executablepath = execpath;
|
||||
parentprocessid = ppid;
|
||||
folderpath = infolderpath;
|
||||
selfPath = inSelfPath;
|
||||
shouldRelaunch = relaunch;
|
||||
shouldShowUI = showUI;
|
||||
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
|
||||
if (alreadyTerminated)
|
||||
[self parentHasQuit];
|
||||
else
|
||||
watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[longInstallationTimer invalidate];
|
||||
}
|
||||
|
||||
|
||||
- (void)parentHasQuit
|
||||
{
|
||||
[self.watchdogTimer invalidate];
|
||||
self.longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
|
||||
target: self selector: @selector(showAppIconInDock:)
|
||||
userInfo:nil repeats:NO];
|
||||
|
||||
if (self.folderpath)
|
||||
[self install];
|
||||
else
|
||||
[self relaunch];
|
||||
}
|
||||
|
||||
- (void)watchdog:(NSTimer *)__unused aTimer
|
||||
{
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.parentprocessid]) {
|
||||
[self parentHasQuit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *)__unused aTimer
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
|
||||
|
||||
- (void)relaunch __attribute__((noreturn))
|
||||
{
|
||||
if (self.shouldRelaunch)
|
||||
{
|
||||
NSString *appPath = nil;
|
||||
if (!self.folderpath || strcmp(self.executablepath, self.hostpath) != 0)
|
||||
appPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.executablepath length:strlen(self.executablepath)];
|
||||
else
|
||||
appPath = self.installationPath;
|
||||
[[NSWorkspace sharedWorkspace] openFile:appPath];
|
||||
}
|
||||
|
||||
if (self.folderpath)
|
||||
{
|
||||
NSError *theError = nil;
|
||||
if( ![SUPlainInstaller _removeFileAtPath: [SUInstaller updateFolder] error: &theError] )
|
||||
SULog( @"Couldn't remove update folder: %@.", theError );
|
||||
if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError])
|
||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
[[NSFileManager defaultManager] removeItemAtPath: selfPath error: NULL];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL];
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
- (void) install
|
||||
- (void)install
|
||||
{
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: hostpath length:strlen(hostpath)]];
|
||||
host = [[SUHost alloc] initWithBundle: theBundle];
|
||||
installationPath = [[host installationPath] copy];
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.hostpath length:strlen(self.hostpath)]];
|
||||
self.host = [[SUHost alloc] initWithBundle:theBundle];
|
||||
self.installationPath = [[self.host installationPath] copy];
|
||||
|
||||
if (shouldShowUI) {
|
||||
SUStatusController* statusCtl = [[SUStatusController alloc] initWithHost: host]; // We quit anyway after we've installed, so leak this for now.
|
||||
[statusCtl setButtonTitle: SULocalizedString(@"Cancel Update",@"") target: nil action: Nil isDefault: NO];
|
||||
[statusCtl beginActionWithTitle: SULocalizedString(@"Installing update...",@"")
|
||||
if (self.shouldShowUI) {
|
||||
SUStatusController *statusCtl = [[SUStatusController alloc] initWithHost:self.host]; // We quit anyway after we've installed, so leak this for now.
|
||||
[statusCtl setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
|
||||
[statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
|
||||
maxProgressValue: 0 statusText: @""];
|
||||
[statusCtl showWindow: self];
|
||||
[statusCtl release];
|
||||
[statusCtl showWindow:self];
|
||||
}
|
||||
|
||||
[SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:folderpath length:strlen(folderpath)]
|
||||
overHost:host
|
||||
installationPath:installationPath
|
||||
[SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.folderpath length:strlen(self.folderpath)]
|
||||
overHost:self.host
|
||||
installationPath:self.installationPath
|
||||
delegate:self
|
||||
versionComparator:[SUStandardVersionComparator defaultComparator]];
|
||||
}
|
||||
|
||||
- (void)installerFinishedForHost:(SUHost *) __unused aHost
|
||||
- (void)installerFinishedForHost:(SUHost *)__unused aHost
|
||||
{
|
||||
[self relaunch];
|
||||
[self relaunch];
|
||||
}
|
||||
|
||||
- (void)installerForHost:(SUHost *) __unused host failedWithError:(NSError *)error __attribute__((noreturn))
|
||||
- (void)installerForHost:(SUHost *)__unused host failedWithError:(NSError *)error __attribute__((noreturn))
|
||||
{
|
||||
if (shouldShowUI)
|
||||
NSRunAlertPanel( @"", @"%@", @"OK", @"", @"", [error localizedDescription] );
|
||||
exit(EXIT_FAILURE);
|
||||
if (self.shouldShowUI)
|
||||
NSRunAlertPanel(@"", @"%@", @"OK", @"", @"", [error localizedDescription]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
if (argc < 5 || argc > 7) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (argc < 5 || argc > 7) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
//ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
//TransformProcessType( &psn, kProcessTransformToForegroundApplication );
|
||||
//ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
//TransformProcessType( &psn, kProcessTransformToForegroundApplication );
|
||||
|
||||
#if 0 // Cmdline tool
|
||||
#if 0 // Cmdline tool
|
||||
NSString* selfPath = nil;
|
||||
if (argv[0][0] == '/') {
|
||||
selfPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])];
|
||||
@@ -199,26 +196,28 @@ int main (int argc, const char * argv[])
|
||||
selfPath = [selfPath stringByAppendingPathComponent: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])]];
|
||||
}
|
||||
#else
|
||||
NSString* selfPath = [[NSBundle mainBundle] bundlePath];
|
||||
NSString *selfPath = [[NSBundle mainBundle] bundlePath];
|
||||
#endif
|
||||
|
||||
BOOL shouldShowUI = (argc > 6) ? !!atoi(argv[6]) : YES;
|
||||
BOOL shouldShowUI = (argc > 6) ? !!atoi(argv[6]) : YES;
|
||||
if (shouldShowUI)
|
||||
{
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
|
||||
}
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
[[[TerminationListener alloc] initWithHostPath: (argc > 1) ? argv[1] : NULL
|
||||
executablePath: (argc > 2) ? argv[2] : NULL
|
||||
parentProcessId: (argc > 3) ? atoi(argv[3]) : 0
|
||||
folderPath: (argc > 4) ? argv[4] : NULL
|
||||
shouldRelaunch: (argc > 5) ? !!atoi(argv[5]) : YES
|
||||
shouldShowUI: shouldShowUI
|
||||
selfPath: selfPath] autorelease];
|
||||
[[NSApplication sharedApplication] run];
|
||||
[NSApplication sharedApplication];
|
||||
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:(argc > 1) ? argv[1] : NULL
|
||||
executablePath:(argc > 2) ? argv[2] : NULL
|
||||
parentProcessId:(argc > 3) ? atoi(argv[3]) : 0
|
||||
folderPath:(argc > 4) ? argv[4] : NULL
|
||||
shouldRelaunch:(argc > 5) ? !!atoi(argv[5]) : YES
|
||||
shouldShowUI:shouldShowUI
|
||||
selfPath:selfPath];
|
||||
|
||||
}
|
||||
[termListen class];
|
||||
[[NSApplication sharedApplication] run];
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Vendored
+3
-10
@@ -12,16 +12,9 @@
|
||||
@protocol SUAppcastDelegate;
|
||||
|
||||
@class SUAppcastItem;
|
||||
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
{
|
||||
@private
|
||||
NSArray *items;
|
||||
NSString *userAgentString;
|
||||
id<SUAppcastDelegate> delegate;
|
||||
NSString *downloadFilename;
|
||||
NSURLDownload *download;
|
||||
}
|
||||
@property (assign) id<SUAppcastDelegate> delegate;
|
||||
@interface SUAppcast : NSObject <NSURLDownloadDelegate>
|
||||
|
||||
@property (weak) id<SUAppcastDelegate> delegate;
|
||||
@property (copy) NSString *userAgentString;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url;
|
||||
|
||||
Vendored
+86
-93
@@ -22,88 +22,81 @@
|
||||
@implementation NSXMLElement (SUAppcastExtensions)
|
||||
- (NSDictionary *)attributesAsDictionary
|
||||
{
|
||||
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
dictionary[[attribute name]] = [attribute stringValue];
|
||||
}
|
||||
return dictionary;
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
dictionary[[attribute name]] = [attribute stringValue];
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface SUAppcast () <NSURLDownloadDelegate>
|
||||
@property (copy) NSString *downloadFilename;
|
||||
@property (retain) NSURLDownload *download;
|
||||
@property (strong) NSURLDownload *download;
|
||||
@property (copy) NSArray *items;
|
||||
- (void)reportError:(NSError *)error;
|
||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
|
||||
@end
|
||||
|
||||
@implementation SUAppcast
|
||||
|
||||
@synthesize downloadFilename;
|
||||
@synthesize delegate;
|
||||
@synthesize userAgentString;
|
||||
@synthesize download;
|
||||
@synthesize items;
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.items = nil;
|
||||
self.userAgentString = nil;
|
||||
self.downloadFilename = nil;
|
||||
self.download = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
||||
if (userAgentString) {
|
||||
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
}
|
||||
if (self.userAgentString) {
|
||||
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
}
|
||||
|
||||
self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease];
|
||||
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
||||
|
||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
{
|
||||
NSString* destinationFilename = NSTemporaryDirectory();
|
||||
NSString *destinationFilename = NSTemporaryDirectory();
|
||||
if (destinationFilename)
|
||||
{
|
||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
||||
[download setDestination:destinationFilename allowOverwrite:NO];
|
||||
}
|
||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
||||
[self.download setDestination:destinationFilename allowOverwrite:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload didCreateDestination:(NSString *)path
|
||||
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
|
||||
{
|
||||
self.downloadFilename = path;
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *) __unused aDownload
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSError *error = nil;
|
||||
|
||||
NSXMLDocument *document = nil;
|
||||
BOOL failed = NO;
|
||||
NSArray *xmlItems = nil;
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
NSXMLDocument *document = nil;
|
||||
BOOL failed = NO;
|
||||
NSArray *xmlItems = nil;
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
|
||||
if (downloadFilename)
|
||||
if (self.downloadFilename)
|
||||
{
|
||||
NSUInteger options = 0;
|
||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
||||
document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease];
|
||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
||||
document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:self.downloadFilename] options:options error:&error];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = YES;
|
||||
}
|
||||
failed = YES;
|
||||
}
|
||||
|
||||
if (nil == document)
|
||||
{
|
||||
@@ -121,14 +114,14 @@
|
||||
if (failed == NO)
|
||||
{
|
||||
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
|
||||
while (failed == NO && (node = [nodeEnum nextObject]))
|
||||
{
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
if ([[node children] count])
|
||||
{
|
||||
node = [node childAtIndex:0];
|
||||
@@ -154,97 +147,97 @@
|
||||
node = [self bestNodeInNodes:nodesDict[name]];
|
||||
if ([name isEqualToString:@"enclosure"])
|
||||
{
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
||||
dict[@"enclosure"] = encDict;
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
||||
dict[@"enclosure"] = encDict;
|
||||
|
||||
}
|
||||
else if ([name isEqualToString:@"pubDate"])
|
||||
{
|
||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
||||
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
|
||||
if (date)
|
||||
dict[name] = date;
|
||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
||||
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
|
||||
if (date)
|
||||
dict[name] = date;
|
||||
}
|
||||
else if ([name isEqualToString:@"sparkle:deltas"])
|
||||
{
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:@"enclosure"])
|
||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
||||
}
|
||||
dict[@"deltas"] = deltas;
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:@"enclosure"])
|
||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
||||
}
|
||||
dict[@"deltas"] = deltas;
|
||||
}
|
||||
else if (name != nil)
|
||||
{
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
dict[name] = theValue;
|
||||
}
|
||||
}
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
dict[name] = theValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString] autorelease];
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||
if (anItem)
|
||||
{
|
||||
[appcastItems addObject:anItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
}
|
||||
[nodesDict removeAllObjects];
|
||||
[dict removeAllObjects];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([appcastItems count])
|
||||
{
|
||||
NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO] autorelease];
|
||||
[appcastItems sortUsingDescriptors:@[sort]];
|
||||
self.items = appcastItems;
|
||||
}
|
||||
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
|
||||
[appcastItems sortUsingDescriptors:@[sort]];
|
||||
self.items = appcastItems;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil)}]];
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil) }]];
|
||||
}
|
||||
else if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
|
||||
else if ([self.delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
|
||||
{
|
||||
[delegate appcastDidFinishLoading:self];
|
||||
}
|
||||
[self.delegate appcastDidFinishLoading:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload didFailWithError:(NSError *)error
|
||||
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
||||
{
|
||||
if (downloadFilename)
|
||||
if (self.downloadFilename)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
}
|
||||
self.downloadFilename = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
}
|
||||
self.downloadFilename = nil;
|
||||
|
||||
[self reportError:error];
|
||||
[self reportError:error];
|
||||
}
|
||||
|
||||
- (NSURLRequest *)download:(NSURLDownload *) __unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *) __unused redirectResponse
|
||||
- (NSURLRequest *)download:(NSURLDownload *)__unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)__unused redirectResponse
|
||||
{
|
||||
return request;
|
||||
return request;
|
||||
}
|
||||
|
||||
- (void)reportError:(NSError *)error
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
|
||||
if ([self.delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
|
||||
{
|
||||
[delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
}
|
||||
[self.delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes
|
||||
{
|
||||
// We use this method to pick out the localized version of a node when one's available.
|
||||
// We use this method to pick out the localized version of a node when one's available.
|
||||
if ([nodes count] == 1)
|
||||
return nodes[0];
|
||||
else if ([nodes count] == 0)
|
||||
@@ -253,15 +246,15 @@
|
||||
NSMutableArray *languages = [NSMutableArray array];
|
||||
NSString *lang;
|
||||
NSUInteger i;
|
||||
for (NSXMLElement *node in nodes) {
|
||||
for (NSXMLElement *node in nodes) {
|
||||
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
||||
[languages addObject:(lang ? lang : @"")];
|
||||
}
|
||||
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
|
||||
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
||||
if (i == NSNotFound) {
|
||||
if (i == NSNotFound) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
return nodes[i];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+5
-5
@@ -13,19 +13,19 @@
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (retain, readonly) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (retain, readonly) NSURL *fileURL;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (retain, readonly) NSURL *infoURL; // UK 2007-08-31
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@@ -33,7 +33,7 @@
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
- (NSURL *)infoURL; // UK 2007-08-31
|
||||
- (NSURL *)infoURL;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+83
-104
@@ -18,15 +18,15 @@
|
||||
@property (copy, readwrite) NSString *title;
|
||||
@property (copy, readwrite) NSDate *date;
|
||||
@property (copy, readwrite) NSString *itemDescription;
|
||||
@property (retain, readwrite) NSURL *releaseNotesURL;
|
||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@property (copy, readwrite) NSString *minimumSystemVersion;
|
||||
@property (copy, readwrite) NSString *maximumSystemVersion;
|
||||
@property (retain, readwrite) NSURL *fileURL;
|
||||
@property (strong, readwrite) NSURL *fileURL;
|
||||
@property (copy, readwrite) NSString *versionString;
|
||||
@property (copy, readwrite) NSString *displayVersionString;
|
||||
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
||||
@property (retain, readwrite) NSURL *infoURL;
|
||||
@property (strong, readwrite) NSURL *infoURL;
|
||||
@property (readwrite, copy) NSDictionary *propertiesDictionary;
|
||||
@end
|
||||
|
||||
@@ -47,152 +47,131 @@
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
return propertiesDictionary[@"enclosure"][@"sparkle:deltaFrom"] != nil;
|
||||
return self.propertiesDictionary[@"enclosure"][@"sparkle:deltaFrom"] != nil;
|
||||
}
|
||||
|
||||
- (BOOL)isCriticalUpdate
|
||||
{
|
||||
return [propertiesDictionary[@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
|
||||
return [self.propertiesDictionary[@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
|
||||
}
|
||||
|
||||
- (instancetype) initWithDictionary:(NSDictionary *)dict
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict
|
||||
{
|
||||
return [self initWithDictionary:dict failureReason:nil];
|
||||
return [self initWithDictionary:dict failureReason:nil];
|
||||
}
|
||||
|
||||
- (instancetype) initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error
|
||||
{
|
||||
self = [super init];
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
id enclosure = dict[@"enclosure"];
|
||||
id enclosure = dict[@"enclosure"];
|
||||
|
||||
// Try to find a version string.
|
||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
|
||||
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
|
||||
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
|
||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = enclosure[@"sparkle:version"];
|
||||
if( newVersion == nil )
|
||||
newVersion = dict[@"sparkle:version"]; // UK 2007-08-31 Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||
// then we remove the extension. Hopefully, this will be the version.
|
||||
NSArray *fileComponents = [enclosure[@"url"] componentsSeparatedByString:@"_"];
|
||||
if ([fileComponents count] > 1)
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
// Try to find a version string.
|
||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
|
||||
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
|
||||
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
|
||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = enclosure[@"sparkle:version"];
|
||||
if (newVersion == nil)
|
||||
newVersion = dict[@"sparkle:version"]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||
// then we remove the extension. Hopefully, this will be the version.
|
||||
NSArray *fileComponents = [enclosure[@"url"] componentsSeparatedByString:@"_"];
|
||||
if ([fileComponents count] > 1)
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if(!newVersion )
|
||||
{
|
||||
if (error)
|
||||
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if (error)
|
||||
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
|
||||
return nil;
|
||||
}
|
||||
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = dict[@"title"];
|
||||
self.date = dict[@"pubDate"];
|
||||
self.itemDescription = dict[@"description"];
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = dict[@"title"];
|
||||
self.date = dict[@"pubDate"];
|
||||
self.itemDescription = dict[@"description"];
|
||||
|
||||
NSString* theInfoURL = dict[@"link"];
|
||||
NSString *theInfoURL = dict[@"link"];
|
||||
if( theInfoURL )
|
||||
{
|
||||
if( ![theInfoURL isKindOfClass: [NSString class]] )
|
||||
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
|
||||
else
|
||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
if (![theInfoURL isKindOfClass:[NSString class]])
|
||||
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
|
||||
else
|
||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
if( !enclosure && !theInfoURL )
|
||||
{
|
||||
if (error)
|
||||
*error = @"No enclosure in feed item";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if (error)
|
||||
*error = @"No enclosure in feed item";
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString* enclosureURLString = enclosure[@"url"];
|
||||
NSString *enclosureURLString = enclosure[@"url"];
|
||||
if( !enclosureURLString && !theInfoURL )
|
||||
{
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
}
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
if( enclosureURLString ) {
|
||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = enclosure[@"sparkle:dsaSignature"];
|
||||
}
|
||||
if (enclosureURLString) {
|
||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = enclosure[@"sparkle:dsaSignature"];
|
||||
}
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"];
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"];
|
||||
self.maximumSystemVersion = dict[@"sparkle:maximumSystemVersion"];
|
||||
|
||||
NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"];
|
||||
if (nil == shortVersionString) {
|
||||
NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"];
|
||||
if (nil == shortVersionString) {
|
||||
shortVersionString = dict[@"sparkle:shortVersionString"]; // fall back on the <item>
|
||||
}
|
||||
}
|
||||
|
||||
if (shortVersionString)
|
||||
self.displayVersionString = shortVersionString;
|
||||
else
|
||||
self.displayVersionString = [self versionString];
|
||||
if (shortVersionString)
|
||||
self.displayVersionString = shortVersionString;
|
||||
else
|
||||
self.displayVersionString = [self versionString];
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
if (dict[@"sparkle:releaseNotesLink"])
|
||||
self.releaseNotesURL = [NSURL URLWithString:dict[@"sparkle:releaseNotesLink"]];
|
||||
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
else
|
||||
self.releaseNotesURL = nil;
|
||||
// Find the appropriate release notes URL.
|
||||
if (dict[@"sparkle:releaseNotesLink"])
|
||||
self.releaseNotesURL = [NSURL URLWithString:dict[@"sparkle:releaseNotesLink"]];
|
||||
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
else
|
||||
self.releaseNotesURL = nil;
|
||||
|
||||
if (dict[@"deltas"])
|
||||
{
|
||||
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
||||
NSArray *deltaDictionaries = dict[@"deltas"];
|
||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
[fakeAppCastDict removeObjectForKey:@"deltas"];
|
||||
fakeAppCastDict[@"enclosure"] = deltaDictionary;
|
||||
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
|
||||
[fakeAppCastDict release];
|
||||
|
||||
deltas[deltaDictionary[@"sparkle:deltaFrom"]] = deltaItem;
|
||||
[deltaItem release];
|
||||
}
|
||||
}
|
||||
self.deltaUpdates = deltas;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.title = nil;
|
||||
self.date = nil;
|
||||
self.itemDescription = nil;
|
||||
self.releaseNotesURL = nil;
|
||||
self.DSASignature = nil;
|
||||
self.minimumSystemVersion = nil;
|
||||
self.fileURL = nil;
|
||||
self.versionString = nil;
|
||||
self.displayVersionString = nil;
|
||||
self.infoURL = nil;
|
||||
self.propertiesDictionary = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+3
-3
@@ -15,9 +15,9 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUInstallNowChoice,
|
||||
SUInstallLaterChoice,
|
||||
SUDoNotInstallChoice
|
||||
SUInstallNowChoice,
|
||||
SUInstallLaterChoice,
|
||||
SUDoNotInstallChoice
|
||||
} SUAutomaticInstallationChoice;
|
||||
|
||||
@class SUAppcastItem, SUHost;
|
||||
|
||||
Vendored
+29
-36
@@ -11,9 +11,9 @@
|
||||
#import "SUHost.h"
|
||||
|
||||
@interface SUAutomaticUpdateAlert ()
|
||||
@property (retain) SUAppcastItem *updateItem;
|
||||
@property (assign) id<SUAutomaticUpdateAlertDelegate> delegate;
|
||||
@property (retain) SUHost *host;
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (weak) id<SUAutomaticUpdateAlertDelegate> delegate;
|
||||
@property (strong) SUHost *host;
|
||||
@end
|
||||
|
||||
@implementation SUAutomaticUpdateAlert
|
||||
@@ -23,71 +23,64 @@
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:(id<SUAutomaticUpdateAlertDelegate>)del
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
|
||||
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
|
||||
if (self)
|
||||
{
|
||||
self.updateItem = item;
|
||||
self.delegate = del;
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
[[self window] center];
|
||||
}
|
||||
return self;
|
||||
self.updateItem = item;
|
||||
self.delegate = del;
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
[[self window] center];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
- (IBAction)installNow:(id)__unused sender
|
||||
{
|
||||
self.host = nil;
|
||||
self.updateItem = nil;
|
||||
[super dealloc];
|
||||
[self close];
|
||||
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUInstallNowChoice];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
- (IBAction)installNow:(id) __unused sender
|
||||
- (IBAction)installLater:(id)__unused sender
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallNowChoice];
|
||||
[self close];
|
||||
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUInstallLaterChoice];
|
||||
}
|
||||
|
||||
- (IBAction)installLater:(id) __unused sender
|
||||
- (IBAction)doNotInstall:(id)__unused sender
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallLaterChoice];
|
||||
}
|
||||
|
||||
- (IBAction)doNotInstall:(id) __unused sender
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUDoNotInstallChoice];
|
||||
[self close];
|
||||
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUDoNotInstallChoice];
|
||||
}
|
||||
|
||||
- (NSImage *)applicationIcon
|
||||
{
|
||||
return [host icon];
|
||||
return [self.host icon];
|
||||
}
|
||||
|
||||
- (NSString *)titleText
|
||||
{
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
-7
@@ -14,13 +14,6 @@
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
|
||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUAutomaticUpdateAlertDelegate>
|
||||
{
|
||||
@private
|
||||
BOOL postponingInstallation, showErrors;
|
||||
BOOL willUpdateOnTermination;
|
||||
SUAutomaticUpdateAlert *alert;
|
||||
NSTimer *showUpdateAlertTimer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+78
-57
@@ -15,29 +15,51 @@
|
||||
// If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise.
|
||||
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
|
||||
|
||||
@interface SUUpdateDriver ()
|
||||
|
||||
@property (getter=isInterruptible) BOOL interruptible;
|
||||
|
||||
@end
|
||||
|
||||
@interface SUAutomaticUpdateDriver ()
|
||||
|
||||
@property (assign) BOOL postponingInstallation;
|
||||
@property (assign) BOOL showErrors;
|
||||
@property (assign) BOOL willUpdateOnTermination;
|
||||
@property (strong) SUAutomaticUpdateAlert *alert;
|
||||
@property (strong) NSTimer *showUpdateAlertTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUAutomaticUpdateDriver
|
||||
|
||||
@synthesize postponingInstallation;
|
||||
@synthesize showErrors;
|
||||
@synthesize willUpdateOnTermination;
|
||||
@synthesize alert;
|
||||
@synthesize showUpdateAlertTimer;
|
||||
|
||||
- (void)showUpdateAlert
|
||||
{
|
||||
isInterruptible = NO;
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
|
||||
self.interruptible = NO;
|
||||
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host delegate:self];
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([self.host isBackgroundApplication])
|
||||
{
|
||||
[[alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
[[self.alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp isActive])
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
if ([NSApp isActive])
|
||||
[[self.alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *) __unused ua
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
|
||||
@@ -45,9 +67,10 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo disableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = YES;
|
||||
self.willUpdateOnTermination = YES;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||
{
|
||||
BOOL relaunch = YES;
|
||||
BOOL showUI = NO;
|
||||
@@ -57,51 +80,49 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
[invocation setArgument:&showUI atIndex:3];
|
||||
[invocation setTarget:self];
|
||||
|
||||
[[updater delegate] updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation];
|
||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
||||
}
|
||||
|
||||
// If this is marked as a critical update, we'll prompt the user to install it right away.
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
[self showUpdateAlert];
|
||||
}
|
||||
else
|
||||
{
|
||||
showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain];
|
||||
self.showUpdateAlertTimer = [NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO];
|
||||
|
||||
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
|
||||
isInterruptible = YES;
|
||||
self.interruptible = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopUpdatingOnTermination
|
||||
{
|
||||
if (willUpdateOnTermination)
|
||||
if (self.willUpdateOnTermination)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo enableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = NO;
|
||||
self.willUpdateOnTermination = NO;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||
[[updater delegate] updater:updater didCancelInstallUpdateOnQuit:updateItem];
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)invalidateShowUpdateAlertTimer
|
||||
{
|
||||
[showUpdateAlertTimer invalidate];
|
||||
[showUpdateAlertTimer release];
|
||||
showUpdateAlertTimer = nil;
|
||||
[self.showUpdateAlertTimer invalidate];
|
||||
self.showUpdateAlertTimer = nil;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[alert release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
@@ -111,58 +132,58 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *) __unused aNotification
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
{
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[self.alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
}
|
||||
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *) __unused aua finishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)__unused aua finishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case SUInstallNowChoice:
|
||||
case SUInstallNowChoice:
|
||||
[self stopUpdatingOnTermination];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
break;
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
break;
|
||||
|
||||
case SUInstallLaterChoice:
|
||||
postponingInstallation = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
isInterruptible = YES;
|
||||
break;
|
||||
case SUInstallLaterChoice:
|
||||
self.postponingInstallation = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
self.interruptible = YES;
|
||||
break;
|
||||
|
||||
case SUDoNotInstallChoice:
|
||||
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
case SUDoNotInstallChoice:
|
||||
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return postponingInstallation; }
|
||||
- (BOOL)shouldInstallSynchronously { return self.postponingInstallation; }
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
if (relaunch) {
|
||||
if (relaunch) {
|
||||
[self stopUpdatingOnTermination];
|
||||
}
|
||||
}
|
||||
|
||||
showErrors = YES;
|
||||
self.showErrors = YES;
|
||||
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *) __unused note
|
||||
- (void)applicationWillTerminate:(NSNotification *)__unused note
|
||||
{
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if (showErrors)
|
||||
[super abortUpdateWithError:error];
|
||||
else
|
||||
[self abortUpdate];
|
||||
if (self.showErrors)
|
||||
[super abortUpdateWithError:error];
|
||||
else
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+5
-9
@@ -15,16 +15,11 @@
|
||||
#import "SUAppcast.h"
|
||||
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate> {
|
||||
SUAppcastItem *updateItem;
|
||||
SUAppcastItem *nonDeltaUpdateItem;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate>
|
||||
|
||||
NSURLDownload *download;
|
||||
NSString *downloadPath;
|
||||
NSString *tempDir;
|
||||
|
||||
NSString *relaunchPath;
|
||||
}
|
||||
@property (strong, readonly) SUAppcastItem *updateItem;
|
||||
@property (strong, readonly) NSURLDownload *download;
|
||||
@property (copy, readonly) NSString *downloadPath;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
|
||||
@@ -53,6 +48,7 @@
|
||||
|
||||
- (void)abortUpdate;
|
||||
- (void)abortUpdateWithError:(NSError *)error;
|
||||
- (void)terminateApp;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+229
-204
@@ -22,54 +22,72 @@
|
||||
#import "SUUpdater_Private.h"
|
||||
|
||||
#ifdef FINISH_INSTALL_TOOL_NAME
|
||||
// FINISH_INSTALL_TOOL_NAME expands to unquoted Autoupdate
|
||||
#define QUOTE_NS_STRING2(str) @"" #str
|
||||
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
|
||||
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
|
||||
// FINISH_INSTALL_TOOL_NAME expands to unquoted Autoupdate
|
||||
#define QUOTE_NS_STRING2(str) @"" #str
|
||||
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
|
||||
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
|
||||
#else
|
||||
#error FINISH_INSTALL_TOOL_NAME not defined
|
||||
#error FINISH_INSTALL_TOOL_NAME not defined
|
||||
#endif
|
||||
|
||||
@interface SUBasicUpdateDriver ()
|
||||
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) NSURLDownload *download;
|
||||
@property (copy) NSString *downloadPath;
|
||||
|
||||
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
|
||||
@property (copy) NSString *tempDir;
|
||||
@property (copy) NSString *relaunchPath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUBasicUpdateDriver
|
||||
|
||||
@synthesize updateItem;
|
||||
@synthesize download;
|
||||
@synthesize downloadPath;
|
||||
|
||||
@synthesize nonDeltaUpdateItem;
|
||||
@synthesize tempDir;
|
||||
@synthesize relaunchPath;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]]}]];
|
||||
return;
|
||||
}
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||
CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC.
|
||||
[appcast release];
|
||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||
|
||||
[appcast setDelegate:self];
|
||||
[appcast setUserAgentString:[updater userAgentString]];
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
[appcast setDelegate:self];
|
||||
[appcast setUserAgentString:[self.updater userAgentString]];
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
}
|
||||
|
||||
- (id <SUVersionComparison>)versionComparator
|
||||
- (id<SUVersionComparison>)versionComparator
|
||||
{
|
||||
id <SUVersionComparison> comparator = nil;
|
||||
id<SUVersionComparison> comparator = nil;
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||
comparator = [[updater delegate] versionComparatorForUpdater:updater];
|
||||
}
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||
comparator = [[self.updater delegate] versionComparatorForUpdater:self.updater];
|
||||
}
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator) {
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
}
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator) {
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
}
|
||||
|
||||
return comparator;
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
@@ -93,204 +111,220 @@
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
{
|
||||
return [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
return ui && [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
||||
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
|
||||
}
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
|
||||
}
|
||||
|
||||
NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
|
||||
NSDictionary *userInfo = (ac != nil) ? @{ SUUpdaterAppcastNotificationKey: ac } : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
|
||||
|
||||
SUAppcastItem *item = nil;
|
||||
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||
}
|
||||
else // If not, we'll take care of it ourselves.
|
||||
{
|
||||
// Find the first update we can actually use.
|
||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
||||
do {
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
{
|
||||
// Find the first update we can actually use.
|
||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
||||
do {
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
|
||||
if (binaryDeltaSupported()) {
|
||||
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
nonDeltaUpdateItem = [item retain];
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (binaryDeltaSupported()) {
|
||||
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
self.nonDeltaUpdateItem = item;
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateItem = [item retain];
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
if (updateItem == nil) { [self didNotFindUpdate]; return; }
|
||||
|
||||
if ([self itemContainsValidUpdate:updateItem])
|
||||
[self didFindValidUpdate];
|
||||
else
|
||||
[self didNotFindUpdate];
|
||||
if ([self itemContainsValidUpdate:item]) {
|
||||
self.updateItem = item;
|
||||
[self didFindValidUpdate];
|
||||
} else {
|
||||
self.updateItem = nil;
|
||||
[self didNotFindUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
|
||||
- (void)appcast:(SUAppcast *)__unused ac failedToLoadWithError:(NSError *)error
|
||||
{
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
[self abortUpdateWithError:error];
|
||||
[self abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
|
||||
[self downloadUpdate];
|
||||
assert(self.updateItem);
|
||||
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
||||
object:self.updater
|
||||
userInfo:@{ SUUpdaterAppcastItemNotificationKey: self.updateItem }];
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]]}]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUNoUpdateError
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", "'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI)"), self.host.name]
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)downloadUpdate
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
|
||||
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
{
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
||||
|
||||
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
|
||||
int cnt=1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
self.tempDir = [[self.host appSupportPath] stringByAppendingPathComponent:downloadFileName];
|
||||
int cnt = 1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
||||
{
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
|
||||
}
|
||||
self.tempDir = [[self.host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
||||
}
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:self.tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
if (!success)
|
||||
{
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir]}]];
|
||||
}
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[self.download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", self.tempDir] }]];
|
||||
}
|
||||
|
||||
downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
|
||||
[download setDestination:downloadPath allowOverwrite:YES];
|
||||
self.downloadPath = [self.tempDir stringByAppendingPathComponent:name];
|
||||
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
{
|
||||
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:host];
|
||||
if (newBundlePath)
|
||||
{
|
||||
NSError *error = nil;
|
||||
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
|
||||
return YES;
|
||||
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:self.host];
|
||||
|
||||
if (newBundlePath) {
|
||||
if ([SUCodeSigningVerifier hostApplicationIsCodeSigned]) {
|
||||
NSError *error = nil;
|
||||
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(@"Code signature check on update failed: %@. Sparkle will use DSA signature instead.", error);
|
||||
}
|
||||
} else {
|
||||
SULog(@"Code signature check on update failed: %@", error);
|
||||
SULog(@"The host app is not signed using Apple Code Signing, and therefore cannot verify updates this way. Sparkle will use DSA signature instead.");
|
||||
}
|
||||
}
|
||||
|
||||
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
if (DSASignature) {
|
||||
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
} else {
|
||||
SULog(@"The appcast item for the update has no DSA signature. The update will be rejected, because both DSA and Apple Code Signing verification failed.");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *) __unused d
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||
{
|
||||
[self extractUpdate];
|
||||
assert(self.updateItem);
|
||||
|
||||
[self extractUpdate];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused download didFailWithError:(NSError *)error
|
||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
}
|
||||
|
||||
- (BOOL)download:(NSURLDownload *) __unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
{
|
||||
// We don't want the download system to extract our gzips.
|
||||
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
||||
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
||||
// We don't want the download system to extract our gzips.
|
||||
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
||||
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
||||
}
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath updatingHost:host];
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHost:self.host];
|
||||
if (!unarchiver)
|
||||
{
|
||||
SULog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV.
|
||||
[unarchiver setDelegate:self];
|
||||
[unarchiver start];
|
||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
[unarchiver setDelegate:self];
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
- (void)failedToApplyDeltaUpdate
|
||||
{
|
||||
// When a delta update fails to apply we fall back on updating via a full install.
|
||||
[updateItem release];
|
||||
updateItem = nonDeltaUpdateItem;
|
||||
nonDeltaUpdateItem = nil;
|
||||
// When a delta update fails to apply we fall back on updating via a full install.
|
||||
self.updateItem = self.nonDeltaUpdateItem;
|
||||
self.nonDeltaUpdateItem = nil;
|
||||
|
||||
[self downloadUpdate];
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
assert(self.updateItem);
|
||||
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)ua
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
if ([self.updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil)}]];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
|
||||
}
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return NO; }
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
if (![self validateUpdateDownloadedToPath:downloadPath extractedToPath:tempDir DSASignature:[updateItem DSASignature] publicDSAKey:[host publicDSAKey]])
|
||||
assert(self.updateItem);
|
||||
|
||||
if (![self validateUpdateDownloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature publicDSAKey:self.host.publicDSAKey])
|
||||
{
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
@@ -298,9 +332,9 @@
|
||||
};
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (![updater mayUpdateAndRestart])
|
||||
if (![self.updater mayUpdateAndRestart])
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
@@ -308,119 +342,110 @@
|
||||
|
||||
// Give the host app an opportunity to postpone the install and relaunch.
|
||||
static BOOL postponedOnce = NO;
|
||||
if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) {
|
||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||
[[updater delegate] updater:updater willInstallUpdate:updateItem];
|
||||
}
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
|
||||
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
|
||||
if (relaunchPathToCopy != nil)
|
||||
{
|
||||
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: @{} error: &error];
|
||||
NSString *targetPath = [[self.host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];
|
||||
|
||||
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
|
||||
relaunchPath = [targetPath retain];
|
||||
else
|
||||
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error])
|
||||
self.relaunchPath = targetPath;
|
||||
else
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]}]];
|
||||
}
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[[updater delegate] updaterWillRelaunchApplication:updater];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[updaterDelegate updaterWillRelaunchApplication:self.updater];
|
||||
|
||||
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
|
||||
if(!self.relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.relaunchPath])
|
||||
{
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath]}]];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]], NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]}]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [host bundlePath];
|
||||
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
|
||||
}
|
||||
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
|
||||
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
tempDir,
|
||||
relaunch ? @"1" : @"0",
|
||||
showUI ? @"1" : @"0"]];
|
||||
NSString *pathToRelaunch = [self.host bundlePath];
|
||||
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
|
||||
}
|
||||
NSString *relaunchToolPath = [[self.relaunchPath stringByAppendingPathComponent:@"/Contents/MacOS"] stringByAppendingPathComponent:finishInstallToolName];
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
self.tempDir,
|
||||
relaunch ? @"1" : @"0",
|
||||
showUI ? @"1" : @"0"]];
|
||||
[self terminateApp];
|
||||
}
|
||||
|
||||
- (void)terminateApp
|
||||
{
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
- (void)cleanUpDownload
|
||||
{
|
||||
if (tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
|
||||
{
|
||||
BOOL success = NO;
|
||||
NSError * error = nil;
|
||||
success = [[NSFileManager defaultManager] removeItemAtPath: tempDir error: &error]; // Clean up the copied relauncher
|
||||
if( !success )
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tempDir stringByDeletingLastPathComponent] destination:@"" files:@[[tempDir lastPathComponent]] tag:NULL];
|
||||
}
|
||||
if (self.tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
|
||||
{
|
||||
BOOL success = NO;
|
||||
NSError *error = nil;
|
||||
success = [[NSFileManager defaultManager] removeItemAtPath:self.tempDir error:&error]; // Clean up the copied relauncher
|
||||
if (!success)
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[self.tempDir stringByDeletingLastPathComponent] destination:@"" files:@[[self.tempDir lastPathComponent]] tag:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
NSError * dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher
|
||||
if (aHost != self.host) { return; }
|
||||
NSError *dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.relaunchPath error:&dontThrow]; // Clean up the copied relauncher
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[[self retain] autorelease]; // In case the notification center was the last one holding on to us.
|
||||
[self cleanUpDownload];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super abortUpdate];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
self.updateItem = nil;
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||
SULog(@"Sparkle Error: %@", [error localizedDescription]);
|
||||
}
|
||||
if ([error localizedFailureReason]) {
|
||||
SULog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
|
||||
}
|
||||
if (download) {
|
||||
[download cancel];
|
||||
}
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[updateItem release];
|
||||
[nonDeltaUpdateItem release];
|
||||
[download release];
|
||||
[downloadPath release];
|
||||
[tempDir release];
|
||||
[relaunchPath release];
|
||||
[super dealloc];
|
||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||
SULog(@"Error: %@ %@", [error localizedDescription], [error localizedFailureReason]);
|
||||
}
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
}
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+5
-17
@@ -26,9 +26,9 @@ extern int bsdiff(int argc, const char **argv);
|
||||
|
||||
@interface CreateBinaryDeltaOperation : NSOperation
|
||||
@property (copy) NSString *relativePath;
|
||||
@property (retain) NSString *resultPath;
|
||||
@property (retain) NSString *_fromPath;
|
||||
@property (retain) NSString *_toPath;
|
||||
@property (strong) NSString *resultPath;
|
||||
@property (strong) NSString *_fromPath;
|
||||
@property (strong) NSString *_toPath;
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree;
|
||||
@end
|
||||
|
||||
@@ -51,22 +51,12 @@ extern int bsdiff(int argc, const char **argv);
|
||||
- (void)main
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = {"/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
||||
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
self.resultPath = temporaryFile;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.relativePath = nil;
|
||||
self.resultPath = nil;
|
||||
self._fromPath = nil;
|
||||
self._toPath = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static NSDictionary *infoForFile(FTSENT *ent)
|
||||
@@ -81,7 +71,7 @@ static NSDictionary *infoForFile(FTSENT *ent)
|
||||
|
||||
static NSString *absolutePath(NSString *path)
|
||||
{
|
||||
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
|
||||
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
||||
return [[url absoluteURL] path];
|
||||
}
|
||||
|
||||
@@ -251,12 +241,10 @@ int main(int argc, char **argv)
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
[operation release];
|
||||
}
|
||||
}
|
||||
|
||||
[deltaQueue waitUntilAllOperationsAreFinished];
|
||||
[deltaQueue release];
|
||||
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
|
||||
Vendored
+3
-3
@@ -23,10 +23,10 @@
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *sourcePath = [[updateHost bundle] bundlePath];
|
||||
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
NSString *sourcePath = [[self.updateHost bundle] bundlePath];
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath);
|
||||
if (!result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
|
||||
Vendored
+36
-21
@@ -13,74 +13,89 @@
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecCodeRef hostCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) {
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy host code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to copy designated requirement %d", result);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath];
|
||||
newBundle = [NSBundle bundleWithPath:destinationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle for update");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
|
||||
if (result != 0) {
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error);
|
||||
if (result != 0 && error) {
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
CFStringRef requirementString = nil;
|
||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
||||
SULog(@"Failed requirement %@", requirementString);
|
||||
SULog(@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
CFRelease(requirementString);
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:hostCode label:@"host info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
|
||||
[*error autorelease];
|
||||
}
|
||||
|
||||
finally:
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
return (result == noErr);
|
||||
}
|
||||
|
||||
static id valueOrNSNull(id value) {
|
||||
return value ? value : [NSNull null];
|
||||
}
|
||||
|
||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
CFDictionaryRef signingInfo = nil;
|
||||
const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation;
|
||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||
NSDictionary* signingDict = (NSDictionary*)signingInfo;
|
||||
NSMutableDictionary* relevantInfo = [NSMutableDictionary dictionary];
|
||||
for (NSString* key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||
relevantInfo[key] = signingDict[key];
|
||||
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
|
||||
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||
relevantInfo[key] = valueOrNSNull(signingDict[key]);
|
||||
}
|
||||
NSDictionary* infoPlist = signingDict[@"info-plist"];
|
||||
relevantInfo[@"version"] = infoPlist[@"CFBundleShortVersionString"];
|
||||
relevantInfo[@"build"] = infoPlist[@"CFBundleVersion"];
|
||||
CFRelease(signingInfo);
|
||||
NSDictionary *infoPlist = signingDict[@"info-plist"];
|
||||
relevantInfo[@"version"] = valueOrNSNull(infoPlist[@"CFBundleShortVersionString"]);
|
||||
relevantInfo[@"build"] = valueOrNSNull(infoPlist[@"CFBundleVersion"]);
|
||||
SULog(@"%@: %@", label, relevantInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -16,15 +16,15 @@
|
||||
|
||||
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
|
||||
// if your app has a downgrade function or URL handler, turn this on:
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 0
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 0
|
||||
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
// following on to always reset the name back to "MyApp":
|
||||
#define NORMALIZE_INSTALLED_APP_NAME 0
|
||||
#define NORMALIZE_INSTALLED_APP_NAME 0
|
||||
|
||||
|
||||
#define TRY_TO_APPEND_VERSION_NUMBER 1
|
||||
#define TRY_TO_APPEND_VERSION_NUMBER 1
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Notifications:
|
||||
@@ -53,9 +53,9 @@ extern NSString *const SUEnableSystemProfilingKey;
|
||||
extern NSString *const SUSendProfileInfoKey;
|
||||
extern NSString *const SULastProfileSubmitDateKey;
|
||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey;
|
||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
||||
extern NSString *const SUDefaultsDomainKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Errors:
|
||||
|
||||
Vendored
+13
-2
@@ -5,14 +5,25 @@
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
+135
-334
@@ -5,351 +5,152 @@
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUDSAVerifier.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SULog.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
|
||||
#include <Security/cssm.h>
|
||||
|
||||
/* CDSA Specific */
|
||||
static CSSM_CSP_HANDLE cdsaInit( void );
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle );
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey );
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature );
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes );
|
||||
|
||||
/* Helper Functions */
|
||||
static NSData *b64decode( NSString *str );
|
||||
static NSData *rawKeyData( NSString *str );
|
||||
|
||||
@implementation SUDSAVerifier
|
||||
#pragma mark -
|
||||
@implementation SUDSAVerifier {
|
||||
SecKeyRef _secKey;
|
||||
}
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
if ( !encodedSignature || !pkeyString || !path ) return NO;
|
||||
BOOL result = NO;
|
||||
NSData *pathData = nil, *sigData = nil;
|
||||
CFDataRef hashData = NULL;
|
||||
CSSM_KEY_PTR pubKey = cdsaCreateKey((CFDataRef)rawKeyData(pkeyString)); // Create the DSA key
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
if (!encodedSignature) {
|
||||
SULog(@"There is no DSA signature to check");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ( !pubKey ) return NO;
|
||||
if ( (cspHandle = cdsaInit()) == CSSM_INVALID_HANDLE ) goto validate_end; // Init CDSA
|
||||
if ( !cdsaVerifyKey(cspHandle, pubKey) ) goto validate_end; // Verify the key is valid
|
||||
if ( (pathData = [NSData dataWithContentsOfFile:path]) == nil ) goto validate_end; // File data
|
||||
if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (CFDataRef)pathData)) == NULL ) goto validate_end; // Hash
|
||||
if (!path) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Remove any line feeds from end of signature
|
||||
// (Not likely needed, but the verify _can_ fail if there is, so...)
|
||||
if ( [encodedSignature characterAtIndex:[encodedSignature length] - 1] == '\n' ) {
|
||||
NSMutableString *sig = [[encodedSignature mutableCopy] autorelease];
|
||||
while ( [sig characterAtIndex:[sig length] - 1] == '\n' )
|
||||
[sig deleteCharactersInRange:NSMakeRange([sig length] - 1, 1)];
|
||||
encodedSignature = sig;
|
||||
}
|
||||
if ( (sigData = b64decode(encodedSignature)) == nil ) goto validate_end; // Decode signature
|
||||
SUDSAVerifier *verifier = [[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
// Verify the signature on the file
|
||||
result = cdsaVerifySignature( cspHandle, pubKey, hashData, (CFDataRef)sigData );
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
validate_end:
|
||||
cdsaReleaseKey( pubKey );
|
||||
cdsaRelease( cspHandle );
|
||||
if ( hashData ) CFRelease( hashData );
|
||||
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
NSData *signature = [[NSData alloc] initWithBase64Encoding:strippedSignature];
|
||||
return [verifier verifyFileAtPath:path signature:signature];
|
||||
}
|
||||
|
||||
return result;
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (!self || !data.length) {
|
||||
SULog(@"Could not read public DSA key");
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecExternalFormat format = kSecFormatOpenSSL;
|
||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||
CFArrayRef items = NULL;
|
||||
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, 0, NULL, NULL, &items);
|
||||
if (status != errSecSuccess || !items) {
|
||||
if (items) {
|
||||
CFRelease(items);
|
||||
}
|
||||
SULog(@"Public DSA key could not be imported: %d", status);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_secKey) {
|
||||
CFRelease(_secKey);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
|
||||
{
|
||||
if (!path.length) {
|
||||
return NO;
|
||||
}
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyStream:dataInputStream signature:signature];
|
||||
}
|
||||
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !signature) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
__block SecTransformRef dataVerifyTransform = NULL;
|
||||
__block CFErrorRef error = NULL;
|
||||
|
||||
BOOL (^cleanup)(void) = ^{
|
||||
if (group) CFRelease(group);
|
||||
if (dataReadTransform) CFRelease(dataReadTransform);
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
return NO;
|
||||
};
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(@"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(@"Could not understand format of the sugnature: %@; Signature data: %@", error, signature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(@"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(@"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
if (error) {
|
||||
SULog(@"DSA signature verification failed: %@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(@"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
}
|
||||
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Misc Helper Functions
|
||||
#pragma mark -
|
||||
|
||||
static NSData *b64decode( NSString *str )
|
||||
{
|
||||
if ( !str ) return nil;
|
||||
NSMutableData *retval = nil;
|
||||
NSData *input = [str dataUsingEncoding:NSUTF8StringEncoding];
|
||||
UInt8 *ibuf = (UInt8 *)[input bytes], *buf = NULL, *a = NULL;
|
||||
size_t len = [input length], i = 0, j = 0, size = ((len + 3) / 4) * 3;
|
||||
static UInt8 table[256] = {
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 00-0F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 10-1F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,62,99,99,99,63, /* 20-2F */
|
||||
52,53,54,55,56,57,58,59,60,61,99,99,99,99,99,99, /* 30-3F */
|
||||
99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
|
||||
15,16,17,18,19,20,21,22,23,24,25,99,99,99,99,99, /* 50-5F */
|
||||
99,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
|
||||
41,42,43,44,45,46,47,48,49,50,51,99,99,99,99,99, /* 70-7F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 80-8F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 90-9F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* A0-AF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* B0-BF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* C0-CF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* D0-DF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* E0-EF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 /* F0-FF */
|
||||
};
|
||||
|
||||
retval = [NSMutableData dataWithLength:size];
|
||||
buf = [retval mutableBytes];
|
||||
|
||||
if ( (a = calloc(4, sizeof(UInt8))) == NULL ) return nil;
|
||||
|
||||
do {
|
||||
size_t ai = 0;
|
||||
a[0] = a[1] = a[2] = a[3] = 0;
|
||||
do {
|
||||
UInt8 d = table[ibuf[i++]];
|
||||
if ( d != 99 ) {
|
||||
a[ai] = d;
|
||||
ai++;
|
||||
if ( ai == 4 ) break;
|
||||
}
|
||||
} while ( i < len );
|
||||
if ( ai >= 2 ) buf[j+0] = (UInt8)((a[0] << 2) | (a[1] >> 4));
|
||||
if ( ai >= 3 ) buf[j+1] = (UInt8)((a[1] << 4) | (a[2] >> 2));
|
||||
if ( ai >= 4 ) buf[j+2] = (UInt8)((a[2] << 6) | (a[3] >> 0));
|
||||
j += ai-1;
|
||||
} while ( i < len );
|
||||
|
||||
free( a );
|
||||
if ( j < size ) [retval setLength:j];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static NSData *rawKeyData( NSString *key )
|
||||
{
|
||||
if ( (key == nil) || ([key length] == 0) ) return nil;
|
||||
NSMutableString *t = [[key mutableCopy] autorelease];
|
||||
|
||||
// Remove the PEM guards (if present)
|
||||
[t replaceOccurrencesOfString:@"-" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"BEGIN PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"END PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
|
||||
// Remove any line feeds from the beginning of the key
|
||||
while ( [t characterAtIndex:0] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange(0, 1)];
|
||||
}
|
||||
|
||||
// Remove any line feeds at the end of the key
|
||||
while ( [t characterAtIndex:[t length] - 1] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange([t length] - 1, 1)];
|
||||
}
|
||||
|
||||
// Remove whitespace around each line of the key.
|
||||
NSMutableArray *pkeyTrimmedLines = [NSMutableArray array];
|
||||
NSCharacterSet *whiteSet = [NSCharacterSet whitespaceCharacterSet];
|
||||
for (NSString *pkeyLine in [t componentsSeparatedByString:@"\n"])
|
||||
{
|
||||
[pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:whiteSet]];
|
||||
}
|
||||
key = [pkeyTrimmedLines componentsJoinedByString:@"\n"]; // Put them back together.
|
||||
|
||||
// Base64 decode to return the raw key bits (DER format rather than PEM)
|
||||
return b64decode( key );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CDSA
|
||||
#pragma mark -
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes );
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData );
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes );
|
||||
|
||||
/* Memory functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void *ref );
|
||||
static void su_free( void *ptr, void *ref );
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref );
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref );
|
||||
|
||||
/* Constants & Typedefs */
|
||||
static CSSM_VERSION vers = { 2, 0 };
|
||||
static const CSSM_GUID su_guid = { 'S', 'p', 'a', { 'r', 'k', 'l', 'e', 0, 0, 0, 0 } };
|
||||
static CSSM_BOOL cssmInited = CSSM_FALSE;
|
||||
|
||||
static CSSM_API_MEMORY_FUNCS SU_MemFuncs = {
|
||||
su_malloc,
|
||||
su_free,
|
||||
su_realloc,
|
||||
su_calloc,
|
||||
NULL
|
||||
};
|
||||
|
||||
static CSSM_CSP_HANDLE cdsaInit( void )
|
||||
{
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_RETURN crtn;
|
||||
|
||||
if ( !cssmInited ) {
|
||||
CSSM_PVC_MODE pvcPolicy = CSSM_PVC_NONE;
|
||||
crtn = CSSM_Init( &vers, CSSM_PRIVILEGE_SCOPE_NONE, &su_guid, CSSM_KEY_HIERARCHY_NONE, &pvcPolicy, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
cssmInited = CSSM_TRUE;
|
||||
}
|
||||
|
||||
crtn = CSSM_ModuleLoad( &gGuidAppleCSP, CSSM_KEY_HIERARCHY_NONE, NULL, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
crtn = CSSM_ModuleAttach( &gGuidAppleCSP, &vers, &SU_MemFuncs, 0, CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE, NULL, 0, NULL, &cspHandle );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
return cspHandle;
|
||||
}
|
||||
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle )
|
||||
{
|
||||
if ( CSSM_ModuleDetach(cspHandle) != CSSM_OK ) return;
|
||||
CSSM_ModuleUnload( &gGuidAppleCSP, NULL, NULL );
|
||||
}
|
||||
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey )
|
||||
{
|
||||
CSSM_KEY_PTR retval = NULL;
|
||||
|
||||
if ( !rawKey || (CFDataGetLength(rawKey) == 0) ) return NULL;
|
||||
|
||||
if ( (retval = su_malloc(sizeof(CSSM_KEY), NULL)) == NULL ) return NULL;
|
||||
|
||||
if ( !su_copyBytesToData(&(retval->KeyData), (CSSM_SIZE)CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
|
||||
su_free( retval, NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSSM_KEYHEADER_PTR hdr = &(retval->KeyHeader);
|
||||
|
||||
memset( hdr, 0, sizeof(CSSM_KEYHEADER) );
|
||||
|
||||
hdr->HeaderVersion = CSSM_KEYHEADER_VERSION;
|
||||
hdr->CspId = su_guid;
|
||||
hdr->BlobType = CSSM_KEYBLOB_RAW;
|
||||
hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_X509;
|
||||
hdr->AlgorithmId = CSSM_ALGID_DSA;
|
||||
hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY;
|
||||
hdr->KeyAttr = CSSM_KEYATTR_EXTRACTABLE;
|
||||
hdr->KeyUsage = CSSM_KEYUSE_ANY;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key ) {
|
||||
if ( key->KeyData.Data ) su_free( key->KeyData.Data, NULL );
|
||||
su_free( key, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key->KeyHeader.LogicalKeySizeInBits == 0 ) {
|
||||
CSSM_RETURN crtn;
|
||||
CSSM_KEY_SIZE keySize;
|
||||
|
||||
/* This will fail if the key isn't valid */
|
||||
crtn = CSSM_QueryKeySizeInBits( cspHandle, CSSM_INVALID_HANDLE, key, &keySize );
|
||||
if ( crtn ) return NO;
|
||||
key->KeyHeader.LogicalKeySizeInBits = keySize.LogicalKeySizeInBits;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR plain = su_createData( msg ), cipher = su_createData( signature );
|
||||
BOOL retval = NO;
|
||||
|
||||
if ( !plain || !cipher || (CSSM_CSP_CreateSignatureContext(cspHandle, CSSM_ALGID_SHA1WithDSA, NULL, key, &ccHandle) != CSSM_OK) )
|
||||
goto verify_end;
|
||||
|
||||
retval = ( CSSM_VerifyData(ccHandle, plain, 1, CSSM_ALGID_NONE, cipher) == CSSM_OK );
|
||||
|
||||
verify_end:
|
||||
su_freeData( plain, true );
|
||||
su_freeData( cipher, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR data = su_createData( bytes ), dgst = su_createData( NULL );
|
||||
CFDataRef retval = NULL;
|
||||
|
||||
if ( !data || !dgst || (CSSM_CSP_CreateDigestContext(cspHandle, CSSM_ALGID_SHA1, &ccHandle) != CSSM_OK) )
|
||||
goto digest_end;
|
||||
|
||||
if ( CSSM_DigestData(ccHandle, data, 1, dgst) == CSSM_OK )
|
||||
retval = CFDataCreate( kCFAllocatorDefault, (const UInt8 *)dgst->Data, (CFIndex)dgst->Length );
|
||||
|
||||
digest_end:
|
||||
su_freeData( data, true );
|
||||
su_freeData( dgst, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Memory Functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
static void su_free( void *ptr, void * __unused ref )
|
||||
{
|
||||
free( ptr );
|
||||
}
|
||||
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return calloc( num, size );
|
||||
}
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes )
|
||||
{
|
||||
CSSM_DATA_PTR data = su_malloc( sizeof(CSSM_DATA), NULL );
|
||||
if ( !data ) return NULL;
|
||||
data->Data = NULL;
|
||||
data->Length = 0;
|
||||
if ( bytes ) su_copyBytesToData( data, (CSSM_SIZE)CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
|
||||
return data;
|
||||
}
|
||||
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData )
|
||||
{
|
||||
if ( data ) {
|
||||
if ( freeData && data->Data ) su_free( data->Data, NULL );
|
||||
su_free( data, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes )
|
||||
{
|
||||
Boolean retval = false;
|
||||
if ( size && bytes ) {
|
||||
if ( (data->Data = su_malloc(size, NULL)) ) {
|
||||
memcpy( data->Data, bytes, size );
|
||||
data->Length = size;
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
Vendored
+85
-79
@@ -16,147 +16,153 @@
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMG
|
||||
{
|
||||
@autoreleasepool {
|
||||
[self extractDMGWithPassword:nil];
|
||||
}
|
||||
[self extractDMGWithPassword:nil];
|
||||
}
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithPassword:(NSString *) __unused password
|
||||
- (void)extractDMGWithPassword:(NSString *)__unused password
|
||||
{
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
SULog(@"Extracting %@ as a DMG", archivePath);
|
||||
SULog(@"Extracting %@ as a DMG", self.archivePath);
|
||||
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
FSRef tmpRef;
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
FSRef tmpRef;
|
||||
NSFileManager *manager;
|
||||
NSError *error;
|
||||
NSArray *contents;
|
||||
// We have to declare these before a goto to prevent an error under ARC.
|
||||
// No, we cannot have them in the dispatch_async calls, as the goto "jump enters
|
||||
// lifetime of block which strongly captures a variable"
|
||||
dispatch_block_t delegateFailure = ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
};
|
||||
dispatch_block_t delegateSuccess = ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
};
|
||||
do
|
||||
{
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
if (uuid)
|
||||
{
|
||||
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
||||
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
||||
if (uuidString)
|
||||
{
|
||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
||||
}
|
||||
CFRelease(uuid);
|
||||
}
|
||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
||||
}
|
||||
CFRelease(uuid);
|
||||
}
|
||||
}
|
||||
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
|
||||
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSArray* arguments = @[@"attach", archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
|
||||
NSArray *arguments = @[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
{
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
||||
|
||||
taskResult = [task result];
|
||||
output = [[[task output] copy] autorelease];
|
||||
[task release];
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
taskResult = [task result];
|
||||
output = [[task output] copy];
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
if (taskResult != 0)
|
||||
{
|
||||
NSString* resultStr = output ? [[[NSString alloc] initWithData: output encoding: NSUTF8StringEncoding] autorelease] : nil;
|
||||
SULog( @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr );
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
||||
SULog(@"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
NSError *error = nil;
|
||||
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
manager = [[NSFileManager alloc] init];
|
||||
contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
if (error)
|
||||
{
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
goto finally;
|
||||
dispatch_async(dispatch_get_main_queue(), delegateSuccess);
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), delegateFailure);
|
||||
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
else
|
||||
SULog(@"Can't mount DMG %@",archivePath);
|
||||
}
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
else
|
||||
SULog(@"Can't mount DMG %@", self.archivePath);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self extractDMG];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
- (BOOL)isEncrypted:(NSData*)resultData
|
||||
- (BOOL)isEncrypted:(NSData *)resultData
|
||||
{
|
||||
BOOL result = NO;
|
||||
BOOL result = NO;
|
||||
if(resultData)
|
||||
{
|
||||
NSString *data = [[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding] autorelease];
|
||||
NSString *data = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
|
||||
|
||||
if ((data != nil) && !NSEqualRanges([data rangeOfString:@"passphrase-count"], NSMakeRange(NSNotFound, 0)))
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+2
-6
@@ -11,12 +11,8 @@
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@interface SUHost : NSObject
|
||||
{
|
||||
@private
|
||||
NSString *defaultsDomain;
|
||||
BOOL usesStandardUserDefaults;
|
||||
}
|
||||
@property (retain, readonly) NSBundle *bundle;
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
|
||||
Vendored
+96
-95
@@ -24,11 +24,18 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
@interface SUHost ()
|
||||
@property (retain, readwrite) NSBundle *bundle;
|
||||
|
||||
@property (strong, readwrite) NSBundle *bundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUHost
|
||||
|
||||
@synthesize bundle;
|
||||
@synthesize defaultsDomain;
|
||||
@synthesize usesStandardUserDefaults;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
@@ -36,33 +43,27 @@ typedef struct {
|
||||
{
|
||||
if (aBundle == nil) aBundle = [NSBundle mainBundle];
|
||||
self.bundle = aBundle;
|
||||
if (![bundle bundleIdentifier]) {
|
||||
SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle);
|
||||
}
|
||||
if (![self.bundle bundleIdentifier]) {
|
||||
SULog(@"Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", self.bundle);
|
||||
}
|
||||
|
||||
defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain];
|
||||
if (!defaultsDomain) {
|
||||
defaultsDomain = [[bundle bundleIdentifier] retain];
|
||||
}
|
||||
self.defaultsDomain = [self.bundle objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
||||
if (!self.defaultsDomain) {
|
||||
self.defaultsDomain = [self.bundle bundleIdentifier];
|
||||
}
|
||||
|
||||
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
|
||||
usesStandardUserDefaults = [defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
|
||||
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[defaultsDomain release];
|
||||
self.bundle = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
|
||||
|
||||
- (NSString *)bundlePath
|
||||
{
|
||||
return [bundle bundlePath];
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)appSupportPath
|
||||
@@ -76,7 +77,7 @@ typedef struct {
|
||||
}
|
||||
else {
|
||||
appSupportPath = appSupportPaths[0];
|
||||
}
|
||||
}
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"];
|
||||
return appSupportPath;
|
||||
@@ -86,165 +87,165 @@ typedef struct {
|
||||
{
|
||||
#if NORMALIZE_INSTALLED_APP_NAME
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) {
|
||||
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:@"CFBundleName"], [[self.bundle bundlePath] pathExtension]]];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:@"CFBundleName"], [[self.bundle bundlePath] pathExtension]]]]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return [bundle bundlePath];
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
NSString *name = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
NSString *name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:@"CFBundleName"];
|
||||
name = [self objectForInfoDictionaryKey:@"CFBundleName"];
|
||||
if (name) return name;
|
||||
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[bundle bundlePath]] stringByDeletingPathExtension];
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
- (NSString *)version
|
||||
{
|
||||
NSString *version = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
|
||||
return version;
|
||||
NSString *version = [self.bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
|
||||
return version;
|
||||
}
|
||||
|
||||
- (NSString *)displayVersion
|
||||
{
|
||||
NSString *shortVersionString = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
return shortVersionString;
|
||||
else
|
||||
return [self version]; // Fall back on the normal version string.
|
||||
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
return shortVersionString;
|
||||
else
|
||||
return [self version]; // Fall back on the normal version string.
|
||||
}
|
||||
|
||||
- (NSImage *)icon
|
||||
{
|
||||
// Cache the application icon.
|
||||
NSString *iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
||||
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// the icon for the bundle. The filename you specify does not need to include the .icns
|
||||
// extension, although it may."
|
||||
//
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
|
||||
if (!iconPath) {
|
||||
iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
|
||||
}
|
||||
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
|
||||
// Use a default icon if none is defined.
|
||||
if (!icon) {
|
||||
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);
|
||||
// Cache the application icon.
|
||||
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
||||
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// the icon for the bundle. The filename you specify does not need to include the .icns
|
||||
// extension, although it may."
|
||||
//
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
|
||||
if (!iconPath) {
|
||||
iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:nil];
|
||||
}
|
||||
NSImage *icon = [[NSImage alloc] initWithContentsOfFile:iconPath];
|
||||
// Use a default icon if none is defined.
|
||||
if (!icon) {
|
||||
BOOL isMainBundle = (self.bundle == [NSBundle mainBundle]);
|
||||
|
||||
NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||
}
|
||||
return icon;
|
||||
NSString *fileType = isMainBundle ? (NSString *)kUTTypeApplication : (NSString *)kUTTypeBundle;
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
- (BOOL)isRunningOnReadOnlyVolume
|
||||
{
|
||||
struct statfs statfs_info;
|
||||
statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY);
|
||||
struct statfs statfs_info;
|
||||
statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY);
|
||||
}
|
||||
|
||||
- (BOOL)isBackgroundApplication
|
||||
{
|
||||
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
|
||||
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
|
||||
}
|
||||
|
||||
- (NSString *)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
if (key) { return key; }
|
||||
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
if (!keyFilename) { return nil; }
|
||||
NSError *ignoreErr = nil;
|
||||
return [NSString stringWithContentsOfFile:[bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error: &ignoreErr];
|
||||
NSError *ignoreErr = nil;
|
||||
return [NSString stringWithContentsOfFile:[self.bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error:&ignoreErr];
|
||||
}
|
||||
|
||||
- (NSArray *)systemProfile
|
||||
{
|
||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
||||
}
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
return [bundle objectForInfoDictionaryKey:key];
|
||||
return [self.bundle objectForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
return [[self objectForInfoDictionaryKey:key] boolValue];
|
||||
return [[self objectForInfoDictionaryKey:key] boolValue];
|
||||
}
|
||||
|
||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (!defaultName || !defaultsDomain) {
|
||||
if (!defaultName || !self.defaultsDomain) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
|
||||
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
|
||||
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
|
||||
if (usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
|
||||
}
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
|
||||
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
|
||||
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
|
||||
if (self.usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
|
||||
}
|
||||
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
return CFBridgingRelease(obj);
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||
return CFBridgingRelease(obj);
|
||||
}
|
||||
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults)
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
|
||||
}
|
||||
if (self.usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
|
||||
}
|
||||
|
||||
BOOL value;
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
if (plr == NULL) {
|
||||
value = NO;
|
||||
BOOL value;
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||
if (plr == NULL) {
|
||||
value = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
||||
CFRelease(plr);
|
||||
}
|
||||
return value;
|
||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
||||
CFRelease(plr);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults)
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)@(value), (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)objectForKey:(NSString *)key {
|
||||
|
||||
Vendored
+77
-78
@@ -16,95 +16,94 @@
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
static NSString* sUpdateFolder = nil;
|
||||
static NSString *sUpdateFolder = nil;
|
||||
|
||||
+(NSString*) updateFolder
|
||||
+ (NSString *)updateFolder
|
||||
{
|
||||
return sUpdateFolder;
|
||||
return sUpdateFolder;
|
||||
}
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
{
|
||||
FSRef fileRef;
|
||||
OSStatus err = noErr;
|
||||
Boolean aliasFileFlag = false, folderFlag = false;
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
FSRef fileRef;
|
||||
OSStatus err = noErr;
|
||||
Boolean aliasFileFlag = false, folderFlag = false;
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
|
||||
if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef))
|
||||
err = coreFoundationUnknownErr;
|
||||
if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef))
|
||||
err = coreFoundationUnknownErr;
|
||||
|
||||
if (noErr == err)
|
||||
err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag);
|
||||
if (noErr == err)
|
||||
err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag);
|
||||
|
||||
if (noErr == err)
|
||||
return !!(aliasFileFlag && folderFlag);
|
||||
else
|
||||
return NO;
|
||||
if (noErr == err)
|
||||
return !!(aliasFileFlag && folderFlag);
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr
|
||||
{
|
||||
// Search subdirectories for the application
|
||||
NSString *currentFile,
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
BOOL isPackage = NO;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath: inUpdateFolder];
|
||||
NSString *currentFile,
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
BOOL isPackage = NO;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||
|
||||
[sUpdateFolder release];
|
||||
sUpdateFolder = [inUpdateFolder retain];
|
||||
sUpdateFolder = inUpdateFolder;
|
||||
|
||||
while ((currentFile = [dirEnum nextObject]))
|
||||
{
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
|
||||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
|
||||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else if ([[currentFile pathExtension] isEqualToString:@"pkg"] ||
|
||||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
|
||||
{
|
||||
if ([[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
if(incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]])
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Some DMGs have symlinks into /Applications! That's no good!
|
||||
if ([self isAliasFolderAtPath:currentPath])
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
// Some DMGs have symlinks into /Applications! That's no good!
|
||||
if ([self isAliasFolderAtPath:currentPath])
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil)
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = fallbackPackagePath;
|
||||
}
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = fallbackPackagePath;
|
||||
}
|
||||
|
||||
if (isPackagePtr) *isPackagePtr = isPackage;
|
||||
return newAppDownloadPath;
|
||||
@@ -134,49 +133,49 @@ static NSString* sUpdateFolder = nil;
|
||||
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
SULog( @"mdimporting" );
|
||||
SULog(@"mdimporting");
|
||||
|
||||
NSTask *mdimport = [[[NSTask alloc] init] autorelease];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:@[installationPath]];
|
||||
NSTask *mdimport = [[NSTask alloc] init];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:@[installationPath]];
|
||||
@try
|
||||
{
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException * launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Sparkle Error: %@", [launchException description]);
|
||||
}
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException *launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Error: %@", [launchException description]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define SUNotifyDictHostKey @"SUNotifyDictHost"
|
||||
#define SUNotifyDictErrorKey @"SUNotifyDictError"
|
||||
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
|
||||
#define SUNotifyDictHostKey @"SUNotifyDictHost"
|
||||
#define SUNotifyDictErrorKey @"SUNotifyDictError"
|
||||
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
|
||||
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id<SUInstallerDelegate>)delegate
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[delegate installerFinishedForHost:host];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[delegate installerForHost:host failedWithError:error];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+2
-2
@@ -25,7 +25,7 @@
|
||||
// Prototypes:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void );
|
||||
void SULog( NSString* format, ... ) NS_FORMAT_FUNCTION(1,2);
|
||||
void SUClearLog(void);
|
||||
void SULog(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
|
||||
|
||||
|
||||
Vendored
+20
-25
@@ -18,7 +18,7 @@
|
||||
// Constants:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log"
|
||||
#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -36,13 +36,12 @@
|
||||
// result - same here.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void )
|
||||
void SUClearLog(void)
|
||||
{
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"w");
|
||||
if( logfile )
|
||||
fclose(logfile);
|
||||
else
|
||||
NSLog(@"----- Sparkle Log -----");
|
||||
FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "w");
|
||||
if (logfile) {
|
||||
fclose(logfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,25 +55,21 @@ void SUClearLog( void )
|
||||
// ... - More parameters depending on format string's contents.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SULog( NSString* format, ... )
|
||||
void SULog(NSString *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString* theStr = [[[NSString alloc] initWithFormat: format arguments: ap] autorelease];
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"a");
|
||||
if( !logfile )
|
||||
NSLog( @"%@",theStr );
|
||||
else
|
||||
{
|
||||
theStr = [NSString stringWithFormat: @"%@: %@", [NSDate date], theStr];
|
||||
NSData* theData = [theStr dataUsingEncoding: NSUTF8StringEncoding];
|
||||
char newlineChar = '\n';
|
||||
fwrite( [theData bytes], 1, [theData length], logfile );
|
||||
fwrite( &newlineChar, 1, 1, logfile ); // Append a newline.
|
||||
fclose( logfile );
|
||||
logfile = NULL;
|
||||
}
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString *theStr = [[NSString alloc] initWithFormat:format arguments:ap];
|
||||
NSLog(@"Sparkle: %@", theStr);
|
||||
|
||||
FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "a");
|
||||
if (logfile) {
|
||||
theStr = [NSString stringWithFormat:@"%@: %@\n", [NSDate date], theStr];
|
||||
NSData *theData = [theStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
fwrite([theData bytes], 1, [theData length], logfile);
|
||||
fclose(logfile);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+69
-64
@@ -15,132 +15,137 @@
|
||||
|
||||
+ (SEL)selectorConformingToTypeOfPath:(NSString *)path
|
||||
{
|
||||
static NSDictionary *typeSelectorDictionary;
|
||||
if (!typeSelectorDictionary)
|
||||
typeSelectorDictionary = [@{@".zip": @"extractZIP",
|
||||
static NSDictionary *typeSelectorDictionary;
|
||||
if (!typeSelectorDictionary)
|
||||
typeSelectorDictionary = @{ @".zip": @"extractZIP",
|
||||
@".tar": @"extractTAR",
|
||||
@".tar.gz": @"extractTGZ",
|
||||
@".tar.gz": @"extractTGZ",
|
||||
@".tgz": @"extractTGZ",
|
||||
@".tar.bz2": @"extractTBZ",
|
||||
@".tbz": @"extractTBZ"} retain];
|
||||
@".tar.bz2": @"extractTBZ",
|
||||
@".tbz": @"extractTBZ" };
|
||||
|
||||
NSString *lastPathComponent = [path lastPathComponent];
|
||||
NSString *lastPathComponent = [path lastPathComponent];
|
||||
for (NSString *currentType in typeSelectorDictionary)
|
||||
{
|
||||
if ([currentType length] > [lastPathComponent length]) continue;
|
||||
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
|
||||
return NSSelectorFromString(typeSelectorDictionary[currentType]);
|
||||
}
|
||||
return NULL;
|
||||
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
|
||||
return NSSelectorFromString(typeSelectorDictionary[currentType]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:archivePath] toTarget:self withObject:nil];
|
||||
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:self.archivePath] toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return ([self selectorConformingToTypeOfPath:path] != nil);
|
||||
return ([self selectorConformingToTypeOfPath:path] != nil);
|
||||
}
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
@autoreleasepool {
|
||||
FILE *fp = NULL, *cmdFP = NULL;
|
||||
char *oldDestinationString = NULL;
|
||||
FILE *fp = NULL, *cmdFP = NULL;
|
||||
char *oldDestinationString = NULL;
|
||||
// We have to declare these before a goto to prevent an error under ARC.
|
||||
// No, we cannot have them in the dispatch_async calls, as the goto "jump enters
|
||||
// lifetime of block which strongly captures a variable"
|
||||
dispatch_block_t delegateSuccess = ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
};
|
||||
dispatch_block_t delegateFailure = ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
};
|
||||
|
||||
SULog(@"Extracting %@ using '%@'",archivePath,command);
|
||||
SULog(@"Extracting %@ using '%@'", self.archivePath, command);
|
||||
|
||||
// Get the file size.
|
||||
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil][NSFileSize];
|
||||
// Get the file size.
|
||||
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil][NSFileSize];
|
||||
if (fs == nil) goto reportError;
|
||||
|
||||
// Thank you, Allan Odgaard!
|
||||
// (who wrote the following extraction alg.)
|
||||
fp = fopen([archivePath fileSystemRepresentation], "r");
|
||||
// Thank you, Allan Odgaard!
|
||||
// (who wrote the following extraction alg.)
|
||||
fp = fopen([self.archivePath fileSystemRepresentation], "r");
|
||||
if (!fp) goto reportError;
|
||||
|
||||
oldDestinationString = getenv("DESTINATION");
|
||||
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
|
||||
cmdFP = popen([command fileSystemRepresentation], "w");
|
||||
size_t written;
|
||||
oldDestinationString = getenv("DESTINATION");
|
||||
setenv("DESTINATION", [[self.archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
|
||||
cmdFP = popen([command fileSystemRepresentation], "w");
|
||||
size_t written;
|
||||
if (!cmdFP) goto reportError;
|
||||
|
||||
char buf[32*1024];
|
||||
size_t len;
|
||||
char buf[32 * 1024];
|
||||
size_t len;
|
||||
while((len = fread(buf, 1, 32*1024, fp)))
|
||||
{
|
||||
written = fwrite(buf, 1, len, cmdFP);
|
||||
written = fwrite(buf, 1, len, cmdFP);
|
||||
if( written < len )
|
||||
{
|
||||
pclose(cmdFP);
|
||||
goto reportError;
|
||||
}
|
||||
pclose(cmdFP);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfExtractedLength:len];
|
||||
});
|
||||
}
|
||||
pclose(cmdFP);
|
||||
});
|
||||
}
|
||||
pclose(cmdFP);
|
||||
|
||||
if (ferror(fp)) {
|
||||
goto reportError;
|
||||
}
|
||||
if (ferror(fp)) {
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
goto finally;
|
||||
dispatch_async(dispatch_get_main_queue(), delegateSuccess);
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), delegateFailure);
|
||||
|
||||
finally:
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
if (oldDestinationString)
|
||||
setenv("DESTINATION", oldDestinationString, 1);
|
||||
else
|
||||
unsetenv("DESTINATION");
|
||||
}
|
||||
finally:
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
if (oldDestinationString)
|
||||
setenv("DESTINATION", oldDestinationString, 1);
|
||||
else
|
||||
unsetenv("DESTINATION");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)extractTAR
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
[self extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
[self extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)extractTGZ
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
[self extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
[self extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)extractTBZ
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
[self extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
[self extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)extractZIP
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
[self extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
[self extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+8
-8
@@ -15,16 +15,16 @@
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
// Prevent malicious downgrades:
|
||||
#if !PERMIT_AUTOMATED_DOWNGRADES
|
||||
// Prevent malicious downgrades:
|
||||
#if !PERMIT_AUTOMATED_DOWNGRADES
|
||||
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending)
|
||||
{
|
||||
NSString * errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSError *error = nil;
|
||||
|
||||
Vendored
+1
-1
@@ -15,7 +15,7 @@
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path;
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error;
|
||||
+ (void)_movePathToTrash:(NSString *)path;
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error;
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error;
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+387
-359
@@ -23,13 +23,17 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE;
|
||||
#endif
|
||||
|
||||
static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
|
||||
{
|
||||
if ([NSThread isMainThread]) {
|
||||
theBlock();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), theBlock);
|
||||
}
|
||||
if ([NSThread isMainThread]) {
|
||||
theBlock();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), theBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@interface SUPlainInstaller (MMExtendedAttributes)
|
||||
@@ -51,31 +55,31 @@ static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
|
||||
// that the quarantine is implemented in part by setting an extended attribute,
|
||||
// "com.apple.quarantine", on affected files. Removing this attribute is
|
||||
// sufficient to remove files from the quarantine.
|
||||
+ (void)releaseFromQuarantine:(NSString*)root;
|
||||
+ (void)releaseFromQuarantine:(NSString *)root;
|
||||
@end
|
||||
|
||||
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, const char *const *arguments)
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
|
||||
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess)
|
||||
{
|
||||
int status;
|
||||
pid_t pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
returnValue = NO;
|
||||
int status;
|
||||
pid_t pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
returnValue = NO;
|
||||
}
|
||||
else
|
||||
returnValue = NO;
|
||||
returnValue = NO;
|
||||
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -83,450 +87,450 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path
|
||||
{
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
NSString *postFix;
|
||||
NSString *version;
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
NSString *postFix;
|
||||
NSString *version;
|
||||
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
|
||||
{
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else
|
||||
postFix = @"old";
|
||||
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
|
||||
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
// Now let's make sure we get a unique path.
|
||||
unsigned int cnt=2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
|
||||
return [tempDir lastPathComponent];
|
||||
postFix = @"old";
|
||||
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
|
||||
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
// Now let's make sure we get a unique path.
|
||||
unsigned int cnt = 2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
|
||||
return [tempDir lastPathComponent];
|
||||
}
|
||||
|
||||
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash: (BOOL*)outDidFindTrash
|
||||
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash:(BOOL *)outDidFindTrash
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
NSString *tempDir = nil;
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
NSString *tempDir = nil;
|
||||
|
||||
UInt8 trashPath[MAXPATHLEN +1] = { 0 };
|
||||
FSRef trashRef, pathRef;
|
||||
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
|
||||
FSCatalogInfo catInfo;
|
||||
memset( &catInfo, 0, sizeof(catInfo) );
|
||||
OSStatus err = FSPathMakeRef( (UInt8*) [path fileSystemRepresentation], &pathRef, NULL );
|
||||
UInt8 trashPath[MAXPATHLEN + 1] = { 0 };
|
||||
FSRef trashRef, pathRef;
|
||||
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
|
||||
FSCatalogInfo catInfo;
|
||||
memset(&catInfo, 0, sizeof(catInfo));
|
||||
OSStatus err = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
|
||||
if( err == noErr )
|
||||
{
|
||||
err = FSGetCatalogInfo( &pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
|
||||
vSrcRefNum = catInfo.volume;
|
||||
}
|
||||
if( err == noErr )
|
||||
err = FSFindFolder( vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef );
|
||||
if( err == noErr )
|
||||
err = FSGetCatalogInfo( &trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
|
||||
if( err == noErr && vSrcRefNum != catInfo.volume )
|
||||
err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future.
|
||||
if( err == noErr )
|
||||
err = FSRefMakePath( &trashRef, trashPath, MAXPATHLEN );
|
||||
if( err == noErr )
|
||||
tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: (char*) trashPath length: strlen((char*) trashPath)];
|
||||
if( outDidFindTrash )
|
||||
*outDidFindTrash = (tempDir != nil);
|
||||
if( !tempDir )
|
||||
tempDir = [path stringByDeletingLastPathComponent];
|
||||
err = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
|
||||
vSrcRefNum = catInfo.volume;
|
||||
}
|
||||
if (err == noErr)
|
||||
err = FSFindFolder(vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef);
|
||||
if (err == noErr)
|
||||
err = FSGetCatalogInfo(&trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
|
||||
if (err == noErr && vSrcRefNum != catInfo.volume)
|
||||
err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future.
|
||||
if (err == noErr)
|
||||
err = FSRefMakePath(&trashRef, trashPath, MAXPATHLEN);
|
||||
if (err == noErr)
|
||||
tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:(char *)trashPath length:strlen((char *)trashPath)];
|
||||
if (outDidFindTrash)
|
||||
*outDidFindTrash = (tempDir != nil);
|
||||
if (!tempDir)
|
||||
tempDir = [path stringByDeletingLastPathComponent];
|
||||
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
#if TRY_TO_APPEND_VERSION_NUMBER
|
||||
NSString *postFix = nil;
|
||||
NSString *version = nil;
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
#if TRY_TO_APPEND_VERSION_NUMBER
|
||||
NSString *postFix = nil;
|
||||
NSString *version = nil;
|
||||
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
|
||||
{
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else {
|
||||
postFix = @"old";
|
||||
}
|
||||
NSString *prefix = [NSString stringWithFormat: @"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
|
||||
#else
|
||||
NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
#endif
|
||||
NSString *tempName = [prefix stringByAppendingPathExtension: [path pathExtension]];
|
||||
tempDir = [tempDir stringByAppendingPathComponent: tempName];
|
||||
postFix = @"old";
|
||||
}
|
||||
NSString *prefix = [NSString stringWithFormat:@"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
|
||||
#else
|
||||
NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
#endif
|
||||
NSString *tempName = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
tempDir = [tempDir stringByAppendingPathComponent:tempName];
|
||||
|
||||
// Now let's make sure we get a unique path.
|
||||
int cnt=2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) {
|
||||
tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]];
|
||||
}
|
||||
// Now let's make sure we get a unique path.
|
||||
int cnt = 2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) {
|
||||
tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]];
|
||||
}
|
||||
|
||||
return tempDir;
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError **)error
|
||||
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
const char* tmpPath = [tmp fileSystemRepresentation];
|
||||
const char* dstPath = [dst fileSystemRepresentation];
|
||||
const char *srcPath = [src fileSystemRepresentation];
|
||||
const char *tmpPath = [tmp fileSystemRepresentation];
|
||||
const char *dstPath = [dst fileSystemRepresentation];
|
||||
|
||||
struct stat dstSB;
|
||||
if( stat(dstPath, &dstSB) != 0 ) // Doesn't exist yet, try containing folder.
|
||||
{
|
||||
const char* dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
struct stat dstSB;
|
||||
if (stat(dstPath, &dstSB) != 0) // Doesn't exist yet, try containing folder.
|
||||
{
|
||||
const char *dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
if( stat(dstDirPath, &dstSB) != 0 )
|
||||
{
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while (authStat == errAuthorizationDenied) {
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while (authStat == errAuthorizationDenied) {
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess) {
|
||||
res = YES;
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess) {
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%u:%u",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%u:%u",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined. It also needs to be
|
||||
// done before "chown" changes ownership, because the ownership
|
||||
// change will almost certainly make it impossible to change
|
||||
// attributes to release the files from the quarantine.
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined. It also needs to be
|
||||
// done before "chown" changes ownership, because the ownership
|
||||
// change will almost certainly make it impossible to change
|
||||
// attributes to release the files from the quarantine.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine");
|
||||
PerformOnMainThreadSync(^{
|
||||
SULog(@"releaseFromQuarantine");
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:src];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog( @"chown -R %s %s failed.", uidgid, srcPath );
|
||||
}
|
||||
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
|
||||
if (!res)
|
||||
SULog(@"chown -R %s %s failed.", uidgid, srcPath);
|
||||
}
|
||||
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog( @"rm failed" );
|
||||
}
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
|
||||
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char *rmParams[] = { "-rf", tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"rm failed");
|
||||
}
|
||||
|
||||
if( res && haveDst ) // Move old exe to tmp path.
|
||||
{
|
||||
const char* mvParams[] = { "-f", dstPath, tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog( @"mv 1 failed" );
|
||||
}
|
||||
if (res && haveDst) // Move old exe to tmp path.
|
||||
{
|
||||
const char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
|
||||
if (!res)
|
||||
SULog(@"mv 1 failed");
|
||||
}
|
||||
|
||||
if( res ) // Move new exe to old exe's path.
|
||||
{
|
||||
const char* mvParams2[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
|
||||
if( !res )
|
||||
SULog( @"mv 2 failed" );
|
||||
}
|
||||
if (res) // Move new exe to old exe's path.
|
||||
{
|
||||
const char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2);
|
||||
if (!res)
|
||||
SULog(@"mv 2 failed");
|
||||
}
|
||||
|
||||
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
|
||||
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
|
||||
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
|
||||
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// }
|
||||
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
|
||||
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
|
||||
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
|
||||
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// }
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined.
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine after installing");
|
||||
PerformOnMainThreadSync(^{
|
||||
SULog(@"releaseFromQuarantine after installing");
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:dst];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
|
||||
}
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
|
||||
}
|
||||
return res;
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError **)error
|
||||
+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
const char* dstPath = [dst fileSystemRepresentation];
|
||||
const char* dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
const char *srcPath = [src fileSystemRepresentation];
|
||||
const char *dstPath = [dst fileSystemRepresentation];
|
||||
const char *dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
|
||||
struct stat dstSB;
|
||||
stat(dstContainerPath, &dstSB);
|
||||
struct stat dstSB;
|
||||
stat(dstContainerPath, &dstSB);
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%d:%d",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%d:%d",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog(@"Can't set permissions");
|
||||
}
|
||||
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
|
||||
if (!res)
|
||||
SULog(@"Can't set permissions");
|
||||
}
|
||||
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
|
||||
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char *rmParams[] = { "-rf", dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
if( res ) // Move!.
|
||||
{
|
||||
const char* mvParams[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog(@"Can't move source file");
|
||||
}
|
||||
if (res) // Move!.
|
||||
{
|
||||
const char *mvParams[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
|
||||
if (!res)
|
||||
SULog(@"Can't move source file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
|
||||
}
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
|
||||
}
|
||||
return res;
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
const char *srcPath = [src fileSystemRepresentation];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
res = YES;
|
||||
|
||||
if( res ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
if (res) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char *rmParams[] = { "-rf", srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
|
||||
}
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate."}];
|
||||
}
|
||||
return res;
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
BOOL success = YES;
|
||||
BOOL success = YES;
|
||||
if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] )
|
||||
{
|
||||
success = [self _removeFileAtPathWithForcedAuthentication: path error: error];
|
||||
}
|
||||
success = [self _removeFileAtPathWithForcedAuthentication:path error:error];
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
+ (void)_movePathToTrash:(NSString *)path
|
||||
{
|
||||
//SULog(@"Moving %@ to the trash.", path);
|
||||
NSInteger tag = 0;
|
||||
//SULog(@"Moving %@ to the trash.", path);
|
||||
NSInteger tag = 0;
|
||||
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag])
|
||||
{
|
||||
BOOL didFindTrash = NO;
|
||||
NSString* trashPath = [self _temporaryCopyNameForPath: path didFindTrash: &didFindTrash];
|
||||
BOOL didFindTrash = NO;
|
||||
NSString *trashPath = [self _temporaryCopyNameForPath:path didFindTrash:&didFindTrash];
|
||||
if( didFindTrash )
|
||||
{
|
||||
NSError *err = nil;
|
||||
if( ![self _movePathWithForcedAuthentication: path toPath: trashPath error: &err] )
|
||||
SULog(@"Sparkle error: couldn't move %@ to the trash (%@). %@", path, trashPath, err);
|
||||
NSError *err = nil;
|
||||
if (![self _movePathWithForcedAuthentication:path toPath:trashPath error:&err]) {
|
||||
SULog(@"Error: couldn't move %@ to the trash (%@). %@", path, trashPath, err);
|
||||
}
|
||||
}
|
||||
else
|
||||
SULog(@"Sparkle error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path);
|
||||
else {
|
||||
SULog(@"Error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path);
|
||||
}
|
||||
}
|
||||
else
|
||||
;//SULog(@"Moved %@ to the trash.", path);
|
||||
}
|
||||
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *) __unused tmp error:(NSError **)error
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
|
||||
OSStatus err;
|
||||
BOOL hadFileAtDest = NO, didFindTrash = NO;
|
||||
NSString *tmpPath = [self _temporaryCopyNameForPath: dst didFindTrash: &didFindTrash];
|
||||
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
|
||||
OSStatus err;
|
||||
BOOL hadFileAtDest = NO, didFindTrash = NO;
|
||||
NSString *tmpPath = [self _temporaryCopyNameForPath:dst didFindTrash:&didFindTrash];
|
||||
|
||||
// Make FSRef for destination:
|
||||
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
|
||||
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
|
||||
// Make FSRef for destination:
|
||||
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
|
||||
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
if (0 != access([dst fileSystemRepresentation], W_OK) || 0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)
|
||||
if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)
|
||||
|| 0 != access([[[dst stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
if (err != noErr)
|
||||
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
}
|
||||
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
if (err != noErr)
|
||||
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
|
||||
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
|
||||
|
||||
if (err == noErr && hadFileAtDest)
|
||||
{
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
NSFileManager *manager = [[NSFileManager alloc] init];
|
||||
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
|
||||
if (!success && hadFileAtDest)
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath]}];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
|
||||
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
|
||||
if (err == noErr)
|
||||
{
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
|
||||
NSFileManager *manager = [[NSFileManager alloc] init];
|
||||
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
|
||||
if (!success)
|
||||
{
|
||||
// We better move the old version back to its old location
|
||||
if (hadFileAtDest) {
|
||||
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
|
||||
}
|
||||
if (!success && error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath]}];
|
||||
return NO;
|
||||
// We better move the old version back to its old location
|
||||
if (hadFileAtDest) {
|
||||
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
|
||||
}
|
||||
if (!success && error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }];
|
||||
return NO;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home in case it's moved across filesystems: if that
|
||||
// happens, the move is actually a copy, and it may result
|
||||
// in the application being quarantined.
|
||||
PerformOnMainThreadSync(^{
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home in case it's moved across filesystems: if that
|
||||
// happens, the move is actually a copy, and it may result
|
||||
// in the application being quarantined.
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:dst];
|
||||
});
|
||||
});
|
||||
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -537,55 +541,79 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
|
||||
@implementation SUPlainInstaller (MMExtendedAttributes)
|
||||
|
||||
+ (int)removeXAttr:(const char*)name
|
||||
fromFile:(NSString*)file
|
||||
+ (int)removeXAttr:(NSString *)name
|
||||
fromFile:(NSString *)file
|
||||
options:(int)options
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* path = NULL;
|
||||
@try {
|
||||
path = [file fileSystemRepresentation];
|
||||
}
|
||||
const char *path = NULL;
|
||||
const char *attr = [name cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
@try {
|
||||
path = [file fileSystemRepresentation];
|
||||
}
|
||||
@catch (id) {
|
||||
// -[NSString fileSystemRepresentation] throws an exception if it's
|
||||
// unable to convert the string to something suitable. Map that to
|
||||
// EDOM, "argument out of domain", which sort of conveys that there
|
||||
// was a conversion failure.
|
||||
errno = EDOM;
|
||||
return -1;
|
||||
}
|
||||
// -[NSString fileSystemRepresentation] throws an exception if it's
|
||||
// unable to convert the string to something suitable. Map that to
|
||||
// EDOM, "argument out of domain", which sort of conveys that there
|
||||
// was a conversion failure.
|
||||
errno = EDOM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return removexattr(path, name, options);
|
||||
return removexattr(path, attr, options);
|
||||
}
|
||||
|
||||
+ (void)releaseFromQuarantine:(NSString*)root
|
||||
+ (void)releaseFromQuarantine:(NSString *)root
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* quarantineAttribute = "com.apple.quarantine";
|
||||
const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
|
||||
if (!&NSURLQuarantinePropertiesKey) {
|
||||
NSString *const quarantineAttribute = (NSString*)kLSItemQuarantineProperties;
|
||||
const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:root
|
||||
options:removeXAttrOptions];
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:root
|
||||
options:removeXAttrOptions];
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary* rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:root error:nil];
|
||||
NSString* rootType = rootAttributes[NSFileType];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil];
|
||||
NSString *rootType = rootAttributes[NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator* directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:root];
|
||||
NSString* file = nil;
|
||||
while ((file = [directoryEnumerator nextObject])) {
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:[root stringByAppendingPathComponent:file]
|
||||
options:removeXAttrOptions];
|
||||
}
|
||||
}
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtPath:root];
|
||||
NSString *file = nil;
|
||||
while ((file = [directoryEnumerator nextObject])) {
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:[root stringByAppendingPathComponent:file]
|
||||
options:removeXAttrOptions];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
NSURL *rootURL = [NSURL fileURLWithPath:root];
|
||||
[rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil];
|
||||
NSString *rootType = rootAttributes[NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
|
||||
for (NSURL *file in directoryEnumerator) {
|
||||
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+14
-10
@@ -15,21 +15,25 @@
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
|
||||
[self abortUpdate];
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[updaterDelegate updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
NSDictionary *userInfo = (self.updateItem != nil) ? @{ SUUpdaterAppcastItemNotificationKey: self.updateItem } : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:self.updater userInfo:userInfo];
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
|
||||
[self abortUpdate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[updaterDelegate updaterDidNotFindUpdate:self.updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
-4
@@ -13,10 +13,6 @@
|
||||
#import "SUUIBasedUpdateDriver.h"
|
||||
|
||||
@interface SUScheduledUpdateDriver : SUUIBasedUpdateDriver
|
||||
{
|
||||
@private
|
||||
BOOL showErrors;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+21
-11
@@ -13,30 +13,40 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@interface SUScheduledUpdateDriver ()
|
||||
|
||||
@property (assign) BOOL showErrors;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUScheduledUpdateDriver
|
||||
|
||||
@synthesize showErrors;
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
showErrors = YES; // We only start showing errors after we present the UI for the first time.
|
||||
[super didFindValidUpdate];
|
||||
self.showErrors = YES; // We only start showing errors after we present the UI for the first time.
|
||||
[super didFindValidUpdate];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
|
||||
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[updaterDelegate updaterDidNotFindUpdate:self.updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if (showErrors)
|
||||
[super abortUpdateWithError:error];
|
||||
else
|
||||
[self abortUpdate];
|
||||
if (self.showErrors)
|
||||
[super abortUpdateWithError:error];
|
||||
else
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
+11
-11
@@ -17,11 +17,11 @@
|
||||
|
||||
+ (SUStandardVersionComparator *)defaultComparator
|
||||
{
|
||||
static SUStandardVersionComparator *defaultComparator = nil;
|
||||
if (defaultComparator == nil) {
|
||||
defaultComparator = [[SUStandardVersionComparator alloc] init];
|
||||
}
|
||||
return defaultComparator;
|
||||
static SUStandardVersionComparator *defaultComparator = nil;
|
||||
if (defaultComparator == nil) {
|
||||
defaultComparator = [[SUStandardVersionComparator alloc] init];
|
||||
}
|
||||
return defaultComparator;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
@@ -50,13 +50,13 @@ typedef enum {
|
||||
NSString *character;
|
||||
NSMutableString *s;
|
||||
NSUInteger i, n;
|
||||
SUCharacterType oldType, newType;
|
||||
SUCharacterType oldType, newType;
|
||||
NSMutableArray *parts = [NSMutableArray array];
|
||||
if ([version length] == 0) {
|
||||
// Nothing to do here
|
||||
return parts;
|
||||
}
|
||||
s = [[[version substringToIndex:1] mutableCopy] autorelease];
|
||||
s = [[version substringToIndex:1] mutableCopy];
|
||||
oldType = [self typeOfCharacter:s];
|
||||
n = [version length] - 1;
|
||||
for (i = 1; i <= n; ++i) {
|
||||
@@ -64,7 +64,7 @@ typedef enum {
|
||||
newType = [self typeOfCharacter:character];
|
||||
if (oldType != newType || oldType == kSeparatorType) {
|
||||
// We've reached a new segment
|
||||
NSString *aPart = [[[NSString alloc] initWithString:s] autorelease];
|
||||
NSString *aPart = [[NSString alloc] initWithString:s];
|
||||
[parts addObject:aPart];
|
||||
[s setString:character];
|
||||
} else {
|
||||
@@ -81,12 +81,12 @@ typedef enum {
|
||||
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB
|
||||
{
|
||||
NSArray *partsA = [self splitVersionString:versionA];
|
||||
NSArray *partsA = [self splitVersionString:versionA];
|
||||
NSArray *partsB = [self splitVersionString:versionB];
|
||||
|
||||
NSString *partA, *partB;
|
||||
NSUInteger i, n;
|
||||
long long valueA, valueB;
|
||||
long long valueA, valueB;
|
||||
SUCharacterType typeA, typeB;
|
||||
|
||||
n = MIN([partsA count], [partsB count]);
|
||||
@@ -139,7 +139,7 @@ typedef enum {
|
||||
// n holds the index of the part we want.
|
||||
NSString *missingPart;
|
||||
SUCharacterType missingType;
|
||||
NSComparisonResult shorterResult, largerResult;
|
||||
NSComparisonResult shorterResult, largerResult;
|
||||
|
||||
if ([partsA count] > [partsB count]) {
|
||||
missingPart = partsA[n];
|
||||
|
||||
Vendored
+3
-3
@@ -13,13 +13,13 @@
|
||||
|
||||
@class SUHost;
|
||||
@interface SUStatusController : SUWindowController
|
||||
@property (assign) IBOutlet NSButton *actionButton;
|
||||
@property (assign) IBOutlet NSProgressIndicator* progressBar;
|
||||
@property (weak) IBOutlet NSButton *actionButton;
|
||||
@property (weak) IBOutlet NSProgressIndicator *progressBar;
|
||||
|
||||
@property (copy) NSString *statusText;
|
||||
@property double progressValue;
|
||||
@property (nonatomic) double maxProgressValue;
|
||||
@property (getter = isButtonEnabled) BOOL buttonEnabled;
|
||||
@property (getter=isButtonEnabled) BOOL buttonEnabled;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host;
|
||||
|
||||
|
||||
Vendored
+38
-47
@@ -16,7 +16,7 @@
|
||||
|
||||
@interface SUStatusController ()
|
||||
@property (copy) NSString *title, *buttonTitle;
|
||||
@property (retain) SUHost *host;
|
||||
@property (strong) SUHost *host;
|
||||
@end
|
||||
|
||||
@implementation SUStatusController
|
||||
@@ -31,99 +31,90 @@
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
|
||||
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
|
||||
if (self)
|
||||
{
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.host = nil;
|
||||
self.title = nil;
|
||||
self.statusText = nil;
|
||||
self.buttonTitle = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
if ([host isBackgroundApplication]) {
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[[self window] setLevel:NSFloatingWindowLevel];
|
||||
}
|
||||
|
||||
[[self window] center];
|
||||
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||
[[self window] center];
|
||||
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
||||
[self.progressBar setUsesThreadedAnimation:YES];
|
||||
}
|
||||
|
||||
- (NSString *)windowTitle
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"Updating %@", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"Updating %@", nil), [self.host name]];
|
||||
}
|
||||
|
||||
- (NSImage *)applicationIcon
|
||||
{
|
||||
return [host icon];
|
||||
return [self.host icon];
|
||||
}
|
||||
|
||||
- (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText
|
||||
{
|
||||
self.title = aTitle;
|
||||
self.title = aTitle;
|
||||
|
||||
self.maxProgressValue = aMaxProgressValue;
|
||||
self.statusText = aStatusText;
|
||||
self.maxProgressValue = aMaxProgressValue;
|
||||
self.statusText = aStatusText;
|
||||
}
|
||||
|
||||
- (void)setButtonTitle:(NSString *)aButtonTitle target:(id)target action:(SEL)action isDefault:(BOOL)isDefault
|
||||
{
|
||||
self.buttonTitle = aButtonTitle;
|
||||
self.buttonTitle = aButtonTitle;
|
||||
|
||||
[self window];
|
||||
[actionButton sizeToFit];
|
||||
// Except we're going to add 15 px for padding.
|
||||
[actionButton setFrameSize:NSMakeSize([actionButton frame].size.width + 15, [actionButton frame].size.height)];
|
||||
// Now we have to move it over so that it's always 15px from the side of the window.
|
||||
[actionButton setFrameOrigin:NSMakePoint([[self window] frame].size.width - 15 - [actionButton frame].size.width, [actionButton frame].origin.y)];
|
||||
// Redisplay superview to clean up artifacts
|
||||
[[actionButton superview] display];
|
||||
[self window];
|
||||
[self.actionButton sizeToFit];
|
||||
// Except we're going to add 15 px for padding.
|
||||
[self.actionButton setFrameSize:NSMakeSize([self.actionButton frame].size.width + 15, [self.actionButton frame].size.height)];
|
||||
// Now we have to move it over so that it's always 15px from the side of the window.
|
||||
[self.actionButton setFrameOrigin:NSMakePoint([[self window] frame].size.width - 15 - [self.actionButton frame].size.width, [self.actionButton frame].origin.y)];
|
||||
// Redisplay superview to clean up artifacts
|
||||
[[self.actionButton superview] display];
|
||||
|
||||
[actionButton setTarget:target];
|
||||
[actionButton setAction:action];
|
||||
[actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
|
||||
[self.actionButton setTarget:target];
|
||||
[self.actionButton setAction:action];
|
||||
[self.actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
|
||||
|
||||
// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
|
||||
[self setButtonEnabled: (target != nil)];
|
||||
// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
|
||||
[self setButtonEnabled:(target != nil)];
|
||||
}
|
||||
|
||||
- (BOOL)progressBarShouldAnimate
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setButtonEnabled:(BOOL)enabled
|
||||
{
|
||||
[actionButton setEnabled:enabled];
|
||||
[self.actionButton setEnabled:enabled];
|
||||
}
|
||||
|
||||
- (BOOL)isButtonEnabled
|
||||
{
|
||||
return [actionButton isEnabled];
|
||||
return [self.actionButton isEnabled];
|
||||
}
|
||||
|
||||
- (void)setMaxProgressValue:(double)value
|
||||
{
|
||||
if (value < 0.0) value = 0.0;
|
||||
maxProgressValue = value;
|
||||
[self setProgressValue:0.0];
|
||||
[progressBar setIndeterminate:(value == 0.0)];
|
||||
[progressBar startAnimation:self];
|
||||
[progressBar setUsesThreadedAnimation: YES];
|
||||
maxProgressValue = value;
|
||||
[self setProgressValue:0.0];
|
||||
[self.progressBar setIndeterminate:(value == 0.0)];
|
||||
[self.progressBar startAnimation:self];
|
||||
[self.progressBar setUsesThreadedAnimation:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+109
-109
@@ -15,142 +15,142 @@
|
||||
@implementation SUSystemProfiler
|
||||
+ (SUSystemProfiler *)sharedSystemProfiler
|
||||
{
|
||||
static SUSystemProfiler *sharedSystemProfiler = nil;
|
||||
if (!sharedSystemProfiler) {
|
||||
sharedSystemProfiler = [[self alloc] init];
|
||||
}
|
||||
return sharedSystemProfiler;
|
||||
static SUSystemProfiler *sharedSystemProfiler = nil;
|
||||
if (!sharedSystemProfiler) {
|
||||
sharedSystemProfiler = [[self alloc] init];
|
||||
}
|
||||
return sharedSystemProfiler;
|
||||
}
|
||||
|
||||
- (NSDictionary *)modelTranslationTable
|
||||
{
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
|
||||
return [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease];
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
|
||||
return [[NSDictionary alloc] initWithContentsOfFile:path];
|
||||
}
|
||||
|
||||
- (NSMutableArray *)systemProfileArrayForHost:(SUHost *)host
|
||||
{
|
||||
NSDictionary *modelTranslation = [self modelTranslationTable];
|
||||
NSDictionary *modelTranslation = [self modelTranslationTable];
|
||||
|
||||
// Gather profile information and append it to the URL.
|
||||
NSMutableArray *profileArray = [NSMutableArray array];
|
||||
NSArray *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"];
|
||||
int error = 0;
|
||||
int value = 0;
|
||||
size_t length = sizeof(value);
|
||||
// Gather profile information and append it to the URL.
|
||||
NSMutableArray *profileArray = [NSMutableArray array];
|
||||
NSArray *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"];
|
||||
int error = 0;
|
||||
int value = 0;
|
||||
size_t length = sizeof(value);
|
||||
|
||||
// OS version
|
||||
NSString *currentSystemVersion = [SUHost systemVersionString];
|
||||
if (currentSystemVersion != nil) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion] forKeys:profileDictKeys]];
|
||||
}
|
||||
// OS version
|
||||
NSString *currentSystemVersion = [SUHost systemVersionString];
|
||||
if (currentSystemVersion != nil) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"osVersion", @"OS Version", currentSystemVersion, currentSystemVersion] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// CPU type (decoder info for values found here is in mach/machine.h)
|
||||
error = sysctlbyname("hw.cputype", &value, &length, NULL, 0);
|
||||
int cpuType = -1;
|
||||
if (error == 0) {
|
||||
cpuType = value;
|
||||
NSString *visibleCPUType;
|
||||
switch(value) {
|
||||
// CPU type (decoder info for values found here is in mach/machine.h)
|
||||
error = sysctlbyname("hw.cputype", &value, &length, NULL, 0);
|
||||
int cpuType = -1;
|
||||
if (error == 0) {
|
||||
cpuType = value;
|
||||
NSString *visibleCPUType;
|
||||
switch (value) {
|
||||
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
|
||||
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
|
||||
default: visibleCPUType = @"Unknown"; break;
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cputype",@"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.cpu64bit_capable", &value, &length, NULL, 0);
|
||||
if (error != 0) {
|
||||
error = sysctlbyname("hw.optional.x86_64", &value, &length, NULL, 0); //x86 specific
|
||||
}
|
||||
if (error != 0) {
|
||||
error = sysctlbyname("hw.optional.64bitops", &value, &length, NULL, 0); //PPC specific
|
||||
}
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cputype", @"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.cpu64bit_capable", &value, &length, NULL, 0);
|
||||
if (error != 0) {
|
||||
error = sysctlbyname("hw.optional.x86_64", &value, &length, NULL, 0); //x86 specific
|
||||
}
|
||||
if (error != 0) {
|
||||
error = sysctlbyname("hw.optional.64bitops", &value, &length, NULL, 0); //PPC specific
|
||||
}
|
||||
|
||||
BOOL is64bit = NO;
|
||||
BOOL is64bit = NO;
|
||||
|
||||
if (error == 0) {
|
||||
is64bit = value == 1;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpu64bit", @"CPU is 64-Bit?", @(is64bit), is64bit ? @"Yes" : @"No"] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.cpusubtype", &value, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *visibleCPUSubType;
|
||||
if (cpuType == 7) {
|
||||
// Intel
|
||||
// TODO: other Intel processors, like Core i7, i5, i3, Xeon?
|
||||
visibleCPUSubType = is64bit ? @"Intel Core 2" : @"Intel Core"; // If anyone knows how to tell a Core Duo from a Core Solo, please email tph@atomicbird.com
|
||||
} else if (cpuType == 18) {
|
||||
// PowerPC
|
||||
switch(value) {
|
||||
if (error == 0) {
|
||||
is64bit = value == 1;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpu64bit", @"CPU is 64-Bit?", @(is64bit), is64bit ? @"Yes" : @"No"] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.cpusubtype", &value, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *visibleCPUSubType;
|
||||
if (cpuType == 7) {
|
||||
// Intel
|
||||
// TODO: other Intel processors, like Core i7, i5, i3, Xeon?
|
||||
visibleCPUSubType = is64bit ? @"Intel Core 2" : @"Intel Core"; // If anyone knows how to tell a Core Duo from a Core Solo, please email tph@atomicbird.com
|
||||
} else if (cpuType == 18) {
|
||||
// PowerPC
|
||||
switch (value) {
|
||||
case 9: visibleCPUSubType=@"G3"; break;
|
||||
case 10: case 11: visibleCPUSubType=@"G4"; break;
|
||||
case 100: visibleCPUSubType=@"G5"; break;
|
||||
default: visibleCPUSubType=@"Other"; break;
|
||||
}
|
||||
} else {
|
||||
visibleCPUSubType = @"Other";
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpusubtype",@"CPU Subtype", @(value), visibleCPUSubType] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.model", NULL, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
char *cpuModel = (char *)malloc(sizeof(char) * length);
|
||||
if (cpuModel != NULL) {
|
||||
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *rawModelName = @(cpuModel);
|
||||
NSString *visibleModelName = modelTranslation[rawModelName];
|
||||
if (visibleModelName == nil) {
|
||||
visibleModelName = rawModelName;
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"model",@"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]];
|
||||
}
|
||||
free(cpuModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
visibleCPUSubType = @"Other";
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpusubtype", @"CPU Subtype", @(value), visibleCPUSubType] forKeys:profileDictKeys]];
|
||||
}
|
||||
error = sysctlbyname("hw.model", NULL, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
char *cpuModel = (char *)malloc(sizeof(char) * length);
|
||||
if (cpuModel != NULL) {
|
||||
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *rawModelName = @(cpuModel);
|
||||
NSString *visibleModelName = modelTranslation[rawModelName];
|
||||
if (visibleModelName == nil) {
|
||||
visibleModelName = rawModelName;
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"model", @"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]];
|
||||
}
|
||||
free(cpuModel);
|
||||
}
|
||||
}
|
||||
|
||||
// Number of CPUs
|
||||
error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ncpu",@"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]];
|
||||
}
|
||||
// Number of CPUs
|
||||
error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ncpu", @"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// User preferred language
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
|
||||
if ([languages count] > 0) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"lang",@"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
|
||||
}
|
||||
// User preferred language
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
|
||||
if ([languages count] > 0) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"lang", @"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// Application sending the request
|
||||
NSString *appName = [host name];
|
||||
if (appName) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appName",@"Application Name", appName, appName] forKeys:profileDictKeys]];
|
||||
}
|
||||
NSString *appVersion = [host version];
|
||||
if (appVersion) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appVersion",@"Application Version", appVersion, appVersion] forKeys:profileDictKeys]];
|
||||
}
|
||||
// Application sending the request
|
||||
NSString *appName = [host name];
|
||||
if (appName) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appName", @"Application Name", appName, appName] forKeys:profileDictKeys]];
|
||||
}
|
||||
NSString *appVersion = [host version];
|
||||
if (appVersion) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appVersion", @"Application Version", appVersion, appVersion] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// Number of displays?
|
||||
// Number of displays?
|
||||
|
||||
// CPU speed
|
||||
unsigned long hz;
|
||||
size_t hz_size = sizeof(unsigned long);
|
||||
if (sysctlbyname("hw.cpufrequency", &hz, &hz_size, NULL, 0) == 0) {
|
||||
unsigned long mhz = hz / 1000000;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpuFreqMHz",@"CPU Speed (GHz)", @(mhz), @(mhz / 1000.)] forKeys:profileDictKeys]];
|
||||
}
|
||||
// CPU speed
|
||||
unsigned long hz;
|
||||
size_t hz_size = sizeof(unsigned long);
|
||||
if (sysctlbyname("hw.cpufrequency", &hz, &hz_size, NULL, 0) == 0) {
|
||||
unsigned long mhz = hz / 1000000;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpuFreqMHz", @"CPU Speed (GHz)", @(mhz), @(mhz / 1000.)] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// amount of RAM
|
||||
unsigned long bytes;
|
||||
size_t bytes_size = sizeof(unsigned long);
|
||||
if (sysctlbyname("hw.memsize", &bytes, &bytes_size, NULL, 0) == 0) {
|
||||
double megabytes = bytes / (1024.*1024.);
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ramMB",@"Memory (MB)", @(megabytes), @(megabytes)] forKeys:profileDictKeys]];
|
||||
}
|
||||
// amount of RAM
|
||||
unsigned long bytes;
|
||||
size_t bytes_size = sizeof(unsigned long);
|
||||
if (sysctlbyname("hw.memsize", &bytes, &bytes_size, NULL, 0) == 0) {
|
||||
double megabytes = bytes / (1024. * 1024.);
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ramMB", @"Memory (MB)", @(megabytes), @(megabytes)] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
return profileArray;
|
||||
return profileArray;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+2
-6
@@ -16,14 +16,10 @@
|
||||
@class SUStatusController;
|
||||
|
||||
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUUpdateAlertDelegate>
|
||||
{
|
||||
SUStatusController *statusController;
|
||||
SUUpdateAlert *updateAlert;
|
||||
}
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert;
|
||||
- (IBAction)cancelDownload: (id)sender;
|
||||
- (void)installAndRestart: (id)sender;
|
||||
- (IBAction)cancelDownload:(id)sender;
|
||||
- (void)installAndRestart:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+142
-127
@@ -14,212 +14,227 @@
|
||||
#import "SUStatusController.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
@interface SUUIBasedUpdateDriver ()
|
||||
|
||||
@property (strong) SUStatusController *statusController;
|
||||
@property (strong) SUUpdateAlert *updateAlert;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUIBasedUpdateDriver
|
||||
|
||||
@synthesize statusController;
|
||||
@synthesize updateAlert;
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:host];
|
||||
[updateAlert setDelegate:self];
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host];
|
||||
[self.updateAlert setDelegate:self];
|
||||
|
||||
id<SUVersionDisplay> versDisp = nil;
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
|
||||
versDisp = [[updater delegate] versionDisplayerForUpdater: updater];
|
||||
}
|
||||
[updateAlert setVersionDisplayer: versDisp];
|
||||
id<SUVersionDisplay> versDisp = nil;
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
|
||||
versDisp = [[self.updater delegate] versionDisplayerForUpdater:self.updater];
|
||||
}
|
||||
[self.updateAlert setVersionDisplayer:versDisp];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
}
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([self.host isBackgroundApplication])
|
||||
{
|
||||
[[updateAlert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
[[self.updateAlert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
|
||||
if ([NSApp isActive])
|
||||
[[updateAlert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
|
||||
if ([NSApp isActive])
|
||||
[[self.updateAlert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [host name], [host displayVersion]];
|
||||
[self showModalAlert:alert];
|
||||
[self abortUpdate];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.")
|
||||
defaultButton:SULocalizedString(@"OK", nil)
|
||||
alternateButton:nil
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[self showModalAlert:alert];
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *) __unused aNotification
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
{
|
||||
[[updateAlert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[self.updateAlert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
}
|
||||
|
||||
- (void)updateAlert:(SUUpdateAlert *) __unused alert finishedWithChoice:(SUUpdateAlertChoice)choice
|
||||
- (void)updateAlert:(SUUpdateAlert *)__unused alert finishedWithChoice:(SUUpdateAlertChoice)choice
|
||||
{
|
||||
[updateAlert release]; updateAlert = nil;
|
||||
[host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
self.updateAlert = nil;
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice)
|
||||
{
|
||||
case SUInstallUpdateChoice:
|
||||
statusController = [[SUStatusController alloc] initWithHost:host];
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
[statusController showWindow:self];
|
||||
[self downloadUpdate];
|
||||
break;
|
||||
case SUInstallUpdateChoice:
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
[self.statusController showWindow:self];
|
||||
[self downloadUpdate];
|
||||
break;
|
||||
|
||||
case SUOpenInfoURLChoice:
|
||||
[[NSWorkspace sharedWorkspace] openURL: [updateItem infoURL]];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
case SUOpenInfoURLChoice:
|
||||
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem infoURL]];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SUSkipThisVersionChoice:
|
||||
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
case SUSkipThisVersionChoice:
|
||||
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SURemindMeLaterChoice:
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
case SURemindMeLaterChoice:
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused download didReceiveResponse:(NSURLResponse *)response
|
||||
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
[statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
[self.statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
}
|
||||
|
||||
- (NSString *)humanReadableSizeFromDouble:(double)value
|
||||
{
|
||||
if (value < 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
|
||||
}
|
||||
if (value < 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
}
|
||||
if (value < 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
}
|
||||
if (value < 1000 * 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused download didReceiveDataOfLength:(NSUInteger)length
|
||||
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
|
||||
{
|
||||
[statusController setProgressValue:[statusController progressValue] + (double)length];
|
||||
if ([statusController maxProgressValue] > 0.0)
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[statusController progressValue]], [self humanReadableSizeFromDouble:[statusController maxProgressValue]]]];
|
||||
else
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[statusController progressValue]]]];
|
||||
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
|
||||
if ([self.statusController maxProgressValue] > 0.0)
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]], [self humanReadableSizeFromDouble:[self.statusController maxProgressValue]]]];
|
||||
else
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]]]];
|
||||
}
|
||||
|
||||
- (IBAction)cancelDownload:(id) __unused sender
|
||||
- (IBAction)cancelDownload:(id)__unused sender
|
||||
{
|
||||
if (download)
|
||||
[download cancel];
|
||||
[self abortUpdate];
|
||||
if (self.download)
|
||||
[self.download cancel];
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
// Now we have to extract the downloaded archive.
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonEnabled:NO];
|
||||
[super extractUpdate];
|
||||
// Now we have to extract the downloaded archive.
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
[super extractUpdate];
|
||||
}
|
||||
|
||||
- (void)unarchiver:(SUUnarchiver *) __unused ua extractedLength:(unsigned long)length
|
||||
- (void)unarchiver:(SUUnarchiver *)__unused ua extractedLength:(unsigned long)length
|
||||
{
|
||||
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
|
||||
if ([statusController maxProgressValue] == 0.0)
|
||||
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
|
||||
if ([self.statusController maxProgressValue] == 0.0)
|
||||
{
|
||||
NSDictionary * attributes;
|
||||
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil];
|
||||
[statusController setMaxProgressValue:[attributes[NSFileSize] doubleValue]];
|
||||
}
|
||||
[statusController setProgressValue:[statusController progressValue] + (double)length];
|
||||
NSDictionary *attributes;
|
||||
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.downloadPath error:nil];
|
||||
[self.statusController setMaxProgressValue:[attributes[NSFileSize] doubleValue]];
|
||||
}
|
||||
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *) __unused ua
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
|
||||
[statusController setProgressValue:1.0]; // Fill the bar.
|
||||
[statusController setButtonEnabled:YES];
|
||||
[statusController setButtonTitle:SULocalizedString(@"Install and Relaunch", nil) target:self action:@selector(installAndRestart:) isDefault:YES];
|
||||
[[statusController window] makeKeyAndOrderFront: self];
|
||||
[NSApp requestUserAttention:NSInformationalRequest];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
|
||||
[self.statusController setProgressValue:1.0]; // Fill the bar.
|
||||
[self.statusController setButtonEnabled:YES];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Install and Relaunch", nil) target:self action:@selector(installAndRestart:) isDefault:YES];
|
||||
[[self.statusController window] makeKeyAndOrderFront:self];
|
||||
[NSApp requestUserAttention:NSInformationalRequest];
|
||||
}
|
||||
|
||||
- (void)installAndRestart:(id) __unused sender
|
||||
- (void)installAndRestart:(id)__unused sender
|
||||
{
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonEnabled:NO];
|
||||
[super installWithToolAndRelaunch:relaunch];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonEnabled:NO];
|
||||
[super installWithToolAndRelaunch:relaunch];
|
||||
}
|
||||
|
||||
- (void)terminateApp
|
||||
{
|
||||
// if a user chooses to NOT relaunch the app (as is the case with WebKit
|
||||
// when it asks you if you are sure you want to close the app with multiple
|
||||
// tabs open), the status window still stays on the screen and obscures
|
||||
// other windows; with this fix, it doesn't
|
||||
|
||||
// if a user chooses to NOT relaunch the app (as is the case with WebKit
|
||||
// when it asks you if you are sure you want to close the app with multiple
|
||||
// tabs open), the status window still stays on the screen and obscures
|
||||
// other windows; with this fix, it doesn't
|
||||
if (self.statusController) {
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
}
|
||||
|
||||
if (statusController)
|
||||
{
|
||||
[statusController close];
|
||||
[statusController autorelease];
|
||||
statusController = nil;
|
||||
}
|
||||
[super terminateApp];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat: @"%@", [error localizedDescription]];
|
||||
[self showModalAlert:alert];
|
||||
[super abortUpdateWithError:error];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", [error localizedDescription]];
|
||||
[self showModalAlert:alert];
|
||||
[super abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
if (statusController)
|
||||
if (self.statusController)
|
||||
{
|
||||
[statusController close];
|
||||
[statusController autorelease];
|
||||
statusController = nil;
|
||||
}
|
||||
[super abortUpdate];
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
}
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
|
||||
[[updater delegate] updaterWillShowModalAlert: updater];
|
||||
}
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
|
||||
[[self.updater delegate] updaterWillShowModalAlert:self.updater];
|
||||
}
|
||||
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([self.host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
[alert setIcon:[host icon]];
|
||||
[alert runModal];
|
||||
[alert setIcon:[self.host icon]];
|
||||
[alert runModal];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
|
||||
[[updater delegate] updaterDidShowModalAlert: updater];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
|
||||
[[self.updater delegate] updaterDidShowModalAlert:self.updater];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+5
-6
@@ -12,12 +12,11 @@
|
||||
@class SUHost;
|
||||
@protocol SUUnarchiverDelegate;
|
||||
|
||||
@interface SUUnarchiver : NSObject {
|
||||
id<SUUnarchiverDelegate> delegate;
|
||||
NSString *archivePath;
|
||||
SUHost *updateHost;
|
||||
}
|
||||
@property (assign) id<SUUnarchiverDelegate> delegate;
|
||||
@interface SUUnarchiver : NSObject
|
||||
|
||||
@property (copy, readonly) NSString *archivePath;
|
||||
@property (weak, readonly) SUHost *updateHost;
|
||||
@property (weak) id<SUUnarchiverDelegate> delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
|
||||
|
||||
|
||||
Vendored
+61
-7
@@ -16,24 +16,78 @@
|
||||
#import "SUUnarchiver_Private.h"
|
||||
|
||||
@implementation SUUnarchiver
|
||||
|
||||
@synthesize archivePath;
|
||||
@synthesize updateHost;
|
||||
@synthesize delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
|
||||
{
|
||||
for (id current in [self unarchiverImplementations])
|
||||
{
|
||||
if ([current canUnarchivePath:path]) {
|
||||
return [[[current alloc] initWithPath:path host:host] autorelease];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
if ([current canUnarchivePath:path]) {
|
||||
return [[current alloc] initWithPath:path host:host];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
|
||||
- (void)start
|
||||
{
|
||||
// No-op
|
||||
// No-op
|
||||
}
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
archivePath = [path copy];
|
||||
updateHost = host;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)__unused path
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfExtractedLength:(size_t)length
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
|
||||
[self.delegate unarchiver:self extractedLength:length];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfSuccess
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(unarchiverDidFinish:)]) {
|
||||
[self.delegate unarchiverDidFinish:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfFailure
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(unarchiverDidFail:)]) {
|
||||
[self.delegate unarchiverDidFail:self];
|
||||
}
|
||||
}
|
||||
|
||||
static NSMutableArray *gUnarchiverImplementations;
|
||||
|
||||
+ (void)registerImplementation:(Class)implementation
|
||||
{
|
||||
if (!gUnarchiverImplementations) {
|
||||
gUnarchiverImplementations = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[gUnarchiverImplementations addObject:implementation];
|
||||
}
|
||||
|
||||
+ (NSArray *)unarchiverImplementations
|
||||
{
|
||||
return [NSArray arrayWithArray:gUnarchiverImplementations];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
-72
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// SUUnarchiver_Private.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 6/17/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
@implementation SUUnarchiver (Private)
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
archivePath = [path copy];
|
||||
updateHost = [host retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[archivePath release];
|
||||
[updateHost release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *) __unused path
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfExtractedLength:(size_t)length
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
|
||||
[delegate unarchiver:self extractedLength:length];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfSuccess
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) {
|
||||
[delegate unarchiverDidFinish:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfFailure
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) {
|
||||
[delegate unarchiverDidFail:self];
|
||||
}
|
||||
}
|
||||
|
||||
static NSMutableArray *gUnarchiverImplementations;
|
||||
|
||||
+ (void)registerImplementation:(Class)implementation
|
||||
{
|
||||
if (!gUnarchiverImplementations) {
|
||||
gUnarchiverImplementations = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[gUnarchiverImplementations addObject:implementation];
|
||||
}
|
||||
|
||||
+ (NSArray *)unarchiverImplementations
|
||||
{
|
||||
return [NSArray arrayWithArray:gUnarchiverImplementations];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+8
-18
@@ -16,27 +16,17 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUInstallUpdateChoice,
|
||||
SURemindMeLaterChoice,
|
||||
SUSkipThisVersionChoice,
|
||||
SUOpenInfoURLChoice
|
||||
SUInstallUpdateChoice,
|
||||
SURemindMeLaterChoice,
|
||||
SUSkipThisVersionChoice,
|
||||
SUOpenInfoURLChoice
|
||||
} SUUpdateAlertChoice;
|
||||
|
||||
@class WebView, SUAppcastItem, SUHost;
|
||||
@interface SUUpdateAlert : SUWindowController {
|
||||
SUAppcastItem *updateItem;
|
||||
SUHost *host;
|
||||
@interface SUUpdateAlert : SUWindowController
|
||||
|
||||
IBOutlet WebView *releaseNotesView;
|
||||
IBOutlet NSTextField *description;
|
||||
IBOutlet NSButton *installButton; // UK 2007-08-31.
|
||||
IBOutlet NSButton *skipButton;
|
||||
IBOutlet NSButton *laterButton;
|
||||
NSProgressIndicator *releaseNotesSpinner;
|
||||
BOOL webViewFinishedLoading;
|
||||
}
|
||||
@property (assign) id<SUUpdateAlertDelegate> delegate;
|
||||
@property (assign) id<SUVersionDisplay> versionDisplayer;
|
||||
@property (weak) id<SUUpdateAlertDelegate> delegate;
|
||||
@property (weak) id<SUVersionDisplay> versionDisplayer;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
|
||||
|
||||
@@ -49,7 +39,7 @@ typedef enum
|
||||
@protocol SUUpdateAlertDelegate <NSObject>
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
|
||||
@optional
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate: (BOOL*)shouldAllowAutoUpdate;
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate:(BOOL *)shouldAllowAutoUpdate;
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
+136
-209
@@ -17,259 +17,186 @@
|
||||
|
||||
#import "SUConstants.h"
|
||||
|
||||
@interface SUUpdateAlert ()
|
||||
|
||||
@interface WebView ()
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) SUHost *host;
|
||||
|
||||
-(void) setDrawsBackground: (BOOL)state;
|
||||
@property (strong) NSProgressIndicator *releaseNotesSpinner;
|
||||
@property (assign) BOOL webViewFinishedLoading;
|
||||
|
||||
@property (weak) IBOutlet WebView *releaseNotesView;
|
||||
@property (weak) IBOutlet NSView *releaseNotesContainerView;
|
||||
@property (weak) IBOutlet NSTextField *descriptionField;
|
||||
@property (weak) IBOutlet NSButton *installButton;
|
||||
@property (weak) IBOutlet NSButton *skipButton;
|
||||
@property (weak) IBOutlet NSButton *laterButton;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation SUUpdateAlert
|
||||
|
||||
@synthesize delegate;
|
||||
@synthesize versionDisplayer;
|
||||
|
||||
@synthesize updateItem;
|
||||
@synthesize host;
|
||||
|
||||
@synthesize releaseNotesSpinner;
|
||||
@synthesize webViewFinishedLoading;
|
||||
|
||||
@synthesize releaseNotesView;
|
||||
@synthesize releaseNotesContainerView;
|
||||
@synthesize descriptionField;
|
||||
@synthesize installButton;
|
||||
@synthesize skipButton;
|
||||
@synthesize laterButton;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost
|
||||
{
|
||||
self = [super initWithHost:host windowNibName:@"SUUpdateAlert"];
|
||||
self = [super initWithHost:host windowNibName:@"SUUpdateAlert"];
|
||||
if (self)
|
||||
{
|
||||
host = [aHost retain];
|
||||
updateItem = [item retain];
|
||||
[self setShouldCascadeWindows:NO];
|
||||
host = aHost;
|
||||
updateItem = item;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
|
||||
// Alex: This dummy line makes sure that the binary is linked against WebKit.
|
||||
// The SUUpdateAlert.xib file contains a WebView and if we don't link against WebKit,
|
||||
// we will get a runtime crash when decoding the NIB. It is better to get a link error.
|
||||
[WebView MIMETypesShownAsHTML];
|
||||
}
|
||||
return self;
|
||||
// Alex: This dummy line makes sure that the binary is linked against WebKit.
|
||||
// The SUUpdateAlert.xib file contains a WebView and if we don't link against WebKit,
|
||||
// we will get a runtime crash when decoding the NIB. It is better to get a link error.
|
||||
[WebView MIMETypesShownAsHTML];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[updateItem release];
|
||||
[host release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)endWithSelection:(SUUpdateAlertChoice)choice
|
||||
{
|
||||
[releaseNotesView stopLoading:self];
|
||||
[releaseNotesView setFrameLoadDelegate:nil];
|
||||
[releaseNotesView setPolicyDelegate:nil];
|
||||
[releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
|
||||
[self close];
|
||||
if ([delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
|
||||
[delegate updateAlert:self finishedWithChoice:choice];
|
||||
[self.releaseNotesView stopLoading:self];
|
||||
[self.releaseNotesView setFrameLoadDelegate:nil];
|
||||
[self.releaseNotesView setPolicyDelegate:nil];
|
||||
[self.releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
|
||||
[self close];
|
||||
if ([self.delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
|
||||
[self.delegate updateAlert:self finishedWithChoice:choice];
|
||||
}
|
||||
|
||||
- (IBAction)installUpdate:(id) __unused sender
|
||||
- (IBAction)installUpdate:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SUInstallUpdateChoice];
|
||||
[self endWithSelection:SUInstallUpdateChoice];
|
||||
}
|
||||
|
||||
- (IBAction)openInfoURL:(id) __unused sender
|
||||
- (IBAction)openInfoURL:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SUOpenInfoURLChoice];
|
||||
[self endWithSelection:SUOpenInfoURLChoice];
|
||||
}
|
||||
|
||||
- (IBAction)skipThisVersion:(id) __unused sender
|
||||
- (IBAction)skipThisVersion:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SUSkipThisVersionChoice];
|
||||
[self endWithSelection:SUSkipThisVersionChoice];
|
||||
}
|
||||
|
||||
- (IBAction)remindMeLater:(id) __unused sender
|
||||
- (IBAction)remindMeLater:(id)__unused sender
|
||||
{
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
}
|
||||
|
||||
- (void)displayReleaseNotes
|
||||
{
|
||||
// Set the default font
|
||||
[releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
|
||||
WebPreferences *prefs = [releaseNotesView preferences];
|
||||
// Set the default font
|
||||
[self.releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
|
||||
WebPreferences *prefs = [self.releaseNotesView preferences];
|
||||
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
|
||||
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
|
||||
familyName = @"Lucida Grande";
|
||||
}
|
||||
[prefs setStandardFontFamily:familyName];
|
||||
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
|
||||
[prefs setStandardFontFamily:familyName];
|
||||
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
|
||||
[prefs setPlugInsEnabled:NO];
|
||||
[releaseNotesView setFrameLoadDelegate:self];
|
||||
[releaseNotesView setPolicyDelegate:self];
|
||||
[self.releaseNotesView setFrameLoadDelegate:self];
|
||||
[self.releaseNotesView setPolicyDelegate:self];
|
||||
|
||||
// Stick a nice big spinner in the middle of the web view until the page is loaded.
|
||||
NSRect frame = [[releaseNotesView superview] frame];
|
||||
releaseNotesSpinner = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)] autorelease];
|
||||
[releaseNotesSpinner setStyle:NSProgressIndicatorSpinningStyle];
|
||||
[releaseNotesSpinner startAnimation:self];
|
||||
webViewFinishedLoading = NO;
|
||||
[[releaseNotesView superview] addSubview:releaseNotesSpinner];
|
||||
// Stick a nice big spinner in the middle of the web view until the page is loaded.
|
||||
NSRect frame = [[self.releaseNotesView superview] frame];
|
||||
self.releaseNotesSpinner = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame) - 16, NSMidY(frame) - 16, 32, 32)];
|
||||
[self.releaseNotesSpinner setStyle:NSProgressIndicatorSpinningStyle];
|
||||
[self.releaseNotesSpinner startAnimation:self];
|
||||
self.webViewFinishedLoading = NO;
|
||||
[[self.releaseNotesView superview] addSubview:self.releaseNotesSpinner];
|
||||
|
||||
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
|
||||
if ([updateItem releaseNotesURL])
|
||||
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
|
||||
if ([self.updateItem releaseNotesURL])
|
||||
{
|
||||
if ([[updateItem releaseNotesURL] isFileURL])
|
||||
if ([[self.updateItem releaseNotesURL] isFileURL])
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons—Javascript would be able to read files on your file system." baseURL:nil];
|
||||
[[self.releaseNotesView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons—Javascript would be able to read files on your file system." baseURL:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
}
|
||||
[[self.releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadHTMLString:[updateItem itemDescription] baseURL:nil];
|
||||
}
|
||||
[[self.releaseNotesView mainFrame] loadHTMLString:[self.updateItem itemDescription] baseURL:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)showsReleaseNotes
|
||||
{
|
||||
NSNumber *shouldShowReleaseNotes = [host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
|
||||
NSNumber *shouldShowReleaseNotes = [self.host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
|
||||
if (shouldShowReleaseNotes == nil)
|
||||
{
|
||||
// UK 2007-09-18: Don't show release notes if RSS item contains no description and no release notes URL:
|
||||
return( ([updateItem itemDescription] != nil
|
||||
&& [[[updateItem itemDescription] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|
||||
|| [updateItem releaseNotesURL] != nil );
|
||||
// Don't show release notes if RSS item contains no description and no release notes URL:
|
||||
return (([self.updateItem itemDescription] != nil
|
||||
&& [[[self.updateItem itemDescription] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|
||||
|| [self.updateItem releaseNotesURL] != nil);
|
||||
}
|
||||
else
|
||||
return [shouldShowReleaseNotes boolValue];
|
||||
return [shouldShowReleaseNotes boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
BOOL allowAutoUpdates = YES; // Defaults to YES.
|
||||
if( [host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] )
|
||||
allowAutoUpdates = [host boolForInfoDictionaryKey: SUAllowsAutomaticUpdatesKey];
|
||||
BOOL allowAutoUpdates = YES; // Defaults to YES.
|
||||
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey])
|
||||
allowAutoUpdates = [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
|
||||
|
||||
// UK 2007-08-31: Give delegate a chance to modify this choice:
|
||||
if( delegate && [delegate respondsToSelector: @selector(updateAlert:shouldAllowAutoUpdate:)] )
|
||||
[delegate updateAlert: self shouldAllowAutoUpdate: &allowAutoUpdates];
|
||||
// Give delegate a chance to modify this choice:
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(updateAlert:shouldAllowAutoUpdate:)])
|
||||
[self.delegate updateAlert:self shouldAllowAutoUpdate:&allowAutoUpdates];
|
||||
|
||||
return allowAutoUpdates;
|
||||
return allowAutoUpdates;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
NSString* sizeStr = [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey];
|
||||
BOOL showReleaseNotes = [self showsReleaseNotes];
|
||||
|
||||
if ([host isBackgroundApplication]) {
|
||||
[[self window] setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! UK 2007-09-04
|
||||
}
|
||||
[[self window] setFrameAutosaveName: sizeStr ? @"" : @"SUUpdateAlertFrame"];
|
||||
[self.window setFrameAutosaveName: showReleaseNotes ? @"SUUpdateAlert" : @"SUUpdateAlertSmall" ];
|
||||
|
||||
// We're gonna do some frame magic to match the window's size to the description field and the presence of the release notes view.
|
||||
NSRect frame = [[self window] frame];
|
||||
BOOL showReleaseNotes = [self showsReleaseNotes]; // UK 2007-09-18
|
||||
if (!showReleaseNotes) // UK 2007-09-18
|
||||
{
|
||||
// Resize the window to be appropriate for not having a huge release notes view.
|
||||
frame.size.height -= [releaseNotesView frame].size.height + 40; // Extra 40 is for the release notes label and margin.
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[self.window setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?!
|
||||
}
|
||||
|
||||
if ([self allowsAutomaticUpdates]) {
|
||||
frame.size.height += 10; // Make room for the check box.
|
||||
}
|
||||
if ([self.updateItem fileURL] == nil) {
|
||||
[self.installButton setTitle:SULocalizedString(@"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed.")];
|
||||
[self.installButton setAction:@selector(openInfoURL:)];
|
||||
}
|
||||
|
||||
// Hiding the resize handles is not enough on 10.5, you can still click
|
||||
// where they would be, so we set the min/max sizes to be equal to
|
||||
// inhibit resizing completely:
|
||||
[[self window] setShowsResizeIndicator: NO];
|
||||
[[self window] setMinSize: frame.size];
|
||||
[[self window] setMaxSize: frame.size];
|
||||
}
|
||||
else if (![self allowsAutomaticUpdates])
|
||||
{
|
||||
NSRect boxFrame = [[[releaseNotesView superview] superview] frame];
|
||||
boxFrame.origin.y -= 20;
|
||||
boxFrame.size.height += 20;
|
||||
[[[releaseNotesView superview] superview] setFrame:boxFrame];
|
||||
}
|
||||
if (showReleaseNotes) {
|
||||
[self displayReleaseNotes];
|
||||
} else {
|
||||
[self.releaseNotesContainerView removeFromSuperview];
|
||||
}
|
||||
|
||||
if( [updateItem fileURL] == nil ) // UK 2007-08-31 (whole if clause)
|
||||
{
|
||||
[installButton setTitle: SULocalizedString( @"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed." )];
|
||||
[installButton setAction: @selector(openInfoURL:)];
|
||||
}
|
||||
|
||||
// Make sure button widths are OK:
|
||||
#define DISTANCE_BETWEEN_BUTTONS 3
|
||||
#define DISTANCE_BETWEEN_BUTTON_GROUPS 12
|
||||
|
||||
CGFloat minimumWindowWidth = [[self window] frame].size.width -NSMaxX([installButton frame]) +NSMinX([skipButton frame]); // Distance between contents and left/right edge.
|
||||
NSDictionary* attrs = @{NSFontAttributeName: [installButton font]};
|
||||
NSSize titleSize = [[installButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect installBtnBox = [installButton frame];
|
||||
installBtnBox.origin.x += installBtnBox.size.width -titleSize.width;
|
||||
installBtnBox.size.width = titleSize.width;
|
||||
[installButton setFrame: installBtnBox];
|
||||
minimumWindowWidth += titleSize.width;
|
||||
|
||||
titleSize = [[laterButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect laterBtnBox = [installButton frame];
|
||||
laterBtnBox.origin.x = installBtnBox.origin.x -DISTANCE_BETWEEN_BUTTONS -titleSize.width;
|
||||
laterBtnBox.size.width = titleSize.width;
|
||||
[laterButton setFrame: laterBtnBox];
|
||||
minimumWindowWidth += DISTANCE_BETWEEN_BUTTONS +titleSize.width;
|
||||
|
||||
titleSize = [[skipButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect skipBtnBox = [skipButton frame];
|
||||
skipBtnBox.size.width = titleSize.width;
|
||||
[skipButton setFrame: skipBtnBox];
|
||||
minimumWindowWidth += DISTANCE_BETWEEN_BUTTON_GROUPS +titleSize.width;
|
||||
|
||||
if( showReleaseNotes ) // UK 2007-09-18 (whole block)
|
||||
{
|
||||
if( sizeStr )
|
||||
{
|
||||
NSSize desiredSize = NSSizeFromString( sizeStr );
|
||||
NSSize sizeDiff = NSZeroSize;
|
||||
// NSBox* boxView = (NSBox*)[[releaseNotesView superview] superview];
|
||||
|
||||
//[boxView setBorderType: NSNoBorder];
|
||||
[releaseNotesView setDrawsBackground: NO];
|
||||
|
||||
sizeDiff.width = desiredSize.width -[releaseNotesView frame].size.width;
|
||||
sizeDiff.height = desiredSize.height -[releaseNotesView frame].size.height;
|
||||
frame.size.width += sizeDiff.width;
|
||||
frame.size.height += sizeDiff.height;
|
||||
|
||||
// No resizing:
|
||||
[[self window] setShowsResizeIndicator:NO];
|
||||
[[self window] setMinSize:frame.size];
|
||||
[[self window] setMaxSize:frame.size];
|
||||
}
|
||||
}
|
||||
|
||||
if (frame.size.width < minimumWindowWidth) {
|
||||
frame.size.width = minimumWindowWidth;
|
||||
}
|
||||
|
||||
[[self window] setFrame: frame display: NO];
|
||||
[[self window] center];
|
||||
|
||||
if (showReleaseNotes) // UK 2007-09-18
|
||||
{
|
||||
[self displayReleaseNotes];
|
||||
}
|
||||
|
||||
[[[releaseNotesView superview] superview] setHidden: !showReleaseNotes]; // UK 2007-09-18
|
||||
[self.window.contentView setNeedsLayout:YES]; // Prod autolayout to place everything
|
||||
|
||||
[self.window center];
|
||||
}
|
||||
|
||||
-(BOOL)showsReleaseNotesText
|
||||
{
|
||||
return( [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey] == nil );
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)windowShouldClose:(NSNotification *) __unused note
|
||||
{
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
@@ -278,42 +205,42 @@
|
||||
|
||||
- (NSImage *)applicationIcon
|
||||
{
|
||||
return [host icon];
|
||||
return [self.host icon];
|
||||
}
|
||||
|
||||
- (NSString *)titleText
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is available!", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is available!", nil), [self.host name]];
|
||||
}
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
NSString *updateItemVersion = [updateItem displayVersionString];
|
||||
NSString *hostVersion = [host displayVersion];
|
||||
// Display more info if the version strings are the same; useful for betas.
|
||||
if( !versionDisplayer && [updateItemVersion isEqualToString:hostVersion] )
|
||||
NSString *updateItemVersion = [self.updateItem displayVersionString];
|
||||
NSString *hostVersion = [self.host displayVersion];
|
||||
// Display more info if the version strings are the same; useful for betas.
|
||||
if (!self.versionDisplayer && [updateItemVersion isEqualToString:hostVersion] )
|
||||
{
|
||||
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [updateItem versionString]];
|
||||
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [host version]];
|
||||
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [self.updateItem versionString]];
|
||||
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [self.host version]];
|
||||
}
|
||||
else {
|
||||
[versionDisplayer formatVersion: &updateItemVersion andVersion: &hostVersion];
|
||||
}
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [host name], updateItemVersion, hostVersion];
|
||||
[self.versionDisplayer formatVersion:&updateItemVersion andVersion:&hostVersion];
|
||||
}
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [self.host name], updateItemVersion, hostVersion];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)sender didFinishLoadForFrame:frame
|
||||
{
|
||||
if ([frame parentFrame] == nil) {
|
||||
webViewFinishedLoading = YES;
|
||||
[releaseNotesSpinner setHidden:YES];
|
||||
[sender display]; // necessary to prevent weird scroll bar artifacting
|
||||
self.webViewFinishedLoading = YES;
|
||||
[self.releaseNotesSpinner setHidden:YES];
|
||||
[sender display]; // necessary to prevent weird scroll bar artifacting
|
||||
}
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *) __unused sender decidePolicyForNavigationAction:(NSDictionary *) __unused actionInformation request:(NSURLRequest *)request frame:(WebFrame *) __unused frame decisionListener:(id <WebPolicyDecisionListener>)listener
|
||||
- (void)webView:(WebView *)__unused sender decidePolicyForNavigationAction:(NSDictionary *)__unused actionInformation request:(NSURLRequest *)request frame:(WebFrame *)__unused frame decisionListener:(id<WebPolicyDecisionListener>)listener
|
||||
{
|
||||
if (webViewFinishedLoading) {
|
||||
if (self.webViewFinishedLoading) {
|
||||
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
|
||||
|
||||
[listener ignore];
|
||||
@@ -324,33 +251,33 @@
|
||||
}
|
||||
|
||||
// Clean up the contextual menu.
|
||||
- (NSArray *)webView:(WebView *) __unused sender contextMenuItemsForElement:(NSDictionary *) __unused element defaultMenuItems:(NSArray *)defaultMenuItems
|
||||
- (NSArray *)webView:(WebView *)__unused sender contextMenuItemsForElement:(NSDictionary *)__unused element defaultMenuItems:(NSArray *)defaultMenuItems
|
||||
{
|
||||
NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease];
|
||||
NSMutableArray *webViewMenuItems = [defaultMenuItems mutableCopy];
|
||||
|
||||
if (webViewMenuItems)
|
||||
{
|
||||
for (NSMenuItem *menuItem in defaultMenuItems)
|
||||
{
|
||||
NSInteger tag = [menuItem tag];
|
||||
NSInteger tag = [menuItem tag];
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case WebMenuItemTagOpenLinkInNewWindow:
|
||||
case WebMenuItemTagDownloadLinkToDisk:
|
||||
case WebMenuItemTagOpenImageInNewWindow:
|
||||
case WebMenuItemTagDownloadImageToDisk:
|
||||
case WebMenuItemTagOpenFrameInNewWindow:
|
||||
case WebMenuItemTagGoBack:
|
||||
case WebMenuItemTagGoForward:
|
||||
case WebMenuItemTagStop:
|
||||
case WebMenuItemTagReload:
|
||||
[webViewMenuItems removeObjectIdenticalTo: menuItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
case WebMenuItemTagOpenLinkInNewWindow:
|
||||
case WebMenuItemTagDownloadLinkToDisk:
|
||||
case WebMenuItemTagOpenImageInNewWindow:
|
||||
case WebMenuItemTagDownloadImageToDisk:
|
||||
case WebMenuItemTagOpenFrameInNewWindow:
|
||||
case WebMenuItemTagGoBack:
|
||||
case WebMenuItemTagGoForward:
|
||||
case WebMenuItemTagStop:
|
||||
case WebMenuItemTagReload:
|
||||
[webViewMenuItems removeObjectIdenticalTo:menuItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return webViewMenuItems;
|
||||
return webViewMenuItems;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+5
-11
@@ -11,21 +11,15 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
extern NSString * const SUUpdateDriverFinishedNotification;
|
||||
extern NSString *const SUUpdateDriverFinishedNotification;
|
||||
|
||||
@class SUHost, SUUpdater;
|
||||
@interface SUUpdateDriver : NSObject<NSURLDownloadDelegate>
|
||||
{
|
||||
SUHost *host;
|
||||
SUUpdater *updater; //assigned
|
||||
NSURL *appcastURL;
|
||||
@interface SUUpdateDriver : NSObject <NSURLDownloadDelegate>
|
||||
|
||||
BOOL finished;
|
||||
BOOL isInterruptible;
|
||||
}
|
||||
@property (retain) SUHost *host;
|
||||
@property (readonly, weak) SUUpdater *updater;
|
||||
@property (strong) SUHost *host;
|
||||
|
||||
- (instancetype) initWithUpdater:(SUUpdater *)updater;
|
||||
- (instancetype)initWithUpdater:(SUUpdater *)updater;
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
- (void)abortUpdate;
|
||||
@property (getter=isInterruptible, readonly) BOOL interruptible;
|
||||
|
||||
Vendored
+25
-21
@@ -9,40 +9,44 @@
|
||||
#import "SUUpdateDriver.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
|
||||
@interface SUUpdateDriver ()
|
||||
|
||||
@property (weak) SUUpdater *updater;
|
||||
@property (copy) NSURL *appcastURL;
|
||||
@property (getter=isInterruptible) BOOL interruptible;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdateDriver
|
||||
@synthesize host;
|
||||
@synthesize interruptible = isInterruptible;
|
||||
@synthesize finished;
|
||||
|
||||
- (instancetype) initWithUpdater:(SUUpdater *)anUpdater
|
||||
@synthesize updater;
|
||||
@synthesize host;
|
||||
@synthesize interruptible;
|
||||
@synthesize finished;
|
||||
@synthesize appcastURL;
|
||||
|
||||
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
updater = anUpdater;
|
||||
}
|
||||
return self;
|
||||
if ((self = [super init])) {
|
||||
self.updater = anUpdater;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h
|
||||
{
|
||||
appcastURL = [URL copy];
|
||||
host = [h retain];
|
||||
self.appcastURL = URL;
|
||||
self.host = h;
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[self setValue:@YES forKey:@"finished"];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.host = nil;
|
||||
[appcastURL release];
|
||||
[super dealloc];
|
||||
[self setValue:@YES forKey:@"finished"];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+4
-11
@@ -12,22 +12,15 @@
|
||||
#import "SUWindowController.h"
|
||||
|
||||
typedef enum {
|
||||
SUAutomaticallyCheck,
|
||||
SUDoNotAutomaticallyCheck
|
||||
SUAutomaticallyCheck,
|
||||
SUDoNotAutomaticallyCheck
|
||||
} SUPermissionPromptResult;
|
||||
|
||||
@protocol SUUpdatePermissionPromptDelegate;
|
||||
|
||||
@class SUHost;
|
||||
@interface SUUpdatePermissionPrompt : SUWindowController {
|
||||
SUHost *host;
|
||||
NSArray *systemProfileInformationArray;
|
||||
id<SUUpdatePermissionPromptDelegate> delegate;
|
||||
IBOutlet NSTextField *descriptionTextField;
|
||||
IBOutlet NSView *moreInfoView;
|
||||
IBOutlet NSButton *moreInfoButton;
|
||||
IBOutlet NSTableView *profileTableView;
|
||||
}
|
||||
@interface SUUpdatePermissionPrompt : SUWindowController
|
||||
|
||||
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d;
|
||||
- (IBAction)toggleMoreInfo:(id)sender;
|
||||
- (IBAction)finishPrompt:(id)sender;
|
||||
|
||||
Vendored
+85
-72
@@ -12,130 +12,143 @@
|
||||
#import "SUConstants.h"
|
||||
|
||||
@interface SUUpdatePermissionPrompt ()
|
||||
@property BOOL isShowingMoreInfo, shouldSendProfile;
|
||||
|
||||
@property (assign) BOOL isShowingMoreInfo;
|
||||
@property (assign) BOOL shouldSendProfile;
|
||||
|
||||
@property (strong) SUHost *host;
|
||||
@property (strong) NSArray *systemProfileInformationArray;
|
||||
@property (weak) id<SUUpdatePermissionPromptDelegate> delegate;
|
||||
@property (weak) IBOutlet NSTextField *descriptionTextField;
|
||||
@property (weak) IBOutlet NSView *moreInfoView;
|
||||
@property (weak) IBOutlet NSButton *moreInfoButton;
|
||||
@property (weak) IBOutlet NSTableView *profileTableView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdatePermissionPrompt
|
||||
|
||||
@synthesize isShowingMoreInfo = _isShowingMoreInfo, shouldSendProfile = _shouldSendProfile;
|
||||
@synthesize isShowingMoreInfo = _isShowingMoreInfo;
|
||||
@synthesize shouldSendProfile = _shouldSendProfile;
|
||||
@synthesize host;
|
||||
@synthesize systemProfileInformationArray;
|
||||
@synthesize delegate;
|
||||
@synthesize descriptionTextField;
|
||||
@synthesize moreInfoView;
|
||||
@synthesize moreInfoButton;
|
||||
@synthesize profileTableView;
|
||||
|
||||
- (BOOL)shouldAskAboutProfile
|
||||
{
|
||||
return [[host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
|
||||
return [[self.host objectForInfoDictionaryKey:SUEnableSystemProfilingKey] boolValue];
|
||||
}
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"];
|
||||
self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"];
|
||||
if (self)
|
||||
{
|
||||
host = [aHost retain];
|
||||
delegate = d;
|
||||
self.isShowingMoreInfo = NO;
|
||||
self.shouldSendProfile = [self shouldAskAboutProfile];
|
||||
systemProfileInformationArray = [profile retain];
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
host = aHost;
|
||||
delegate = d;
|
||||
self.isShowingMoreInfo = NO;
|
||||
self.shouldSendProfile = [self shouldAskAboutProfile];
|
||||
systemProfileInformationArray = profile;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id <SUUpdatePermissionPromptDelegate>)d
|
||||
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d
|
||||
{
|
||||
// If this is a background application we need to focus it in order to bring the prompt
|
||||
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
|
||||
// the user would not know why the application was paused.
|
||||
// If this is a background application we need to focus it in order to bring the prompt
|
||||
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
|
||||
// the user would not know why the application was paused.
|
||||
if ([aHost isBackgroundApplication]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; }
|
||||
|
||||
SUUpdatePermissionPrompt *prompt = [[[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d] autorelease];
|
||||
[NSApp runModalForWindow:[prompt window]];
|
||||
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
|
||||
[NSApp runModalForWindow:[prompt window]];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
if (![self shouldAskAboutProfile])
|
||||
{
|
||||
NSRect frame = [[self window] frame];
|
||||
frame.size.height -= [moreInfoButton frame].size.height;
|
||||
[[self window] setFrame:frame display:YES];
|
||||
} else {
|
||||
NSRect frame = [[self window] frame];
|
||||
frame.size.height -= [self.moreInfoButton frame].size.height;
|
||||
[[self window] setFrame:frame display:YES];
|
||||
} else {
|
||||
// Set the table view's delegate so we can disable row selection.
|
||||
[profileTableView setDelegate:(id)self];
|
||||
[self.profileTableView setDelegate:(id)self];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(NSTableView *) __unused tableView shouldSelectRow:(NSInteger) __unused row { return NO; }
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[host release];
|
||||
[systemProfileInformationArray release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSImage *)icon
|
||||
{
|
||||
return [host icon];
|
||||
return [self.host icon];
|
||||
}
|
||||
|
||||
- (NSString *)promptDescription
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [self.host name]];
|
||||
}
|
||||
|
||||
- (IBAction)toggleMoreInfo:(id) __unused sender
|
||||
- (IBAction)toggleMoreInfo:(id)__unused sender
|
||||
{
|
||||
self.isShowingMoreInfo = !_isShowingMoreInfo;
|
||||
self.isShowingMoreInfo = !self.isShowingMoreInfo;
|
||||
|
||||
NSView *contentView = [[self window] contentView];
|
||||
NSRect contentViewFrame = [contentView frame];
|
||||
NSRect windowFrame = [[self window] frame];
|
||||
NSView *contentView = [[self window] contentView];
|
||||
NSRect contentViewFrame = [contentView frame];
|
||||
NSRect windowFrame = [[self window] frame];
|
||||
|
||||
NSRect profileMoreInfoViewFrame = [moreInfoView frame];
|
||||
NSRect profileMoreInfoButtonFrame = [moreInfoButton frame];
|
||||
NSRect descriptionFrame = [descriptionTextField frame];
|
||||
NSRect profileMoreInfoViewFrame = [self.moreInfoView frame];
|
||||
NSRect profileMoreInfoButtonFrame = [self.moreInfoButton frame];
|
||||
NSRect descriptionFrame = [self.descriptionTextField frame];
|
||||
|
||||
if (_isShowingMoreInfo)
|
||||
if (self.isShowingMoreInfo)
|
||||
{
|
||||
// Add the subview
|
||||
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
|
||||
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
|
||||
profileMoreInfoViewFrame.origin.x = descriptionFrame.origin.x;
|
||||
profileMoreInfoViewFrame.size.width = descriptionFrame.size.width;
|
||||
// Add the subview
|
||||
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
|
||||
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
|
||||
profileMoreInfoViewFrame.origin.x = descriptionFrame.origin.x;
|
||||
profileMoreInfoViewFrame.size.width = descriptionFrame.size.width;
|
||||
|
||||
windowFrame.size.height += profileMoreInfoViewFrame.size.height;
|
||||
windowFrame.origin.y -= profileMoreInfoViewFrame.size.height;
|
||||
windowFrame.size.height += profileMoreInfoViewFrame.size.height;
|
||||
windowFrame.origin.y -= profileMoreInfoViewFrame.size.height;
|
||||
|
||||
[moreInfoView setFrame:profileMoreInfoViewFrame];
|
||||
[moreInfoView setHidden:YES];
|
||||
[contentView addSubview:moreInfoView
|
||||
positioned:NSWindowBelow
|
||||
relativeTo:moreInfoButton];
|
||||
} else {
|
||||
// Remove the subview
|
||||
[moreInfoView setHidden:NO];
|
||||
[moreInfoView removeFromSuperview];
|
||||
contentViewFrame.size.height -= profileMoreInfoViewFrame.size.height;
|
||||
[self.moreInfoView setFrame:profileMoreInfoViewFrame];
|
||||
[self.moreInfoView setHidden:YES];
|
||||
[contentView addSubview:self.moreInfoView
|
||||
positioned:NSWindowBelow
|
||||
relativeTo:self.moreInfoButton];
|
||||
} else {
|
||||
// Remove the subview
|
||||
[self.moreInfoView setHidden:NO];
|
||||
[self.moreInfoView removeFromSuperview];
|
||||
contentViewFrame.size.height -= profileMoreInfoViewFrame.size.height;
|
||||
|
||||
windowFrame.size.height -= profileMoreInfoViewFrame.size.height;
|
||||
windowFrame.origin.y += profileMoreInfoViewFrame.size.height;
|
||||
}
|
||||
[[self window] setFrame:windowFrame display:YES animate:YES];
|
||||
[contentView setFrame:contentViewFrame];
|
||||
[contentView setNeedsDisplay:YES];
|
||||
[moreInfoView setHidden:(!_isShowingMoreInfo)];
|
||||
windowFrame.size.height -= profileMoreInfoViewFrame.size.height;
|
||||
windowFrame.origin.y += profileMoreInfoViewFrame.size.height;
|
||||
}
|
||||
[[self window] setFrame:windowFrame display:YES animate:YES];
|
||||
[contentView setFrame:contentViewFrame];
|
||||
[contentView setNeedsDisplay:YES];
|
||||
[self.moreInfoView setHidden:!self.isShowingMoreInfo];
|
||||
}
|
||||
|
||||
- (IBAction)finishPrompt:(id)sender
|
||||
{
|
||||
if (![delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) {
|
||||
[NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", delegate];
|
||||
}
|
||||
[host setBool:_shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
[delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)];
|
||||
[[self window] close];
|
||||
[NSApp stopModal];
|
||||
if (![self.delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) {
|
||||
[NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", self.delegate];
|
||||
}
|
||||
[self.host setBool:self.shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
[self.delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)];
|
||||
[[self window] close];
|
||||
[NSApp stopModal];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+12
-17
@@ -23,13 +23,8 @@
|
||||
and automatically schedule and control checks for updates.
|
||||
*/
|
||||
@interface SUUpdater : NSObject
|
||||
{
|
||||
@private
|
||||
SUUpdateDriver *driver;
|
||||
|
||||
SUHost *host;
|
||||
}
|
||||
@property (assign) IBOutlet id<SUUpdaterDelegate> delegate;
|
||||
@property (weak) IBOutlet id<SUUpdaterDelegate> delegate;
|
||||
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
@@ -37,9 +32,9 @@
|
||||
|
||||
@property (readonly, strong) NSBundle *hostBundle;
|
||||
|
||||
@property BOOL automaticallyChecksForUpdates;
|
||||
@property BOOL automaticallyChecksForUpdates;
|
||||
|
||||
@property NSTimeInterval updateCheckInterval;
|
||||
@property NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
* The URL of the appcast used to download update information.
|
||||
@@ -50,9 +45,9 @@
|
||||
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
@property BOOL sendsSystemProfile;
|
||||
@property BOOL sendsSystemProfile;
|
||||
|
||||
@property BOOL automaticallyDownloadsUpdates;
|
||||
@property BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
@@ -162,7 +157,7 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (NSString*)feedURLStringForUpdater:(SUUpdater*)updater;
|
||||
- (NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
@@ -260,7 +255,7 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
@@ -272,7 +267,7 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (id <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
|
||||
- (id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns the path which is used to relaunch the client after the update is installed.
|
||||
@@ -289,7 +284,7 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
-(void) updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
- (void)updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after an updater shows a modal alert window,
|
||||
@@ -297,7 +292,7 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
-(void) updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
- (void)updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit.
|
||||
@@ -327,13 +322,13 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
#if defined(DEBUG) && DEBUG && 0
|
||||
#define SU_MIN_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_MIN_CHECK_INTERVAL 60*60
|
||||
#define SU_MIN_CHECK_INTERVAL 60 * 60
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) && DEBUG && 0
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60*60*24
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60 * 60 * 24
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Vendored
+243
-241
@@ -28,7 +28,7 @@ NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNoti
|
||||
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
|
||||
|
||||
@interface SUUpdater () <SUUpdatePermissionPromptDelegate>
|
||||
@property (retain) NSTimer *checkTimer;
|
||||
@property (strong) NSTimer *checkTimer;
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
- (void)startUpdateCycle;
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
|
||||
@@ -38,63 +38,69 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note;
|
||||
@property (readonly, copy) NSURL *parameterizedFeedURL;
|
||||
|
||||
-(void) notifyWillShowModalAlert;
|
||||
-(void) notifyDidShowModalAlert;
|
||||
- (void)notifyWillShowModalAlert;
|
||||
- (void)notifyDidShowModalAlert;
|
||||
|
||||
@property (strong) SUUpdateDriver *driver;
|
||||
@property (strong) SUHost *host;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdater
|
||||
|
||||
@synthesize delegate;
|
||||
@synthesize checkTimer;
|
||||
@synthesize userAgentString = customUserAgentString;
|
||||
|
||||
@synthesize driver;
|
||||
@synthesize host;
|
||||
|
||||
#pragma mark Initialization
|
||||
|
||||
static NSMutableDictionary *sharedUpdaters = nil;
|
||||
static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
|
||||
+ (SUUpdater *)sharedUpdater
|
||||
{
|
||||
return [self updaterForBundle:[NSBundle mainBundle]];
|
||||
return [self updaterForBundle:[NSBundle mainBundle]];
|
||||
}
|
||||
|
||||
// SUUpdater has a singleton for each bundle. We use the fact that NSBundle instances are also singletons, so we can use them as keys. If you don't trust that you can also use the identifier as key
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle
|
||||
{
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater == nil) {
|
||||
updater = [[[[self class] alloc] initForBundle:bundle] autorelease];
|
||||
}
|
||||
return updater;
|
||||
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater == nil) {
|
||||
updater = [[[self class] alloc] initForBundle:bundle];
|
||||
}
|
||||
return updater;
|
||||
}
|
||||
|
||||
// This is the designated initializer for SUUpdater, important for subclasses
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle
|
||||
{
|
||||
self = [super init];
|
||||
self = [super init];
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
|
||||
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
|
||||
if (self) {
|
||||
[self registerAsObserver];
|
||||
}
|
||||
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
|
||||
if (self) {
|
||||
[self registerAsObserver];
|
||||
}
|
||||
|
||||
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
|
||||
id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater)
|
||||
{
|
||||
[self release];
|
||||
self = [updater retain];
|
||||
self = updater;
|
||||
}
|
||||
else if (self)
|
||||
{
|
||||
if (sharedUpdaters == nil) {
|
||||
if (sharedUpdaters == nil) {
|
||||
sharedUpdaters = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
}
|
||||
sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]] = self;
|
||||
host = [[SUHost alloc] initWithBundle:bundle];
|
||||
|
||||
// Saving-the-developer-from-a-stupid-mistake-check:
|
||||
// Saving-the-developer-from-a-stupid-mistake-check:
|
||||
BOOL hasPublicDSAKey = [host publicDSAKey] != nil;
|
||||
BOOL isMainBundle = [bundle isEqualTo:[NSBundle mainBundle]];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
||||
@@ -110,8 +116,8 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that
|
||||
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:0];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,20 +127,20 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
return [self initForBundle:[NSBundle mainBundle]];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
|
||||
-(void) notifyWillShowModalAlert
|
||||
- (void)notifyWillShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterWillShowModalAlert:)] )
|
||||
[delegate updaterWillShowModalAlert: self];
|
||||
if ([self.delegate respondsToSelector:@selector(updaterWillShowModalAlert:)])
|
||||
[self.delegate updaterWillShowModalAlert:self];
|
||||
}
|
||||
|
||||
|
||||
-(void) notifyDidShowModalAlert
|
||||
- (void)notifyDidShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterDidShowModalAlert:)] )
|
||||
[delegate updaterDidShowModalAlert: self];
|
||||
if ([self.delegate respondsToSelector:@selector(updaterDidShowModalAlert:)])
|
||||
[self.delegate updaterDidShowModalAlert:self];
|
||||
}
|
||||
|
||||
|
||||
@@ -142,28 +148,28 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
{
|
||||
BOOL shouldPrompt = NO;
|
||||
|
||||
// If the user has been asked about automatic checks, don't bother prompting
|
||||
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKey])
|
||||
// If the user has been asked about automatic checks, don't bother prompting
|
||||
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey])
|
||||
{
|
||||
shouldPrompt = NO;
|
||||
}
|
||||
// Does the delegate want to take care of the logic for when we should ask permission to update?
|
||||
else if ([delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)])
|
||||
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)])
|
||||
{
|
||||
shouldPrompt = [delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
|
||||
shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
|
||||
}
|
||||
// Has he been asked already? And don't ask if the host has a default value set in its Info.plist.
|
||||
else if ([host objectForKey:SUEnableAutomaticChecksKey] == nil)
|
||||
else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil)
|
||||
{
|
||||
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) {
|
||||
[self setAutomaticallyChecksForUpdates:[host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]];
|
||||
}
|
||||
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) {
|
||||
[self setAutomaticallyChecksForUpdates:[self.host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]];
|
||||
}
|
||||
// Now, we don't want to ask the user for permission to do a weird thing on the first launch.
|
||||
// We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
|
||||
else if (![host objectForKey:SUPromptUserOnFirstLaunchKey])
|
||||
else if (![self.host objectForKey:SUPromptUserOnFirstLaunchKey])
|
||||
{
|
||||
if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
|
||||
[host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
|
||||
if ([self.host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
|
||||
[self.host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
|
||||
else
|
||||
shouldPrompt = YES;
|
||||
}
|
||||
@@ -173,12 +179,12 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
if (shouldPrompt)
|
||||
{
|
||||
NSArray *profileInfo = [host systemProfile];
|
||||
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
|
||||
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:YES]];
|
||||
}
|
||||
[SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self];
|
||||
NSArray *profileInfo = [self.host systemProfile];
|
||||
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
|
||||
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:YES]];
|
||||
}
|
||||
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:profileInfo delegate:self];
|
||||
// We start the update checks and register as observer for changes after the prompt finishes
|
||||
}
|
||||
else
|
||||
@@ -190,199 +196,197 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
- (void)updatePermissionPromptFinishedWithResult:(SUPermissionPromptResult)result
|
||||
{
|
||||
[self setAutomaticallyChecksForUpdates:(result == SUAutomaticallyCheck)];
|
||||
[self setAutomaticallyChecksForUpdates:(result == SUAutomaticallyCheck)];
|
||||
// Schedule checks, but make sure we ignore the delayed call from KVO
|
||||
[self resetUpdateCycle];
|
||||
[self resetUpdateCycle];
|
||||
}
|
||||
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note
|
||||
{
|
||||
if ([note object] == driver && [driver finished])
|
||||
if ([note object] == self.driver && [self.driver finished])
|
||||
{
|
||||
[driver release]; driver = nil;
|
||||
[self scheduleNextUpdateCheck];
|
||||
self.driver = nil;
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)lastUpdateCheckDate
|
||||
{
|
||||
return [host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
return [self.host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheck
|
||||
{
|
||||
if (checkTimer)
|
||||
if (self.checkTimer)
|
||||
{
|
||||
[checkTimer invalidate];
|
||||
self.checkTimer = nil; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
[self.checkTimer invalidate];
|
||||
self.checkTimer = nil; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
if (![self automaticallyChecksForUpdates]) return;
|
||||
|
||||
// How long has it been since last we checked for an update?
|
||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||
// How long has it been since last we checked for an update?
|
||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
|
||||
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
|
||||
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
|
||||
-(void) putFeedURLIntoDictionary: (NSMutableDictionary*)theDict // You release this.
|
||||
- (void)putFeedURLIntoDictionary:(NSMutableDictionary *)theDict // You release this.
|
||||
{
|
||||
theDict[@"feedURL"] = [self feedURL];
|
||||
theDict[@"feedURL"] = [self feedURL];
|
||||
}
|
||||
|
||||
-(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDriver /* RUNS ON ITS OWN THREAD */
|
||||
- (void)checkForUpdatesInBgReachabilityCheckWithDriver:(SUUpdateDriver *)inDriver /* RUNS ON ITS OWN THREAD */
|
||||
{
|
||||
@try {
|
||||
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
|
||||
// can block, and it can be waiting a long time on slow networks, and we
|
||||
// wouldn't want to beachball the main thread for a background operation.
|
||||
// We could use asynchronous reachability callbacks, but those aren't
|
||||
// reliable enough and can 'get lost' sometimes, which we don't want.
|
||||
@try {
|
||||
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
|
||||
// can block, and it can be waiting a long time on slow networks, and we
|
||||
// wouldn't want to beachball the main thread for a background operation.
|
||||
// We could use asynchronous reachability callbacks, but those aren't
|
||||
// reliable enough and can 'get lost' sometimes, which we don't want.
|
||||
|
||||
@autoreleasepool {
|
||||
SCNetworkConnectionFlags flags = 0;
|
||||
BOOL isNetworkReachable = YES;
|
||||
SCNetworkConnectionFlags flags = 0;
|
||||
BOOL isNetworkReachable = YES;
|
||||
|
||||
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
|
||||
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
|
||||
NSMutableDictionary *theDict = [NSMutableDictionary dictionary];
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[self putFeedURLIntoDictionary:theDict]; // Get feed URL on main thread, it's not safe to call elsewhere.
|
||||
});
|
||||
});
|
||||
|
||||
const char *hostname = [[(NSURL *)theDict[@"feedURL"] host] cStringUsingEncoding: NSUTF8StringEncoding];
|
||||
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
|
||||
Boolean reachabilityResult = NO;
|
||||
// If the feed's using a file:// URL, we won't be able to use reachability.
|
||||
if (reachability != NULL) {
|
||||
SCNetworkReachabilityGetFlags(reachability, &flags);
|
||||
CFRelease(reachability);
|
||||
}
|
||||
const char *hostname = [[(NSURL *)theDict[@"feedURL"] host] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
|
||||
Boolean reachabilityResult = NO;
|
||||
// If the feed's using a file:// URL, we won't be able to use reachability.
|
||||
if (reachability != NULL) {
|
||||
SCNetworkReachabilityGetFlags(reachability, &flags);
|
||||
CFRelease(reachability);
|
||||
}
|
||||
|
||||
if( reachabilityResult )
|
||||
{
|
||||
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
|
||||
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
|
||||
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
|
||||
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
|
||||
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
|
||||
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
|
||||
|
||||
//NSLog(@"reachable = %s, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO"));
|
||||
if (!(reachable || automatic || local))
|
||||
isNetworkReachable = NO;
|
||||
}
|
||||
|
||||
if( !(reachable || automatic || local) )
|
||||
isNetworkReachable = NO;
|
||||
}
|
||||
|
||||
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self checkForUpdatesWithDriver: isNetworkReachable ? inDriver : nil];
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
} @catch (NSException *localException) {
|
||||
SULog(@"UNCAUGHT EXCEPTION IN UPDATE CHECK TIMER: %@",[localException reason]);
|
||||
// Don't propagate the exception beyond here. In Carbon apps that would trash the stack.
|
||||
}
|
||||
SULog(@"UNCAUGHT EXCEPTION IN UPDATE CHECK TIMER: %@", [localException reason]);
|
||||
// Don't propagate the exception beyond here. In Carbon apps that would trash the stack.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
// Background update checks should only happen if we have a network connection.
|
||||
// Wouldn't want to annoy users on dial-up by establishing a connection every
|
||||
// hour or so:
|
||||
SUUpdateDriver * theUpdateDriver = [[[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease];
|
||||
// Background update checks should only happen if we have a network connection.
|
||||
// Wouldn't want to annoy users on dial-up by establishing a connection every
|
||||
// hour or so:
|
||||
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)mayUpdateAndRestart
|
||||
{
|
||||
return( !delegate || ![delegate respondsToSelector: @selector(updaterShouldRelaunchApplication:)] || [delegate updaterShouldRelaunchApplication: self] );
|
||||
return (!self.delegate || ![self.delegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.delegate updaterShouldRelaunchApplication:self]);
|
||||
}
|
||||
|
||||
- (IBAction)checkForUpdates:(id) __unused sender
|
||||
- (IBAction)checkForUpdates:(id)__unused sender
|
||||
{
|
||||
if (driver && [driver isInterruptible]) {
|
||||
[driver abortUpdate];
|
||||
}
|
||||
if (self.driver && [self.driver isInterruptible]) {
|
||||
[self.driver abortUpdate];
|
||||
}
|
||||
|
||||
[self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]];
|
||||
[self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]];
|
||||
}
|
||||
|
||||
- (void)checkForUpdateInformation
|
||||
{
|
||||
[self checkForUpdatesWithDriver:[[[SUProbingUpdateDriver alloc] initWithUpdater:self] autorelease]];
|
||||
[self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self]];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
|
||||
{
|
||||
if ([self updateInProgress]) { return; }
|
||||
if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
|
||||
SUClearLog();
|
||||
SULog( @"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath: [[NSBundle mainBundle] bundlePath]] );
|
||||
SUClearLog();
|
||||
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
|
||||
|
||||
[self willChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
[self willChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
|
||||
if( [delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![delegate updaterMayCheckForUpdates: self] )
|
||||
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
driver = [d retain];
|
||||
self.driver = d;
|
||||
|
||||
// If we're not given a driver at all, just schedule the next update check and bail.
|
||||
if (!driver)
|
||||
if (!self.driver)
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL* theFeedURL = [self parameterizedFeedURL];
|
||||
if( theFeedURL ) // Use a NIL URL to cancel quietly.
|
||||
[driver checkForUpdatesAtURL: theFeedURL host:host];
|
||||
else
|
||||
[driver abortUpdate];
|
||||
NSURL *theFeedURL = [self parameterizedFeedURL];
|
||||
if (theFeedURL) // Use a NIL URL to cancel quietly.
|
||||
[self.driver checkForUpdatesAtURL:theFeedURL host:self.host];
|
||||
else
|
||||
[self.driver abortUpdate];
|
||||
}
|
||||
|
||||
- (void)registerAsObserver
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:(NSKeyValueObservingOptions)0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:(NSKeyValueObservingOptions)0 context:(__bridge void *)(SUUpdaterDefaultsObservationContext)];
|
||||
}
|
||||
|
||||
- (void)unregisterAsObserver
|
||||
{
|
||||
@try
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
NSLog(@"Sparkle Error: [SUUpdater unregisterAsObserver] called, but the updater wasn't registered as an observer.");
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
SULog(@"Error: [SUUpdater unregisterAsObserver] called, but the updater wasn't registered as an observer.");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
if (context == SUUpdaterDefaultsObservationContext)
|
||||
if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext))
|
||||
{
|
||||
// Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking.
|
||||
// Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them.
|
||||
@@ -391,7 +395,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
}
|
||||
else
|
||||
{
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,40 +407,40 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
|
||||
{
|
||||
[host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey];
|
||||
// Hack to support backwards compatibility with older Sparkle versions, which supported
|
||||
// disabling updates by setting the check interval to 0.
|
||||
if (automaticallyCheckForUpdates && (NSInteger)[self updateCheckInterval] == 0) {
|
||||
[self.host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey];
|
||||
// Hack to support backwards compatibility with older Sparkle versions, which supported
|
||||
// disabling updates by setting the check interval to 0.
|
||||
if (automaticallyCheckForUpdates && (NSInteger)[self updateCheckInterval] == 0) {
|
||||
[self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL];
|
||||
}
|
||||
}
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
// Don't automatically update when the check interval is 0, to be compatible with 1.1 settings.
|
||||
if ((NSInteger)[self updateCheckInterval] == 0) {
|
||||
// Don't automatically update when the check interval is 0, to be compatible with 1.1 settings.
|
||||
if ((NSInteger)[self updateCheckInterval] == 0) {
|
||||
return NO;
|
||||
}
|
||||
return [host boolForKey:SUEnableAutomaticChecksKey];
|
||||
}
|
||||
return [self.host boolForKey:SUEnableAutomaticChecksKey];
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
|
||||
{
|
||||
[host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
[self.host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
|
||||
if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) {
|
||||
return NO;
|
||||
}
|
||||
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
|
||||
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
// Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
@@ -444,7 +448,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
if (![NSThread isMainThread])
|
||||
[NSException raise:@"SUThreadException" format:@"This method must be called on the main thread"];
|
||||
|
||||
[host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
|
||||
[self.host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
|
||||
}
|
||||
|
||||
- (NSURL *)feedURL
|
||||
@@ -452,127 +456,125 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
if (![NSThread isMainThread])
|
||||
[NSException raise:@"SUThreadException" format:@"This method must be called on the main thread"];
|
||||
|
||||
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
|
||||
NSString *appcastString = [host objectForKey:SUFeedURLKey];
|
||||
if( [delegate respondsToSelector: @selector(feedURLStringForUpdater:)] )
|
||||
appcastString = [delegate feedURLStringForUpdater: self];
|
||||
if (!appcastString) // Can't find an appcast string!
|
||||
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey];
|
||||
NSCharacterSet* quoteSet = [NSCharacterSet characterSetWithCharactersInString: @"\"\'"]; // Some feed publishers add quotes; strip 'em.
|
||||
NSString* castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
|
||||
if( !castUrlStr || [castUrlStr length] == 0 )
|
||||
return nil;
|
||||
else
|
||||
return [NSURL URLWithString: castUrlStr];
|
||||
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
|
||||
NSString *appcastString = [self.host objectForKey:SUFeedURLKey];
|
||||
if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)])
|
||||
appcastString = [self.delegate feedURLStringForUpdater:self];
|
||||
if (!appcastString) // Can't find an appcast string!
|
||||
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey];
|
||||
NSCharacterSet *quoteSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"]; // Some feed publishers add quotes; strip 'em.
|
||||
NSString *castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
|
||||
if (!castUrlStr || [castUrlStr length] == 0)
|
||||
return nil;
|
||||
else
|
||||
return [NSURL URLWithString:castUrlStr];
|
||||
}
|
||||
|
||||
- (NSString *)userAgentString
|
||||
{
|
||||
if (customUserAgentString) {
|
||||
return customUserAgentString;
|
||||
}
|
||||
if (customUserAgentString) {
|
||||
return customUserAgentString;
|
||||
}
|
||||
|
||||
NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [host name], [host displayVersion], version ? version : @"?"];
|
||||
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||
return [[[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding] autorelease];
|
||||
NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"];
|
||||
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||
return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding];
|
||||
}
|
||||
|
||||
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile
|
||||
{
|
||||
[host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
[self.host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (BOOL)sendsSystemProfile
|
||||
{
|
||||
return [host boolForKey:SUSendProfileInfoKey];
|
||||
return [self.host boolForKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (NSURL *)parameterizedFeedURL
|
||||
{
|
||||
NSURL *baseFeedURL = [self feedURL];
|
||||
NSURL *baseFeedURL = [self feedURL];
|
||||
|
||||
// Determine all the parameters we're attaching to the base feed URL.
|
||||
BOOL sendingSystemProfile = [self sendsSystemProfile];
|
||||
// Determine all the parameters we're attaching to the base feed URL.
|
||||
BOOL sendingSystemProfile = [self sendsSystemProfile];
|
||||
|
||||
// Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.
|
||||
NSDate *lastSubmitDate = [host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
if (!lastSubmitDate) {
|
||||
lastSubmitDate = [NSDate distantPast];
|
||||
}
|
||||
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
|
||||
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
|
||||
// Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.
|
||||
NSDate *lastSubmitDate = [self.host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
if (!lastSubmitDate) {
|
||||
lastSubmitDate = [NSDate distantPast];
|
||||
}
|
||||
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
|
||||
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
|
||||
|
||||
NSArray *parameters = @[];
|
||||
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
|
||||
}
|
||||
NSArray *parameters = @[];
|
||||
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
|
||||
}
|
||||
if (sendingSystemProfile)
|
||||
{
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[host systemProfile]];
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
}
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[self.host systemProfile]];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
}
|
||||
if ([parameters count] == 0) { return baseFeedURL; }
|
||||
|
||||
// Build up the parameterized URL.
|
||||
NSMutableArray *parameterStrings = [NSMutableArray array];
|
||||
for (NSDictionary *currentProfileInfo in parameters) {
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[currentProfileInfo[@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[currentProfileInfo[@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||
}
|
||||
// Build up the parameterized URL.
|
||||
NSMutableArray *parameterStrings = [NSMutableArray array];
|
||||
for (NSDictionary *currentProfileInfo in parameters) {
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[currentProfileInfo[@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[currentProfileInfo[@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||
}
|
||||
|
||||
NSString *separatorCharacter = @"?";
|
||||
if ([baseFeedURL query]) {
|
||||
separatorCharacter = @"&"; // In case the URL is already http://foo.org/baz.xml?bat=4
|
||||
}
|
||||
NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@%@%@", [baseFeedURL absoluteString], separatorCharacter, [parameterStrings componentsJoinedByString:@"&"]];
|
||||
NSString *separatorCharacter = @"?";
|
||||
if ([baseFeedURL query]) {
|
||||
separatorCharacter = @"&"; // In case the URL is already http://foo.org/baz.xml?bat=4
|
||||
}
|
||||
NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@%@%@", [baseFeedURL absoluteString], separatorCharacter, [parameterStrings componentsJoinedByString:@"&"]];
|
||||
|
||||
// Clean it up so it's a valid URL
|
||||
return [NSURL URLWithString:appcastStringWithProfile];
|
||||
// Clean it up so it's a valid URL
|
||||
return [NSURL URLWithString:appcastStringWithProfile];
|
||||
}
|
||||
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
[host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if ((NSInteger)updateCheckInterval == 0) { // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
}
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
[self.host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if ((NSInteger)updateCheckInterval == 0) { // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
}
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
NSNumber *intervalValue = [host objectForKey:SUScheduledCheckIntervalKey];
|
||||
if (intervalValue)
|
||||
return [intervalValue doubleValue];
|
||||
else
|
||||
return SU_DEFAULT_CHECK_INTERVAL;
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
NSNumber *intervalValue = [self.host objectForKey:SUScheduledCheckIntervalKey];
|
||||
if (intervalValue)
|
||||
return [intervalValue doubleValue];
|
||||
else
|
||||
return SU_DEFAULT_CHECK_INTERVAL;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self unregisterAsObserver];
|
||||
[host release];
|
||||
if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
[super dealloc];
|
||||
[self unregisterAsObserver];
|
||||
if (checkTimer) { [checkTimer invalidate]; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
if ([item action] == @selector(checkForUpdates:)) {
|
||||
return ![self updateInProgress];
|
||||
}
|
||||
return YES;
|
||||
if ([item action] == @selector(checkForUpdates:)) {
|
||||
return ![self updateInProgress];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)updateInProgress
|
||||
{
|
||||
return driver && ([driver finished] == NO);
|
||||
return self.driver && ([self.driver finished] == NO);
|
||||
}
|
||||
|
||||
- (NSBundle *)hostBundle { return [host bundle]; }
|
||||
- (NSBundle *)hostBundle { return [self.host bundle]; }
|
||||
|
||||
@end
|
||||
-5
@@ -13,11 +13,6 @@
|
||||
#import "SUUIBasedUpdateDriver.h"
|
||||
|
||||
@interface SUUserInitiatedUpdateDriver : SUUIBasedUpdateDriver
|
||||
{
|
||||
@private
|
||||
SUStatusController *checkingController;
|
||||
BOOL isCanceled;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+44
-35
@@ -11,78 +11,87 @@
|
||||
#import "SUStatusController.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
@interface SUUserInitiatedUpdateDriver ()
|
||||
|
||||
@property (strong) SUStatusController *checkingController;
|
||||
@property (assign, getter=isCanceled) BOOL canceled;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUserInitiatedUpdateDriver
|
||||
|
||||
@synthesize checkingController;
|
||||
@synthesize canceled;
|
||||
|
||||
- (void)closeCheckingWindow
|
||||
{
|
||||
if (checkingController)
|
||||
if (self.checkingController)
|
||||
{
|
||||
[[checkingController window] close];
|
||||
[checkingController release];
|
||||
checkingController = nil;
|
||||
}
|
||||
[[self.checkingController window] close];
|
||||
self.checkingController = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelCheckForUpdates:(id) __unused sender
|
||||
- (void)cancelCheckForUpdates:(id)__unused sender
|
||||
{
|
||||
[self closeCheckingWindow];
|
||||
isCanceled = YES;
|
||||
[self closeCheckingWindow];
|
||||
self.canceled = YES;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
checkingController = [[SUStatusController alloc] initWithHost:aHost];
|
||||
[[checkingController window] center]; // Force the checking controller to load its window.
|
||||
[checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
|
||||
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[checkingController showWindow:self];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
self.checkingController = [[SUStatusController alloc] initWithHost:aHost];
|
||||
[[self.checkingController window] center]; // Force the checking controller to load its window.
|
||||
[self.checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
|
||||
[self.checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[self.checkingController showWindow:self];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
if ([aHost isBackgroundApplication])
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
{
|
||||
if (isCanceled)
|
||||
if (self.isCanceled)
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
[self closeCheckingWindow];
|
||||
[super appcastDidFinishLoading:ac];
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
[self closeCheckingWindow];
|
||||
[super appcastDidFinishLoading:ac];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
[self closeCheckingWindow];
|
||||
[super abortUpdateWithError:error];
|
||||
[self closeCheckingWindow];
|
||||
[super abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[self closeCheckingWindow];
|
||||
[super abortUpdate];
|
||||
[self closeCheckingWindow];
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
|
||||
{
|
||||
if (isCanceled)
|
||||
if (self.isCanceled)
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
[super appcast:ac failedToLoadWithError:error];
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
[super appcast:ac failedToLoadWithError:error];
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
{
|
||||
// We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version.
|
||||
return [self hostSupportsItem:ui] && [self isItemNewer:ui];
|
||||
// We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version.
|
||||
return [self hostSupportsItem:ui] && [self isItemNewer:ui];
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a,
|
||||
and NSOrderedSame if they are equivalent.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -20,6 +20,6 @@
|
||||
Both versions are provided so that important distinguishing information
|
||||
can be displayed while also leaving out unnecessary/confusing parts.
|
||||
*/
|
||||
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
|
||||
- (void)formatVersion:(NSString **)inOutVersionA andVersion:(NSString **)inOutVersionB;
|
||||
|
||||
@end
|
||||
Vendored
+9
-9
@@ -13,15 +13,15 @@
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host windowNibName:(NSString *)nibName
|
||||
{
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:nibName ofType:@"nib"];
|
||||
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
|
||||
{
|
||||
NSString *frameworkPath = [[[host bundle] sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
|
||||
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
|
||||
path = [framework pathForResource:nibName ofType:@"nib"];
|
||||
}
|
||||
self = [super initWithWindowNibPath:path owner:self];
|
||||
return self;
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:nibName ofType:@"nib"];
|
||||
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
|
||||
{
|
||||
NSString *frameworkPath = [[[host bundle] sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
|
||||
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
|
||||
path = [framework pathForResource:nibName ofType:@"nib"];
|
||||
}
|
||||
self = [super initWithWindowNibPath:path owner:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+93
-81
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13E25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1070" identifier="macosx"/>
|
||||
<development version="5100" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6154.17"/>
|
||||
<plugIn identifier="com.apple.WebKitIBPlugin" version="6154.17"/>
|
||||
@@ -10,9 +11,10 @@
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="SUUpdateAlert">
|
||||
<connections>
|
||||
<outlet property="description" destination="101" id="105"/>
|
||||
<outlet property="descriptionField" destination="101" id="9oA-2S-eXN"/>
|
||||
<outlet property="installButton" destination="76" id="176"/>
|
||||
<outlet property="laterButton" destination="22" id="177"/>
|
||||
<outlet property="releaseNotesContainerView" destination="fKC-QA-GZa" id="BYw-MA-Z5h"/>
|
||||
<outlet property="releaseNotesView" destination="18" id="32"/>
|
||||
<outlet property="skipButton" destination="23" id="178"/>
|
||||
<outlet property="window" destination="5" id="69"/>
|
||||
@@ -31,7 +33,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="620" height="370"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="7">
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="7" userLabel="Program icon">
|
||||
<rect key="frame" x="22" y="286" width="64" height="64"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="7" secondAttribute="height" multiplier="1:1" id="7pS-Kw-VGo"/>
|
||||
@@ -43,7 +45,7 @@
|
||||
<binding destination="-2" name="value" keyPath="applicationIcon" id="9"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="10">
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="10" userLabel="Version text field">
|
||||
<rect key="frame" x="106" y="338" width="494" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" priority="777" constant="17" id="n8w-DR-XEM"/>
|
||||
@@ -57,24 +59,91 @@
|
||||
<binding destination="-2" name="value" keyPath="titleText" id="11"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="106" y="294" width="87" height="14"/>
|
||||
<textField horizontalHuggingPriority="350" verticalHuggingPriority="999" horizontalCompressionResistancePriority="100" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="101" userLabel="Question text field">
|
||||
<rect key="frame" x="106" y="316" width="494" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="100" constant="100" id="gkn-FW-9aC"/>
|
||||
<constraint firstAttribute="height" relation="lessThanOrEqual" priority="300" constant="28" id="H6E-te-Fog"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="14" id="KUO-Dw-g6s"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Release Notes:" usesSingleLineMode="YES" id="170">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" id="174">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="72">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="-2" name="value" keyPath="descriptionText" id="103"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="fKC-QA-GZa" userLabel="Container to hide release notes">
|
||||
<rect key="frame" x="108" y="72" width="492" height="236"/>
|
||||
<subviews>
|
||||
<box boxType="oldStyle" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="89">
|
||||
<rect key="frame" x="0.0" y="0.0" width="492" height="216"/>
|
||||
<view key="contentView">
|
||||
<rect key="frame" x="1" y="1" width="490" height="214"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<webView maintainsBackForwardList="NO" translatesAutoresizingMaskIntoConstraints="NO" id="18">
|
||||
<rect key="frame" x="0.0" y="-2" width="492" height="216"/>
|
||||
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12" minimumFontSize="7" plugInsEnabled="NO" javaEnabled="NO" javaScriptCanOpenWindowsAutomatically="NO">
|
||||
<nil key="identifier"/>
|
||||
</webPreferences>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="161">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</webView>
|
||||
</subviews>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="18" secondAttribute="bottom" constant="-1" id="7Uu-EM-qfh"/>
|
||||
<constraint firstAttribute="trailing" secondItem="18" secondAttribute="trailing" constant="-1" id="EFO-ey-o4D"/>
|
||||
<constraint firstItem="18" firstAttribute="leading" secondItem="89" secondAttribute="leading" constant="1" id="Shl-nT-W5w"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="pvn-8k-9Ev"/>
|
||||
<constraint firstItem="18" firstAttribute="top" secondItem="89" secondAttribute="top" constant="1" id="x0j-CT-nBY"/>
|
||||
</constraints>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" size="11" name="LucidaGrande"/>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="164">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</box>
|
||||
<textField verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="-2" y="222" width="87" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="100" constant="100" id="gkn-FW-9aC"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Release Notes:" usesSingleLineMode="YES" id="170">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="72">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="89" firstAttribute="top" secondItem="17" secondAttribute="bottom" constant="6" id="1H8-33-yNF"/>
|
||||
<constraint firstAttribute="width" secondItem="89" secondAttribute="width" id="3y1-1h-gd7"/>
|
||||
<constraint firstAttribute="bottom" secondItem="89" secondAttribute="bottom" id="E4h-VA-0Xt"/>
|
||||
<constraint firstItem="17" firstAttribute="top" secondItem="fKC-QA-GZa" secondAttribute="top" id="P9G-6a-y7j"/>
|
||||
<constraint firstItem="89" firstAttribute="leading" secondItem="fKC-QA-GZa" secondAttribute="leading" id="e5T-q1-kq1"/>
|
||||
<constraint firstItem="17" firstAttribute="leading" secondItem="fKC-QA-GZa" secondAttribute="leading" id="tFH-k0-O7I"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<button horizontalHuggingPriority="150" verticalHuggingPriority="750" horizontalCompressionResistancePriority="997" translatesAutoresizingMaskIntoConstraints="NO" id="22">
|
||||
<rect key="frame" x="328" y="12" width="146" height="32"/>
|
||||
<constraints>
|
||||
@@ -117,60 +186,6 @@ DQ
|
||||
<action selector="installUpdate:" target="-2" id="77"/>
|
||||
</connections>
|
||||
</button>
|
||||
<box boxType="oldStyle" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="89">
|
||||
<rect key="frame" x="110" y="76" width="490" height="213"/>
|
||||
<view key="contentView">
|
||||
<rect key="frame" x="1" y="1" width="488" height="211"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<webView maintainsBackForwardList="NO" translatesAutoresizingMaskIntoConstraints="NO" id="18">
|
||||
<rect key="frame" x="-2" y="-1" width="490" height="213"/>
|
||||
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12" minimumFontSize="7" plugInsEnabled="NO" javaEnabled="NO" javaScriptCanOpenWindowsAutomatically="NO">
|
||||
<nil key="identifier"/>
|
||||
</webPreferences>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="161">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</webView>
|
||||
</subviews>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstItem="18" firstAttribute="width" secondItem="89" secondAttribute="width" id="EFp-Ab-Fcg"/>
|
||||
<constraint firstItem="18" firstAttribute="leading" secondItem="89" secondAttribute="leading" constant="-1" id="Shl-nT-W5w"/>
|
||||
<constraint firstItem="18" firstAttribute="height" secondItem="89" secondAttribute="height" id="gw8-DG-V2x"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="pvn-8k-9Ev"/>
|
||||
<constraint firstItem="18" firstAttribute="top" secondItem="89" secondAttribute="top" id="x0j-CT-nBY"/>
|
||||
</constraints>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" size="11" name="LucidaGrande"/>
|
||||
<connections>
|
||||
<binding destination="-2" name="hidden" keyPath="showsReleaseNotes" id="164">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</box>
|
||||
<textField horizontalHuggingPriority="350" verticalHuggingPriority="999" horizontalCompressionResistancePriority="100" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="101">
|
||||
<rect key="frame" x="106" y="316" width="494" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="lessThanOrEqual" priority="300" constant="28" id="H6E-te-Fog"/>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="14" id="KUO-Dw-g6s"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" id="174">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="descriptionText" id="103"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="117">
|
||||
<rect key="frame" x="106" y="49" width="495" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Automatically download and install updates in the future" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="175">
|
||||
@@ -188,34 +203,31 @@ DQ
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="101" firstAttribute="leading" secondItem="17" secondAttribute="leading" id="1MC-kH-3oJ"/>
|
||||
<constraint firstItem="10" firstAttribute="leading" secondItem="7" secondAttribute="trailing" constant="22" id="2ef-4I-Il3"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fKC-QA-GZa" secondAttribute="trailing" constant="20" id="406-Cn-C5d"/>
|
||||
<constraint firstItem="101" firstAttribute="leading" secondItem="10" secondAttribute="leading" id="7XS-9C-U6N"/>
|
||||
<constraint firstItem="23" firstAttribute="top" secondItem="117" secondAttribute="bottom" constant="12" id="CBk-cX-pk2"/>
|
||||
<constraint firstItem="22" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="23" secondAttribute="trailing" constant="12" id="EeC-NR-NYg"/>
|
||||
<constraint firstAttribute="trailing" secondItem="76" secondAttribute="trailing" constant="20" id="GdV-QF-Cdi"/>
|
||||
<constraint firstItem="76" firstAttribute="width" secondItem="22" secondAttribute="width" multiplier="0.8" priority="110" id="I8t-73-gX0"/>
|
||||
<constraint firstItem="117" firstAttribute="top" secondItem="89" secondAttribute="bottom" constant="12" id="IjI-ZH-LLg"/>
|
||||
<constraint firstItem="10" firstAttribute="width" secondItem="89" secondAttribute="width" id="KTa-HC-lmw"/>
|
||||
<constraint firstItem="22" firstAttribute="top" relation="greaterThanOrEqual" secondItem="89" secondAttribute="bottom" constant="12" id="KbD-kI-R4j"/>
|
||||
<constraint firstItem="117" firstAttribute="top" secondItem="fKC-QA-GZa" secondAttribute="bottom" priority="900" constant="8" id="M7E-UY-nWx"/>
|
||||
<constraint firstItem="fKC-QA-GZa" firstAttribute="top" secondItem="101" secondAttribute="bottom" constant="8" id="Mbz-C0-6Cx"/>
|
||||
<constraint firstItem="117" firstAttribute="leading" secondItem="23" secondAttribute="leading" id="Nm4-V1-7X0"/>
|
||||
<constraint firstItem="17" firstAttribute="top" secondItem="101" secondAttribute="bottom" constant="8" id="OWv-9a-x37"/>
|
||||
<constraint firstItem="89" firstAttribute="width" secondItem="101" secondAttribute="width" id="Q6u-cf-5Tx"/>
|
||||
<constraint firstItem="76" firstAttribute="top" secondItem="89" secondAttribute="bottom" priority="500" constant="19" id="QPU-Ih-z9h"/>
|
||||
<constraint firstItem="18" firstAttribute="leading" secondItem="23" secondAttribute="leading" id="SM7-zA-jDZ"/>
|
||||
<constraint firstItem="23" firstAttribute="leading" secondItem="117" secondAttribute="leading" id="OXY-8u-ljs"/>
|
||||
<constraint firstItem="23" firstAttribute="leading" secondItem="10" secondAttribute="leading" constant="1" id="RRB-n5-xid"/>
|
||||
<constraint firstItem="76" firstAttribute="leading" secondItem="22" secondAttribute="trailing" constant="12" id="VQk-Ut-ggj"/>
|
||||
<constraint firstItem="76" firstAttribute="trailing" secondItem="89" secondAttribute="trailing" id="Vaw-cD-5Li"/>
|
||||
<constraint firstItem="17" firstAttribute="width" relation="lessThanOrEqual" secondItem="89" secondAttribute="width" id="XXU-Tj-ytp"/>
|
||||
<constraint firstItem="7" firstAttribute="top" secondItem="6" secondAttribute="top" constant="20" id="alH-AL-5RD"/>
|
||||
<constraint firstItem="22" firstAttribute="baseline" secondItem="23" secondAttribute="baseline" id="ayY-6b-JGg"/>
|
||||
<constraint firstItem="76" firstAttribute="baseline" secondItem="22" secondAttribute="baseline" id="dIR-3Q-wQx"/>
|
||||
<constraint firstAttribute="bottom" secondItem="76" secondAttribute="bottom" constant="19" id="gcR-Kl-Wlq"/>
|
||||
<constraint firstItem="89" firstAttribute="top" secondItem="17" secondAttribute="bottom" constant="5" id="i9D-OK-Rit"/>
|
||||
<constraint firstAttribute="trailing" secondItem="101" secondAttribute="trailing" constant="22" id="k7p-HC-x7i"/>
|
||||
<constraint firstItem="fKC-QA-GZa" firstAttribute="leading" secondItem="23" secondAttribute="leading" constant="-1" id="nVW-Qt-8JE"/>
|
||||
<constraint firstAttribute="trailing" secondItem="10" secondAttribute="trailing" constant="22" id="oQx-Oc-awc"/>
|
||||
<constraint firstItem="76" firstAttribute="width" secondItem="23" secondAttribute="width" priority="109" id="pLI-z3-P0b"/>
|
||||
<constraint firstItem="89" firstAttribute="leading" secondItem="17" secondAttribute="leading" constant="2" id="qXk-jk-ol1"/>
|
||||
<constraint firstItem="fKC-QA-GZa" firstAttribute="leading" secondItem="10" secondAttribute="leading" id="qQ9-OJ-06z"/>
|
||||
<constraint firstItem="101" firstAttribute="top" secondItem="10" secondAttribute="bottom" constant="8" id="r7Q-z5-jkx"/>
|
||||
<constraint firstItem="10" firstAttribute="top" secondItem="6" secondAttribute="top" constant="15" id="rXd-o0-WQQ"/>
|
||||
<constraint firstItem="117" firstAttribute="width" secondItem="89" secondAttribute="width" id="tJi-eu-fpg"/>
|
||||
<constraint firstAttribute="trailing" secondItem="117" secondAttribute="trailing" constant="21" id="sHI-Hm-eSA"/>
|
||||
<constraint firstItem="7" firstAttribute="leading" secondItem="6" secondAttribute="leading" constant="22" id="zSE-lw-Ggj"/>
|
||||
</constraints>
|
||||
</view>
|
||||
|
||||
Vendored
+6
-5
@@ -56,6 +56,10 @@
|
||||
/* the unit for kilobytes */
|
||||
"KB" = "KB";
|
||||
|
||||
/* Alternative name for "Install" button if we have a paid update or other update
|
||||
without a download but with a URL. */
|
||||
"Learn More..." = "Learn More…";
|
||||
|
||||
/* the unit for megabytes */
|
||||
"MB" = "MB";
|
||||
|
||||
@@ -68,6 +72,8 @@
|
||||
/* Message that is optionally shown at startup to allow users to turn on/off update checks. */
|
||||
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.";
|
||||
|
||||
"The update is improperly signed." = "The update is improperly signed.";
|
||||
|
||||
"Update Error!" = "Update Error!";
|
||||
|
||||
"Updating %@" = "Updating %@";
|
||||
@@ -77,8 +83,3 @@
|
||||
|
||||
/* Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates. */
|
||||
"You're up-to-date!" = "You’re up-to-date!";
|
||||
|
||||
/* Alternative name for "Install" button if we have a paid update or other update
|
||||
without a download but with a URL. */
|
||||
"Learn More..." = "Learn More…";
|
||||
|
||||
Vendored
+2
-3
@@ -58,11 +58,11 @@
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="106" y="294" width="84" height="14"/>
|
||||
<rect key="frame" x="106" y="294" width="92" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="100" constant="100" id="gkn-FW-9aC"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="リリースノート:" usesSingleLineMode="YES" id="170">
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="リリースノート:" usesSingleLineMode="YES" id="170">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -222,7 +222,6 @@ DQ
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="50"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="155" y="147"/>
|
||||
</window>
|
||||
<userDefaultsController representsSharedInstance="YES" id="93" userLabel="Shared Defaults"/>
|
||||
</objects>
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" tag="1" id="13">
|
||||
<rect key="frame" x="300" y="12" width="105" height="32"/>
|
||||
<rect key="frame" x="318" y="12" width="105" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
|
||||
<buttonCell key="cell" type="push" title="自動で確認" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" tag="1" inset="2" id="176">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@@ -42,7 +42,7 @@ DQ
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" id="14">
|
||||
<rect key="frame" x="162" y="12" width="105" height="32"/>
|
||||
<rect key="frame" x="213" y="12" width="105" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
|
||||
<buttonCell key="cell" type="push" title="確認しない" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="177">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@@ -58,7 +58,7 @@ Gw
|
||||
<textField verticalHuggingPriority="750" id="32">
|
||||
<rect key="frame" x="104" y="114" width="289" height="34"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="アップデートを自動で確認させますか?" id="178">
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="アップデートを自動で確認しますか?" id="178">
|
||||
<font key="font" size="13" name="AquaKana-Bold"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
|
||||
Vendored
+26
-16
@@ -1,31 +1,35 @@
|
||||
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ がインストールされました。次回の %1$@ 起動時から使用可能になります。今すぐ再起動しますか?";
|
||||
"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ がダウンロードされました! これは重要なアップデートです。今すぐ %1$@ をインストールして再起動しますか?";
|
||||
|
||||
"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ は、ディスクイメージや光学式ドライブなどのリードオンリーボリュームから起動している場合、アップデートできません。%1$@ をアプリケーションフォルダに移動し、そこから再起動した後、やり直して下さい。";
|
||||
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ がダウンロードされました! 今すぐ %1$@ をインストールして再起動しますか?";
|
||||
|
||||
"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ は、ディスクイメージや光学式ドライブなどの読み出し専用ボリュームから起動している場合アップデートできません。%1$@ をアプリケーションフォルダに移動し、そこから再起動したあとやり直してください。";
|
||||
|
||||
"%@ %@ is currently the newest version available." = "%1$@ %2$@ は現在入手できる最新バージョンです。";
|
||||
|
||||
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ が入手できます(使用中のバージョンは %3$@ です)。今すぐダウンロードしますか?";
|
||||
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ が入手できます(使用中のバージョンは %3$@ です)。今すぐダウンロードしますか?";
|
||||
|
||||
"%@ downloaded" = "%@ ダウンロード済み";
|
||||
|
||||
"%@ of %@" = "%1$@ / %2$@";
|
||||
|
||||
"A new version of %@ is available!" = "新しいバージョンの %@ が入手できます。";
|
||||
"A new version of %@ is available!" = "新しいバージョンの %@ が入手できます!";
|
||||
|
||||
"A new version of %@ is ready to install!" = "新しいバージョンの %@ が今すぐインストールできます!";
|
||||
|
||||
"An error occurred in retrieving update information. Please try again later." = "アップデート情報の取得中にエラーが発生しました。後ほど改めてお試しください。";
|
||||
"An error occurred in retrieving update information. Please try again later." = "アップデート情報の取得中にエラーが発生しました。あとでやり直してください。";
|
||||
|
||||
"An error occurred while downloading the update. Please try again later." = "アップデートをダウンロード中にエラーが発生しました。後でもう一度やり直してください。";
|
||||
"An error occurred while downloading the update. Please try again later." = "アップデートをダウンロード中にエラーが発生しました。あとでやり直してください。";
|
||||
|
||||
"An error occurred while extracting the archive. Please try again later." = "アーカイブの展開中にエラーが発生しました。後ほど改めてお試しください。";
|
||||
"An error occurred while extracting the archive. Please try again later." = "アーカイブの展開中にエラーが発生しました。あとでやり直してください。";
|
||||
|
||||
"An error occurred while installing the update. Please try again later." = "アップデートをインストール中にエラーが発生しました。後でもう一度やり直してください。";
|
||||
"An error occurred while installing the update. Please try again later." = "アップデートをインストール中にエラーが発生しました。あとでやり直してください。";
|
||||
|
||||
"An error occurred while parsing the update feed." = "アップデートフィードを解析中にエラーが発生しました。";
|
||||
|
||||
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "%1$@ を再起動中にエラーが発生しましたが、次回 %1$@ の実行時に新しいバージョンが利用できます。";
|
||||
|
||||
"An important update to %@ is ready to install" = "%@ の重要なアップデートがインストールできます。";
|
||||
|
||||
/* the unit for bytes */
|
||||
"B" = "B";
|
||||
|
||||
@@ -52,24 +56,30 @@
|
||||
/* the unit for kilobytes */
|
||||
"KB" = "KB";
|
||||
|
||||
/* Alternative name for "Install" button if we have a paid update or other update
|
||||
without a download but with a URL. */
|
||||
"Learn More..." = "詳しい情報…";
|
||||
|
||||
/* the unit for megabytes */
|
||||
"MB" = "MB";
|
||||
|
||||
/* OK button. */
|
||||
"OK" = "OK";
|
||||
|
||||
/* Status message on progress window once download has finished. */
|
||||
"Ready to Install" = "インストールできます";
|
||||
|
||||
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = " %1$@ のアップデートを自動で確認しますか? アップデートは、%1$@ メニューから手動でいつでも確認することができます。";
|
||||
/* Message that is optionally shown at startup to allow users to turn on/off update checks. */
|
||||
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = " %1$@ のアップデートを自動で確認しますか? アップデートは %1$@ メニューから手動でいつでも確認することができます。";
|
||||
|
||||
"Update Error!" = "アップデートエラー";
|
||||
"The update is improperly signed." = "このアップデートは無効な署名が含まれています。";
|
||||
|
||||
"Update Error!" = "アップデートエラー!";
|
||||
|
||||
"Updating %@" = "%@ をアップデート中";
|
||||
|
||||
"You already have the newest version of %@." = "既に最新バージョンの %@ を使用しています。";
|
||||
/* 'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI) */
|
||||
"You already have the newest version of %@." = "すでに最新バージョンの %@ を使用しています。";
|
||||
|
||||
/* Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates. */
|
||||
"You're up-to-date!" = "最新版を使用しています!";
|
||||
|
||||
/* Alternative name for "Install" button if we have a paid update or other update
|
||||
without a download but with a URL. */
|
||||
|
||||
"Learn More..." = "詳しい情報…";
|
||||
@@ -27,6 +27,6 @@
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://sparkle-project.org/files/sparkletestcast.xml</string>
|
||||
<key>SUPublicDSAKeyFile</key>
|
||||
<string>dsa_pub.pem</string>
|
||||
<string>test_app_only_dsa_pub.pem</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,20 +0,0 @@
|
||||
-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIDPgIBAAKCAQEA9lmy8fAXdW9b6fBXQ6Us5B2dLZV+cR685tFlhPSKJDpicP1F
|
||||
pNRkGESZwPFJbnxUyVeHWVS9yLeMcKqllhcjd+i1oEFKX7LPXk5+zO745OwVWHIe
|
||||
0DLOIxhJ0mJHm7mH1YVGZYOVVYkPt+0Y/hDbQVK5DycSGAhgDiCZ+Obl+aDSD2xJ
|
||||
RZGnVOpu83dYJ/CoUYCHqWtpN4gW5Bbgm8Uz0/2qiyPjFvJEeI1yE04AZA3sOg1y
|
||||
1S/UrCbqeC3gBIs0xsskwWOW3zCWjvDWgfPrj65At0mVfq/yyGgXJlN71X5sONxR
|
||||
swZSbRn5T2i/BJPZUStWks5Nxq+7T3WmnaPbTwIVAJp+BByoy95V3x8wZg0q66eR
|
||||
ufiJAoIBABbxkX6C9Lt8zeDvvIpk8X4kmHBVIwVJcuICJTVzOAIBZsvFhPnYmUYe
|
||||
v93oPgjtAdYqPrYZlNrExQG1e7B1bhmgaT8hbXL6whxhqRHKlsJsboVHNQs3qAbx
|
||||
sOLvJnwgb3FD4xX4ZZSSRXSIGk62FxcaoLG+mSlirGM/SY4yZDpURSJUX6MHdUZa
|
||||
qHWWGL3b31pz3d9h6SPYv6H4T3ZReVtn+dXYh/41SWkQqEyhAsHGBvqpDwuYJCCI
|
||||
Mwuvwz0U/KcwiydDaFo900MC9S33zEpk/YUxgA9YsiY5+UvWSy5M/yvkKBkvkb+I
|
||||
G6DAMWtApWu0fDcLV6jA9JKXmcAwAIECggEBAPC0OJEnLkOwU1Ehop7o2XJbWDKN
|
||||
giFt44IO3l9gx1fu05HrieDbwAJTkRK7qNEA0yk1iMT2hMHHbwLRNddEsOJuUd7o
|
||||
iyKwqwkmCQ2Q1zYPBR09wag9NEr8xLSTQJCw9CpxTRSH+9hc1DeuwkwAnTEn7JiW
|
||||
WbcxVCRtmtaUlN7+dTozxqGJHpYF6WsqHMeuG7Ixnyf6he8Fz8mjxnrc7/l73gFL
|
||||
Q+IZvUSjzh2zqtqaejtcmlNcT+fGmEFKxpcLB3JP3uu8PN8MbS/R6j191f1ovuM9
|
||||
U4MO3RuT4xJF0OlwyWAnOEik1S1p+tNQciQ/Ipv8Ff3DDBct9YZPPlNGi+ICFHHD
|
||||
tP5yX7hMTJIykGaMuM44KJMM
|
||||
-----END DSA PRIVATE KEY-----
|
||||
@@ -10,5 +10,5 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
return NSApplicationMain(argc, (const char **)argv);
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// SUDSAVerifierTest.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Kornel on 25/07/2014.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "SUDSAVerifier.h"
|
||||
|
||||
@interface SUDSAVerifierTest : XCTestCase
|
||||
@property NSString *testDir, *testFile, *pubKeyFile;
|
||||
@end
|
||||
|
||||
@implementation SUDSAVerifierTest
|
||||
@synthesize testDir, testFile, pubKeyFile;
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
self.testDir = [@"" __FILE__ stringByDeletingLastPathComponent];
|
||||
self.testFile = [self.testDir stringByAppendingPathComponent:@"/signed_test_file"];
|
||||
self.pubKeyFile = [self.testDir stringByAppendingPathComponent:@"test_pubkey"];
|
||||
}
|
||||
|
||||
- (void)testVerifyFileAtPath
|
||||
{
|
||||
NSData *pubKey = [NSData dataWithContentsOfFile:self.pubKeyFile];
|
||||
XCTAssertNotNil(pubKey, @"Public key must be readable");
|
||||
|
||||
NSString *validSig = @"MCwCFCIHCIYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
|
||||
XCTAssertTrue([self checkFile:self.testFile
|
||||
withPubKey:pubKey
|
||||
signature:validSig],
|
||||
@"Expected valid signature");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withPubKey:[NSData dataWithBytes:"lol" length:3]
|
||||
signature:validSig],
|
||||
@"Invalid pubkey");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.pubKeyFile
|
||||
withPubKey:pubKey
|
||||
signature:validSig],
|
||||
@"Wrong file checked");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withPubKey:pubKey
|
||||
signature:@"MCwCFCIHCiYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ=="],
|
||||
@"Expected invalid signature");
|
||||
|
||||
XCTAssertTrue([self checkFile:self.testFile
|
||||
withPubKey:pubKey
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8c="],
|
||||
@"Expected valid signature");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withPubKey:pubKey
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8"],
|
||||
@"Expected invalid signature");
|
||||
}
|
||||
|
||||
- (BOOL)checkFile:(NSString *)aFile withPubKey:(NSData *)pubKey signature:(NSString *)sigString
|
||||
{
|
||||
SUDSAVerifier *v = [[SUDSAVerifier alloc] initWithPublicKeyData:pubKey];
|
||||
|
||||
NSData *sig = [[NSData alloc] initWithBase64Encoding:sigString];
|
||||
|
||||
return [v verifyFileAtPath:aFile signature:sig];
|
||||
}
|
||||
|
||||
- (void)testValidatePath
|
||||
{
|
||||
NSString *pubkey = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
|
||||
XCTAssertTrue([SUDSAVerifier validatePath:self.testFile
|
||||
withEncodedDSASignature:@"MC0CFFMF3ha5kjvrJ9JTpTR8BenPN9QUAhUAzY06JRdtP17MJewxhK0twhvbKIE="
|
||||
withPublicDSAKey:pubkey],
|
||||
@"Expected valid signature");
|
||||
}
|
||||
|
||||
@end
|
||||
+19
-21
@@ -11,29 +11,27 @@
|
||||
#import "SUUpdater.h"
|
||||
|
||||
@interface SUUpdaterTest : XCTestCase <SUUpdaterDelegate>
|
||||
|
||||
@property (strong) NSOperationQueue *queue;
|
||||
@property (strong) SUUpdater *updater;
|
||||
@end
|
||||
|
||||
@implementation SUUpdaterTest
|
||||
{
|
||||
NSOperationQueue *queue;
|
||||
SUUpdater *updater;
|
||||
}
|
||||
|
||||
@synthesize queue;
|
||||
@synthesize updater;
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
queue = [[NSOperationQueue alloc] init];
|
||||
updater = [[SUUpdater alloc] init];
|
||||
updater.delegate = self;
|
||||
self.queue = [[NSOperationQueue alloc] init];
|
||||
self.updater = [[SUUpdater alloc] init];
|
||||
self.updater.delegate = self;
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
[updater release];
|
||||
updater = nil;
|
||||
[queue release];
|
||||
queue = nil;
|
||||
self.updater = nil;
|
||||
self.queue = nil;
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
@@ -44,36 +42,36 @@
|
||||
|
||||
- (void)testFeedURL
|
||||
{
|
||||
[updater feedURL]; // this WON'T throw
|
||||
[self.updater feedURL]; // this WON'T throw
|
||||
|
||||
[queue addOperationWithBlock:^{
|
||||
[self.queue addOperationWithBlock:^{
|
||||
XCTAssertTrue(![NSThread isMainThread]);
|
||||
@try {
|
||||
[updater feedURL];
|
||||
[self.updater feedURL];
|
||||
XCTFail(@"feedURL did not throw an exception when called on a secondary thread");
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"%@", exception);
|
||||
}
|
||||
}];
|
||||
[queue waitUntilAllOperationsAreFinished];
|
||||
[self.queue waitUntilAllOperationsAreFinished];
|
||||
}
|
||||
|
||||
- (void)setTestFeedURL
|
||||
- (void)testSetTestFeedURL
|
||||
{
|
||||
[updater setFeedURL:[NSURL URLWithString:@""]]; // this WON'T throw
|
||||
[self.updater setFeedURL:[NSURL URLWithString:@""]]; // this WON'T throw
|
||||
|
||||
[queue addOperationWithBlock:^{
|
||||
[self.queue addOperationWithBlock:^{
|
||||
XCTAssertTrue(![NSThread isMainThread]);
|
||||
@try {
|
||||
[updater setFeedURL:[NSURL URLWithString:@""]];
|
||||
[self.updater setFeedURL:[NSURL URLWithString:@""]];
|
||||
XCTFail(@"setFeedURL: did not throw an exception when called on a secondary thread");
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"%@", exception);
|
||||
}
|
||||
}];
|
||||
[queue waitUntilAllOperationsAreFinished];
|
||||
[self.queue waitUntilAllOperationsAreFinished];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1 @@
|
||||
Hello World!
|
||||
@@ -0,0 +1,36 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIGOjCCBC0GByqGSM44BAEwggQgAoICAQCHyAu13F9I72JZzN9KgVhrprKnRH7n
|
||||
dJJP5ZVHaSqm5PbRmHbnT06DGMxloZc8Nd5QWwG6N+5O1I9ZZjnIrc9Qzodho8hM
|
||||
KNInrfCEy/lTHjydvQvYG2LitbknapgGTf57BWEIYSiAQyP8Gs6lTVZmGrqSJdRC
|
||||
Kdt29OmFKLhWVn5hm2nx7PCbRT7FzrRyX8jkjCUKSeI/s1j3jpjFT5nGutAsSYNS
|
||||
Y/ifH1/IRejv9kRUEWM7qEU/ue3C18qCoDsmTSQVh+E1MIBWqeaWWAGrw7JO4cxR
|
||||
cgR6eeDYp8plTw//e9dSn1u/6ArnQ4QAoZP8Q6MfJMABgg07lltRIQYiXnUNPE4c
|
||||
xzMQ6kxbKLBi2VyeKm/mQ5oO6PH+59Lw0Q1YhchAXCO171fx2s4W2UGcIjdNbyhs
|
||||
My5iSEICwXQQgAvTEC08An8aYi5waEpQ1fnnkQcawTgRoBL2gMNsQOkZdERbJr2X
|
||||
zNJfLwGoDnNJTD8V4FCAeHieOAqmlGsqRc7mKPq2EVW7GH6vzWBJbZc71rmk7EwY
|
||||
2zvpR9aFam71ivmFgLYwLrRef3vd+AGbIc2WOcIADJ9JIa6HF1gK8LSym/t+/2ws
|
||||
fQ1FHpjHmYZICJqac1SQ6KZhMz9q35yKqBSaNmiv+mXBg7W6Jfckjg8mGgxvTdL+
|
||||
VDRDlK9K6bxClwIVAPd9bTMe17hl3ipR0X6O2UOmt799AoICABPfIvExHzdmJK+G
|
||||
kx+o28PNNw9ZAte2RxZWm8b0m9MW+jdeWDrhGbbk7nVJn6i6xaaRgJDWuZnKUQbC
|
||||
0WwjOm9fXnjBmnQhacJu0RGyr/b+akzZ4Y/7N+SBxRjasLVTFd+msQ2NE1PkXps5
|
||||
rhJWVMu9R9xp0qR/e+rh/Cax7nSq5UNAqSy9gzHkOhjS7s6UJ1yfCEO5Xfcvb7ND
|
||||
RpLIeBYbLT3OSkSd6kkFvMtb0Sl/WZ7z88flkdNGbutAcJVQzBcfQIwCuXyOYzUr
|
||||
8TcIB5j4c19MN9yfkykgemieC0uz/xzgtZt6g6bFfQNONmJ0YGoEPkz1GftI6dx/
|
||||
324vh4KhLfBjKDKFB8Pt9JKI9nQA7P10GlwWeA+IpSTzjlJq3x35u220K7tc/5xr
|
||||
TDMEftBemn/dvb/bJ9h+iSciZ7EcnN2RXB7SfykUAohE9DdEUlmjip6DYLP+hSN2
|
||||
oHiVmDVjv3XEGYQfATuxQmwcveHTYZmPId8XF2wkGiy6w0BY0NN+4oEuZga4YvEK
|
||||
3MVF2VEzM0onFzNgszwb+KaUfcA+eycthidca+sJzmOGAMWCx/vydNryMcWVXABF
|
||||
IRxbZVaXHCWf1RhAf0jcsiz9+JIuScAB2J26Oy2shPGOmesvuUHeUTqzvEJ2G77j
|
||||
k9Mps+1fbzySKX3PQEwA/qQ11qT6A4ICBQACggIAbDXVjXtIxAM4TSt9FSep+H1j
|
||||
yRoEXgisf5Q6eU6I7Wf6kAoW6bHw76S/OHgcMBYX7Z42kbVbna/rIAVfHnfrAaZY
|
||||
ygYVqbxTKdhi0c8IxR2qyF9Z5UK68C/EP0SHjHJrFRAnYgwkqvJXbemHFB4c0Ds1
|
||||
iIL47Kas8o/WvLpT1VzlHXFyFKvRxNMdeJsy8/LBSrQpRUiKcJFM2lg+O8cNWsRd
|
||||
kHTeWnjLrZT2rpPUIkSQZdbR16VBI8nS4pYpzdZ/N2zy+2S5dup7jMNtnLbXVT3X
|
||||
AjSjiYHRZPQUnX0pG3qA0BzDuA0U3MdBs8Wf7YhGd8XLbAfdo5zPSM9GimJrGH0s
|
||||
q4XKLHAEXUPfSuDGOdG8l990MujcRrewocwX5La1X/Nc4TDClCPUOVbf1aqy7LXY
|
||||
TB1M+nHvTb5HhtIrZYSHmsdpWlcLj5mYde/nvFXmNu3RNVCLhMzQDV9S/U1hqNcH
|
||||
m/BX2VTJ0xqhFIlA5UVrKZpnAEISKcFjwmZo7GuA1ENw2vhuvswjfYQ3OMfEr258
|
||||
0b1tKNMWrkbCgHdALjT/VdRUtte7RyGvsMccUHu6MHPowFRxbT3lWUqj1LKdZYnT
|
||||
uERL4E1J2VIP1/x2upPPWl/wbQjxplsRQrSY+cQCfWM22Wtilouh+CdEc+1DNKs/
|
||||
bKZWFUcty/GYmXtxTTk=
|
||||
-----END PUBLIC KEY-----
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#define NTSYNCHRONOUSTASK_H
|
||||
|
||||
@interface NTSynchronousTask : NSObject
|
||||
@property (readonly, retain) NSData *output;
|
||||
@property (readonly, strong) NSData *output;
|
||||
@property (readonly) int result;
|
||||
|
||||
// pass nil for directory if not needed
|
||||
|
||||
+18
-35
@@ -14,10 +14,10 @@
|
||||
#import "NTSynchronousTask.h"
|
||||
|
||||
@interface NTSynchronousTask ()
|
||||
@property (retain) NSTask *task;
|
||||
@property (retain) NSPipe *outputPipe;
|
||||
@property (retain) NSPipe *inputPipe;
|
||||
@property (readwrite, retain) NSData *output;
|
||||
@property (strong) NSTask *task;
|
||||
@property (strong) NSPipe *outputPipe;
|
||||
@property (strong) NSPipe *inputPipe;
|
||||
@property (readwrite, strong) NSData *output;
|
||||
@property (getter = isDone) BOOL done;
|
||||
@property (readwrite) int result;
|
||||
@end
|
||||
@@ -47,9 +47,9 @@
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
self.task = [[[NSTask alloc] init] autorelease];
|
||||
self.outputPipe = [[[NSPipe alloc] init] autorelease];
|
||||
self.inputPipe = [[[NSPipe alloc] init] autorelease];
|
||||
self.task = [[NSTask alloc] init];
|
||||
self.outputPipe = [[NSPipe alloc] init];
|
||||
self.inputPipe = [[NSPipe alloc] init];
|
||||
|
||||
self.task.standardInput = self.inputPipe;
|
||||
self.task.standardOutput = self.outputPipe;
|
||||
@@ -65,13 +65,6 @@
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
self.task = nil;
|
||||
self.outputPipe = nil;
|
||||
self.inputPipe = nil;
|
||||
self.output = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
|
||||
@@ -132,34 +125,30 @@
|
||||
|
||||
+ (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
|
||||
{
|
||||
NSData* result = nil;
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
@autoreleasepool {
|
||||
NSData* result = nil;
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
@try {
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:toolPath directory:currentDirectory withArgs:args input:input];
|
||||
|
||||
if ([task result] == 0) {
|
||||
result = [[task output] retain];
|
||||
result = [task output];
|
||||
}
|
||||
|
||||
[task release];
|
||||
}
|
||||
@catch (NSException *) { }
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// retained above
|
||||
return [result autorelease];
|
||||
}
|
||||
|
||||
|
||||
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData**)outData
|
||||
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData*__autoreleasing *)outData
|
||||
{
|
||||
int taskResult = 0;
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
@autoreleasepool {
|
||||
int taskResult = 0;
|
||||
if (outData) {
|
||||
*outData = nil;
|
||||
}
|
||||
@@ -171,21 +160,15 @@
|
||||
|
||||
taskResult = [task result];
|
||||
if (outData) {
|
||||
*outData = [[task output] retain];
|
||||
*outData = [task output];
|
||||
}
|
||||
|
||||
[task release];
|
||||
|
||||
} @catch (NSException *) {
|
||||
taskResult = errCppGeneral;
|
||||
}
|
||||
|
||||
|
||||
return taskResult;
|
||||
}
|
||||
// retained above
|
||||
if (outData) {
|
||||
[*outData autorelease];
|
||||
}
|
||||
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user