updater->downloadState() != OCUpdater::DownloadComplete);
_ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
+
+ // Channel selection
+ _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0);
+ connect(_ui->updateChannel, &QComboBox::currentTextChanged,
+ this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection);
+
} else {
// can't have those infos from sparkle currently
_ui->updatesGroupBox->setVisible(false);
}
}
+void GeneralSettings::slotUpdateChannelChanged(const QString &channel)
+{
+ ConfigFile().setUpdateChannel(channel);
+ auto *updater = qobject_cast<OCUpdater *>(Updater::instance());
+ if (updater) {
+ updater->setUpdateUrl(Updater::updateUrl());
+ updater->checkForUpdate();
+ }
+}
+
void GeneralSettings::slotUpdateCheckNow()
{
auto *updater = qobject_cast<OCUpdater *>(Updater::instance());
void slotShowLegalNotice();
#if defined(BUILD_UPDATER)
void slotUpdateInfo();
+ void slotUpdateChannelChanged(const QString &channel);
void slotUpdateCheckNow();
void slotToggleAutoUpdateCheck();
#endif
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <spacer name="horizontalSpacer_5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <widget class="QLabel" name="updateChannelLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Preferred</enum>
+ <property name="text">
+ <string>&Channel</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ <property name="buddy">
+ <cstring>updateChannel</cstring>
</property>
- </spacer>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="updateChannel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>stable</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>beta</string>
+ </property>
+ </item>
+ </widget>
</item>
- </layout>
- </item>
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="updateStateLabel">
<property name="text">
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</item>
</layout>
{
}
+void OCUpdater::setUpdateUrl(const QUrl &url)
+{
+ _updateUrl = url;
+}
+
bool OCUpdater::performUpdate()
{
ConfigFile cfg;
UpdateOnlyAvailableThroughSystem };
explicit OCUpdater(const QUrl &url);
+ void setUpdateUrl(const QUrl &url);
+
bool performUpdate();
void checkForUpdate() override;
#include "theme.h"
#include "common/utility.h"
#include "version.h"
+#include "configfile.h"
#include "config.h"
#include "configfile.h"
return _instance;
}
+QUrl Updater::updateUrl()
+{
+ QUrl updateBaseUrl(QString::fromLocal8Bit(qgetenv("OCC_UPDATE_URL")));
+ if (updateBaseUrl.isEmpty()) {
+ updateBaseUrl = QUrl(QLatin1String(APPLICATION_UPDATE_URL));
+ }
+ if (!updateBaseUrl.isValid() || updateBaseUrl.host() == ".") {
+ return QUrl();
+ }
+
+ auto urlQuery = getQueryParams();
+
+#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
+ urlQuery.addQueryItem(QLatin1String("sparkle"), QLatin1String("true"));
+#endif
+
+ updateBaseUrl.setQuery(urlQuery);
+
+ return updateBaseUrl;
+}
+
QUrlQuery Updater::getQueryParams()
{
QUrlQuery query;
QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
query.addQueryItem(QLatin1String("versionsuffix"), suffix);
- if (suffix.startsWith("daily")
- || suffix.startsWith("nightly")
- || suffix.startsWith("alpha")
- || suffix.startsWith("rc")
- || suffix.startsWith("beta")) {
- query.addQueryItem(QLatin1String("channel"), "beta");
- // FIXME: Provide a checkbox in UI to enable regular versions to switch
- // to beta channel
+
+ auto channel = ConfigFile().updateChannel();
+ if (channel != "stable") {
+ query.addQueryItem(QLatin1String("channel"), channel);
}
// updateSegment (see configfile.h)
// To test, cmake with -DAPPLICATION_UPDATE_URL="http://127.0.0.1:8080/test.rss"
Updater *Updater::create()
{
- QUrl updateBaseUrl(QString::fromLocal8Bit(qgetenv("OCC_UPDATE_URL")));
- if (updateBaseUrl.isEmpty()) {
- updateBaseUrl = QUrl(QLatin1String(APPLICATION_UPDATE_URL));
- }
- if (!updateBaseUrl.isValid() || updateBaseUrl.host() == ".") {
+ auto url = updateUrl();
+ if (url.isEmpty()) {
qCWarning(lcUpdater) << "Not a valid updater URL, will not do update check";
return nullptr;
}
- auto urlQuery = getQueryParams();
-
-#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
- urlQuery.addQueryItem(QLatin1String("sparkle"), QLatin1String("true"));
-#endif
-
- updateBaseUrl.setQuery(urlQuery);
-
#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
- return new SparkleUpdater(updateBaseUrl.toString());
+ return new SparkleUpdater(url.toString());
#elif defined(Q_OS_WIN32)
// the best we can do is notify about updates
- return new NSISUpdater(updateBaseUrl);
+ return new NSISUpdater(url);
#else
- return new PassiveUpdateNotifier(QUrl(updateBaseUrl));
+ return new PassiveUpdateNotifier(url);
#endif
}
};
static Updater *instance();
+ static QUrl updateUrl();
virtual void checkForUpdate() = 0;
virtual void backgroundCheckForUpdate() = 0;
#include "theme.h"
#include "common/utility.h"
#include "common/asserts.h"
+#include "version.h"
#include "creds/abstractcredentials.h"
#include "creds/keychainchunk.h"
static const char autoUpdateCheckC[] = "autoUpdateCheck";
static const char updateCheckIntervalC[] = "updateCheckInterval";
static const char updateSegmentC[] = "updateSegment";
+static const char updateChannelC[] = "updateChannel";
static const char geometryC[] = "geometry";
static const char timeoutC[] = "timeout";
static const char chunkSizeC[] = "chunkSize";
return segment;
}
+QString ConfigFile::updateChannel() const
+{
+ QString defaultUpdateChannel = QStringLiteral("stable");
+ QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
+ if (suffix.startsWith("daily")
+ || suffix.startsWith("nightly")
+ || suffix.startsWith("alpha")
+ || suffix.startsWith("rc")
+ || suffix.startsWith("beta")) {
+ defaultUpdateChannel = QStringLiteral("beta");
+ }
+
+ QSettings settings(configFile(), QSettings::IniFormat);
+ return settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
+}
+
+void ConfigFile::setUpdateChannel(const QString &channel)
+{
+ QSettings settings(configFile(), QSettings::IniFormat);
+ settings.setValue(QLatin1String(updateChannelC), channel);
+}
+
int ConfigFile::maxLogLines() const
{
QSettings settings(configFile(), QSettings::IniFormat);
See: https://github.com/nextcloud/client_updater_server/pull/36 */
int updateSegment() const;
+ QString updateChannel() const;
+ void setUpdateChannel(const QString &channel);
+
void saveGeometryHeader(QHeaderView *header);
void restoreGeometryHeader(QHeaderView *header);