diff options
author | Daniel Molkentin <danimo@owncloud.com> | 2014-02-06 21:54:48 +0400 |
---|---|---|
committer | Daniel Molkentin <danimo@owncloud.com> | 2014-02-06 21:56:33 +0400 |
commit | 97345447ab79b30ac568499835bf1cf21f27496d (patch) | |
tree | 998fbd6caf89994e247c36de9d16b1f56452eb28 /src/updater | |
parent | bb378902aeaed620b3be719fcca637f7d5ec286b (diff) |
Updater: Unify Sparkle&non-Sparkle URLs
...now that we have the support on the server-side.
Diffstat (limited to 'src/updater')
-rw-r--r-- | src/updater/ocupdater.cpp | 43 | ||||
-rw-r--r-- | src/updater/ocupdater.h | 2 | ||||
-rw-r--r-- | src/updater/updater.cpp | 57 | ||||
-rw-r--r-- | src/updater/updater.h | 5 |
4 files changed, 60 insertions, 47 deletions
diff --git a/src/updater/ocupdater.cpp b/src/updater/ocupdater.cpp index 36cb64731..797d69174 100644 --- a/src/updater/ocupdater.cpp +++ b/src/updater/ocupdater.cpp @@ -116,27 +116,7 @@ void OCUpdater::slotStartInstaller() void OCUpdater::checkForUpdate() { - Theme *theme = Theme::instance(); - QUrl url(_updateUrl); - QString platform = QLatin1String("stranger"); - if (Utility::isLinux()) { - platform = QLatin1String("linux"); - } else if (Utility::isWindows()) { - platform = QLatin1String("win32"); - } else if (Utility::isMac()) { - platform = QLatin1String("macos"); - } - qDebug() << "00 client update check to " << url.toString(); - - QString sysInfo = getSystemInfo(); - if( !sysInfo.isEmpty() ) { - url.addQueryItem(QLatin1String("client"), sysInfo ); - } - url.addQueryItem( QLatin1String("version"), clientVersion() ); - url.addQueryItem( QLatin1String("platform"), platform ); - url.addQueryItem( QLatin1String("oem"), theme->appName() ); - - QNetworkReply *reply = _accessManager->get( QNetworkRequest(url) ); + QNetworkReply *reply = _accessManager->get(QNetworkRequest(_updateUrl)); connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimedOut())); _timer->start(30*1000); connect(reply, SIGNAL(finished()), this, SLOT(slotVersionInfoArrived())); @@ -147,22 +127,6 @@ void OCUpdater::slotOpenUpdateUrl() QDesktopServices::openUrl(_updateInfo.web()); } -QString OCUpdater::getSystemInfo() -{ -#ifdef Q_OS_LINUX - QProcess process; - process.start( QLatin1String("lsb_release -a") ); - process.waitForFinished(); - QByteArray output = process.readAllStandardOutput(); - qDebug() << "Sys Info size: " << output.length(); - if( output.length() > 1024 ) output.clear(); // don't send too much. - - return QString::fromLocal8Bit( output.toBase64() ); -#else - return QString::null; -#endif -} - bool OCUpdater::updateSucceeded() const { MirallConfigFile cfg; @@ -173,11 +137,6 @@ bool OCUpdater::updateSucceeded() const return currentVersion >= targetVersionInt; } -QString OCUpdater::clientVersion() const -{ - return QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_FULL)); -} - void OCUpdater::slotVersionInfoArrived() { _timer->stop(); diff --git a/src/updater/ocupdater.h b/src/updater/ocupdater.h index 9d99f257a..2b7c9765b 100644 --- a/src/updater/ocupdater.h +++ b/src/updater/ocupdater.h @@ -61,8 +61,6 @@ private slots: protected: virtual void versionInfoArrived(const UpdateInfo &info) = 0; bool updateSucceeded() const; - QString clientVersion() const; - QString getSystemInfo(); QNetworkAccessManager* qnam() const { return _accessManager; } UpdateInfo updateInfo() const { return _updateInfo; } private: diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 65b3ff0f3..f0dd46512 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -11,11 +11,17 @@ * for more details. */ +#include <QUrl> +#include <QProcess> +#include <QDebug> + #include "updater/updater.h" #include "updater/sparkleupdater.h" #include "updater/ocupdater.h" #include "mirall/version.h" +#include "mirall/theme.h" +#include "mirall/utility.h" #include "config.h" @@ -31,15 +37,56 @@ Updater * Updater::instance() return _instance; } +QUrl Updater::addQueryParams(const QUrl &url) +{ + QUrl paramUrl = url; + Theme *theme = Theme::instance(); + QString platform = QLatin1String("stranger"); + if (Utility::isLinux()) { + platform = QLatin1String("linux"); + } else if (Utility::isWindows()) { + platform = QLatin1String("win32"); + } else if (Utility::isMac()) { + platform = QLatin1String("macos"); + } + + QString sysInfo = getSystemInfo(); + if( !sysInfo.isEmpty() ) { + paramUrl.addQueryItem(QLatin1String("client"), sysInfo ); + } + paramUrl.addQueryItem( QLatin1String("version"), clientVersion() ); + paramUrl.addQueryItem( QLatin1String("platform"), platform ); + paramUrl.addQueryItem( QLatin1String("oem"), theme->appName() ); + return paramUrl; +} + + +QString Updater::getSystemInfo() +{ +#ifdef Q_OS_LINUX + QProcess process; + process.start( QLatin1String("lsb_release -a") ); + process.waitForFinished(); + QByteArray output = process.readAllStandardOutput(); + qDebug() << "Sys Info size: " << output.length(); + if( output.length() > 1024 ) output.clear(); // don't send too much. + + return QString::fromLocal8Bit( output.toBase64() ); +#else + return QString::null; +#endif +} + // To test, cmake with -DAPPLICATION_UPDATE_URL="http://127.0.0.1:8080/test.rss" Updater *Updater::create() { - QString updateBaseUrl(QLatin1String(APPLICATION_UPDATE_URL)); + QUrl updateBaseUrl = addQueryParams(QUrl(QLatin1String(APPLICATION_UPDATE_URL))); #if defined(Q_OS_MAC) && defined(HAVE_SPARKLE) - return new SparkleUpdater(updateBaseUrl); + updateBaseUrl.addQueryItem( QLatin1String("sparkle"), QLatin1String("true")); + return new SparkleUpdater(updateBaseUrl.toString()); #elif defined (Q_OS_WIN32) // the best we can do is notify about updates - return new NSISUpdater(QUrl(updateBaseUrl)); + return new NSISUpdater(updateBaseUrl); #else return new PassiveUpdateNotifier(QUrl(updateBaseUrl)); #endif @@ -67,5 +114,9 @@ qint64 Updater::Helper::stringVersionToInt(const QString& version) return versionToInt(major, minor, patch, build); } +QString Updater::clientVersion() +{ + return QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_FULL)); +} } // namespace Mirall diff --git a/src/updater/updater.h b/src/updater/updater.h index 70325ac3b..9df20ec99 100644 --- a/src/updater/updater.h +++ b/src/updater/updater.h @@ -34,7 +34,12 @@ public: virtual bool handleStartup() = 0; +protected: + static QString clientVersion(); + private: + static QString getSystemInfo(); + static QUrl addQueryParams(const QUrl &url); static Updater *create(); static Updater *_instance; }; |