Emit 'update-available' and 'checking-for-update' events.
This commit is contained in:
parent
da602a7c01
commit
6949af5427
4 changed files with 26 additions and 0 deletions
|
@ -30,6 +30,14 @@ void AutoUpdater::OnError(const std::string& error) {
|
||||||
Emit("error", &args);
|
Emit("error", &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoUpdater::OnCheckingForUpdate() {
|
||||||
|
Emit("checking-for-update");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoUpdater::OnUpdateAvailable() {
|
||||||
|
Emit("update-available");
|
||||||
|
}
|
||||||
|
|
||||||
void AutoUpdater::OnUpdateNotAvailable() {
|
void AutoUpdater::OnUpdateNotAvailable() {
|
||||||
Emit("update-not-available");
|
Emit("update-not-available");
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ class AutoUpdater : public EventEmitter,
|
||||||
|
|
||||||
// AutoUpdaterDelegate implementations.
|
// AutoUpdaterDelegate implementations.
|
||||||
virtual void OnError(const std::string& error) OVERRIDE;
|
virtual void OnError(const std::string& error) OVERRIDE;
|
||||||
|
virtual void OnCheckingForUpdate() OVERRIDE;
|
||||||
|
virtual void OnUpdateAvailable() OVERRIDE;
|
||||||
virtual void OnUpdateNotAvailable() OVERRIDE;
|
virtual void OnUpdateNotAvailable() OVERRIDE;
|
||||||
virtual void OnUpdateDownloaded(
|
virtual void OnUpdateDownloaded(
|
||||||
const std::string& release_notes,
|
const std::string& release_notes,
|
||||||
|
|
|
@ -20,6 +20,12 @@ class AutoUpdaterDelegate {
|
||||||
// An error happened.
|
// An error happened.
|
||||||
virtual void OnError(const std::string& error) {}
|
virtual void OnError(const std::string& error) {}
|
||||||
|
|
||||||
|
// Checking to see if there is an update
|
||||||
|
virtual void OnCheckingForUpdate() {}
|
||||||
|
|
||||||
|
// There is an update available and it is being downloaded
|
||||||
|
virtual void OnUpdateAvailable() {}
|
||||||
|
|
||||||
// There is no available update.
|
// There is no available update.
|
||||||
virtual void OnUpdateNotAvailable() {}
|
virtual void OnUpdateNotAvailable() {}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#import <ReactiveCocoa/RACCommand.h>
|
#import <ReactiveCocoa/RACCommand.h>
|
||||||
#import <ReactiveCocoa/RACSignal.h>
|
#import <ReactiveCocoa/RACSignal.h>
|
||||||
|
#import <ReactiveCocoa/NSObject+RACPropertySubscribing.h>
|
||||||
#import <Squirrel/Squirrel.h>
|
#import <Squirrel/Squirrel.h>
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
|
@ -63,6 +64,15 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
|
||||||
if (!has_update)
|
if (!has_update)
|
||||||
delegate->OnUpdateNotAvailable();
|
delegate->OnUpdateNotAvailable();
|
||||||
has_update = false;
|
has_update = false;
|
||||||
|
[[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
|
||||||
|
subscribeNext:^(NSNumber *stateNumber) {
|
||||||
|
int state = [stateNumber integerValue];
|
||||||
|
if (state == SQRLUpdaterStateCheckingForUpdate) {
|
||||||
|
delegate->OnCheckingForUpdate();
|
||||||
|
}
|
||||||
|
else if (state == SQRLUpdaterStateDownloadingUpdate) {
|
||||||
|
delegate->OnUpdateAvailable();
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue