Author: tgoettlicher Date: Fri Apr 20 11:47:42 2007 New Revision: 5422 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5422&view=rev Log: fix wait for initial update until (K)NetworkManager has established connection (#231203) Modified: branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.h Modified: branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp?rev=5422&r1=5421&r2=5422&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp Fri Apr 20 11:47:42 2007 @@ -195,18 +195,18 @@ _stderr_buffer += QString::fromUtf8( buffer, buflen ); } -bool ZYppUpdater::networkOnline() const +int ZYppUpdater::getNetworkStatus() const { //enum EnumStatus { NoNetworks = 1, Unreachable, OfflineDisconnected, OfflineFailed, ShuttingDown, Offline, Establishing, Online }; - + int online = 1; if ( kapp->dcopClient()->isApplicationRegistered( "kded" ) ) { QByteArray data, replyData; - + QDataStream arg(data, IO_WriteOnly); arg << QString("www.novell.com"); - + QCString replyType; if ( !kapp->dcopClient()->call( "kded", "networkstatus", "status(QString)", data, replyType, replyData ) ) @@ -220,9 +220,9 @@ else kdDebug() << "DCOP: unexpected return type." << endl; } } - - return (online == 8) || ( online == 1 ); - + + return online; + } void ZYppUpdater::shutdown() @@ -230,20 +230,45 @@ } -void ZYppUpdater::doCheckForUpdates() +void ZYppUpdater::doCheckForUpdates(bool lastattempt) { - kdDebug() << "checking..." << endl; - if ( networkOnline() ) - { - kdDebug() << "Network available." << endl; - } - else + 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/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.h?rev=5422&r1=5421&r2=5422&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.h (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.h Fri Apr 20 11:47:42 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 * ); @@ -128,9 +135,9 @@ private: - bool networkOnline() const; + int getNetworkStatus() const; - void doCheckForUpdates(); + void doCheckForUpdates(bool lastattempt=false); KProcess *_process; QString _buffer; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org