mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add atom.update and atom.getUpdateStatus
This commit is contained in:
@@ -6,8 +6,10 @@ class AtomCefClient;
|
||||
@interface AtomApplication : NSApplication <CefAppProtocol, NSApplicationDelegate> {
|
||||
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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -84,6 +84,12 @@ bool AtomCefClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
else if (name == "toggleFullScreen") {
|
||||
ToggleFullScreen(browser);
|
||||
}
|
||||
else if (name == "update") {
|
||||
Update();
|
||||
}
|
||||
else if (name == "getUpdateStatus") {
|
||||
GetUpdateStatus(messageId, browser);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ class AtomCefClient : public CefClient,
|
||||
void Log(const char *message);
|
||||
void Show(CefRefPtr<CefBrowser> browser);
|
||||
void ToggleFullScreen(CefRefPtr<CefBrowser> browser);
|
||||
void Update();
|
||||
void GetUpdateStatus(int replyId, CefRefPtr<CefBrowser> browser);
|
||||
|
||||
IMPLEMENT_REFCOUNTING(AtomCefClient);
|
||||
IMPLEMENT_LOCKING(AtomCefClient);
|
||||
|
||||
@@ -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<CefBrowser> browser) {
|
||||
CefRefPtr<CefProcessMessage> replyMessage = CefProcessMessage::Create("reply");
|
||||
CefRefPtr<CefListValue> replyArguments = replyMessage->GetArgumentList();
|
||||
|
||||
replyArguments->SetSize(2);
|
||||
replyArguments->SetString(1, [[(AtomApplication *)NSApp updateStatus] UTF8String]);
|
||||
replyArguments->SetList(0, CreateReplyDescriptor(replyId, 0));
|
||||
|
||||
browser->SendProcessMessage(PID_RENDERER, replyMessage);
|
||||
}
|
||||
@@ -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")"
|
||||
|
||||
|
||||
@@ -163,3 +163,9 @@ _.extend atom,
|
||||
_.valueForKeyPath(windowState, keyPath)
|
||||
else
|
||||
windowState
|
||||
|
||||
update: ->
|
||||
@sendMessageToBrowserProcess('update')
|
||||
|
||||
getUpdateStatus: (callback) ->
|
||||
@sendMessageToBrowserProcess('getUpdateStatus', [], callback)
|
||||
Reference in New Issue
Block a user