mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
We support NSSecureCoding for SUAppcastItem and SUHost Callbacks from XPC <-> Host app now async to main GCD queue. This is needed for everything to be thread safe. Todo: NSDate parsing sucks and is temporarily disabled. In particular, we're using deprecated methods to read the dates, which don't support NSSecureCoding. The other problem is that the dates are really useless technically and we shouldn't sort by them.
149 lines
3.3 KiB
Objective-C
149 lines
3.3 KiB
Objective-C
//
|
|
// SUUpdateSettingsWindowController.m
|
|
// Sparkle
|
|
//
|
|
// Created by Mayur Pawashe on 7/25/15.
|
|
// Copyright (c) 2015 Sparkle Project. All rights reserved.
|
|
//
|
|
|
|
#import "SUUpdateSettingsWindowController.h"
|
|
#import <Sparkle/Sparkle.h>
|
|
|
|
#import "SUUserUpdaterDriver.h"
|
|
|
|
@interface SULoggerUpdateDriver : NSObject<SUUserUpdaterDriver>
|
|
|
|
@property (nonatomic, readonly) SUHost *host;
|
|
|
|
@end
|
|
|
|
@implementation SULoggerUpdateDriver
|
|
|
|
@synthesize host = _host;
|
|
|
|
- (instancetype)initWithHost:(SUHost *)host
|
|
{
|
|
self = [super init];
|
|
if (self != nil) {
|
|
_host = host;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)requestUpdatePermissionWithSystemProfile:(NSArray *)systemProfile reply:(void (^)(SUUpdatePermissionPromptResult *))reply
|
|
{
|
|
NSLog(@"Giving permission to automatically install updates!");
|
|
reply([SUUpdatePermissionPromptResult updatePermissionPromptResultWithChoice:SUAutomaticallyCheck shouldSendProfile:YES]);
|
|
}
|
|
|
|
- (void)openInfoURLForAppcastItem:(SUAppcastItem *)appcastItem
|
|
{
|
|
NSLog(@"Hah, you want to open info URL? That's funny!");
|
|
}
|
|
|
|
- (void)showUserInitiatedUpdateCheckWithCancelCallback:(void (^)(void))cancelUpdateCheck
|
|
{
|
|
NSLog(@"Evil user initiated an update check!");
|
|
}
|
|
|
|
- (void)dismissUserInitiatedUpdateCheck
|
|
{
|
|
NSLog(@"Update check is done!");
|
|
}
|
|
|
|
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem versionDisplayer:(id<SUVersionDisplay>)versionDisplayer reply:(void (^)(SUUpdateAlertChoice))reply
|
|
{
|
|
NSLog(@"OMG new update was found! Let's install it!");
|
|
reply(SUInstallUpdateChoice);
|
|
}
|
|
|
|
- (void)showUpdateNotFound
|
|
{
|
|
NSLog(@":( there was no new update");
|
|
}
|
|
|
|
- (BOOL)showsUpdateNotFoundModally
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (void)showUpdaterError:(NSError *)error
|
|
{
|
|
NSLog(@"Update error: %@", error);
|
|
}
|
|
|
|
- (BOOL)showsUpdateErrorModally
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
- (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))cancelDownload
|
|
{
|
|
NSLog(@"Downloading update...");
|
|
}
|
|
|
|
- (void)showDownloadDidReceiveResponse:(NSURLResponse *)response
|
|
{
|
|
NSLog(@"Download recieved length: %lld", response.expectedContentLength);
|
|
}
|
|
|
|
- (void)showDownloadDidReceiveDataOfLength:(NSUInteger)length
|
|
{
|
|
NSLog(@"Download received progress: %lu", length);
|
|
}
|
|
|
|
- (void)showDownloadFinishedAndStartedExtractingUpdate
|
|
{
|
|
NSLog(@"Download finished.. Extracting..");
|
|
}
|
|
|
|
- (void)showExtractionReceivedProgress:(double)progress
|
|
{
|
|
NSLog(@"Extracting progress: %f", progress);
|
|
}
|
|
|
|
- (void)showExtractionFinishedAndReadyToInstallAndRelaunch:(void (^)(void))installUpdateAndRelaunch
|
|
{
|
|
NSLog(@"Extracting finished.. Letting it install & relaunch..");
|
|
installUpdateAndRelaunch();
|
|
}
|
|
|
|
- (void)showInstallingUpdate
|
|
{
|
|
NSLog(@"Installing update...");
|
|
}
|
|
|
|
- (void)dismissUpdateInstallation
|
|
{
|
|
NSLog(@"Dismissing the installation.");
|
|
}
|
|
|
|
@end
|
|
|
|
@interface SUUpdateSettingsWindowController ()
|
|
|
|
@property (nonatomic) IBOutlet SUUpdater *updater;
|
|
|
|
@end
|
|
|
|
@implementation SUUpdateSettingsWindowController
|
|
|
|
@synthesize updater = _updater;
|
|
|
|
- (void)windowDidLoad
|
|
{
|
|
self.updater.userUpdaterDriver = [[/* SUSparkleUserUpdaterDriver */ SULoggerUpdateDriver alloc] initWithHost:[[SUHost alloc] initWithBundle:[NSBundle mainBundle]]];
|
|
}
|
|
|
|
- (NSString *)windowNibName
|
|
{
|
|
return NSStringFromClass([self class]);
|
|
}
|
|
|
|
- (IBAction)checkForUpdates:(id __unused)sender
|
|
{
|
|
[self.updater checkForUpdates:nil];
|
|
}
|
|
|
|
@end
|