mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Use NSRunLoop instead of NSApplication
Don't use AppKit where we don't have to, especially for command line tools
This commit is contained in:
1 parent
15483815ff
commit
83bb5354dc
5 files changed
+24
-56
No files matched your search
@@ -267,7 +267,7 @@
|
||||
72D954811CBACC35006F28BD /* InstallerProgressAppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D954801CBACC35006F28BD /* InstallerProgressAppController.m */; };
|
||||
72D954831CBAD34F006F28BD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D954821CBAD34F006F28BD /* main.m */; };
|
||||
72D954861CBB179D006F28BD /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
|
||||
72D954A21CBB415C006F28BD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D954A11CBB415C006F28BD /* AppDelegate.m */; };
|
||||
72D954A21CBB415C006F28BD /* SUCommandLineDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D954A11CBB415C006F28BD /* SUCommandLineDriver.m */; };
|
||||
72D954A51CBB415C006F28BD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D954A41CBB415C006F28BD /* main.m */; };
|
||||
72D954B31CBB42DA006F28BD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
|
||||
72D954B51CBB447A006F28BD /* Sparkle.framework in Copy Sparkle */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
@@ -897,8 +897,8 @@
|
||||
72D954841CBAD418006F28BD /* ShowInstallerProgress.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ShowInstallerProgress.h; path = Sparkle/InstallerProgress/ShowInstallerProgress.h; sourceTree = SOURCE_ROOT; };
|
||||
72D954851CBAD4AE006F28BD /* InstallerProgressAppControllerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstallerProgressAppControllerDelegate.h; path = Sparkle/InstallerProgress/InstallerProgressAppControllerDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
72D9549E1CBB415B006F28BD /* sparkle.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sparkle.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
72D954A01CBB415C006F28BD /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
72D954A11CBB415C006F28BD /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
72D954A01CBB415C006F28BD /* SUCommandLineDriver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUCommandLineDriver.h; sourceTree = "<group>"; };
|
||||
72D954A11CBB415C006F28BD /* SUCommandLineDriver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SUCommandLineDriver.m; sourceTree = "<group>"; };
|
||||
72D954A41CBB415C006F28BD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
72D954AB1CBB415C006F28BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigSparkleTool.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -1600,8 +1600,8 @@
|
||||
72D9549F1CBB415C006F28BD /* sparkle-cli */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72D954A01CBB415C006F28BD /* AppDelegate.h */,
|
||||
72D954A11CBB415C006F28BD /* AppDelegate.m */,
|
||||
72D954A01CBB415C006F28BD /* SUCommandLineDriver.h */,
|
||||
72D954A11CBB415C006F28BD /* SUCommandLineDriver.m */,
|
||||
72D954B61CBB467F006F28BD /* SUCommandLineUserDriver.h */,
|
||||
72D954B71CBB467F006F28BD /* SUCommandLineUserDriver.m */,
|
||||
72D954AB1CBB415C006F28BD /* Info.plist */,
|
||||
@@ -2564,7 +2564,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72D954A51CBB415C006F28BD /* main.m in Sources */,
|
||||
72D954A21CBB415C006F28BD /* AppDelegate.m in Sources */,
|
||||
72D954A21CBB415C006F28BD /* SUCommandLineDriver.m in Sources */,
|
||||
72D954B81CBB467F006F28BD /* SUCommandLineUserDriver.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
Vendored
+3
-35
@@ -1,33 +1,6 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SULog.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AppInstaller.h"
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
|
||||
@property (nonatomic, readonly) AppInstaller *appInstaller;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@synthesize appInstaller = _appInstaller;
|
||||
|
||||
- (instancetype)initWithAppInstaller:(AppInstaller *)appInstaller
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_appInstaller = appInstaller;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification
|
||||
{
|
||||
[self.appInstaller start];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main(int __unused argc, const char __unused *argv[])
|
||||
{
|
||||
@autoreleasepool
|
||||
@@ -41,13 +14,8 @@ int main(int __unused argc, const char __unused *argv[])
|
||||
BOOL inheritsPrivileges = args[2].boolValue;
|
||||
|
||||
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostBundleIdentifier:hostBundleIdentifier inheritsPrivileges:inheritsPrivileges];
|
||||
|
||||
AppDelegate *delegate = [[AppDelegate alloc] initWithAppInstaller:appInstaller];
|
||||
|
||||
NSApplication *application = [NSApplication sharedApplication];
|
||||
[application setDelegate:delegate];
|
||||
|
||||
[application run];
|
||||
[appInstaller start];
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// AppDelegate.h
|
||||
// SUCommandLineDriver.h
|
||||
// sparkle-cli
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
@@ -10,10 +10,12 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
@interface SUCommandLineDriver : NSObject
|
||||
|
||||
- (instancetype)initWithUpdateBundlePath:(const char *)updateBundlePath relaunchBundlePath:(const char *)relaunchBundlePath;
|
||||
|
||||
- (void)run;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,23 +1,23 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// SUCommandLineDriver.m
|
||||
// sparkle-cli
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "SUCommandLineDriver.h"
|
||||
#import <Sparkle/Sparkle.h>
|
||||
#import "SUCommandLineUserDriver.h"
|
||||
|
||||
@interface AppDelegate () <SUUpdaterDelegate>
|
||||
@interface SUCommandLineDriver () <SUUpdaterDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SUUpdater *updater;
|
||||
@property (nonatomic, readonly) NSString *relaunchBundlePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
@implementation SUCommandLineDriver
|
||||
|
||||
@synthesize updater = _updater;
|
||||
@synthesize relaunchBundlePath = _relaunchBundlePath;
|
||||
@@ -64,7 +64,7 @@
|
||||
return self.relaunchBundlePath;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)__unused aNotification
|
||||
- (void)run
|
||||
{
|
||||
// Kick off a scheduled update check once we start the updater later
|
||||
[self.updater checkForUpdates];
|
||||
+6
-8
@@ -6,8 +6,8 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "AppDelegate.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUCommandLineDriver.h"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
@@ -18,16 +18,14 @@ int main(int argc, const char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
AppDelegate *delegate = [[AppDelegate alloc] initWithUpdateBundlePath:argv[1] relaunchBundlePath:argv[2]];
|
||||
if (delegate == nil) {
|
||||
SUCommandLineDriver *driver = [[SUCommandLineDriver alloc] initWithUpdateBundlePath:argv[1] relaunchBundlePath:argv[2]];
|
||||
if (driver == nil) {
|
||||
printf("Error: Failed to initialize sparkle. Is the bundle you specified valid?\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
NSApplication *application = [NSApplication sharedApplication];
|
||||
[application setDelegate:delegate];
|
||||
|
||||
[application run];
|
||||
[driver run];
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in new issue
Block a user