diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-27 11:52:10 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-27 11:52:10 -0500 |
commit | 2a415e33e054e00a9b1a3385d3883f36c9c1b6d4 (patch) | |
tree | b9025bd120d65d48067e2f29ce13cf550580b119 /tdecore | |
parent | cfbdd55bb39f6e2012103a506d8d2506145cc936 (diff) | |
download | tdelibs-2a415e33e054e00a9b1a3385d3883f36c9c1b6d4.tar.gz tdelibs-2a415e33e054e00a9b1a3385d3883f36c9c1b6d4.zip |
Add network manager global object to kinstance
This breaks the ABI
Diffstat (limited to 'tdecore')
-rw-r--r-- | tdecore/kglobal.cpp | 8 | ||||
-rw-r--r-- | tdecore/kglobal.h | 11 | ||||
-rw-r--r-- | tdecore/kinstance.cpp | 18 | ||||
-rw-r--r-- | tdecore/kinstance.h | 11 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.cpp | 96 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.h | 144 |
6 files changed, 285 insertions, 3 deletions
diff --git a/tdecore/kglobal.cpp b/tdecore/kglobal.cpp index efb9d803f..6c88302ce 100644 --- a/tdecore/kglobal.cpp +++ b/tdecore/kglobal.cpp @@ -35,6 +35,7 @@ #include <kcharsets.h> #include <kiconloader.h> #include <tdehardwaredevices.h> +#include <tdenetworkconnections.h> #include <kstandarddirs.h> #include <kinstance.h> #include "kstaticdeleter.h" @@ -87,6 +88,13 @@ TDEHardwareDevices *KGlobal::hardwareDevices() return _instance->hardwareDevices(); } +TDEGlobalNetworkManager *KGlobal::networkManager() +{ + MYASSERT(_instance); + + return _instance->networkManager(); +} + KInstance *KGlobal::instance() { MYASSERT(_instance); diff --git a/tdecore/kglobal.h b/tdecore/kglobal.h index a6a60c96c..d7aadbc3f 100644 --- a/tdecore/kglobal.h +++ b/tdecore/kglobal.h @@ -26,6 +26,7 @@ class KConfig; class KSharedConfig; class KIconLoader; class TDEHardwareDevices; +class TDEGlobalNetworkManager; class KLocale; class KStandardDirs; class KStaticDeleterBase; @@ -79,12 +80,18 @@ public: static KIconLoader *iconLoader(); /** - * Returns a hardwaredevices object. - * @return the global hardwaredevices object + * Returns a TDEHardwareDevices object. + * @return the global hardware devices object */ static TDEHardwareDevices *hardwareDevices(); /** + * Returns a TDEGlobalNetworkManager object. + * @return the global network manager object + */ + static TDEGlobalNetworkManager *networkManager(); + + /** * Returns the global locale object. * @return the global locale object */ diff --git a/tdecore/kinstance.cpp b/tdecore/kinstance.cpp index 5b3aa8625..721864e5a 100644 --- a/tdecore/kinstance.cpp +++ b/tdecore/kinstance.cpp @@ -25,6 +25,7 @@ #include "kcharsets.h" #include "kiconloader.h" #include "tdehardwaredevices.h" +#include "tdenetworkconnections.h" #include "kaboutdata.h" #include "kstandarddirs.h" #include "kdebug.h" @@ -72,6 +73,7 @@ KInstance::KInstance( const TQCString& name) _config (0L), _iconLoader (0L), _hardwaredevices (0L), + _networkmanager (0L), _name( name ), _aboutData( new KAboutData( name, "", 0 ) ), m_configReadOnly(false) { DEBUG_ADD @@ -91,6 +93,7 @@ KInstance::KInstance( const KAboutData * aboutData ) _config (0L), _iconLoader (0L), _hardwaredevices (0L), + _networkmanager (0L), _name( aboutData->appName() ), _aboutData( aboutData ), m_configReadOnly(false) { DEBUG_ADD @@ -111,6 +114,7 @@ KInstance::KInstance( KInstance* src ) _config ( src->_config ), _iconLoader ( src->_iconLoader ), _hardwaredevices ( src->_hardwaredevices ), + _networkmanager ( src->_networkmanager ), _name( src->_name ), _aboutData( src->_aboutData ), m_configReadOnly(false) { DEBUG_ADD @@ -130,6 +134,7 @@ KInstance::KInstance( KInstance* src ) src->_config = 0L; src->_iconLoader = 0L; src->_hardwaredevices = 0L; + src->_networkmanager = 0L; src->_aboutData = 0L; delete src; } @@ -151,6 +156,9 @@ KInstance::~KInstance() delete _hardwaredevices; _hardwaredevices = 0; + delete _networkmanager; + _networkmanager = 0; + // delete _config; // Do not delete, stored in d->sharedConfig _config = 0; delete _dirs; @@ -272,6 +280,16 @@ TDEHardwareDevices *KInstance::hardwareDevices() const return _hardwaredevices; } +TDEGlobalNetworkManager *KInstance::networkManager() const +{ + DEBUG_CHECK_ALIVE + if( _networkmanager == 0 ) { + _networkmanager = new TDEGlobalNetworkManager( ); + } + + return _networkmanager; +} + void KInstance::newIconLoader() const { DEBUG_CHECK_ALIVE diff --git a/tdecore/kinstance.h b/tdecore/kinstance.h index 444a2d8c8..5d1dbdce0 100644 --- a/tdecore/kinstance.h +++ b/tdecore/kinstance.h @@ -28,6 +28,7 @@ class KInstancePrivate; class KMimeSourceFactory; class KSharedConfig; class TDEHardwareDevices; +class TDEGlobalNetworkManager; #include <tqstring.h> #include "tdelibs_export.h" @@ -110,12 +111,18 @@ class TDECORE_EXPORT KInstance KIconLoader *iconLoader() const; /** - * Returns a hardwaredevices object. + * Returns a TDEHardwareDevices object. * @return the hardwaredevices object. */ TDEHardwareDevices *hardwareDevices() const; /** + * Returns a TDEGlobalNetworkManager object. + * @return the networkmanager object. + */ + TDEGlobalNetworkManager *networkManager() const; + + /** * Re-allocate the global iconloader. */ void newIconLoader() const; @@ -162,6 +169,8 @@ private: mutable KIconLoader *_iconLoader; mutable TDEHardwareDevices *_hardwaredevices; + mutable TDEGlobalNetworkManager *_networkmanager; + mutable void *_placeholder; TQCString _name; const KAboutData *_aboutData; diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp index 0a3893f1f..70d528e9b 100644 --- a/tdecore/tdenetworkconnections.cpp +++ b/tdecore/tdenetworkconnections.cpp @@ -19,6 +19,12 @@ #include "tdehardwaredevices.h" #include "tdenetworkconnections.h" +#include "config.h" + +#ifdef WITH_NETWORK_MANAGER_BACKEND +#include "networkbackends/network-manager/network-manager.h" +#endif // WITH_NETWORK_MANAGER_BACKEND + #define SET_BIT(x, y) (x |= 1 << y) #define TEST_BIT(x, y) ((x & (1 << y)) >> y) @@ -466,6 +472,96 @@ void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkCo } /*================================================================================================*/ +/* TDEGlobalNetworkManager */ +/*================================================================================================*/ + +TDEGlobalNetworkManager::TDEGlobalNetworkManager() : m_internalConnectionManager(NULL) { +#ifdef WITH_NETWORK_MANAGER_BACKEND + m_internalConnectionManager = new TDENetworkConnectionManager_BackendNM(TQString::null); +#endif // WITH_NETWORK_MANAGER_BACKEND + connect(m_internalConnectionManager, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); +} + +TDEGlobalNetworkManager::~TDEGlobalNetworkManager() { + delete m_internalConnectionManager; +} + +TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags TDEGlobalNetworkManager::backendStatus() { + if (!m_internalConnectionManager) return TDENetworkGlobalManagerFlags::Unknown; + return m_internalConnectionManager->backendStatus(); +} + +void TDEGlobalNetworkManager::loadConnectionInformation() { + if (!m_internalConnectionManager) return; + return m_internalConnectionManager->loadConnectionInformation(); +} + +bool TDEGlobalNetworkManager::loadConnectionSecrets(TQString uuid) { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->loadConnectionSecrets(uuid); +} + +bool TDEGlobalNetworkManager::saveConnection(TDENetworkConnection* connection) { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->saveConnection(connection); +} + +bool TDEGlobalNetworkManager::deleteConnection(TQString uuid) { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->deleteConnection(uuid); +} + +TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::initiateConnection(TQString uuid) { + if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid; + return m_internalConnectionManager->initiateConnection(uuid); +} + +TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::checkConnectionStatus(TQString uuid) { + if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid; + return m_internalConnectionManager->checkConnectionStatus(uuid); +} + +TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::deactivateConnection(TQString uuid) { + if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid; + return m_internalConnectionManager->deactivateConnection(uuid); +} + +TDENetworkHWNeighborList* TDEGlobalNetworkManager::siteSurvey() { + if (!m_internalConnectionManager) return NULL; + return m_internalConnectionManager->siteSurvey(); +} + +bool TDEGlobalNetworkManager::networkingEnabled() { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->networkingEnabled(); +} + +bool TDEGlobalNetworkManager::wiFiHardwareEnabled() { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->wiFiHardwareEnabled(); +} + +bool TDEGlobalNetworkManager::enableWiFi(bool enable) { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->enableWiFi(enable); +} + +bool TDEGlobalNetworkManager::wiFiEnabled() { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->wiFiEnabled(); +} + +TDENetworkConnectionList* TDEGlobalNetworkManager::connections() { + if (!m_internalConnectionManager) return NULL; + return m_internalConnectionManager->connections(); +} + +TDENetworkConnection* TDEGlobalNetworkManager::findConnectionByUUID(TQString uuid) { + if (!m_internalConnectionManager) return NULL; + return m_internalConnectionManager->findConnectionByUUID(uuid); +} + +/*================================================================================================*/ /* End */ /*================================================================================================*/ diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h index bec8d3201..985f75e68 100644 --- a/tdecore/tdenetworkconnections.h +++ b/tdecore/tdenetworkconnections.h @@ -688,4 +688,148 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus; }; +class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject +{ + Q_OBJECT + + public: + /** + * Constructor. + */ + TDEGlobalNetworkManager(); + + /** + * Destructor. + */ + ~TDEGlobalNetworkManager(); + + /** + * @return A TDENetworkGlobalManagerFlags enum value with the current status of the networking backend. + */ + virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus(); + + /** + * Loads all connection information from the configuration backend + * Secret information must be loaded separately via a call to + * loadConnectionSecrets(TQString uuid) after this method has been + * executed at least once. + */ + virtual void loadConnectionInformation(); + + /** + * @param uuid a TQString conntaining the UUID of a connection for which to + * load secrets from the configuration backend. + * @return true on success, false on failure. + */ + virtual bool loadConnectionSecrets(TQString uuid); + + /** + * @param connection a pointer to a TDENetworkConnection object containing a + * connection to save to the configuration backend. + * @return true on success, false on failure. + */ + virtual bool saveConnection(TDENetworkConnection* connection); + + /** + * @param uuid a TQString conntaining the UUID of a connection to + * delete from the configuration backend. + * @return true on success, false on failure. + */ + virtual bool deleteConnection(TQString uuid); + + /** + * Initiates a connection with UUID @param uuid. + * @return A TDENetworkConnectionStatus enum value with the current connection status + * The client application should poll for status updates using checkConnectionStatus() + */ + virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid); + + /** + * Checks the status of a connection with UUID @param uuid. + * @return A TDENetworkConnectionStatus enum value with the current connection status + */ + virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid); + + /** + * Disconnects a connection with UUID @param uuid. + * @return A TDENetworkConnectionStatus enum value with the current connection status + * The client application should poll for status updates using checkConnectionStatus() + */ + virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid); + + /** + * @return a TDENetworkHWNeighborList object containing the result of a site survey; + * i.e. all nearby access points or devices. This function only returns valid information + * if the underlying network device supports site surveys. + * + * Note that the returned list is internally managed and must not be deleted! + * Also note that pointers in the list may become invalid on subsequent calls to + * siteSurvey(). + */ + virtual TDENetworkHWNeighborList* siteSurvey(); + + /** + * @return true if networking is enabled, false if not. + */ + virtual bool networkingEnabled(); + + /** + * @return true if WiFi hardware is enabled, false if not. + */ + virtual bool wiFiHardwareEnabled(); + + /** + * @param enable true to enable WiFi, false to disable it. + * @return true on success, false on failure. + */ + virtual bool enableWiFi(bool enable); + + /** + * @return true if WiFi is enabled, false if not. + */ + virtual bool wiFiEnabled(); + + signals: + /** + * Emitted whenever the state of the system's connection changes + * If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid + */ + void networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState); + + /** + * Emitted whenever the state of a device changes + * If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid + * If the global connection state has changed, @param hwAddress will be empty, otherwise it will contain the MAC address + * of the networking hardware that has changed state. + */ + void networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus previousState, TQString hwAddress); + + public: + /** + * @return a TDENetworkConnectionList object containing a list of all + * possible connections this connection manager is aware of, regardless + * of current state or availability. + * + * loadConnectionInformation() should be called at least once before calling + * this method, in order to update internal connection information from the + * configuration backend. + * + * Note that the returned list is internally managed and must not be deleted! + * Also note that pointers in the list may become invalid on subsequent calls to + * loadConnectionInformation(), saveConnection(), deleteConnection(), or connections(). + */ + virtual TDENetworkConnectionList* connections(); + + /** + * @return a pointer to a TDENetworkConnection object with the specified @param uuid, + * or a NULL pointer if no such connection exists. + * + * Note that the returned object is internally managed and must not be deleted! + */ + TDENetworkConnection* findConnectionByUUID(TQString uuid); + + private: + TDENetworkConnectionManager* m_internalConnectionManager; +}; + #endif // _TDENETWORKCONNECTIONS_H
\ No newline at end of file |