diff options
author | Gerald Combs <gerald@wireshark.org> | 2022-04-09 14:14:04 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2022-04-18 18:57:43 +0000 |
commit | fea6591b0c84660f46c06029e664e2a9af18fe87 (patch) | |
tree | f4192581b2ebb181e668dc52781f9ae39c362ce7 /ui | |
parent | c8d9c6fc6a92d83c34160b8c4490f6495d57f605 (diff) |
macOS: Add support for Sparkle 2.
Sparkle 2 deprecated the sharedUpdater singleton, so create our own
which uses Sparkle 2's updated API. Ping #18035.
Update our CMake version check.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/macosx/sparkle_bridge.m | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/ui/macosx/sparkle_bridge.m b/ui/macosx/sparkle_bridge.m index 0fe59c03e7..f922b1b932 100644 --- a/ui/macosx/sparkle_bridge.m +++ b/ui/macosx/sparkle_bridge.m @@ -15,19 +15,60 @@ #import <Sparkle.h> +// XXX Is there a more reliable way to do this? +#ifdef SPUUserUpdateState_h +#define HAVE_SPARKLE_2 +#endif + // https://sparkle-project.org/documentation/customization/ -// Sparkle stores its state in ~/Library/Preferences/org.wireshark.Wireshark.plist +// Sparkle stores its state in ~/Library/Preferences/org.wireshark.Wireshark.plist. +// You can check its log output via `log stream | grep -i sparkle`. + +#ifdef HAVE_SPARKLE_2 +// The Sparkle 1 UI provided a sharedUpdater singleton, which is deprecated +// in Sparkle 2: +// https://sparkle-project.org/documentation/upgrading/ +// Create our own singleton which uses the updated API. +// https://sparkle-project.org/documentation/programmatic-setup/ + +@interface SparkleBridge : NSObject ++ (SPUStandardUpdaterController *)sharedStandardUpdaterController; +@end + +@implementation SparkleBridge + ++ (SPUStandardUpdaterController *)sharedStandardUpdaterController { + static SPUStandardUpdaterController *sharedStandardUpdaterController_ = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedStandardUpdaterController_ = [[SPUStandardUpdaterController alloc] initWithUpdaterDelegate: nil userDriverDelegate: nil]; + }); + return sharedStandardUpdaterController_; +} + +@end +#endif void sparkle_software_update_init(const char *url, bool enabled, int interval) { +#ifdef HAVE_SPARKLE_2 + [[[SparkleBridge sharedStandardUpdaterController] updater] setAutomaticallyChecksForUpdates: enabled]; + [[[SparkleBridge sharedStandardUpdaterController] updater] setUpdateCheckInterval: interval]; + [[[SparkleBridge sharedStandardUpdaterController] updater] setFeedURL: [NSURL URLWithString: [[NSString alloc] initWithUTF8String: url] ]]; +#else [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates: enabled]; [[SUUpdater sharedUpdater] setUpdateCheckInterval: interval]; [[SUUpdater sharedUpdater] setFeedURL: [NSURL URLWithString: [[NSString alloc] initWithUTF8String: url] ]]; +#endif } void sparkle_software_update_check(void) { +#ifdef HAVE_SPARKLE_2 + [[SparkleBridge sharedStandardUpdaterController] checkForUpdates: [[NSApplication sharedApplication] delegate]]; +#else [[SUUpdater sharedUpdater] checkForUpdates: [[NSApplication sharedApplication] delegate]]; +#endif } // Sparkle requires NSApplicationWillTerminateNotification in order to |