[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/kdewin-installer
From:       Ralf Habacker <Ralf.Habacker () freenet ! de>
Date:       2009-08-18 22:07:06
Message-ID: 1250633226.157624.10796.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1013123 by habacker:

added support for release independent installer updates on installer start 
It scans the installer home dir on www.winkde.org for newer versions. The update \
check uses proxy settings, so it may be that on the first run, when no proxy is set \
updates may not be detectable. In this case the update check will skip silently. 

Note: The release based @newversion tag will not be checked anymore. 



 M  +1 -1      CMakeLists.txt  
 M  +0 -3      config-sample.txt  
 M  +12 -9     gui/installerenginegui.cpp  
 M  +1 -3      shared/globalconfig.cpp  
 M  +0 -4      shared/globalconfig.h  
 M  +36 -1     shared/installerupdate.cpp  
 M  +9 -6      shared/installerupdate.h  


--- trunk/kdesupport/kdewin-installer/CMakeLists.txt #1013122:1013123
@@ -6,7 +6,7 @@
 set (VERSION_MAJOR 0)
 set (VERSION_MINOR 9)
 set (VERSION_REVISION 6)
-set (VERSION_PATCH "2")
+set (VERSION_PATCH "3")
 set (VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}")
 set (VERSION_PATCH "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}-${VERSION_PATCH}")
  
--- trunk/kdesupport/kdewin-installer/config-sample.txt #1013122:1013123
@@ -4,9 +4,6 @@
 ; define mininal required installer version
 ;@minversion 0.8.3-7
 
-; define new installer 
-@newversion 0.9.3-3 <new-installer-url>
-
 ; define config file timestamp  
 @timestamp 200711291436
 
--- trunk/kdesupport/kdewin-installer/gui/installerenginegui.cpp #1013122:1013123
@@ -28,6 +28,7 @@
 #include "installerenginegui.h"
 #include "downloader.h"
 #include "installwizard.h"
+#include "installerupdate.h"
 #include "misc.h"
 
 //#include "downloader.h"
@@ -468,6 +469,14 @@
 InstallerEngineGui::InstallerEngineGui (QWidget *parent)
         : InstallerEngine ( parent ), m_parent(parent)
 {
+    InstallerUpdate &iu = InstallerUpdate::instance();
+    if (iu.isUpdateAvailable()) {
+        if (InstallerDialogs::instance().newInstallerAvailable())
+            if (iu.fetch())
+                iu.run();
+            else 
+                InstallerDialogs::instance().newInstallerDownloadError();
+    }
 }
 
 bool InstallerEngineGui::init()
@@ -475,17 +484,11 @@
     m_displayMode = Settings::instance().isPackageManagerMode() ? Single : \
BinaryOnly;  
     initGlobalConfig();
-    if (m_globalConfig->installerUpdate().isUpdateAvailable()) {
-        if (InstallerDialogs::instance().newInstallerAvailable())
-            if (m_globalConfig->installerUpdate().fetch())
-                m_globalConfig->installerUpdate().run();
-            else 
-                InstallerDialogs::instance().newInstallerDownloadError();
-    }
-    else if (isInstallerVersionOutdated())
+    
+    if (isInstallerVersionOutdated())
         InstallerDialogs::instance().installerOutdated();
+
     return initPackages();
-
     /// @TODO add updates to category cache
 }
 
--- trunk/kdesupport/kdewin-installer/shared/globalconfig.cpp #1013122:1013123
@@ -203,9 +203,7 @@
                 m_minimalInstallerVersion = cmdBA[1];
             else if (keyword == "newversion")
             {
-                m_installerUpdate.setNewVersion(cmd[1]);
-                m_installerUpdate.setCurrentVersion(VERSION_PATCH);
-                m_installerUpdate.setUrl(cmd[2]);
+                // deprecated
             }
             else if (keyword == "timestamp")
             {
--- trunk/kdesupport/kdewin-installer/shared/globalconfig.h #1013122:1013123
@@ -24,7 +24,6 @@
 #define GLOBALCONFIG_H
 
 #include "hash.h"
-#include "installerupdate.h"
 #include "site.h"
 #include "package.h"
 
@@ -76,8 +75,6 @@
         const QByteArray &minimalInstallerVersion() { return \
m_minimalInstallerVersion; }  void setBaseURL(const QUrl &url) { m_baseURL = \
url.toString(); }  
-        InstallerUpdate &installerUpdate() { return m_installerUpdate; }
-
         /// check if a config-remote.txt is located in download directory
         static bool isRemoteConfigAvailable();
         /// return path of remote config file
@@ -97,7 +94,6 @@
         QHash <QString,QStringList> m_categoryPackages;
         QList <Mirror*> m_mirrors;
         QString m_baseURL;
-        InstallerUpdate m_installerUpdate;
         QDateTime m_timestamp;
         QByteArray m_minimalInstallerVersion;
         QStringList m_endUserCategories;
--- trunk/kdesupport/kdewin-installer/shared/installerupdate.cpp #1013122:1013123
@@ -21,6 +21,7 @@
 **
 ****************************************************************************/
 
+#include "config.h"
 #include "debug.h"
 #include "downloader.h"
 #include "downloaderprogress.h"
@@ -36,6 +37,9 @@
 
 #include <psapi.h>
 
+QUrl installerUpdateUrl("http://www.winkde.org/pub/kde/ports/win32/installer/");
+QByteArray installerName ="kdewin-installer-gui-";
+
 bool isProcessRunning(int pid)
 {
     DWORD aProcesses[1024], cbNeeded, cProcesses;
@@ -61,6 +65,7 @@
 
 InstallerUpdate::InstallerUpdate()
 {
+    setCurrentVersion(VERSION_PATCH);
 }
 
 InstallerUpdate::~InstallerUpdate()
@@ -85,12 +90,42 @@
 
 bool InstallerUpdate::isUpdateAvailable()
 {
+    QByteArray data;
+    if (!Downloader::instance()->fetch(installerUpdateUrl,data))
+        return false;
+   
+    QByteArray tempVersion;
+    QByteArray tempName;
+    foreach(QByteArray line, data.split('\n')) {
+        if (!line.contains(installerName ) || line.contains(installerName + \
"latest")) +            continue;
+        int a = line.indexOf("href=\"") + 6;
+        int b = line.indexOf("\">",a);
+        const QByteArray name = line.mid(a,b-a);
+        if (name.endsWith(".exe")) {
+            QByteArray version = name;
+            version.replace(installerName,"");
+            version.replace(".exe","");
+            // set highest version
+            if (tempVersion < version) 
+            {
+                tempVersion = version;
+                tempName =  name;
+            }
+        }
+    }
+    if (tempVersion > m_currentVersion)
+    {
+        setNewVersion(tempVersion);
+        setUrl(installerUpdateUrl.toString() + tempName);
+    }
+
     bool result = m_url.isValid() 
         && !m_newVersion.isEmpty()
         && !m_currentVersion.isEmpty() 
         && m_newVersion > m_currentVersion;
     if (result)
-        qDebug() << "update found" << "- old" << m_currentVersion << "new" << \
m_newVersion; +        qDebug() << "update" << m_newVersion << "at" << m_url << \
"found";  else
         qDebug() << "no update found";
     return result;
--- trunk/kdesupport/kdewin-installer/shared/installerupdate.h #1013122:1013123
@@ -34,14 +34,9 @@
         InstallerUpdate();
         ~InstallerUpdate();
 
-        /// set current installer version
-        void setCurrentVersion(const QString &version);
-        /// set new installer version
-        void setNewVersion(const QString &version);
-        /// set url for new update
-        void setUrl(const QUrl &url);
         /// check if the provided version is newer 
         bool isUpdateAvailable();
+        
         /// fetch new installer 
         bool fetch();
 
@@ -53,7 +48,15 @@
 
         /// return singleton instance
         static InstallerUpdate &instance();
+        
     protected:
+        /// set current installer version
+        void setCurrentVersion(const QString &version);
+        /// set new installer version
+        void setNewVersion(const QString &version);
+        /// set url for new update
+        void setUrl(const QUrl &url);
+
         QUrl m_url;
         QString m_newVersion;
         QString m_currentVersion;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic