summaryrefslogtreecommitdiffstats
path: root/tdecore/networkbackends
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-11 10:02:26 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-09-11 10:02:26 -0500
commit92fcdec6c3fc085186c8d32d8dd8fa8641d7da33 (patch)
tree2132628449e87396d1ce2778ee7ac466222e3799 /tdecore/networkbackends
parent8be09fcc83077443fc3277dfa974d6aa02afc5bf (diff)
downloadtdelibs-92fcdec6c3fc085186c8d32d8dd8fa8641d7da33.tar.gz
tdelibs-92fcdec6c3fc085186c8d32d8dd8fa8641d7da33.zip
Add VPN status flags and signals
Diffstat (limited to 'tdecore/networkbackends')
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.cpp78
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.h11
-rw-r--r--tdecore/networkbackends/network-manager/network-manager_p.h5
3 files changed, 91 insertions, 3 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp
index a9a076139..a3ebba325 100644
--- a/tdecore/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/networkbackends/network-manager/network-manager.cpp
@@ -160,6 +160,42 @@ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nmGlobalStateToTDEGlo
return ret;
}
+TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nmVPNStateToTDEGlobalState(TQ_UINT32 nmType) {
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags ret = TDENetworkGlobalManagerFlags::Unknown;
+
+ if (nmType == NM_VPN_STATE_UNKNOWN) {
+ ret |= TDENetworkGlobalManagerFlags::VPNUnknown;
+ }
+ else if (nmType == NM_VPN_STATE_PREPARE) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNEstablishingLink;
+ }
+ else if (nmType == NM_VPN_STATE_NEED_AUTH) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNNeedAuthorization;
+ }
+ else if (nmType == NM_VPN_STATE_CONNECT) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNConfiguringProtocols;
+ }
+ else if (nmType == NM_VPN_STATE_IP_CONFIG_GET) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNVerifyingProtocols;
+ }
+ else if (nmType == NM_VPN_STATE_ACTIVATED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNConnected;
+ }
+ else if (nmType == NM_VPN_STATE_FAILED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNFailed;
+ }
+ else if (nmType == NM_VPN_STATE_DISCONNECTED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ }
+
+ return ret;
+}
+
TDENetworkConnectionStatus::TDENetworkConnectionStatus nmDeviceStateToTDEDeviceState(TQ_UINT32 nmType) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus ret = TDENetworkConnectionStatus::None;
@@ -1282,6 +1318,8 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQS
d->m_networkManagerProxy->setConnection(TQT_DBusConnection::systemBus());
d->m_networkManagerSettings = new DBus::SettingsInterface(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS);
d->m_networkManagerSettings->setConnection(TQT_DBusConnection::systemBus());
+ d->m_vpnProxy = new DBus::VPNPluginProxy(NM_VPN_DBUS_PLUGIN_SERVICE, NM_VPN_DBUS_PLUGIN_PATH);
+ d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus());
TQString dbusDeviceString = deviceInterfaceString(macAddress);
if (dbusDeviceString != "") {
@@ -1296,6 +1334,13 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQS
// Connect global signals
connect(d->m_networkManagerProxy, SIGNAL(StateChanged(TQ_UINT32)), d, SLOT(internalProcessGlobalStateChanged(TQ_UINT32)));
+ // Connect VPN signals
+ if (d->m_vpnProxy) {
+ connect(d->m_vpnProxy, SIGNAL(StateChanged(TQ_UINT32)), d, SLOT(internalProcessVPNStateChanged(TQ_UINT32)));
+ connect(d->m_vpnProxy, SIGNAL(LoginBanner(const TQString&)), d, SLOT(internalProcessVPNLoginBanner(const TQString&)));
+ connect(d->m_vpnProxy, SIGNAL(Failure(TQ_UINT32)), d, SLOT(internalProcessVPNFailure(TQ_UINT32)));
+ }
+
// Connect local signals
if (d->m_networkDeviceProxy) {
connect(d->m_networkDeviceProxy, SIGNAL(StateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)), d, SLOT(internalProcessDeviceStateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)));
@@ -1330,7 +1375,21 @@ TDENetworkConnectionManager_BackendNM::~TDENetworkConnectionManager_BackendNM()
}
void TDENetworkConnectionManager_BackendNMPrivate::internalProcessGlobalStateChanged(TQ_UINT32 state) {
- m_parent->internalNetworkConnectionStateChanged(nmGlobalStateToTDEGlobalState(state));
+ m_parent->internalNetworkConnectionStateChanged(m_parent->backendStatus());
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNStateChanged(TQ_UINT32 state) {
+ m_parent->internalNetworkConnectionStateChanged(m_parent->backendStatus());
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNLoginBanner(const TQString& banner) {
+ m_parent->internalVpnEvent(TDENetworkVPNEventType::LoginBanner, banner);
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNFailure(TQ_UINT32 reason) {
+ // FIXME
+ // This should provide a plain-text interpretation of the NetworkManager-specific error code
+ m_parent->internalVpnEvent(TDENetworkVPNEventType::Failure, TQString("%1").arg(reason));
}
void TDENetworkConnectionManager_BackendNMPrivate::internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason) {
@@ -1496,7 +1555,20 @@ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags TDENetworkConnectionM
return TDENetworkGlobalManagerFlags::BackendUnavailable;
}
else {
- return nmGlobalStateToTDEGlobalState(ret);
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags globalFlags = nmGlobalStateToTDEGlobalState(ret);
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags vpnFlags = TDENetworkGlobalManagerFlags::Unknown;
+ if (d->m_vpnProxy) {
+ ret = d->m_vpnProxy->getState(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ vpnFlags = TDENetworkGlobalManagerFlags::VPNUnknown;
+ }
+ else {
+ vpnFlags = nmVPNStateToTDEGlobalState(ret);
+ }
+ }
+ return globalFlags | vpnFlags;
}
}
else {
@@ -5032,7 +5104,7 @@ TQStringList TDENetworkConnectionManager_BackendNM::defaultNetworkDevices() {
}
}
-TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_parent(parent) {
+TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_vpnProxy(NULL), m_parent(parent) {
//
}
diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h
index 11f08c65a..5b475eea7 100644
--- a/tdecore/networkbackends/network-manager/network-manager.h
+++ b/tdecore/networkbackends/network-manager/network-manager.h
@@ -26,10 +26,12 @@
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection"
+#define NM_VPN_DBUS_PLUGIN_PATH "/org/freedesktop/NetworkManager/VPN/Plugin"
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
#define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings"
#define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection"
+#define NM_VPN_DBUS_PLUGIN_SERVICE "org.freedesktop.NetworkManager.VPN.Plugin"
//====================================================================================================
//====================================================================================================
@@ -72,6 +74,15 @@
#define NM_DEVICE_STATE_DEACTIVATING 110
#define NM_DEVICE_STATE_FAILED 120
//====================================================================================================
+#define NM_VPN_STATE_UNKNOWN 0
+#define NM_VPN_STATE_PREPARE 1
+#define NM_VPN_STATE_NEED_AUTH 2
+#define NM_VPN_STATE_CONNECT 3
+#define NM_VPN_STATE_IP_CONFIG_GET 4
+#define NM_VPN_STATE_ACTIVATED 5
+#define NM_VPN_STATE_FAILED 6
+#define NM_VPN_STATE_DISCONNECTED 7
+//====================================================================================================
#define NM_DEVICE_CAP_NONE 0
#define NM_DEVICE_CAP_NM_SUPPORTED 1
#define NM_DEVICE_CAP_CARRIER_DETECT 2
diff --git a/tdecore/networkbackends/network-manager/network-manager_p.h b/tdecore/networkbackends/network-manager/network-manager_p.h
index 758e7fe77..4ef3affe8 100644
--- a/tdecore/networkbackends/network-manager/network-manager_p.h
+++ b/tdecore/networkbackends/network-manager/network-manager_p.h
@@ -54,6 +54,7 @@
#include "olpcmeshproxy.h"
#include "activeconnectionproxy.h"
#include "accesspointproxy.h"
+#include "vpnpluginproxy.h"
typedef TQT_DBusDataMap<TQString> TQT_DBusTQStringDataMap;
typedef TQValueList<TQT_DBusData> TQT_DBusDataValueList;
@@ -79,6 +80,7 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
DBus::SettingsInterface* m_networkManagerSettings;
DBus::DeviceProxy* m_networkDeviceProxy;
DBus::WiFiDeviceProxy* m_wiFiDeviceProxy;
+ DBus::VPNPluginProxy* m_vpnProxy;
NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
@@ -89,6 +91,9 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&);
void internalProcessGlobalStateChanged(TQ_UINT32 state);
+ void internalProcessVPNStateChanged(TQ_UINT32 state);
+ void internalProcessVPNLoginBanner(const TQString& banner);
+ void internalProcessVPNFailure(TQ_UINT32 reason);
void internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason);
void internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&);
void internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&);