diff --git a/native/atom_application.h b/native/atom_application.h index 29ad86adf..7db0bece8 100644 --- a/native/atom_application.h +++ b/native/atom_application.h @@ -6,8 +6,10 @@ class AtomCefClient; @interface AtomApplication : NSApplication { NSWindowController *_backgroundWindowController; NSDictionary *_arguments; + NSInvocation *_updateInvocation; + NSString *_updateStatus; BOOL _filesOpened; - BOOL handlingSendEvent_; + BOOL _handlingSendEvent; } + (AtomApplication *)sharedApplication; @@ -21,6 +23,8 @@ class AtomCefClient; - (void)runSpecsThenExit:(BOOL)exitWhenDone; - (NSDictionary *)arguments; - (void)runBenchmarksThenExit:(BOOL)exitWhenDone; +- (NSString *)updateStatus; +- (void)installUpdate; @property (nonatomic, retain) NSDictionary *arguments; diff --git a/native/atom_application.mm b/native/atom_application.mm index 48721fc62..102774de5 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -135,6 +135,7 @@ - (void)dealloc { [_backgroundWindowController release]; [_arguments release]; + [_updateInvocation release]; [super dealloc]; } @@ -236,11 +237,11 @@ # pragma mark CefAppProtocol - (BOOL)isHandlingSendEvent { - return handlingSendEvent_; + return _handlingSendEvent; } - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { - handlingSendEvent_ = handlingSendEvent; + _handlingSendEvent = handlingSendEvent; } - (void)sendEvent:(NSEvent*)event { @@ -256,26 +257,35 @@ } } +- (NSString *)updateStatus { + return _updateStatus ? _updateStatus : @"idle"; +} + +- (void)installUpdate { + if (_updateInvocation) [_updateInvocation invoke]; +} + #pragma mark SUUpdaterDelegate - (void)updaterDidNotFindUpdate:(SUUpdater *)update { - NSLog(@"No update found"); + _updateStatus = @"current"; } - (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update { - NSLog(@"Found Update"); + _updateStatus = @"downloading"; } - (void)updater:(SUUpdater *)updater willExtractUpdate:(SUAppcastItem *)update { - NSLog(@"Extract update"); + _updateStatus = @"installing"; } - (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)update immediateInstallationInvocation:(NSInvocation *)invocation { - NSLog(@"Install Update"); + _updateInvocation = invocation; + _updateStatus = @"ready"; } - (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)update { - NSLog(@"Cancel Update Install"); + _updateStatus = @"current"; } @end diff --git a/native/atom_cef_client.cpp b/native/atom_cef_client.cpp index 34e679124..61be7900e 100644 --- a/native/atom_cef_client.cpp +++ b/native/atom_cef_client.cpp @@ -84,6 +84,12 @@ bool AtomCefClient::OnProcessMessageReceived(CefRefPtr browser, else if (name == "toggleFullScreen") { ToggleFullScreen(browser); } + else if (name == "update") { + Update(); + } + else if (name == "getUpdateStatus") { + GetUpdateStatus(messageId, browser); + } else { return false; } diff --git a/native/atom_cef_client.h b/native/atom_cef_client.h index 16a80298b..812559c32 100644 --- a/native/atom_cef_client.h +++ b/native/atom_cef_client.h @@ -126,6 +126,8 @@ class AtomCefClient : public CefClient, void Log(const char *message); void Show(CefRefPtr browser); void ToggleFullScreen(CefRefPtr browser); + void Update(); + void GetUpdateStatus(int replyId, CefRefPtr browser); IMPLEMENT_REFCOUNTING(AtomCefClient); IMPLEMENT_LOCKING(AtomCefClient); diff --git a/native/atom_cef_client_mac.mm b/native/atom_cef_client_mac.mm index fdb398732..0ef9c0cbc 100644 --- a/native/atom_cef_client_mac.mm +++ b/native/atom_cef_client_mac.mm @@ -5,6 +5,7 @@ #import "native/atom_cef_client.h" #import "atom_application.h" #import "atom_window_controller.h" +#import "atom_application.h" void AtomCefClient::FocusNextWindow() { NSArray *windows = [NSApp windows]; @@ -157,3 +158,18 @@ void AtomCefClient::Exit(int status) { void AtomCefClient::Log(const char *message) { std::cout << message << "\n"; } + +void AtomCefClient::Update() { + [(AtomApplication *)NSApp installUpdate]; +} + +void AtomCefClient::GetUpdateStatus(int replyId, CefRefPtr browser) { + CefRefPtr replyMessage = CefProcessMessage::Create("reply"); + CefRefPtr replyArguments = replyMessage->GetArgumentList(); + + replyArguments->SetSize(2); + replyArguments->SetString(1, [[(AtomApplication *)NSApp updateStatus] UTF8String]); + replyArguments->SetList(0, CreateReplyDescriptor(replyId, 0)); + + browser->SendProcessMessage(PID_RENDERER, replyMessage); +} \ No newline at end of file diff --git a/script/copy-files-to-bundle b/script/copy-files-to-bundle index c8ab8dd4f..c509e7aef 100755 --- a/script/copy-files-to-bundle +++ b/script/copy-files-to-bundle @@ -10,15 +10,12 @@ if [ -f /opt/github/env.sh ]; then fi RESOUCES_PATH="$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH" -mkdir -p "$RESOUCES_PATH/v8_extensions" -cp "$PROJECT_DIR/native/v8_extensions/"*.js "$RESOUCES_PATH/v8_extensions/" DIRS="src static vendor" # Compile .coffee files into bundle COFFEE_FILES=$(find $DIRS -type file -name '*.coffee') for COFFEE_FILE in $COFFEE_FILES; do - echo $COFFEE_FILE JS_FILE=$(echo "$RESOUCES_PATH/$COFFEE_FILE" | sed 's/.coffee/.js/' ) OUTPUT_PATH="$RESOUCES_PATH/$(dirname "$COFFEE_FILE")" @@ -31,7 +28,6 @@ done; # Compile .cson files into bundle CSON_FILES=$(find $DIRS -type file -name '*.cson') for CSON_FILE in $CSON_FILES; do - echo $CSON_FILE JSON_FILE=$(echo "$RESOUCES_PATH/$CSON_FILE" | sed 's/.cson/.json/' ) OUTPUT_PATH="$RESOUCES_PATH/$(dirname "$CSON_FILE")" diff --git a/src/app/atom.coffee b/src/app/atom.coffee index b642e5ac8..524a6ce26 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -163,3 +163,9 @@ _.extend atom, _.valueForKeyPath(windowState, keyPath) else windowState + + update: -> + @sendMessageToBrowserProcess('update') + + getUpdateStatus: (callback) -> + @sendMessageToBrowserProcess('getUpdateStatus', [], callback) \ No newline at end of file