mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
For sparkle-cli and out-of-process updaters, I added a did finish installing event. I also have logic dealing with whether an update can be silently installed or not. I made closing status windows before app termination a reponsibility for the user driver now, not the installer drivers. I improved checking for updates before starting the updater, if Sparle didn't ask the user for permission yet. Currently, Autoupdate can persist in the background even when the app is terminated, if we don't have sufficient privilleges to install right away for example, or if an update isn't silent. After much thinking, I need to ditch this strategy because: 1. An app can be manually replaced and so the installer would have to monitor that 2. We leave a zombie process running
56 lines
1.5 KiB
Objective-C
56 lines
1.5 KiB
Objective-C
//
|
|
// AppDelegate.m
|
|
// sparkle-cli
|
|
//
|
|
// Created by Mayur Pawashe on 4/10/16.
|
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
|
//
|
|
|
|
#import "AppDelegate.h"
|
|
#import <Sparkle/Sparkle.h>
|
|
#import "SUCommandLineUserDriver.h"
|
|
|
|
@interface AppDelegate ()
|
|
|
|
@property (nonatomic, readonly) SUUpdater *updater;
|
|
|
|
@end
|
|
|
|
@implementation AppDelegate
|
|
|
|
@synthesize updater = _updater;
|
|
|
|
- (instancetype)initWithBundlePath:(const char *)bundlePath
|
|
{
|
|
self = [super init];
|
|
if (self != nil) {
|
|
NSString *bundlePathString = [[NSString alloc] initWithUTF8String:bundlePath];
|
|
if (bundlePathString == nil) {
|
|
return nil;
|
|
}
|
|
|
|
NSBundle *bundle = [NSBundle bundleWithPath:bundlePathString];
|
|
if (bundle == nil) {
|
|
return nil;
|
|
}
|
|
|
|
id <SUUserDriver> userDriver = [[SUCommandLineUserDriver alloc] initWithBundle:bundle];
|
|
_updater = [[SUUpdater alloc] initWithHostBundle:bundle userDriver:userDriver delegate:nil];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification *)__unused aNotification
|
|
{
|
|
// Kick off a scheduled update check once we start the updater later
|
|
[self.updater checkForUpdates];
|
|
|
|
NSError *updaterError = nil;
|
|
if (![self.updater startUpdater:&updaterError]) {
|
|
printf("Error: Failed to initialize updater with error (%ld): %s\n", updaterError.code, updaterError.localizedDescription.UTF8String);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
@end
|