summaryrefslogtreecommitdiffstats
path: root/networkstatus
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-04 17:53:12 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-04 17:53:12 +0000
commitaf20635a2bb11eefabb627a2419644d3ac78831d (patch)
treea10097346376a69cf49288d3bd592b635a8744f9 /networkstatus
parent84ae8923dff22da5912d9a322db515ce0a2388c7 (diff)
downloadtdelibs-af20635a2bb11eefabb627a2419644d3ac78831d.tar.gz
tdelibs-af20635a2bb11eefabb627a2419644d3ac78831d.zip
Added networkstatus service from pim to core for use in other network enabled applications
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171617 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'networkstatus')
-rw-r--r--networkstatus/Makefile.am46
-rw-r--r--networkstatus/clientiface.h77
-rw-r--r--networkstatus/clientifaceimpl.cpp51
-rw-r--r--networkstatus/clientifaceimpl.h43
-rw-r--r--networkstatus/connectionmanager.cpp223
-rw-r--r--networkstatus/connectionmanager.h194
-rw-r--r--networkstatus/connectionmanager_p.cpp13
-rw-r--r--networkstatus/connectionmanager_p.h55
-rw-r--r--networkstatus/network.cpp87
-rw-r--r--networkstatus/network.h73
-rw-r--r--networkstatus/networkstatus.cpp326
-rw-r--r--networkstatus/networkstatus.desktop4
-rw-r--r--networkstatus/networkstatus.h80
-rw-r--r--networkstatus/networkstatus.kdevelop2
-rw-r--r--networkstatus/networkstatuscommon.cpp73
-rw-r--r--networkstatus/networkstatuscommon.h54
-rw-r--r--networkstatus/networkstatusiface.h50
-rw-r--r--networkstatus/networkstatusindicator.cpp64
-rw-r--r--networkstatus/networkstatusindicator.h42
-rw-r--r--networkstatus/provideriface.h42
-rw-r--r--networkstatus/serviceiface.h51
-rw-r--r--networkstatus/serviceifaceimpl.cpp46
-rw-r--r--networkstatus/serviceifaceimpl.h43
-rw-r--r--networkstatus/testclient.cpp234
-rw-r--r--networkstatus/testclient.h80
-rw-r--r--networkstatus/testclient2.cpp222
-rw-r--r--networkstatus/testclient2.h82
-rw-r--r--networkstatus/testclientview.ui177
-rw-r--r--networkstatus/testservice.cpp188
-rw-r--r--networkstatus/testservice.h53
-rw-r--r--networkstatus/testserviceview.ui181
31 files changed, 1012 insertions, 1944 deletions
diff --git a/networkstatus/Makefile.am b/networkstatus/Makefile.am
index 90c6891f3..c59aa55c6 100644
--- a/networkstatus/Makefile.am
+++ b/networkstatus/Makefile.am
@@ -2,44 +2,36 @@
METASOURCES = AUTO
-INCLUDES = -I$(top_srcdir)/kded -I$(top_srcdir) $(all_includes)
-
kde_module_LTLIBRARIES = kded_networkstatus.la
-
-kded_networkstatus_la_SOURCES = networkstatus.cpp networkstatus.skel \
- network.cpp
-kded_networkstatus_la_LIBADD = $(LIB_KDECORE) $(LIB_KIO) ./libnetworkstatus.la
-kded_networkstatus_la_LDFLAGS = $(all_libraries) -module -avoid-version
-
-servicesdir = $(kde_servicesdir)/kded
-
-services_DATA = networkstatus.desktop
-
lib_LTLIBRARIES = libnetworkstatus.la libconnectionmanager.la
libnetworkstatus_la_LIBADD = $(LIB_KDECORE)
libnetworkstatus_la_LDFLAGS = $(all_libraries)
libnetworkstatus_la_SOURCES = networkstatuscommon.cpp
-libconnectionmanager_la_LIBADD = $(LIB_KDECORE) libnetworkstatus.la
+libconnectionmanager_la_LIBADD = $(LIB_KDECORE)
libconnectionmanager_la_LDFLAGS = $(all_libraries)
-libconnectionmanager_la_SOURCES = connectionmanager.cpp connectionmanager_p.cpp networkstatusindicator.cpp connectionmanager.skel networkstatusiface.stub
+libconnectionmanager_la_SOURCES = connectionmanager.cpp connectionmanager.skel clientiface.stub
+
+INCLUDES = $(all_includes)
+
+kded_networkstatus_la_SOURCES = networkstatus.cpp networkstatus.skel \
+ clientiface.skel serviceiface.skel network.cpp
+#kclientiface.skel serviceiface.skel
+kded_networkstatus_la_LIBADD = $(LIB_KDECORE) $(LIB_KIO) ./libnetworkstatus.la
+kded_networkstatus_la_LDFLAGS = $(all_libraries) -module -avoid-version
-noinst_PROGRAMS = networkstatustestservice networkstatustestclient managedconnectiontestclient
+servicesdir = $(kde_servicesdir)/kded
+services_DATA = networkstatus.desktop
-networkstatustestservice_LDFLAGS = $(all_libraries)
-networkstatustestservice_LDADD = $(LIB_KFILE) libnetworkstatus.la
-networkstatustestservice_SOURCES = testservice.cpp testserviceview.ui networkstatusiface.stub
+noinst_HEADERS = serviceifaceimpl.h \
+ network.h clientifaceimpl.h testservice.h connectionmanager.h
-networkstatustestclient_LDFLAGS = $(all_libraries)
-networkstatustestclient_LDADD = $(LIB_KFILE) libnetworkstatus.la libconnectionmanager.la
-networkstatustestclient_SOURCES = testclient.cpp testclientview.ui
+include_HEADERS = serviceiface.h provideriface.h networkstatuscommon.h
-managedconnectiontestclient_LDFLAGS = $(all_libraries)
-managedconnectiontestclient_LDADD = $(LIB_KFILE) libnetworkstatus.la libconnectionmanager.la
-managedconnectiontestclient_SOURCES = testclient2.cpp testclientview.ui
+bin_PROGRAMS = networkstatustestservice
-noinst_HEADERS = network.h testservice.h testclient.h
+networkstatustestservice_LDFLAGS = $(all_libraries)
+networkstatustestservice_LDADD = libnetworkstatus.la
-include_HEADERS = networkstatuscommon.h connectionmanager.h networkstatusindicator.h \
- networkstatusiface.h
+networkstatustestservice_SOURCES = testservice.cpp provideriface.skel serviceiface.stub
diff --git a/networkstatus/clientiface.h b/networkstatus/clientiface.h
new file mode 100644
index 000000000..9fcef57a3
--- /dev/null
+++ b/networkstatus/clientiface.h
@@ -0,0 +1,77 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KDED_NETWORKSTATUS_CLIENTIFACE_H
+#define KDED_NETWORKSTATUS_CLIENTIFACE_H
+
+#include "networkstatuscommon.h"
+
+#include <dcopobject.h>
+
+class ClientIface : virtual public DCOPObject
+{
+K_DCOP
+k_dcop:
+ /** Get the set of networks that the daemon is aware of. Mostly for debug */
+ virtual TQStringList networks() = 0;
+ /**
+ * Get the status of the connection to the given host.
+ * @param host
+ * @return a NetworkStatus::EnumStatus representing the state of the connection to the given host
+ */
+ virtual int status( const TQString & host) = 0;
+ /**
+ * Request a connection to the named host, registering the application's usage of this connection
+ * @param host The hostname the client wants to connect to.
+ * @param userInitiated Indicates whether the connection is a direct result of a user action or is a background task. Used by the daemon to decide whether to create an on-demand connection.
+ * @return An NetworkStatus::EnumRequestResult indicating whether the request was accepted
+ */
+ virtual int request( const TQString & host, bool userInitiated ) = 0;
+ /**
+ * Indicate that a previously registered connection to the given host is no longer needed by this client
+ * @param host The hostname being relinquished.
+ */
+ virtual void relinquish( const TQString & host ) = 0;
+ /**
+ * Indicate that a communication failure has occurred for a given host
+ * @param host The hostname for which the failure occurred.
+ * @return True indicates the caller should try again to lookup the host, as the daemon has another IP address available.
+ */
+ virtual bool reportFailure( const TQString & host ) = 0;
+ /**
+ * Utility method to check the daemon's status
+ */
+k_dcop_signals:
+ /**
+ * A status change occurred for the network(s) used to connect to the given host.
+ * @param host The host which the application has indicated it is using
+ * @param status The new status of the network used to reach host.
+ */
+ void statusChange( TQString host, int status );
+ /**
+ * The network would like to shut down - any clients using this host are to finish using it immediately and call
+ * relinquish() when done.
+ * @param host The host, registered as in use by applications, which is about to be disconnected.
+ */
+ void shutdownRequested( TQString host );
+};
+
+#endif
diff --git a/networkstatus/clientifaceimpl.cpp b/networkstatus/clientifaceimpl.cpp
new file mode 100644
index 000000000..f20957e73
--- /dev/null
+++ b/networkstatus/clientifaceimpl.cpp
@@ -0,0 +1,51 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "clientifaceimpl.h"
+
+ClientIfaceImpl::ClientIfaceImpl( NetworkStatusModule * module ) : m_module ( module )
+{
+}
+
+int ClientIfaceImpl::status( TQString host )
+{
+ return m_module->status( host );
+}
+
+int ClientIfaceImpl::request( TQString host, bool userInitiated )
+{
+ return m_module->request( host, userInitiated );
+}
+
+void ClientIfaceImpl::relinquish( TQString host )
+{
+ m_module->relinquish( host );
+}
+
+bool ClientIfaceImpl::reportFailure( TQString host )
+{
+ return m_module->reportFailure( host );
+}
+
+// TQString ClientIfaceImpl::statusAsString()
+// {
+//
+// }
diff --git a/networkstatus/clientifaceimpl.h b/networkstatus/clientifaceimpl.h
new file mode 100644
index 000000000..bdc99a19f
--- /dev/null
+++ b/networkstatus/clientifaceimpl.h
@@ -0,0 +1,43 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef NETWORKSTATUS_CLIENTIFACEIMPL_H
+#define NETWORKSTATUS_CLIENTIFACEIMPL_H
+
+#include <tqstring.h>
+
+#include "clientiface.h"
+#include "networkstatus.h"
+
+class ClientIfaceImpl : virtual public ClientIface
+{
+public:
+ ClientIfaceImpl( NetworkStatusModule * module );
+ int status( TQString host );
+ int request( TQString host, bool userInitiated );
+ void relinquish( TQString host );
+ bool reportFailure( TQString host );
+/* TQString statusAsString();*/
+private:
+ NetworkStatusModule * m_module;
+};
+
+#endif
diff --git a/networkstatus/connectionmanager.cpp b/networkstatus/connectionmanager.cpp
index 35040909b..a28c6a124 100644
--- a/networkstatus/connectionmanager.cpp
+++ b/networkstatus/connectionmanager.cpp
@@ -1,9 +1,12 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,161 +14,143 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#include <kapplication.h>
-#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
#include <kstaticdeleter.h>
+#include "clientiface_stub.h"
+#include "networkstatuscommon.h"
+
#include "connectionmanager.h"
-#include "connectionmanager_p.h"
-// Connection manager itself
-ConnectionManager::ConnectionManager( TQObject * parent, const char * name ) : DCOPObject( "ConnectionManager" ), TQObject( parent, name ), d( new ConnectionManagerPrivate( this ) )
+// ConnectionManager's private parts
+class ConnectionManagerPrivate
{
- d->service = new NetworkStatusIface_stub( kapp->dcopClient(), "kded", "networkstatus" );
-
- connectDCOPSignal( "kded", "networkstatus", "statusChange(int)", "slotStatusChanged(int)", false );
+ public:
+ // this holds the currently active state
+ ConnectionManager::State m_state;
+ ClientIface_stub * m_stub;
+ bool m_userInitiatedOnly;
+};
- initialise();
-}
-
-ConnectionManager::~ConnectionManager()
+// Connection manager itself
+ConnectionManager::ConnectionManager( TQObject * parent, const char * name ) : DCOPObject( "ConnectionManager" ),TQObject( parent, name )
{
- delete d;
+ d = new ConnectionManagerPrivate;
+
+ d->m_stub = new ClientIface_stub( kapp->dcopClient(), "kded", "networkstatus" );
+
+ connectDCOPSignal( "kded", "networkstatus", "statusChange(TQString,int)", "slotStatusChanged(TQString,int)", false );
+ d->m_userInitiatedOnly = false;
+ initialise();
}
ConnectionManager *ConnectionManager::s_self = 0L;
ConnectionManager *ConnectionManager::self()
{
- static KStaticDeleter<ConnectionManager> deleter;
- if(!s_self)
- deleter.setObject( s_self, new ConnectionManager( 0, "connection_manager" ) );
- return s_self;
+ static KStaticDeleter<ConnectionManager> deleter;
+ if(!s_self)
+ deleter.setObject( s_self, new ConnectionManager( 0, "connection_manager" ) );
+ return s_self;
}
void ConnectionManager::initialise()
{
- // determine initial state and set the state object accordingly.
- d->status = ( NetworkStatus::Status )d->service->status();
-}
-
-NetworkStatus::Status ConnectionManager::status()
-{
- return d->status;
-}
-
-void ConnectionManager::slotStatusChanged( int status )
-{
- d->status = ( NetworkStatus::Status )status;
- switch ( status ) {
- case NetworkStatus::NoNetworks:
- break;
- case NetworkStatus::Unreachable:
- break;
- case NetworkStatus::OfflineDisconnected:
- case NetworkStatus::OfflineFailed:
- case NetworkStatus::ShuttingDown:
- case NetworkStatus::Offline:
- case NetworkStatus::Establishing:
- if ( d->disconnectPolicy == Managed ) {
- emit d->disconnected();
- } else if ( d->disconnectPolicy == OnNextChange ) {
- setDisconnectPolicy( Manual );
- emit d->disconnected();
- }
- break;
- case NetworkStatus::Online:
- if ( d->disconnectPolicy == Managed ) {
- emit d->connected();
- } else if ( d->disconnectPolicy == OnNextChange ) {
- setConnectPolicy( Manual );
- emit d->connected();
- }
- break;
- default:
- kdDebug() << k_funcinfo << "Unrecognised status code!" << endl;
- }
- emit statusChanged( d->status );
-}
-
-ConnectionManager::ConnectionPolicy ConnectionManager::connectPolicy() const
-{
- return d->connectPolicy;
+ // determine initial state and set the state object accordingly.
+ d->m_state = Offline;
+ updateStatus();
+}
+
+void ConnectionManager::updateStatus()
+{
+ /*NetworkStatus::EnumStatus daemonStatus = (NetworkStatus::EnumStatus)d->m_stub->status( TQString::null );
+ switch ( daemonStatus )
+ {
+ case Offline:
+ case OfflineFailed:
+ case OfflineDisconnected:
+ case ShuttingDown:
+ if ( d->m_state == Online )
+ d->m_state = Pending;
+ else
+ d->m_state = Offline;
+ break;
+ case Establishing:
+ case Online:
+ d->m_state = Online;
+ break;
+ case NoNetworks:
+ case Unreachable:
+ d->m_state = Inactive;
+ break;
+ }*/
}
-void ConnectionManager::setConnectPolicy( ConnectionManager::ConnectionPolicy policy )
-{
- d->connectPolicy = policy;
-}
-
-ConnectionManager::ConnectionPolicy ConnectionManager::disconnectPolicy() const
-{
- return d->disconnectPolicy;
-}
-
-void ConnectionManager::setDisconnectPolicy( ConnectionManager::ConnectionPolicy policy )
-{
- d->disconnectPolicy = policy;
-}
-
-void ConnectionManager::setManualConnectionPolicies()
-{
- d->connectPolicy = ConnectionManager::Manual;
- d->disconnectPolicy = ConnectionManager::Manual;
-}
-
-void ConnectionManager::setManagedConnectionPolicies()
+ConnectionManager::~ConnectionManager()
{
- d->connectPolicy = ConnectionManager::Managed;
- d->disconnectPolicy = ConnectionManager::Managed;
+ delete d;
}
-void ConnectionManager::registerConnectSlot( TQObject * receiver, const char * member )
+NetworkStatus::EnumStatus ConnectionManager::status( const TQString & host )
{
- d->connectReceiver = receiver;
- d->connectSlot = member;
- connect( d, TQT_SIGNAL( connected() ), receiver, member );
+ if ( d->m_state == Inactive )
+ return NetworkStatus::NoNetworks;
+ else
+ return NetworkStatus::Offline;
}
-
-void ConnectionManager::forgetConnectSlot()
+NetworkStatus::EnumRequestResult ConnectionManager::requestConnection( TQWidget * mainWidget, const TQString & host, bool userInitiated )
{
- disconnect( d, TQT_SIGNAL( connected() ), d->connectReceiver, d->connectSlot );
- d->connectReceiver = 0;
- d->connectSlot = 0;
+ NetworkStatus::EnumRequestResult result;
+ // if offline and the user has previously indicated they didn't want any new connections, suppress it
+ if ( d->m_state == Offline && !userInitiated && d->m_userInitiatedOnly )
+ result = NetworkStatus::UserRefused;
+ // if offline, ask the user whether this connection should be allowed
+ if ( d->m_state == Offline )
+ {
+ if ( askToConnect( mainWidget ) )
+ result = (NetworkStatus::EnumRequestResult)d->m_stub->request( host, userInitiated );
+ else
+ result = NetworkStatus::UserRefused;
+ }
+ // otherwise, just ask for the connection
+ else
+ result = (NetworkStatus::EnumRequestResult)d->m_stub->request( host, userInitiated );
+
+ return result;
}
-bool ConnectionManager::isConnectSlotRegistered() const
+void ConnectionManager::relinquishConnection( const TQString & host )
{
- return ( d->connectSlot != 0 );
+ d->m_stub->relinquish( host );
}
-void ConnectionManager::registerDisconnectSlot( TQObject * receiver, const char * member )
+void ConnectionManager::slotStatusChanged( TQString host, int status )
{
- d->disconnectReceiver = receiver;
- d->disconnectSlot = member;
- connect( d, TQT_SIGNAL( disconnected() ), receiver, member );
-}
+ updateStatus();
+ // reset user initiated only flag if we are now online
+ if ( d->m_state == Online )
+ d->m_userInitiatedOnly = false;
-void ConnectionManager::forgetDisconnectSlot()
-{
- disconnect( d, TQT_SIGNAL( disconnected() ), d->disconnectReceiver, d->disconnectSlot );
- d->disconnectReceiver = 0;
- d->disconnectSlot = 0;
+ emit statusChanged( host, (NetworkStatus::EnumStatus)status );
}
-bool ConnectionManager::isDisconnectSlotRegistered() const
+bool ConnectionManager::askToConnect( TQWidget * mainWidget )
{
- return ( d->disconnectSlot != 0 );
+ i18n( "A network connection was disconnected. The application is now in offline mode. Do you want the application to resume network operations when the network is available again?" );
+ i18n( "This application is currently in offline mode. Do you want to connect?" );
+ i18n( "Message shown when a network connection failed. The placeholder contains the concrete description of the operation eg 'while performing this operation", "A network connection failed %1. Do you want to place the application in offline mode?" );
+ return ( KMessageBox::questionYesNo( mainWidget,
+ i18n("This application is currently in offline mode. Do you want to connect in order to carry out this operation?"),
+ i18n("Leave Offline Mode?"),
+ i18n("Connect"), i18n("Do Not Connect"),
+ TQString::fromLatin1("OfflineModeAlwaysGoOnline") ) == KMessageBox::Yes );
}
#include "connectionmanager.moc"
-
diff --git a/networkstatus/connectionmanager.h b/networkstatus/connectionmanager.h
index 43d7e98bd..00ca4e35c 100644
--- a/networkstatus/connectionmanager.h
+++ b/networkstatus/connectionmanager.h
@@ -1,166 +1,56 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
+/*
+ connectionmanager.h - Provides the client side interface to the kde networkstatus daemon
+
+ Copyright (c) 2004 by Will Stephenson <lists@stevello.free-online.co.uk>
+
+ *************************************************************************
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ *************************************************************************
*/
#ifndef KDE_CONNECTION_MANAGER_H
#define KDE_CONNECTION_MANAGER_H
#include <dcopobject.h>
-#include <kdemacros.h>
-#include <networkstatuscommon.h>
+#include "networkstatuscommon.h"
class ConnectionManagerPrivate;
-class KDE_EXPORT ConnectionManager : public TQObject, virtual public DCOPObject
+class ConnectionManager : public TQObject, virtual public DCOPObject
{
-Q_OBJECT
-K_DCOP
-k_dcop:
- void slotStatusChanged( int status );
-public:
- /**
- * This defines application policy in response to networking connect/disconnect events
- * Manual - the app only disconnects when the user does so
- * OnNextChange - the app should connect or disconnect the next time the network changes state, thereafter
- * Manual
- * Managed - the app should disconnect when the ConnectionManager thinks the system is
- * offline
- */
- enum ConnectionPolicy { Manual, OnNextChange, Managed };
- /**
- * Set a policy to manage the application's connect behaviour
- */
- void setConnectPolicy( ConnectionPolicy );
- /**
- * Retrieve a policy managing the application's connect behaviour
- */
- ConnectionPolicy connectPolicy() const;
-
- /**
- * Set a policy to manage the application's disconnect behaviour
- */
- void setDisconnectPolicy( ConnectionPolicy );
-
- /**
- * Retrieve a policy managing the application's disconnect behaviour
- */
- ConnectionPolicy disconnectPolicy() const;
-
- /*
- * We'll get logic of the form
- * onStatusChange() {
- * if ( ConnectionManager::self()->policy( ConnectionManager::ConnectBehaviour ) == ConnectionManager::OnNextChange ||
- * ConnectionManager::self()->policy( ConnectionManager::ConnectBehaviour ) == ConnectionManager::Managed )
- * {
- * // do connect
- *
- * // reset the policy
- * if ( ConnectionManager::self()->policy( ConnectionManager::ConnectBehaviour ) == ConnectionManager::OnNextChange )
- * ConnectionManager::self()->setPolicy( ConnectionManager::ConnectionManager,
- * ConnectionManager::Manual );
- * }
- *
- * Do we just use the CM for policy storage, or do we try to factor the logic to implement the
- * policy into the CM too?
- *
- * could signal doConnect(), then reset the policy
- * or could register a connect slot
- * registerConnectMethod( TQObject * receiver, const char * member );
- * unregisterConnectMethod();
- * etc.
- *
- * The problem with automatically controlled behaviour, where policy may change as a result of a
- * connect, is that if it is also manually altered, the CM needs to be updated. But the CM needs to
- * be updated in any case.
- * CM need
- */
- /**
- * Lazy-method to set Manual on both policies
- */
- void setManualConnectionPolicies();
- /**
- * Lazy-method to set Managed on both policies
- */
- void setManagedConnectionPolicies();
-
- /**
- * Record a slot to call on a given receiving TQObject when
- * 1) the network connection is online,
- * 2) the policy mandates that the app connect
- *
- * Only one slot may be registered at any one time. If a second slot is
- * registered, the first slot is forgotten
- * @param receiver the TQObject where the slot is located
- * @param member the slot to call. Set up member using the TQT_SLOT() macro.
- */
- void registerConnectSlot( TQObject * receiver, const char * member );
-
- /**
- * Forget any connect slot previously registered
- */
- void forgetConnectSlot();
-
- /**
- * Has any slot been registered to be called on connect?
- */
- bool isConnectSlotRegistered() const;
-
- /**
- * Record a slot to call on a given receiving TQObject when
- * 1) the network connection goes offline (in any way ),
- * 2) the policy mandates that the app disconnect
- *
- * Only one slot may be registered at any one time. If a second slot is
- * registered, the first slot is forgotten
- * @param receiver the TQObject where the slot is located
- * @param member the slot to call. Set up member using the TQT_SLOT() macro.
- */
- void registerDisconnectSlot( TQObject * receiver, const char * member );
-
- /**
- * Forget any disconnect slot previously registered
- */
- void forgetDisconnectSlot();
-
- /**
- * Has any slot been registered to be called on disconnect?
- */
- bool isDisconnectSlotRegistered() const;
-
- /// existing API
-
- static ConnectionManager* self();
- virtual ~ConnectionManager();
- NetworkStatus::Status status();
-signals:
- // signal that the network for a hostname is up/down
- void statusChanged( NetworkStatus::Status status );
-private:
- // sets up internal state
- void initialise();
- // reread the desktop status from the daemon and update internal state
- ConnectionManager( TQObject *parent, const char * name );
- ConnectionManagerPrivate * d;
- static ConnectionManager * s_self;
+ Q_OBJECT
+ K_DCOP
+ public:
+ static ConnectionManager* self();
+ enum State { Inactive, Online, Offline, Pending };
+ virtual ~ConnectionManager();
+ NetworkStatus::EnumStatus status( const TQString & host );
+ // check if a hostname is available. Ask user if offline. Request host
+ NetworkStatus::EnumRequestResult requestConnection( TQWidget* mainWidget, const TQString & host, bool userInitiated );
+ // method to relinquish a connection
+ void relinquishConnection( const TQString & host );
+ signals:
+ // signal that the network for a hostname is up/down
+ void statusChanged( const TQString & host, NetworkStatus::EnumStatus status );
+ protected:
+ // sets up internal state
+ void initialise();
+ // reread the desktop status from the daemon and update internal state
+ void updateStatus();
+ // ask if the user would like to reconnect
+ bool askToConnect( TQWidget * mainWidget );
+ k_dcop:
+ void slotStatusChanged( TQString host, int status );
+ private:
+ ConnectionManager( TQObject *parent, const char * name );
+ ConnectionManagerPrivate *d;
+ static ConnectionManager * s_self;
};
#endif
diff --git a/networkstatus/connectionmanager_p.cpp b/networkstatus/connectionmanager_p.cpp
deleted file mode 100644
index 3eb8f156e..000000000
--- a/networkstatus/connectionmanager_p.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "connectionmanager_p.h"
-
-ConnectionManagerPrivate::ConnectionManagerPrivate(TQObject * parent, const char * name ) : TQObject( parent, name ), service( 0 ), connectPolicy( ConnectionManager::Managed ),
- disconnectPolicy( ConnectionManager::Managed ), connectReceiver( 0 ), connectSlot( 0 ),
- disconnectReceiver( 0 ), disconnectSlot( 0 )
-{
-}
-
-ConnectionManagerPrivate::~ConnectionManagerPrivate()
-{
-}
-
-#include "connectionmanager_p.moc"
diff --git a/networkstatus/connectionmanager_p.h b/networkstatus/connectionmanager_p.h
deleted file mode 100644
index e1960056c..000000000
--- a/networkstatus/connectionmanager_p.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#ifndef CONNECTIONMANAGERPRIVATE_H
-#define CONNECTIONMANAGERPRIVATE_H
-
-#include <tqobject.h>
-
-#include "connectionmanager.h"
-#include "networkstatuscommon.h"
-#include "networkstatusiface_stub.h"
-
-
-// ConnectionManager's private parts
-class ConnectionManagerPrivate : public TQObject
-{
-Q_OBJECT
- friend class ConnectionManager;
-public:
- ConnectionManagerPrivate( TQObject * parent = 0, const char * name = 0);
- ~ConnectionManagerPrivate();
- // this holds the currently active state
- NetworkStatus::Status status;
- NetworkStatusIface_stub * service;
- ConnectionManager::ConnectionPolicy connectPolicy;
- ConnectionManager::ConnectionPolicy disconnectPolicy;
- TQObject * connectReceiver;
- const char * connectSlot;
- TQObject * disconnectReceiver;
- const char * disconnectSlot;
-signals:
- void connected();
- void disconnected();
-};
-
-#endif
diff --git a/networkstatus/network.cpp b/networkstatus/network.cpp
index a937634cb..fcb4a6f51 100644
--- a/networkstatus/network.cpp
+++ b/networkstatus/network.cpp
@@ -1,9 +1,12 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,52 +14,80 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#include <kdebug.h>
#include "network.h"
-Network::Network( NetworkStatus::Properties properties )
- : m_name( properties.name ), m_status( properties.status ), m_service( properties.service )
-{
-}
-
-void Network::setStatus( NetworkStatus::Status status )
+Network::Network( const TQString name, NetworkStatus::Properties properties )
+ : m_name( name )
{
- m_status = status;
+ kdDebug() << k_funcinfo << "constructing network '" << name << "', status: " << properties.status << endl;
+ m_status = properties.status;
+ m_netmasks = properties.netmasks;
+ m_internet = properties.internet;
+ m_service = properties.service;
+ m_onDemandPolicy = properties.onDemandPolicy;
}
-NetworkStatus::Status Network::status()
+NetworkStatus::EnumStatus Network::reachabilityFor( const TQString & host )
{
- return m_status;
+ // initially assume all networks are internet
+ // TODO: compute reachability properly
+ Q_UNUSED( host );
+ if ( true /*nss.properties.internet && notPrivateNetwork( host )*/ )
+ {
+ NetworkStatus::EnumStatus status;
+ if ( m_status == NetworkStatus::Establishing || m_status == NetworkStatus::Online )
+ status = NetworkStatus::Online;
+ else if ( m_status == NetworkStatus::ShuttingDown || m_status == NetworkStatus::Offline )
+ status = NetworkStatus::Offline;
+ else
+ status = m_status;
+
+ return status;
+ }
}
-void Network::setName( const TQString& name )
+void Network::registerUsage( const TQCString appId, const TQString host )
{
- m_name = name;
+ NetworkUsageStruct nus;
+ nus.appId = appId;
+ nus.host = host;
+ NetworkUsageList::iterator end = m_usage.end();
+ for ( NetworkUsageList::iterator it = m_usage.begin(); it != end; ++it )
+ {
+ if ( (*it).appId == appId && (*it).host == host )
+ return;
+ }
+ kdDebug() << k_funcinfo << "registering " << appId << " as using network " << m_name << " for " << host << endl;
+ m_usage.append( nus );
}
-TQString Network::name()
+void Network::unregisterUsage( const TQCString appId, const TQString host )
{
- return m_name;
+ NetworkUsageList::iterator end = m_usage.end();
+ for ( NetworkUsageList::iterator it = m_usage.begin(); it != end; ++it )
+ {
+ if ( (*it).appId == appId && (*it).host == host )
+ {
+ kdDebug() << k_funcinfo << "unregistering " << appId << "'s usage of " << m_name << " for " << host << endl;
+ m_usage.remove( it );
+ break;
+ }
+ }
}
-TQString Network::service()
+void Network::setStatus( NetworkStatus::EnumStatus status )
{
- return m_service;
+ m_status = status;
}
-void Network::setService( const TQString& service )
+void Network::removeAllUsage()
{
- m_service = service;
+ m_usage.clear();
}
-
-// vim: sw=4 ts=4
diff --git a/networkstatus/network.h b/networkstatus/network.h
index dd6a75561..dcd2cd339 100644
--- a/networkstatus/network.h
+++ b/networkstatus/network.h
@@ -1,9 +1,12 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,50 +14,54 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#ifndef NETWORKSTATUS_NETWORK_H
#define NETWORKSTATUS_NETWORK_H
+#include <tqstringlist.h>
+#include <ksharedptr.h>
#include "networkstatuscommon.h"
+struct NetworkUsageStruct
+{
+ TQCString appId;
+ TQString host;
+};
+
+typedef TQValueList< NetworkUsageStruct > NetworkUsageList;
+
class Network
{
public:
- Network( const TQString name );
- Network( NetworkStatus::Properties properties );
- /**
- * Update the status of this network
- */
- void setStatus( NetworkStatus::Status status );
- /**
- * The connection status of this network
- */
- NetworkStatus::Status status();
- /**
- * The name of this network
- */
- TQString name();
- void setName( const TQString& name );
- /**
- * Returns the service owning this network
- */
- TQString service();
- void setService( const TQString& service );
+ Network( const TQString name, NetworkStatus::Properties properties );
+ Network( const Network & other );
+ NetworkStatus::EnumStatus reachabilityFor( const TQString & host );
+ void registerUsage( const TQCString appId, const TQString host );
+ void unregisterUsage( const TQCString appId, const TQString host );
+ void setStatus( NetworkStatus::EnumStatus status );
+
+ void removeAllUsage();
+ NetworkStatus::EnumStatus status() { return m_status; }
+ TQString name() { return m_name; }
+ bool internet() { return m_internet; }
+ TQStringList netmasks() { return m_netmasks; }
+ TQCString service() { return m_service; }
+ NetworkStatus::EnumOnDemandPolicy onDemandPolicy() { return m_onDemandPolicy; }
+ NetworkUsageList usage() { return m_usage; }
+
private:
- Network( const Network & );
+ NetworkStatus::EnumStatus m_status;
TQString m_name;
- NetworkStatus::Status m_status;
- TQString m_service;
+ bool m_internet;
+ TQStringList m_netmasks;
+ TQCString m_service;
+ NetworkStatus::EnumOnDemandPolicy m_onDemandPolicy;
+ NetworkUsageList m_usage;
};
#endif
-// vim: sw=4 ts=4
diff --git a/networkstatus/networkstatus.cpp b/networkstatus/networkstatus.cpp
index f6966639d..092f2b392 100644
--- a/networkstatus/networkstatus.cpp
+++ b/networkstatus/networkstatus.cpp
@@ -1,9 +1,12 @@
-/* This file is part of kdepim
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,153 +14,294 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#include "networkstatus.h"
-#include <tqmap.h>
+#include <tqdict.h>
+#include <tqtimer.h>
+#include <tqvaluelist.h>
#include <dcopclient.h>
#include <kapplication.h>
#include <kdebug.h>
+#include "clientifaceimpl.h"
+#include "serviceifaceimpl.h"
#include "network.h"
-#include <kdemacros.h>
+#include <kdepimmacros.h>
extern "C" {
- KDE_EXPORT KDEDModule* create_networkstatus( const TQCString& obj )
- {
- return new NetworkStatusModule( obj );
- }
+ KDE_EXPORT KDEDModule* create_networkstatus( const TQCString& obj )
+ {
+ return new NetworkStatusModule( obj );
+ }
}
// INTERNALLY USED STRUCTS AND TYPEDEFS
-typedef TQMap< TQString, Network * > NetworkMap;
+//typedef TQDict< Network > NetworkList;
+typedef TQValueList< Network * > NetworkList;
class NetworkStatusModule::Private
{
public:
- NetworkMap networks;
- NetworkStatus::Status status;
+ NetworkList networks;
+/* ClientIface * clientIface;
+ ServiceIface * serviceIface;*/
};
// CTORS/DTORS
-NetworkStatusModule::NetworkStatusModule( const TQCString & obj ) : KDEDModule( obj ), d( new Private )
+NetworkStatusModule::NetworkStatusModule( const TQCString & obj ) : KDEDModule( obj )
{
- d->status = NetworkStatus::NoNetworks;
- connect( kapp->dcopClient(), TQT_SIGNAL( applicationRemoved( const TQCString& ) ) , this, TQT_SLOT( unregisteredFromDCOP( const TQCString& ) ) );
- // connect( kapp->dcopClient(), TQT_SIGNAL( applicationRegistered( const TQCString& ) ) , this, TQT_SLOT( registeredToDCOP( const TQCString& ) ) );
+ d = new Private;
+/* d->clientIface = new ClientIfaceImpl( this );
+ d->serviceIface = new ServiceIfaceImpl( this );*/
+ connect( kapp->dcopClient(), TQT_SIGNAL( applicationRemoved( const TQCString& ) ) , this, TQT_SLOT( unregisteredFromDCOP( const TQCString& ) ) );
+ connect( kapp->dcopClient(), TQT_SIGNAL( applicationRegistered( const TQCString& ) ) , this, TQT_SLOT( registeredToDCOP( const TQCString& ) ) );
}
NetworkStatusModule::~NetworkStatusModule()
{
- NetworkMap::ConstIterator it;
- const NetworkMap::ConstIterator end = d->networks.end();
-
- for ( it = d->networks.begin(); it != end; ++it ) {
- delete ( *it );
- }
-
- delete d;
+/* delete d->clientIface;
+ delete d->serviceIface;*/
+ delete d;
}
// CLIENT INTERFACE
TQStringList NetworkStatusModule::networks()
{
- kdDebug() << k_funcinfo << " contains " << d->networks.count() << " networks" << endl;
- return d->networks.keys();
+ kdDebug() << k_funcinfo << " contains " << d->networks.count() << " networks" << endl;
+ TQStringList networks;
+ NetworkList::iterator end = d->networks.end();
+ NetworkList::iterator it = d->networks.begin();
+ for ( ; it != end; ++it )
+ networks.append( (*it)->name() );
+ return networks;
+}
+
+int NetworkStatusModule::status( const TQString & host )
+{
+ if ( host == "127.0.0.1" || host == "localhost" )
+ return NetworkStatus::Online;
+ Network * p = networkForHost( host );
+ if ( !p )
+ {
+ //kdDebug() << k_funcinfo << " no networks have status for host '" << host << "'" << endl;
+ return (int)NetworkStatus::NoNetworks;
+ }
+ else
+ {
+ kdDebug() << k_funcinfo << " got status for host '" << host << "' : " << (int)(p->status()) << endl;
+ return (int)(p->status());
+ }
+}
+
+int NetworkStatusModule::request( const TQString & host, bool userInitiated )
+{
+ // identify most suitable network for host
+ Network * p = networkForHost( host );
+ if ( !p )
+ return NetworkStatus::Unavailable;
+
+ NetworkStatus::EnumStatus status = p->status();
+ TQCString appId = kapp->dcopClient()->senderId();
+ if ( status == NetworkStatus::Online )
+ {
+ p->registerUsage( appId, host );
+ return NetworkStatus::Connected;
+ }
+ // if online
+ // register usage
+ // return Available
+ else if ( status == NetworkStatus::Establishing )
+ {
+ p->registerUsage( appId, host );
+ return NetworkStatus::RequestAccepted;
+ }
+ // if establishing
+ // register usage
+ // return Accepted
+ else if ( status == NetworkStatus::Offline || status == NetworkStatus::ShuttingDown )
+ {
+ // TODO: check on demand policy
+
+ p->registerUsage( appId, host );
+ return NetworkStatus::RequestAccepted;
+ }
+ // if offline or ShuttingDown
+ // check ODP::
+ // always or Permanent: register, return accepted
+ // user: check userInitiated, register, return Accepted or UserRefused
+ // never: return UserRefused
+ else if ( status == NetworkStatus::OfflineFailed )
+ {
+ // TODO: check user's preference for dealing with failed networks
+ p->registerUsage( appId, host );
+ return NetworkStatus::RequestAccepted;
+ }
+ // if OfflineFailed
+ // check user's preference
+ else if ( status == NetworkStatus::OfflineDisconnected )
+ {
+ return NetworkStatus::Unavailable;
+ }
+ else
+ return NetworkStatus::Unavailable;
+ // if OfflineDisconnected or NoNetworks
+ // return Unavailable
}
-int NetworkStatusModule::status()
+void NetworkStatusModule::relinquish( const TQString & host )
{
- kdDebug() << k_funcinfo << " status: " << (int)d->status << endl;
- return (int)d->status;
+ TQCString appId = kapp->dcopClient()->senderId();
+ // find network currently used by app for host...
+ NetworkList::iterator end = d->networks.end();
+ NetworkList::iterator it = d->networks.begin();
+ for ( ; it != end; ++it )
+ {
+ Network * net = *it;
+ NetworkUsageList usage = net->usage();
+ NetworkUsageList::iterator end2 = usage.end();
+ for ( NetworkUsageList::iterator usageIt = usage.begin(); usageIt != end2; ++usageIt )
+ {
+ if ( (*usageIt).appId == appId && (*usageIt).host == host )
+ {
+ // remove host usage record
+ usage.remove( usageIt );
+ // if requested shutdown flagged for network
+ // check if all hosts have relinquished
+ // call confirmShutDown on Service
+ //checkShutdownOk();
+ }
+ }
+ }
}
-//protected:
+bool NetworkStatusModule::reportFailure( const TQString & host )
+{
+ // find network for host
+ // check IP record. remove IP usage record. if other IP exists, return true.
+ Q_UNUSED( host );
+ kdDebug() << k_funcinfo << "NOT IMPLEMENTED" << endl;
+ return false;
+}
-void NetworkStatusModule::updateStatus()
+// PROTECTED UTILITY FUNCTIONS
+/*
+ * Determine the network to use for the supplied host
+ */
+Network * NetworkStatusModule::networkForHost( const TQString & host ) const
+{
+ // return a null pointer if no networks are registered
+ if ( d->networks.isEmpty() )
+ return 0;
+
+ NetworkList::const_iterator it = d->networks.begin();
+ Network * bestNetwork = *(it++);
+ NetworkList::const_iterator end = d->networks.end();
+ for ( ; it != end; ++it )
+ {
+ if ( (*it)->reachabilityFor( host ) > bestNetwork->reachabilityFor( host ) )
+ {
+ bestNetwork = (*it);
+ }
+ }
+ return bestNetwork;
+}
+
+
+void NetworkStatusModule::registeredToDCOP( const TQCString & appId )
{
- NetworkStatus::Status bestStatus = NetworkStatus::NoNetworks;
- const NetworkStatus::Status oldStatus = d->status;
-
- NetworkMap::ConstIterator it;
- const NetworkMap::ConstIterator end = d->networks.end();
- for ( it = d->networks.begin(); it != end; ++it ) {
- if ( ( *it )->status() > bestStatus )
- bestStatus = ( *it )->status();
- }
- d->status = bestStatus;
-
- if ( oldStatus != d->status ) {
- statusChange( (int)d->status );
- }
}
void NetworkStatusModule::unregisteredFromDCOP( const TQCString & appId )
{
- // unregister and delete any networks owned by a service that has just unregistered
- NetworkMap::Iterator it = d->networks.begin();
- const NetworkMap::Iterator end = d->networks.end();
- while (it != d->networks.end())
- {
- if ( ( *it )->service() == TQString( appId ) )
- {
- NetworkMap::Iterator toRemove = it++;
- delete *toRemove;
- d->networks.remove( toRemove );
- updateStatus();
- continue;
- }
- ++it;
- }
+ // unregister any networks owned by a service that has just unregistered
+ NetworkList::iterator it = d->networks.begin();
+ NetworkList::iterator end = d->networks.end();
+ for ( ; it != end; ++it )
+ {
+ if ( (*it)->service() == appId)
+ {
+ kdDebug() << k_funcinfo << "removing '" << (*it)->name() << "', registered by " << appId << endl;
+ d->networks.remove( it );
+ break;
+ }
+ }
}
// SERVICE INTERFACE //
void NetworkStatusModule::setNetworkStatus( const TQString & networkName, int st )
{
- kdDebug() << k_funcinfo << networkName << ", " << st << endl;
- NetworkStatus::Status changedStatus = (NetworkStatus::Status)st;
- Network * net = 0;
- NetworkMap::Iterator it = d->networks.find( networkName );
- if ( it != d->networks.end() ) {
- net = (*it);
- net->setStatus( changedStatus );
- updateStatus();
- }
- else
- kdDebug() << " No network named '" << networkName << "' found." << endl;
+ kdDebug() << k_funcinfo << endl;
+ NetworkStatus::EnumStatus status = (NetworkStatus::EnumStatus)st;
+ Network * net = 0;
+ NetworkList::iterator it = d->networks.begin();
+ NetworkList::iterator end = d->networks.end();
+ for ( ; it != end; ++it )
+ {
+ if ( (*it)->name() == networkName )
+ {
+ net = (*it);
+ break;
+ }
+ }
+ if ( net )
+ {
+ if ( net->status() == status )
+ return;
+
+ // update the status of the network
+ net->setStatus( status );
+
+ // notify for each host in use on that network
+ NetworkUsageList usage = net->usage();
+ NetworkUsageList::iterator end = usage.end();
+ TQStringList notified;
+ for ( NetworkUsageList::iterator it = usage.begin(); it != end; ++it )
+ {
+ // only notify once per host
+ if ( !notified.contains( (*it).host ) )
+ {
+ kdDebug() << "notifying statusChange of " << networkName << " to " << (int)status <<
+ " because " << (*it).appId << " is using " << (*it).host << endl;
+ /*d->clientIface->*/statusChange( (*it).host, (int)status );
+ notified.append( (*it).host );
+ }
+ }
+
+ // if we are now anything but Establishing or Online, reset the usage records for that network
+ if ( !( net->status() == NetworkStatus::Establishing || net->status() == NetworkStatus::Establishing ) )
+ net->removeAllUsage();
+ }
+ else
+ kdDebug() << k_funcinfo << "No network found by this name" << endl;
}
-void NetworkStatusModule::registerNetwork( const NetworkStatus::Properties properties )
+void NetworkStatusModule::registerNetwork( const TQString & networkName, const NetworkStatus::Properties properties )
{
- kdDebug() << k_funcinfo << properties.name << ", with status " << properties.status << endl;
-
- d->networks.insert( properties.name, new Network( properties ) );
- updateStatus();
+ kdDebug() << k_funcinfo << "registering '" << networkName << "', with status " << properties.status << endl;
+ // TODO: check for re-registration, checking appid matches
+
+ d->networks.append( new Network( networkName, properties ) );
}
void NetworkStatusModule::unregisterNetwork( const TQString & networkName )
{
- kdDebug() << k_funcinfo << networkName << endl;
-
- NetworkMap::Iterator it = d->networks.find( networkName );
- if ( it != d->networks.end() ) {
- delete *it;
- d->networks.remove( it );
- }
- updateStatus();
+ // TODO: check appid
+ //d->networks.remove( networkName );
+}
+
+void NetworkStatusModule::requestShutdown( const TQString & networkName )
+{
+ Q_UNUSED( networkName );
+ kdDebug() << k_funcinfo << "NOT IMPLEMENTED" << endl;
}
#include "networkstatus.moc"
-// vim: set noet sw=4 ts=4:
diff --git a/networkstatus/networkstatus.desktop b/networkstatus/networkstatus.desktop
index 0ef533c04..4d66b8c51 100644
--- a/networkstatus/networkstatus.desktop
+++ b/networkstatus/networkstatus.desktop
@@ -1,5 +1,4 @@
[Desktop Entry]
-Encoding=UTF-8
Name=Network Status Daemon
Name[af]=Netwerk status bediener
Name[ar]=مراقب القرص Ùˆ التنÙيذ لحالة الشبكة
@@ -9,6 +8,7 @@ Name[cs]=Démon stavu sítě
Name[da]=Netværkstatusdæmon
Name[de]=Ãœberwachung des Netzwerkstatus
Name[el]=Δαίμονας κατάστασης δικτÏου
+Name[eo]=Retstat-demono
Name[es]=Daemon de estado de la red
Name[et]=Võrguoleku deemon
Name[eu]=Sarearen egoera deabrua
@@ -23,6 +23,7 @@ Name[it]=Demone dello stato della rete
Name[ja]=ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ã‚¹ãƒ†ãƒ¼ã‚¿ã‚¹ãƒ‡ãƒ¼ãƒ¢ãƒ³
Name[kk]=Желі күйінің қызметі
Name[km]=ដáŸáž˜áž·áž“​ស្ážáž¶áž“ភាព​បណ្ដាញ
+Name[ko]=ë„¤íŠ¸ì›Œí¬ ìƒíƒœ ë°ëª¬
Name[lt]=Tinklo statuso tarnyba
Name[mk]=Даемон за мрежен ÑтатуÑ
Name[ms]=Daemon Berstatus Rangkaian
@@ -85,6 +86,7 @@ Comment[sr]=Прати ÑÑ‚Ð°Ñ‚ÑƒÑ Ð¼Ñ€ÐµÐ¶Ð½Ð¸Ñ… интерфејÑа и прÑ
Comment[sr@Latn]=Prati status mrežnih interfejsa i pruža obaveštenja programima koji koriste mrežu.
Comment[sv]=Bevakar status för nätverksgränssnitt och tillhandahåller underrättelser till program som använder nätverket.
Comment[ta]=வலைபà¯à®ªà®¿à®©à¯à®©à®²à¯ˆà®ªà¯ பயனà¯à®ªà®Ÿà¯à®¤à¯à®¤à®¿ வலைபà¯à®ªà®¿à®©à¯à®©à®²à¯ இடைமà¯à®•à®™à¯à®•à®³à®¿à®©à¯ நிலையை கணà¯à®•à®¾à®£à®¿à®•à¯à®•à®¿à®±à®¤à¯ மறà¯à®±à¯à®®à¯ பயனà¯à®ªà®¾à®Ÿà¯à®•à®³à¯à®•à¯à®•à¯ அறிவிபà¯à®ªà¯ˆ வழஙà¯à®•à¯à®•à®¿à®±à®¤à¯.
+Comment[tr]=Ağ arayüzlerinin durmunu izler ve ağı kullanan uygulamalar için gereken uyarıları sağlar.
Comment[uk]=Слідкує за Ñтаном інтерфейÑів мережі Ñ– Ñповіщає програми, Ñкі кориÑтуютьÑÑ Ð¼ÐµÑ€ÐµÐ¶ÐµÑŽ.
Comment[zh_CN]=跟踪网å¡çš„状æ€å¹¶ä¸ºåº”用程åºæ供使用网络的通知。
Comment[zh_TW]=追蹤網路介é¢çš„狀態,並æ供使用網路的應用程å¼çš„通知。
diff --git a/networkstatus/networkstatus.h b/networkstatus/networkstatus.h
index 0bc343915..710afd79a 100644
--- a/networkstatus/networkstatus.h
+++ b/networkstatus/networkstatus.h
@@ -1,9 +1,12 @@
-/* This file is part of kdepim
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,56 +14,67 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#ifndef KDED_NETWORKSTATUS_H
#define KDED_NETWORKSTATUS_H
+#include "networkstatuscommon.h"
+
#include <kdedmodule.h>
-#include "networkstatuscommon.h"
+#include "clientiface.h"
#include "network.h"
+#include "serviceiface.h"
+
+struct NetworkStatusStruct;
-class NetworkStatusModule : virtual public KDEDModule
+class NetworkStatusModule : virtual public KDEDModule/*, public ClientIface, ServiceIface*/ // <-spot the multiple inheritance pb
{
Q_OBJECT
K_DCOP
public:
- NetworkStatusModule( const TQCString& obj );
- ~NetworkStatusModule();
+ NetworkStatusModule( const TQCString & obj );
+ ~NetworkStatusModule();
k_dcop:
- // Client interface
- TQStringList networks();
- int status();
- // Service interface
- void setNetworkStatus( const TQString & networkName, int status );
- void registerNetwork( NetworkStatus::Properties properties );
- void unregisterNetwork( const TQString & networkName );
+ // Client interface
+ TQStringList networks();
+ int status( const TQString & host );
+ int request( const TQString & host, bool userInitiated );
+ void relinquish( const TQString & host );
+ bool reportFailure( const TQString & host );
+// TQString statusAsString();
+ // Service interface
+ void setNetworkStatus( const TQString & networkName, int status );
+ void registerNetwork( const TQString & networkName, NetworkStatus::Properties properties );
+ void unregisterNetwork( const TQString & networkName );
+ void requestShutdown( const TQString & networkName );
k_dcop_signals:
- /**
- * A status change occurred affecting the overall connectivity
- * @param status The new status
- */
- void statusChange( int status );
+ /**
+ * A status change occurred for the network(s) used to connect to the given host.
+ * @param host The host which the application has indicated it is using
+ * @param status The new status of the network used to reach host.
+ */
+ void statusChange( TQString host, int status );
+ /**
+ * The network would like to shut down - any clients using this host are to finish using it immediately and call
+ * relinquish() when done.
+ * @param host The host, registered as in use by applications, which is about to be disconnected.
+ */
+ void shutdownRequested( TQString host );
protected slots:
- //void registeredToDCOP( const TQCString& appId );
- void unregisteredFromDCOP( const TQCString& appId );
+ void registeredToDCOP( const TQCString& appId );
+ void unregisteredFromDCOP( const TQCString& appId );
protected:
- // recalculate cached status
- void updateStatus();
+ // TQStringList networkUsers( const TQString & networkName );
+ Network * networkForHost( const TQString & host ) const;
private:
- class Private;
- Private *d;
+ class Private;
+ Private *d;
};
-
#endif
-// vim: sw=4 ts=4
diff --git a/networkstatus/networkstatus.kdevelop b/networkstatus/networkstatus.kdevelop
index d913b59da..29168abf7 100644
--- a/networkstatus/networkstatus.kdevelop
+++ b/networkstatus/networkstatus.kdevelop
@@ -7,7 +7,7 @@
<projectmanagement>KDevKDEAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
- <keyword>TQt</keyword>
+ <keyword>Qt</keyword>
<keyword>KDE</keyword>
</keywords>
</general>
diff --git a/networkstatus/networkstatuscommon.cpp b/networkstatus/networkstatuscommon.cpp
index fbfd4b434..574862929 100644
--- a/networkstatus/networkstatuscommon.cpp
+++ b/networkstatus/networkstatuscommon.cpp
@@ -1,9 +1,12 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,66 +14,40 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#include "networkstatuscommon.h"
+#include <kdebug.h>
TQDataStream & operator<< ( TQDataStream & s, const NetworkStatus::Properties p )
{
- s << p.name;
+ kdDebug() << k_funcinfo << "status is: " << (int)p.status << endl;
s << (int)p.status;
+ s << (int)p.onDemandPolicy;
s << p.service;
+ s << ( p.internet ? 1 : 0 );
+ s << p.netmasks;
return s;
}
TQDataStream & operator>> ( TQDataStream & s, NetworkStatus::Properties &p )
{
- int status;
- s >> p.name;
+ int status, onDemandPolicy, internet;
s >> status;
- p.status = (NetworkStatus::Status)status;
+ kdDebug() << k_funcinfo << "status is: " << status << endl;
+ p.status = ( NetworkStatus::EnumStatus )status;
+ s >> onDemandPolicy;
+ p.onDemandPolicy = ( NetworkStatus::EnumOnDemandPolicy )onDemandPolicy;
s >> p.service;
+ s >> internet;
+ if ( internet )
+ p.internet = true;
+ else
+ p.internet = false;
+ s >> p.netmasks;
+ kdDebug() << k_funcinfo << "enum converted status is: " << p.status << endl;
return s;
}
-
-namespace NetworkStatus
-{
- TQString toString( NetworkStatus::Status st )
- {
- TQString str;
- switch ( st ) {
- case NetworkStatus::NoNetworks:
- str = "NoNetworks";
- break;
- case NetworkStatus::Unreachable:
- str = "Unreachable";
- break;
- case NetworkStatus::OfflineDisconnected:
- str = "OfflineDisconnected";
- break;
- case NetworkStatus::OfflineFailed:
- str = "OfflineFailed";
- break;
- case NetworkStatus::ShuttingDown:
- str = "ShuttingDown";
- break;
- case NetworkStatus::Offline:
- str = "Offline";
- break;
- case NetworkStatus::Establishing:
- str = "Establishing";
- break;
- case NetworkStatus::Online:
- str = "Online";
- break;
- }
- return str;
- }
-} // namespace NetworkStatus
diff --git a/networkstatus/networkstatuscommon.h b/networkstatus/networkstatuscommon.h
index 73e41236f..63c388c3f 100644
--- a/networkstatus/networkstatuscommon.h
+++ b/networkstatus/networkstatuscommon.h
@@ -1,9 +1,12 @@
-/* This file is part of kdepim
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -11,13 +14,9 @@
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
#ifndef NETWORKSTATUS_COMMON_H
@@ -27,23 +26,26 @@
namespace NetworkStatus
{
- enum Status { NoNetworks = 1, Unreachable, OfflineDisconnected, OfflineFailed, ShuttingDown, Offline, Establishing, Online };
- enum RequestResult { RequestAccepted = 1, Connected, UserRefused, Unavailable };
- enum UnusedDemandPolicy { All, User, None, Permanent };
-
- // BINARY COMPATIBILITY ALERT BEGIN !!!!
- struct Properties
- {
- TQString name;
- Status status;
- UnusedDemandPolicy unused1;
- TQCString service;
- bool unused3;
- TQStringList unused4;
- };
- // BINARY COMPATIBILITY ALERT END !!!!
-
- TQString toString( Status st );
+ enum EnumStatus { NoNetworks = 1, Unreachable, OfflineDisconnected, OfflineFailed, ShuttingDown, Offline, Establishing, Online };
+ enum EnumRequestResult { RequestAccepted = 1, Connected, UserRefused, Unavailable };
+ enum EnumOnDemandPolicy { All, User, None, Permanent };
+ struct Properties
+ {
+ TQString name;
+ // status of the network
+ EnumStatus status;
+ // policy for on-demand usage as defined by the service
+ EnumOnDemandPolicy onDemandPolicy;
+ // identifier for the service
+ TQCString service;
+ // indicate that the connection is to 'the internet' - similar to default gateway in routing
+ bool internet;
+ // list of netmasks that the network connects to - overridden by above internet
+ TQStringList netmasks;
+ // for future expansion consider
+ // EnumChargingModel - FlatRate, TimeCharge, VolumeCharged
+ // EnumLinkStatus - for WLANs - VPOOR, POOR, AVERAGE, GOOD, EXCELLENT
+ };
}
TQDataStream & operator>> ( TQDataStream & s, NetworkStatus::Properties &p );
diff --git a/networkstatus/networkstatusiface.h b/networkstatus/networkstatusiface.h
deleted file mode 100644
index c35a22db5..000000000
--- a/networkstatus/networkstatusiface.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#ifndef KDED_NETWORKSTATUSIFACE_H
-#define KDED_NETWORKSTATUSIFACE_H
-
-#include <dcopobject.h>
-#include <tqstringlist.h>
-
-#include "networkstatuscommon.h"
-
-class NetworkStatusIface : virtual public DCOPObject
-{
-K_DCOP
-k_dcop:
- // Client interface
- virtual TQStringList networks() = 0;
- virtual int status() = 0;
- // Service interface
- virtual void setNetworkStatus( const TQString & networkName, int status ) = 0;
- virtual void registerNetwork( NetworkStatus::Properties properties ) = 0;
- virtual void unregisterNetwork( const TQString & networkName ) = 0 ;
-k_dcop_signals:
- /**
- * A status change occurred affecting the overall connectivity
- * @param status The new status
- */
- virtual void statusChange( int status ) = 0;
-};
-#endif
-// vim: sw=4 ts=4
diff --git a/networkstatus/networkstatusindicator.cpp b/networkstatus/networkstatusindicator.cpp
deleted file mode 100644
index 2afba0c6f..000000000
--- a/networkstatus/networkstatusindicator.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#include <tqlabel.h>
-#include <tqtooltip.h>
-#include <kiconloader.h>
-#include <klocale.h>
-
-#include "connectionmanager.h"
-
-#include "networkstatusindicator.h"
-
-StatusBarNetworkStatusIndicator::StatusBarNetworkStatusIndicator(
- TQWidget * parent, const char * name ) : TQHBox( parent, name )/*, d( new StatusBarNetworkStatusIndicatorPrivate )*/
-{
- setMargin( 2 );
- setSpacing( 1 );
- TQLabel * label = new TQLabel( this, "offlinemodelabel" );
- label->setPixmap( SmallIcon("connect_no") );
- TQToolTip::add( label, i18n( "The desktop is offline" ) );
-
- connect( ConnectionManager::self(), TQT_SIGNAL( statusChanged( NetworkStatus::Status ) ),
- TQT_SLOT( networkStatusChanged( NetworkStatus::Status) ) );
-
-}
-
-void StatusBarNetworkStatusIndicator::init()
-{
- networkStatusChanged( ConnectionManager::self()->status());
-}
-
-StatusBarNetworkStatusIndicator::~StatusBarNetworkStatusIndicator()
-{
-}
-
-void StatusBarNetworkStatusIndicator::networkStatusChanged( NetworkStatus::Status status )
-{
- if ( status == NetworkStatus::Online || status == NetworkStatus::NoNetworks ) {
- hide();
- } else {
- show();
- }
-}
-
-#include "networkstatusindicator.moc"
diff --git a/networkstatus/networkstatusindicator.h b/networkstatus/networkstatusindicator.h
deleted file mode 100644
index 417a08532..000000000
--- a/networkstatus/networkstatusindicator.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library. If not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this library
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#ifndef KDE_NETWORKSTATUS_INDICATOR_H
-#define KDE_NETWORKSTATUS_INDICATOR_H
-
-#include <tqhbox.h>
-#include <kdemacros.h>
-#include <networkstatuscommon.h>
-
-class StatusBarNetworkStatusIndicator : public TQHBox
-{
-Q_OBJECT
-public:
- StatusBarNetworkStatusIndicator( TQWidget * parent, const char * name );
- virtual ~StatusBarNetworkStatusIndicator();
- void init();
-protected slots:
- void networkStatusChanged( NetworkStatus::Status status );
-};
-
-#endif
-
diff --git a/networkstatus/provideriface.h b/networkstatus/provideriface.h
new file mode 100644
index 000000000..93f23103d
--- /dev/null
+++ b/networkstatus/provideriface.h
@@ -0,0 +1,42 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef NETWORKSTATUS_PROVIDERIFACE_H
+#define NETWORKSTATUS_PROVIDERIFACE_H
+
+#include <dcopobject.h>
+class ProviderIface : virtual public DCOPObject
+{
+K_DCOP
+k_dcop:
+ /** @return NetworkStatus::EnumOnlineStatus */
+ virtual int status( const TQString & network ) = 0;
+ /** @return NetworkStatus::EnumRequestResult */
+ virtual int establish( const TQString & network ) = 0;
+ /** @return NetworkStatus::EnumRequestResult */
+ virtual int shutdown( const TQString & network ) = 0;
+ /** fake a failure - go directly to failed */
+ virtual void simulateFailure() = 0;
+ /** fake a network disconnect - go directly to offlinedisconnected */
+ virtual void simulateDisconnect() = 0;
+};
+
+#endif
diff --git a/networkstatus/serviceiface.h b/networkstatus/serviceiface.h
new file mode 100644
index 000000000..1e6b423ff
--- /dev/null
+++ b/networkstatus/serviceiface.h
@@ -0,0 +1,51 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KDED_NETWORKSTATUS_SERVICEIFACE_H
+#define KDED_NETWORKSTATUS_SERVICEIFACE_H
+
+#include "networkstatuscommon.h"
+
+#include <dcopobject.h>
+
+class ServiceIface : virtual public DCOPObject
+{
+K_DCOP
+k_dcop:
+ /** Change the status for the given network */
+ virtual void setNetworkStatus( const TQString & networkName, int status ) = 0;
+ /** Register or update the properties for a network
+ NB Check that people don't use this to change status */
+ virtual void registerNetwork( const TQString & networkName, NetworkStatus::Properties properties ) = 0;
+ /**
+ * Indicate that this service is no longer administering the named network
+ * TODO: Work out the implications to clients of unregistering a network
+ * - maybe this method needs more parameters to give them a clue.
+ */
+ virtual void unregisterNetwork( const TQString & networkName ) = 0;
+ /**
+ * Tell the daemon that the service would like to shut down this network connection,
+ * and to notify clients using it so they can stop using it in a controlled manner
+ */
+ virtual void requestShutdown( const TQString & networkName ) = 0;
+};
+
+#endif
diff --git a/networkstatus/serviceifaceimpl.cpp b/networkstatus/serviceifaceimpl.cpp
new file mode 100644
index 000000000..cf5c0df99
--- /dev/null
+++ b/networkstatus/serviceifaceimpl.cpp
@@ -0,0 +1,46 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "serviceifaceimpl.h"
+
+ServiceIfaceImpl::ServiceIfaceImpl( NetworkStatusModule * module ) : m_module ( module )
+{
+}
+
+void ServiceIfaceImpl::setStatus( TQString networkName, int status )
+{
+ m_module->setStatus( networkName, (NetworkStatus::EnumStatus)status );
+}
+
+void ServiceIfaceImpl::registerNetwork( TQString networkName, NetworkStatus::Properties properties )
+{
+ m_module->registerNetwork( networkName, properties );
+}
+
+void ServiceIfaceImpl::unregisterNetwork( TQString networkName )
+{
+ m_module->unregisterNetwork( networkName );
+}
+
+void ServiceIfaceImpl::requestShutdown( TQString networkName )
+{
+ m_module->requestShutdown( networkName );
+}
diff --git a/networkstatus/serviceifaceimpl.h b/networkstatus/serviceifaceimpl.h
new file mode 100644
index 000000000..6ffba3609
--- /dev/null
+++ b/networkstatus/serviceifaceimpl.h
@@ -0,0 +1,43 @@
+/*
+ This file is part of kdepim.
+
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef NETWORKSTATUS_SERVICEIFACEIMPL_H
+#define NETWORKSTATUS_SERVICEIFACEIMPL_H
+
+#include "networkstatus.h"
+#include "serviceiface.h"
+
+/**
+ * Glue class linking DCOP skeleton to daemon
+ */
+class ServiceIfaceImpl : virtual public ServiceIface
+{
+public:
+ ServiceIfaceImpl( NetworkStatusModule * module );
+ void setStatus( TQString networkName, int status );
+ void registerNetwork( TQString networkName, NetworkStatus::Properties properties );
+ void unregisterNetwork( TQString networkName );
+ void requestShutdown( TQString networkName );
+private:
+ NetworkStatusModule * m_module;
+};
+
+#endif
diff --git a/networkstatus/testclient.cpp b/networkstatus/testclient.cpp
deleted file mode 100644
index 2c39a85ec..000000000
--- a/networkstatus/testclient.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/* This file is part of kdepim.
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#include <tqlabel.h>
-#include <tqpushbutton.h>
-
-
-#include <kaboutdata.h>
-#include <kcmdlineargs.h>
-#include <kdebug.h>
-#include <kdeversion.h>
-#include <kglobal.h>
-#include <klocale.h>
-#include <kiconloader.h>
-
-#include "connectionmanager.h"
-#include "testclientview.h"
-#include "testclient.h"
-
-TestClient::TestClient()
- : KMainWindow( 0, "ktestnetworkstatus" ),
- m_view(new TestClientView(this)),
- m_status( AppDisconnected )
-{
- // tell the KMainWindow that this is indeed the main widget
- setCentralWidget(m_view);
-
- networkStatusChanged( ConnectionManager::self()->status() );
- appDisconnected();
-
- connect( ConnectionManager::self(), TQT_SIGNAL( statusChanged( NetworkStatus::Status ) ), TQT_SLOT( networkStatusChanged( NetworkStatus::Status ) ) );
-
- connect( m_view->connectButton, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( connectButtonToggled( bool ) ) );
-}
-
-TestClient::~TestClient()
-{
-}
-
-void TestClient::networkStatusChanged( NetworkStatus::Status status )
-{
- kdDebug() << k_funcinfo << endl;
-//enum EnumStatus { NoNetworks = 1, Unreachable, OfflineDisconnected, OfflineFailed, ShuttingDown
-// , Offline, Establishing, Online };
- kdDebug() << "Networking is now: " << NetworkStatus::toString( status ) << " (" << status << ")" << endl;
- m_view->netStatusLabel->setText( NetworkStatus::toString( status ) );
- m_view->netStatusLabel->setPaletteBackgroundColor( toQColor( status ) );
- switch ( status ) {
- case NetworkStatus::NoNetworks:
- break;
- case NetworkStatus::Unreachable:
- break;
- case NetworkStatus::OfflineDisconnected:
- break;
- case NetworkStatus::OfflineFailed:
- break;
- case NetworkStatus::ShuttingDown:
- if ( m_status == AppConnected ) {
- appDisestablishing();
- }
- break;
- case NetworkStatus::Offline:
- if ( m_status == AppConnected ) {
- appDisconnected();
- }
- break;
- case NetworkStatus::Establishing:
- if ( m_status == AppWaitingForConnect )
- appEstablishing();
- else if ( m_status == AppConnected )
- appDisconnected();
- break;
- case NetworkStatus::Online:
- if ( m_status == AppWaitingForConnect )
- appIsConnected();
- break;
- default:
- m_view->netStatusLabel->setText( "Unrecognised status code!" );
- }
-}
-
-void TestClient::connectButtonToggled( bool on )
-{
- kdDebug() << k_funcinfo << endl;
- if ( on && m_status == AppDisconnected ) {
- switch ( ConnectionManager::self()->status() )
- {
- case NetworkStatus::NoNetworks:
- case NetworkStatus::Online:
- appIsConnected();
- break;
- default:
- appWaiting();
- break;
- }
- }
- else if ( !on && m_status == AppConnected ) {
- appDisconnected();
- }
-}
-
-void TestClient::appWaiting()
-{
- kdDebug() << k_funcinfo << endl;
- m_status = AppWaitingForConnect;
- m_view->appStatusLabel->setText( "Waiting" );
-}
-
-void TestClient::appIsConnected()
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( true );
- m_view->connectButton->setText( "Disconnect" );
- m_view->appStatusLabel->setText( "Connected" );
- m_status = AppConnected;
-}
-
-void TestClient::appEstablishing()
-{
- kdDebug() << k_funcinfo << endl;
- m_view->netStatusLabel->setText( "Establishing" );
- m_view->connectButton->setEnabled( false );
-}
-
-void TestClient::appDisestablishing( )
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( false );
- m_view->appStatusLabel->setText( "Disconnected" );
-}
-
-void TestClient::appDisconnected( )
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( true );
- m_view->connectButton->setText( "Start Connect" );
- m_view->appStatusLabel->setText( "Disconnected" );
- m_status = AppDisconnected;
-}
-
-TQColor TestClient::toQColor( NetworkStatus::Status st )
-{
- TQColor col;
- switch ( st ) {
- case NetworkStatus::NoNetworks:
- col = Qt::darkGray;
- break;
- case NetworkStatus::Unreachable:
- col = Qt::darkMagenta;
- break;
- case NetworkStatus::OfflineDisconnected:
- col = Qt::blue;
- break;
- case NetworkStatus::OfflineFailed:
- col = Qt::darkRed;
- break;
- case NetworkStatus::ShuttingDown:
- col = Qt::darkYellow;
- break;
- case NetworkStatus::Offline:
- col = Qt::blue;
- break;
- case NetworkStatus::Establishing:
- col = Qt::yellow;
- break;
- case NetworkStatus::Online:
- col = Qt::green;
- break;
- }
- return col;
-}
-//main
-static const char description[] =
- I18N_NOOP("Test Client for Network Status kded module");
-
-static const char version[] = "v0.1";
-
-static KCmdLineOptions options[] =
-{
- KCmdLineLastOption
-};
-
-int main(int argc, char **argv)
-{
- KAboutData about("KNetworkStatusTestClient", I18N_NOOP("knetworkstatustestclient"), version, description, KAboutData::License_GPL, "(C) 2007 Will Stephenson", 0, 0, "wstephenson@kde.org");
- about.addAuthor( "Will Stephenson", 0, "wstephenson@kde.org" );
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineArgs::addCmdLineOptions(options);
- KApplication app;
-
- // register ourselves as a dcop client
- app.dcopClient()->registerAs(app.name(), false);
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- if (args->count() == 0)
- {
- TestClient *widget = new TestClient;
- widget->show();
- }
- else
- {
- int i = 0;
- for (; i < args->count(); i++)
- {
- TestClient *widget = new TestClient;
- widget->show();
- }
- }
- args->clear();
-
- return app.exec();
-}
-
-#include "testclient.moc"
-
diff --git a/networkstatus/testclient.h b/networkstatus/testclient.h
deleted file mode 100644
index 77f7afa3e..000000000
--- a/networkstatus/testclient.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This file is part of kdepim.
-
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#ifndef KTESTNETWORKSTATUS_H
-#define KTESTNETWORKSTATUS_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <dcopclient.h>
-#include <kapplication.h>
-#include <kmainwindow.h>
-#include <networkstatuscommon.h>
-
-#include "networkstatusiface_stub.h"
-
-class TestClientView;
-
-/**
- * This class serves as the main window for ktestnetworkstatus. It handles the
- * menus, toolbars, and status bars.
- *
- * @short Main window class
- * @author Will Stephenson <wstephenson@kde.org>
- * @version 0.1
- */
-class TestClient : public KMainWindow
-{
-Q_OBJECT
-public:
- enum AppStatus{ AppDisconnected, AppWaitingForConnect, AppConnected };
- /**
- * Default Constructor
- */
- TestClient();
-
- /**
- * Default Destructor
- */
- virtual ~TestClient();
-
-private slots:
- void networkStatusChanged( NetworkStatus::Status status );
- void connectButtonToggled( bool on );
-private:
- void appWaiting();
- void appEstablishing();
- void appIsConnected();
- void appDisestablishing();
- void appDisconnected();
- static TQColor toQColor( NetworkStatus::Status );
-private:
- NetworkStatusIface_stub *m_service;
- TestClientView *m_view;
- AppStatus m_status; // this represents the app's status not the network's status
-};
-
-#endif // KTESTNETWORKSTATUS_H
-
diff --git a/networkstatus/testclient2.cpp b/networkstatus/testclient2.cpp
deleted file mode 100644
index 2e3a95e60..000000000
--- a/networkstatus/testclient2.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/* This file is part of kdepim.
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#include <tqlabel.h>
-#include <tqpushbutton.h>
-#include <tqvbox.h>
-
-#include <kaboutdata.h>
-#include <kcmdlineargs.h>
-#include <kdebug.h>
-#include <kdeversion.h>
-#include <kglobal.h>
-#include <klocale.h>
-#include <kiconloader.h>
-
-#include <connectionmanager.h>
-#include <networkstatusindicator.h>
-
-#include "testclientview.h"
-#include "testclient2.h"
-
-TestClient::TestClient()
- : KMainWindow( 0, "ktestnetworkstatus" ),
- m_layout( new TQVBox( 0, "layout" ) ),
- m_status( AppDisconnected )
-{
- m_view = new TestClientView( this );
- new StatusBarNetworkStatusIndicator( m_view, "statusindicator" );
- // tell the KMainWindow that this is indeed the main widget
- setCentralWidget(m_view);
-
- networkStatusChanged( ConnectionManager::self()->status() );
- appDisconnected();
-
- connect( ConnectionManager::self(), TQT_SIGNAL( statusChanged( NetworkStatus::Status ) ), TQT_SLOT( networkStatusChanged( NetworkStatus::Status ) ) );
- ConnectionManager::self()->registerConnectSlot( this, TQT_SLOT( doConnect() ) );
- ConnectionManager::self()->registerDisconnectSlot( this, TQT_SLOT( doDisconnect() ) );
-
- connect( m_view->connectButton, TQT_SIGNAL( clicked() ), TQT_SLOT( connectButtonClicked() ) );
-}
-
-TestClient::~TestClient()
-{
-}
-
-void TestClient::networkStatusChanged( NetworkStatus::Status status )
-{
- kdDebug() << k_funcinfo << endl;
- kdDebug() << "Networking is now: " << NetworkStatus::toString( status ) << " (" << status << ")" << endl;
- m_view->netStatusLabel->setText( NetworkStatus::toString( status ) );
- m_view->netStatusLabel->setPaletteBackgroundColor( toQColor( status ) );
-}
-
-void TestClient::doConnect()
-{
- Q_ASSERT( ConnectionManager::self()->status() == NetworkStatus::Online );
- if ( m_status != AppConnected ) {
- appIsConnected();
- }
-}
-
-void TestClient::doDisconnect()
-{
- Q_ASSERT( ConnectionManager::self()->status() != NetworkStatus::Online );
- if ( m_status == AppConnected ) {
- appDisconnected();
- }
-}
-
-void TestClient::connectButtonClicked()
-{
- kdDebug() << k_funcinfo << endl;
- if ( m_status == AppDisconnected ) {
- switch ( ConnectionManager::self()->status() )
- {
- case NetworkStatus::NoNetworks:
- case NetworkStatus::Online:
- appIsConnected();
- break;
- default:
- appWaiting();
- break;
- }
- }
- else if ( m_status == AppConnected || m_status == AppWaitingForConnect ) {
- appDisconnected();
- }
-}
-
-void TestClient::appWaiting()
-{
- kdDebug() << k_funcinfo << endl;
- //m_status = AppWaitingForConnect;
- m_view->appStatusLabel->setText( "Waiting" );
-}
-
-void TestClient::appIsConnected()
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( true );
- m_view->connectButton->setText( "Disconnect" );
- m_view->appStatusLabel->setText( "Connected" );
- m_status = AppConnected;
-}
-
-void TestClient::appEstablishing()
-{
- kdDebug() << k_funcinfo << endl;
- m_view->netStatusLabel->setText( "Establishing" );
- m_view->connectButton->setEnabled( false );
-}
-
-void TestClient::appDisestablishing( )
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( false );
- m_view->appStatusLabel->setText( "Disconnected" );
-}
-
-void TestClient::appDisconnected( )
-{
- kdDebug() << k_funcinfo << endl;
- m_view->connectButton->setEnabled( true );
- m_view->connectButton->setText( "Start Connect" );
- m_view->appStatusLabel->setText( "Disconnected" );
- m_status = AppDisconnected;
-}
-
-TQColor TestClient::toQColor( NetworkStatus::Status st )
-{
- TQColor col;
- switch ( st ) {
- case NetworkStatus::NoNetworks:
- col = Qt::darkGray;
- break;
- case NetworkStatus::Unreachable:
- col = Qt::darkMagenta;
- break;
- case NetworkStatus::OfflineDisconnected:
- col = Qt::blue;
- break;
- case NetworkStatus::OfflineFailed:
- col = Qt::darkRed;
- break;
- case NetworkStatus::ShuttingDown:
- col = Qt::darkYellow;
- break;
- case NetworkStatus::Offline:
- col = Qt::blue;
- break;
- case NetworkStatus::Establishing:
- col = Qt::yellow;
- break;
- case NetworkStatus::Online:
- col = Qt::green;
- break;
- }
- return col;
-}
-//main
-static const char description[] =
- I18N_NOOP("Test Client for Network Status kded module");
-
-static const char version[] = "v0.1";
-
-static KCmdLineOptions options[] =
-{
- KCmdLineLastOption
-};
-
-int main(int argc, char **argv)
-{
- KAboutData about("KNetworkStatusTestClient", I18N_NOOP("knetworkstatustestclient"), version, description, KAboutData::License_GPL, "(C) 2007 Will Stephenson", 0, 0, "wstephenson@kde.org");
- about.addAuthor( "Will Stephenson", 0, "wstephenson@kde.org" );
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineArgs::addCmdLineOptions(options);
- KApplication app;
-
- // register ourselves as a dcop client
- app.dcopClient()->registerAs(app.name(), false);
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- if (args->count() == 0)
- {
- TestClient *widget = new TestClient;
- widget->show();
- }
- else
- {
- int i = 0;
- for (; i < args->count(); i++)
- {
- TestClient *widget = new TestClient;
- widget->show();
- }
- }
- args->clear();
-
- return app.exec();
-}
-
-#include "testclient2.moc"
-
diff --git a/networkstatus/testclient2.h b/networkstatus/testclient2.h
deleted file mode 100644
index 257d6f949..000000000
--- a/networkstatus/testclient2.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This file is part of kdepim.
-
- Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
-*/
-
-#ifndef KTESTNETWORKSTATUS_H
-#define KTESTNETWORKSTATUS_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <dcopclient.h>
-#include <kapplication.h>
-#include <kmainwindow.h>
-#include <networkstatuscommon.h>
-
-#include "networkstatusiface_stub.h"
-
-class TestClientView;
-
-/**
- * Test client that uses a ConnectionManager to change its state
- *
- * @short Main window class
- * @author Will Stephenson <wstephenson@kde.org>
- * @version 0.1
- */
-class TestClient : public KMainWindow
-{
-Q_OBJECT
-public:
- enum AppStatus{ AppDisconnected, AppWaitingForConnect, AppConnected };
- /**
- * Default Constructor
- */
- TestClient();
-
- /**
- * Default Destructor
- */
- virtual ~TestClient();
-
-private slots:
- void networkStatusChanged( NetworkStatus::Status status );
- void connectButtonClicked();
- void doConnect();
- void doDisconnect();
-private:
- void appWaiting();
- void appEstablishing();
- void appIsConnected();
- void appDisestablishing();
- void appDisconnected();
- static TQColor toQColor( NetworkStatus::Status );
-private:
- TQHBox * m_layout;
- NetworkStatusIface_stub *m_service;
- TestClientView *m_view;
- AppStatus m_status; // this represents the app's status not the network's status
-};
-
-#endif // KTESTNETWORKSTATUS_H
-
diff --git a/networkstatus/testclientview.ui b/networkstatus/testclientview.ui
deleted file mode 100644
index 1ef36de23..000000000
--- a/networkstatus/testclientview.ui
+++ /dev/null
@@ -1,177 +0,0 @@
-<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
-<class>TestClientView</class>
-<widget class="QWidget">
- <property name="name">
- <cstring>TestClientView</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>356</width>
- <height>127</height>
- </rect>
- </property>
- <property name="caption">
- <string>Form1</string>
- </property>
- <vbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel4</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&lt;font size="+2"&gt;&lt;b&gt;Client for KDE 3 Offline Mode&lt;/b&gt;&lt;/font&gt;</string>
- </property>
- <property name="alignment">
- <set>AlignVCenter</set>
- </property>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout1</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel1</cstring>
- </property>
- <property name="text">
- <string>Network status:</string>
- </property>
- </widget>
- <widget class="QLabel">
- <property name="name">
- <cstring>netStatusLabel</cstring>
- </property>
- <property name="paletteBackgroundColor">
- <color>
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </property>
- <property name="frameShape">
- <enum>Panel</enum>
- </property>
- <property name="text">
- <string>STATUS</string>
- </property>
- <property name="alignment">
- <set>AlignCenter</set>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout1_2</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel1_2</cstring>
- </property>
- <property name="text">
- <string>App status:</string>
- </property>
- </widget>
- <widget class="QLabel">
- <property name="name">
- <cstring>appStatusLabel</cstring>
- </property>
- <property name="paletteBackgroundColor">
- <color>
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </property>
- <property name="frameShape">
- <enum>Panel</enum>
- </property>
- <property name="text">
- <string>STATUS</string>
- </property>
- <property name="alignment">
- <set>AlignCenter</set>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout2</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <spacer>
- <property name="name">
- <cstring>spacer1</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>31</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget class="QPushButton">
- <property name="name">
- <cstring>connectButton</cstring>
- </property>
- <property name="text">
- <string>Start Connect</string>
- </property>
- <property name="toggleButton">
- <bool>false</bool>
- </property>
- </widget>
- <spacer>
- <property name="name">
- <cstring>spacer2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>61</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </hbox>
- </widget>
- </vbox>
-</widget>
-<layoutdefaults spacing="6" margin="11"/>
-</UI>
diff --git a/networkstatus/testservice.cpp b/networkstatus/testservice.cpp
index 0938b882a..46b19109f 100644
--- a/networkstatus/testservice.cpp
+++ b/networkstatus/testservice.cpp
@@ -1,126 +1,55 @@
-/* This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+/*
+ This file is part of kdepim.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- as published by the Free Software Foundation.
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
- This program is distributed in the hope that it will be useful,
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
*/
-#include <tqcombobox.h>
-#include <tqlabel.h>
-#include <tqpushbutton.h>
#include <tqtimer.h>
-
#include <dcopclient.h>
-#include <kaboutdata.h>
#include <kapplication.h>
-#include <kcmdlineargs.h>
-#include <kdebug.h>
-#include <klocale.h>
+#include "provideriface.h"
#include "testservice.h"
-#include "testserviceview.h"
-#include "networkstatusiface_stub.h"
-
-TestService::TestService() : KMainWindow( 0, "testservice" ),
- m_service( new NetworkStatusIface_stub( "kded", "networkstatus" ) ),
- m_status ( NetworkStatus::Offline ),
- m_nextStatus( NetworkStatus::OfflineDisconnected ),
- m_view( new TestServiceView( this ) )
-{
- setCentralWidget( m_view );
- kapp->dcopClient()->registerAs("testservice" );
-
- connect( m_view->changeCombo, TQT_SIGNAL( activated( int ) ), TQT_SLOT( changeComboActivated( int ) ) );
- connect( m_view->changeButton, TQT_SIGNAL( clicked() ), TQT_SLOT( changeButtonClicked() ) );
-
- connect( kapp->dcopClient(), TQT_SIGNAL( applicationRegistered( const TQCString& ) ), this, TQT_SLOT( registeredToDCOP( const TQCString& ) ) );
- kapp->dcopClient()->setNotifications( true );
-
- m_view->statusLabel->setText( NetworkStatus::toString( m_status ) );
- m_view->statusLabel->setPaletteBackgroundColor( toQColor( m_status ) );
- setCaption( NetworkStatus::toString( m_status ) );
+#include "serviceiface_stub.h"
- registerService();
-}
-
-TestService::~TestService()
+TestService::TestService() : TQObject(), DCOPObject("ProviderIface")
{
- delete m_service;
- delete m_view;
+ kapp->dcopClient()->registerAs("testservice" );
+ m_service = new ServiceIface_stub( "kded", "networkstatus" );
+ m_status = NetworkStatus::Offline;
+ NetworkStatus::Properties nsp;
+ nsp.internet = true;
+ nsp.name = "test_net";
+ nsp.onDemandPolicy = NetworkStatus::All;
+ nsp.service = kapp->dcopClient()->appId();
+ nsp.status = m_status;
+ m_service->registerNetwork( "test_net", nsp );
}
-void TestService::registerService()
-{
- NetworkStatus::Properties nsp;
- nsp.name = "test_net";
- nsp.service = kapp->dcopClient()->appId();
- nsp.status = m_status;
- m_service->registerNetwork( nsp );
-}
-
-void TestService::registeredToDCOP( const TQCString & appId )
+TestService::~TestService()
{
- if ( appId == "kded" )
- registerService();
+ delete m_service;
}
int TestService::status( const TQString & network )
{
- Q_UNUSED( network );
- return (int)m_status;
-}
-
-void TestService::changeComboActivated( int index )
-{
- switch ( index ) {
- case 0 /*NetworkStatus::OfflineDisconnected*/:
- m_nextStatus = NetworkStatus::OfflineDisconnected;
- break;
- case 1 /*NetworkStatus::OfflineFailed*/:
- m_nextStatus = NetworkStatus::OfflineFailed;
- break;
- case 2 /*NetworkStatus::ShuttingDown*/:
- m_nextStatus = NetworkStatus::ShuttingDown;
- break;
- case 3 /*NetworkStatus::Offline*/:
- m_nextStatus = NetworkStatus::Offline;
- break;
- case 4 /*NetworkStatus::Establishing*/:
- m_nextStatus = NetworkStatus::Establishing;
- break;
- case 5 /*NetworkStatus::Online*/:
- m_nextStatus = NetworkStatus::Online;
- break;
- default:
- kdDebug() << "Unrecognised status!" << endl;
- Q_ASSERT( false );
- }
- m_view->changeButton->setEnabled( true );
-}
-
-void TestService::changeButtonClicked()
-{
- m_view->changeButton->setEnabled( false );
- m_status = m_nextStatus;
- m_service->setNetworkStatus( "test_net", ( int )m_status );
- m_view->statusLabel->setText( NetworkStatus::toString( m_status ) );
- m_view->statusLabel->setPaletteBackgroundColor( toQColor( m_status ) );
- setCaption( NetworkStatus::toString( m_status ) );
+ Q_UNUSED( network );
+ return (int)m_status;
}
int TestService::establish( const TQString & network )
@@ -161,59 +90,12 @@ void TestService::slotStatusChange()
m_service->setNetworkStatus( "test_net", (int)m_status );
}
-TQColor TestService::toQColor( NetworkStatus::Status st )
-{
- TQColor col;
- switch ( st ) {
- case NetworkStatus::NoNetworks:
- col = Qt::darkGray;
- break;
- case NetworkStatus::Unreachable:
- col = Qt::darkMagenta;
- break;
- case NetworkStatus::OfflineDisconnected:
- col = Qt::blue;
- break;
- case NetworkStatus::OfflineFailed:
- col = Qt::darkRed;
- break;
- case NetworkStatus::ShuttingDown:
- col = Qt::darkYellow;
- break;
- case NetworkStatus::Offline:
- col = Qt::blue;
- break;
- case NetworkStatus::Establishing:
- col = Qt::yellow;
- break;
- case NetworkStatus::Online:
- col = Qt::green;
- break;
- }
- return col;
-}
-
-static const char description[] =
- I18N_NOOP("Test Service for Network Status kded module");
-
-static const char version[] = "v0.1";
-
-static KCmdLineOptions options[] =
-{
- KCmdLineLastOption
-};
-
int main( int argc, char** argv )
{
- KAboutData about("KNetworkStatusTestService", I18N_NOOP("knetworkstatustestservice"), version, description, KAboutData::License_GPL, "(C) 2007 Will Stephenson", 0, 0, "wstephenson@kde.org");
- about.addAuthor( "Will Stephenson", 0, "wstephenson@kde.org" );
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineArgs::addCmdLineOptions(options);
- KApplication app;
-
- TestService * test = new TestService;
- test->show();
- return app.exec();
+ KApplication app(argc, argv, "testdcop");
+ TestService * test = new TestService;
+ Q_UNUSED( test );
+ return app.exec();
}
#include "testservice.moc"
diff --git a/networkstatus/testservice.h b/networkstatus/testservice.h
index 9c641f893..65febdca9 100644
--- a/networkstatus/testservice.h
+++ b/networkstatus/testservice.h
@@ -1,37 +1,34 @@
-/* This file is part of kdepim.
+/*
+ This file is part of kdepim.
- Copyright (C) 2005,2007 Will Stephenson <wstephenson@kde.org>
+ Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, permission is given to link this program
- with any edition of TQt, and distribute the resulting executable,
- without including the source code for TQt in the source distribution.
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
#ifndef _TEST_NETWORKSTATUS_SERVICE_H
#define _TEST_NETWORKSTATUS_SERVICE_H
-#include <kmainwindow.h>
-
#include "networkstatuscommon.h"
+#include "provideriface.h"
-class NetworkStatusIface_stub;
-class TestServiceView;
+class ServiceIface_stub;
-class TestService : public KMainWindow {
+class TestService : virtual public TQObject, ProviderIface
+{
Q_OBJECT
public:
TestService();
@@ -42,19 +39,11 @@ public:
void simulateFailure();
void simulateDisconnect();
protected slots:
- void changeComboActivated( int index );
- void registeredToDCOP( const TQCString& appId );
-
- void changeButtonClicked();
-
void slotStatusChange();
private:
- void registerService();
- static TQColor toQColor( NetworkStatus::Status );
- NetworkStatusIface_stub * m_service;
- NetworkStatus::Status m_status;
- NetworkStatus::Status m_nextStatus;
- TestServiceView * m_view;
+ ServiceIface_stub * m_service;
+ NetworkStatus::EnumStatus m_status;
+ NetworkStatus::EnumStatus m_nextStatus;
};
#endif
diff --git a/networkstatus/testserviceview.ui b/networkstatus/testserviceview.ui
deleted file mode 100644
index 17e4853c4..000000000
--- a/networkstatus/testserviceview.ui
+++ /dev/null
@@ -1,181 +0,0 @@
-<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
-<class>TestServiceView</class>
-<widget class="QWidget">
- <property name="name">
- <cstring>TestServiceView</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>367</width>
- <height>132</height>
- </rect>
- </property>
- <property name="caption">
- <string>Form1</string>
- </property>
- <vbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel4</cstring>
- </property>
- <property name="text">
- <string>&lt;font size="+2"&gt;&lt;b&gt;Service for KDE 3 Offline Mode&lt;/b&gt;&lt;/font&gt;</string>
- </property>
- <property name="alignment">
- <set>AlignVCenter</set>
- </property>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout2</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel1</cstring>
- </property>
- <property name="text">
- <string>Status:</string>
- </property>
- </widget>
- <widget class="QLabel">
- <property name="name">
- <cstring>statusLabel</cstring>
- </property>
- <property name="paletteBackgroundColor">
- <color>
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </property>
- <property name="frameShape">
- <enum>StyledPanel</enum>
- </property>
- <property name="text">
- <string>STATUS</string>
- </property>
- <property name="alignment">
- <set>AlignCenter</set>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout3</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="QLabel">
- <property name="name">
- <cstring>textLabel3</cstring>
- </property>
- <property name="text">
- <string>Change to:</string>
- </property>
- </widget>
- <widget class="QComboBox">
- <item>
- <property name="text">
- <string>Offline Disconnected</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Offline Failed</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Shutting Down</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Offline</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Establishing</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Online</string>
- </property>
- </item>
- <property name="name">
- <cstring>changeCombo</cstring>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>layout1</cstring>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <spacer>
- <property name="name">
- <cstring>spacer1</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>51</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget class="QPushButton">
- <property name="name">
- <cstring>changeButton</cstring>
- </property>
- <property name="text">
- <string>Do change</string>
- </property>
- </widget>
- <spacer>
- <property name="name">
- <cstring>spacer2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>41</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </hbox>
- </widget>
- </vbox>
-</widget>
-<layoutdefaults spacing="6" margin="11"/>
-</UI>
-