Add VPN status flags and signals

pull/16/head
Timothy Pearson 12 years ago
parent 8be09fcc83
commit 92fcdec6c3

@ -160,6 +160,42 @@ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nmGlobalStateToTDEGlo
return ret; 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 nmDeviceStateToTDEDeviceState(TQ_UINT32 nmType) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus ret = TDENetworkConnectionStatus::None; TDENetworkConnectionStatus::TDENetworkConnectionStatus ret = TDENetworkConnectionStatus::None;
@ -1282,6 +1318,8 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQS
d->m_networkManagerProxy->setConnection(TQT_DBusConnection::systemBus()); d->m_networkManagerProxy->setConnection(TQT_DBusConnection::systemBus());
d->m_networkManagerSettings = new DBus::SettingsInterface(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS); d->m_networkManagerSettings = new DBus::SettingsInterface(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS);
d->m_networkManagerSettings->setConnection(TQT_DBusConnection::systemBus()); 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); TQString dbusDeviceString = deviceInterfaceString(macAddress);
if (dbusDeviceString != "") { if (dbusDeviceString != "") {
@ -1296,6 +1334,13 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQS
// Connect global signals // Connect global signals
connect(d->m_networkManagerProxy, SIGNAL(StateChanged(TQ_UINT32)), d, SLOT(internalProcessGlobalStateChanged(TQ_UINT32))); 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 // Connect local signals
if (d->m_networkDeviceProxy) { 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))); 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) { 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) { void TDENetworkConnectionManager_BackendNMPrivate::internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason) {
@ -1496,7 +1555,20 @@ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags TDENetworkConnectionM
return TDENetworkGlobalManagerFlags::BackendUnavailable; return TDENetworkGlobalManagerFlags::BackendUnavailable;
} }
else { 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 { 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) {
// //
} }

@ -26,10 +26,12 @@
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager" #define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings" #define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection" #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_SERVICE "org.freedesktop.NetworkManager"
#define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings" #define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings"
#define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection" #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_DEACTIVATING 110
#define NM_DEVICE_STATE_FAILED 120 #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_NONE 0
#define NM_DEVICE_CAP_NM_SUPPORTED 1 #define NM_DEVICE_CAP_NM_SUPPORTED 1
#define NM_DEVICE_CAP_CARRIER_DETECT 2 #define NM_DEVICE_CAP_CARRIER_DETECT 2

@ -54,6 +54,7 @@
#include "olpcmeshproxy.h" #include "olpcmeshproxy.h"
#include "activeconnectionproxy.h" #include "activeconnectionproxy.h"
#include "accesspointproxy.h" #include "accesspointproxy.h"
#include "vpnpluginproxy.h"
typedef TQT_DBusDataMap<TQString> TQT_DBusTQStringDataMap; typedef TQT_DBusDataMap<TQString> TQT_DBusTQStringDataMap;
typedef TQValueList<TQT_DBusData> TQT_DBusDataValueList; typedef TQValueList<TQT_DBusData> TQT_DBusDataValueList;
@ -79,6 +80,7 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
DBus::SettingsInterface* m_networkManagerSettings; DBus::SettingsInterface* m_networkManagerSettings;
DBus::DeviceProxy* m_networkDeviceProxy; DBus::DeviceProxy* m_networkDeviceProxy;
DBus::WiFiDeviceProxy* m_wiFiDeviceProxy; DBus::WiFiDeviceProxy* m_wiFiDeviceProxy;
DBus::VPNPluginProxy* m_vpnProxy;
NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting; NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse; NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse; NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
@ -89,6 +91,9 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&); void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&);
void internalProcessGlobalStateChanged(TQ_UINT32 state); 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 internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason);
void internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&); void internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&);
void internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&); void internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&);

@ -839,6 +839,10 @@ void TDENetworkConnectionManager::internalNetworkDeviceEvent(TDENetworkDeviceEve
emit(networkDeviceEvent(event)); emit(networkDeviceEvent(event));
} }
void TDENetworkConnectionManager::internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message) {
emit(vpnEvent(event, message));
}
void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) { void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) {
emit(networkManagementEvent(event)); emit(networkManagementEvent(event));
} }
@ -853,6 +857,7 @@ TDEGlobalNetworkManager::TDEGlobalNetworkManager() : m_internalConnectionManager
#endif // WITH_NETWORK_MANAGER_BACKEND #endif // WITH_NETWORK_MANAGER_BACKEND
if (m_internalConnectionManager) { if (m_internalConnectionManager) {
connect(m_internalConnectionManager, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); 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))); connect(m_internalConnectionManager, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)), this, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)));
} }
} }

@ -201,6 +201,15 @@ namespace TDENetworkGlobalEventType {
}; };
}; };
namespace TDENetworkVPNEventType {
enum TDENetworkVPNEventType {
LoginBanner,
Failure,
Other,
Last = Other
};
};
namespace TDENetworkDeviceEventType { namespace TDENetworkDeviceEventType {
enum TDENetworkDeviceEventType { enum TDENetworkDeviceEventType {
BitRateChanged, BitRateChanged,
@ -231,7 +240,17 @@ namespace TDENetworkGlobalManagerFlags {
SiteLocalAccess = 0x00000020, SiteLocalAccess = 0x00000020,
GlobalAccess = 0x00000040, GlobalAccess = 0x00000040,
Sleeping = 0x00000080, 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) CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkGlobalManagerFlags)
@ -1170,6 +1189,13 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/ */
void networkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event); 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 * Emitted whenever a global network management event occurs
* The event type that caused the signal is available in @param event * The event type that caused the signal is available in @param event
@ -1271,6 +1297,12 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/ */
void internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event); 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 * @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 * It emits the appropriate signals to notify client applications of the state change
@ -1464,6 +1496,13 @@ class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject
*/ */
void accessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event); 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 * Emitted whenever a global network management event occurs
* The event type that caused the signal is available in @param event * The event type that caused the signal is available in @param event

Loading…
Cancel
Save