Mailinglist Archive: zypp-commit (149 mails)

< Previous Next >
[zypp-commit] r5418 - in /branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp: ZYppUpdater.cpp ZYppUpdater.h
  • From: tgoettlicher@xxxxxxxxxxxxxxxx
  • Date: Fri, 20 Apr 2007 08:45:50 -0000
  • Message-id: <20070420084550.6D936355A6@xxxxxxxxxxxxxxxx>
Author: tgoettlicher
Date: Fri Apr 20 10:45:50 2007
New Revision: 5418

URL: http://svn.opensuse.org/viewcvs/zypp?rev=5418&view=rev
Log:
Code clean-up: sleep() => QTimer::singleShot()


Modified:
    branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.cpp
    branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.h

Modified: branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.cpp?rev=5418&r1=5417&r2=5418&view=diff
==============================================================================
--- branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.cpp (original)
+++ branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.cpp Fri Apr 20 10:45:50 2007
@@ -46,6 +46,7 @@
 //#include "ZYppInstallWindow.h"
 //#include "ZYppConfigWindow.h"
 #include "UpdateListItem.h"
+#include "qtimer.h"
 
 // <?xml version='1.0'?>
 // <update-status op="success">
@@ -194,27 +195,29 @@
   // give KNetworkmanager some seconds to establish a
   // network connection and try again. 
 
-  for (int attempt=0 ; attempt < 10; ++attempt)
+/*  for (int attempt=0 ; attempt < 10; ++attempt)
   {
     if (attempt != 0) // wait 3s before we do   
     {                 // 2nd, 3rd. ... attempt 
       kdDebug() << "Network connection is getting established. waiting... " << endl;
+
       sleep (3);      
     }
 
-    kdDebug() << "Checking network connection..." << endl;
-    switch (getNetworkStatus())
-    {
-      case 1:               // NoNetworks
-      case 8: return true;  // Online         ==> true
+*/
 
-      case 2:               // Unreachable
-      case 3:               // OfflineDisconnected
-      case 4:               // OfflineFailed
-      case 5:               // ShuttingDown
-      case 6: return false; // Offline        ==> false
-      case 7: break;        // Establishing   ==> next attempt
-    }
+  kdDebug() << "Checking network connection..." << endl;
+  switch (getNetworkStatus())
+  {
+    case 1:               // NoNetworks
+    case 8: return true;  // Online         ==> true
+
+    case 2:               // Unreachable
+    case 3:               // OfflineDisconnected
+    case 4:               // OfflineFailed
+    case 5:               // ShuttingDown
+    case 6: return false; // Offline        ==> false
+    case 7: break;        // Establishing   ==> next attempt
   }
   return false;
 }
@@ -255,20 +258,52 @@
 
 }
 
-void ZYppUpdater::doCheckForUpdates()
+void ZYppUpdater::slotCheckAgainForUpdates()
 {
-  kdDebug() << "checking..." << endl;
+  doCheckForUpdates(true);
+}
 
-  if ( networkOnline() )
-  {
-    kdDebug() << "Network available." << endl;
-  }
-  else
+
+void ZYppUpdater::doCheckForUpdates(bool lastattempt)
+{
+
+  kdDebug() << "Checking network connection..." << endl;
+  switch (getNetworkStatus())
   {
-    kdDebug() << "No network, skipping check..." << endl;
-    return;
+    // Network connection is available => go on 
+    case 1:               // NoNetworks
+    case 8:               // Online      
+            kdDebug() << "Network available." << endl;
+            break;
+
+
+    // No network connection is avaiable => return
+    case 2:               // Unreachable
+    case 3:               // OfflineDisconnected
+    case 4:               // OfflineFailed
+    case 5:               // ShuttingDown
+    case 6:               // Offline      
+            kdDebug() << "No network, skipping check..." << endl;
+            return;
+
+
+    // Network connection being established. 
+    // We do two attempts:
+    // When the fist fails we try again after 1 minute 
+    // When the second fails we give up.
+    case 7:               // Establishing   
+            if (!lastattempt)
+            {
+              kdDebug() << "Network connection being established. Will try again in 1 minute..." << endl;
+              QTimer::singleShot( 1*60*1000, this, SLOT(slotCheckAgainForUpdates()) );
+            }
+            return;
   }
-  
+
+
+
+  kdDebug() << "Checking for updates..." << endl;
+
   
   if ( _process ) {
     kdDebug() << "Check process still running. Will not run this time." << endl;

Modified: branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.h?rev=5418&r1=5417&r2=5418&view=diff
==============================================================================
--- branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.h (original)
+++ branches/SuSE-Linux-10_2-Branch/updater-kde/updater/zypp/ZYppUpdater.h Fri Apr 20 10:45:50 2007
@@ -116,6 +116,13 @@
                */
                void updateMenu(QListViewItem* item, const QPoint& point);
 
+               /**
+                       Slot which gets called 1 minute after CheckForUpdates
+      has detected "network connection being established"
+               */
+    void slotCheckAgainForUpdates();
+
+
   protected slots:
     
     void slotYOUProcessExited( KProcess * );
@@ -126,13 +133,14 @@
     void slotReceivedStdout(KProcess *proc, char *buffer, int buflen);
     void slotReceivedStderr(KProcess *proc, char *buffer, int buflen);
     
+
        private:
     
     bool networkOnline() const;
     int getNetworkStatus() const;
 
+    void doCheckForUpdates(bool lastattempt=false);
     
-    void doCheckForUpdates();
 
     KProcess *_process;
     QString _buffer;

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages