mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Rename SUUpdater -> SPUUpdater & add SUUpdater for backwards compatibility
New classes will soon be prefixed with "SPU" I still need to look into adding a compatibility layer for -updater:willInstallUpdateOnQuit:immediateInstallationInvocation: and possibly deprecating no-DSA instead of outright rejecting it.
This commit is contained in:
1 parent
c811db1e67
commit
4f285d2245
19 files changed
+1318
-945
No files matched your search
@@ -76,8 +76,8 @@
|
||||
61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A2279A0D1CEE7600430CCD /* SUSystemProfiler.h */; settings = {ATTRIBUTES = (); }; };
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */; };
|
||||
61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; };
|
||||
61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */; };
|
||||
61B5F8ED09C4CE3C00B25A18 /* SPUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5F8E309C4CE3C00B25A18 /* SPUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
61B5F8EE09C4CE3C00B25A18 /* SPUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E409C4CE3C00B25A18 /* SPUUpdater.m */; };
|
||||
61B5F90F09C4CF3A00B25A18 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */; };
|
||||
61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 61B5F92C09C4CFD800B25A18 /* MainMenu.xib */; };
|
||||
@@ -249,8 +249,6 @@
|
||||
726E07B41CAF08D6001A286B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B31CAF08D6001A286B /* main.m */; };
|
||||
726E07BF1CAF0C6C001A286B /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
726E07C01CAF15B7001A286B /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
|
||||
726E4A0E1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0D1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
726E4A101C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0F1C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
726E4A1B1C86C88F00C57C6A /* TestAppHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E4A1A1C86C88F00C57C6A /* TestAppHelper.m */; };
|
||||
726E4A1D1C86C88F00C57C6A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E4A1C1C86C88F00C57C6A /* main.m */; };
|
||||
726E4A211C86C88F00C57C6A /* TestAppHelper.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E4A161C86C88F00C57C6A /* TestAppHelper.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -323,6 +321,8 @@
|
||||
72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
72F94F5E1CC455B4002DEE68 /* org.sparkle-project.PersistentDownloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* org.sparkle-project.PersistentDownloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
72F94F5F1CC455B4002DEE68 /* org.sparkle-project.TemporaryDownloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 728638F31CAF5A5F00783084 /* org.sparkle-project.TemporaryDownloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */; };
|
||||
72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; };
|
||||
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; };
|
||||
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; };
|
||||
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; };
|
||||
@@ -756,8 +756,8 @@
|
||||
61AAE84F0A321AF700D8810D /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
61AAE8590A321B0400D8810D /* fr */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
61AAE8710A321F7700D8810D /* nl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SUUpdater.h; sourceTree = "<group>"; };
|
||||
61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SUUpdater.m; sourceTree = "<group>"; };
|
||||
61B5F8E309C4CE3C00B25A18 /* SPUUpdater.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SPUUpdater.h; sourceTree = "<group>"; };
|
||||
61B5F8E409C4CE3C00B25A18 /* SPUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SPUUpdater.m; sourceTree = "<group>"; };
|
||||
61B5F8F609C4CEB300B25A18 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sparkle Test App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestApplication-Info.plist"; sourceTree = "<group>"; };
|
||||
@@ -932,8 +932,6 @@
|
||||
726E07B51CAF08D6001A286B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
726E07C11CAF1E79001A286B /* ConfigInstallerLauncher.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigInstallerLauncher.xcconfig; sourceTree = "<group>"; };
|
||||
726E07EF1CAF37BD001A286B /* org.sparkle-project.PersistentDownloader.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "org.sparkle-project.PersistentDownloader.xpc"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
726E4A0D1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUStandardUserDriverUIDelegate.h; sourceTree = "<group>"; };
|
||||
726E4A0F1C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUStandardUserDriverRemoteDelegate.h; sourceTree = "<group>"; };
|
||||
726E4A111C86C44A00C57C6A /* Sparkle-Test-App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Sparkle-Test-App.entitlements"; sourceTree = "<group>"; };
|
||||
726E4A161C86C88F00C57C6A /* TestAppHelper.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = TestAppHelper.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
726E4A181C86C88F00C57C6A /* TestAppHelperProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestAppHelperProtocol.h; sourceTree = "<group>"; };
|
||||
@@ -1021,6 +1019,8 @@
|
||||
72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppHelperDebug.xcconfig; sourceTree = "<group>"; };
|
||||
72F94F561CC44DE1002DEE68 /* SUXPCServiceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUXPCServiceInfo.h; sourceTree = "<group>"; };
|
||||
72F94F571CC44DE1002DEE68 /* SUXPCServiceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUXPCServiceInfo.m; sourceTree = "<group>"; };
|
||||
72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdater.h; sourceTree = "<group>"; };
|
||||
72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdater.m; sourceTree = "<group>"; };
|
||||
8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = "<group>"; };
|
||||
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestWebServer.h; sourceTree = "<group>"; };
|
||||
@@ -1315,6 +1315,7 @@
|
||||
729746481C91483B00FC134E /* IPC */,
|
||||
089C1665FE841158C02AAC07 /* Framework Resources */,
|
||||
61B5F8F309C4CE5900B25A18 /* Other Sources */,
|
||||
72F9EBE41D519425004AC8B6 /* Deprecated */,
|
||||
61F83F6E0DBFE07A006FDD30 /* Update Control */,
|
||||
61299B3A09CB056100B7442F /* User Interface */,
|
||||
);
|
||||
@@ -1569,8 +1570,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
61CFB2C20E38496B007A1735 /* Drivers */,
|
||||
61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */,
|
||||
61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */,
|
||||
61B5F8E309C4CE3C00B25A18 /* SPUUpdater.h */,
|
||||
61B5F8E409C4CE3C00B25A18 /* SPUUpdater.m */,
|
||||
726E078B1CA891E9001A286B /* SUUpdaterSettings.h */,
|
||||
726E078C1CA891E9001A286B /* SUUpdaterSettings.m */,
|
||||
72A6F9891C94E2D6005F404C /* SUUpdaterDelegate.h */,
|
||||
@@ -1651,8 +1652,6 @@
|
||||
7246E0A11C83B685003B4E75 /* SUStandardUpdaterController.h */,
|
||||
7246E0A21C83B685003B4E75 /* SUStandardUpdaterController.m */,
|
||||
726E4A361C89116000C57C6A /* SUStandardUserDriverDelegate.h */,
|
||||
726E4A0D1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h */,
|
||||
726E4A0F1C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h */,
|
||||
725F97A71C8B42D700265BE4 /* SUStandardUserDriverProtocol.h */,
|
||||
725CB9581C7121830064365A /* SUStandardUserDriver.h */,
|
||||
725CB9591C7121830064365A /* SUStandardUserDriver.m */,
|
||||
@@ -1784,6 +1783,15 @@
|
||||
name = "XPC Services";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
72F9EBE41D519425004AC8B6 /* Deprecated */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */,
|
||||
72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */,
|
||||
);
|
||||
name = Deprecated;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
FA1941C40D94A6EA00DD942E /* Configurations */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1838,9 +1846,7 @@
|
||||
720E217B1D0D00BF003A311C /* SUUpdaterCycle.h in Headers */,
|
||||
72A6F98A1C94E2D6005F404C /* SUUpdaterDelegate.h in Headers */,
|
||||
726E4A371C89116000C57C6A /* SUStandardUserDriverDelegate.h in Headers */,
|
||||
726E4A0E1C86881600C57C6A /* SUStandardUserDriverUIDelegate.h in Headers */,
|
||||
725F97A81C8B42D700265BE4 /* SUStandardUserDriverProtocol.h in Headers */,
|
||||
726E4A101C86B5A200C57C6A /* SUStandardUserDriverRemoteDelegate.h in Headers */,
|
||||
721BC20E1D1CDE55002BC71E /* SULocalCacheDirectory.h in Headers */,
|
||||
72B767DA1C9CD2E400A07552 /* SUUIBasedUpdateDriver.h in Headers */,
|
||||
725CB95A1C7121830064365A /* SUStandardUserDriver.h in Headers */,
|
||||
@@ -1873,6 +1879,7 @@
|
||||
726E075C1CA3A6D6001A286B /* SUSecureCoding.h in Headers */,
|
||||
72B767E21C9CE90A00A07552 /* SUCoreBasedUpdateDriver.h in Headers */,
|
||||
72B09CE71CE6BCBD0052EF9E /* SUURLDownload.h in Headers */,
|
||||
72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */,
|
||||
61A225A40D1C4AC000430CCD /* SUStandardVersionComparator.h in Headers */,
|
||||
7229E1B91C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h in Headers */,
|
||||
7214B8811D456A8500CB5CED /* SUBundleIcon.h in Headers */,
|
||||
@@ -1886,7 +1893,7 @@
|
||||
724BB3871D32A167005D534A /* SUXPCInstallerConnection.h in Headers */,
|
||||
61B5FCDF09C52A9F00B25A18 /* SUUpdateAlert.h in Headers */,
|
||||
7267E5B11D3D8AD500D1BF90 /* SUMessageTypes.h in Headers */,
|
||||
61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */,
|
||||
61B5F8ED09C4CE3C00B25A18 /* SPUUpdater.h in Headers */,
|
||||
61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */,
|
||||
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */,
|
||||
7267E5E51D3D90AA00D1BF90 /* SUFileManager.h in Headers */,
|
||||
@@ -2806,6 +2813,7 @@
|
||||
728337A71C9E6FF40085AA99 /* SUProbeInstallStatus.m in Sources */,
|
||||
725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */,
|
||||
72B767DF1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.m in Sources */,
|
||||
72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */,
|
||||
72B767CF1C9B924900A07552 /* SUInstallerDriver.m in Sources */,
|
||||
720E217C1D0D00BF003A311C /* SUUpdaterCycle.m in Sources */,
|
||||
72A450541C69A68900D67EEA /* SUUpdatePermission.m in Sources */,
|
||||
@@ -2826,7 +2834,7 @@
|
||||
61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */,
|
||||
7267E5FE1D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */,
|
||||
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
|
||||
61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */,
|
||||
61B5F8EE09C4CE3C00B25A18 /* SPUUpdater.m in Sources */,
|
||||
72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */,
|
||||
726E075D1CA3A6D6001A286B /* SUSecureCoding.m in Sources */,
|
||||
7267E5B21D3D8AD500D1BF90 /* SUMessageTypes.m in Sources */,
|
||||
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// SPUUpdater.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
#import "SUUserDriver.h"
|
||||
|
||||
@class SUAppcastItem, SUAppcast;
|
||||
|
||||
@protocol SUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
/*!
|
||||
* Initializes a new SUUpdater instance
|
||||
*
|
||||
* This does not start the updater. To start it, see -[SUUpdater startUpdater:]
|
||||
*
|
||||
* Note that this is a normal initializer and doesn't implement the singleton pattern (i.e, instances aren't cached, so no surprises)
|
||||
* Hence you shouldn't create multiple live instances that target the same bundle.
|
||||
* However, this also means that updater instances can be deallocated, and that they will be torn down properly
|
||||
*
|
||||
* Related: See SUStandardUpdaterController which wraps a SUUpdater instance and is suitable for instantiating in nib files
|
||||
*
|
||||
* @param hostBundle The bundle that should be targetted for updating. This must not be nil.
|
||||
* @param userDriver The user driver that Sparkle uses for user update interaction
|
||||
* @param delegate The delegate for SUUpdater. This may be nil.
|
||||
*
|
||||
* This must be called on the main thread.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)delegate;
|
||||
|
||||
/*!
|
||||
* Starts the updater.
|
||||
*
|
||||
* This method checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
|
||||
* Other properties of this SUUpdater instance can be set before this method is invoked as well, such as automatic update checks.
|
||||
* If the configuration is valid, this method may bring up a permission prompt (if needed) for checking if the user wants automatic update checking.
|
||||
* This method then starts the regular update cycle if automatic update checks are enabled.
|
||||
*
|
||||
* @param error The error that is populated if this method fails. Pass NULL if not interested in the error information.
|
||||
* @return YES if the updater started otherwise NO with a populated error
|
||||
*/
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error;
|
||||
|
||||
@property (weak, readonly) id<SUUpdaterDelegate> delegate;
|
||||
@property (nonatomic, readonly) id<SUUserDriver> userDriver;
|
||||
|
||||
@property (readonly, strong) NSBundle *hostBundle;
|
||||
@property (strong, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
@property (nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
@property (nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
* The URL of the appcast used to download update information.
|
||||
*
|
||||
* This property must be called on the main thread.
|
||||
*/
|
||||
@property (copy) NSURL *feedURL;
|
||||
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
@property (copy) NSDictionary *httpHeaders;
|
||||
|
||||
@property (nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
Checks for updates, and displays progress while doing so
|
||||
|
||||
This is meant for users initiating an update check
|
||||
*/
|
||||
- (void)checkForUpdates;
|
||||
|
||||
/*!
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates. That is,
|
||||
it will display no UI unless it actually finds an update, in which case it
|
||||
proceeds as usual.
|
||||
|
||||
If the fully automated updating is turned on, however, this will invoke that
|
||||
behavior, and if an update is found, it will be downloaded and prepped for
|
||||
installation.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
*/
|
||||
@property (readonly, copy) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal timer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
@end
|
||||
Vendored
+770
@@ -0,0 +1,770 @@
|
||||
//
|
||||
// SPUUpdater.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUUpdater.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
#import "SUUpdaterSettings.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUUpdatePermission.h"
|
||||
#import "SUUpdateDriver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUSystemProfiler.h"
|
||||
#import "SUScheduledUpdateDriver.h"
|
||||
#import "SUProbingUpdateDriver.h"
|
||||
#import "SUUserInitiatedUpdateDriver.h"
|
||||
#import "SUAutomaticUpdateDriver.h"
|
||||
#import "SUProbeInstallStatus.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUXPCServiceInfo.h"
|
||||
#import "SUUpdaterCycle.h"
|
||||
#import "SUDownloadedUpdate.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
|
||||
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
|
||||
NSString *const SUUpdaterDidNotFindUpdateNotification = @"SUUpdaterDidNotFindUpdateNotification";
|
||||
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNotificationKey";
|
||||
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
|
||||
|
||||
@interface SPUUpdater () <SUUpdaterCycleDelegate>
|
||||
|
||||
@property (readonly, copy) NSURL *parameterizedFeedURL;
|
||||
|
||||
@property (nonatomic) id <SUUpdateDriver> driver;
|
||||
@property (nonatomic, weak) id delegator;
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) SUUpdaterSettings *updaterSettings;
|
||||
@property (nonatomic, readonly) SUUpdaterCycle *updaterCycle;
|
||||
@property (nonatomic) BOOL startedUpdater;
|
||||
@property (nonatomic, copy) void (^preStartedScheduledUpdateBlock)(void);
|
||||
@property (nonatomic, nullable) SUDownloadedUpdate *resumableUpdate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUUpdater
|
||||
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize delegator = _delegator;
|
||||
@synthesize userDriver = _userDriver;
|
||||
@synthesize userAgentString = customUserAgentString;
|
||||
@synthesize httpHeaders;
|
||||
@synthesize driver;
|
||||
@synthesize host = _host;
|
||||
@synthesize updaterSettings = _updaterSettings;
|
||||
@synthesize updaterCycle = _updaterCycle;
|
||||
@synthesize sparkleBundle = _sparkleBundle;
|
||||
@synthesize startedUpdater = _startedUpdater;
|
||||
@synthesize preStartedScheduledUpdateBlock = _preStartedScheduledUpdateBlock;
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
|
||||
#ifdef DEBUG
|
||||
+ (void)load
|
||||
{
|
||||
// We're using NSLog instead of SULog here because we don't want to start Sparkle's logger here,
|
||||
// and because this is not really an error, just a warning notice
|
||||
NSLog(@"WARNING: This is running a Debug build of Sparkle; don't use this in production!");
|
||||
}
|
||||
#endif
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)theDelegate
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self != nil) {
|
||||
// Use explicit class to use the correct bundle even when subclassed
|
||||
_sparkleBundle = [NSBundle bundleForClass:[SPUUpdater class]];
|
||||
|
||||
_host = [[SUHost alloc] initWithBundle:bundle];
|
||||
|
||||
_updaterSettings = [[SUUpdaterSettings alloc] initWithHostBundle:bundle];
|
||||
_updaterCycle = [[SUUpdaterCycle alloc] initWithDelegate:self];
|
||||
|
||||
_userDriver = userDriver;
|
||||
|
||||
_delegate = theDelegate;
|
||||
_delegator = self;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// To prevent subclasses from doing something bad based on older Sparkle code
|
||||
- (instancetype)initForBundle:(NSBundle *)__unused bundle
|
||||
{
|
||||
SULog(@"-[SUUpdater initForBundle:] is not implemented anymore.");
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
// To prevent trying to stick an SUUpdater in a nib or initializing it in an incorrect way
|
||||
- (instancetype)init
|
||||
{
|
||||
SULog(@"-[SUUpdater init] is not implemented. If you want to drop an updater into a nib, see SUStandardUpdaterController.");
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![self checkIfConfiguredProperly:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.startedUpdater = YES;
|
||||
[self startUpdateCycle];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)checkATSIssueForBundle:(NSBundle * _Nullable)bundle getBundleExists:(BOOL *)bundleExists
|
||||
{
|
||||
if (bundleExists != NULL) {
|
||||
*bundleExists = (bundle != nil);
|
||||
}
|
||||
|
||||
if (bundle == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return ([bundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
|
||||
}
|
||||
|
||||
- (BOOL)checkIfConfiguredProperly:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (self.sparkleBundle == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: @"SPUUpdater can't find Sparkle.framework it belongs to." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSURL *feedURL = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([[self hostBundle] bundleIdentifier] == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidHostBundleIdentifierError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot target a bundle that does not have a valid bundle identifier." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!self.host.validVersion) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidHostVersionError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot target a bundle that does not have a valid version." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
if (!hasPublicDSAKey) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, updates need to be signed with a DSA key. See Sparkle's documentation for more information." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
if (!servingOverHttps) {
|
||||
BOOL foundXPCTemporaryDownloaderService = NO;
|
||||
BOOL foundATSTemporaryIssue = [self checkATSIssueForBundle:SUXPCServiceBundle(@TEMPORARY_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCTemporaryDownloaderService];
|
||||
|
||||
BOOL foundXPCPersistentDownloaderService = NO;
|
||||
BOOL foundATSPersistentIssue = NO;
|
||||
if (!foundATSTemporaryIssue) {
|
||||
foundATSPersistentIssue = [self checkATSIssueForBundle:SUXPCServiceBundle(@PERSISTENT_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCPersistentDownloaderService];
|
||||
}
|
||||
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
BOOL foundATSMainBundleIssue = NO;
|
||||
if (!foundATSTemporaryIssue && !foundATSPersistentIssue && (!foundXPCTemporaryDownloaderService || !foundXPCPersistentDownloaderService)) {
|
||||
BOOL foundATSIssue = ([mainBundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
|
||||
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
|
||||
|
||||
if (updatingMainBundle) {
|
||||
// The only way we'll know for sure if there is an issue is if the main bundle is the same as the one we're updating
|
||||
// We don't want to generate false positives..
|
||||
foundATSMainBundleIssue = foundATSIssue;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundATSTemporaryIssue || foundATSPersistentIssue || foundATSMainBundleIssue) {
|
||||
// Just log a warning. Don't outright fail in case we are wrong (eg: app is linked on an old SDK where ATS doesn't take effect)
|
||||
SULog(@"The feed URL (%@) may need to change to use HTTPS.\nFor more information: https://sparkle-project.org/documentation/app-transport-security", [feedURL absoluteString]);
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)startUpdateCycle
|
||||
{
|
||||
BOOL shouldPrompt = NO;
|
||||
NSNumber *timeIntervalAtFirstLaunch = [self.host objectForUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
|
||||
NSDate *currentDate = [NSDate date];
|
||||
|
||||
// If the user has been asked about automatic checks, don't bother prompting
|
||||
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey]) {
|
||||
shouldPrompt = NO;
|
||||
}
|
||||
// If the developer wants to check for updates, we shouldn't bug the user about a prompt yet
|
||||
else if (self.preStartedScheduledUpdateBlock != nil) {
|
||||
shouldPrompt = NO;
|
||||
}
|
||||
// Does the delegate want to take care of the logic for when we should ask permission to update?
|
||||
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) {
|
||||
shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self.delegator];
|
||||
}
|
||||
// Has the user been asked already? And don't ask if the host has a default value set in its Info.plist.
|
||||
else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil) {
|
||||
// Now, we don't want to ask the user for permission to do a weird thing right when they install the app
|
||||
// We wait until another launch after a few hours have passed, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
|
||||
|
||||
if ([self.host objectForKey:SUPromptUserOnFirstLaunchKey] != nil) {
|
||||
shouldPrompt = YES;
|
||||
} else if (timeIntervalAtFirstLaunch != nil) {
|
||||
NSDate *firstLaunchDate = [NSDate dateWithTimeIntervalSinceReferenceDate:timeIntervalAtFirstLaunch.doubleValue];
|
||||
NSTimeInterval intervalSinceFirstLaunch = [currentDate timeIntervalSinceDate:firstLaunchDate];
|
||||
// We want to prompt if more than (or equal to) 'SUDefaultUpdatePermissionPromptInterval' seconds have passed since the first launch
|
||||
// If the first launch time is after (or equal to) our current date, then something may have gone wrong in the system - prompt to be on the safe side
|
||||
if (intervalSinceFirstLaunch >= SUDefaultUpdatePermissionPromptInterval || intervalSinceFirstLaunch <= 0) {
|
||||
shouldPrompt = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timeIntervalAtFirstLaunch == nil) {
|
||||
[self.host setObject:@([currentDate timeIntervalSinceReferenceDate]) forUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
|
||||
}
|
||||
|
||||
if (shouldPrompt) {
|
||||
NSArray *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
|
||||
// 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:)]) {
|
||||
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self.delegator sendingSystemProfile:YES];
|
||||
if (feedParameters != nil) {
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:feedParameters];
|
||||
}
|
||||
}
|
||||
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
[self.userDriver requestUpdatePermissionWithSystemProfile:profileInfo reply:^(SUUpdatePermission *result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf updatePermissionPromptFinishedWithResult:result];
|
||||
// Schedule checks, but make sure we ignore the delayed call from KVO
|
||||
[strongSelf resetUpdateCycle];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
// We start the update checks and register as observer for changes after the prompt finishes
|
||||
} else {
|
||||
if (self.preStartedScheduledUpdateBlock != nil) {
|
||||
self.preStartedScheduledUpdateBlock();
|
||||
self.preStartedScheduledUpdateBlock = nil;
|
||||
} else {
|
||||
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updatePermissionPromptFinishedWithResult:(SUUpdatePermission *)result
|
||||
{
|
||||
[self.host setBool:result.sendProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
[self setAutomaticallyChecksForUpdates:(result.choice == SUAutomaticallyCheck)];
|
||||
}
|
||||
|
||||
- (NSDate *)lastUpdateCheckDate
|
||||
{
|
||||
return [self.host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
}
|
||||
|
||||
- (void)updateLastUpdateCheckDate
|
||||
{
|
||||
[self willChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheck
|
||||
{
|
||||
[self scheduleNextUpdateCheckFiringImmediately:NO];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately
|
||||
{
|
||||
[self.userDriver invalidateUpdateCheckTimer];
|
||||
|
||||
BOOL automaticallyCheckForUpdates = [self automaticallyChecksForUpdates];
|
||||
|
||||
[self.userDriver showCanCheckForUpdates:!automaticallyCheckForUpdates];
|
||||
[self.userDriver idleOnUpdateChecks:!automaticallyCheckForUpdates];
|
||||
|
||||
if (!automaticallyCheckForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (firingImmediately) {
|
||||
[self checkForUpdatesInBackground];
|
||||
} else {
|
||||
[self.userDriver showCanCheckForUpdates:YES];
|
||||
|
||||
[self retrieveNextUpdateCheckInterval:^(NSTimeInterval updateCheckInterval) {
|
||||
// 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];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
|
||||
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
||||
if (intervalSinceCheck < updateCheckInterval) {
|
||||
NSTimeInterval delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
__weak SPUUpdater *weakSelf = self; // we don't want this to keep the updater alive
|
||||
[self.userDriver startUpdateCheckTimerWithNextTimeInterval:delayUntilCheck reply:^(SUUpdateCheckTimerStatus checkTimerStatus) {
|
||||
switch (checkTimerStatus) {
|
||||
case SUCheckForUpdateWillOccurLater:
|
||||
break;
|
||||
case SUCheckForUpdateNow:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf checkForUpdatesInBackground];
|
||||
});
|
||||
break;
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
// We're overdue! Run one now.
|
||||
[self checkForUpdatesInBackground];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
if (!self.startedUpdater) {
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdatesInBackground];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't want the probe check to act on the driver if the updater is going near death
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:hostBundleIdentifier completion:^(BOOL installerIsRunning) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
id <SUUpdateDriver> updateDriver;
|
||||
if (!installerIsRunning && [strongSelf automaticallyDownloadsUpdates] && [strongSelf allowsAutomaticUpdates] && strongSelf.resumableUpdate == nil) {
|
||||
updateDriver =
|
||||
[[SUAutomaticUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf.delegator
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
} else {
|
||||
updateDriver =
|
||||
[[SUScheduledUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf.delegator
|
||||
userDriver:strongSelf.userDriver
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
}
|
||||
|
||||
[strongSelf checkForUpdatesWithDriver:updateDriver installerInProgress:installerIsRunning];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdates
|
||||
{
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
if (!self.startedUpdater) {
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdates];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.driver != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
id <SUUpdateDriver> theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithHost:self.host sparkleBundle:self.sparkleBundle updater:self.delegator userDriver:self.userDriver updaterDelegate:self.delegate];
|
||||
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:bundleIdentifier completion:^(BOOL installerInProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf checkForUpdatesWithDriver:theUpdateDriver installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdateInformation
|
||||
{
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
if (!self.startedUpdater) {
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdateInformation];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:bundleIdentifier completion:^(BOOL installerInProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf.delegator updaterDelegate:strongSelf.delegate] installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesWithDriver:(id <SUUpdateDriver> )d installerInProgress:(BOOL)installerInProgress
|
||||
{
|
||||
if (self.driver != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.userDriver invalidateUpdateCheckTimer];
|
||||
|
||||
[self updateLastUpdateCheckDate];
|
||||
|
||||
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates:self.delegator] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
self.driver = d;
|
||||
|
||||
// If we're not given a driver at all, just schedule the next update check and bail.
|
||||
if (!self.driver) {
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
// Reload our host bundle information in case its current cache is out of date
|
||||
// We could have updated the bundle before for example without terminating this updater process
|
||||
[self.host reloadInfoDictionary];
|
||||
|
||||
// Because an application can change the configuration (eg: the feed url) at any point, we should always check if it's valid
|
||||
NSError *configurationError = nil;
|
||||
if (![self checkIfConfiguredProperly:&configurationError]) {
|
||||
SULog(@"Fatal configuration error (%ld): %@", (long)configurationError.code, configurationError.localizedDescription);
|
||||
abort();
|
||||
}
|
||||
|
||||
NSURL *theFeedURL = [self parameterizedFeedURL];
|
||||
// Use a NIL URL to cancel quietly.
|
||||
if (theFeedURL) {
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
SUUpdateDriverCompletion completionBlock = ^(BOOL shouldShowUpdateImmediately, SUDownloadedUpdate * _Nullable resumableUpdate) {
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.resumableUpdate = resumableUpdate;
|
||||
strongSelf.driver = nil;
|
||||
[strongSelf updateLastUpdateCheckDate];
|
||||
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately];
|
||||
}
|
||||
};
|
||||
|
||||
[self.userDriver showCanCheckForUpdates:NO];
|
||||
|
||||
if (installerInProgress) {
|
||||
[self.driver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
} else if (self.resumableUpdate != nil) {
|
||||
[self.driver resumeDownloadedUpdate:(SUDownloadedUpdate * _Nonnull)self.resumableUpdate completion:completionBlock];
|
||||
} else {
|
||||
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] completion:completionBlock];
|
||||
}
|
||||
} else {
|
||||
[self.driver abortUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelNextUpdateCycle
|
||||
{
|
||||
[self.updaterCycle cancelNextUpdateCycle];
|
||||
}
|
||||
|
||||
- (void)resetUpdateCycle
|
||||
{
|
||||
if (!self.startedUpdater) {
|
||||
return; // not even ready yet
|
||||
}
|
||||
|
||||
[self cancelNextUpdateCycle];
|
||||
|
||||
if (self.driver == nil) {
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resetUpdateCycleAfterShortDelay
|
||||
{
|
||||
[self cancelNextUpdateCycle];
|
||||
[self.updaterCycle resetUpdateCycleAfterDelay];
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
|
||||
{
|
||||
[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:SUDefaultUpdateCheckInterval];
|
||||
}
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self resetUpdateCycleAfterShortDelay];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
return [self.updaterSettings automaticallyChecksForUpdates];
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
|
||||
{
|
||||
[self.host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
return [self.updaterSettings automaticallyDownloadsUpdates];
|
||||
}
|
||||
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
return [self.updaterSettings allowsAutomaticUpdates];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(@"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
[self.host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
|
||||
}
|
||||
|
||||
- (BOOL)retrieveFeedURL:(NSURL * __autoreleasing *)feedURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(@"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
// 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.delegator];
|
||||
|
||||
if (!appcastString) { // Can't find an appcast string!
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidFeedURLError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSCharacterSet *quoteSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"]; // Some feed publishers add quotes; strip 'em.
|
||||
NSString *castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
|
||||
if (feedURL != NULL) {
|
||||
if (!castUrlStr || [castUrlStr length] == 0) {
|
||||
*feedURL = nil;
|
||||
} else {
|
||||
*feedURL = [NSURL URLWithString:castUrlStr];
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSURL *)feedURL
|
||||
{
|
||||
NSURL *feedURL = nil;
|
||||
NSError *feedError = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:&feedError]) {
|
||||
SULog(@"Fatal Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
abort();
|
||||
}
|
||||
return feedURL;
|
||||
}
|
||||
|
||||
- (NSString *)userAgentString
|
||||
{
|
||||
if (customUserAgentString) {
|
||||
return customUserAgentString;
|
||||
}
|
||||
|
||||
NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
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
|
||||
{
|
||||
[self.host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (BOOL)sendsSystemProfile
|
||||
{
|
||||
return [self.updaterSettings sendsSystemProfile];
|
||||
}
|
||||
|
||||
- (NSURL *)parameterizedFeedURL
|
||||
{
|
||||
NSURL *baseFeedURL = [self feedURL];
|
||||
|
||||
// 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 = [self.host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
if (!lastSubmitDate) {
|
||||
lastSubmitDate = [NSDate distantPast];
|
||||
}
|
||||
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
|
||||
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
|
||||
|
||||
NSArray *parameters = @[];
|
||||
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self.delegator sendingSystemProfile:sendingSystemProfile];
|
||||
if (feedParameters != nil) {
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:feedParameters];
|
||||
}
|
||||
}
|
||||
if (sendingSystemProfile)
|
||||
{
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[SUSystemProfiler systemProfileArrayForHost:self.host]];
|
||||
[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 objectForKey:@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[[currentProfileInfo objectForKey:@"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:@"&"]];
|
||||
|
||||
// Clean it up so it's a valid URL
|
||||
return [NSURL URLWithString:appcastStringWithProfile];
|
||||
}
|
||||
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
[self.host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if ((NSInteger)updateCheckInterval == 0) { // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
}
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self resetUpdateCycleAfterShortDelay];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
return [self.updaterSettings updateCheckInterval];
|
||||
}
|
||||
|
||||
// This may not return the same update check interval as the developer has configured
|
||||
// Notably it may differ when we have an update that has been already downloaded and needs to resume,
|
||||
// as well as if that update is marked critical or not
|
||||
- (void)retrieveNextUpdateCheckInterval:(void (^)(NSTimeInterval))completionHandler
|
||||
{
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHostBundleIdentifier:hostBundleIdentifier completion:^(SUInstallationInfo * _Nullable installationInfo) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSTimeInterval regularCheckInterval = [self updateCheckInterval];
|
||||
if (installationInfo == nil) {
|
||||
// Proceed as normal if there's no resumable updates
|
||||
completionHandler(regularCheckInterval);
|
||||
} else {
|
||||
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate]) {
|
||||
completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
} else {
|
||||
completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
// Stop checking for updates
|
||||
[self cancelNextUpdateCycle];
|
||||
|
||||
// Don't tell the user driver to invalidate the update check timer
|
||||
// It could always create a new updater instance once the scheduled time occurs
|
||||
|
||||
// Abort any on-going updates
|
||||
// A driver could be retained by another object (eg: a timer),
|
||||
// so not aborting could mean it stays alive longer than we'd want
|
||||
[self.driver abortUpdate];
|
||||
self.driver = nil;
|
||||
}
|
||||
|
||||
- (NSBundle *)hostBundle { return [self.host bundle]; }
|
||||
|
||||
// Private API for backwards compatibility, used by SUUpdater
|
||||
- (void)setDelegate:(id<SUUpdaterDelegate>)delegate
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
// Don't want to declare a property for a private API
|
||||
_delegate = delegate;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
// Private API for backwards compatibility, used by SUUpdater
|
||||
- (void)setUpdaterDelegator:(id)delegator
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
// Don't want to declare a property for a private API
|
||||
_delegator = delegator;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+10
@@ -32,6 +32,12 @@
|
||||
|
||||
#define FIRST_INSTALLER_MESSAGE_TIMEOUT 7ull
|
||||
|
||||
@interface NSObject (SparkleUpdaterDeprecated)
|
||||
|
||||
- (NSString *)_decryptionPasswordForSparkleUpdater;
|
||||
|
||||
@end
|
||||
|
||||
@interface SUInstallerDriver () <SUInstallerCommunicationProtocol>
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@@ -165,6 +171,10 @@
|
||||
NSString *decryptionPassword = nil;
|
||||
if ([self.updaterDelegate respondsToSelector:@selector(decryptionPasswordForUpdater:)]) {
|
||||
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
|
||||
} else if ([self.updater respondsToSelector:@selector(_decryptionPasswordForSparkleUpdater)]) {
|
||||
// The old updater (SUUpdater) has a decryptionPassword property
|
||||
// Let's ask it if it has a decryption password available
|
||||
decryptionPassword = [self.updater _decryptionPasswordForSparkleUpdater];
|
||||
}
|
||||
|
||||
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName installationType:self.updateItem.installationType dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUUpdater;
|
||||
@class SPUUpdater;
|
||||
@protocol SUUserDriver, SUStandardUserDriver, SUUpdaterDelegate, SUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
@@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
This is nil before being loaded from the nib.
|
||||
You may access this property after your application has finished launching, or after your window controller has finished loading.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) SUUpdater *updater;
|
||||
@property (nonatomic, readonly, nullable) SPUUpdater *updater;
|
||||
|
||||
/*!
|
||||
Accessible property for the updater's user driver.
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SUStandardUpdaterController.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SPUUpdater.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUStandardUserDriver.h"
|
||||
#import "SUConstants.h"
|
||||
@@ -18,7 +18,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
@interface SUStandardUpdaterController ()
|
||||
|
||||
@property (nonatomic) SUUpdater *updater;
|
||||
@property (nonatomic) SPUUpdater *updater;
|
||||
@property (nonatomic) id <SUStandardUserDriver> userDriver;
|
||||
@property (nonatomic) BOOL initializedUpdater;
|
||||
|
||||
@@ -42,7 +42,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
NSBundle *hostBundle = [NSBundle mainBundle];
|
||||
id <SUUserDriver, SUStandardUserDriver> userDriver = [[SUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:self.userDriverDelegate];
|
||||
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate];
|
||||
self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate];
|
||||
self.userDriver = userDriver;
|
||||
|
||||
// In the case this is being called right as an application is being launched,
|
||||
|
||||
Vendored
-1
@@ -9,7 +9,6 @@
|
||||
#import "SUStandardUserDriver.h"
|
||||
#import "SUUserDriverCoreComponent.h"
|
||||
#import "SUStandardUserDriverDelegate.h"
|
||||
#import "SUStandardUserDriverUIDelegate.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
+50
-4
@@ -8,13 +8,59 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol SUStandardUserDriverUIDelegate, SUStandardUserDriverRemoteDelegate;
|
||||
@protocol SUVersionDisplay;
|
||||
|
||||
/*!
|
||||
A protocol for Sparkle's standard user driver's delegate
|
||||
|
||||
If you are interested in UI interactions, check out SUStandardUserDriverUIDelegate
|
||||
If you are interested in XPC or remote process communications for efficiency and reliability, check out SUStandardUserDriverRemoteDelegate
|
||||
This includes methods related to UI interactions and XPC/remote process communication.
|
||||
*/
|
||||
@protocol SUStandardUserDriverDelegate <SUStandardUserDriverUIDelegate, SUStandardUserDriverRemoteDelegate>
|
||||
@protocol SUStandardUserDriverDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Called before showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)userDriverWillShowModalAlert;
|
||||
|
||||
/*!
|
||||
Called after showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)userDriverDidShowModalAlert;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version formatter will be used.
|
||||
*/
|
||||
- (_Nullable id <SUVersionDisplay>)userDriverRequestsVersionDisplayer;
|
||||
|
||||
/*!
|
||||
Asks whether or not the delegate is responsible for initiating updater checks.
|
||||
|
||||
The user driver uses this to decide whether or not it should be the one initiating update checks.
|
||||
If the delegate wants to initiate update checks, then the user driver lets the updater know it shouldn't
|
||||
wait for a response from the user driver. When the user driver and updater live in separate processes,
|
||||
having a delegate implement this can be more efficient for the system and therefore is encouraged.
|
||||
|
||||
@return Returns if the delegate is responsible for initiating update checks. If the delegate returns YES,
|
||||
then the delegate must also implement -userDriverRequestsInitatingUpdateCheck which is when the delegate should
|
||||
initiate update checks.
|
||||
*/
|
||||
- (BOOL)userDriverRequestsResponsibilityForInitiatingUpdateCheck;
|
||||
|
||||
/*!
|
||||
Called when user driver tells the delegate to initiate an update check
|
||||
|
||||
This is called if the delegate returned YES from -userDriverRequestsResponsibilityForInitiatingUpdateCheck
|
||||
|
||||
The delegate will have to find a pathway to tell the SUUpdater instance to check for updates, that
|
||||
does not go through the user driver. See -userDriverRequestsResponsibilityForInitiatingUpdateCheck as to why
|
||||
a delegate may want to implement this.
|
||||
*/
|
||||
- (void)userDriverRequestsInitatingUpdateCheck;
|
||||
|
||||
@end
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
//
|
||||
// SUStandardUserDriverRemoteDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/2/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
A delegate protocol for Sparkle's standard user driver related to efficiency and reliablity when Sparkle's updater lives in a separate process
|
||||
*/
|
||||
@protocol SUStandardUserDriverRemoteDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Asks whether or not the delegate is responsible for initiating updater checks.
|
||||
|
||||
The user driver uses this to decide whether or not it should be the one initiating update checks.
|
||||
If the delegate wants to initiate update checks, then the user driver lets the updater know it shouldn't
|
||||
wait for a response from the user driver. When the user driver and updater live in separate processes,
|
||||
having a delegate implement this can be more efficient for the system and therefore is encouraged.
|
||||
|
||||
@return Returns if the delegate is responsible for initiating update checks. If the delegate returns YES,
|
||||
then the delegate must also implement -userDriverRequestsInitatingUpdateCheck which is when the delegate should
|
||||
initiate update checks.
|
||||
*/
|
||||
- (BOOL)userDriverRequestsResponsibilityForInitiatingUpdateCheck;
|
||||
|
||||
/*!
|
||||
Called when user driver tells the delegate to initiate an update check
|
||||
|
||||
This is called if the delegate returned YES from -userDriverRequestsResponsibilityForInitiatingUpdateCheck
|
||||
|
||||
The delegate will have to find a pathway to tell the SUUpdater instance to check for updates, that
|
||||
does not go through the user driver. See -userDriverRequestsResponsibilityForInitiatingUpdateCheck as to why
|
||||
a delegate may want to implement this.
|
||||
*/
|
||||
- (void)userDriverRequestsInitatingUpdateCheck;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
//
|
||||
// SUStandardUserDriverUIDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUVersionDisplay;
|
||||
|
||||
/*!
|
||||
A delegate protocol for Sparkle's standard user driver related to user interactions
|
||||
*/
|
||||
@protocol SUStandardUserDriverUIDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Called before showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)userDriverWillShowModalAlert;
|
||||
|
||||
/*!
|
||||
Called after showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)userDriverDidShowModalAlert;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version formatter will be used.
|
||||
*/
|
||||
- (_Nullable id <SUVersionDisplay>)userDriverRequestsVersionDisplayer;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+66
-69
@@ -15,56 +15,30 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
#import "SUUserDriver.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
|
||||
@class SUAppcastItem, SUAppcast;
|
||||
|
||||
@protocol SUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
*/
|
||||
__deprecated_msg("Use SUStandardUpdaterController or SPUUpdater instead")
|
||||
SU_EXPORT @interface SUUpdater : NSObject
|
||||
|
||||
/*!
|
||||
* Initializes a new SUUpdater instance
|
||||
*
|
||||
* This does not start the updater. To start it, see -[SUUpdater startUpdater:]
|
||||
*
|
||||
* Note that this is a normal initializer and doesn't implement the singleton pattern (i.e, instances aren't cached, so no surprises)
|
||||
* Hence you shouldn't create multiple live instances that target the same bundle.
|
||||
* However, this also means that updater instances can be deallocated, and that they will be torn down properly
|
||||
*
|
||||
* Related: See SUStandardUpdaterController which wraps a SUUpdater instance and is suitable for instantiating in nib files
|
||||
*
|
||||
* @param hostBundle The bundle that should be targetted for updating. This must not be nil.
|
||||
* @param userDriver The user driver that Sparkle uses for user update interaction
|
||||
* @param delegate The delegate for SUUpdater. This may be nil.
|
||||
*
|
||||
* This must be called on the main thread.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)delegate;
|
||||
@property (unsafe_unretained, nonatomic) IBOutlet id<SUUpdaterDelegate> delegate;
|
||||
|
||||
/*!
|
||||
* Starts the updater.
|
||||
*
|
||||
* This method checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
|
||||
* Other properties of this SUUpdater instance can be set before this method is invoked as well, such as automatic update checks.
|
||||
* If the configuration is valid, this method may bring up a permission prompt (if needed) for checking if the user wants automatic update checking.
|
||||
* This method then starts the regular update cycle if automatic update checks are enabled.
|
||||
*
|
||||
* @param error The error that is populated if this method fails. Pass NULL if not interested in the error information.
|
||||
* @return YES if the updater started otherwise NO with a populated error
|
||||
*/
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error;
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
|
||||
@property (weak, readonly) id<SUUpdaterDelegate> delegate;
|
||||
@property (nonatomic, readonly) id<SUUserDriver> userDriver;
|
||||
|
||||
@property (readonly, strong) NSBundle *hostBundle;
|
||||
@property (readonly, nonatomic) NSBundle *hostBundle;
|
||||
@property (strong, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
@property (nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
@@ -76,63 +50,86 @@ SU_EXPORT @interface SUUpdater : NSObject
|
||||
*
|
||||
* This property must be called on the main thread.
|
||||
*/
|
||||
@property (copy) NSURL *feedURL;
|
||||
@property (nonatomic, copy) NSURL *feedURL;
|
||||
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
@property (copy) NSDictionary *httpHeaders;
|
||||
@property (nonatomic, copy) NSDictionary *httpHeaders;
|
||||
|
||||
@property (nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
|
||||
/*!
|
||||
Checks for updates, and displays progress while doing so
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
This is meant for users initiating an update check
|
||||
This method is meant for a main menu item.
|
||||
Connect any menu item to this action in Interface Builder,
|
||||
and Sparkle will check for updates and report back its findings verbosely
|
||||
when it is invoked.
|
||||
*/
|
||||
- (void)checkForUpdates;
|
||||
- (IBAction)checkForUpdates:(id)sender;
|
||||
|
||||
/*!
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates. That is,
|
||||
it will display no UI unless it actually finds an update, in which case it
|
||||
proceeds as usual.
|
||||
|
||||
If the fully automated updating is turned on, however, this will invoke that
|
||||
behavior, and if an update is found, it will be downloaded and prepped for
|
||||
installation.
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates. That is,
|
||||
it will display no UI unless it actually finds an update, in which case it
|
||||
proceeds as usual.
|
||||
|
||||
If the fully automated updating is turned on, however, this will invoke that
|
||||
behavior, and if an update is found, it will be downloaded and prepped for
|
||||
installation.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
*/
|
||||
@property (readonly, copy) NSDate *lastUpdateCheckDate;
|
||||
@property (nonatomic, readonly, copy) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal timer.
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal NSTimer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
@property (nonatomic, readonly) BOOL updateInProgress;
|
||||
|
||||
@end
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
// The updater will be the notification object
|
||||
// -----------------------------------------------------------------------------
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
|
||||
|
||||
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
#endif
|
||||
Vendored
+188
-687
@@ -7,743 +7,244 @@
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
#import "SUUpdaterSettings.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUUpdatePermission.h"
|
||||
#import "SUUpdateDriver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SPUUpdater.h"
|
||||
#import "SUStandardUserDriver.h"
|
||||
#import "SUStandardUserDriverDelegate.h"
|
||||
#import "SULog.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUSystemProfiler.h"
|
||||
#import "SUScheduledUpdateDriver.h"
|
||||
#import "SUProbingUpdateDriver.h"
|
||||
#import "SUUserInitiatedUpdateDriver.h"
|
||||
#import "SUAutomaticUpdateDriver.h"
|
||||
#import "SUProbeInstallStatus.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUXPCServiceInfo.h"
|
||||
#import "SUUpdaterCycle.h"
|
||||
#import "SUDownloadedUpdate.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
#endif
|
||||
@interface SUUpdater () <SUStandardUserDriverDelegate>
|
||||
|
||||
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
|
||||
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
|
||||
NSString *const SUUpdaterDidNotFindUpdateNotification = @"SUUpdaterDidNotFindUpdateNotification";
|
||||
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNotificationKey";
|
||||
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
|
||||
|
||||
@interface SUUpdater () <SUUpdaterCycleDelegate>
|
||||
|
||||
@property (readonly, copy) NSURL *parameterizedFeedURL;
|
||||
|
||||
@property (nonatomic) id <SUUpdateDriver> driver;
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) SUUpdaterSettings *updaterSettings;
|
||||
@property (nonatomic, readonly) SUUpdaterCycle *updaterCycle;
|
||||
@property (nonatomic) BOOL startedUpdater;
|
||||
@property (nonatomic, copy) void (^preStartedScheduledUpdateBlock)(void);
|
||||
@property (nonatomic, nullable) SUDownloadedUpdate *resumableUpdate;
|
||||
@property (nonatomic, readonly) SPUUpdater *updater;
|
||||
@property (nonatomic, readonly) SUStandardUserDriver *userDriver;
|
||||
|
||||
@end
|
||||
|
||||
@interface SPUUpdater (Private)
|
||||
|
||||
- (void)setDelegate:(id<SUUpdaterDelegate>)delegate;
|
||||
- (void)setUpdaterDelegator:(id)delegator;
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
||||
@implementation SUUpdater
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize updater = _updater;
|
||||
@synthesize userDriver = _userDriver;
|
||||
@synthesize userAgentString = customUserAgentString;
|
||||
@synthesize httpHeaders;
|
||||
@synthesize driver;
|
||||
@synthesize host = _host;
|
||||
@synthesize updaterSettings = _updaterSettings;
|
||||
@synthesize updaterCycle = _updaterCycle;
|
||||
@synthesize sparkleBundle = _sparkleBundle;
|
||||
@synthesize startedUpdater = _startedUpdater;
|
||||
@synthesize preStartedScheduledUpdateBlock = _preStartedScheduledUpdateBlock;
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
|
||||
#ifdef DEBUG
|
||||
+ (void)load
|
||||
static NSMutableDictionary *sharedUpdaters = nil;
|
||||
|
||||
+ (SUUpdater *)sharedUpdater
|
||||
{
|
||||
// We're using NSLog instead of SULog here because we don't want to start Sparkle's logger here,
|
||||
// and because this is not really an error, just a warning notice
|
||||
NSLog(@"WARNING: This is running a Debug build of Sparkle; don't use this in production!");
|
||||
return [self updaterForBundle:[NSBundle mainBundle]];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)theDelegate
|
||||
// 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 objectForKey:[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];
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
|
||||
if (self != nil) {
|
||||
// Use explicit class to use the correct bundle even when subclassed
|
||||
_sparkleBundle = [NSBundle bundleForClass:[SUUpdater class]];
|
||||
|
||||
_host = [[SUHost alloc] initWithBundle:bundle];
|
||||
|
||||
_updaterSettings = [[SUUpdaterSettings alloc] initWithHostBundle:bundle];
|
||||
_updaterCycle = [[SUUpdaterCycle alloc] initWithDelegate:self];
|
||||
|
||||
_userDriver = userDriver;
|
||||
|
||||
_delegate = theDelegate;
|
||||
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater)
|
||||
{
|
||||
self = updater;
|
||||
}
|
||||
else if (self)
|
||||
{
|
||||
if (sharedUpdaters == nil) {
|
||||
sharedUpdaters = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
[sharedUpdaters setObject:self forKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
|
||||
_userDriver = [[SUStandardUserDriver alloc] initWithHostBundle:bundle delegate:self];
|
||||
_updater = [[SPUUpdater alloc] initWithHostBundle:bundle userDriver:_userDriver delegate:nil];
|
||||
[_updater setUpdaterDelegator:self];
|
||||
|
||||
NSError *updaterError = nil;
|
||||
if (![_updater startUpdater:&updaterError]) {
|
||||
SULog(@"Error: Falied to start updater with error: %@", updaterError);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// To prevent subclasses from doing something bad based on older Sparkle code
|
||||
- (instancetype)initForBundle:(NSBundle *)__unused bundle
|
||||
{
|
||||
SULog(@"-[SUUpdater initForBundle:] is not implemented anymore.");
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
// To prevent trying to stick an SUUpdater in a nib or initializing it in an incorrect way
|
||||
// This will be used when the updater is instantiated in a nib such as MainMenu
|
||||
- (instancetype)init
|
||||
{
|
||||
SULog(@"-[SUUpdater init] is not implemented. If you want to drop an updater into a nib, see SUStandardUpdaterController.");
|
||||
abort();
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![self checkIfConfiguredProperly:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.startedUpdater = YES;
|
||||
[self startUpdateCycle];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)checkATSIssueForBundle:(NSBundle * _Nullable)bundle getBundleExists:(BOOL *)bundleExists
|
||||
{
|
||||
if (bundleExists != NULL) {
|
||||
*bundleExists = (bundle != nil);
|
||||
}
|
||||
|
||||
if (bundle == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return ([bundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
|
||||
}
|
||||
|
||||
- (BOOL)checkIfConfiguredProperly:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (self.sparkleBundle == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: @"SUUpdater can't find Sparkle.framework it belongs to." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSURL *feedURL = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([[self hostBundle] bundleIdentifier] == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidHostBundleIdentifierError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot target a bundle that does not have a valid bundle identifier." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!self.host.validVersion) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidHostVersionError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot target a bundle that does not have a valid version." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
if (!hasPublicDSAKey) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
if (!servingOverHttps) {
|
||||
BOOL foundXPCTemporaryDownloaderService = NO;
|
||||
BOOL foundATSTemporaryIssue = [self checkATSIssueForBundle:SUXPCServiceBundle(@TEMPORARY_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCTemporaryDownloaderService];
|
||||
|
||||
BOOL foundXPCPersistentDownloaderService = NO;
|
||||
BOOL foundATSPersistentIssue = NO;
|
||||
if (!foundATSTemporaryIssue) {
|
||||
foundATSPersistentIssue = [self checkATSIssueForBundle:SUXPCServiceBundle(@PERSISTENT_DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCPersistentDownloaderService];
|
||||
}
|
||||
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
BOOL foundATSMainBundleIssue = NO;
|
||||
if (!foundATSTemporaryIssue && !foundATSPersistentIssue && (!foundXPCTemporaryDownloaderService || !foundXPCPersistentDownloaderService)) {
|
||||
BOOL foundATSIssue = ([mainBundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
|
||||
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
|
||||
|
||||
if (updatingMainBundle) {
|
||||
// The only way we'll know for sure if there is an issue is if the main bundle is the same as the one we're updating
|
||||
// We don't want to generate false positives..
|
||||
foundATSMainBundleIssue = foundATSIssue;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundATSTemporaryIssue || foundATSPersistentIssue || foundATSMainBundleIssue) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsecureFeedURLError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"You must change the feed URL (%@) to use HTTPS or use a build of Sparkle with App Transport Security disabled.\n\nFor more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", [feedURL absoluteString]] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)startUpdateCycle
|
||||
{
|
||||
BOOL shouldPrompt = NO;
|
||||
NSNumber *timeIntervalAtFirstLaunch = [self.host objectForUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
|
||||
NSDate *currentDate = [NSDate date];
|
||||
|
||||
// If the user has been asked about automatic checks, don't bother prompting
|
||||
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey]) {
|
||||
shouldPrompt = NO;
|
||||
}
|
||||
// If the developer wants to check for updates, we shouldn't bug the user about a prompt yet
|
||||
else if (self.preStartedScheduledUpdateBlock != nil) {
|
||||
shouldPrompt = NO;
|
||||
}
|
||||
// Does the delegate want to take care of the logic for when we should ask permission to update?
|
||||
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) {
|
||||
shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
|
||||
}
|
||||
// Has the user been asked already? And don't ask if the host has a default value set in its Info.plist.
|
||||
else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil) {
|
||||
// Now, we don't want to ask the user for permission to do a weird thing right when they install the app
|
||||
// We wait until another launch after a few hours have passed, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
|
||||
|
||||
if ([self.host objectForKey:SUPromptUserOnFirstLaunchKey] != nil) {
|
||||
shouldPrompt = YES;
|
||||
} else if (timeIntervalAtFirstLaunch != nil) {
|
||||
NSDate *firstLaunchDate = [NSDate dateWithTimeIntervalSinceReferenceDate:timeIntervalAtFirstLaunch.doubleValue];
|
||||
NSTimeInterval intervalSinceFirstLaunch = [currentDate timeIntervalSinceDate:firstLaunchDate];
|
||||
// We want to prompt if more than (or equal to) 'SUDefaultUpdatePermissionPromptInterval' seconds have passed since the first launch
|
||||
// If the first launch time is after (or equal to) our current date, then something may have gone wrong in the system - prompt to be on the safe side
|
||||
if (intervalSinceFirstLaunch >= SUDefaultUpdatePermissionPromptInterval || intervalSinceFirstLaunch <= 0) {
|
||||
shouldPrompt = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timeIntervalAtFirstLaunch == nil) {
|
||||
[self.host setObject:@([currentDate timeIntervalSinceReferenceDate]) forUserDefaultsKey:SUTimeIntervalAtFirstLaunchKey];
|
||||
}
|
||||
|
||||
if (shouldPrompt) {
|
||||
NSArray *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
|
||||
// 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:)]) {
|
||||
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:YES];
|
||||
if (feedParameters != nil) {
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:feedParameters];
|
||||
}
|
||||
}
|
||||
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
[self.userDriver requestUpdatePermissionWithSystemProfile:profileInfo reply:^(SUUpdatePermission *result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf updatePermissionPromptFinishedWithResult:result];
|
||||
// Schedule checks, but make sure we ignore the delayed call from KVO
|
||||
[strongSelf resetUpdateCycle];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
// We start the update checks and register as observer for changes after the prompt finishes
|
||||
} else {
|
||||
if (self.preStartedScheduledUpdateBlock != nil) {
|
||||
self.preStartedScheduledUpdateBlock();
|
||||
self.preStartedScheduledUpdateBlock = nil;
|
||||
} else {
|
||||
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updatePermissionPromptFinishedWithResult:(SUUpdatePermission *)result
|
||||
{
|
||||
[self.host setBool:result.sendProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
[self setAutomaticallyChecksForUpdates:(result.choice == SUAutomaticallyCheck)];
|
||||
}
|
||||
|
||||
- (NSDate *)lastUpdateCheckDate
|
||||
{
|
||||
return [self.host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
}
|
||||
|
||||
- (void)updateLastUpdateCheckDate
|
||||
{
|
||||
[self willChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheck
|
||||
{
|
||||
[self scheduleNextUpdateCheckFiringImmediately:NO];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately
|
||||
{
|
||||
[self.userDriver invalidateUpdateCheckTimer];
|
||||
|
||||
BOOL automaticallyCheckForUpdates = [self automaticallyChecksForUpdates];
|
||||
|
||||
[self.userDriver showCanCheckForUpdates:!automaticallyCheckForUpdates];
|
||||
[self.userDriver idleOnUpdateChecks:!automaticallyCheckForUpdates];
|
||||
|
||||
if (!automaticallyCheckForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (firingImmediately) {
|
||||
[self checkForUpdatesInBackground];
|
||||
} else {
|
||||
[self.userDriver showCanCheckForUpdates:YES];
|
||||
|
||||
[self retrieveNextUpdateCheckInterval:^(NSTimeInterval updateCheckInterval) {
|
||||
// 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];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
|
||||
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
||||
if (intervalSinceCheck < updateCheckInterval) {
|
||||
NSTimeInterval delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
__weak SUUpdater *weakSelf = self; // we don't want this to keep the updater alive
|
||||
[self.userDriver startUpdateCheckTimerWithNextTimeInterval:delayUntilCheck reply:^(SUUpdateCheckTimerStatus checkTimerStatus) {
|
||||
switch (checkTimerStatus) {
|
||||
case SUCheckForUpdateWillOccurLater:
|
||||
break;
|
||||
case SUCheckForUpdateNow:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf checkForUpdatesInBackground];
|
||||
});
|
||||
break;
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
// We're overdue! Run one now.
|
||||
[self checkForUpdatesInBackground];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
if (!self.startedUpdater) {
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdatesInBackground];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't want the probe check to act on the driver if the updater is going near death
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:hostBundleIdentifier completion:^(BOOL installerIsRunning) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
id <SUUpdateDriver> updateDriver;
|
||||
if (!installerIsRunning && [strongSelf automaticallyDownloadsUpdates] && [strongSelf allowsAutomaticUpdates] && strongSelf.resumableUpdate == nil) {
|
||||
updateDriver =
|
||||
[[SUAutomaticUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
} else {
|
||||
updateDriver =
|
||||
[[SUScheduledUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf
|
||||
userDriver:strongSelf.userDriver
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
}
|
||||
|
||||
[strongSelf checkForUpdatesWithDriver:updateDriver installerInProgress:installerIsRunning];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdates
|
||||
{
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
if (!self.startedUpdater) {
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdates];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.driver != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
id <SUUpdateDriver> theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithHost:self.host sparkleBundle:self.sparkleBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate];
|
||||
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:bundleIdentifier completion:^(BOOL installerInProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf checkForUpdatesWithDriver:theUpdateDriver installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdateInformation
|
||||
{
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
if (!self.startedUpdater) {
|
||||
self.preStartedScheduledUpdateBlock = ^{
|
||||
[weakSelf checkForUpdateInformation];
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:bundleIdentifier completion:^(BOOL installerInProgress) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf updaterDelegate:strongSelf.delegate] installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesWithDriver:(id <SUUpdateDriver> )d installerInProgress:(BOOL)installerInProgress
|
||||
{
|
||||
if (self.driver != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.userDriver invalidateUpdateCheckTimer];
|
||||
|
||||
[self updateLastUpdateCheckDate];
|
||||
|
||||
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
self.driver = d;
|
||||
|
||||
// If we're not given a driver at all, just schedule the next update check and bail.
|
||||
if (!self.driver) {
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
// Reload our host bundle information in case its current cache is out of date
|
||||
// We could have updated the bundle before for example without terminating this updater process
|
||||
[self.host reloadInfoDictionary];
|
||||
|
||||
// Because an application can change the configuration (eg: the feed url) at any point, we should always check if it's valid
|
||||
NSError *configurationError = nil;
|
||||
if (![self checkIfConfiguredProperly:&configurationError]) {
|
||||
SULog(@"Fatal configuration error (%ld): %@", (long)configurationError.code, configurationError.localizedDescription);
|
||||
abort();
|
||||
}
|
||||
|
||||
NSURL *theFeedURL = [self parameterizedFeedURL];
|
||||
// Use a NIL URL to cancel quietly.
|
||||
if (theFeedURL) {
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
SUUpdateDriverCompletion completionBlock = ^(BOOL shouldShowUpdateImmediately, SUDownloadedUpdate * _Nullable resumableUpdate) {
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.resumableUpdate = resumableUpdate;
|
||||
strongSelf.driver = nil;
|
||||
[strongSelf updateLastUpdateCheckDate];
|
||||
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately];
|
||||
}
|
||||
};
|
||||
|
||||
[self.userDriver showCanCheckForUpdates:NO];
|
||||
|
||||
if (installerInProgress) {
|
||||
[self.driver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
} else if (self.resumableUpdate != nil) {
|
||||
[self.driver resumeDownloadedUpdate:(SUDownloadedUpdate * _Nonnull)self.resumableUpdate completion:completionBlock];
|
||||
} else {
|
||||
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] completion:completionBlock];
|
||||
}
|
||||
} else {
|
||||
[self.driver abortUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelNextUpdateCycle
|
||||
{
|
||||
[self.updaterCycle cancelNextUpdateCycle];
|
||||
return [self initForBundle:[NSBundle mainBundle]];
|
||||
}
|
||||
|
||||
- (void)resetUpdateCycle
|
||||
{
|
||||
if (!self.startedUpdater) {
|
||||
return; // not even ready yet
|
||||
}
|
||||
|
||||
[self cancelNextUpdateCycle];
|
||||
|
||||
if (self.driver == nil) {
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
[self.updater resetUpdateCycle];
|
||||
}
|
||||
|
||||
- (void)resetUpdateCycleAfterShortDelay
|
||||
- (id<SUUpdaterDelegate>)delegate
|
||||
{
|
||||
[self cancelNextUpdateCycle];
|
||||
[self.updaterCycle resetUpdateCycleAfterDelay];
|
||||
return self.updater.delegate;
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
|
||||
- (void)setDelegate:(id<SUUpdaterDelegate>)delegate
|
||||
{
|
||||
[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:SUDefaultUpdateCheckInterval];
|
||||
}
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self resetUpdateCycleAfterShortDelay];
|
||||
// Note: This invokes a private API
|
||||
[self.updater setDelegate:delegate];
|
||||
}
|
||||
|
||||
- (NSBundle *)hostBundle
|
||||
{
|
||||
return self.updater.hostBundle;
|
||||
}
|
||||
|
||||
- (NSBundle *)sparkleBundle
|
||||
{
|
||||
return self.updater.sparkleBundle;
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
return [self.updaterSettings automaticallyChecksForUpdates];
|
||||
return self.updater.automaticallyChecksForUpdates;
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
[self.host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
return [self.updaterSettings automaticallyDownloadsUpdates];
|
||||
}
|
||||
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
return [self.updaterSettings allowsAutomaticUpdates];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(@"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
[self.host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
|
||||
}
|
||||
|
||||
- (BOOL)retrieveFeedURL:(NSURL * __autoreleasing *)feedURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![NSThread isMainThread]) {
|
||||
SULog(@"This method must be called on the main thread");
|
||||
abort();
|
||||
}
|
||||
|
||||
// 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!
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidFeedURLError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSCharacterSet *quoteSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"]; // Some feed publishers add quotes; strip 'em.
|
||||
NSString *castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
|
||||
if (feedURL != NULL) {
|
||||
if (!castUrlStr || [castUrlStr length] == 0) {
|
||||
*feedURL = nil;
|
||||
} else {
|
||||
*feedURL = [NSURL URLWithString:castUrlStr];
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSURL *)feedURL
|
||||
{
|
||||
NSURL *feedURL = nil;
|
||||
NSError *feedError = nil;
|
||||
if (![self retrieveFeedURL:&feedURL error:&feedError]) {
|
||||
SULog(@"Fatal Error (%ld): %@", feedError.code, feedError.localizedDescription);
|
||||
abort();
|
||||
}
|
||||
return feedURL;
|
||||
}
|
||||
|
||||
- (NSString *)userAgentString
|
||||
{
|
||||
if (customUserAgentString) {
|
||||
return customUserAgentString;
|
||||
}
|
||||
|
||||
NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
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
|
||||
{
|
||||
[self.host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (BOOL)sendsSystemProfile
|
||||
{
|
||||
return [self.updaterSettings sendsSystemProfile];
|
||||
}
|
||||
|
||||
- (NSURL *)parameterizedFeedURL
|
||||
{
|
||||
NSURL *baseFeedURL = [self feedURL];
|
||||
|
||||
// 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 = [self.host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
if (!lastSubmitDate) {
|
||||
lastSubmitDate = [NSDate distantPast];
|
||||
}
|
||||
const NSTimeInterval oneWeek = 60 * 60 * 24 * 7;
|
||||
sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek);
|
||||
|
||||
NSArray *parameters = @[];
|
||||
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile];
|
||||
if (feedParameters != nil) {
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:feedParameters];
|
||||
}
|
||||
}
|
||||
if (sendingSystemProfile)
|
||||
{
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[SUSystemProfiler systemProfileArrayForHost:self.host]];
|
||||
[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 objectForKey:@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[[currentProfileInfo objectForKey:@"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:@"&"]];
|
||||
|
||||
// Clean it up so it's a valid URL
|
||||
return [NSURL URLWithString:appcastStringWithProfile];
|
||||
}
|
||||
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
[self.host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if ((NSInteger)updateCheckInterval == 0) { // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
}
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self resetUpdateCycleAfterShortDelay];
|
||||
[self.updater setAutomaticallyChecksForUpdates:automaticallyChecksForUpdates];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
return [self.updaterSettings updateCheckInterval];
|
||||
return self.updater.updateCheckInterval;
|
||||
}
|
||||
|
||||
// This may not return the same update check interval as the developer has configured
|
||||
// Notably it may differ when we have an update that has been already downloaded and needs to resume,
|
||||
// as well as if that update is marked critical or not
|
||||
- (void)retrieveNextUpdateCheckInterval:(void (^)(NSTimeInterval))completionHandler
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHostBundleIdentifier:hostBundleIdentifier completion:^(SUInstallationInfo * _Nullable installationInfo) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSTimeInterval regularCheckInterval = [self updateCheckInterval];
|
||||
if (installationInfo == nil) {
|
||||
// Proceed as normal if there's no resumable updates
|
||||
completionHandler(regularCheckInterval);
|
||||
} else {
|
||||
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate]) {
|
||||
completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
} else {
|
||||
completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
[self.updater setUpdateCheckInterval:updateCheckInterval];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (NSURL *)feedURL
|
||||
{
|
||||
// Stop checking for updates
|
||||
[self cancelNextUpdateCycle];
|
||||
|
||||
// Don't tell the user driver to invalidate the update check timer
|
||||
// It could always create a new updater instance once the scheduled time occurs
|
||||
|
||||
// Abort any on-going updates
|
||||
// A driver could be retained by another object (eg: a timer),
|
||||
// so not aborting could mean it stays alive longer than we'd want
|
||||
[self.driver abortUpdate];
|
||||
self.driver = nil;
|
||||
return self.updater.feedURL;
|
||||
}
|
||||
|
||||
- (NSBundle *)hostBundle { return [self.host bundle]; }
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
{
|
||||
[self.updater setFeedURL:feedURL];
|
||||
}
|
||||
|
||||
- (NSString *)userAgentString
|
||||
{
|
||||
return self.updater.userAgentString;
|
||||
}
|
||||
|
||||
- (void)setUserAgentString:(NSString *)userAgentString
|
||||
{
|
||||
[self.updater setUserAgentString:userAgentString];
|
||||
}
|
||||
|
||||
- (NSDictionary *)httpHeaders
|
||||
{
|
||||
return self.updater.httpHeaders;
|
||||
}
|
||||
|
||||
- (void)setHttpHeaders:(NSDictionary *)httpHeaders
|
||||
{
|
||||
[self.updater setHttpHeaders:httpHeaders];
|
||||
}
|
||||
|
||||
- (BOOL)sendsSystemProfile
|
||||
{
|
||||
return self.updater.sendsSystemProfile;
|
||||
}
|
||||
|
||||
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile
|
||||
{
|
||||
[self.updater setSendsSystemProfile:sendsSystemProfile];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
return self.updater.automaticallyDownloadsUpdates;
|
||||
}
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
[self.updater setAutomaticallyDownloadsUpdates:automaticallyDownloadsUpdates];
|
||||
}
|
||||
|
||||
- (IBAction)checkForUpdates:(id)__unused sender
|
||||
{
|
||||
[self.updater checkForUpdates];
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
if ([item action] == @selector(checkForUpdates:)) {
|
||||
return self.userDriver.canCheckForUpdates;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
[self.updater checkForUpdatesInBackground];
|
||||
}
|
||||
|
||||
- (NSDate *)lastUpdateCheckDate
|
||||
{
|
||||
return self.updater.lastUpdateCheckDate;
|
||||
}
|
||||
|
||||
- (void)checkForUpdateInformation
|
||||
{
|
||||
[self.updater checkForUpdateInformation];
|
||||
}
|
||||
|
||||
- (BOOL)updateInProgress
|
||||
{
|
||||
return !self.userDriver.canCheckForUpdates;
|
||||
}
|
||||
|
||||
- (void)userDriverWillShowModalAlert
|
||||
{
|
||||
if ([self.updater.delegate respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
|
||||
[self.updater.delegate updaterWillShowModalAlert:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)userDriverDidShowModalAlert
|
||||
{
|
||||
if ([self.updater.delegate respondsToSelector:@selector(updaterDidShowModalAlert:)]) {
|
||||
[self.updater.delegate updaterDidShowModalAlert:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (_Nullable id <SUVersionDisplay>)userDriverRequestsVersionDisplayer
|
||||
{
|
||||
if ([self.updater.delegate respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
|
||||
return [self.updater.delegate versionDisplayerForUpdater:self];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Private API that is used by SUInstallerDriver
|
||||
- (NSString *)_decryptionPasswordForSparkleUpdater
|
||||
{
|
||||
return self.decryptionPassword;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+58
-58
@@ -10,7 +10,7 @@
|
||||
#import "SUExport.h"
|
||||
|
||||
@protocol SUVersionComparison;
|
||||
@class SUUpdater, SUAppcast, SUAppcastItem;
|
||||
@class SUAppcast, SUAppcastItem;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
@@ -43,49 +43,49 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
|
||||
- (BOOL)updaterMayCheckForUpdates:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
*/
|
||||
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
- (NSArray *)feedParametersForUpdater:(id)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
/*!
|
||||
Returns a custom appcast URL.
|
||||
|
||||
Override this to dynamically specify the entire URL.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
|
||||
- (NSString *)feedURLStringForUpdater:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(id)updater;
|
||||
|
||||
/*!
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
- (void)updater:(id)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/*!
|
||||
Returns the item in the appcast corresponding to the update that should be installed.
|
||||
@@ -95,68 +95,68 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
in the given appcast.
|
||||
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
|
||||
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(id)updater;
|
||||
|
||||
/*!
|
||||
Called when a valid update is found by the update driver.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
- (void)updater:(id)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
|
||||
- (void)updaterDidNotFindUpdate:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns whether the release notes (if available) should be downloaded after an update is found and shown.
|
||||
|
||||
This is specifically for the releaseNotesLink element in the appcast.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
|
||||
\return \c YES to download and show the release notes if available
|
||||
*/
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(SUUpdater *)updater;
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(id)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
\param request The mutable URL request that will be used to download the update.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
- (void)updater:(id)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
|
||||
/*!
|
||||
Called after the specified update failed to download.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that failed to download.
|
||||
\param error The error generated by the failed download.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
- (void)updater:(id)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the cancel button while and update is being downloaded.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)userDidCancelDownload:(SUUpdater *)updater;
|
||||
- (void)userDidCancelDownload:(id)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before installing the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
- (void)updater:(id)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
\deprecated Use -updater:shouldPostponeRelaunchForUpdate:untilInvokingBlock: instead
|
||||
@@ -167,13 +167,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation The invocation that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p invocation is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation __deprecated;
|
||||
- (BOOL)updater:(id)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation __deprecated;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
@@ -183,13 +183,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param installHandler The install handler that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p installHandler is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler;
|
||||
- (BOOL)updater:(id)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
@@ -197,16 +197,16 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
Some apps \b cannot be relaunched under certain circumstances.
|
||||
This method can be used to explicitly prevent a relaunch.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
|
||||
- (BOOL)updaterShouldRelaunchApplication:(id)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before relaunching.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
|
||||
- (void)updaterWillRelaunchApplication:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that compares version numbers to determine their arithmetic relation to each other.
|
||||
@@ -219,15 +219,15 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
\sa SUStandardVersionComparator
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
- (id<SUVersionComparison>)versionComparatorForUpdater:(id)updater;
|
||||
|
||||
/*!
|
||||
@deprecated This method is no longer used. See SUStandardUserUpdaterDriver delegate instead.
|
||||
*/
|
||||
// Don't specify SUVersionDisplay in the return type, otherwise we'd have to forward declare a protocol that isn't used here anymore
|
||||
- (id)versionDisplayerForUpdater:(SUUpdater *)updater __deprecated;
|
||||
- (id)versionDisplayerForUpdater:(id)updater __deprecated;
|
||||
|
||||
/*!
|
||||
Returns the path to the application which is used to relaunch after the update is installed.
|
||||
@@ -236,9 +236,9 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
The default is the path of the host bundle.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
|
||||
- (NSString *)pathToRelaunchForUpdater:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns whether or not the updater should allow interaction with its installer
|
||||
@@ -251,54 +251,54 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
On the other hand, if interaction is not allowed, then an installation may fail if the user does not
|
||||
have sufficient privileges to perform the installation.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldAllowInstallerInteraction:(SUUpdater *)updater;
|
||||
- (BOOL)updaterShouldAllowInstallerInteraction:(id)updater;
|
||||
|
||||
/*!
|
||||
Returns the decryption password (if any) which is used to extract the update archive DMG.
|
||||
|
||||
Return nil if no password should be used.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (NSString *)decryptionPasswordForUpdater:(SUUpdater *)updater;
|
||||
- (NSString *)decryptionPasswordForUpdater:(id)updater;
|
||||
|
||||
/*!
|
||||
Called before an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
|
||||
@deprecated See SUStandardUserUpdaterDriver delegate instead. This method is no longer invoked.
|
||||
*/
|
||||
- (void)updaterWillShowModalAlert:(SUUpdater *)updater __deprecated;
|
||||
- (void)updaterWillShowModalAlert:(id)updater __deprecated;
|
||||
|
||||
/*!
|
||||
Called after an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
|
||||
@deprecated See SUStandardUserUpdaterDriver delegate instead. This method is no longer invoked.
|
||||
*/
|
||||
- (void)updaterDidShowModalAlert:(SUUpdater *)updater __deprecated;
|
||||
- (void)updaterDidShowModalAlert:(id)updater __deprecated;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation Can be used to trigger an immediate silent install and relaunch.
|
||||
|
||||
\deprecated See -updater:willInstallUpdateOnQuit:immediateInstallationBlock: and -updaterIsRequestingQuit: instead. This method is no longer invoked.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation __deprecated;
|
||||
- (void)updater:(id)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation __deprecated;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit after downloading the update automatically.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param immediateInstallHandler The install handler to immediately install the update.
|
||||
If you plan to invoke this, you must return YES from this method and also implement -updaterIsRequestingQuit:
|
||||
@@ -308,35 +308,35 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
Also if the updater is given responsibility and the update item is marked critical, the new update will be presented to the user immediately after.
|
||||
Even if the immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
|
||||
- (BOOL)updater:(id)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
|
||||
|
||||
/*!
|
||||
Called when the updater requests to quit the application after the delegate invoked its installation block from -updater:willInstallUpdateOnQuit:immediateInstallationBlock:
|
||||
|
||||
\param updater the SUUpdater instance.
|
||||
\param updater the updater instance.
|
||||
|
||||
The delegate should terminate the application so the installer can immediately install the update.
|
||||
After the application is terminated, the installer will install the update and the application will be relaunched.
|
||||
The installer will not show any UI interaction.
|
||||
*/
|
||||
- (void)updaterIsRequestingQuit:(SUUpdater *)updater;
|
||||
- (void)updaterIsRequestingQuit:(id)updater;
|
||||
|
||||
/*!
|
||||
Calls after an update that was scheduled to be silently installed on quit has been canceled.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that was proposed to be installed.
|
||||
|
||||
\deprecated This method is no longer invoked. The installer will try to its best ability to install the update.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item __deprecated;
|
||||
- (void)updater:(id)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item __deprecated;
|
||||
|
||||
/*!
|
||||
Called after an update is aborted due to an error.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param updater The updater instance.
|
||||
\param error The error that caused the abort
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
|
||||
- (void)updater:(id)updater didAbortWithError:(NSError *)error;
|
||||
|
||||
@end
|
||||
Vendored
-1
@@ -8,7 +8,6 @@
|
||||
|
||||
#import "SUUserDriverCoreComponent.h"
|
||||
#import "SUStandardUserDriverDelegate.h"
|
||||
#import "SUStandardUserDriverRemoteDelegate.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SPUUpdater.h"
|
||||
#import "SUUpdaterSettings.h"
|
||||
#import "SUStandardUpdaterController.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@interface TestAppHelper ()
|
||||
|
||||
@property (nonatomic) SUUpdater *updater;
|
||||
@property (nonatomic) SPUUpdater *updater;
|
||||
@property (nonatomic) id <SUUserDriver> userDriver;
|
||||
|
||||
@end
|
||||
@@ -42,7 +42,7 @@
|
||||
NSURL *appURL = [[[[[NSBundle mainBundle] bundleURL] URLByDeletingLastPathComponent] URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
|
||||
|
||||
NSBundle *hostBundle = [NSBundle bundleWithURL:appURL];
|
||||
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:self.userDriver delegate:nil];
|
||||
self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:self.userDriver delegate:nil];
|
||||
|
||||
NSError *updaterError = nil;
|
||||
if (![self.updater startUpdater:&updaterError]) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="SUUpdateSettingsWindowController">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "SUConstants.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SPUUpdater.h"
|
||||
#import "SUStandardUserDriver.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
@end
|
||||
|
||||
@interface SUUpdaterTest : XCTestCase <SUUpdaterDelegate>
|
||||
@property (strong) SUUpdater *updater;
|
||||
@property (strong) SPUUpdater *updater;
|
||||
@end
|
||||
|
||||
@implementation SUUpdaterTest
|
||||
@@ -95,7 +95,7 @@
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (NSString *)feedURLStringForUpdater:(SUUpdater *) __unused updater
|
||||
- (NSString *)feedURLStringForUpdater:(id)__unused updater
|
||||
{
|
||||
return @"https://test.example.com";
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void _SULogDisableStandardErrorStream(void);
|
||||
|
||||
@interface SUCommandLineDriver () <SUUpdaterDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SUUpdater *updater;
|
||||
@property (nonatomic, readonly) SPUUpdater *updater;
|
||||
@property (nonatomic, readonly) NSString *applicationBundlePath;
|
||||
@property (nonatomic, readonly) BOOL verbose;
|
||||
@property (nonatomic) BOOL probingForUpdates;
|
||||
@@ -64,7 +64,7 @@ void _SULogDisableStandardErrorStream(void);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)updaterShouldAllowInstallerInteraction:(SUUpdater *)__unused updater
|
||||
- (BOOL)updaterShouldAllowInstallerInteraction:(id)__unused updater
|
||||
{
|
||||
// If the installation is interactive, we can show an authorization prompt for requesting additional privileges,
|
||||
// otherwise we should have the installer inherit the updater's privileges.
|
||||
@@ -83,7 +83,7 @@ void _SULogDisableStandardErrorStream(void);
|
||||
}
|
||||
|
||||
// In case we fail during probing, otherwise we leave error handling to the user driver
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)__unused updater
|
||||
- (void)updaterDidNotFindUpdate:(id)__unused updater
|
||||
{
|
||||
if (self.probingForUpdates) {
|
||||
if (self.verbose) {
|
||||
@@ -94,7 +94,7 @@ void _SULogDisableStandardErrorStream(void);
|
||||
}
|
||||
|
||||
// In case we fail during probing, otherwise we leave error handling to the user driver
|
||||
- (void)updater:(SUUpdater *)__unused updater didAbortWithError:(NSError *)error
|
||||
- (void)updater:(id)__unused updater didAbortWithError:(NSError *)error
|
||||
{
|
||||
if (self.probingForUpdates) {
|
||||
if (self.verbose) {
|
||||
@@ -104,12 +104,12 @@ void _SULogDisableStandardErrorStream(void);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)__unused updater
|
||||
- (NSString *)pathToRelaunchForUpdater:(id)__unused updater
|
||||
{
|
||||
return self.applicationBundlePath;
|
||||
}
|
||||
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(SUUpdater *)__unused updater
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(id)__unused updater
|
||||
{
|
||||
return self.verbose;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user