summaryrefslogtreecommitdiffstats
path: root/tdecore
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
parent8be09fcc83077443fc3277dfa974d6aa02afc5bf (diff)
downloadtdelibs-92fcdec6c3fc085186c8d32d8dd8fa8641d7da33.tar.gz
tdelibs-92fcdec6c3fc085186c8d32d8dd8fa8641d7da33.zip
Add VPN status flags and signals
Diffstat (limited to 'tdecore')
-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
-rw-r--r--tdecore/tdenetworkconnections.cpp5
-rw-r--r--tdecore/tdenetworkconnections.h41
5 files changed, 136 insertions, 4 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&);
diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp
index dcccc64c0..14117d990 100644
--- a/tdecore/tdenetworkconnections.cpp
+++ b/tdecore/tdenetworkconnections.cpp
@@ -839,6 +839,10 @@ void TDENetworkConnectionManager::internalNetworkDeviceEvent(TDENetworkDeviceEve
emit(networkDeviceEvent(event));
}
+void TDENetworkConnectionManager::internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message) {
+ emit(vpnEvent(event, message));
+}
+
void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) {
emit(networkManagementEvent(event));
}
@@ -853,6 +857,7 @@ TDEGlobalNetworkManager::TDEGlobalNetworkManager() : m_internalConnectionManager
#endif // WITH_NETWORK_MANAGER_BACKEND
if (m_internalConnectionManager) {
connect(m_internalConnectionManager, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)));
+ connect(m_internalConnectionManager, SIGNAL(vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)), this, SIGNAL(vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)));
connect(m_internalConnectionManager, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)), this, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)));
}
}
diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h
index 2ba894732..7a05a003f 100644
--- a/tdecore/tdenetworkconnections.h
+++ b/tdecore/tdenetworkconnections.h
@@ -201,6 +201,15 @@ namespace TDENetworkGlobalEventType {
};
};
+namespace TDENetworkVPNEventType {
+ enum TDENetworkVPNEventType {
+ LoginBanner,
+ Failure,
+ Other,
+ Last = Other
+ };
+};
+
namespace TDENetworkDeviceEventType {
enum TDENetworkDeviceEventType {
BitRateChanged,
@@ -231,7 +240,17 @@ namespace TDENetworkGlobalManagerFlags {
SiteLocalAccess = 0x00000020,
GlobalAccess = 0x00000040,
Sleeping = 0x00000080,
- BackendUnavailable = 0x00000100
+ BackendUnavailable = 0x00000100,
+ VPNUnknown = 0x00000200,
+ VPNEstablishingLink = 0x00000400,
+ VPNNeedAuthorization = 0x00000800,
+ VPNConfiguringProtocols = 0x00001000,
+ VPNVerifyingProtocols = 0x00002000,
+ VPNConnected = 0x00004000,
+ VPNFailed = 0x00008000,
+ VPNDisconnected = 0x00010000,
+ GlobalMask = 0x000001ff,
+ VPNMask = 0x0001fe00
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkGlobalManagerFlags)
@@ -1171,6 +1190,13 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
void networkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event);
/**
+ * Emitted whenever a VPN-related event occurs
+ * The event type that caused the signal is available in @param event
+ * @param message contains additional information if available
+ */
+ void vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
* Emitted whenever a global network management event occurs
* The event type that caused the signal is available in @param event
*/
@@ -1272,6 +1298,12 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
void internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event);
/**
+ * @internal This method must be called by the network backend whenever a VPN event occurs
+ * It emits the appropriate signals to notify client applications of the network device event
+ */
+ void internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
* @internal This method must be called by the network backend whenever it changes state
* It emits the appropriate signals to notify client applications of the state change
*/
@@ -1465,6 +1497,13 @@ class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject
void accessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event);
/**
+ * Emitted whenever a VPN-related event occurs
+ * The event type that caused the signal is available in @param event
+ * @param message contains additional information if available
+ */
+ void vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
* Emitted whenever a global network management event occurs
* The event type that caused the signal is available in @param event
*/