From 5eb715f1f3dcf00a4b3e1e028f5df7b42387464d Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 2 Mar 2016 00:53:28 -0500 Subject: [PATCH] Added docs to sparkle's user driver Also split SUSparkleUserDriverDelegate into two protocols, since it just makes sense. --- Sparkle.xcodeproj/project.pbxproj | 12 ++-- Sparkle/SUSparkleUserDriver.h | 40 ++++++++++++- Sparkle/SUSparkleUserDriver.m | 3 +- Sparkle/SUSparkleUserDriverDelegate.h | 29 ---------- Sparkle/SUSparkleUserDriverRemoteDelegate.h | 62 +++++++++++++++++++++ Sparkle/SUSparkleUserDriverUIDelegate.h | 46 +++++++++++++++ 6 files changed, 157 insertions(+), 35 deletions(-) delete mode 100644 Sparkle/SUSparkleUserDriverDelegate.h create mode 100644 Sparkle/SUSparkleUserDriverRemoteDelegate.h create mode 100644 Sparkle/SUSparkleUserDriverUIDelegate.h diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 48780d39..28978061 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -181,7 +181,8 @@ 725CB95B1C7121830064365A /* SUSparkleUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725CB9591C7121830064365A /* SUSparkleUserDriver.m */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SUStatusCompletionResults.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 726E4A0E1C86881600C57C6A /* SUSparkleUserDriverDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverDelegate.h */; }; + 726E4A0E1C86881600C57C6A /* SUSparkleUserDriverUIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverUIDelegate.h */; }; + 726E4A101C86B5A200C57C6A /* SUSparkleUserDriverRemoteDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A0F1C86B5A200C57C6A /* SUSparkleUserDriverRemoteDelegate.h */; }; 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; }; 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; @@ -643,7 +644,8 @@ 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; 726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 726DF88D1C84277500188804 /* SUStatusCompletionResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUStatusCompletionResults.h; sourceTree = ""; }; - 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSparkleUserDriverDelegate.h; sourceTree = ""; }; + 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSparkleUserDriverUIDelegate.h; sourceTree = ""; }; + 726E4A0F1C86B5A200C57C6A /* SUSparkleUserDriverRemoteDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSparkleUserDriverRemoteDelegate.h; sourceTree = ""; }; 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUOperatingSystem.h; sourceTree = ""; }; 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUOperatingSystem.m; sourceTree = ""; }; 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; @@ -1000,7 +1002,8 @@ children = ( 7246E0A11C83B685003B4E75 /* SUUpdaterController.h */, 7246E0A21C83B685003B4E75 /* SUUpdaterController.m */, - 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverDelegate.h */, + 726E4A0D1C86881600C57C6A /* SUSparkleUserDriverUIDelegate.h */, + 726E4A0F1C86B5A200C57C6A /* SUSparkleUserDriverRemoteDelegate.h */, 725CB9581C7121830064365A /* SUSparkleUserDriver.h */, 725CB9591C7121830064365A /* SUSparkleUserDriver.m */, 6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */, @@ -1184,6 +1187,7 @@ 72162B061C82C8B30013C1C5 /* SUParameterAssert.h in Headers */, 726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */, 72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */, + 726E4A101C86B5A200C57C6A /* SUSparkleUserDriverRemoteDelegate.h in Headers */, 611142E910FB1BE5009810AA /* bspatch.h in Headers */, 61299B3609CB04E000B7442F /* Sparkle.h in Headers */, 61CFB3290E385186007A1735 /* Sparkle.pch in Headers */, @@ -1225,7 +1229,7 @@ 61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */, 6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */, 61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */, - 726E4A0E1C86881600C57C6A /* SUSparkleUserDriverDelegate.h in Headers */, + 726E4A0E1C86881600C57C6A /* SUSparkleUserDriverUIDelegate.h in Headers */, 61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */, 3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */, ); diff --git a/Sparkle/SUSparkleUserDriver.h b/Sparkle/SUSparkleUserDriver.h index 629005a0..e731f38d 100644 --- a/Sparkle/SUSparkleUserDriver.h +++ b/Sparkle/SUSparkleUserDriver.h @@ -11,16 +11,54 @@ NS_ASSUME_NONNULL_BEGIN -@protocol SUSparkleUserDriverDelegate; +@protocol SUSparkleUserDriverUIDelegate, SUSparkleUserDriverRemoteDelegate; +/*! + A protocol for Sparkle's user driver's delegate + + If you are interested in UI interactions, check out SUSparkleUserDriverUIDelegate + If you are interested in XPC or remote process communications for efficiency and reliability, check out SUSparkleUserDriverRemoteDelegate + */ +@protocol SUSparkleUserDriverDelegate +@end + +/*! + Sparkle's standard built-in driver for user updater interactions + */ @interface SUSparkleUserDriver : NSObject +/*! + Initializes a Sparkle's standard user driver for user update interactions + + @param hostBundle The target bundle of the host that is being updated + @param delegate The delegate to this user driver. Pass nil if you don't want to provide one. + */ - (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(_Nullable id )delegate; +/*! + Readable and writable property for this user driver's delegate + */ @property (nonatomic, weak, nullable) id delegate; +/*! + Indicates whether or not an update is in progress as far as the user is concerned + + A typical application may rely on this property for its check for updates menu item validation + */ @property (nonatomic, readonly, getter=isUpdateInProgress) BOOL updateInProgress; +/*! + Send a signal to the user driver that the user application should terminate. + + This should only be invoked if the user driver's delegate says it's responsible for signaling application termination, + and this should only be called from NSApplicationDelegate's applicationShouldTerminate: method. + + This is particularly useful when the user driver and updater live in separate processes, and the updater + wants to install an automatic update on termination. If the updater is in a separate process, that means + we may have to defer application termination a bit until the updater is ready to launch its auto updater. + + @return The NSApplication termination reply. Use this as a return value to NSApplicationDelegate's applicationShouldTerminate: + */ - (NSApplicationTerminateReply)sendApplicationTerminationSignal; @end diff --git a/Sparkle/SUSparkleUserDriver.m b/Sparkle/SUSparkleUserDriver.m index b6ef62e4..d7bbc245 100644 --- a/Sparkle/SUSparkleUserDriver.m +++ b/Sparkle/SUSparkleUserDriver.m @@ -7,7 +7,8 @@ // #import "SUSparkleUserDriver.h" -#import "SUSparkleUserDriverDelegate.h" +#import "SUSparkleUserDriverUIDelegate.h" +#import "SUSparkleUserDriverRemoteDelegate.h" #import "SUAppcastItem.h" #import "SUVersionDisplayProtocol.h" #import "SUHost.h" diff --git a/Sparkle/SUSparkleUserDriverDelegate.h b/Sparkle/SUSparkleUserDriverDelegate.h deleted file mode 100644 index a56d8ccc..00000000 --- a/Sparkle/SUSparkleUserDriverDelegate.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// SUSparkleUserDriverDelegate.h -// Sparkle -// -// Created by Mayur Pawashe on 3/1/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol SUUserDriver, SUVersionDisplay; - -@protocol SUSparkleUserDriverDelegate - -- (void)userDriverWillShowModalAlert:(id )userDriver; -- (void)userDriverDidShowModalAlert:(id )userDriver; - -- (_Nullable id )versionDisplayerForUserDriver:(id )userDriver; - -- (BOOL)responsibleForInitiatingUpdateCheckForUserDriver:(id )userDriver; -- (void)initiateUpdateCheckForUserDriver:(id )userDriver; - -- (BOOL)responsibleForSignalingApplicationTerminationForUserDriver:(id )userDriver; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUSparkleUserDriverRemoteDelegate.h b/Sparkle/SUSparkleUserDriverRemoteDelegate.h new file mode 100644 index 00000000..ae83893a --- /dev/null +++ b/Sparkle/SUSparkleUserDriverRemoteDelegate.h @@ -0,0 +1,62 @@ +// +// SUSparkleUserDriverRemoteDelegate.h +// Sparkle +// +// Created by Mayur Pawashe on 3/2/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol SUUserDriver; + +/*! + A delegate protocol for Sparkle's user driver related to efficiency and reliablity when Sparkle's updater lives in a separate process + */ +@protocol SUSparkleUserDriverRemoteDelegate + +/*! + 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 -initiateUpdateCheckForUserDriver: which is when the delegate should + initiate update checks. + + @param userDriver The user driver instance. + */ +- (BOOL)responsibleForInitiatingUpdateCheckForUserDriver:(id )userDriver; + +/*! + Called when user driver tells the delegate to initiate an update check + + This is called if the delegate returned YES from -responsibleForInitiatingUpdateCheckForUserDriver: + + 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 -responsibleForInitiatingUpdateCheckForUserDriver: as to why + a delegate may want to implement this. + + @param userDriver The user driver instance. + */ +- (void)initiateUpdateCheckForUserDriver:(id )userDriver; + +/*! + Asks whether or not the delegate is responsible for letting the user driver know when the application is about to terminate + + This is necessary to implement when automatic updates are possible and when the updater and user driver live in separate processes. + + See -[SUSparkleUserDriver sendApplicationTerminationSignal] for more details on how to follow up + + @param userDriver The user driver instance. + */ +- (BOOL)responsibleForSignalingApplicationTerminationForUserDriver:(id )userDriver; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUSparkleUserDriverUIDelegate.h b/Sparkle/SUSparkleUserDriverUIDelegate.h new file mode 100644 index 00000000..a40db5b4 --- /dev/null +++ b/Sparkle/SUSparkleUserDriverUIDelegate.h @@ -0,0 +1,46 @@ +// +// SUSparkleUserDriverUIDelegate.h +// Sparkle +// +// Created by Mayur Pawashe on 3/1/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol SUUserDriver, SUVersionDisplay; + +/*! + A delegate protocol for Sparkle's user driver related to user interactions + */ +@protocol SUSparkleUserDriverUIDelegate + +/*! + Called before showing a modal alert window, + to give the opportunity to hide attached windows that may get in the way. + + @param userDriver The user driver instance. + */ +- (void)userDriverWillShowModalAlert:(id )userDriver; + +/*! + Called after showing a modal alert window, + to give the opportunity to hide attached windows that may get in the way. + + @param userDriver The user driver instance. + */ +- (void)userDriverDidShowModalAlert:(id )userDriver; + +/*! + 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. + \param userDriver The user driver instance. + */ +- (_Nullable id )versionDisplayerForUserDriver:(id )userDriver; + +@end + +NS_ASSUME_NONNULL_END