mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-04-18 02:42:30 +00:00
NOISSUE Remove concept of switching update channels
It is all develop from now on, we no longer make stable releases. This means no maintenance of version numbers and removal of all the overhead associated with making stable releases. MultiMC 6 might have a better system, but with how infrequent and stable MultiMC releases are getting, there's no need to have a distinction between `stable` and `develop` anymore.
This commit is contained in:
parent
75568ed04b
commit
458944ad91
@ -57,7 +57,7 @@ QString Config::printableVersionString() const
|
|||||||
QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX));
|
QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX));
|
||||||
|
|
||||||
// If the build is not a main release, append the channel
|
// If the build is not a main release, append the channel
|
||||||
if(VERSION_CHANNEL != "stable")
|
if(VERSION_CHANNEL != "develop")
|
||||||
{
|
{
|
||||||
vstr += "-" + VERSION_CHANNEL;
|
vstr += "-" + VERSION_CHANNEL;
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
{
|
{
|
||||||
m_settings.reset(new INISettingsObject(BuildConfig.LAUNCHER_CONFIGFILE, this));
|
m_settings.reset(new INISettingsObject(BuildConfig.LAUNCHER_CONFIGFILE, this));
|
||||||
// Updates
|
// Updates
|
||||||
m_settings->registerSetting("UpdateChannel", BuildConfig.VERSION_CHANNEL);
|
|
||||||
m_settings->registerSetting("AutoUpdate", true);
|
m_settings->registerSetting("AutoUpdate", true);
|
||||||
|
|
||||||
// Theming
|
// Theming
|
||||||
@ -812,7 +811,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
||||||
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
||||||
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
||||||
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_BUILD));
|
||||||
qDebug() << "<> Updater started.";
|
qDebug() << "<> Updater started.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
NotificationChecker::NotificationChecker(QObject *parent)
|
NotificationChecker::NotificationChecker(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent), m_appVersionChannel("develop")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,11 +19,6 @@ void NotificationChecker::setNotificationsUrl(const QUrl ¬ificationsUrl)
|
|||||||
m_notificationsUrl = notificationsUrl;
|
m_notificationsUrl = notificationsUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationChecker::setApplicationChannel(QString channel)
|
|
||||||
{
|
|
||||||
m_appVersionChannel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotificationChecker::setApplicationFullVersion(QString version)
|
void NotificationChecker::setApplicationFullVersion(QString version)
|
||||||
{
|
{
|
||||||
m_appFullVersion = version;
|
m_appFullVersion = version;
|
||||||
|
@ -14,7 +14,6 @@ public:
|
|||||||
|
|
||||||
void setNotificationsUrl(const QUrl ¬ificationsUrl);
|
void setNotificationsUrl(const QUrl ¬ificationsUrl);
|
||||||
void setApplicationPlatform(QString platform);
|
void setApplicationPlatform(QString platform);
|
||||||
void setApplicationChannel(QString channel);
|
|
||||||
void setApplicationFullVersion(QString version);
|
void setApplicationFullVersion(QString version);
|
||||||
|
|
||||||
struct NotificationEntry
|
struct NotificationEntry
|
||||||
|
@ -849,14 +849,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
// if automatic update checks are allowed, start one.
|
// if automatic update checks are allowed, start one.
|
||||||
if (APPLICATION->settings()->get("AutoUpdate").toBool() && updatesAllowed)
|
if (APPLICATION->settings()->get("AutoUpdate").toBool() && updatesAllowed)
|
||||||
{
|
{
|
||||||
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false);
|
updater->checkForUpdate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto checker = new NotificationChecker();
|
auto checker = new NotificationChecker();
|
||||||
checker->setNotificationsUrl(QUrl(BuildConfig.NOTIFICATION_URL));
|
checker->setNotificationsUrl(QUrl(BuildConfig.NOTIFICATION_URL));
|
||||||
checker->setApplicationChannel(BuildConfig.VERSION_CHANNEL);
|
|
||||||
checker->setApplicationPlatform(BuildConfig.BUILD_PLATFORM);
|
checker->setApplicationPlatform(BuildConfig.BUILD_PLATFORM);
|
||||||
checker->setApplicationFullVersion(BuildConfig.FULL_VERSION_STR);
|
checker->setApplicationFullVersion(BuildConfig.FULL_VERSION_STR);
|
||||||
m_notificationChecker.reset(checker);
|
m_notificationChecker.reset(checker);
|
||||||
@ -1639,7 +1638,7 @@ void MainWindow::checkForUpdates()
|
|||||||
if(BuildConfig.UPDATER_ENABLED)
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
{
|
{
|
||||||
auto updater = APPLICATION->updateChecker();
|
auto updater = APPLICATION->updateChecker();
|
||||||
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), true);
|
updater->checkForUpdate(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -11,14 +11,13 @@
|
|||||||
UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDialog)
|
UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
|
|
||||||
if(hasUpdate)
|
if(hasUpdate)
|
||||||
{
|
{
|
||||||
ui->label->setText(tr("A new %1 update is available!").arg(channel));
|
ui->label->setText(tr("A new update is available!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->label->setText(tr("No %1 updates found. You are running the latest version.").arg(channel));
|
ui->label->setText(tr("No updates found. You are running the latest version."));
|
||||||
ui->btnUpdateNow->setHidden(true);
|
ui->btnUpdateNow->setHidden(true);
|
||||||
ui->btnUpdateLater->setText(tr("Close"));
|
ui->btnUpdateLater->setText(tr("Close"));
|
||||||
}
|
}
|
||||||
@ -33,19 +32,10 @@ UpdateDialog::~UpdateDialog()
|
|||||||
|
|
||||||
void UpdateDialog::loadChangelog()
|
void UpdateDialog::loadChangelog()
|
||||||
{
|
{
|
||||||
auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
|
|
||||||
dljob = new NetJob("Changelog", APPLICATION->network());
|
dljob = new NetJob("Changelog", APPLICATION->network());
|
||||||
QString url;
|
QString url;
|
||||||
if(channel == "stable")
|
url = QString("https://api.github.com/repos/MultiMC/Launcher/compare/%1...develop").arg(BuildConfig.GIT_COMMIT);
|
||||||
{
|
m_changelogType = CHANGELOG_COMMITS;
|
||||||
url = QString("https://raw.githubusercontent.com/MultiMC/Launcher/%1/changelog.md").arg(channel);
|
|
||||||
m_changelogType = CHANGELOG_MARKDOWN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url = QString("https://api.github.com/repos/MultiMC/Launcher/compare/%1...%2").arg(BuildConfig.GIT_COMMIT, channel);
|
|
||||||
m_changelogType = CHANGELOG_COMMITS;
|
|
||||||
}
|
|
||||||
dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData));
|
dljob->addNetAction(Net::Download::makeByteArray(QUrl(url), &changelogData));
|
||||||
connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded);
|
connect(dljob.get(), &NetJob::succeeded, this, &UpdateDialog::changelogLoaded);
|
||||||
connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed);
|
connect(dljob.get(), &NetJob::failed, this, &UpdateDialog::changelogFailed);
|
||||||
@ -65,7 +55,6 @@ QString reprocessMarkdown(QByteArray markdown)
|
|||||||
|
|
||||||
QString reprocessCommits(QByteArray json)
|
QString reprocessCommits(QByteArray json)
|
||||||
{
|
{
|
||||||
auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
@ -119,7 +108,7 @@ QString reprocessCommits(QByteArray json)
|
|||||||
|
|
||||||
if(status == "identical")
|
if(status == "identical")
|
||||||
{
|
{
|
||||||
return QObject::tr("<p>There are no code changes between your current version and latest %1.</p>").arg(channel);
|
return QObject::tr("<p>There are no code changes between your current version and the latest.</p>");
|
||||||
}
|
}
|
||||||
else if(status == "ahead")
|
else if(status == "ahead")
|
||||||
{
|
{
|
||||||
|
@ -56,23 +56,12 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
|
|||||||
m_languageModel = APPLICATION->translations();
|
m_languageModel = APPLICATION->translations();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
// Updater
|
||||||
{
|
if(!BuildConfig.UPDATER_ENABLED)
|
||||||
QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList);
|
|
||||||
|
|
||||||
if (APPLICATION->updateChecker()->hasChannels())
|
|
||||||
{
|
|
||||||
refreshUpdateChannelList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
APPLICATION->updateChecker()->updateChanList(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ui->updateSettingsBox->setHidden(true);
|
ui->updateSettingsBox->setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
if(BuildConfig.ANALYTICS_ID.isEmpty())
|
if(BuildConfig.ANALYTICS_ID.isEmpty())
|
||||||
{
|
{
|
||||||
@ -163,78 +152,6 @@ void LauncherPage::on_migrateDataFolderMacBtn_clicked()
|
|||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherPage::refreshUpdateChannelList()
|
|
||||||
{
|
|
||||||
// Stop listening for selection changes. It's going to change a lot while we update it and
|
|
||||||
// we don't need to update the
|
|
||||||
// description label constantly.
|
|
||||||
QObject::disconnect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(updateChannelSelectionChanged(int)));
|
|
||||||
|
|
||||||
QList<UpdateChecker::ChannelListEntry> channelList = APPLICATION->updateChecker()->getChannelList();
|
|
||||||
ui->updateChannelComboBox->clear();
|
|
||||||
int selection = -1;
|
|
||||||
for (int i = 0; i < channelList.count(); i++)
|
|
||||||
{
|
|
||||||
UpdateChecker::ChannelListEntry entry = channelList.at(i);
|
|
||||||
|
|
||||||
// When it comes to selection, we'll rely on the indexes of a channel entry being the
|
|
||||||
// same in the
|
|
||||||
// combo box as it is in the update checker's channel list.
|
|
||||||
// This probably isn't very safe, but the channel list doesn't change often enough (or
|
|
||||||
// at all) for
|
|
||||||
// this to be a big deal. Hope it doesn't break...
|
|
||||||
ui->updateChannelComboBox->addItem(entry.name);
|
|
||||||
|
|
||||||
// If the update channel we just added was the selected one, set the current index in
|
|
||||||
// the combo box to it.
|
|
||||||
if (entry.id == m_currentUpdateChannel)
|
|
||||||
{
|
|
||||||
qDebug() << "Selected index" << i << "channel id" << m_currentUpdateChannel;
|
|
||||||
selection = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->updateChannelComboBox->setCurrentIndex(selection);
|
|
||||||
|
|
||||||
// Start listening for selection changes again and update the description label.
|
|
||||||
QObject::connect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(updateChannelSelectionChanged(int)));
|
|
||||||
refreshUpdateChannelDesc();
|
|
||||||
|
|
||||||
// Now that we've updated the channel list, we can enable the combo box.
|
|
||||||
// It starts off disabled so that if the channel list hasn't been loaded, it will be
|
|
||||||
// disabled.
|
|
||||||
ui->updateChannelComboBox->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherPage::updateChannelSelectionChanged(int index)
|
|
||||||
{
|
|
||||||
refreshUpdateChannelDesc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherPage::refreshUpdateChannelDesc()
|
|
||||||
{
|
|
||||||
// Get the channel list.
|
|
||||||
QList<UpdateChecker::ChannelListEntry> channelList = APPLICATION->updateChecker()->getChannelList();
|
|
||||||
int selectedIndex = ui->updateChannelComboBox->currentIndex();
|
|
||||||
if (selectedIndex < 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (selectedIndex < channelList.count())
|
|
||||||
{
|
|
||||||
// Find the channel list entry with the given index.
|
|
||||||
UpdateChecker::ChannelListEntry selected = channelList.at(selectedIndex);
|
|
||||||
|
|
||||||
// Set the description text.
|
|
||||||
ui->updateChannelDescLabel->setText(selected.description);
|
|
||||||
|
|
||||||
// Set the currently selected channel ID.
|
|
||||||
m_currentUpdateChannel = selected.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherPage::applySettings()
|
void LauncherPage::applySettings()
|
||||||
{
|
{
|
||||||
auto s = APPLICATION->settings();
|
auto s = APPLICATION->settings();
|
||||||
@ -246,7 +163,6 @@ void LauncherPage::applySettings()
|
|||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
||||||
s->set("UpdateChannel", m_currentUpdateChannel);
|
|
||||||
auto original = s->get("IconTheme").toString();
|
auto original = s->get("IconTheme").toString();
|
||||||
//FIXME: make generic
|
//FIXME: make generic
|
||||||
switch (ui->themeComboBox->currentIndex())
|
switch (ui->themeComboBox->currentIndex())
|
||||||
@ -333,7 +249,6 @@ void LauncherPage::loadSettings()
|
|||||||
auto s = APPLICATION->settings();
|
auto s = APPLICATION->settings();
|
||||||
// Updates
|
// Updates
|
||||||
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
||||||
m_currentUpdateChannel = s->get("UpdateChannel").toString();
|
|
||||||
//FIXME: make generic
|
//FIXME: make generic
|
||||||
auto theme = s->get("IconTheme").toString();
|
auto theme = s->get("IconTheme").toString();
|
||||||
if (theme == "pe_dark")
|
if (theme == "pe_dark")
|
||||||
|
@ -69,31 +69,14 @@ slots:
|
|||||||
void on_iconsDirBrowseBtn_clicked();
|
void on_iconsDirBrowseBtn_clicked();
|
||||||
void on_migrateDataFolderMacBtn_clicked();
|
void on_migrateDataFolderMacBtn_clicked();
|
||||||
|
|
||||||
/*!
|
|
||||||
* Updates the list of update channels in the combo box.
|
|
||||||
*/
|
|
||||||
void refreshUpdateChannelList();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Updates the channel description label.
|
|
||||||
*/
|
|
||||||
void refreshUpdateChannelDesc();
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Updates the font preview
|
* Updates the font preview
|
||||||
*/
|
*/
|
||||||
void refreshFontPreview();
|
void refreshFontPreview();
|
||||||
|
|
||||||
void updateChannelSelectionChanged(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LauncherPage *ui;
|
Ui::LauncherPage *ui;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Stores the currently selected update channel.
|
|
||||||
*/
|
|
||||||
QString m_currentUpdateChannel;
|
|
||||||
|
|
||||||
// default format for the font preview...
|
// default format for the font preview...
|
||||||
QTextCharFormat *defaultFormat;
|
QTextCharFormat *defaultFormat;
|
||||||
|
|
||||||
|
@ -58,33 +58,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="updateChannelLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Up&date Channel:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>updateChannelComboBox</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="updateChannelComboBox">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="updateChannelDescLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>No channel selected.</string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -555,7 +528,6 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
<tabstop>autoUpdateCheckBox</tabstop>
|
<tabstop>autoUpdateCheckBox</tabstop>
|
||||||
<tabstop>updateChannelComboBox</tabstop>
|
|
||||||
<tabstop>instDirTextBox</tabstop>
|
<tabstop>instDirTextBox</tabstop>
|
||||||
<tabstop>instDirBrowseBtn</tabstop>
|
<tabstop>instDirBrowseBtn</tabstop>
|
||||||
<tabstop>modsDirTextBox</tabstop>
|
<tabstop>modsDirTextBox</tabstop>
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
UpdateChecker::UpdateChecker(shared_qobject_ptr<QNetworkAccessManager> nam, QString channelUrl, QString currentChannel, int currentBuild)
|
UpdateChecker::UpdateChecker(shared_qobject_ptr<QNetworkAccessManager> nam, QString channelUrl, int currentBuild)
|
||||||
{
|
{
|
||||||
m_network = nam;
|
m_network = nam;
|
||||||
m_channelUrl = channelUrl;
|
m_channelUrl = channelUrl;
|
||||||
m_currentChannel = currentChannel;
|
m_currentChannel = "develop";
|
||||||
m_currentBuild = currentBuild;
|
m_currentBuild = currentBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,9 +44,10 @@ bool UpdateChecker::hasChannels() const
|
|||||||
return !m_channels.isEmpty();
|
return !m_channels.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
void UpdateChecker::checkForUpdate(bool notifyNoUpdate)
|
||||||
{
|
{
|
||||||
qDebug() << "Checking for updates.";
|
qDebug() << "Checking for updates.";
|
||||||
|
QString updateChannel = "develop";
|
||||||
|
|
||||||
// If the channel list hasn't loaded yet, load it and defer checking for updates until
|
// If the channel list hasn't loaded yet, load it and defer checking for updates until
|
||||||
// later.
|
// later.
|
||||||
@ -54,7 +55,6 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
|||||||
{
|
{
|
||||||
qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring update check.";
|
qDebug() << "Channel list isn't loaded yet. Loading channel list and deferring update check.";
|
||||||
m_checkUpdateWaiting = true;
|
m_checkUpdateWaiting = true;
|
||||||
m_deferredUpdateChannel = updateChannel;
|
|
||||||
updateChanList(notifyNoUpdate);
|
updateChanList(notifyNoUpdate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,13 +67,13 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
|||||||
|
|
||||||
// Find the desired channel within the channel list and get its repo URL. If if cannot be
|
// Find the desired channel within the channel list and get its repo URL. If if cannot be
|
||||||
// found, error.
|
// found, error.
|
||||||
QString stableUrl;
|
QString developUrl;
|
||||||
m_newRepoUrl = "";
|
m_newRepoUrl = "";
|
||||||
for (ChannelListEntry entry : m_channels)
|
for (ChannelListEntry entry : m_channels)
|
||||||
{
|
{
|
||||||
qDebug() << "channelEntry = " << entry.id;
|
qDebug() << "channelEntry = " << entry.id;
|
||||||
if(entry.id == "stable") {
|
if(entry.id == "develop") {
|
||||||
stableUrl = entry.url;
|
developUrl = entry.url;
|
||||||
}
|
}
|
||||||
if (entry.id == updateChannel) {
|
if (entry.id == updateChannel) {
|
||||||
m_newRepoUrl = entry.url;
|
m_newRepoUrl = entry.url;
|
||||||
@ -88,8 +88,8 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate)
|
|||||||
qDebug() << "m_repoUrl = " << m_newRepoUrl;
|
qDebug() << "m_repoUrl = " << m_newRepoUrl;
|
||||||
|
|
||||||
if (m_newRepoUrl.isEmpty()) {
|
if (m_newRepoUrl.isEmpty()) {
|
||||||
qWarning() << "m_repoUrl was empty. defaulting to 'stable': " << stableUrl;
|
qWarning() << "m_repoUrl was empty. defaulting to 'develop': " << developUrl;
|
||||||
m_newRepoUrl = stableUrl;
|
m_newRepoUrl = developUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If nothing applies, error
|
// If nothing applies, error
|
||||||
@ -255,7 +255,7 @@ void UpdateChecker::chanListDownloadFinished(bool notifyNoUpdate)
|
|||||||
|
|
||||||
// If we're waiting to check for updates, do that now.
|
// If we're waiting to check for updates, do that now.
|
||||||
if (m_checkUpdateWaiting) {
|
if (m_checkUpdateWaiting) {
|
||||||
checkForUpdate(m_deferredUpdateChannel, notifyNoUpdate);
|
checkForUpdate(notifyNoUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit channelListLoaded();
|
emit channelListLoaded();
|
||||||
|
@ -23,8 +23,8 @@ class UpdateChecker : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateChecker(shared_qobject_ptr<QNetworkAccessManager> nam, QString channelUrl, QString currentChannel, int currentBuild);
|
UpdateChecker(shared_qobject_ptr<QNetworkAccessManager> nam, QString channelUrl, int currentBuild);
|
||||||
void checkForUpdate(QString updateChannel, bool notifyNoUpdate);
|
void checkForUpdate(bool notifyNoUpdate);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Causes the update checker to download the channel list from the URL specified in config.h (generated by CMake).
|
* Causes the update checker to download the channel list from the URL specified in config.h (generated by CMake).
|
||||||
@ -107,11 +107,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool m_checkUpdateWaiting = false;
|
bool m_checkUpdateWaiting = false;
|
||||||
|
|
||||||
/*!
|
|
||||||
* if m_checkUpdateWaiting, this is the last used update channel
|
|
||||||
*/
|
|
||||||
QString m_deferredUpdateChannel;
|
|
||||||
|
|
||||||
int m_currentBuild = -1;
|
int m_currentBuild = -1;
|
||||||
QString m_currentChannel;
|
QString m_currentChannel;
|
||||||
QString m_currentRepoUrl;
|
QString m_currentRepoUrl;
|
||||||
|
@ -42,38 +42,32 @@ slots:
|
|||||||
|
|
||||||
void tst_ChannelListParsing_data()
|
void tst_ChannelListParsing_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("channel");
|
|
||||||
QTest::addColumn<QString>("channelUrl");
|
QTest::addColumn<QString>("channelUrl");
|
||||||
QTest::addColumn<bool>("hasChannels");
|
QTest::addColumn<bool>("hasChannels");
|
||||||
QTest::addColumn<bool>("valid");
|
QTest::addColumn<bool>("valid");
|
||||||
QTest::addColumn<QList<UpdateChecker::ChannelListEntry> >("result");
|
QTest::addColumn<QList<UpdateChecker::ChannelListEntry> >("result");
|
||||||
|
|
||||||
QTest::newRow("garbage")
|
QTest::newRow("garbage")
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("data/garbageChannels.json")
|
<< findTestDataUrl("data/garbageChannels.json")
|
||||||
<< false
|
<< false
|
||||||
<< false
|
<< false
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
<< QList<UpdateChecker::ChannelListEntry>();
|
||||||
QTest::newRow("errors")
|
QTest::newRow("errors")
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("data/errorChannels.json")
|
<< findTestDataUrl("data/errorChannels.json")
|
||||||
<< false
|
<< false
|
||||||
<< true
|
<< true
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
<< QList<UpdateChecker::ChannelListEntry>();
|
||||||
QTest::newRow("no channels")
|
QTest::newRow("no channels")
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("data/noChannels.json")
|
<< findTestDataUrl("data/noChannels.json")
|
||||||
<< false
|
<< false
|
||||||
<< true
|
<< true
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
<< QList<UpdateChecker::ChannelListEntry>();
|
||||||
QTest::newRow("one channel")
|
QTest::newRow("one channel")
|
||||||
<< QString("develop")
|
|
||||||
<< findTestDataUrl("data/oneChannel.json")
|
<< findTestDataUrl("data/oneChannel.json")
|
||||||
<< true
|
<< true
|
||||||
<< true
|
<< true
|
||||||
<< (QList<UpdateChecker::ChannelListEntry>() << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", "http://example.org/stuff"});
|
<< (QList<UpdateChecker::ChannelListEntry>() << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", "http://example.org/stuff"});
|
||||||
QTest::newRow("several channels")
|
QTest::newRow("several channels")
|
||||||
<< QString("develop")
|
|
||||||
<< findTestDataUrl("data/channels.json")
|
<< findTestDataUrl("data/channels.json")
|
||||||
<< true
|
<< true
|
||||||
<< true
|
<< true
|
||||||
@ -84,15 +78,13 @@ slots:
|
|||||||
}
|
}
|
||||||
void tst_ChannelListParsing()
|
void tst_ChannelListParsing()
|
||||||
{
|
{
|
||||||
|
|
||||||
QFETCH(QString, channel);
|
|
||||||
QFETCH(QString, channelUrl);
|
QFETCH(QString, channelUrl);
|
||||||
QFETCH(bool, hasChannels);
|
QFETCH(bool, hasChannels);
|
||||||
QFETCH(bool, valid);
|
QFETCH(bool, valid);
|
||||||
QFETCH(QList<UpdateChecker::ChannelListEntry>, result);
|
QFETCH(QList<UpdateChecker::ChannelListEntry>, result);
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
||||||
UpdateChecker checker(nam, channelUrl, channel, 0);
|
UpdateChecker checker(nam, channelUrl, 0);
|
||||||
|
|
||||||
QSignalSpy channelListLoadedSpy(&checker, SIGNAL(channelListLoaded()));
|
QSignalSpy channelListLoadedSpy(&checker, SIGNAL(channelListLoaded()));
|
||||||
QVERIFY(channelListLoadedSpy.isValid());
|
QVERIFY(channelListLoadedSpy.isValid());
|
||||||
@ -116,12 +108,11 @@ slots:
|
|||||||
|
|
||||||
void tst_UpdateChecking()
|
void tst_UpdateChecking()
|
||||||
{
|
{
|
||||||
QString channel = "develop";
|
|
||||||
QString channelUrl = findTestDataUrl("data/channels.json");
|
QString channelUrl = findTestDataUrl("data/channels.json");
|
||||||
int currentBuild = 2;
|
int currentBuild = 2;
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
||||||
UpdateChecker checker(nam, channelUrl, channel, currentBuild);
|
UpdateChecker checker(nam, channelUrl, currentBuild);
|
||||||
|
|
||||||
QSignalSpy updateAvailableSpy(&checker, SIGNAL(updateAvailable(GoUpdate::Status)));
|
QSignalSpy updateAvailableSpy(&checker, SIGNAL(updateAvailable(GoUpdate::Status)));
|
||||||
QVERIFY(updateAvailableSpy.isValid());
|
QVERIFY(updateAvailableSpy.isValid());
|
||||||
@ -133,7 +124,7 @@ slots:
|
|||||||
|
|
||||||
qDebug() << "CWD:" << QDir::current().absolutePath();
|
qDebug() << "CWD:" << QDir::current().absolutePath();
|
||||||
checker.m_channels[0].url = findTestDataUrl("data/");
|
checker.m_channels[0].url = findTestDataUrl("data/");
|
||||||
checker.checkForUpdate(channel, false);
|
checker.checkForUpdate(false);
|
||||||
|
|
||||||
QVERIFY(updateAvailableSpy.wait());
|
QVERIFY(updateAvailableSpy.wait());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user