mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Merge 1645f6510b into d2fa7cf7f7
This commit is contained in:
commit
9fc6c9d66c
1 changed files with 40 additions and 32 deletions
|
|
@ -75,7 +75,6 @@ class MacSparkleUpdater::Private {
|
||||||
SPUStandardUpdaterController* updaterController;
|
SPUStandardUpdaterController* updaterController;
|
||||||
UpdaterObserver* updaterObserver;
|
UpdaterObserver* updaterObserver;
|
||||||
UpdaterDelegate* updaterDelegate;
|
UpdaterDelegate* updaterDelegate;
|
||||||
NSAutoreleasePool* autoReleasePool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MacSparkleUpdater::MacSparkleUpdater() {
|
MacSparkleUpdater::MacSparkleUpdater() {
|
||||||
|
|
@ -83,7 +82,6 @@ MacSparkleUpdater::MacSparkleUpdater() {
|
||||||
|
|
||||||
// Enable Cocoa's memory management.
|
// Enable Cocoa's memory management.
|
||||||
NSApplicationLoad();
|
NSApplicationLoad();
|
||||||
priv->autoReleasePool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
// Delegate is used for setting/getting allowed update channels.
|
// Delegate is used for setting/getting allowed update channels.
|
||||||
priv->updaterDelegate = [[UpdaterDelegate alloc] init];
|
priv->updaterDelegate = [[UpdaterDelegate alloc] init];
|
||||||
|
|
@ -101,17 +99,19 @@ MacSparkleUpdater::MacSparkleUpdater() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MacSparkleUpdater::~MacSparkleUpdater() {
|
MacSparkleUpdater::~MacSparkleUpdater() {
|
||||||
[priv->updaterObserver removeObserver:priv->updaterObserver forKeyPath:@"updater.canCheckForUpdates"];
|
@autoreleasepool {
|
||||||
|
[priv->updaterObserver removeObserver:priv->updaterObserver forKeyPath:@"updater.canCheckForUpdates"];
|
||||||
[priv->updaterController release];
|
}
|
||||||
[priv->updaterObserver release];
|
[priv->updaterObserver release];
|
||||||
|
[priv->updaterController release];
|
||||||
[priv->updaterDelegate release];
|
[priv->updaterDelegate release];
|
||||||
[priv->autoReleasePool release];
|
|
||||||
delete priv;
|
delete priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacSparkleUpdater::checkForUpdates() {
|
void MacSparkleUpdater::checkForUpdates() {
|
||||||
[priv->updaterController checkForUpdates:nil];
|
@autoreleasepool {
|
||||||
|
[priv->updaterController checkForUpdates:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacSparkleUpdater::getAutomaticallyChecksForUpdates() {
|
bool MacSparkleUpdater::getAutomaticallyChecksForUpdates() {
|
||||||
|
|
@ -123,12 +123,14 @@ double MacSparkleUpdater::getUpdateCheckInterval() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> MacSparkleUpdater::getAllowedChannels() {
|
QSet<QString> MacSparkleUpdater::getAllowedChannels() {
|
||||||
// Convert NSSet<NSString> -> QSet<QString>
|
@autoreleasepool {
|
||||||
__block QSet<QString> channels;
|
// Convert NSSet<NSString> -> QSet<QString>
|
||||||
[priv->updaterDelegate.allowedChannels enumerateObjectsUsingBlock:^(NSString* channel, BOOL* stop) {
|
__block QSet<QString> channels;
|
||||||
channels.insert(QString::fromNSString(channel));
|
[priv->updaterDelegate.allowedChannels enumerateObjectsUsingBlock:^(NSString* channel, BOOL* stop) {
|
||||||
}];
|
channels.insert(QString::fromNSString(channel));
|
||||||
return channels;
|
}];
|
||||||
|
return channels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacSparkleUpdater::getBetaAllowed() {
|
bool MacSparkleUpdater::getBetaAllowed() {
|
||||||
|
|
@ -144,34 +146,40 @@ void MacSparkleUpdater::setUpdateCheckInterval(double seconds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacSparkleUpdater::clearAllowedChannels() {
|
void MacSparkleUpdater::clearAllowedChannels() {
|
||||||
priv->updaterDelegate.allowedChannels = [NSSet set];
|
@autoreleasepool {
|
||||||
|
priv->updaterDelegate.allowedChannels = [NSSet set];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacSparkleUpdater::setAllowedChannel(const QString& channel) {
|
void MacSparkleUpdater::setAllowedChannel(const QString& channel) {
|
||||||
if (channel.isEmpty()) {
|
@autoreleasepool {
|
||||||
clearAllowedChannels();
|
if (channel.isEmpty()) {
|
||||||
return;
|
clearAllowedChannels();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NSSet<NSString*>* nsChannels = [NSSet setWithObject:channel.toNSString()];
|
NSSet<NSString*>* nsChannels = [NSSet setWithObject:channel.toNSString()];
|
||||||
priv->updaterDelegate.allowedChannels = nsChannels;
|
priv->updaterDelegate.allowedChannels = nsChannels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacSparkleUpdater::setAllowedChannels(const QSet<QString>& channels) {
|
void MacSparkleUpdater::setAllowedChannels(const QSet<QString>& channels) {
|
||||||
if (channels.isEmpty()) {
|
@autoreleasepool {
|
||||||
clearAllowedChannels();
|
if (channels.isEmpty()) {
|
||||||
return;
|
clearAllowedChannels();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString channelsConfig = "";
|
QString channelsConfig = "";
|
||||||
// Convert QSet<QString> -> NSSet<NSString>
|
// Convert QSet<QString> -> NSSet<NSString>
|
||||||
NSMutableSet<NSString*>* nsChannels = [NSMutableSet setWithCapacity:channels.count()];
|
NSMutableSet<NSString*>* nsChannels = [NSMutableSet setWithCapacity:channels.count()];
|
||||||
for (const QString& channel : channels) {
|
for (const QString& channel : channels) {
|
||||||
[nsChannels addObject:channel.toNSString()];
|
[nsChannels addObject:channel.toNSString()];
|
||||||
channelsConfig += channel + " ";
|
channelsConfig += channel + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->updaterDelegate.allowedChannels = nsChannels;
|
priv->updaterDelegate.allowedChannels = nsChannels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacSparkleUpdater::setBetaAllowed(bool allowed) {
|
void MacSparkleUpdater::setBetaAllowed(bool allowed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue