diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 18588358..bbe3268d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -214,6 +214,11 @@ CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFData NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]]; [request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"]; [self updateURLRequestHTTPHeaders:request]; + 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]; } @@ -332,6 +337,12 @@ CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFData 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 9742ef75..12fb983f 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -211,6 +211,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.