autoupdate: add Sparkle framework
This commits brings optionnal linking against Sparkle framework.
This framework is used to autoupdate apps not present in the Mac app store
Refs #75349
Change-Id: I82b14757c106f1282d91e631927057d00989feb7
diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm
index 197b320..6325438 100644
--- a/src/AppDelegate.mm
+++ b/src/AppDelegate.mm
@@ -36,10 +36,18 @@
#import <QItemSelectionModel>
#import <account.h>
+#if ENABLE_SPARKLE
+#import <Sparkle/Sparkle.h>
+#endif
+
#import "Constants.h"
#import "RingWizardWC.h"
+#if ENABLE_SPARKLE
+@interface AppDelegate() <SUUpdaterDelegate>
+#else
@interface AppDelegate()
+#endif
@property RingWindowController* ringWindowController;
@property RingWizardWC* wizard;
@@ -51,7 +59,6 @@
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
-
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager];
@@ -148,4 +155,30 @@
[[NSApplication sharedApplication] terminate:self];
}
+#if ENABLE_SPARKLE
+
+#pragma mark -
+#pragma mark Sparkle delegate
+
+- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
+{
+ [NSApp activateIgnoringOtherApps:YES];
+}
+
+- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle
+{
+ return YES;
+}
+
+- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater
+{
+ return YES;
+}
+
+- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error
+{
+ NSLog(@"Error:%@", error.localizedDescription);
+}
+
+#endif
@end