Author: tgoettlicher
Date: Wed May 23 15:56:09 2007
New Revision: 5611
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5611&view=rev
Log:
moved network availibility check from zyppupdater to mainwindow
now it is independent from backends
Modified:
trunk/updater-kde/updater/MainWindow.cpp
trunk/updater-kde/updater/MainWindow.h
trunk/updater-kde/updater/UpdaterApplication.cpp
trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
trunk/updater-kde/updater/zypp/ZYppUpdater.h
Modified: trunk/updater-kde/updater/MainWindow.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.cpp?rev=5611&r1=5610&r2=5611&view=diff
==============================================================================
--- trunk/updater-kde/updater/MainWindow.cpp (original)
+++ trunk/updater-kde/updater/MainWindow.cpp Wed May 23 15:56:09 2007
@@ -32,6 +32,7 @@
#include
#include
#include
+#include
#include
#include
@@ -80,12 +81,18 @@
_hide_action = KStdAction::close (this, SLOT(hide()), actionCollection(), 0);
_quit_action = KStdAction::quit(this, SLOT(slotExit()), actionCollection(), 0);
+ connect(this, SIGNAL(updateApplet(int, int)), this, SLOT(slotAppletState(int, int)));
+ connect(this, SIGNAL(updateAppletError(const QString &)), this, SLOT(slotAppletError(const QString &)));
+
//Initially we have 0 selected updates of course.
updatesSelected = 0;
popup = new OSUpdaterPopup(applet,this);
hide();
+
+
+
}
/*************************************************************
@@ -346,11 +353,81 @@
updateButtons();
}
+int MainWindow::getNetworkStatus() const
+{
+ //enum EnumStatus { NoNetworks = 1, Unreachable, OfflineDisconnected, OfflineFailed, ShuttingDown, Offline, Establishing, Online };
-void MainWindow::checkUpdates() {
+ 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 ) )
+ {
+ kdError() << "DCOP error." << endl;
+ }
+ else
+ {
+ QDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "int") reply >> online;
+ else kdDebug() << "DCOP: unexpected return type." << endl;
+ }
+ }
+
+ return online;
+
+}
+
+
+
+void MainWindow::checkAgainUpdates() {
+ checkUpdates(true);
+}
+
+void MainWindow::checkUpdates(bool lastAttempt) {
kdDebug() << "MainWindow::checkUpdates" << endl;
+ kdDebug() << "Checking network connection..." << endl;
+ switch (getNetworkStatus())
+ {
+ // 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
+ emit(updateAppletError("TODO No Network Error Msg"));
+ 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(slotCheckAgainUpdates()) );
+ }
+ return;
+ }
+
+
//Clear the list and fire the update signal to the backend
updateList->clear();
packageDescription->setText("");
Modified: trunk/updater-kde/updater/MainWindow.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.h?rev=5611&r1=5610&r2=5611&view=diff
==============================================================================
--- trunk/updater-kde/updater/MainWindow.h (original)
+++ trunk/updater-kde/updater/MainWindow.h Wed May 23 15:56:09 2007
@@ -131,6 +131,25 @@
void signalConfigChanged();
+
+ /** This is a signal sent to the MainWindow class.
+ It updates the applet to the specified state.
+ @param state this is the state the updater applet
+ @param n number of updates
+ will be refreshed to reflect
+ **/
+ void updateApplet(int state, int n);
+
+ /** This is a signal sent to the MainWindow class.
+ It updates the applet to the specified state.
+ @param state this is the state the updater applet
+ @param n number of updates
+ will be refreshed to reflect
+ **/
+ void updateAppletError( const QString &desc );
+
+
+
public slots:
/**
@@ -155,7 +174,13 @@
/**
Tells the backend to repopulate our list.
*/
- void checkUpdates();
+ void checkUpdates(bool lastAttempt=false);
+
+ /**
+ Slot which gets called 1 minute after CheckForUpdates
+ has detected "network connection being established"
+ */
+ void checkAgainUpdates();
/**
react to value changes
@@ -254,6 +279,9 @@
KConfigDialog *configDialog;
+ int getNetworkStatus() const;
+
+
};
Modified: trunk/updater-kde/updater/UpdaterApplication.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/UpdaterApplication.cpp?rev=5611&r1=5610&r2=5611&view=diff
==============================================================================
--- trunk/updater-kde/updater/UpdaterApplication.cpp (original)
+++ trunk/updater-kde/updater/UpdaterApplication.cpp Wed May 23 15:56:09 2007
@@ -45,11 +45,6 @@
connect(_main, SIGNAL(signalConfigChanged()), this, SLOT(slotConfigChanged()));
connectToPlugin();
-
- if (_updater)
- {
- _main->setUpdaterCapabilities(_updater->capabilities());
- }
}
void UpdaterApplication::connectToPlugin()
@@ -64,7 +59,6 @@
_updater->shutdown();
delete _updater;
_updater = NULL;
-
}
// read new plugin form config and connect to it
@@ -81,7 +75,7 @@
kdDebug() << "Will check for updates soon." << endl;
QTimer::singleShot( 30*1000, _main , SLOT(checkUpdates() ));
_main->slotAppletState(APPLET_CHECKING, 0);
-
+ _main->setUpdaterCapabilities(_updater->capabilities());
}
}
@@ -134,7 +128,6 @@
{
kdDebug() << "Config has changed. Reloading backend plugin..." << endl;
connectToPlugin();
- _main->setUpdaterCapabilities(_updater->capabilities());
}
Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpdater.cpp?rev=5611&r1=5610&r2=5611&view=diff
==============================================================================
--- trunk/updater-kde/updater/zypp/ZYppUpdater.cpp (original)
+++ trunk/updater-kde/updater/zypp/ZYppUpdater.cpp Wed May 23 15:56:09 2007
@@ -31,7 +31,6 @@
#include
#include
-#include
#include
#include
@@ -107,7 +106,6 @@
void ZYppUpdater::showLog()
{
-
}
void ZYppUpdater::slotProcessExited( KProcess *proc )
@@ -200,84 +198,13 @@
_stderr_buffer += QString::fromUtf8( buffer, buflen );
}
-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 ) )
- {
- kdError() << "DCOP error." << endl;
- }
- else
- {
- QDataStream reply(replyData, IO_ReadOnly);
- if (replyType == "int") reply >> online;
- else kdDebug() << "DCOP: unexpected return type." << endl;
- }
- }
-
- return online;
-
-}
-
void ZYppUpdater::shutdown()
{
}
-void ZYppUpdater::slotCheckAgainForUpdates()
+void ZYppUpdater::doCheckForUpdates()
{
- ZYppUpdater::doCheckForUpdates(true);
-}
-
-void ZYppUpdater::doCheckForUpdates(bool lastattempt)
-{
-
- kdDebug() << "Checking network connection..." << endl;
- switch (getNetworkStatus())
- {
- // 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 ) {
Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpdater.h?rev=5611&r1=5610&r2=5611&view=diff
==============================================================================
--- trunk/updater-kde/updater/zypp/ZYppUpdater.h (original)
+++ trunk/updater-kde/updater/zypp/ZYppUpdater.h Wed May 23 15:56:09 2007
@@ -137,7 +137,7 @@
int getNetworkStatus() const;
- void doCheckForUpdates(bool lastattempt=false);
+ void doCheckForUpdates();
KProcess *_process;
QString _buffer;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org