mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-30 05:28:50 +00:00
Move installer status info service to progress agent
This commit is contained in:
1 parent
50594dda57
commit
3244bf7f14
6 files changed
+42
-27
No files matched your search
+10
-21
@@ -8,7 +8,6 @@
|
||||
|
||||
#import "AppInstaller.h"
|
||||
#import "TerminationListener.h"
|
||||
#import "StatusInfo.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SULog.h"
|
||||
#import "SUHost.h"
|
||||
@@ -54,7 +53,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@property (nonatomic) NSXPCListener* xpcListener;
|
||||
@property (nonatomic) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> communicator;
|
||||
@property (nonatomic) StatusInfo *statusInfo;
|
||||
@property (nonatomic) AgentConnection *agentConnection;
|
||||
@property (nonatomic) BOOL receivedUpdaterPong;
|
||||
|
||||
@@ -85,7 +83,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize communicator = _communicator;
|
||||
@synthesize statusInfo = _statusInfo;
|
||||
@synthesize agentConnection = _agentConnection;
|
||||
@synthesize receivedUpdaterPong = _receivedUpdaterPong;
|
||||
@synthesize hostBundleIdentifier = _hostBundleIdentifier;
|
||||
@@ -117,7 +114,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
|
||||
_statusInfo = [[StatusInfo alloc] initWithHostBundleIdentifier:hostBundleIdentifier];
|
||||
_agentConnection = [[AgentConnection alloc] initWithHostBundleIdentifier:hostBundleIdentifier delegate:self];
|
||||
|
||||
return self;
|
||||
@@ -169,7 +165,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
- (void)start
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[self.statusInfo startListener];
|
||||
[self.agentConnection startListener];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FIRST_UPDATER_MESSAGE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@@ -399,12 +394,13 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
}
|
||||
});
|
||||
} else if (identifier == SUSentUpdateAppcastItemData) {
|
||||
if (self.statusInfo.installationInfoData == nil) {
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
|
||||
if (updateItem != nil) {
|
||||
SUInstallationInfo *installationInfo = [[SUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[self.installer canInstallSilently]];
|
||||
|
||||
self.statusInfo.installationInfoData = SUArchiveRootObjectSecurely(installationInfo);
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
|
||||
if (updateItem != nil) {
|
||||
SUInstallationInfo *installationInfo = [[SUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[self.installer canInstallSilently]];
|
||||
|
||||
NSData *archivedData = SUArchiveRootObjectSecurely(installationInfo);
|
||||
if (archivedData != nil) {
|
||||
[self.agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
}
|
||||
}
|
||||
} else if (identifier == SUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
|
||||
@@ -583,18 +579,14 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
self.performedStage3Installation = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Make sure to terminate our displayed progress before we move onto cleanup
|
||||
// Make sure to terminate our displayed progress before we move onto cleanup & relaunch
|
||||
// This will also stop the agent from broadcasting the status info service, which we want to do before
|
||||
// we relaunch the app because the relaunched app could check the service upon launch..
|
||||
[self.agentConnection.agent stopProgress];
|
||||
shouldLaunchInstallerProgress = NO;
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SUInstallationFinishedStage3 data:[NSData data]];
|
||||
|
||||
// Invalidate the status info listener before re-launching the updated app
|
||||
// If we don't do this, the updated app could think the installation can be resumable,
|
||||
// if it checks for updates immediately on launch
|
||||
[self.statusInfo invalidate];
|
||||
self.statusInfo = nil;
|
||||
|
||||
NSString *installationPath = [SUInstaller installationPathForHost:self.host];
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
@@ -632,9 +624,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
|
||||
[self.statusInfo invalidate];
|
||||
self.statusInfo = nil;
|
||||
|
||||
[self.agentConnection invalidate];
|
||||
self.agentConnection = nil;
|
||||
|
||||
|
||||
@@ -80,10 +80,14 @@
|
||||
jobDictionary[@"NICE"] = @0;
|
||||
jobDictionary[@"LaunchOnlyOnce"] = @YES;
|
||||
|
||||
NSMutableDictionary *machServicesDictionary = [[NSMutableDictionary alloc] init];
|
||||
machServicesDictionary[SUStatusInfoServiceNameForBundleIdentifier(hostBundleIdentifier)] = @YES;
|
||||
if (shouldSubmitInstaller) {
|
||||
jobDictionary[@"MachServices"] = @{SUProgressAgentLauncherServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES};
|
||||
machServicesDictionary[SUProgressAgentLauncherServiceNameForBundleIdentifier(hostBundleIdentifier)] = @YES;
|
||||
}
|
||||
|
||||
jobDictionary[@"MachServices"] = [machServicesDictionary copy];
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
submittedJob = SMJobSubmit(domain, (__bridge CFDictionaryRef)(jobDictionary), auth, &submitError);
|
||||
if (!submittedJob) {
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"NICE" : @0, @"LaunchOnlyOnce": @YES, @"MachServices" : @{SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUStatusInfoServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"NICE" : @0, @"LaunchOnlyOnce": @YES, @"MachServices" : @{SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
submittedJob = SMJobSubmit(domain, (__bridge CFDictionaryRef)(jobDictionary), auth, &submitError);
|
||||
|
||||
@@ -180,7 +180,6 @@
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59B1D3D8A5A00D1BF90 /* SUDSAVerifier.m */; };
|
||||
7267E59F1D3D8A6F00D1BF90 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E59E1D3D8A6F00D1BF90 /* main.m */; };
|
||||
7267E5A21D3D8A7E00D1BF90 /* AppInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A11D3D8A7E00D1BF90 /* AppInstaller.m */; };
|
||||
7267E5A51D3D8A8A00D1BF90 /* StatusInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A41D3D8A8A00D1BF90 /* StatusInfo.m */; };
|
||||
7267E5A81D3D8A9900D1BF90 /* AgentConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A71D3D8A9900D1BF90 /* AgentConnection.m */; };
|
||||
7267E5AB1D3D8AA800D1BF90 /* TerminationListener.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5AA1D3D8AA800D1BF90 /* TerminationListener.m */; };
|
||||
7267E5AE1D3D8AB700D1BF90 /* SUInstallationInputData.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5AD1D3D8AB700D1BF90 /* SUInstallationInputData.m */; };
|
||||
@@ -233,6 +232,7 @@
|
||||
7267E5F71D3D919600D1BF90 /* SUPlainInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5C11D3D8B2700D1BF90 /* SUPlainInstaller.m */; };
|
||||
7267E5F81D3D91A800D1BF90 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5831D3D89B300D1BF90 /* SUPipedUnarchiver.m */; };
|
||||
7267E5F91D3D92DA00D1BF90 /* Autoupdate in CopyFiles */ = {isa = PBXBuildFile; fileRef = 72B398D21D3D879300EE297F /* Autoupdate */; };
|
||||
7267E5FA1D3DAC3600D1BF90 /* StatusInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A41D3D8A8A00D1BF90 /* StatusInfo.m */; };
|
||||
726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SUStatusCompletionResults.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
726E075C1CA3A6D6001A286B /* SUSecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E075A1CA3A6D6001A286B /* SUSecureCoding.h */; };
|
||||
726E075D1CA3A6D6001A286B /* SUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SUSecureCoding.m */; };
|
||||
@@ -1315,8 +1315,6 @@
|
||||
7267E59E1D3D8A6F00D1BF90 /* main.m */,
|
||||
7267E5A01D3D8A7E00D1BF90 /* AppInstaller.h */,
|
||||
7267E5A11D3D8A7E00D1BF90 /* AppInstaller.m */,
|
||||
7267E5A31D3D8A8A00D1BF90 /* StatusInfo.h */,
|
||||
7267E5A41D3D8A8A00D1BF90 /* StatusInfo.m */,
|
||||
7267E5A61D3D8A9900D1BF90 /* AgentConnection.h */,
|
||||
7267E5A71D3D8A9900D1BF90 /* AgentConnection.m */,
|
||||
7267E5A91D3D8AA800D1BF90 /* TerminationListener.h */,
|
||||
@@ -1557,6 +1555,8 @@
|
||||
721652641D3C744700FD13D8 /* InstallerProgressLauncher.m */,
|
||||
72D954841CBAD418006F28BD /* ShowInstallerProgress.h */,
|
||||
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */,
|
||||
7267E5A31D3D8A8A00D1BF90 /* StatusInfo.h */,
|
||||
7267E5A41D3D8A8A00D1BF90 /* StatusInfo.m */,
|
||||
72D954821CBAD34F006F28BD /* main.m */,
|
||||
721C24581CB7567D005440CB /* InstallerProgress-Info.plist */,
|
||||
);
|
||||
@@ -2570,6 +2570,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7267E5FA1D3DAC3600D1BF90 /* StatusInfo.m in Sources */,
|
||||
7267E5EB1D3D90C200D1BF90 /* SUFileManager.m in Sources */,
|
||||
7267E5DC1D3D8F1E00D1BF90 /* SUMessageTypes.m in Sources */,
|
||||
721652621D3C44A100FD13D8 /* SUSystemAuthorization.m in Sources */,
|
||||
@@ -2687,7 +2688,6 @@
|
||||
7267E5C41D3D8B2700D1BF90 /* SUPackageInstaller.m in Sources */,
|
||||
7267E5771D3D895B00D1BF90 /* SUBinaryDeltaCommon.m in Sources */,
|
||||
7267E5871D3D89B300D1BF90 /* SUPipedUnarchiver.m in Sources */,
|
||||
7267E5A51D3D8A8A00D1BF90 /* StatusInfo.m in Sources */,
|
||||
7267E5751D3D895B00D1BF90 /* SUBinaryDeltaApply.m in Sources */,
|
||||
7267E59D1D3D8A5A00D1BF90 /* SUDSAVerifier.m in Sources */,
|
||||
7267E5791D3D895B00D1BF90 /* SUBinaryDeltaCreate.m in Sources */,
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#import "SUInstallerAgentProtocol.h"
|
||||
#import "SUInstallerAgentInitiationProtocol.h"
|
||||
#import "InstallerProgressLauncher.h"
|
||||
#import "StatusInfo.h"
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
|
||||
/*!
|
||||
@@ -32,6 +33,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
@property (nonatomic) BOOL repliedToRegistration;
|
||||
@property (nonatomic, readonly) NSBundle *hostBundle;
|
||||
@property (nonatomic, readonly, nullable) InstallerProgressLauncher *progressLauncher;
|
||||
@property (nonatomic) StatusInfo *statusInfo;
|
||||
@property (nonatomic) BOOL submittedLauncherJob;
|
||||
|
||||
@end
|
||||
@@ -47,6 +49,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
@synthesize repliedToRegistration = _repliedToRegistration;
|
||||
@synthesize hostBundle = _hostBundle;
|
||||
@synthesize progressLauncher = _progressLauncher;
|
||||
@synthesize statusInfo = _statusInfo;
|
||||
@synthesize submittedLauncherJob = _submittedLauncherJob;
|
||||
|
||||
- (instancetype)initWithApplication:(NSApplication *)application arguments:(NSArray<NSString *> *)arguments delegate:(id<InstallerProgressDelegate>)delegate
|
||||
@@ -89,6 +92,8 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
_progressLauncher = [[InstallerProgressLauncher alloc] initWithHostBundle:_hostBundle installerPath:installerPath allowingInteraction:allowingInteraction delegate:self];
|
||||
}
|
||||
|
||||
_statusInfo = [[StatusInfo alloc] initWithHostBundleIdentifier:hostBundleIdentifier];
|
||||
|
||||
application.delegate = self;
|
||||
|
||||
_application = application;
|
||||
@@ -130,6 +135,8 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
|
||||
- (void)startConnection
|
||||
{
|
||||
[self.statusInfo startListener];
|
||||
|
||||
[self.connection resume];
|
||||
[self.connection.remoteObjectProxy connectionDidInitiateWithReply:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -156,6 +163,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
|
||||
- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn))
|
||||
{
|
||||
[self.statusInfo invalidate];
|
||||
[self.connection invalidate];
|
||||
[self.progressLauncher invalidate];
|
||||
|
||||
@@ -194,6 +202,15 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.statusInfo.installationInfoData == nil) {
|
||||
self.statusInfo.installationInfoData = installationInfoData;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)relaunchPath:(NSString *)pathToRelaunch
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -229,6 +246,9 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
|
||||
- (void)_stopProgress
|
||||
{
|
||||
[self.statusInfo invalidate];
|
||||
self.statusInfo = nil;
|
||||
|
||||
[self.delegate installerProgressShouldStop];
|
||||
self.delegate = nil;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)registerRelaunchBundlePath:(NSString *)relaunchBundlePath reply:(void (^)(NSNumber * _Nullable processIdentifier))reply;
|
||||
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData;
|
||||
|
||||
- (void)showProgress;
|
||||
|
||||
- (void)stopProgress;
|
||||
|
||||
Reference in new issue
Block a user