summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.h.cmake3
-rw-r--r--tdecore/CMakeLists.txt11
-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
-rw-r--r--tdecore/tdehardwaredevices.cpp13
-rw-r--r--tdecore/tdenetworkconnections.cpp351
-rw-r--r--tdecore/tdenetworkconnections.h395
9 files changed, 3366 insertions, 85 deletions
diff --git a/config.h.cmake b/config.h.cmake
index 36e30793c..265b5afb9 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -831,6 +831,9 @@
/* Defined if compiling without arts */
#cmakedefine WITHOUT_ARTS 1
+/* Defined if compiling with the network-manager backend */
+#cmakedefine WITH_NETWORK_MANAGER_BACKEND 1
+
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt
index a684dc59c..2e00d6afa 100644
--- a/tdecore/CMakeLists.txt
+++ b/tdecore/CMakeLists.txt
@@ -22,7 +22,15 @@ endif( WITH_LIBART )
if( WITH_NETWORK_MANAGER_BACKEND )
add_subdirectory( networkbackends/network-manager/dbus )
- set ( TDENM_LIBRARIES tdenm_dbus-static )
+ set ( TDENM_INCLUDE_DIRECTORIES
+ ${DBUS_TQT_INCLUDE_DIRS}
+ ${NM_UTIL_INCLUDE_DIRS}
+ "${CMAKE_BINARY_DIR}/tdecore/networkbackends/network-manager/dbus"
+ )
+ set ( TDENM_LIBRARIES
+ tdenm_dbus-static
+ ${DBUS_TQT_LIBRARIES}
+ )
set ( TDENM_BACKEND_SOURCES networkbackends/network-manager/network-manager.cpp )
endif( WITH_NETWORK_MANAGER_BACKEND )
@@ -41,6 +49,7 @@ include_directories(
${LIBART_INCLUDE_DIRS}
${LIBIDN_INCLUDE_DIRS}
${GAMIN_INCLUDEDIR}
+ ${TDENM_INCLUDE_DIRECTORIES}
)
link_directories(
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 <kb9vqf@pearsoncomputing.net>
+
+ 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
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index ab3c06e91..293454457 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -16,8 +16,6 @@
Boston, MA 02110-1301, USA.
*/
-#define USE_NETWORKMANAGER_NETWORK_BACKEND
-
#include <tdehardwaredevices.h>
#include <tqfile.h>
@@ -61,9 +59,12 @@
// Network connection manager
#include "tdenetworkconnections.h"
-#ifdef USE_NETWORKMANAGER_NETWORK_BACKEND
+// Compile-time configuration
+#include "config.h"
+
+#ifdef WITH_NETWORK_MANAGER_BACKEND
#include "networkbackends/network-manager/network-manager.h"
-#endif // USE_NETWORKMANAGER_NETWORK_BACKEND
+#endif // WITH_NETWORK_MANAGER_BACKEND
// BEGIN BLOCK
// Copied from include/linux/genhd.h
@@ -1458,11 +1459,11 @@ void TDENetworkDevice::internalSetTxPackets(double tx) {
}
TDENetworkConnectionManager* TDENetworkDevice::connectionManager() {
-#ifdef USE_NETWORKMANAGER_NETWORK_BACKEND
+#ifdef WITH_NETWORK_MANAGER_BACKEND
if (!m_connectionManager) {
m_connectionManager = new TDENetworkConnectionManager_BackendNM(m_macAddress);
}
-#endif // USE_NETWORKMANAGER_NETWORK_BACKEND
+#endif // WITH_NETWORK_MANAGER_BACKEND
return m_connectionManager;
}
diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp
index e137457ed..0a3893f1f 100644
--- a/tdecore/tdenetworkconnections.cpp
+++ b/tdecore/tdenetworkconnections.cpp
@@ -19,13 +19,297 @@
#include "tdehardwaredevices.h"
#include "tdenetworkconnections.h"
+#define SET_BIT(x, y) (x |= 1 << y)
+#define TEST_BIT(x, y) ((x & (1 << y)) >> y)
+
+/*================================================================================================*/
+/* TDENetworkSearchDomain */
+/*================================================================================================*/
+
+TDENetworkSearchDomain::TDENetworkSearchDomain() {
+ m_isIPV6 = false;
+}
+
+TDENetworkSearchDomain::TDENetworkSearchDomain(TQString domain, bool ipv6) {
+ m_isIPV6 = ipv6;
+ m_domain = domain;
+}
+
+TDENetworkSearchDomain::~TDENetworkSearchDomain() {
+ //
+}
+
+TQString TDENetworkSearchDomain::searchDomain() {
+ return m_domain;
+}
+
+void TDENetworkSearchDomain::setSearchDomain(TQString domain, bool ipv6) {
+ m_isIPV6 = ipv6;
+ m_domain = domain;
+}
+
+bool TDENetworkSearchDomain::isIPv4() {
+ return !m_isIPV6;
+}
+
+bool TDENetworkSearchDomain::isIPv6() {
+ return m_isIPV6;
+}
+
+/*================================================================================================*/
+/* TDENetMask */
+/*================================================================================================*/
+
+TDENetMask::TDENetMask() {
+ m_ipv4NetMask = 0;
+ m_isIPV6 = false;
+}
+
+TDENetMask::TDENetMask(TQ_UINT32 netmask) {
+ m_ipv4NetMask = netmask;
+ m_isIPV6 = false;
+}
+
+TDENetMask::TDENetMask(TQ_UINT8* netmask) {
+ m_ipv6NetMask = TQHostAddress(netmask);
+ m_isIPV6 = true;
+}
+
+TDENetMask::~TDENetMask() {
+ //
+}
+
+void TDENetMask::fromCIDRMask(unsigned char mask, bool ipv6) {
+ unsigned int i;
+ unsigned int j;
+ if (!ipv6) {
+ m_ipv4NetMask = 0;
+ for (i=31;i>=(32-mask);i--) {
+ SET_BIT(m_ipv4NetMask, i);
+ }
+ m_isIPV6 = false;
+ }
+ else {
+ Q_IPV6ADDR maskarray;
+ j=0;
+ unsigned int byteno=0;
+ memset(maskarray.c, 0, 16);
+ for (i=127;i>=(128-mask);i--) {
+ SET_BIT(maskarray.c[byteno], (i-((15-byteno)*8)));
+ j++;
+ if (j>7) {
+ j=0;
+ byteno++;
+ }
+ }
+ m_ipv6NetMask = TQHostAddress(maskarray);
+ m_isIPV6 = true;
+ }
+}
+
+unsigned char TDENetMask::toCIDRMask() {
+ unsigned int i;
+ unsigned int j;
+ if (!m_isIPV6) {
+ for (i=0; i<32; i++) {
+ if (TEST_BIT(m_ipv4NetMask, i)) {
+ break;
+ }
+ }
+ return 32-i;
+ }
+ else {
+ Q_IPV6ADDR mask = m_ipv6NetMask.toIPv6Address();
+ bool found = false;
+ for (j=0; j<16; ++j) {
+ for (i=0; i<8; i++) {
+ if (!TEST_BIT(mask.c[j], i)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) break;
+ }
+ return ((j*8)+i);
+ }
+}
+
+void TDENetMask::fromString(TQString mask) {
+ if (mask.contains(".")) {
+ m_isIPV6 = false;
+ m_ipv4NetMask = 0;
+ TQStringList pieces = TQStringList::split(".", mask);
+ TQ_UINT8 chunk;
+ chunk = pieces[0].toUShort();
+ m_ipv4NetMask = m_ipv4NetMask | (chunk << 24);
+ chunk = pieces[1].toUShort();
+ m_ipv4NetMask = m_ipv4NetMask | (chunk << 16);
+ chunk = pieces[2].toUShort();
+ m_ipv4NetMask = m_ipv4NetMask | (chunk << 8);
+ chunk = pieces[3].toUShort();
+ m_ipv4NetMask = m_ipv4NetMask | (chunk << 0);
+ }
+ else if (mask.contains(":")) {
+ m_isIPV6 = true;
+ m_ipv6NetMask.setAddress(mask);
+ }
+}
+
+TQString TDENetMask::toString() {
+ if (!m_isIPV6) {
+ return TQString("%1.%2.%3.%4").arg((m_ipv4NetMask & 0xff000000) >> 24).arg((m_ipv4NetMask & 0x00ff0000) >> 16).arg((m_ipv4NetMask & 0x0000ff00) >> 8).arg((m_ipv4NetMask & 0x000000ff) >> 0);
+ }
+ else {
+ return m_ipv6NetMask.toString();
+ }
+}
+
+bool TDENetMask::isIPv4() {
+ return !m_isIPV6;
+}
+
+bool TDENetMask::isIPv6() {
+ return m_isIPV6;
+}
+
+/*================================================================================================*/
+/* TDEMACAddress */
+/*================================================================================================*/
+
+TDEMACAddress::TDEMACAddress() {
+ m_macAddress.clear();
+ m_isValid = false;
+}
+
+TDEMACAddress::TDEMACAddress(TDENetworkByteList address) {
+ m_macAddress = address;
+ m_isValid = true;
+}
+
+TDEMACAddress::~TDEMACAddress() {
+ //
+}
+
+TDENetworkByteList TDEMACAddress::address() {
+ return m_macAddress;
+}
+
+void TDEMACAddress::setAddress(TDENetworkByteList address) {
+ m_macAddress = address;
+ m_isValid = true;
+}
+
+bool TDEMACAddress::isValid() {
+ return m_isValid;
+}
+
+void TDEMACAddress::fromString(TQString address) {
+ TQStringList pieces = TQStringList::split(":", address);
+ m_macAddress.clear();
+ for (TQStringList::Iterator it = pieces.begin(); it != pieces.end(); ++it) {
+ m_macAddress.append((*it).toUShort(0, 16));
+ }
+ m_isValid = true;
+}
+
+TQString TDEMACAddress::toString() {
+ TQString ret;
+ TDENetworkByteList::iterator it;
+ for (it = m_macAddress.begin(); it != m_macAddress.end(); ++it) {
+ if (ret != "") {
+ ret.append(":");
+ }
+ ret.append(TQString().sprintf("%02x", *it));
+ }
+ return ret.lower();
+}
+
+bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2) {
+ if (a1.m_macAddress.count() != a2.m_macAddress.count()) {
+ return false;
+ }
+ else {
+ unsigned int i;
+ for (i=0; i<a1.m_macAddress.count(); i++) {
+ if (a1.m_macAddress[i] != a2.m_macAddress[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
+
+/*================================================================================================*/
+/* TDENetworkSingleIPConfiguration */
+/*================================================================================================*/
+
+TDENetworkSingleIPConfiguration::TDENetworkSingleIPConfiguration() {
+ valid = false;
+}
+
+TDENetworkSingleIPConfiguration::~TDENetworkSingleIPConfiguration() {
+ //
+}
+
+bool TDENetworkSingleIPConfiguration::isIPv4() {
+ return ipAddress.isIPv4Address() & valid;
+}
+
+bool TDENetworkSingleIPConfiguration::isIPv6() {
+ return ipAddress.isIPv6Address() & valid;
+}
+
+/*================================================================================================*/
+/* TDENetworkSingleRouteConfiguration */
+/*================================================================================================*/
+
+TDENetworkSingleRouteConfiguration::TDENetworkSingleRouteConfiguration() {
+ valid = false;
+}
+
+TDENetworkSingleRouteConfiguration::~TDENetworkSingleRouteConfiguration() {
+ //
+}
+
+bool TDENetworkSingleRouteConfiguration::isIPv4() {
+ return ipAddress.isIPv4Address() & valid;
+}
+
+bool TDENetworkSingleRouteConfiguration::isIPv6() {
+ return ipAddress.isIPv6Address() & valid;
+}
+
+/*================================================================================================*/
+/* TDENetworkIEEE8021xConfiguration */
+/*================================================================================================*/
+
+TDENetworkIEEE8021xConfiguration::TDENetworkIEEE8021xConfiguration() {
+ valid = false;
+ secretsValid = false;
+ fastProvisioningFlags = TDENetworkIEEE8021xFastFlags::None;
+ passwordFlags = TDENetworkPasswordHandlingFlags::None;
+ binaryPasswordFlags = TDENetworkPasswordHandlingFlags::None;
+ forceSystemCaCertificates = false;
+}
+
+TDENetworkIEEE8021xConfiguration::~TDENetworkIEEE8021xConfiguration() {
+ //
+}
+
/*================================================================================================*/
/* TDENetworkIPConfiguration */
/*================================================================================================*/
TDENetworkIPConfiguration::TDENetworkIPConfiguration() {
valid = false;
- connectionFlags = TDENetworkIPConfigurationFlags::Invalid;
+ connectionFlags = TDENetworkIPConfigurationFlags::IPV4DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
}
TDENetworkIPConfiguration::~TDENetworkIPConfiguration() {
@@ -86,8 +370,12 @@ TDENetworkWiFiAPInfo::~TDENetworkWiFiAPInfo() {
/* TDENetworkConnection */
/*================================================================================================*/
-TDENetworkConnection::TDENetworkConnection() : TQObject() {
- //
+TDENetworkConnection::TDENetworkConnection() {
+ autoConnect = false;
+ fullDuplex = true;
+ requireIPV4 = false;
+ requireIPV6 = false;
+ mtu = 0;
}
TDENetworkConnection::~TDENetworkConnection() {
@@ -95,6 +383,18 @@ TDENetworkConnection::~TDENetworkConnection() {
}
/*================================================================================================*/
+/* TDEWiredEthernetConnection */
+/*================================================================================================*/
+
+TDEWiredEthernetConnection::TDEWiredEthernetConnection() : TDENetworkConnection() {
+ //
+}
+
+TDEWiredEthernetConnection::~TDEWiredEthernetConnection() {
+ //
+}
+
+/*================================================================================================*/
/* TDEWiFiConnection */
/*================================================================================================*/
@@ -110,7 +410,7 @@ TDEWiFiConnection::~TDEWiFiConnection() {
/* TDENetworkConnectionManager */
/*================================================================================================*/
-TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_macAddress(macAddress) {
+TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_hwNeighborList(NULL), m_macAddress(macAddress), m_prevConnectionStatus(TDENetworkGlobalManagerFlags::Unknown) {
//
}
@@ -122,6 +422,49 @@ TQString TDENetworkConnectionManager::deviceMACAddress() {
return m_macAddress;
}
+TDENetworkConnectionList* TDENetworkConnectionManager::connections() {
+ return m_connectionList;
+}
+
+TDENetworkConnection* TDENetworkConnectionManager::findConnectionByUUID(TQString uuid) {
+ TDENetworkConnection *connection;
+ for (connection = m_connectionList->first(); connection; connection = m_connectionList->next()) {
+ if (connection->UUID == uuid) {
+ return connection;
+ }
+ }
+ return NULL;
+}
+
+void TDENetworkConnectionManager::clearTDENetworkConnectionList() {
+ TDENetworkConnection *connection;
+ for (connection = m_connectionList->first(); connection; connection = m_connectionList->next()) {
+ delete connection;
+ }
+ m_connectionList->clear();
+}
+
+void TDENetworkConnectionManager::clearTDENetworkHWNeighborList() {
+ TDENetworkHWNeighbor *neighbor;
+ for (neighbor = m_hwNeighborList->first(); neighbor; neighbor = m_hwNeighborList->next()) {
+ delete neighbor;
+ }
+ m_hwNeighborList->clear();
+}
+
+void TDENetworkConnectionManager::internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState) {
+ emit(networkConnectionStateChanged(m_prevConnectionStatus, newState));
+ m_prevConnectionStatus = newState;
+}
+
+void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress) {
+ if (!m_prevDeviceStatus.contains("hwAddress")) {
+ m_prevDeviceStatus[hwAddress] = TDENetworkConnectionStatus::Invalid;
+ }
+ emit(networkDeviceStateChanged(m_prevDeviceStatus[hwAddress], newState, hwAddress));
+ m_prevDeviceStatus[hwAddress] = newState;
+}
+
/*================================================================================================*/
/* End */
/*================================================================================================*/
diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h
index 05c4bb591..bec8d3201 100644
--- a/tdecore/tdenetworkconnections.h
+++ b/tdecore/tdenetworkconnections.h
@@ -23,6 +23,7 @@
#include <tqstring.h>
#include <tqptrlist.h>
#include <tqstringlist.h>
+#include <tqhostaddress.h>
#include "kiconloader.h"
#include "tdelibs_export.h"
@@ -40,10 +41,26 @@
inline x operator~(x a) \
{ \
return static_cast<x>(~static_cast<int>(a)); \
+ } \
+ \
+ inline x &operator|=(x& a, const x& b) \
+ { \
+ a = static_cast<x>(static_cast<int>(a) | static_cast<int>(b)); \
+ return a; \
+ } \
+ \
+ inline x &operator&=(x& a, const x& b) \
+ { \
+ a = static_cast<x>(static_cast<int>(a) & static_cast<int>(b)); \
+ return a; \
}
+typedef TQValueList<TQ_UINT8> TDENetworkByteList;
+typedef TQValueList<TQHostAddress> TDENetworkAddressList;
+
namespace TDENetworkConnectionType {
enum TDENetworkConnectionType {
+ BackendOnly,
WiredEthernet,
WiFi,
Bluetooth,
@@ -139,6 +156,50 @@ namespace TDENetworkWiFiConnectionCipher {
};
};
+namespace TDENetworkIEEE8021xType {
+ enum TDENetworkIEEE8021xType {
+ None,
+ LEAP,
+ MD5,
+ PAP,
+ CHAP,
+ MSCHAP,
+ MSCHAPV2,
+ Fast,
+ PSK,
+ PAX,
+ SAKE,
+ GPSK,
+ TLS,
+ PEAP,
+ TTLS,
+ SIM,
+ GTC,
+ OTP
+ };
+};
+
+namespace TDENetworkIEEE8021xFastFlags {
+ enum TDENetworkIEEE8021xFastFlags {
+ None = 0x00000000,
+ AllowUnauthenticated = 0x00000001,
+ AllowAuthenticated = 0x00000002
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkIEEE8021xFastFlags)
+};
+
+namespace TDENetworkPasswordHandlingFlags {
+ enum TDENetworkPasswordHandlingFlags {
+ None = 0x00000000,
+ NoSave = 0x00000001,
+ NoPrompt = 0x00000002,
+ ExternalStorage = 0x00000004
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkPasswordHandlingFlags)
+};
+
namespace TDENetworkConnectionStatus {
enum TDENetworkConnectionStatus {
Invalid = 0x00000000,
@@ -146,17 +207,18 @@ namespace TDENetworkConnectionStatus {
Connected = 0x00000002,
LinkUnavailable = 0x00000004,
EstablishingLink = 0x00000008,
- ConfiguringProtocols = 0x00000010,
- Reconnecting = 0x00000020,
- LinkLost = 0x00000040,
- LinkLocalAccess = 0x00000080,
- SiteLocalAccess = 0x00000100,
- GlobalAccess = 0x00000200,
- UnManaged = 0x00000400,
- NeedAuthorization = 0x00000800,
- Failed = 0x00001000,
- VerifyingProtocols = 0x00002000,
- DependencyWait = 0x00004000
+ DeactivatingLink = 0x00000010,
+ ConfiguringProtocols = 0x00000020,
+ Reconnecting = 0x00000040,
+ LinkLost = 0x00000080,
+ LinkLocalAccess = 0x00000100,
+ SiteLocalAccess = 0x00000200,
+ GlobalAccess = 0x00000400,
+ UnManaged = 0x00000800,
+ NeedAuthorization = 0x00001000,
+ Failed = 0x00002000,
+ VerifyingProtocols = 0x00004000,
+ DependencyWait = 0x00008000
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkConnectionStatus)
@@ -164,16 +226,168 @@ namespace TDENetworkConnectionStatus {
namespace TDENetworkIPConfigurationFlags {
enum TDENetworkIPConfigurationFlags {
- Invalid = 0x00000000,
- IPV4 = 0x00000001,
- IPV6 = 0x00000002,
- DHCP = 0x00000004,
- StaticIP = 0x00000008
+ None = 0x00000000,
+ IPV4DHCPIP = 0x00000001,
+ IPV4DHCPDNS = 0x00000002,
+ IPV4DHCPRoutes = 0x00000004,
+ IPV4LocalOnly = 0x00000008,
+ IPV4StartConnectionSharingServer = 0x00000010,
+ IPV4Disabled = 0x00000020,
+ IPV4MayUseAsDefaultRoute = 0x00000040,
+ IPV6DHCPIP = 0x00000080,
+ IPV6DHCPDNS = 0x00000100,
+ IPV6DHCPRoutes = 0x00000200,
+ IPV6LocalOnly = 0x00000400,
+ IPV6StartConnectionSharingServer = 0x00000800,
+ IPV6Disabled = 0x00001000,
+ IPV6MayUseAsDefaultRoute = 0x00002000
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkIPConfigurationFlags)
};
+class TDECORE_EXPORT TDENetworkSearchDomain
+{
+ public:
+ TDENetworkSearchDomain();
+ TDENetworkSearchDomain(TQString domain, bool ipv6=false);
+ ~TDENetworkSearchDomain();
+
+ TQString searchDomain();
+ void setSearchDomain(TQString domain, bool ipv6=false);
+
+ bool isIPv4();
+ bool isIPv6();
+
+ private:
+ TQString m_domain;
+ bool m_isIPV6;
+};
+
+typedef TQValueList<TDENetworkSearchDomain> TDENetworkSearchDomainList;
+
+class TDECORE_EXPORT TDENetMask
+{
+ public:
+ TDENetMask();
+ TDENetMask(TQ_UINT32 netmask);
+ TDENetMask(TQ_UINT8* netmask);
+ ~TDENetMask();
+
+ void fromCIDRMask(unsigned char mask, bool ipv6=false);
+ unsigned char toCIDRMask();
+ void fromString(TQString mask);
+ TQString toString();
+
+ bool isIPv4();
+ bool isIPv6();
+
+ private:
+ TQ_UINT32 m_ipv4NetMask;
+ TQHostAddress m_ipv6NetMask;
+ bool m_isIPV6;
+};
+
+class TDECORE_EXPORT TDEMACAddress
+{
+ public:
+ TDEMACAddress();
+ TDEMACAddress(TDENetworkByteList address);
+ ~TDEMACAddress();
+
+ TDENetworkByteList address();
+ void setAddress(TDENetworkByteList address);
+ TQString toString();
+ void fromString(TQString address);
+ bool isValid();
+
+ private:
+ bool m_isValid;
+ TDENetworkByteList m_macAddress;
+
+ friend bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2);
+};
+
+bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2);
+
+class TDECORE_EXPORT TDENetworkSingleIPConfiguration
+{
+ public:
+ TDENetworkSingleIPConfiguration();
+ ~TDENetworkSingleIPConfiguration();
+
+ bool isIPv4();
+ bool isIPv6();
+
+ public:
+ bool valid;
+ TQHostAddress ipAddress;
+ TDENetMask networkMask;
+ TQHostAddress gateway;
+};
+
+typedef TQValueList<TDENetworkSingleIPConfiguration> TDENetworkSingleIPConfigurationList;
+
+class TDECORE_EXPORT TDENetworkSingleRouteConfiguration
+{
+ public:
+ TDENetworkSingleRouteConfiguration();
+ ~TDENetworkSingleRouteConfiguration();
+
+ bool isIPv4();
+ bool isIPv6();
+
+ public:
+ bool valid;
+ TQHostAddress ipAddress;
+ TDENetMask networkMask;
+ TQHostAddress gateway;
+ TQ_UINT32 metric;
+};
+
+typedef TQValueList<TDENetworkSingleRouteConfiguration> TDENetworkSingleRouteConfigurationList;
+
+class TDENetworkIEEE8021xConfiguration
+{
+ public:
+ TDENetworkIEEE8021xConfiguration();
+ ~TDENetworkIEEE8021xConfiguration();
+
+ public:
+ bool valid;
+ bool secretsValid;
+ TDENetworkIEEE8021xType::TDENetworkIEEE8021xType type;
+ TQString userName;
+ TQString anonymousUserName;
+ TQString pacFileName;
+ TQByteArray caCertificate;
+ TQString additionalCAFilesPath;
+ TQString authServerCertSubjectMatch;
+ TQStringList alternateAuthServerCertSubjectMatch;
+ TQByteArray clientCertificate;
+ TQString forcePEAPVersion;
+ TQString forcePEAPLabel;
+ TDENetworkIEEE8021xFastFlags::TDENetworkIEEE8021xFastFlags fastProvisioningFlags;
+ TQString phase2NonEAPAuthMethod;
+ TQString phase2EAPAuthMethod;
+ TQByteArray phase2CaCertificate;
+ TQString phase2CaFilesPath;
+ TQString phase2AuthServerCertSubjectMatch;
+ TQStringList phase2AlternateAuthServerCertSubjectMatch;
+ TQByteArray phase2ClientCertificate;
+ TQString password;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags passwordFlags;
+ TQByteArray binaryPassword;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags binaryPasswordFlags;
+ TQByteArray privateKey;
+ TQString privateKeyPassword;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags privateKeyPasswordFlags;
+ TQByteArray phase2PrivateKey;
+ TQString phase2PrivateKeyPassword;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags phase2PrivateKeyPasswordFlags;
+ bool forceSystemCaCertificates;
+};
+
class TDECORE_EXPORT TDENetworkIPConfiguration
{
public:
@@ -183,11 +397,13 @@ class TDECORE_EXPORT TDENetworkIPConfiguration
public:
bool valid;
TDENetworkIPConfigurationFlags::TDENetworkIPConfigurationFlags connectionFlags;
- TQString ipAddress;
- TQString networkMask;
- TQString gateway;
- TQString broadcast;
- TQString destination;
+ TDENetworkSingleIPConfigurationList ipConfigurations;
+ TDENetworkSingleRouteConfigurationList routeConfigurations;
+ TQHostAddress broadcast;
+ TQHostAddress destination;
+ TDENetworkAddressList resolvers;
+ TDENetworkSearchDomainList searchDomains;
+ TQString dhcpClientIdentifier;
};
class TDECORE_EXPORT TDENetworkWiFiDeviceInfo
@@ -198,8 +414,8 @@ class TDECORE_EXPORT TDENetworkWiFiDeviceInfo
public:
bool valid;
- TQString hwAddress;
- TQString permanentHWAddress;
+ TDEMACAddress hwAddress;
+ TDEMACAddress permanentHWAddress;
TDEWiFiMode::TDEWiFiMode operatingMode;
unsigned int bitrate;
TQString activeAccessPointBSSID;
@@ -225,7 +441,7 @@ class TDECORE_EXPORT TDENetworkDeviceInformation
bool autoConnect;
bool firmwareMissing;
TDENetworkConnectionType::TDENetworkConnectionType deviceType;
- TDENetworkWiFiDeviceInfo wirelessInfo;
+ TDENetworkWiFiDeviceInfo wiFiInfo;
};
class TDECORE_EXPORT TDENetworkHWNeighbor
@@ -245,8 +461,9 @@ class TDECORE_EXPORT TDENetworkWiFiAPInfo : public TDENetworkHWNeighbor
~TDENetworkWiFiAPInfo();
public:
- TQString SSID;
- TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags;
+ TQByteArray SSID;
+ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags wpaFlags;
+ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags rsnFlags;
unsigned int frequency;
TQString BSSID;
unsigned int maxBitrate;
@@ -255,28 +472,38 @@ class TDECORE_EXPORT TDENetworkWiFiAPInfo : public TDENetworkHWNeighbor
typedef TQPtrList< TDENetworkHWNeighbor > TDENetworkHWNeighborList;
-class TDECORE_EXPORT TDENetworkConnection : public TQObject
+class TDECORE_EXPORT TDENetworkConnection
{
- Q_OBJECT
-
public:
TDENetworkConnection();
- ~TDENetworkConnection();
+ virtual ~TDENetworkConnection();
public:
TQString UUID;
TQString friendlyName;
TDENetworkIPConfiguration ipConfig;
+ TDEMACAddress lockedHWAddress;
+ TDEMACAddress manualHWAddress;
bool autoConnect;
+ bool fullDuplex;
+ bool requireIPV4;
+ bool requireIPV6;
+ TQ_UINT32 mtu;
+ TDENetworkIEEE8021xConfiguration eapConfig;
};
-class TDECORE_EXPORT TDEWiFiConnection : public TDENetworkConnection
+class TDECORE_EXPORT TDEWiredEthernetConnection : public TDENetworkConnection
{
- Q_OBJECT
+ public:
+ TDEWiredEthernetConnection();
+ virtual ~TDEWiredEthernetConnection();
+};
+class TDECORE_EXPORT TDEWiFiConnection : public TDENetworkConnection
+{
public:
TDEWiFiConnection();
- ~TDEWiFiConnection();
+ virtual ~TDEWiFiConnection();
public:
TQString SSID;
@@ -297,6 +524,8 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
/**
* Constructor.
* @param macAddress The MAC address of the hardware device
+ * If an empty MAC address is passed, this object will make global networking backend
+ * methods available exclusively (TDENetworkConnectionType::BackendOnly).
*/
TDENetworkConnectionManager(TQString macAddress);
@@ -327,15 +556,25 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
/**
* Loads all connection information from the configuration backend
+ * Secret information must be loaded separately via a call to
+ * loadConnectionSecrets(TQString uuid) after this method has been
+ * executed at least once.
*/
virtual void loadConnectionInformation() = 0;
/**
- * @param connection a TDENetworkConnection object containing a
+ * @param uuid a TQString conntaining the UUID of a connection for which to
+ * load secrets from the configuration backend.
+ * @return true on success, false on failure.
+ */
+ virtual bool loadConnectionSecrets(TQString uuid) = 0;
+
+ /**
+ * @param connection a pointer to a TDENetworkConnection object containing a
* connection to save to the configuration backend.
* @return true on success, false on failure.
*/
- virtual bool saveConnection(TDENetworkConnection connection) = 0;
+ virtual bool saveConnection(TDENetworkConnection* connection) = 0;
/**
* @param uuid a TQString conntaining the UUID of a connection to
@@ -345,21 +584,6 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
virtual bool deleteConnection(TQString uuid) = 0;
/**
- * @return a TDENetworkConnectionList object containing a list of all
- * possible connections this connection manager is aware of, regardless
- * of current state or availability.
- *
- * loadConnectionInformation() should be called at least once before calling
- * this method, in order to update internal connection information from the
- * configuration backend.
- *
- * Note that the returned list is internally managed and must not be deleted!
- * Also note that pointers in the list may become invalid on subsequent calls to
- * loadConnectionInformation(), saveConnection(), deleteConnection(), or connections().
- */
- virtual TDENetworkConnectionList* connections() = 0;
-
- /**
* Initiates a connection with UUID @param uuid.
* @return A TDENetworkConnectionStatus enum value with the current connection status
* The client application should poll for status updates using checkConnectionStatus()
@@ -390,9 +614,78 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
virtual TDENetworkHWNeighborList* siteSurvey() = 0;
- private:
+ /**
+ * @return true if networking is enabled, false if not.
+ */
+ virtual bool networkingEnabled() = 0;
+
+ /**
+ * @return true if WiFi hardware is enabled, false if not.
+ */
+ virtual bool wiFiHardwareEnabled() = 0;
+
+ /**
+ * @param enable true to enable WiFi, false to disable it.
+ * @return true on success, false on failure.
+ */
+ virtual bool enableWiFi(bool enable) = 0;
+
+ /**
+ * @return true if WiFi is enabled, false if not.
+ */
+ virtual bool wiFiEnabled() = 0;
+
+ signals:
+ /**
+ * Emitted whenever the state of the system's connection changes
+ * If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid
+ */
+ void networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState);
+
+ /**
+ * Emitted whenever the state of a device changes
+ * If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid
+ * If the global connection state has changed, @param hwAddress will be empty, otherwise it will contain the MAC address
+ * of the networking hardware that has changed state.
+ */
+ void networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus previousState, TQString hwAddress);
+
+ public:
+ /**
+ * @return a TDENetworkConnectionList object containing a list of all
+ * possible connections this connection manager is aware of, regardless
+ * of current state or availability.
+ *
+ * loadConnectionInformation() should be called at least once before calling
+ * this method, in order to update internal connection information from the
+ * configuration backend.
+ *
+ * Note that the returned list is internally managed and must not be deleted!
+ * Also note that pointers in the list may become invalid on subsequent calls to
+ * loadConnectionInformation(), saveConnection(), deleteConnection(), or connections().
+ */
+ virtual TDENetworkConnectionList* connections();
+
+ /**
+ * @return a pointer to a TDENetworkConnection object with the specified @param uuid,
+ * or a NULL pointer if no such connection exists.
+ *
+ * Note that the returned object is internally managed and must not be deleted!
+ */
+ TDENetworkConnection* findConnectionByUUID(TQString uuid);
+
+ protected:
+ void clearTDENetworkConnectionList();
+ void clearTDENetworkHWNeighborList();
+ void internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState);
+ void internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress=TQString::null);
+
+ protected:
TDENetworkConnectionList* m_connectionList;
+ TDENetworkHWNeighborList* m_hwNeighborList;
TQString m_macAddress;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags m_prevConnectionStatus;
+ TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus;
};
#endif // _TDENETWORKCONNECTIONS_H \ No newline at end of file