summaryrefslogtreecommitdiffstats
path: root/tdecore/networkbackends
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-08-27 11:31:08 -0500
committerTimothy Pearson <[email protected]>2012-08-27 11:31:08 -0500
commitcfbdd55bb39f6e2012103a506d8d2506145cc936 (patch)
tree98914c5e8f41cc7777aab4eec23f9344071dc7f8 /tdecore/networkbackends
parent2d67c1c6b2606b2c96831a44da73afe41fb8b6e1 (diff)
downloadtdelibs-cfbdd55bb39f6e2012103a506d8d2506145cc936.tar.gz
tdelibs-cfbdd55bb39f6e2012103a506d8d2506145cc936.zip
Add very preliminary network-manager backend support
Diffstat (limited to 'tdecore/networkbackends')
-rw-r--r--tdecore/networkbackends/network-manager/dbus/CMakeLists.txt7
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.cpp2482
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.h106
-rw-r--r--tdecore/networkbackends/network-manager/network-manager_p.h83
4 files changed, 2655 insertions, 23 deletions
diff --git a/tdecore/networkbackends/network-manager/dbus/CMakeLists.txt b/tdecore/networkbackends/network-manager/dbus/CMakeLists.txt
index e179dad3e..0739a85d8 100644
--- a/tdecore/networkbackends/network-manager/dbus/CMakeLists.txt
+++ b/tdecore/networkbackends/network-manager/dbus/CMakeLists.txt
@@ -46,14 +46,15 @@ add_dbus_xml( p accesspointproxy AccessPointProxy DBus nm-access-point.xml )
add_dbus_xml( p activeconnectionproxy ActiveConnectionProxy DBus nm-active-connection.xml )
add_dbus_xml( p vpnconnectionproxy VPNConnectionProxy DBus nm-vpn-connection.xml )
add_dbus_xml( p vpnpluginproxy VPNPluginProxy DBus nm-vpn-plugin.xml )
-add_dbus_xml( i networkmanagersettings SettingsInterface DBus nm-settings.xml )
-add_dbus_xml( i connectionsettings ConnectionSettingsInterface DBus nm-settings-connection.xml )
+add_dbus_xml( p networkmanagersettings SettingsInterface DBus nm-settings.xml )
+add_dbus_xml( p connectionsettings ConnectionSettingsInterface DBus nm-settings-connection.xml )
# generate moc files
set( MOCHEADERS accesspointproxy.h deviceproxy.h networkmanagerproxy.h networkmanagerpppproxy.h ethernetproxy.h
- infinibandproxy.h wifiproxy.h wimaxproxy.h activeconnectionproxy.h vpnconnectionproxy.h vpnpluginproxy.h modemproxy.h )
+ infinibandproxy.h wifiproxy.h wimaxproxy.h activeconnectionproxy.h vpnconnectionproxy.h vpnpluginproxy.h modemproxy.h
+ networkmanagersettings.h connectionsettings.h )
foreach( _header_file ${MOCHEADERS} )
get_filename_component( _basename "${_header_file}" NAME_WE )
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp
index fcd2f8abc..80225c1a7 100644
--- a/tdecore/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/networkbackends/network-manager/network-manager.cpp
@@ -17,57 +17,2505 @@
*/
#include "network-manager.h"
+#include "network-manager_p.h"
+
+#define PRINT_ERROR(x) printf("[TDE NM Backend ERROR] %s\n\r", x.ascii());
+#define UPDATE_STRING_SETTING_IF_VALID(string, key, settingsMap) if (!string.isNull()) settingsMap[key] = convertDBUSDataToVariantData(TQT_DBusData::fromString(string)); \
+ else settingsMap.remove(key);
+
+#define NM_ASYNC_TIMEOUT_MS 1000
+
+#define DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+TQ_UINT32 reverseIPV4ByteOrder(TQ_UINT32 address) {
+ TQ_UINT32 ret;
+ unsigned char valuearray[4];
+ valuearray[0] = (address & 0xff000000) >> 24;
+ valuearray[1] = (address & 0x00ff0000) >> 16;
+ valuearray[2] = (address & 0x0000ff00) >> 8;
+ valuearray[3] = (address & 0x000000ff) >> 0;
+ ret = 0;
+ ret = ret | (valuearray[0] << 0);
+ ret = ret | (valuearray[1] << 8);
+ ret = ret | (valuearray[2] << 16);
+ ret = ret | (valuearray[3] << 24);
+ return ret;
+}
+
+TQT_DBusData convertDBUSDataToVariantData(TQT_DBusData object) {
+ TQT_DBusVariant variant;
+ variant.value = object;
+ variant.signature = variant.value.buildDBusSignature();
+ return TQT_DBusData::fromVariant(variant);
+}
+
+void printDBUSObjectStructure(TQT_DBusData object, int level=0) {
+ int i;
+ TQString levelIndent = "";
+ for (i=0; i<level; i++) {
+ levelIndent = levelIndent + " ";
+ }
+ TQCString signature = object.buildDBusSignature();
+ printf("%s%s\n\r", levelIndent.ascii(), signature.data()); fflush(stdout);
+
+ if (object.type() == TQT_DBusData::Map) {
+ // HACK
+ // NetworkManager currently uses string key maps exclusively as far as I can tell, so this should be adequate for the time being
+ TQMap<TQString, TQT_DBusData> outerMap = object.toStringKeyMap().toTQMap();
+ TQMap<TQString, TQT_DBusData>::const_iterator it;
+ for (it = outerMap.begin(); it != outerMap.end(); ++it) {
+ printDBUSObjectStructure(*it, level+1);
+ }
+ }
+ if (object.type() == TQT_DBusData::List) {
+ TQT_DBusDataValueList valueList = object.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it;
+ for (it = valueList.begin(); it != valueList.end(); ++it) {
+ printDBUSObjectStructure(*it, level+1);
+ }
+ }
+ else if (object.type() == TQT_DBusData::Variant) {
+ TQT_DBusVariant dataValueVariant = object.toVariant();
+ TQT_DBusData dataValue = dataValueVariant.value;
+ printDBUSObjectStructure(dataValue, level+1);
+ }
+}
+
+TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nmGlobalStateToTDEGlobalState(TQ_UINT32 nmType) {
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags ret = TDENetworkGlobalManagerFlags::Unknown;
+
+ if (nmType == NM_STATE_UNKNOWN) {
+ ret |= TDENetworkGlobalManagerFlags::Unknown;
+ }
+ else if (nmType == NM_STATE_ASLEEP) {
+ ret |= TDENetworkGlobalManagerFlags::Disconnected;
+ ret |= TDENetworkGlobalManagerFlags::Sleeping;
+ }
+ else if (nmType == NM_STATE_DISCONNECTED) {
+ ret |= TDENetworkGlobalManagerFlags::Disconnected;
+ }
+ else if (nmType == NM_STATE_DISCONNECTING) {
+ ret |= TDENetworkGlobalManagerFlags::Connected;
+ ret |= TDENetworkGlobalManagerFlags::DeactivatingLink;
+ }
+ else if (nmType == NM_STATE_CONNECTING) {
+ ret |= TDENetworkGlobalManagerFlags::Disconnected;
+ ret |= TDENetworkGlobalManagerFlags::EstablishingLink;
+ }
+ else if (nmType == NM_STATE_CONNECTED_LOCAL) {
+ ret |= TDENetworkGlobalManagerFlags::Connected;
+ ret |= TDENetworkGlobalManagerFlags::LinkLocalAccess;
+ }
+ else if (nmType == NM_STATE_CONNECTED_SITE) {
+ ret |= TDENetworkGlobalManagerFlags::Connected;
+ ret |= TDENetworkGlobalManagerFlags::SiteLocalAccess;
+ }
+ else if (nmType == NM_STATE_CONNECTED_GLOBAL) {
+ ret |= TDENetworkGlobalManagerFlags::Connected;
+ ret |= TDENetworkGlobalManagerFlags::GlobalAccess;
+ }
+
+ return ret;
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus nmDeviceStateToTDEDeviceState(TQ_UINT32 nmType) {
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus ret = TDENetworkConnectionStatus::Invalid;
+
+ if (nmType == NM_DEVICE_STATE_UNKNOWN) {
+ ret |= TDENetworkConnectionStatus::Invalid;
+ }
+ else if (nmType == NM_DEVICE_STATE_UNMANAGED) {
+ ret |= TDENetworkConnectionStatus::UnManaged;
+ }
+ else if (nmType == NM_DEVICE_STATE_UNAVAILABLE) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::LinkUnavailable;
+ }
+ else if (nmType == NM_DEVICE_STATE_DISCONNECTED) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ }
+ else if (nmType == NM_DEVICE_STATE_PREPARE) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::EstablishingLink;
+ }
+ else if (nmType == NM_DEVICE_STATE_CONFIG) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::EstablishingLink;
+ }
+ else if (nmType == NM_DEVICE_STATE_NEED_AUTH) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::NeedAuthorization;
+ }
+ else if (nmType == NM_DEVICE_STATE_IP_CONFIG) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::ConfiguringProtocols;
+ }
+ else if (nmType == NM_DEVICE_STATE_IP_CHECK) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::VerifyingProtocols;
+ }
+ else if (nmType == NM_DEVICE_STATE_SECONDARIES) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::DependencyWait;
+ }
+ else if (nmType == NM_DEVICE_STATE_ACTIVATED) {
+ ret |= TDENetworkConnectionStatus::Connected;
+ }
+ else if (nmType == NM_DEVICE_STATE_DEACTIVATING) {
+ ret |= TDENetworkConnectionStatus::Connected;
+ ret |= TDENetworkConnectionStatus::DeactivatingLink;
+ }
+ else if (nmType == NM_DEVICE_STATE_FAILED) {
+ ret |= TDENetworkConnectionStatus::Disconnected;
+ ret |= TDENetworkConnectionStatus::Failed;
+ }
+
+ return ret;
+}
+
+TDENetworkConnectionType::TDENetworkConnectionType TDENetworkConnectionManager_BackendNM::nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType) {
+ TDENetworkConnectionType::TDENetworkConnectionType ret = TDENetworkConnectionType::Other;
+
+ if (nmType == NM_DEVICE_TYPE_UNKNOWN) {
+ ret = TDENetworkConnectionType::Other;
+ }
+ else if (nmType == NM_DEVICE_TYPE_ETHERNET) {
+ ret = TDENetworkConnectionType::WiredEthernet;
+ }
+ else if (nmType == NM_DEVICE_TYPE_WIFI) {
+ ret = TDENetworkConnectionType::WiFi;
+ }
+ else if (nmType == NM_DEVICE_TYPE_UNUSED1) {
+ }
+ else if (nmType == NM_DEVICE_TYPE_UNUSED2) {
+ }
+ else if (nmType == NM_DEVICE_TYPE_BT) {
+ ret = TDENetworkConnectionType::Bluetooth;
+ }
+ else if (nmType == NM_DEVICE_TYPE_OLPC_MESH) {
+ ret = TDENetworkConnectionType::OLPCMesh;
+ }
+ else if (nmType == NM_DEVICE_TYPE_WIMAX) {
+ ret = TDENetworkConnectionType::WiMax;
+ }
+ else if (nmType == NM_DEVICE_TYPE_MODEM) {
+ ret = TDENetworkConnectionType::Modem;
+ }
+ else if (nmType == NM_DEVICE_TYPE_INFINIBAND) {
+ ret = TDENetworkConnectionType::Infiniband;
+ }
+ else if (nmType == NM_DEVICE_TYPE_BOND) {
+ ret = TDENetworkConnectionType::Bond;
+ }
+ else if (nmType == NM_DEVICE_TYPE_VLAN) {
+ ret = TDENetworkConnectionType::VLAN;
+ }
+ else if (nmType == NM_DEVICE_TYPE_ADSL) {
+ ret = TDENetworkConnectionType::ADSL;
+ }
+
+ return ret;
+}
+
+TDENetworkIEEE8021xType::TDENetworkIEEE8021xType nmEAPTypeToTDEEAPType(TQString nm) {
+ TDENetworkIEEE8021xType::TDENetworkIEEE8021xType ret = TDENetworkIEEE8021xType::None;
+
+ if (nm.lower() == "") {
+ ret = TDENetworkIEEE8021xType::None;
+ }
+ else if (nm.lower() == "leap") {
+ ret = TDENetworkIEEE8021xType::LEAP;
+ }
+ else if (nm.lower() == "md5") {
+ ret = TDENetworkIEEE8021xType::MD5;
+ }
+ else if (nm.lower() == "pap") {
+ ret = TDENetworkIEEE8021xType::PAP;
+ }
+ else if (nm.lower() == "chap") {
+ ret = TDENetworkIEEE8021xType::CHAP;
+ }
+ else if (nm.lower() == "mschap") {
+ ret = TDENetworkIEEE8021xType::MSCHAP;
+ }
+ else if (nm.lower() == "mschapv2") {
+ ret = TDENetworkIEEE8021xType::MSCHAPV2;
+ }
+ else if (nm.lower() == "fast") {
+ ret = TDENetworkIEEE8021xType::Fast;
+ }
+ else if (nm.lower() == "psk") {
+ ret = TDENetworkIEEE8021xType::PSK;
+ }
+ else if (nm.lower() == "pax") {
+ ret = TDENetworkIEEE8021xType::PAX;
+ }
+ else if (nm.lower() == "sake") {
+ ret = TDENetworkIEEE8021xType::SAKE;
+ }
+ else if (nm.lower() == "gpsk") {
+ ret = TDENetworkIEEE8021xType::GPSK;
+ }
+ else if (nm.lower() == "tls") {
+ ret = TDENetworkIEEE8021xType::TLS;
+ }
+ else if (nm.lower() == "peap") {
+ ret = TDENetworkIEEE8021xType::PEAP;
+ }
+ else if (nm.lower() == "ttls") {
+ ret = TDENetworkIEEE8021xType::TTLS;
+ }
+ else if (nm.lower() == "sim") {
+ ret = TDENetworkIEEE8021xType::SIM;
+ }
+ else if (nm.lower() == "gtc") {
+ ret = TDENetworkIEEE8021xType::GTC;
+ }
+ else if (nm.lower() == "otp") {
+ ret = TDENetworkIEEE8021xType::OTP;
+ }
+ else {
+ PRINT_ERROR(TQString("unknown EAP type %s requested in existing connection").arg(nm.lower()))
+ }
+
+ return ret;
+}
+
+TQString tdeEAPTypeToNMEAPType(TDENetworkIEEE8021xType::TDENetworkIEEE8021xType eaptype) {
+ TQString ret = "";
+
+ if (eaptype == TDENetworkIEEE8021xType::None) {
+ ret = "";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::LEAP) {
+ ret = "leap";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::MD5) {
+ ret = "md5";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::PAP) {
+ ret = "pap";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::CHAP) {
+ ret = "chap";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::MSCHAP) {
+ ret = "mschap";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::MSCHAPV2) {
+ ret = "mschapv2";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::Fast) {
+ ret = "fast";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::PSK) {
+ ret = "psk";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::PAX) {
+ ret = "pax";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::SAKE) {
+ ret = "sake";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::GPSK) {
+ ret = "gpsk";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::TLS) {
+ ret = "tls";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::PEAP) {
+ ret = "peap";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::TTLS) {
+ ret = "ttls";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::SIM) {
+ ret = "sim";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::GTC) {
+ ret = "gtc";
+ }
+ else if (eaptype == TDENetworkIEEE8021xType::OTP) {
+ ret = "otp";
+ }
+ else {
+ PRINT_ERROR(TQString("unknown TDE EAP type %d requested in new or updated connection").arg(eaptype))
+ }
+
+ return ret;
+}
+
+TDENetworkIEEE8021xFastFlags::TDENetworkIEEE8021xFastFlags nmEAPFastFlagsToTDEEAPFastFlags(TQString nm) {
+ TDENetworkIEEE8021xFastFlags::TDENetworkIEEE8021xFastFlags ret = TDENetworkIEEE8021xFastFlags::AllowUnauthenticated | TDENetworkIEEE8021xFastFlags::AllowAuthenticated;
+
+ unsigned int nm_int = nm.toUInt();
+ if (nm_int == NM_EAP_FAST_PROVISIONING_DISABLED) {
+ ret = TDENetworkIEEE8021xFastFlags::None;
+ }
+ else if (nm_int == NM_EAP_FAST_PROVISIONING_UNAUTHONLY) {
+ ret = TDENetworkIEEE8021xFastFlags::AllowUnauthenticated;
+ }
+ else if (nm_int == NM_EAP_FAST_PROVISIONING_AUTHONLY) {
+ ret = TDENetworkIEEE8021xFastFlags::AllowAuthenticated;
+ }
+ else if (nm_int == NM_EAP_FAST_PROVISIONING_BOTH) {
+ ret = TDENetworkIEEE8021xFastFlags::AllowUnauthenticated | TDENetworkIEEE8021xFastFlags::AllowAuthenticated;
+ }
+ else {
+ PRINT_ERROR(TQString("unknown EAP fast flag %s requested in existing connection").arg(nm.lower()))
+ }
+
+ return ret;
+}
+
+TQString tdeEAPFastFlagsToNMEAPFastFlags(TDENetworkIEEE8021xFastFlags::TDENetworkIEEE8021xFastFlags eaptype) {
+ TQString ret = "";
+
+ if ((eaptype & TDENetworkIEEE8021xFastFlags::AllowUnauthenticated) && (eaptype & TDENetworkIEEE8021xFastFlags::AllowAuthenticated)) {
+ ret = TQString("%1").arg(NM_EAP_FAST_PROVISIONING_BOTH);
+ }
+ else if (eaptype & TDENetworkIEEE8021xFastFlags::AllowAuthenticated) {
+ ret = TQString("%1").arg(NM_EAP_FAST_PROVISIONING_AUTHONLY);
+ }
+ else if (eaptype & TDENetworkIEEE8021xFastFlags::AllowUnauthenticated) {
+ ret = TQString("%1").arg(NM_EAP_FAST_PROVISIONING_UNAUTHONLY);
+ }
+ else {
+ ret = TQString("%1").arg(NM_EAP_FAST_PROVISIONING_DISABLED);
+ }
+
+ return ret;
+}
+
+TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags nmPasswordFlagsToTDEPasswordFlags(unsigned int nm) {
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags ret = TDENetworkPasswordHandlingFlags::None;
+
+ if (nm & NM_PASSWORD_SECRET_AGENTOWNED) {
+ ret |= TDENetworkPasswordHandlingFlags::ExternalStorage;
+ }
+ if (nm & NM_PASSWORD_SECRET_NOTSAVED) {
+ ret |= TDENetworkPasswordHandlingFlags::NoSave;
+ }
+ if (nm & NM_PASSWORD_SECRET_NOTREQUIRED) {
+ ret |= TDENetworkPasswordHandlingFlags::NoPrompt;
+ }
+
+ return ret;
+}
+
+unsigned int tdePasswordFlagsToNMPasswordFlags(TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags flags) {
+ unsigned int ret = 0;
+
+ if (flags & TDENetworkPasswordHandlingFlags::ExternalStorage) {
+ ret |= NM_PASSWORD_SECRET_AGENTOWNED;
+ }
+ if (flags & TDENetworkPasswordHandlingFlags::NoSave) {
+ ret |= NM_PASSWORD_SECRET_NOTSAVED;
+ }
+ if (flags & TDENetworkPasswordHandlingFlags::NoPrompt) {
+ ret |= NM_PASSWORD_SECRET_NOTREQUIRED;
+ }
+
+ return ret;
+}
+
+TDENetworkDeviceCapabilityFlags::TDENetworkDeviceCapabilityFlags nmCapabilityFlagsToTDECapabilityFlags(unsigned int nm) {
+ TDENetworkDeviceCapabilityFlags::TDENetworkDeviceCapabilityFlags ret = TDENetworkDeviceCapabilityFlags::None;
+
+ if (nm & NM_DEVICE_CAP_NM_SUPPORTED) {
+ ret |= TDENetworkDeviceCapabilityFlags::Supported;
+ }
+ if (nm & NM_DEVICE_CAP_CARRIER_DETECT) {
+ ret |= TDENetworkDeviceCapabilityFlags::CanDetectLink;
+ }
+
+ return ret;
+}
+
+unsigned int tdeCapabilityFlagsToNMCapabilityFlags(TDENetworkDeviceCapabilityFlags::TDENetworkDeviceCapabilityFlags flags) {
+ unsigned int ret = 0;
+
+ if (flags & TDENetworkDeviceCapabilityFlags::Supported) {
+ ret |= NM_DEVICE_CAP_NM_SUPPORTED;
+ }
+ if (flags & TDENetworkDeviceCapabilityFlags::CanDetectLink) {
+ ret |= NM_DEVICE_CAP_CARRIER_DETECT;
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags nmAPSecFlagsToTDEAPSecFlags(unsigned int genflags, unsigned int nm) {
+ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags ret = TDENetworkWiFiAPFlags::None;
+
+ if (genflags & NM_ACCESS_POINT_CAP_PRIVACY) {
+ ret |= TDENetworkWiFiAPFlags::PrivacySupport;
+ }
+
+ if (nm & NM_ACCESS_POINT_SEC_PAIR_WEP40) {
+ ret |= TDENetworkWiFiAPFlags::PairWEP40;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_PAIR_WEP104) {
+ ret |= TDENetworkWiFiAPFlags::PairWEP104;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_PAIR_TKIP) {
+ ret |= TDENetworkWiFiAPFlags::PairTKIP;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_PAIR_CCMP) {
+ ret |= TDENetworkWiFiAPFlags::PairCCMP;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_GROUP_WEP40) {
+ ret |= TDENetworkWiFiAPFlags::GroupWEP40;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_GROUP_WEP104) {
+ ret |= TDENetworkWiFiAPFlags::GroupWEP104;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_GROUP_TKIP) {
+ ret |= TDENetworkWiFiAPFlags::GroupTKIP;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_GROUP_CCMP) {
+ ret |= TDENetworkWiFiAPFlags::GroupCCMP;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_KEY_MGMT_PSK) {
+ ret |= TDENetworkWiFiAPFlags::KeyManagementPSK;
+ }
+ if (nm & NM_ACCESS_POINT_SEC_KEY_MGMT_802_1X) {
+ ret |= TDENetworkWiFiAPFlags::KeyManagement80211;
+ }
+
+ return ret;
+}
+
+unsigned int tdeAPSecFlagsToNMAPGenSecFlags(TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags) {
+ unsigned int ret = 0;
+
+ if (flags & TDENetworkWiFiAPFlags::PrivacySupport) {
+ ret |= NM_ACCESS_POINT_CAP_PRIVACY;
+ }
+
+ return ret;
+}
+
+unsigned int tdeAPSecFlagsToNMAPSecFlags(TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags) {
+ unsigned int ret = 0;
+
+ if (flags & TDENetworkWiFiAPFlags::PairWEP40) {
+ ret |= NM_ACCESS_POINT_SEC_PAIR_WEP40;
+ }
+ if (flags & TDENetworkWiFiAPFlags::PairWEP104) {
+ ret |= NM_ACCESS_POINT_SEC_PAIR_WEP104;
+ }
+ if (flags & TDENetworkWiFiAPFlags::PairTKIP) {
+ ret |= NM_ACCESS_POINT_SEC_PAIR_TKIP;
+ }
+ if (flags & TDENetworkWiFiAPFlags::PairCCMP) {
+ ret |= NM_ACCESS_POINT_SEC_PAIR_CCMP;
+ }
+ if (flags & TDENetworkWiFiAPFlags::GroupWEP40) {
+ ret |= NM_ACCESS_POINT_SEC_GROUP_WEP40;
+ }
+ if (flags & TDENetworkWiFiAPFlags::GroupWEP104) {
+ ret |= NM_ACCESS_POINT_SEC_GROUP_WEP104;
+ }
+ if (flags & TDENetworkWiFiAPFlags::GroupTKIP) {
+ ret |= NM_ACCESS_POINT_SEC_GROUP_TKIP;
+ }
+ if (flags & TDENetworkWiFiAPFlags::GroupCCMP) {
+ ret |= NM_ACCESS_POINT_SEC_GROUP_CCMP;
+ }
+ if (flags & TDENetworkWiFiAPFlags::KeyManagementPSK) {
+ ret |= NM_ACCESS_POINT_SEC_KEY_MGMT_PSK;
+ }
+ if (flags & TDENetworkWiFiAPFlags::KeyManagement80211) {
+ ret |= NM_ACCESS_POINT_SEC_KEY_MGMT_802_1X;
+ }
+
+ return ret;
+}
+
+TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString macAddress) {
+ if (d->m_networkManagerProxy) {
+ TQT_DBusObjectPathList devices;
+ TQT_DBusError error;
+ bool ret;
+ ret = d->m_networkManagerProxy->GetDevices(devices, error);
+ if (ret) {
+ TQT_DBusObjectPathList::iterator it;
+ for (it = devices.begin(); it != devices.end(); ++it) {
+ DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, (*it));
+ genericDevice.setConnection(TQT_DBusConnection::systemBus());
+ TDENetworkConnectionType::TDENetworkConnectionType deviceType = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ break;
+ }
+ else if (deviceType == TDENetworkConnectionType::WiredEthernet) {
+ DBus::EthernetDeviceProxy ethernetDevice(NM_DBUS_SERVICE, (*it));
+ ethernetDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = ethernetDevice.getPermHwAddress(error);
+ if (!error.isValid()) {
+ if (candidateMACAddress.lower() == macAddress.lower()) {
+ return (*it);
+ }
+ }
+ }
+ else if (deviceType == TDENetworkConnectionType::WiFi) {
+ DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, (*it));
+ wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = wiFiDevice.getPermHwAddress(error);
+ if (!error.isValid()) {
+ if (candidateMACAddress.lower() == macAddress.lower()) {
+ return (*it);
+ }
+ }
+ }
+ // FIXME
+ // Add other supported device types here
+ }
+ return "";
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ return "";
+ }
+ }
+ else {
+ return "";
+ }
+}
TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQString macAddress) : TDENetworkConnectionManager(macAddress) {
- //
+ d = new TDENetworkConnectionManager_BackendNMPrivate();
+
+ // Set up proxy interfaces
+ d->m_networkManagerProxy = new DBus::NetworkManagerProxy(NM_DBUS_SERVICE, NM_DBUS_PATH);
+ 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());
+
+ TQString dbusDeviceString = deviceInterfaceString(macAddress);
+ if (dbusDeviceString != "") {
+ d->m_networkDeviceProxy = new DBus::DeviceProxy(NM_DBUS_SERVICE, dbusDeviceString);
+ d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
+ }
+
+ // Connect global signals
+ connect(d->m_networkManagerProxy, SIGNAL(StateChanged(TQ_UINT32)), this, SLOT(internalProcessGlobalStateChanged(TQ_UINT32)));
+
+ // Connect local signals
+ if (d->m_networkDeviceProxy) {
+ connect(d->m_networkDeviceProxy, SIGNAL(StateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)), this, SLOT(internalProcessDeviceStateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)));
+ }
+
+ // Create public lists
+ m_connectionList = new TDENetworkConnectionList;
+ m_hwNeighborList = new TDENetworkHWNeighborList;
}
TDENetworkConnectionManager_BackendNM::~TDENetworkConnectionManager_BackendNM() {
- //
+ // Destroy public lists
+ clearTDENetworkConnectionList();
+ delete m_connectionList;
+ clearTDENetworkHWNeighborList();
+ delete m_hwNeighborList;
+
+ // Tear down proxy interfaces
+ if (d->m_networkManagerProxy) delete d->m_networkManagerProxy;
+ if (d->m_networkManagerSettings) delete d->m_networkManagerSettings;
+ if (d->m_networkDeviceProxy) delete d->m_networkDeviceProxy;
+
+ delete d;
+}
+
+void TDENetworkConnectionManager_BackendNM::internalProcessGlobalStateChanged(TQ_UINT32 state) {
+ internalNetworkConnectionStateChanged(nmGlobalStateToTDEGlobalState(state));
+}
+
+void TDENetworkConnectionManager_BackendNM::internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason) {
+ Q_UNUSED(oldState)
+ Q_UNUSED(reason)
+ internalNetworkDeviceStateChanged(nmDeviceStateToTDEDeviceState(newState), m_macAddress);
}
TDENetworkConnectionType::TDENetworkConnectionType TDENetworkConnectionManager_BackendNM::connectionType() {
- //
+ if (m_macAddress == "") {
+ return TDENetworkConnectionType::BackendOnly;
+ }
+ else {
+ // Query NM for the device type
+ TQT_DBusError error;
+ TQString dbusDeviceString = deviceInterfaceString(m_macAddress);
+ DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, dbusDeviceString);
+ genericDevice.setConnection(TQT_DBusConnection::systemBus());
+ TDENetworkConnectionType::TDENetworkConnectionType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return TDENetworkConnectionType::Other;
+ }
+ else {
+ return ret;
+ }
+ }
}
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags TDENetworkConnectionManager_BackendNM::backendStatus() {
- //
+ if (d->m_networkManagerProxy) {
+ TQ_UINT32 ret;
+ TQT_DBusError error;
+ ret = d->m_networkManagerProxy->getState(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return TDENetworkGlobalManagerFlags::Unknown;
+ }
+ else {
+ return nmGlobalStateToTDEGlobalState(ret);
+ }
+ }
+ else {
+ return TDENetworkGlobalManagerFlags::Unknown;
+ }
}
TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceInformation() {
- //
+ TQT_DBusError error;
+ TDENetworkDeviceInformation ret;
+
+ if (d->m_networkDeviceProxy) {
+ ret.statusFlags = nmDeviceStateToTDEDeviceState(d->m_networkDeviceProxy->getState(error));
+ ret.UUID = d->m_networkDeviceProxy->getUdi(error);
+ ret.backendDriver = d->m_networkDeviceProxy->getDriver(error);
+ ret.backendDriverVersion = d->m_networkDeviceProxy->getDriverVersion(error);
+ ret.firmwareVersion = d->m_networkDeviceProxy->getFirmwareVersion(error);
+ ret.capabilityFlags = nmCapabilityFlagsToTDECapabilityFlags(d->m_networkDeviceProxy->getCapabilities(error));
+ // ipConfiguration is not filled in, as the TDE HW library provides complementary functionality and is more reliable/easier to use and maintain
+ ret.managed = d->m_networkDeviceProxy->getManaged(error);
+ ret.autoConnect = d->m_networkDeviceProxy->getAutoconnect(error);
+ ret.firmwareMissing = d->m_networkDeviceProxy->getFirmwareMissing(error);
+ ret.deviceType = nmDeviceTypeToTDEDeviceType(d->m_networkDeviceProxy->getDeviceType(error));
+ // FIXME wiFiInfo is not filled in
+ ret.valid = true;
+ }
+
+ return ret;
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::processConnectionSettingsAsyncReply(int asyncCallId, const TQT_DBusDataMap<TQString>& settings) {
+ nmConnectionSettingsAsyncCallWaiting[asyncCallId] = false;
+ nmConnectionSettingsAsyncSettingsResponse[asyncCallId] = settings;
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::processConnectionSettingsUpdateAsyncReply(int asyncCallId) {
+ nmConnectionSettingsAsyncCallWaiting[asyncCallId] = false;
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::processAddConnectionAsyncReply(int asyncCallId, const TQT_DBusObjectPath& path) {
+ nmConnectionSettingsAsyncCallWaiting[asyncCallId] = false;
+ nmAddConnectionAsyncResponse[asyncCallId] = path;
}
void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
- //
+ TDEMACAddress deviceMACAddress;
+ deviceMACAddress.fromString(m_macAddress);
+
+ if (d->m_networkManagerSettings) {
+ clearTDENetworkConnectionList();
+ TQT_DBusObjectPathList connections;
+ TQT_DBusError error;
+ bool ret;
+ int state;
+ ret = d->m_networkManagerSettings->ListConnections(connections, error);
+ if (ret) {
+ TQT_DBusObjectPathList::iterator it;
+ for (it = connections.begin(); it != connections.end(); ++it) {
+ TDENetworkConnection* connection;
+ TDEWiredEthernetConnection* ethernetConnection = NULL;
+ TDEWiFiConnection* wiFiConnection = NULL;
+ TDENetworkConnectionType::TDENetworkConnectionType connType = connectionType();
+ if (connType == TDENetworkConnectionType::WiredEthernet) {
+ connection = ethernetConnection = new TDEWiredEthernetConnection;
+ }
+ if (connType == TDENetworkConnectionType::WiFi) {
+ connection = wiFiConnection = new TDEWiFiConnection;
+ }
+ else {
+ connection = new TDENetworkConnection;
+ }
+ // Set up defaults
+ connection->ipConfig.connectionFlags = TDENetworkIPConfigurationFlags::IPV4DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s\n\r", (*it).data()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, (*it));
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ connect(&connectionSettings, SIGNAL(GetSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&)), d, SLOT(processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&)));
+ int asyncCallID;
+ ret = connectionSettings.GetSettingsAsync(asyncCallID, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ tqApp->processEvents();
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ }
+ TQT_DBusTQStringDataMap connectionSettingsMap = d->nmConnectionSettingsAsyncSettingsResponse[asyncCallID];
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] received DBUS object structure map follows:\n\r"); fflush(stdout);
+ printDBUSObjectStructure(TQT_DBusData::fromStringKeyMap(connectionSettingsMap));
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+ // Parse settings
+ TQT_DBusTQStringDataMap::const_iterator it2;
+ for (it2 = connectionSettingsMap.begin(); it2 != connectionSettingsMap.end(); ++it2) {
+ TQString outerKeyValue = it2.key();
+ TQT_DBusData dataValue = it2.data();
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] [%s]\n\r", outerKeyValue.ascii()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ TQT_DBusTQStringDataMap nestedConnectionSettingsMap = dataValue.toStringKeyMap();
+ TQT_DBusTQStringDataMap::const_iterator it3;
+ for (it3 = nestedConnectionSettingsMap.begin(); it3 != nestedConnectionSettingsMap.end(); ++it3) {
+ TQString keyValue = it3.key();
+ TQT_DBusData dataValue = it3.data();
+ if (dataValue.type() != TQT_DBusData::Variant) {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s = %s (type %d(%s))\n\r", keyValue.ascii(), dataValue.toString().ascii(), dataValue.type(), dataValue.typeName()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // No NM settings are known which use this style
+ }
+ else {
+ TQT_DBusVariant dataValueVariant = dataValue.toVariant();
+ TQT_DBusData dataValue2 = dataValueVariant.value;
+ if (dataValue2.type() != TQT_DBusData::Variant) {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s = %s (type %d(%s), signature %s)\n\r", keyValue.ascii(), dataValue2.toString().ascii(), dataValue2.type(), dataValue2.typeName(), dataValueVariant.signature.ascii()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // Most NM settings use this style
+ if (outerKeyValue.lower() == "connection") {
+ if (keyValue.lower() == "id") {
+ connection->friendlyName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "uuid") {
+ connection->UUID = dataValue2.toString().lower();
+ }
+ }
+ else if (outerKeyValue.lower() == "802-1x") {
+ // FIXME
+ // Implement load+save of the remaining settings in this group!
+ if (keyValue.lower() == "eap") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ state = 0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ if (state == 0) {
+ // EAP type
+ connection->eapConfig.type = nmEAPTypeToTDEEAPType(innerDataValue.toString());
+ }
+ state++;
+ }
+ }
+ else if (keyValue.lower() == "identity") {
+ connection->eapConfig.userName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "anonymous-identity") {
+ connection->eapConfig.anonymousUserName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "pac-file") {
+ connection->eapConfig.pacFileName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "ca-cert") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.caCertificate.resize(count+1);
+ connection->eapConfig.caCertificate[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "ca-path") {
+ connection->eapConfig.additionalCAFilesPath = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "subject-match") {
+ connection->eapConfig.authServerCertSubjectMatch = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "altsubject-matches") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ connection->eapConfig.alternateAuthServerCertSubjectMatch.append(innerDataValue.toString());
+ }
+ }
+ else if (keyValue.lower() == "client-cert") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.clientCertificate.resize(count+1);
+ connection->eapConfig.clientCertificate[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "phase1-peapver") {
+ connection->eapConfig.forcePEAPVersion = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "phase1-peaplabel") {
+ connection->eapConfig.forcePEAPLabel = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "phase1-fast-provisioning") {
+ connection->eapConfig.fastProvisioningFlags = nmEAPFastFlagsToTDEEAPFastFlags(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "phase2-auth") {
+ connection->eapConfig.phase2NonEAPAuthMethod = nmEAPTypeToTDEEAPType(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "phase2-autheap") {
+ connection->eapConfig.phase2EAPAuthMethod = nmEAPTypeToTDEEAPType(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "phase2-ca-cert") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.phase2CaCertificate.resize(count+1);
+ connection->eapConfig.phase2CaCertificate[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "phase2-ca-path") {
+ connection->eapConfig.phase2CaFilesPath = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "phase2-subject-match") {
+ connection->eapConfig.phase2AuthServerCertSubjectMatch = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "phase2-altsubject-matches") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ connection->eapConfig.phase2AlternateAuthServerCertSubjectMatch.append(innerDataValue.toString());
+ }
+ }
+ else if (keyValue.lower() == "phase2-client-cert") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.phase2ClientCertificate.resize(count+1);
+ connection->eapConfig.phase2ClientCertificate[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "password-flags") {
+ connection->eapConfig.passwordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "password-raw-flags") {
+ connection->eapConfig.binaryPasswordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "private-key") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.privateKey.resize(count+1);
+ connection->eapConfig.privateKey[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "private-key-password-flags") {
+ connection->eapConfig.privateKeyPasswordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "phase2-private-key") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.phase2PrivateKey.resize(count+1);
+ connection->eapConfig.phase2PrivateKey[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "phase2-private-key-password-flags") {
+ connection->eapConfig.phase2PrivateKeyPasswordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "system-ca-certs") {
+ connection->eapConfig.forceSystemCaCertificates = dataValue2.toBool();
+ }
+ connection->eapConfig.valid = true;
+ }
+ else if (outerKeyValue.lower() == "802-3-ethernet") {
+ if (keyValue.lower() == "duplex") {
+ connection->fullDuplex = (dataValue2.toString().lower() == "full")?true:false;
+ }
+ else if (keyValue.lower() == "mac-address") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ TDENetworkByteList macAddress;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ macAddress.append(innerDataValue.toByte());
+ }
+ connection->lockedHWAddress.setAddress(macAddress);
+ }
+ else if (keyValue.lower() == "cloned-mac-address") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ TDENetworkByteList macAddress;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ macAddress.append(innerDataValue.toByte());
+ }
+ connection->manualHWAddress.setAddress(macAddress);
+ }
+ else if (keyValue.lower() == "mtu") {
+ connection->mtu = dataValue2.toUInt32();
+ }
+ }
+ else if (outerKeyValue.lower() == "ipv4") {
+ if (keyValue.lower() == "addresses") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ state = 0;
+ TDENetworkSingleIPConfiguration ipConfig;
+ for (it5 = innerValueList.begin(); it5 != innerValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (state == 0) {
+ // Address
+ ipConfig.ipAddress = TQHostAddress(reverseIPV4ByteOrder(innerMostDataValue.toUInt32()));
+ }
+ else if (state == 1) {
+ // Network mask
+ ipConfig.networkMask.fromCIDRMask(innerMostDataValue.toUInt32());
+ }
+ else if (state == 2) {
+ // Gateway
+ ipConfig.gateway = TQHostAddress(reverseIPV4ByteOrder(innerMostDataValue.toUInt32()));
+ }
+ state++;
+ }
+ ipConfig.valid = true;
+ connection->ipConfig.ipConfigurations.append(ipConfig);
+ }
+ }
+ else if (keyValue.lower() == "dhcp-client-id") {
+ connection->ipConfig.dhcpClientIdentifier = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "dns") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ connection->ipConfig.resolvers.append(TQHostAddress(reverseIPV4ByteOrder(innerDataValue.toUInt32())));
+ }
+ }
+ else if (keyValue.lower() == "dns-search") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ connection->ipConfig.searchDomains.append(TDENetworkSearchDomain(innerDataValue.toString(), false));
+ }
+ }
+ else if (keyValue.lower() == "ignore-auto-dns") {
+ bool nm_static_dns = dataValue2.toBool();
+ if (nm_static_dns) {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4DHCPDNS;
+ }
+ else {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPDNS;
+ }
+ }
+ else if (keyValue.lower() == "may-fail") {
+ bool nm_may_fail = dataValue2.toBool();
+ connection->requireIPV4 = !nm_may_fail;
+ }
+ else if (keyValue.lower() == "method") {
+ TQString nm_method = dataValue2.toString().lower();
+ if (nm_method == "auto") {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPIP;
+ }
+ else if (nm_method == "manual") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4DHCPIP;
+ }
+ else if (nm_method == "link-local") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4LocalOnly;
+ }
+ else if (nm_method == "shared") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4StartConnectionSharingServer;
+ }
+ else if (nm_method == "disabled") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4Disabled;
+ }
+ }
+ else if (keyValue.lower() == "ignore-auto-routes") {
+ bool nm_static_routes = dataValue2.toBool();
+ if (nm_static_routes) {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4DHCPRoutes;
+ }
+ else {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPRoutes;
+ }
+ }
+ else if (keyValue.lower() == "never-default") {
+ bool nm_can_default_route = !dataValue2.toBool();
+ if (nm_can_default_route) {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute;
+ }
+ else {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute;
+ }
+ }
+ if (keyValue.lower() == "routes") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ state = 0;
+ TDENetworkSingleRouteConfiguration routeConfig;
+ for (it5 = innerValueList.begin(); it5 != innerValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (state == 0) {
+ // Address
+ routeConfig.ipAddress = TQHostAddress(reverseIPV4ByteOrder(innerMostDataValue.toUInt32()));
+ }
+ else if (state == 1) {
+ // Network mask
+ routeConfig.networkMask.fromCIDRMask(innerMostDataValue.toUInt32());
+ }
+ else if (state == 2) {
+ // Gateway
+ routeConfig.gateway = TQHostAddress(reverseIPV4ByteOrder(innerMostDataValue.toUInt32()));
+ }
+ else if (state == 3) {
+ // Metric
+ routeConfig.metric = innerMostDataValue.toUInt32();
+ }
+ state++;
+ }
+ routeConfig.valid = true;
+ connection->ipConfig.routeConfigurations.append(routeConfig);
+ }
+ }
+ }
+ else if (outerKeyValue.lower() == "ipv6") {
+ if (keyValue.lower() == "addresses") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toStruct();
+ TQT_DBusDataValueList::const_iterator it5;
+ TDENetworkSingleIPConfiguration ipConfig;
+ // Address
+ TQT_DBusDataValueList innerMostValueList;
+ innerMostValueList = innerValueList[0].toTQValueList();
+ TQ_UINT8 nm_v6address[16];
+ unsigned char nm_addr_ptr = 0;
+ memset(nm_v6address, 0, sizeof(TQ_UINT8)*16);
+ for (it5 = innerMostValueList.begin(); it5 != innerMostValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (nm_addr_ptr < 16) {
+ nm_v6address[nm_addr_ptr] = innerMostDataValue.toByte();
+ nm_addr_ptr++;
+ }
+ }
+ ipConfig.ipAddress = TQHostAddress(nm_v6address);
+
+ // Netmask
+ ipConfig.networkMask.fromCIDRMask(innerValueList[1].toUInt32(), true);
+
+ // Gateway
+ memset(nm_v6address, 0, sizeof(TQ_UINT8)*16);
+ for (it5 = innerMostValueList.begin(); it5 != innerMostValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (nm_addr_ptr < 16) {
+ nm_v6address[nm_addr_ptr] = innerMostDataValue.toByte();
+ nm_addr_ptr++;
+ }
+ }
+ ipConfig.gateway = TQHostAddress(nm_v6address);
+
+ ipConfig.valid = true;
+ connection->ipConfig.ipConfigurations.append(ipConfig);
+ }
+ }
+ else if (keyValue.lower() == "dns") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ TQ_UINT8 nm_v6address[16];
+ unsigned char nm_addr_ptr = 0;
+ memset(nm_v6address, 0, sizeof(TQ_UINT8)*16);
+ for (it5 = innerValueList.begin(); it5 != innerValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (nm_addr_ptr < 16) {
+ nm_v6address[nm_addr_ptr] = innerMostDataValue.toByte();
+ nm_addr_ptr++;
+ }
+ }
+ connection->ipConfig.resolvers.append(TQHostAddress(nm_v6address));
+ }
+ }
+ else if (keyValue.lower() == "dns-search") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it5;
+ connection->ipConfig.searchDomains.append(TDENetworkSearchDomain(innerDataValue.toString(), true));
+ }
+ }
+ else if (keyValue.lower() == "ignore-auto-dns") {
+ bool nm_static_dns = dataValue2.toBool();
+ if (nm_static_dns) {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV4DHCPDNS;
+ }
+ else {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPDNS;
+ }
+ }
+ else if (keyValue.lower() == "may-fail") {
+ bool nm_may_fail = dataValue2.toBool();
+ connection->requireIPV6 = !nm_may_fail;
+ }
+ else if (keyValue.lower() == "method") {
+ TQString nm_method = dataValue2.toString().lower();
+ if (nm_method == "auto") {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV6DHCPIP;
+ }
+ else if (nm_method == "manual") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6DHCPIP;
+ }
+ else if (nm_method == "link-local") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6LocalOnly;
+ }
+ else if (nm_method == "shared") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6StartConnectionSharingServer;
+ }
+ else if (nm_method == "ignore") {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6Disabled;
+ }
+ }
+ else if (keyValue.lower() == "ignore-auto-routes") {
+ bool nm_static_routes = dataValue2.toBool();
+ if (nm_static_routes) {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6DHCPRoutes;
+ }
+ else {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV6DHCPRoutes;
+ }
+ }
+ else if (keyValue.lower() == "never-default") {
+ bool nm_can_default_route = !dataValue2.toBool();
+ if (nm_can_default_route) {
+ connection->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
+ }
+ else {
+ connection->ipConfig.connectionFlags &= ~TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
+ }
+ }
+ if (keyValue.lower() == "routes") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQT_DBusDataValueList innerValueList = innerDataValue.toStruct();
+ TQT_DBusDataValueList::const_iterator it5;
+ TDENetworkSingleRouteConfiguration routeConfig;
+ // Address
+ TQT_DBusDataValueList innerMostValueList;
+ innerMostValueList = innerValueList[0].toTQValueList();
+ TQ_UINT8 nm_v6address[16];
+ unsigned char nm_addr_ptr = 0;
+ memset(nm_v6address, 0, sizeof(TQ_UINT8)*16);
+ for (it5 = innerMostValueList.begin(); it5 != innerMostValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (nm_addr_ptr < 16) {
+ nm_v6address[nm_addr_ptr] = innerMostDataValue.toByte();
+ nm_addr_ptr++;
+ }
+ }
+ routeConfig.ipAddress = TQHostAddress(nm_v6address);
+
+ // Netmask
+ routeConfig.networkMask.fromCIDRMask(innerValueList[1].toUInt32(), true);
+
+ // Gateway
+ innerMostValueList = innerValueList[2].toTQValueList();
+ nm_addr_ptr = 0;
+ memset(nm_v6address, 0, sizeof(TQ_UINT8)*16);
+ for (it5 = innerMostValueList.begin(); it5 != innerMostValueList.end(); ++it5) {
+ TQT_DBusData innerMostDataValue = *it5;
+ if (nm_addr_ptr < 16) {
+ nm_v6address[nm_addr_ptr] = innerMostDataValue.toByte();
+ nm_addr_ptr++;
+ }
+ }
+ routeConfig.gateway = TQHostAddress(nm_v6address);
+
+ // Metric
+ routeConfig.metric = innerValueList[3].toUInt32();
+
+ routeConfig.valid = true;
+ connection->ipConfig.routeConfigurations.append(routeConfig);
+ }
+ }
+ }
+ }
+ else {
+ // FIXME
+ // There are several advanced properties which appear to use string maps
+ // For example, s390-options
+ // Support should eventually be added for these, e.g. in a backend-specific Advanced tab somewhere
+ }
+ }
+ }
+ }
+
+ // If the connection's MAC matches my MAC, or if the connection is not locked to any MAC address,
+ // or if this manager object is not locked to a device, then add this connection to the list
+ if ((deviceMACAddress == connection->lockedHWAddress) || (!connection->lockedHWAddress.isValid()) || (!deviceMACAddress.isValid())) {
+ connection->ipConfig.valid = true;
+ m_connectionList->append(connection);
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ }
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ }
+ }
}
-bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection connection) {
- //
+// NOTE
+// While this separate separate routine is needed to get the secrets, note that secrets must
+// be saved using the same connection map save routine that all other settings use above.
+bool TDENetworkConnectionManager_BackendNM::loadConnectionSecrets(TQString uuid) {
+ bool ret = TRUE;
+ ret = ret && loadConnectionSecretsForGroup(uuid, "802-1x");
+ return ret;
}
-bool TDENetworkConnectionManager_BackendNM::deleteConnection(TQString uuid) {
- //
+bool TDENetworkConnectionManager_BackendNM::loadConnectionSecretsForGroup(TQString uuid, TQString group) {
+ TDENetworkConnection* connection = findConnectionByUUID(uuid);
+ if (!connection) {
+ PRINT_ERROR(TQString("Unable to locate connection with uuid '%1' in local database. Did you run loadConnectionInformation() first?"));
+ return FALSE;
+ }
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ TQT_DBusTQStringDataMap connectionSecretsMap(TQT_DBusData::String);
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
+ if (ret) {
+ // Obtain connection secrets from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ connect(&connectionSettings, SIGNAL(GetSecretsAsyncReply(int, const TQT_DBusDataMap<TQString>&)), d, SLOT(processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&)));
+ int asyncCallID;
+ ret = connectionSettings.GetSecretsAsync(asyncCallID, group, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ tqApp->processEvents();
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ }
+ connectionSecretsMap = d->nmConnectionSettingsAsyncSettingsResponse[asyncCallID];
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] received DBUS object structure map follows:\n\r"); fflush(stdout);
+ printDBUSObjectStructure(TQT_DBusData::fromStringKeyMap(connectionSecretsMap));
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+ // Parse settings
+ TQT_DBusTQStringDataMap::const_iterator it2;
+ for (it2 = connectionSecretsMap.begin(); it2 != connectionSecretsMap.end(); ++it2) {
+ TQString outerKeyValue = it2.key();
+ TQT_DBusData dataValue = it2.data();
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] [%s]\n\r", outerKeyValue.ascii()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ TQT_DBusTQStringDataMap nestedConnectionSettingsMap = dataValue.toStringKeyMap();
+ TQT_DBusTQStringDataMap::const_iterator it3;
+ for (it3 = nestedConnectionSettingsMap.begin(); it3 != nestedConnectionSettingsMap.end(); ++it3) {
+ TQString keyValue = it3.key();
+ TQT_DBusData dataValue = it3.data();
+ if (dataValue.type() != TQT_DBusData::Variant) {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s = %s (type %d(%s))\n\r", keyValue.ascii(), dataValue.toString().ascii(), dataValue.type(), dataValue.typeName()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // No NM settings are known which use this style
+ }
+ else {
+ TQT_DBusVariant dataValueVariant = dataValue.toVariant();
+ TQT_DBusData dataValue2 = dataValueVariant.value;
+ if (dataValue2.type() != TQT_DBusData::Variant) {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s = %s (type %d(%s), signature %s)\n\r", keyValue.ascii(), dataValue2.toString().ascii(), dataValue2.type(), dataValue2.typeName(), dataValueVariant.signature.ascii()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // Most NM settings use this style
+ if (outerKeyValue.lower() == "802-1x") {
+ if (keyValue.lower() == "password") {
+ connection->eapConfig.password = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "password-raw") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ int count=0;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ count++;
+ connection->eapConfig.binaryPassword.resize(count+1);
+ connection->eapConfig.binaryPassword[count] = innerDataValue.toByte();
+ }
+ }
+ else if (keyValue.lower() == "private-key-password") {
+ connection->eapConfig.privateKeyPassword = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "phase2-private-key-password") {
+ connection->eapConfig.phase2PrivateKeyPassword = dataValue2.toString();
+ }
+ connection->eapConfig.secretsValid = true;
+ }
+ }
+ }
+ }
+ }
+ return TRUE;
+ }
+ else {
+ PRINT_ERROR(TQString("Unable to load secrets for connection with uuid '%1'").arg(uuid))
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return FALSE;
+ }
}
-TDENetworkConnectionList* TDENetworkConnectionManager_BackendNM::connections() {
- //
+bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* connection) {
+ // Find path for connection with specified UUID, if it exists
+ // This is so that any settings that we are not aware of can be loaded now and preserved through the update operation
+ if (!connection) {
+ PRINT_ERROR(TQString("connection cannot be NULL!"));
+ return FALSE;
+ }
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ bool existing;
+ TQT_DBusTQStringDataMap connectionSettingsMap(TQT_DBusData::String);
+ existing = false;
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(connection->UUID, existingConnection, error);
+ if (ret) {
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ connect(&connectionSettings, SIGNAL(GetSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&)), d, SLOT(processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&)));
+ int asyncCallID;
+ ret = connectionSettings.GetSettingsAsync(asyncCallID, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ tqApp->processEvents();
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ }
+ connectionSettingsMap = d->nmConnectionSettingsAsyncSettingsResponse[asyncCallID];
+ existing = true;
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+ }
+ }
+
+ // Create and/or update settings map from provided connection information
+ // We start at the outermost layer and work our way inwards, in a structure which should match the parser in loadConnectionInformation() very closely
+ bool groupValid;
+ TQT_DBusData dbusData;
+ TQT_DBusData innerDbusData;
+ TQMap<TQString, TQT_DBusData> outerMap = connectionSettingsMap.toTQMap();
+ {
+ dbusData = outerMap["connection"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ settingsMap["id"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->friendlyName));
+ {
+ TQString type;
+ if (dynamic_cast<TDEWiredEthernetConnection*>(connection)) type = "802-3-ethernet";
+ else if (dynamic_cast<TDEWiFiConnection*>(connection)) type = "802-11-wireless";
+ if (!type.isNull()) settingsMap["type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(type));
+ }
+ settingsMap["uuid"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->UUID));
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("connection", dbusData, TRUE); else outerMap.remove("connection");
+
+ dbusData = outerMap["802-1x"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // EAP type
+ valueList.append(TQT_DBusData::fromString(tdeEAPTypeToNMEAPType(connection->eapConfig.type)));
+ }
+ settingsMap["eap"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ else {
+ settingsMap.remove("eap");
+ }
+ if (connection->eapConfig.valid) {
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.userName, "identity", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.anonymousUserName, "anonymous-identity", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.pacFileName, "pac-file", settingsMap)
+ }
+ else {
+ settingsMap.remove("identity");
+ settingsMap.remove("anonymous-identity");
+ settingsMap.remove("pac-file");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.caCertificate.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.caCertificate[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["ca-cert"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("ca-cert");
+ }
+ else {
+ settingsMap.remove("ca-cert");
+ }
+ if (connection->eapConfig.valid) {
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.additionalCAFilesPath, "ca-path", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.authServerCertSubjectMatch, "subject-match", settingsMap)
+ }
+ else {
+ settingsMap.remove("ca-path");
+ settingsMap.remove("subject-match");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ for (TQStringList::Iterator it = connection->eapConfig.alternateAuthServerCertSubjectMatch.begin(); it != connection->eapConfig.alternateAuthServerCertSubjectMatch.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(*it));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["altsubject-matches"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("altsubject-matches");
+ }
+ else {
+ settingsMap.remove("altsubject-matches");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.clientCertificate.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.clientCertificate[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["client-cert"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("client-cert");
+ }
+ else {
+ settingsMap.remove("client-cert");
+ }
+ if (connection->eapConfig.valid) {
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.forcePEAPVersion, "phase1-peapver", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.forcePEAPLabel, "phase1-peaplabel", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(tdeEAPFastFlagsToNMEAPFastFlags(connection->eapConfig.fastProvisioningFlags), "phase1-fast-provisioning", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.phase2NonEAPAuthMethod, "phase2-auth", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.phase2EAPAuthMethod, "phase2-autheap", settingsMap)
+ }
+ else {
+ settingsMap.remove("phase1-peapver");
+ settingsMap.remove("phase1-peaplabel");
+ settingsMap.remove("phase1-fast-provisioning");
+ settingsMap.remove("phase2-auth");
+ settingsMap.remove("phase2-autheap");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.phase2CaCertificate.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.phase2CaCertificate[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["phase2-ca-cert"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("phase2-ca-cert");
+ }
+ else {
+ settingsMap.remove("phase2-ca-cert");
+ }
+ if (connection->eapConfig.valid) {
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.phase2CaFilesPath, "phase2-ca-path", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->eapConfig.phase2AuthServerCertSubjectMatch, "phase2-subject-match", settingsMap)
+ }
+ else {
+ settingsMap.remove("phase2-ca-path");
+ settingsMap.remove("phase2-subject-match");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ for (TQStringList::Iterator it = connection->eapConfig.phase2AlternateAuthServerCertSubjectMatch.begin(); it != connection->eapConfig.phase2AlternateAuthServerCertSubjectMatch.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(*it));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["phase2-altsubject-matches"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("phase2-altsubject-matches");
+ }
+ else {
+ settingsMap.remove("phase2-altsubject-matches");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.phase2ClientCertificate.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.phase2ClientCertificate[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["phase2-client-cert"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("phase2-client-cert");
+ }
+ else {
+ settingsMap.remove("phase2-client-cert");
+ }
+ if (connection->eapConfig.valid) {
+ settingsMap["password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(connection->eapConfig.passwordFlags)));
+ settingsMap["password-raw-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(connection->eapConfig.binaryPasswordFlags)));
+ }
+ else {
+ settingsMap.remove("password-flags");
+ settingsMap.remove("password-raw-flags");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.privateKey.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.privateKey[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["private-key"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("private-key");
+ }
+ else {
+ settingsMap.remove("private-key");
+ }
+ if (connection->eapConfig.valid) {
+ settingsMap["private-key-password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(connection->eapConfig.privateKeyPasswordFlags)));
+ }
+ else {
+ settingsMap.remove("private-key-password-flags");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.phase2PrivateKey.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.phase2PrivateKey[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["phase2-private-key"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("phase2-private-key");
+ }
+ else {
+ settingsMap.remove("phase2-private-key");
+ }
+ if (connection->eapConfig.valid) {
+ settingsMap["phase2-private-key-password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(connection->eapConfig.phase2PrivateKeyPasswordFlags)));
+ }
+ else {
+ settingsMap.remove("phase2-private-key-password-flags");
+ }
+ if (connection->eapConfig.valid) {
+ settingsMap["system-ca-certs"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->eapConfig.forceSystemCaCertificates));
+ }
+ else {
+ settingsMap.remove("system-ca-certs");
+ }
+ if (connection->eapConfig.secretsValid) {
+ settingsMap["password"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->eapConfig.password));
+ }
+ else {
+ settingsMap.remove("password");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ {
+ unsigned int count;
+ for (count=0; count<connection->eapConfig.binaryPassword.count(); count++) {
+ valueList.append(TQT_DBusData::fromByte(connection->eapConfig.binaryPassword[count]));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["password-raw"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("password-raw");
+ }
+ else {
+ settingsMap.remove("password-raw");
+ }
+ if (connection->eapConfig.secretsValid) {
+ settingsMap["private-key-password"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->eapConfig.privateKeyPassword));
+ settingsMap["phase2-private-key-password"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->eapConfig.phase2PrivateKeyPassword));
+ }
+ else {
+ settingsMap.remove("private-key-password");
+ settingsMap.remove("phase2-private-key-password");
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("802-1x", dbusData, TRUE); else outerMap.remove("802-1x");
+
+ dbusData = outerMap["802-3-ethernet"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ settingsMap["duplex"] = convertDBUSDataToVariantData(TQT_DBusData::fromString((connection->fullDuplex)?"full":"half"));
+ if (connection->lockedHWAddress.isValid()) {
+ TDENetworkByteList address = connection->lockedHWAddress.address();
+ TQT_DBusDataValueList valueList;
+ TDENetworkByteList::iterator it;
+ for (it = address.begin(); it != address.end(); ++it) {
+ TQT_DBusData innerDataValue = TQT_DBusData::fromByte(*it);
+ valueList.append(innerDataValue);
+ }
+ TQT_DBusData nmHWAddress = TQT_DBusData::fromTQValueList(valueList);
+ settingsMap["mac-address"] = convertDBUSDataToVariantData(nmHWAddress);
+ }
+ else {
+ settingsMap.remove("mac-address");
+ }
+ if (connection->manualHWAddress.isValid()) {
+ TDENetworkByteList address = connection->manualHWAddress.address();
+ TQT_DBusDataValueList valueList;
+ TDENetworkByteList::iterator it;
+ for (it = address.begin(); it != address.end(); ++it) {
+ TQT_DBusData innerDataValue = TQT_DBusData::fromByte(*it);
+ valueList.append(innerDataValue);
+ }
+ TQT_DBusData nmHWAddress = TQT_DBusData::fromTQValueList(valueList);
+ settingsMap["cloned-mac-address"] = convertDBUSDataToVariantData(nmHWAddress);
+ }
+ else {
+ settingsMap.remove("mac-address");
+ }
+ if (connection->mtu > 0) {
+ settingsMap["mtu"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->mtu));
+ }
+ else {
+ settingsMap.remove("mtu");
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("802-3-ethernet", dbusData, TRUE); else outerMap.remove("802-3-ethernet");
+
+ dbusData = outerMap["ipv4"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ for (it = connection->ipConfig.ipConfigurations.begin(); it != connection->ipConfig.ipConfigurations.end(); ++it) {
+ if ((*it).isIPv4()) {
+ TQT_DBusDataValueList innerValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerValueList.append(TQT_DBusData::fromUInt32(reverseIPV4ByteOrder((*it).ipAddress.toIPv4Address())));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).networkMask.toCIDRMask()));
+ // Gateway
+ innerValueList.append(TQT_DBusData::fromUInt32(reverseIPV4ByteOrder((*it).gateway.toIPv4Address())));
+ valueList.append(TQT_DBusData::fromTQValueList(innerValueList));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ TQT_DBusData valueList;
+ valueList = TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::UInt32));
+ settingsMap["addresses"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(valueList)));
+ }
+ else {
+ settingsMap["addresses"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ {
+ if (!connection->ipConfig.dhcpClientIdentifier.isNull()) {
+ settingsMap["dhcp-client-id"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->ipConfig.dhcpClientIdentifier));
+ }
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkAddressList::iterator it;
+ for (it = connection->ipConfig.resolvers.begin(); it != connection->ipConfig.resolvers.end(); ++it) {
+ if ((*it).isIPv4Address()) {
+ valueList.append(TQT_DBusData::fromUInt32(reverseIPV4ByteOrder((*it).toIPv4Address())));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ settingsMap["dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::UInt32)));
+ }
+ else {
+ settingsMap["dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSearchDomainList::iterator it;
+ for (it = connection->ipConfig.searchDomains.begin(); it != connection->ipConfig.searchDomains.end(); ++it) {
+ if ((*it).isIPv4()) {
+ valueList.append(TQT_DBusData::fromString((*it).searchDomain()));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["dns-search"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ {
+ settingsMap["ignore-auto-dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPDNS)));
+ }
+ {
+ settingsMap["may-fail"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!connection->requireIPV4));
+ }
+ {
+ TQString method;
+ if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) {
+ method = "auto";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4LocalOnly) {
+ method = "link-local";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4StartConnectionSharingServer) {
+ method = "shared";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4Disabled) {
+ method = "disabled";
+ }
+ else {
+ method = "manual";
+ }
+ if (!method.isNull())
+ settingsMap["method"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(method));
+ }
+ {
+ settingsMap["ignore-auto-routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPRoutes)));
+ }
+ {
+ settingsMap["never-default"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute)));
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleRouteConfigurationList::iterator it;
+ for (it = connection->ipConfig.routeConfigurations.begin(); it != connection->ipConfig.routeConfigurations.end(); ++it) {
+ if ((*it).isIPv4()) {
+ TQT_DBusDataValueList innerValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerValueList.append(TQT_DBusData::fromUInt32(reverseIPV4ByteOrder((*it).ipAddress.toIPv4Address())));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).networkMask.toCIDRMask()));
+ // Gateway
+ innerValueList.append(TQT_DBusData::fromUInt32(reverseIPV4ByteOrder((*it).gateway.toIPv4Address())));
+ // Metric
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).metric));
+ valueList.append(TQT_DBusData::fromTQValueList(innerValueList));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ TQT_DBusData valueList;
+ valueList = TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::UInt32));
+ settingsMap["routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(valueList)));
+ }
+ else {
+ settingsMap["routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("ipv4", dbusData, TRUE); else outerMap.remove("ipv4");
+
+ dbusData = outerMap["ipv6"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleIPConfigurationList::iterator it;
+ for (it = connection->ipConfig.ipConfigurations.begin(); it != connection->ipConfig.ipConfigurations.end(); ++it) {
+ if ((*it).isIPv6()) {
+ int i;
+ Q_IPV6ADDR v6address;
+ TQT_DBusDataValueList innerValueList;
+ TQT_DBusDataValueList innerMostValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerMostValueList.clear();
+ v6address = (*it).ipAddress.toIPv6Address();
+ for (i=0; i<16; i++) {
+ innerMostValueList.append(TQT_DBusData::fromByte(v6address.c[i]));
+ }
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).networkMask.toCIDRMask()));
+ // Gateway
+ innerMostValueList.clear();
+ v6address = (*it).gateway.toIPv6Address();
+ for (i=0; i<16; i++) {
+ innerMostValueList.append(TQT_DBusData::fromByte(v6address.c[i]));
+ }
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ valueList.append(TQT_DBusData::fromStruct(innerValueList));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ TQT_DBusDataValueList innerValueList;
+ TQT_DBusDataValueList innerMostValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerMostValueList.clear();
+ innerMostValueList.append(TQT_DBusData::fromByte(0));
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32(0));
+ // Gateway
+ innerMostValueList.clear();
+ innerMostValueList.append(TQT_DBusData::fromByte(0));
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ settingsMap["addresses"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::fromStruct(innerValueList))));
+ }
+ else {
+ settingsMap["addresses"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkAddressList::iterator it;
+ for (it = connection->ipConfig.resolvers.begin(); it != connection->ipConfig.resolvers.end(); ++it) {
+ if ((*it).isIPv6Address()) {
+ int i;
+ Q_IPV6ADDR v6address;
+ TQT_DBusDataValueList innerValueList;
+ v6address = (*it).toIPv6Address();
+ for (i=0; i<16; i++) {
+ innerValueList.append(TQT_DBusData::fromByte(v6address.c[i]));
+ }
+ valueList.append(TQT_DBusData::fromTQValueList(innerValueList));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ TQT_DBusData valueList;
+ valueList = TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::Byte));
+ settingsMap["dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(valueList)));
+ }
+ else {
+ settingsMap["dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSearchDomainList::iterator it;
+ for (it = connection->ipConfig.searchDomains.begin(); it != connection->ipConfig.searchDomains.end(); ++it) {
+ if ((*it).isIPv6()) {
+ valueList.append(TQT_DBusData::fromString((*it).searchDomain()));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["dns-search"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ {
+ settingsMap["ignore-auto-dns"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPDNS)));
+ }
+ {
+ settingsMap["may-fail"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!connection->requireIPV6));
+ }
+ {
+ TQString method;
+ if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6DHCPIP) {
+ method = "auto";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6LocalOnly) {
+ method = "link-local";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6StartConnectionSharingServer) {
+ method = "shared";
+ }
+ else if (connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6Disabled) {
+ method = "ignore";
+ }
+ else {
+ method = "manual";
+ }
+ if (!method.isNull())
+ settingsMap["method"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(method));
+ }
+ {
+ settingsMap["ignore-auto-routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6DHCPRoutes)));
+ }
+ {
+ settingsMap["never-default"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute)));
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkSingleRouteConfigurationList::iterator it;
+ for (it = connection->ipConfig.routeConfigurations.begin(); it != connection->ipConfig.routeConfigurations.end(); ++it) {
+ if ((*it).isIPv6()) {
+ int i;
+ Q_IPV6ADDR v6address;
+ TQT_DBusDataValueList innerValueList;
+ TQT_DBusDataValueList innerMostValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerMostValueList.clear();
+ v6address = (*it).ipAddress.toIPv6Address();
+ for (i=0; i<16; i++) {
+ innerMostValueList.append(TQT_DBusData::fromByte(v6address.c[i]));
+ }
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).networkMask.toCIDRMask()));
+ // Gateway
+ innerMostValueList.clear();
+ v6address = (*it).gateway.toIPv6Address();
+ for (i=0; i<16; i++) {
+ innerMostValueList.append(TQT_DBusData::fromByte(v6address.c[i]));
+ }
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Metric
+ innerValueList.append(TQT_DBusData::fromUInt32((*it).metric));
+ valueList.append(TQT_DBusData::fromStruct(innerValueList));
+ }
+ }
+ if (valueList.count() <= 0) {
+ // Create an empty list with the correct DBUS type structure
+ TQT_DBusDataValueList innerValueList;
+ TQT_DBusDataValueList innerMostValueList;
+ // WARNING: The exact order of the data in the list is critical, therefore extreme caution should be exercised when modifying the code below!
+ // Address
+ innerMostValueList.clear();
+ innerMostValueList.append(TQT_DBusData::fromByte(0));
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Netmask
+ innerValueList.append(TQT_DBusData::fromUInt32(0));
+ // Gateway
+ innerMostValueList.clear();
+ innerMostValueList.append(TQT_DBusData::fromByte(0));
+ innerValueList.append(TQT_DBusData::fromTQValueList(innerMostValueList));
+ // Metric
+ innerValueList.append(TQT_DBusData::fromUInt32(0));
+ settingsMap["routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromList(TQT_DBusDataList(TQT_DBusData::fromStruct(innerValueList))));
+ }
+ else {
+ settingsMap["routes"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("ipv6", dbusData, TRUE); else outerMap.remove("ipv6");
+ }
+ connectionSettingsMap = TQT_DBusDataMap<TQString>(outerMap);
+
+ // If existing==true, a connection already existed and simply needs to be updated
+ // If existing==false, a new connection must be created
+ // To update: Use 'DBus::ConnectionSettingsInterface' with the connection path 'existingConnection' and call 'virtual bool UpdateAsync(int& asyncCallId, const TQT_DBusDataMap<TQString>& properties, TQT_DBusError& error);'
+ // To create new: Use 'd->m_networkManagerSettings' and call 'virtual bool AddConnectionAsync(int& asyncCallId, const TQT_DBusDataMap<TQString>& connection, TQT_DBusError& error);'
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] uploaded DBUS object structure map follows:\n\r"); fflush(stdout);
+ printDBUSObjectStructure(TQT_DBusData::fromStringKeyMap(connectionSettingsMap));
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+ if (existing) {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] Updating existing connection\n\r"); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // Save connection settings to the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ connect(&connectionSettings, SIGNAL(UpdateAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
+ int asyncCallID;
+ ret = connectionSettings.UpdateAsync(asyncCallID, connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ tqApp->processEvents();
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ return TRUE;
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ }
+ else {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] Creating new connection\n\r"); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ // Create new connection
+ connect(d->m_networkManagerSettings, SIGNAL(AddConnectionAsyncReply(int, const TQT_DBusObjectPath&)), d, SLOT(processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&)));
+ int asyncCallID;
+ ret = d->m_networkManagerSettings->AddConnectionAsync(asyncCallID, connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ tqApp->processEvents();
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ d->nmAddConnectionAsyncResponse.remove(asyncCallID);
+ return TRUE;
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::deleteConnection(TQString uuid) {
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ if (d->m_networkManagerSettings) {
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
+ if (ret) {
+ // Obtain connection secrets from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ connect(&connectionSettings, SIGNAL(DeleteAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
+ int asyncCallID;
+ ret = connectionSettings.DeleteAsync(asyncCallID, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ tqApp->processEvents();
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ return TRUE;
+ }
+ else {
+ PRINT_ERROR(TQString("Unable to remove connection with uuid '%1'").arg(uuid))
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object").arg(uuid));
+ return FALSE;
+ }
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManager_BackendNM::initiateConnection(TQString uuid) {
- //
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
+ if (ret) {
+ TQString dbusDeviceString;
+ if (m_macAddress == "") {
+ dbusDeviceString = "/";
+ }
+ else {
+ dbusDeviceString = deviceInterfaceString(m_macAddress);
+ }
+ connect(d->m_networkManagerProxy, SIGNAL(ActivateConnectionAsyncReply(int, const TQT_DBusObjectPath&)), d, SLOT(processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&)));
+ int asyncCallID;
+ ret = d->m_networkManagerProxy->ActivateConnectionAsync(asyncCallID, existingConnection, TQT_DBusObjectPath(dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ tqApp->processEvents();
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ d->nmAddConnectionAsyncResponse.remove(asyncCallID);
+ return checkConnectionStatus(uuid);
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ return checkConnectionStatus(uuid);
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManager_BackendNM::checkConnectionStatus(TQString uuid) {
- //
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ if (d->m_networkManagerProxy) {
+ TQT_DBusObjectPathList activeConnections = d->m_networkManagerProxy->getActiveConnections(error);
+ TQT_DBusObjectPathList::iterator it;
+ for (it = activeConnections.begin(); it != activeConnections.end(); ++it) {
+ DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, (*it));
+ activeConnection.setConnection(TQT_DBusConnection::systemBus());
+ if (activeConnection.getUuid(error) == uuid) {
+ return nmDeviceStateToTDEDeviceState(activeConnection.getState(error));
+ }
+ }
+ PRINT_ERROR(TQString("active connection for provided uuid '%1' was not found").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManager_BackendNM::deactivateConnection(TQString uuid) {
- //
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
+ if (ret) {
+ TQString dbusDeviceString;
+ if (m_macAddress == "") {
+ dbusDeviceString = "/";
+ }
+ else {
+ dbusDeviceString = deviceInterfaceString(m_macAddress);
+ }
+ connect(d->m_networkManagerProxy, SIGNAL(DeactivateConnectionAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
+ int asyncCallID;
+ ret = d->m_networkManagerProxy->DeactivateConnectionAsync(asyncCallID, existingConnection, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR(error.name())
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_TIMEOUT_MS, TRUE);
+ while (d->nmConnectionSettingsAsyncCallWaiting[asyncCallID]) {
+ if (!nmCallTimeoutTimer.isActive()) {
+ PRINT_ERROR(TQString("DBUS asynchronous call timed out!"))
+ break;
+ }
+ tqApp->processEvents();
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ return checkConnectionStatus(uuid);
+ }
+ else {
+ // Error!
+ PRINT_ERROR(error.name())
+ return checkConnectionStatus(uuid);
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object").arg(uuid));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+}
+
+TDENetworkWiFiAPInfo* TDENetworkConnectionManager_BackendNM::getAccessPointDetails(TQString dbusPath) {
+ TDENetworkWiFiAPInfo* apInfo = new TDENetworkWiFiAPInfo;
+ TQT_DBusError error;
+ unsigned int index;
+ DBus::AccessPointProxy accessPoint(NM_DBUS_SERVICE, dbusPath);
+ accessPoint.setConnection(TQT_DBusConnection::systemBus());
+
+ TQValueList<TQ_UINT8> nmSSID = accessPoint.getSsid(error);
+ if (error.isValid()) {
+ delete apInfo;
+ return NULL;
+ }
+ TQValueList<TQ_UINT8>::iterator it;
+ index = 0;
+ for (it = nmSSID.begin(); it != nmSSID.end(); ++it) {
+ apInfo->SSID.resize(index+1);
+ apInfo->SSID[index] = (*it);
+ index++;
+ }
+
+ apInfo->wpaFlags = nmAPSecFlagsToTDEAPSecFlags(accessPoint.getFlags(error), accessPoint.getWpaFlags(error));
+ apInfo->rsnFlags = nmAPSecFlagsToTDEAPSecFlags(accessPoint.getFlags(error), accessPoint.getRsnFlags(error));
+ apInfo->frequency = accessPoint.getFrequency(error);
+ apInfo->BSSID = accessPoint.getHwAddress(error);
+ apInfo->maxBitrate = accessPoint.getMaxBitrate(error);
+ apInfo->signalQuality = (accessPoint.getStrength(error)/100.0);
+
+ apInfo->valid = true;
+
+ return apInfo;
}
TDENetworkHWNeighborList* TDENetworkConnectionManager_BackendNM::siteSurvey() {
- //
+ // FIXME
+ // Implement this!
+ // WiFiDeviceProxy(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0);
+ // virtual bool GetAccessPoints(TQValueList<TQT_DBusObjectPath>& access_points, TQT_DBusError& error);
+ // deviceInterfaceString
+
+ TQT_DBusError error;
+ bool ret;
+
+ TDENetworkConnectionType::TDENetworkConnectionType deviceType = connectionType();
+ TQString dbusDeviceString = deviceInterfaceString(m_macAddress);
+ clearTDENetworkHWNeighborList();
+
+ if (deviceType == TDENetworkConnectionType::WiFi) {
+ DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, dbusDeviceString);
+ wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
+ // FIXME
+ // Should call wiFiDevice.RequestScanAsync first to rescan all access points
+ TQT_DBusObjectPathList accessPoints;
+ ret = wiFiDevice.GetAccessPoints(accessPoints, error);
+ if (ret) {
+ TQT_DBusObjectPathList::iterator it;
+ for (it = accessPoints.begin(); it != accessPoints.end(); ++it) {
+ TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(TQString(*it));
+ if (apInfo) {
+ m_hwNeighborList->append(apInfo);
+ }
+ }
+ }
+ }
+
+ return m_hwNeighborList;
+}
+
+bool TDENetworkConnectionManager_BackendNM::networkingEnabled() {
+ if (d->m_networkManagerProxy) {
+ bool ret;
+ TQT_DBusError error;
+ ret = d->m_networkManagerProxy->getNetworkingEnabled(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::wiFiHardwareEnabled() {
+ if (d->m_networkManagerProxy) {
+ bool ret;
+ TQT_DBusError error;
+ ret = d->m_networkManagerProxy->getWirelessHardwareEnabled(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::enableWiFi(bool enable) {
+ if (d->m_networkManagerProxy) {
+ TQT_DBusError error;
+ d->m_networkManagerProxy->setWirelessEnabled(enable, error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::wiFiEnabled() {
+ if (d->m_networkManagerProxy) {
+ bool ret;
+ TQT_DBusError error;
+ ret = d->m_networkManagerProxy->getWirelessEnabled(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR(error.name())
+ return FALSE;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ return FALSE;
+ }
}
-#include "network-manager.moc" \ No newline at end of file
+#include "network-manager.moc"
+#include "network-manager_p.moc" \ No newline at end of file
diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h
index 40dc725d4..f1fe36a8a 100644
--- a/tdecore/networkbackends/network-manager/network-manager.h
+++ b/tdecore/networkbackends/network-manager/network-manager.h
@@ -20,6 +20,90 @@
#include "tdenetworkconnections.h"
+//====================================================================================================
+// General NetworkManager DBUS service paths
+//====================================================================================================
+#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_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"
+//====================================================================================================
+
+//====================================================================================================
+// These defines MUST be kept in sync with their respective introspection XML files
+//====================================================================================================
+#define NM_DEVICE_TYPE_UNKNOWN 0
+#define NM_DEVICE_TYPE_ETHERNET 1
+#define NM_DEVICE_TYPE_WIFI 2
+#define NM_DEVICE_TYPE_UNUSED1 3
+#define NM_DEVICE_TYPE_UNUSED2 4
+#define NM_DEVICE_TYPE_BT 5
+#define NM_DEVICE_TYPE_OLPC_MESH 6
+#define NM_DEVICE_TYPE_WIMAX 7
+#define NM_DEVICE_TYPE_MODEM 8
+#define NM_DEVICE_TYPE_INFINIBAND 9
+#define NM_DEVICE_TYPE_BOND 10
+#define NM_DEVICE_TYPE_VLAN 11
+#define NM_DEVICE_TYPE_ADSL 12
+//====================================================================================================
+#define NM_STATE_UNKNOWN 0
+#define NM_STATE_ASLEEP 10
+#define NM_STATE_DISCONNECTED 20
+#define NM_STATE_DISCONNECTING 30
+#define NM_STATE_CONNECTING 40
+#define NM_STATE_CONNECTED_LOCAL 50
+#define NM_STATE_CONNECTED_SITE 60
+#define NM_STATE_CONNECTED_GLOBAL 70
+//====================================================================================================
+#define NM_DEVICE_STATE_UNKNOWN 0
+#define NM_DEVICE_STATE_UNMANAGED 10
+#define NM_DEVICE_STATE_UNAVAILABLE 20
+#define NM_DEVICE_STATE_DISCONNECTED 30
+#define NM_DEVICE_STATE_PREPARE 40
+#define NM_DEVICE_STATE_CONFIG 50
+#define NM_DEVICE_STATE_NEED_AUTH 60
+#define NM_DEVICE_STATE_IP_CONFIG 70
+#define NM_DEVICE_STATE_IP_CHECK 80
+#define NM_DEVICE_STATE_SECONDARIES 90
+#define NM_DEVICE_STATE_ACTIVATED 100
+#define NM_DEVICE_STATE_DEACTIVATING 110
+#define NM_DEVICE_STATE_FAILED 120
+//====================================================================================================
+#define NM_DEVICE_CAP_NONE 0
+#define NM_DEVICE_CAP_NM_SUPPORTED 1
+#define NM_DEVICE_CAP_CARRIER_DETECT 2
+//====================================================================================================
+#define NM_EAP_FAST_PROVISIONING_DISABLED 0
+#define NM_EAP_FAST_PROVISIONING_UNAUTHONLY 1
+#define NM_EAP_FAST_PROVISIONING_AUTHONLY 2
+#define NM_EAP_FAST_PROVISIONING_BOTH 3
+//====================================================================================================
+#define NM_PASSWORD_SECRET_NONE 0
+#define NM_PASSWORD_SECRET_AGENTOWNED 1
+#define NM_PASSWORD_SECRET_NOTSAVED 2
+#define NM_PASSWORD_SECRET_NOTREQUIRED 4
+//====================================================================================================
+#define NM_ACCESS_POINT_CAP_NONE 0x0
+#define NM_ACCESS_POINT_CAP_PRIVACY 0x1
+//====================================================================================================
+#define NM_ACCESS_POINT_SEC_NONE 0x0
+#define NM_ACCESS_POINT_SEC_PAIR_WEP40 0x1
+#define NM_ACCESS_POINT_SEC_PAIR_WEP104 0x2
+#define NM_ACCESS_POINT_SEC_PAIR_TKIP 0x4
+#define NM_ACCESS_POINT_SEC_PAIR_CCMP 0x8
+#define NM_ACCESS_POINT_SEC_GROUP_WEP40 0x10
+#define NM_ACCESS_POINT_SEC_GROUP_WEP104 0x20
+#define NM_ACCESS_POINT_SEC_GROUP_TKIP 0x40
+#define NM_ACCESS_POINT_SEC_GROUP_CCMP 0x80
+#define NM_ACCESS_POINT_SEC_KEY_MGMT_PSK 0x100
+#define NM_ACCESS_POINT_SEC_KEY_MGMT_802_1X 0x200
+//====================================================================================================
+
+class TDENetworkConnectionManager_BackendNMPrivate;
+
class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkConnectionManager
{
Q_OBJECT
@@ -33,16 +117,32 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
virtual TDENetworkDeviceInformation deviceInformation();
virtual void loadConnectionInformation();
- virtual bool saveConnection(TDENetworkConnection connection);
+ virtual bool loadConnectionSecrets(TQString uuid);
+ virtual bool saveConnection(TDENetworkConnection* connection);
virtual bool deleteConnection(TQString uuid);
- virtual TDENetworkConnectionList* connections();
-
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid);
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid);
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid);
virtual TDENetworkHWNeighborList* siteSurvey();
+
+ virtual bool networkingEnabled();
+ virtual bool wiFiHardwareEnabled();
+
+ virtual bool enableWiFi(bool enable);
+ virtual bool wiFiEnabled();
+
+ private:
+ void internalProcessGlobalStateChanged(TQ_UINT32 state);
+ void internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason);
+ TDENetworkConnectionType::TDENetworkConnectionType nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType);
+ TQString deviceInterfaceString(TQString macAddress);
+ bool loadConnectionSecretsForGroup(TQString uuid, TQString group);
+ TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath);
+
+ private:
+ TDENetworkConnectionManager_BackendNMPrivate* d;
};
#endif // _TDENETWORKBACKEND_NETWORKMANAGER_H \ No newline at end of file
diff --git a/tdecore/networkbackends/network-manager/network-manager_p.h b/tdecore/networkbackends/network-manager/network-manager_p.h
new file mode 100644
index 000000000..694e75984
--- /dev/null
+++ b/tdecore/networkbackends/network-manager/network-manager_p.h
@@ -0,0 +1,83 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDENETWORKBACKEND_NETWORKMANAGER_P_H
+#define _TDENETWORKBACKEND_NETWORKMANAGER_P_H
+
+/* TQt headers */
+#include <tqvaluelist.h>
+#include <tqapplication.h>
+#include <tqtimer.h>
+
+/* TDE headers */
+#include <kdebug.h>
+#include <klocale.h>
+
+/* TQDbus headers */
+#include <tqdbusconnection.h>
+#include <tqdbusobjectpath.h>
+#include <tqdbusdata.h>
+#include <tqdbuserror.h>
+#include <tqdbusdatamap.h>
+#include <tqdbusvariant.h>
+#include <tqdbusdatalist.h>
+
+/* NM headers */
+//#include <NetworkManager.h>
+
+/* Proxy headers */
+#include "networkmanagerproxy.h"
+#include "networkmanagersettings.h"
+#include "connectionsettings.h"
+#include "deviceproxy.h"
+#include "ethernetproxy.h"
+#include "wifiproxy.h"
+#include "activeconnectionproxy.h"
+#include "accesspointproxy.h"
+
+typedef TQT_DBusDataMap<TQString> TQT_DBusTQStringDataMap;
+typedef TQValueList<TQT_DBusData> TQT_DBusDataValueList;
+
+typedef TQMap<uint, bool> NMAsyncCallIDMap;
+typedef TQMap<uint, TQT_DBusTQStringDataMap> NMAsyncSettingsResponseMap;
+typedef TQMap<uint, TQT_DBusObjectPath> NMAddConnectionAsyncResponseMap;
+
+typedef TQValueList<TQT_DBusObjectPath> TQT_DBusObjectPathList;
+
+class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ TDENetworkConnectionManager_BackendNMPrivate() : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL) {}
+
+ public:
+ DBus::NetworkManagerProxy* m_networkManagerProxy;
+ DBus::SettingsInterface* m_networkManagerSettings;
+ DBus::DeviceProxy* m_networkDeviceProxy;
+ NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
+ NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
+ NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
+
+ public slots:
+ void processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&);
+ void processConnectionSettingsUpdateAsyncReply(int);
+ void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&);
+};
+
+#endif // _TDENETWORKBACKEND_NETWORKMANAGER_P_H \ No newline at end of file