From fbb9fbf53534cd25dfd56d2c458c346b5fb705f0 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 14 May 2016 21:56:35 -0400 Subject: [PATCH] Add showing release notes from sparkle-cli --- sparkle-cli/SUCommandLineUserDriver.m | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sparkle-cli/SUCommandLineUserDriver.m b/sparkle-cli/SUCommandLineUserDriver.m index 4b4f8ac0..71dc059a 100644 --- a/sparkle-cli/SUCommandLineUserDriver.m +++ b/sparkle-cli/SUCommandLineUserDriver.m @@ -119,22 +119,46 @@ }); } +- (void)displayReleaseNotes:(NSData *)releaseNotes +{ + NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTML:releaseNotes documentAttributes:NULL]; + fprintf(stderr, "Release notes:\n"); + fprintf(stderr, "%s\n", attributedString.string.UTF8String); +} + - (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem allowsAutomaticUpdates:(BOOL)__unused allowsAutomaticUpdates alreadyDownloaded:(BOOL)__unused alreadyDownloaded reply:(void (^)(SUUpdateAlertChoice))reply { dispatch_async(dispatch_get_main_queue(), ^{ if (self.verbose) { fprintf(stderr, "Found new update! (%s)\n", appcastItem.displayVersionString.UTF8String); + + if (appcastItem.itemDescription != nil) { + NSData *descriptionData = [appcastItem.itemDescription dataUsingEncoding:NSUTF8StringEncoding]; + if (descriptionData != nil) { + [self displayReleaseNotes:descriptionData]; + } + } } reply(SUInstallUpdateChoice); }); } -- (void)showUpdateReleaseNotes:(NSData *)__unused releaseNotes +- (void)showUpdateReleaseNotes:(NSData *)releaseNotes { + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.verbose) { + [self displayReleaseNotes:releaseNotes]; + } + }); } -- (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)__unused error +- (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)error { + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.verbose) { + fprintf(stderr, "Error: Unable to download release notes: %s\n", error.description.UTF8String); + } + }); } - (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))__unused acknowledgement