summaryrefslogtreecommitdiffstats
path: root/networkstatus/connectionmanager.h
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/connectionmanager.h
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/connectionmanager.h')
-rw-r--r--networkstatus/connectionmanager.h194
1 files changed, 42 insertions, 152 deletions
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