diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-04 10:25:49 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-09-04 10:25:49 -0500 |
commit | aaaec8b3f88a53ce2ec3b9295774523b6f2d8c82 (patch) | |
tree | fc7b5577502365de25a1b7031060b9661c3e5565 | |
parent | adea4c592cd28583a9a8cc24b9ec68bb118d874a (diff) | |
download | tdelibs-aaaec8b3f88a53ce2ec3b9295774523b6f2d8c82.tar.gz tdelibs-aaaec8b3f88a53ce2ec3b9295774523b6f2d8c82.zip |
Add global networking state control
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.cpp | 24 | ||||
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.h | 1 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.cpp | 5 | ||||
-rw-r--r-- | tdecore/tdenetworkconnections.h | 12 |
4 files changed, 42 insertions, 0 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp index b68a8bdb8..3a303237b 100644 --- a/tdecore/networkbackends/network-manager/network-manager.cpp +++ b/tdecore/networkbackends/network-manager/network-manager.cpp @@ -4117,6 +4117,30 @@ bool TDENetworkConnectionManager_BackendNM::wiFiHardwareEnabled() { } } +bool TDENetworkConnectionManager_BackendNM::enableNetworking(bool enable) { + // FIXME + // Yes, this abuses the Sleep command + // Is there a better way to do it? + if (d->m_networkManagerProxy) { + int asynccallid; + TQT_DBusError error; + d->m_networkManagerProxy->SleepAsync(asynccallid, !enable, error); + if (error.isValid()) { + // Error! + PRINT_ERROR(error.name()) + return FALSE; + } + else { + // FIXME + // Wait for async reply before returning... + return TRUE; + } + } + else { + return FALSE; + } +} + bool TDENetworkConnectionManager_BackendNM::enableWiFi(bool enable) { if (d->m_networkManagerProxy) { TQT_DBusError error; diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h index 82e12696a..ef878bb00 100644 --- a/tdecore/networkbackends/network-manager/network-manager.h +++ b/tdecore/networkbackends/network-manager/network-manager.h @@ -143,6 +143,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo virtual bool networkingEnabled(); virtual bool wiFiHardwareEnabled(); + virtual bool enableNetworking(bool enable); virtual bool enableWiFi(bool enable); virtual bool wiFiEnabled(); diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp index a02f72e64..96da418e7 100644 --- a/tdecore/tdenetworkconnections.cpp +++ b/tdecore/tdenetworkconnections.cpp @@ -729,6 +729,11 @@ bool TDEGlobalNetworkManager::networkingEnabled() { return m_internalConnectionManager->networkingEnabled(); } +bool TDEGlobalNetworkManager::enableNetworking(bool enable) { + if (!m_internalConnectionManager) return false; + return m_internalConnectionManager->enableNetworking(enable); +} + bool TDEGlobalNetworkManager::wiFiHardwareEnabled() { if (!m_internalConnectionManager) return false; return m_internalConnectionManager->wiFiHardwareEnabled(); diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h index ca20f613c..e13484262 100644 --- a/tdecore/tdenetworkconnections.h +++ b/tdecore/tdenetworkconnections.h @@ -994,6 +994,12 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject virtual bool networkingEnabled() = 0; /** + * @param enable true to enable networking, false to disable it. + * @return true on success, false on failure. + */ + virtual bool enableNetworking(bool enable) = 0; + + /** * @return true if WiFi hardware is enabled, false if not. */ virtual bool wiFiHardwareEnabled() = 0; @@ -1148,6 +1154,12 @@ class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject virtual bool networkingEnabled(); /** + * @param enable true to enable networking, false to disable it. + * @return true on success, false on failure. + */ + virtual bool enableNetworking(bool enable); + + /** * @return true if WiFi hardware is enabled, false if not. */ virtual bool wiFiHardwareEnabled(); |