mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Simplify user driver API
Deprecate the "done" statuses for user initiated update checks and downloading updates because they really did nothing but burden implementor (there was a relic of an XPC reason back in the day that no longer applies).
This commit is contained in:
1 parent
1f90f7c993
commit
833eb89bb5
5 files changed
+14
-28
No files matched your search
Vendored
+2
-2
@@ -19,12 +19,12 @@
|
||||
#endif
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) {
|
||||
SPUUserInitiatedCheckDone,
|
||||
SPUUserInitiatedCheckDone __deprecated_msg("Deprecated because SPUUserInitiatedCheckDone has no effect. Just don't reply with this status."),
|
||||
SPUUserInitiatedCheckCanceled
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) {
|
||||
SPUDownloadUpdateDone,
|
||||
SPUDownloadUpdateDone __deprecated_msg("Deprecated because SPUDownloadUpdateDone has no effect. Just don't reply with this status."),
|
||||
SPUDownloadUpdateCanceled
|
||||
};
|
||||
|
||||
|
||||
Vendored
+4
@@ -203,7 +203,11 @@
|
||||
{
|
||||
[self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) {
|
||||
switch (downloadCompletionStatus) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
case SPUDownloadUpdateDone:
|
||||
// Note this status is documented to have no effect
|
||||
#pragma clang diagnostic pop
|
||||
break;
|
||||
case SPUDownloadUpdateCanceled:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Vendored
+2
-18
@@ -28,18 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell
|
||||
an object that implements this protocol what actions to take and show to the user.
|
||||
|
||||
Every method in this protocol is required (i.e, not optional) and has a void return type and can optionally take a single parameter block, which waits for
|
||||
a response back from the user driver. Note that every parameter block, or reply, *must* be responded to eventually -
|
||||
that is, none can be ignored. Furthermore, they can only be replied to *once* - a reply or completion block should be considered
|
||||
invalidated after it's once used. The faster a reply can be made, the more Sparkle may be able to idle, and so the better.
|
||||
Every method in this protocol can be assumed to be called from the main thread.
|
||||
|
||||
It may be possible for an action that says to invalidate or dismiss something to be called multiple times in succession, and the implementor may choose to ignore further requests. (TODO: This should be verified if this actually can happen in practice).
|
||||
|
||||
Note: Once upon a time, when first developing the user driver API, I had the user driver exist in a separate process from the rest of the framework (this is no longer supported).
|
||||
If you're familiar with how the higher level XPC APIs work, this explains why some of the decisions above were made
|
||||
(reply block executed on any thread, reply block replied only once, single reply block, void return types, idleness, no optional methods, ...)
|
||||
This is somewhat of an artifact now, but I think most of these set of restrictions still enforces a well designed API.
|
||||
*/
|
||||
SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
|
||||
@@ -66,9 +55,8 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*
|
||||
* Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar.
|
||||
*
|
||||
* @param updateCheckStatusCompletion A reply indicating whether the initiated update check is done or canceled.
|
||||
* Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. Replying with SPUUserInitiatedCheckDone
|
||||
* on the other hand should not be done until -dismissUserInitiatedUpdateCheck is invoked.
|
||||
* @param updateCheckStatusCompletion A reply that can be used to cancel the update check with SPUUserInitiatedCheckCanceled.
|
||||
* Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked.
|
||||
*/
|
||||
- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion;
|
||||
|
||||
@@ -76,7 +64,6 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
* Dismiss the user initiated update check from the user
|
||||
*
|
||||
* Dismiss whatever was started in -showUserInitiatedUpdateCheckWithCompletion:
|
||||
* This is an appropriate time to reply with SPUUserInitiatedCheckDone if not having done so already
|
||||
*/
|
||||
- (void)dismissUserInitiatedUpdateCheck;
|
||||
|
||||
@@ -194,8 +181,6 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*
|
||||
* @param downloadUpdateStatusCompletion A reply of SPUDownloadUpdateCanceled can be used to cancel
|
||||
* the download at any point before -showDownloadDidStartExtractingUpdate is invoked.
|
||||
* A reply of SPUDownloadUpdateDone signifies that the download is done, which should not be invoked until
|
||||
* -showDownloadDidStartExtractingUpdate
|
||||
*/
|
||||
- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion;
|
||||
|
||||
@@ -219,7 +204,6 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
/*!
|
||||
* Show the user that the update finished downloading and started extracting
|
||||
*
|
||||
* This is an appropriate time to reply with SPUDownloadUpdateDone if not done so already
|
||||
* Sparkle uses this to show an indeterminate progress bar.
|
||||
*
|
||||
* Note that an update can resume at this point after having been downloaded before,
|
||||
|
||||
Vendored
+2
-8
@@ -67,10 +67,7 @@
|
||||
|
||||
- (void)completeUpdateCheckStatus
|
||||
{
|
||||
if (self.updateCheckStatusCompletion != nil) {
|
||||
self.updateCheckStatusCompletion(SPUUserInitiatedCheckDone);
|
||||
self.updateCheckStatusCompletion = nil;
|
||||
}
|
||||
self.updateCheckStatusCompletion = nil;
|
||||
}
|
||||
|
||||
#pragma mark Download Status
|
||||
@@ -90,10 +87,7 @@
|
||||
|
||||
- (void)completeDownloadStatus
|
||||
{
|
||||
if (self.downloadStatusCompletion != nil) {
|
||||
self.downloadStatusCompletion(SPUDownloadUpdateDone);
|
||||
self.downloadStatusCompletion = nil;
|
||||
}
|
||||
self.downloadStatusCompletion = nil;
|
||||
}
|
||||
|
||||
#pragma mark Simple Acknoledgments
|
||||
|
||||
+4
@@ -52,7 +52,11 @@
|
||||
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) {
|
||||
switch (completionStatus) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
case SPUUserInitiatedCheckDone:
|
||||
// Note this status is documented to have no effect
|
||||
#pragma clang diagnostic pop
|
||||
break;
|
||||
case SPUUserInitiatedCheckCanceled:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Reference in new issue
Block a user