[Pkg-owncloud-commits] [owncloud-client] 15/47: Updater: Unify Sparkle&non-Sparkle URLs

Sandro Knauß hefee-guest at moszumanska.debian.org
Mon Feb 17 18:06:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 97345447ab79b30ac568499835bf1cf21f27496d
Author: Daniel Molkentin <danimo at owncloud.com>
Date:   Thu Feb 6 18:54:48 2014 +0100

    Updater: Unify Sparkle&non-Sparkle URLs
    
    ...now that we have the support on the server-side.
---
 src/updater/ocupdater.cpp | 43 +----------------------------------
 src/updater/ocupdater.h   |  2 --
 src/updater/updater.cpp   | 57 ++++++++++++++++++++++++++++++++++++++++++++---
 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 36cb647..797d691 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 9d99f25..2b7c976 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 65b3ff0..f0dd465 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 70325ac..9df20ec 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;
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list