diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index d6f72f53..b3600ccf 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -191,6 +191,11 @@ { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]]; [request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"]; + if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) { + [[self.updater delegate] updater:self.updater + willDownloadUpdate:self.updateItem + withRequest:request]; + } self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self]; } @@ -309,6 +314,12 @@ if (!failingUrl) { failingUrl = [self.updateItem fileURL]; } + + if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) { + [[self.updater delegate] updater:self.updater + failedToDownloadUpdate:self.updateItem + error:error]; + } [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index ea52e53d..3ac4828a 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -209,6 +209,24 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; */ - (void)updaterDidNotFindUpdate:(SUUpdater *)updater; +/*! + Called immediately before downloading the specified update. + + \param updater The SUUpdater 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; + +/*! + Called after the specified update failed to download. + + \param updater The SUUpdater 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; + /*! Called immediately before installing the specified update.