summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/CMakeLists.txt82
-rw-r--r--tdecore/tdehw/hwlibdaemons/CMakeLists.txt13
-rw-r--r--tdecore/tdehw/hwlibdaemons/dbus/CMakeLists.txt37
-rw-r--r--tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.conf38
-rw-r--r--tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.service.cmake4
-rw-r--r--tdecore/tdehw/hwlibdaemons/dbus/tde_dbus_hardwarecontrol.c327
-rw-r--r--tdecore/tdehw/hwlibdata/CMakeLists.txt14
-rw-r--r--tdecore/tdehw/hwlibdata/classrules/CMakeLists.txt17
-rw-r--r--tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass10
-rw-r--r--tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass9
-rw-r--r--tdecore/tdehw/hwlibdata/pnpdev/CMakeLists.txt17
-rw-r--r--tdecore/tdehw/hwlibdata/pnpdev/dpy.ids8
-rw-r--r--tdecore/tdehw/hwlibdata/pnpdev/pnp.ids156
-rw-r--r--tdecore/tdehw/networkbackends/CMakeLists.txt12
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/CMakeLists.txt36
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/CMakeLists.txt90
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-access-point.xml92
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-active-connection.xml76
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-agent-manager.xml38
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-adsl.xml21
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bond.xml27
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bt.xml48
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-ethernet.xml39
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-infiniband.xml27
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-modem.xml64
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-olpc-mesh.xml34
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-vlan.xml33
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wifi.xml124
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wimax.xml103
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device.xml577
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp4-config.xml20
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp6-config.xml20
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip4-config.xml29
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip6-config.xml19
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-manager.xml390
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ppp-manager.xml22
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-secret-agent.xml177
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings-connection.xml93
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings.xml102
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-connection.xml146
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-plugin.xml199
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-wimax-nsp.xml44
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.cpp5627
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.h263
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager_p.h140
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp6206
-rw-r--r--tdecore/tdehw/tdehardwaredevices.h2122
-rw-r--r--tdecore/tdehw/tdenetworkconnections.cpp1106
-rw-r--r--tdecore/tdehw/tdenetworkconnections.h1596
49 files changed, 20494 insertions, 0 deletions
diff --git a/tdecore/tdehw/CMakeLists.txt b/tdecore/tdehw/CMakeLists.txt
new file mode 100644
index 000000000..960158cea
--- /dev/null
+++ b/tdecore/tdehw/CMakeLists.txt
@@ -0,0 +1,82 @@
+#################################################
+#
+# (C) 2013 Golubev Alexander
+# fatzer2 (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( hwlibdata )
+add_subdirectory( hwlibdaemons )
+add_subdirectory( networkbackends )
+
+if( NOT DBUS_SYSTEM_BUS )
+ set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE )
+endif()
+
+if( WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
+ WITH_NETWORK_MANAGER_BACKEND OR WITH_CONSOLEKIT )
+ list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${DBUS_TQT_INCLUDE_DIRS} )
+ list( APPEND TDEHW_CUSTOM_LIBRARY_DIRS ${DBUS_TQT_LIBRARY_DIRS} )
+ list( APPEND TDEHW_CUSTOM_LIBRARIES ${DBUS_TQT_LIBRARIES} )
+endif( )
+
+if( WITH_UPOWER )
+ add_definitions( -DWITH_UPOWER )
+endif( )
+
+if( WITH_UDISKS )
+ add_definitions( -DWITH_UDISKS )
+endif( )
+
+if( WITH_UDISKS2 )
+ add_definitions( -DWITH_UDISKS2 )
+endif( )
+
+if( WITH_CONSOLEKIT )
+ add_definitions( -DWITH_CONSOLEKIT )
+endif( )
+
+if( WITH_NETWORK_MANAGER_BACKEND )
+ list( APPEND TDEHW_CUSTOM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/networkbackends/network-manager/dbus )
+ list( APPEND TDEHW_CUSTOM_LIBRARIES network_manager_backend-static )
+endif( WITH_NETWORK_MANAGER_BACKEND )
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/dcop
+ ${TDEHW_CUSTOM_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+ ${TDEHW_CUSTOM_LIBRARY_DIRS}
+)
+
+##### headers ###################################
+
+install( FILES tdehardwaredevices.h tdenetworkconnections.h
+ DESTINATION ${INCLUDE_INSTALL_DIR} )
+
+
+##### libtdecore ################################
+
+set( target tdehw )
+
+set( ${target}_SRCS
+ tdehardwaredevices.cpp tdenetworkconnections.cpp
+)
+
+tde_add_library( ${target} STATIC_PIC AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK udev ${TDENM_LIBRARIES} ${TDEUPOWER_LIBRARIES}
+ ${TDEHW_CUSTOM_LIBRARIES}
+)
diff --git a/tdecore/tdehw/hwlibdaemons/CMakeLists.txt b/tdecore/tdehw/hwlibdaemons/CMakeLists.txt
new file mode 100644
index 000000000..edc853c95
--- /dev/null
+++ b/tdecore/tdehw/hwlibdaemons/CMakeLists.txt
@@ -0,0 +1,13 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+
+add_subdirectory( dbus )
diff --git a/tdecore/tdehw/hwlibdaemons/dbus/CMakeLists.txt b/tdecore/tdehw/hwlibdaemons/dbus/CMakeLists.txt
new file mode 100644
index 000000000..4d1f4618a
--- /dev/null
+++ b/tdecore/tdehw/hwlibdaemons/dbus/CMakeLists.txt
@@ -0,0 +1,37 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${DBUS_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+##### tde_dbus_hardwarecontrol ##################
+
+tde_add_executable( tde_dbus_hardwarecontrol
+ SOURCES tde_dbus_hardwarecontrol.c
+ LINK ${DBUS_LIBRARIES}
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+##### other data ################################
+
+configure_file( org.trinitydesktop.hardwarecontrol.service.cmake org.trinitydesktop.hardwarecontrol.service @ONLY )
+
+install( FILES
+ org.trinitydesktop.hardwarecontrol.conf
+ DESTINATION ${DBUS_SYSTEM_CONF_DIRECTORY} )
+
+install( FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/org.trinitydesktop.hardwarecontrol.service
+ DESTINATION ${DBUS_SERVICE_DIRECTORY} )
diff --git a/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.conf b/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.conf
new file mode 100644
index 000000000..a649b969f
--- /dev/null
+++ b/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.conf
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
+
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- Only root can own the service -->
+ <policy user="root">
+ <allow own="org.trinitydesktop.hardwarecontrol"/>
+ </policy>
+
+ <policy at_console="true">
+ <!-- Users with physical access to the machine are allowed access -->
+ <allow send_destination="org.trinitydesktop.hardwarecontrol"
+ send_interface="org.freedesktop.DBus.Introspectable"/>
+
+ <allow send_destination="org.trinitydesktop.hardwarecontrol"
+ send_interface="org.freedesktop.DBus.Properties"/>
+ <allow send_destination="org.trinitydesktop.hardwarecontrol.CPUGovernor"
+ send_interface="org.freedesktop.DBus.Properties"/>
+ <allow send_destination="org.trinitydesktop.hardwarecontrol.Brightness"
+ send_interface="org.freedesktop.DBus.Properties"/>
+
+ <allow send_destination="org.trinitydesktop.hardwarecontrol"
+ send_interface="org.trinitydesktop.hardwarecontrol"/>
+ <allow send_destination="org.trinitydesktop.hardwarecontrol"
+ send_interface="org.trinitydesktop.hardwarecontrol.CPUGovernor"/>
+ <allow send_destination="org.trinitydesktop.hardwarecontrol"
+ send_interface="org.trinitydesktop.hardwarecontrol.Brightness"/>
+ </policy>
+
+ <policy context="default">
+ <!-- Everyone else is denied access -->
+ <deny own="org.trinitydesktop.hardwarecontrol"/>
+
+ <deny send_destination="org.trinitydesktop.hardwarecontrol"/>
+ </policy>
+</busconfig>
diff --git a/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.service.cmake b/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.service.cmake
new file mode 100644
index 000000000..3be2ebeee
--- /dev/null
+++ b/tdecore/tdehw/hwlibdaemons/dbus/org.trinitydesktop.hardwarecontrol.service.cmake
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.trinitydesktop.hardwarecontrol
+Exec=@BIN_INSTALL_DIR@/tde_dbus_hardwarecontrol
+User=root \ No newline at end of file
diff --git a/tdecore/tdehw/hwlibdaemons/dbus/tde_dbus_hardwarecontrol.c b/tdecore/tdehw/hwlibdaemons/dbus/tde_dbus_hardwarecontrol.c
new file mode 100644
index 000000000..f7e707522
--- /dev/null
+++ b/tdecore/tdehw/hwlibdaemons/dbus/tde_dbus_hardwarecontrol.c
@@ -0,0 +1,327 @@
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void reply_Bool(DBusMessage* msg, DBusConnection* conn, int value) {
+ DBusMessage* reply;
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ dbus_uint32_t serial = 0;
+
+ // create a reply from the message
+ reply = dbus_message_new_method_return(msg);
+
+ // add the arguments to the reply
+ dbus_message_iter_init_append(reply, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BOOLEAN, &value)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_message_iter_append_basic failed\n", member);
+ return;
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_connection_send failed\n", member);
+ return;
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+}
+
+void reply_CanSetGivenPath(DBusMessage* msg, DBusConnection* conn, const char* param) {
+ DBusMessage* reply;
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ dbus_uint32_t serial = 0;
+ int writable = false;
+
+ // check if path is writable
+ int rval = access (param, W_OK);
+ if (rval == 0) {
+ writable = true;
+ }
+
+ // create a reply from the message
+ reply = dbus_message_new_method_return(msg);
+
+ // add the arguments to the reply
+ dbus_message_iter_init_append(reply, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BOOLEAN, &writable)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_message_iter_append_basic failed\n", member);
+ return;
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_connection_send failed\n", member);
+ return;
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+}
+
+void reply_SetGivenPath(DBusMessage* msg, DBusConnection* conn, const char* param, const char* contents) {
+ DBusMessage* reply;
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ dbus_uint32_t serial = 0;
+ int writable = false;
+ int written = false;
+
+ // check if path is writable
+ int rval = access (param, W_OK);
+ if (rval == 0) {
+ writable = true;
+ }
+
+ if (writable) {
+ FILE *node = fopen(param, "w");
+ if (node != NULL) {
+ if (fputs(contents, node) != EOF) {
+ written = true;
+ }
+ if (fclose(node) == EOF) {
+ // Error!
+ }
+ }
+ }
+
+ // create a reply from the message
+ reply = dbus_message_new_method_return(msg);
+
+ // add the arguments to the reply
+ dbus_message_iter_init_append(reply, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BOOLEAN, &written)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_message_iter_append_basic failed\n", member);
+ return;
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_connection_send failed\n", member);
+ return;
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+}
+
+void reply_CanSetCPUGovernor(DBusMessage* msg, DBusConnection* conn) {
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ dbus_int32_t cpunum;
+ char path[256];
+
+ // read the arguments
+ if (!dbus_message_iter_init(msg, &args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: no argument supplied\n", member);
+ }
+ else if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: argument not 32-bit integer\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &cpunum);
+ }
+
+ snprintf(path, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpunum);
+ reply_CanSetGivenPath(msg, conn, path);
+}
+
+void reply_SetCPUGovernor(DBusMessage* msg, DBusConnection* conn) {
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ dbus_int32_t cpunum = -1;
+ char* governor = NULL;
+ char path[256];
+
+ // read the arguments
+ if (!dbus_message_iter_init(msg, &args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: no arguments supplied\n", member);
+ }
+ else if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: first argument not 32-bit integer\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &cpunum);
+ }
+
+ if (!dbus_message_iter_next(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: second argument not supplied\n", member);
+ }
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: second argument not string\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &governor);
+ }
+
+ snprintf(path, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpunum);
+ if ((cpunum>-1) && governor) {
+ reply_SetGivenPath(msg, conn, path, governor);
+ }
+ else {
+ reply_Bool(msg, conn, false);
+ }
+}
+
+void reply_CanSetBrightness(DBusMessage* msg, DBusConnection* conn) {
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ char* rawpath;
+ char* safepath;
+ char path[256];
+
+ // read the arguments
+ if (!dbus_message_iter_init(msg, &args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: no argument supplied\n", member);
+ }
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: argument not string\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &rawpath);
+ }
+
+ safepath = realpath(rawpath, NULL);
+
+ if (safepath &&
+ (strstr(safepath, "/sys/devices") == safepath) &&
+ (strstr(safepath, "/brightness") == (safepath+strlen(safepath)-strlen("/brightness")))
+ ) {
+ reply_CanSetGivenPath(msg, conn, safepath);
+ }
+ else {
+ reply_Bool(msg, conn, false);
+ }
+
+ free(safepath);
+}
+
+void reply_SetBrightness(DBusMessage* msg, DBusConnection* conn) {
+ DBusMessageIter args;
+ const char* member = dbus_message_get_member(msg);
+ char* rawpath;
+ char* safepath;
+ char* brightness;
+ char path[256];
+
+ // read the arguments
+ if (!dbus_message_iter_init(msg, &args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: no arguments supplied\n", member);
+ }
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: first argument not string\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &rawpath);
+ }
+
+ if (!dbus_message_iter_next(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: second argument not supplied\n", member);
+ }
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: second argument not string\n", member);
+ }
+ else {
+ dbus_message_iter_get_basic(&args, &brightness);
+ }
+
+ safepath = realpath(rawpath, NULL);
+
+ if (safepath && brightness &&
+ (strstr(safepath, "/sys/devices") == safepath) &&
+ (strstr(safepath, "/brightness") == (safepath+strlen(safepath)-strlen("/brightness")))
+ ) {
+ reply_SetGivenPath(msg, conn, safepath, brightness);
+ }
+ else {
+ reply_Bool(msg, conn, false);
+ }
+
+ free(safepath);
+}
+
+void listen() {
+ DBusMessage* msg;
+ DBusMessage* reply;
+ DBusMessageIter args;
+ DBusConnection* conn;
+ DBusError err;
+ int ret;
+ char* param;
+
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] Listening...\n");
+
+ // initialise the error structure
+ dbus_error_init(&err);
+
+ // connect to the bus and check for errors
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] Connection failed with error '%s'\n", err.message);
+ dbus_error_free(&err);
+ }
+ if (NULL == conn) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] No connection, exiting!\n");
+ exit(1);
+ }
+
+ // request our name on the bus and check for errors
+ ret = dbus_bus_request_name(conn, "org.trinitydesktop.hardwarecontrol", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
+ if (dbus_error_is_set(&err)) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] Name request failed with error '%s'\n", err.message);
+ dbus_error_free(&err);
+ }
+ if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] Not primary owner (%d), exiting!\n", ret);
+ exit(1);
+ }
+
+ // loop, testing for new messages
+ while (true) {
+ // non blocking read of the next available message
+ dbus_connection_read_write(conn, 1000); // block for up to 1 second
+ msg = dbus_connection_pop_message(conn);
+
+ // loop again if we haven't got a message
+ if (NULL == msg) {
+ continue;
+ }
+
+ // check this is a method call for the right interface & method
+ if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.CPUGovernor", "CanSetCPUGovernor")) {
+ reply_CanSetCPUGovernor(msg, conn);
+ }
+ else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.CPUGovernor", "SetCPUGovernor")) {
+ reply_SetCPUGovernor(msg, conn);
+ }
+ else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Brightness", "CanSetBrightness")) {
+ reply_CanSetBrightness(msg, conn);
+ }
+ else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Brightness", "SetBrightness")) {
+ reply_SetBrightness(msg, conn);
+ }
+ else {
+ fprintf(stderr, "[tde_dbus_hardwarecontrol] Unknown method '%s' called on interface '%s', ignoring\n", dbus_message_get_member(msg), dbus_message_get_interface(msg));
+ }
+
+ // free the message
+ dbus_message_unref(msg);
+ }
+
+ // close the connection
+ dbus_connection_close(conn);
+}
+
+int main(int argc, char** argv) {
+ listen();
+ return 0;
+}
diff --git a/tdecore/tdehw/hwlibdata/CMakeLists.txt b/tdecore/tdehw/hwlibdata/CMakeLists.txt
new file mode 100644
index 000000000..fe7cee67d
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/CMakeLists.txt
@@ -0,0 +1,14 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+
+add_subdirectory( classrules )
+add_subdirectory( pnpdev )
diff --git a/tdecore/tdehw/hwlibdata/classrules/CMakeLists.txt b/tdecore/tdehw/hwlibdata/classrules/CMakeLists.txt
new file mode 100644
index 000000000..3b9452f43
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/classrules/CMakeLists.txt
@@ -0,0 +1,17 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+
+##### other data ################################
+
+install( FILES
+ floppydisk-platform.hwclass floppydisk-udev.hwclass
+ DESTINATION ${DATA_INSTALL_DIR}/tdehwlib/deviceclasses )
diff --git a/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass b/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass
new file mode 100644
index 000000000..b3ccab66c
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/classrules/floppydisk-platform.hwclass
@@ -0,0 +1,10 @@
+[Conditions]
+SUBSYSTEM=block
+DRIVER=floppy
+
+[DeviceType]
+GENTYPE=Disk
+SUBTYPE=Floppy
+
+[DeviceSettings]
+UPDATE_BLACKLISTED=false
diff --git a/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass b/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass
new file mode 100644
index 000000000..6c76d3c85
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/classrules/floppydisk-udev.hwclass
@@ -0,0 +1,9 @@
+[Conditions]
+ID_TYPE=floppy
+
+[DeviceType]
+GENTYPE=Disk
+SUBTYPE=Floppy
+
+[DeviceSettings]
+UPDATE_BLACKLISTED=false
diff --git a/tdecore/tdehw/hwlibdata/pnpdev/CMakeLists.txt b/tdecore/tdehw/hwlibdata/pnpdev/CMakeLists.txt
new file mode 100644
index 000000000..98b117d54
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/pnpdev/CMakeLists.txt
@@ -0,0 +1,17 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+
+##### other data ################################
+
+install( FILES
+ pnp.ids dpy.ids
+ DESTINATION ${DATA_INSTALL_DIR}/tdehwlib/pnpdev )
diff --git a/tdecore/tdehw/hwlibdata/pnpdev/dpy.ids b/tdecore/tdehw/hwlibdata/pnpdev/dpy.ids
new file mode 100644
index 000000000..605ef28f4
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/pnpdev/dpy.ids
@@ -0,0 +1,8 @@
+# This file is provided soley in the interest of cross platform compatibility
+# It only contains information on certain generic core system devices that cannot be looked up via another method
+# All marks are the property of their owners
+
+ACR Acer
+LPL LG
+PHL Philips
+SEC Samsung \ No newline at end of file
diff --git a/tdecore/tdehw/hwlibdata/pnpdev/pnp.ids b/tdecore/tdehw/hwlibdata/pnpdev/pnp.ids
new file mode 100644
index 000000000..bf4a3ce01
--- /dev/null
+++ b/tdecore/tdehw/hwlibdata/pnpdev/pnp.ids
@@ -0,0 +1,156 @@
+# The information provided in this PNP ID to friendly name mapping table was obtained from
+# multiple public sources, as well as this authoritative publicly accessible file:
+# ftp://ftpmicrosoftcom/developr/drg/plug-and-play/devidstxt
+#
+# This file is provided soley in the interest of cross platform compatibility
+# It only contains information on certain generic core system devices that cannot be looked up via another method
+# All marks are the property of their owners
+#
+# A typical PNP ID takes the form of PNPxxxx:yy
+#
+# Some additional information that may be useful for applications parsing PNP device ID strings:
+# PNP0xxx System devices
+# PNP8xxx Network adapters
+# PNPAxxx SCSI, proprietary CD adapters
+# PNPBxxx Sound, video capture, multimedia
+# PNPCxxx - PNPDxxx Modems
+#
+# The two digit code yy appears to be a PCI device type code followed by a subtype code and should be parsed as such
+
+PNP0802 Microsoft® Sound System-compatible device
+
+PNP0000 AT Interrupt Controller
+PNP0001 EISA Interrupt Controller
+PNP0002 MCA Interrupt Controller
+PNP0003 APIC
+PNP0004 Cyrix SLiC MP Interrupt Controller
+
+PNP0100 AT Timer
+PNP0101 EISA Timer
+PNP0102 MCA Timer
+PNP0103 High Precision Event Timer
+
+PNP0200 AT DMA Controller
+PNP0201 EISA DMA Controller
+PNP0202 MCA DMA Controller
+
+PNP0300 IBM PC/XT keyboard controller (83-key)
+PNP0301 IBM PC/AT keyboard controller (86-key)
+PNP0302 IBM PC/XT keyboard controller (84-key)
+PNP0303 IBM Enhanced (101/102-key, PS/2 mouse support)
+PNP0304 Olivetti Keyboard (83-key)
+PNP0305 Olivetti Keyboard (102-key)
+PNP0306 Olivetti Keyboard (86-key)
+PNP0307 Microsoft® Windows(R) Keyboard
+PNP0308 General Input Device Emulation Interface (GIDEI) legacy
+PNP0309 Olivetti Keyboard (A101/102 key)
+PNP030A AT&T 302 keyboard
+PNP030B Reserved by Microsoft®
+PNP0320 Japanese 106-key keyboard A01
+PNP0321 Japanese 101-key keyboard
+PNP0322 Japanese AX keyboard
+PNP0323 Japanese 106-key keyboard 002/003
+PNP0324 Japanese 106-key keyboard 001
+PNP0325 Japanese Toshiba Desktop keyboard
+PNP0326 Japanese Toshiba Laptop keyboard
+PNP0327 Japanese Toshiba Notebook keyboard
+PNP0340 Korean 84-key keyboard
+PNP0341 Korean 86-key keyboard
+PNP0342 Korean Enhanced keyboard
+PNP0343 Korean Enhanced keyboard 101b
+PNP0343 Korean Enhanced keyboard 101c
+PNP0344 Korean Enhanced keyboard 103
+
+PNP0400 Standard LPT Printer Port
+PNP0401 ECP Printer Port
+
+PNP0500 Standard PC Serial Port
+PNP0501 16550A-compatible Serial Port
+PNP0502 Multiport Serial Device (non-intelligent 16550)
+PNP0510 Generic IRDA-compatible Device
+PNP0511 Generic IRDA-compatible Device
+
+PNP0600 Generic ESDI/IDE/ATA Compatible Hard Disk Controller
+PNP0603 Generic IDE supporting Microsoft® Device Bay Specification
+PNP0700 PC Standard Floppy Disk Controller
+PNP0701 Microsoft® Device Bay Compatible Floppy Controller
+
+PNP0802 Microsoft® Sound System compatible device
+
+PNP0900 VGA Compatible Display Controller
+PNP09FF Plug and Play Monitor (VESA DDC)
+
+PNP0A00 ISA Root Bus
+PNP0A01 EISA Root Bus
+PNP0A02 MCA Root Bus
+PNP0A03 PCI Root Bus
+PNP0A04 VESA/VL Bus
+PNP0A05 Generic ACPI Root Bus
+PNP0A06 Generic ACPI Extended-IO Root Bus (EIO Root Bus)
+PNP0A08 PCI Express Root Bus
+
+PNP0800 AT-style Speaker
+PNP0B00 AT Real-Time Clock
+PNP0C00 Plug and Play BIOS
+PNP0C01 System Board
+PNP0C02 Plug and Play Motherboard Register Resource
+PNP0C03 Plug and Play BIOS Event Notification Interrupt
+PNP0C04 Math Coprocessor
+PNP0C05 APM BIOS
+PNP0C06 Early Plug and Play BIOS
+PNP0C07 Early Plug and Play BIOS
+PNP0C08 ACPI System Board
+PNP0C09 ACPI Embedded Controller
+PNP0C0A ACPI Control Method Battery
+PNP0C0B ACPI Fan
+PNP0C0C ACPI Power Button
+PNP0C0D ACPI Lid Switch
+PNP0C0E ACPI Sleep Button
+PNP0C0F PCI Interrupt Link
+PNP0C10 ACPI System Indicator
+PNP0C11 ACPI Thermal Zone
+PNP0C12 Device Bay Controller
+PNP0C13 Plug and Play BIOS
+
+PNP0E00 Intel 82365-Compatible PCMCIA Controller
+PNP0E01 Cirrus Logic CL-PD6720 PCMCIA Controller
+PNP0E02 VLSI VL82C146 PCMCIA Controller
+PNP0E03 Intel 82365-compatible CardBus controller
+
+PNP0F00 Microsoft® Bus Mouse
+PNP0F01 Microsoft® Serial Mouse
+PNP0F02 Microsoft® InPort Mouse
+PNP0F03 Microsoft® PS/2-style Mouse
+PNP0F04 Mouse Systems Mouse
+PNP0F05 Mouse Systems 3-Button Mouse
+PNP0F06 Genius Mouse
+PNP0F07 Genius Mouse
+PNP0F08 Logitech Serial Mouse
+PNP0F09 Microsoft® BallPoint Serial Mouse
+PNP0F0A Microsoft® Plug and Play Mouse
+PNP0F0B Microsoft® Plug and Play BallPoint Mouse
+PNP0F0C Microsoft®-compatible Serial Mouse
+PNP0F0D Microsoft®-compatible InPort-compatible Mouse
+PNP0F0E Microsoft®-compatible PS/2-style Mouse
+PNP0F0F Microsoft®-compatible Serial BallPoint-compatible Mouse
+PNP0F10 Texas Instruments QuickPort Mouse
+PNP0F11 Microsoft®-compatible Bus Mouse
+PNP0F12 Logitech PS/2-style Mouse
+PNP0F13 PS/2 Port for PS/2-style Mice
+PNP0F14 Microsoft® Kids Mouse
+PNP0F15 Logitech bus mouse
+PNP0F16 Logitech SWIFT device
+PNP0F17 Logitech-compatible serial mouse
+PNP0F18 Logitech-compatible bus mouse
+PNP0F19 Logitech-compatible PS/2-style Mouse
+PNP0F1A Logitech-compatible SWIFT Device
+PNP0F1B HP Omnibook Mouse
+PNP0F1C Compaq LTE Trackball PS/2-style Mouse
+PNP0F1D Compaq LTE Trackball Serial Mouse
+PNP0F1E Microsoft® Kids Trackball Mouse
+PNP0F1F Reserved by Microsoft® Input Device Group
+PNP0F20 Reserved by Microsoft® Input Device Group
+PNP0F21 Reserved by Microsoft® Input Device Group
+PNP0F22 Reserved by Microsoft® Input Device Group
+PNP0F23 Reserved by Microsoft® Input Device Group
+PNP0FFF Reserved by Microsoft® Systems \ No newline at end of file
diff --git a/tdecore/tdehw/networkbackends/CMakeLists.txt b/tdecore/tdehw/networkbackends/CMakeLists.txt
new file mode 100644
index 000000000..f5b916a95
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2013 Golubev Alexander
+# fatzer2 (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+tde_conditional_add_subdirectory( WITH_NETWORK_MANAGER_BACKEND network-manager )
diff --git a/tdecore/tdehw/networkbackends/network-manager/CMakeLists.txt b/tdecore/tdehw/networkbackends/network-manager/CMakeLists.txt
new file mode 100644
index 000000000..f00b5e482
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/CMakeLists.txt
@@ -0,0 +1,36 @@
+#################################################
+#
+# (C) 2013 Golubev Alexander
+# fatzer2 (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( dbus-introspection )
+
+include_directories (
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${DBUS_TQT_INCLUDE_DIRS}
+ ${NM_UTIL_INCLUDE_DIRS}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdecore/tdehw
+ ${CMAKE_CURRENT_BINARY_DIR}/dbus-introspection
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+ ${DBUS_TQT_LIBRARY_DIRS}
+)
+
+tde_add_library( network_manager_backend STATIC_PIC AUTOMOC
+ SOURCES network-manager.cpp
+ EMBED tdenm_dbus-static
+ LINK tdenm_dbus-static ${DBUS_TQT_LIBRARIES}
+)
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/CMakeLists.txt b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/CMakeLists.txt
new file mode 100644
index 000000000..144d56569
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/CMakeLists.txt
@@ -0,0 +1,90 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TQT_INCLUDE_DIRS}
+ ${DBUS_TQT_INCLUDE_DIRS}
+)
+
+
+##### tdenm_dbus (static) #########################
+
+set( INTROSPECTIONPATH ${CMAKE_CURRENT_SOURCE_DIR} )
+
+# options:
+# p - generate proxy files
+# i - generate interface files
+# n - generate node files
+
+function( add_dbus_xml option basename classname namespace xmlfile )
+ if( classname )
+ set( classname -c ${classname} )
+ endif( )
+ add_custom_command( OUTPUT ${basename}.cpp ${basename}.h
+ COMMAND ${DBUSXML2QT3_EXECUTABLE} -${option} ${basename} ${classname} -N ${namespace} ${INTROSPECTIONPATH}/${xmlfile} 2>/dev/null
+ DEPENDS ${INTROSPECTIONPATH}/${xmlfile} )
+endfunction( )
+
+add_dbus_xml( p networkmanagerproxy NetworkManagerProxy DBus nm-manager.xml )
+add_dbus_xml( p networkmanagerpppproxy NetworkManagerPPPProxy DBus nm-ppp-manager.xml )
+add_dbus_xml( p deviceproxy DeviceProxy DBus nm-device.xml )
+add_dbus_xml( p wifiproxy WiFiDeviceProxy DBus nm-device-wifi.xml )
+add_dbus_xml( p wimaxproxy WiMaxDeviceProxy DBus nm-device-wimax.xml )
+add_dbus_xml( p olpcmeshproxy OlpcMeshDeviceProxy DBus nm-device-olpc-mesh.xml )
+add_dbus_xml( p bluetoothproxy BluetoothDeviceProxy DBus nm-device-bt.xml )
+add_dbus_xml( p ethernetproxy EthernetDeviceProxy DBus nm-device-ethernet.xml )
+add_dbus_xml( p infinibandproxy InfinibandDeviceProxy DBus nm-device-infiniband.xml )
+add_dbus_xml( p modemproxy ModemDeviceProxy DBus nm-device-modem.xml )
+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( 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 bluetoothproxy.h olpcmeshproxy.h ethernetproxy.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 )
+ set( _moc_file ${_basename}.moc )
+ list( APPEND _moc_files ${_moc_file} )
+ add_custom_command( OUTPUT ${_moc_file}
+ COMMAND ${TMOC_EXECUTABLE} ${_header_file} -o ${_moc_file}
+ DEPENDS ${_header_file} )
+endforeach( )
+
+add_custom_command( OUTPUT mocfiles.cpp
+ COMMAND cat ${_moc_files} > mocfiles.cpp
+ DEPENDS ${_moc_files} )
+
+# tde_automoc( accesspointproxy.h deviceproxy.h networkmanagerproxy.h
+# networkmanagerpppproxy.h bluetoothproxy.h olpcmeshproxy.h
+# ethernetproxy.h infinibandproxy.h wifiproxy.h wimaxproxy.h
+# activeconnectionproxy.h vpnconnectionproxy.h vpnpluginproxy.h
+# modemproxy.h networkmanagersettings.h connectionsettings.h )
+
+# build the library
+
+tde_add_library( tdenm_dbus STATIC_PIC
+ SOURCES
+ networkmanagerproxy.cpp networkmanagerpppproxy.cpp
+ deviceproxy.cpp bluetoothproxy.cpp olpcmeshproxy.cpp ethernetproxy.cpp
+ infinibandproxy.cpp wifiproxy.cpp wimaxproxy.cpp accesspointproxy.cpp
+ networkmanagersettings.cpp connectionsettings.cpp
+ mocfiles.cpp activeconnectionproxy.cpp vpnconnectionproxy.cpp
+ vpnpluginproxy.cpp modemproxy.cpp
+)
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-access-point.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-access-point.xml
new file mode 100644
index 000000000..21f238ffa
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-access-point.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.AccessPoint">
+ <property name="Flags" type="u" access="read" tp:type="NM_802_11_AP_FLAGS">
+ <tp:docstring>Flags describing the capabilities of the access point.</tp:docstring>
+ </property>
+ <property name="WpaFlags" type="u" access="read" tp:type="NM_802_11_AP_SEC">
+ <tp:docstring>Flags describing the access point's capabilities according to WPA (Wifi Protected Access).</tp:docstring>
+ </property>
+ <property name="RsnFlags" type="u" access="read" tp:type="NM_802_11_AP_SEC">
+ <tp:docstring>Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol.</tp:docstring>
+ </property>
+ <property name="Ssid" type="ay" access="read">
+ <tp:docstring>The Service Set Identifier identifying the access point.</tp:docstring>
+ </property>
+ <property name="Frequency" type="u" access="read">
+ <tp:docstring>The radio channel frequency in use by the access point, in MHz.</tp:docstring>
+ </property>
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>The hardware address (BSSID) of the access point.</tp:docstring>
+ </property>
+
+ <property name="Mode" type="u" access="read" tp:type="NM_802_11_MODE">
+ <tp:docstring>Describes the operating mode of the access point.</tp:docstring>
+ </property>
+ <property name="MaxBitrate" type="u" access="read">
+ <tp:docstring>The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).</tp:docstring>
+ </property>
+ <property name="Strength" type="y" access="read">
+ <tp:docstring>The current signal quality of the access point, in percent.</tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+ <tp:flags name="NM_802_11_AP_FLAGS" value-prefix="NM_802_11_AP_FLAGS" type="u">
+ <tp:docstring>
+ Flags describing the general capabilities of the access point.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>Null capability - says nothing about the access point.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PRIVACY" value="0x1">
+ <tp:docstring>Access point supports privacy measures.</tp:docstring>
+ </tp:flag>
+ </tp:flags>
+ <tp:flags name="NM_802_11_AP_SEC" value-prefix="NM_802_11_AP_SEC" type="u">
+ <tp:docstring>
+ Flags describing the security capabilities of the access point.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>Null flag.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PAIR_WEP40" value="0x1">
+ <tp:docstring>Access point supports pairwise 40-bit WEP encryption.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PAIR_WEP104" value="0x2">
+ <tp:docstring>Access point supports pairwise 104-bit WEP encryption.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PAIR_TKIP" value="0x4">
+ <tp:docstring>Access point supports pairwise TKIP encryption.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PAIR_CCMP" value="0x8">
+ <tp:docstring>Access point supports pairwise CCMP encryption.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="GROUP_WEP40" value="0x10">
+ <tp:docstring>Access point supports a group 40-bit WEP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="GROUP_WEP104" value="0x20">
+ <tp:docstring>Access point supports a group 104-bit WEP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="GROUP_TKIP" value="0x40">
+ <tp:docstring>Access point supports a group TKIP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="GROUP_CCMP" value="0x80">
+ <tp:docstring>Access point supports a group CCMP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="KEY_MGMT_PSK" value="0x100">
+ <tp:docstring>Access point supports PSK key management.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="KEY_MGMT_802_1X" value="0x200">
+ <tp:docstring>Access point supports 802.1x key management.</tp:docstring>
+ </tp:flag>
+ </tp:flags>
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-active-connection.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-active-connection.xml
new file mode 100644
index 000000000..ef01ab160
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-active-connection.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Connection.Active">
+ <tp:docstring>
+ Objects that implement the Connection.Active interface represent an attempt
+ to connect to a network using the details provided by a Connection object.
+ The Connection.Active object tracks the life-cycle of the connection
+ attempt and if successful indicates whether the connected network is the
+ "default" or preferred network for access.
+ </tp:docstring>
+
+ <property name="Connection" type="o" access="read">
+ <tp:docstring>The path of the connection.</tp:docstring>
+ </property>
+ <property name="SpecificObject" type="o" access="read">
+ <tp:docstring>A specific object associated with the active connection.</tp:docstring>
+ </property>
+ <property name="Uuid" type="s" access="read">
+ <tp:docstring>
+ The UUID of the connection, provided as a convenience so that clients
+ do not have to retrieve all connection details.
+ </tp:docstring>
+ </property>
+ <property name="Devices" type="ao" access="read">
+ <tp:docstring>Array of object paths representing devices which are part of this active connection.</tp:docstring>
+ </property>
+ <property name="State" type="u" access="read" tp:type="NM_ACTIVE_CONNECTION_STATE">
+ <tp:docstring>The state of this active connection.</tp:docstring>
+ </property>
+ <property name="Default" type="b" access="read">
+ <tp:docstring>Whether this active connection is the default IPv4 connection, i.e. whether it currently owns the default IPv4 route.</tp:docstring>
+ </property>
+ <property name="Default6" type="b" access="read">
+ <tp:docstring>Whether this active connection is the default IPv6 connection, i.e. whether it currently owns the default IPv6 route.</tp:docstring>
+ </property>
+ <property name="Vpn" type="b" access="read">
+ <tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>
+ </property>
+ <property name="Master" type="o" access="read">
+ <tp:docstring>The path to the master device if the connection is a slave.</tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:enum name="NM_ACTIVE_CONNECTION_STATE" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The active connection is in an unknown state.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ACTIVATING" value="1">
+ <tp:docstring>
+ The connection is activating.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ACTIVATED" value="2">
+ <tp:docstring>
+ The connection is activated.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DEACTIVATING" value="3">
+ <tp:docstring>
+ The connection is being torn down and cleaned up.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-agent-manager.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-agent-manager.xml
new file mode 100644
index 000000000..e26caacf4
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-agent-manager.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/org/freedesktop/NetworkManager/AgentManager" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.AgentManager">
+
+ <method name="Register">
+ <tp:docstring>
+ Called by secret Agents to register their ability to provide and save
+ network secrets.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_register"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="identifier" type="s" direction="in">
+ <tp:docstring>
+ Identifies this agent; only one agent in each user session may use the
+ same identifier. Identifier formatting follows the same rules as
+ D-Bus bus names with the exception that the ':' character is not
+ allowed. The valid set of characters is "[A-Z][a-z][0-9]_-." and the
+ identifier is limited in length to 255 characters with a minimum
+ of 3 characters. An example valid identifier is 'org.gnome.nm-applet'
+ (without quotes).
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="Unregister">
+ <tp:docstring>
+ Called by secret Agents to notify NetworkManager that they will no
+ longer handle requests for network secrets. Agents are automatically
+ unregistered when they disconnect from D-Bus.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_unregister"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ </method>
+
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-adsl.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-adsl.xml
new file mode 100644
index 000000000..ec50d1104
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-adsl.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Adsl">
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <property name="Carrier" type="b" access="read">
+ <tp:docstring>
+ Indicates whether the physical carrier is found.
+ </tp:docstring>
+ </property>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bond.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bond.xml
new file mode 100644
index 000000000..9d200ef8f
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bond.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Bond">
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Carrier" type="b" access="read">
+ <tp:docstring>
+ Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bt.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bt.xml
new file mode 100644
index 000000000..cc4a9b544
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-bt.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Bluetooth">
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Bluetooth hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Name" type="s" access="read">
+ <tp:docstring>
+ Bluetooth name of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="BtCapabilities" type="u" access="read" tp:type="NM_BT_CAPABILITIES">
+ <tp:docstring>
+ Bluetooth capabilities of the device (either DUN or NAP).
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:flags name="NM_BT_CAPABILITIES" value-prefix="NM_BT_CAPABILITY" type="u">
+ <tp:docstring>
+ Flags describing the capabilities of a Bluetooth device.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>The device has no recognized capabilities.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="DUN" value="0x1">
+ <tp:docstring>The device supports Bluetooth Dial-Up Networking.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PAN" value="0x2">
+ <tp:docstring>The device supports Bluetooth Personal Area Networking.</tp:docstring>
+ </tp:flag>
+ </tp:flags>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-ethernet.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-ethernet.xml
new file mode 100644
index 000000000..000caf752
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-ethernet.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Wired">
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Active hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="PermHwAddress" type="s" access="read">
+ <tp:docstring>
+ Permanent hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Speed" type="u" access="read">
+ <tp:docstring>
+ Design speed of the device, in megabits/second (Mb/s).
+ </tp:docstring>
+ </property>
+
+ <property name="Carrier" type="b" access="read">
+ <tp:docstring>
+ Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-infiniband.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-infiniband.xml
new file mode 100644
index 000000000..097714c69
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-infiniband.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Infiniband">
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Carrier" type="b" access="read">
+ <tp:docstring>
+ Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-modem.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-modem.xml
new file mode 100644
index 000000000..0ca101fd7
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-modem.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Modem">
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <property name="ModemCapabilities" type="u" access="read" tp:type="NM_DEVICE_MODEM_CAPABILITIES">
+ <tp:docstring>
+ The generic family of access technologies the modem supports. Not all
+ capabilities are available at the same time however; some modems require
+ a firmware reload or other reinitialization to switch between eg CDMA/EVDO
+ and GSM/UMTS.
+ </tp:docstring>
+ </property>
+
+ <property name="CurrentCapabilities" type="u" access="read" tp:type="NM_DEVICE_MODEM_CAPABILITIES">
+ <tp:docstring>
+ The generic family of access technologies the modem currently supports
+ without a firmware reload or reinitialization.
+ </tp:docstring>
+ </property>
+
+ <tp:flags name="NM_DEVICE_MODEM_CAPABILITIES" value-prefix="NM_DEVICE_MODEM_CAPABILITY" type="u">
+ <tp:docstring>
+ Flags describing one or more of the general access technology families
+ that a modem device supports.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>Modem has no capabilties.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="POTS" value="0x1">
+ <tp:docstring>
+ Modem supports the analog wired telephone network (ie 56k dialup) and
+ does not have wireless/cellular capabilities.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CDMA_EVDO" value="0x2">
+ <tp:docstring>
+ Modem supports at least one of CDMA 1xRTT, EVDO revision 0, EVDO
+ revision A, or EVDO revision B.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="GSM_UMTS" value="0x4">
+ <tp:docstring>
+ Modem supports at least one of GSM, GPRS, EDGE, UMTS, HSDPA, HSUPA, or
+ HSPA+ packet switched data capability.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="LTE" value="0x8">
+ <tp:docstring>
+ Modem has at LTE data capability.
+ </tp:docstring>
+ </tp:flag>
+ </tp:flags>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-olpc-mesh.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-olpc-mesh.xml
new file mode 100644
index 000000000..c30ecfc60
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-olpc-mesh.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.OlpcMesh">
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ The hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Companion" type="o" access="read">
+ <tp:docstring>
+ The object path of the companion device.
+ </tp:docstring>
+ </property>
+
+ <property name="ActiveChannel" type="u" access="read">
+ <tp:docstring>
+ The currently active channel.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary containing the FIXME: check changed parameters.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when the wireless device's properties changed.
+ </tp:docstring>
+ </signal>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-vlan.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-vlan.xml
new file mode 100644
index 000000000..54b7bbe48
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-vlan.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Vlan">
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Carrier" type="b" access="read">
+ <tp:docstring>
+ Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
+ </tp:docstring>
+ </property>
+
+ <property name="VlanId" type="u" access="read">
+ <tp:docstring>
+ The VLAN ID of this VLAN interface.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wifi.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wifi.xml
new file mode 100644
index 000000000..531fc8930
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wifi.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.Wireless">
+ <method name="GetAccessPoints">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_access_points"/>
+ <arg name="access_points" type="ao" direction="out">
+ <tp:docstring>
+ List of access point object paths
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Get the list of access points visible to this device.
+ </tp:docstring>
+ </method>
+
+ <method name="RequestScan">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_request_scan"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="options" type="a{sv}" direction="in">
+ <tp:docstring>
+ Options of scan
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Request the device to scan
+ </tp:docstring>
+ </method>
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ The active hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="PermHwAddress" type="s" access="read">
+ <tp:docstring>
+ The permanent hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="Mode" type="u" access="read" tp:type="NM_802_11_MODE">
+ <tp:docstring>
+ The operating mode of the wireless device.
+ </tp:docstring>
+ </property>
+
+ <property name="Bitrate" type="u" access="read">
+ <tp:docstring>
+ The bit rate currently used by the wireless device, in kilobits/second (Kb/s).
+ </tp:docstring>
+ </property>
+ <property name="ActiveAccessPoint" type="o" access="read">
+ <tp:docstring>
+ Object path of the access point currently used by the wireless device.
+ </tp:docstring>
+ </property>
+ <property name="WirelessCapabilities" type="u" access="read" tp:type="NM_802_11_DEVICE_CAP">
+ <tp:docstring>
+ The capabilities of the wireless device.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary containing the FIXME: check changed parameters.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when the wireless device's properties changed.
+ </tp:docstring>
+ </signal>
+
+ <signal name="AccessPointAdded">
+ <arg name="access_point" type="o">
+ <tp:docstring>
+ The object path of the newly found access point.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when a new access point is found by the device.
+ </tp:docstring>
+ </signal>
+
+ <signal name="AccessPointRemoved">
+ <arg name="access_point" type="o">
+ <tp:docstring>
+ The object path of the access point that has disappeared.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when an access point disappears from view of the device.
+ </tp:docstring>
+ </signal>
+
+ <tp:flags name="NM_802_11_DEVICE_CAP" type="u">
+ <tp:docstring>
+ Flags describing the capabilities of a wireless device.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>Null capability - syntactic sugar for no capabilities supported. Do not AND this with other capabilities!</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CIPHER_WEP40" value="0x1">
+ <tp:docstring>The device supports the 40-bit WEP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CIPHER_WEP104" value="0x2">
+ <tp:docstring>The device supports the 104-bit WEP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CIPHER_TKIP" value="0x4">
+ <tp:docstring>The device supports the TKIP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CIPHER_CCMP" value="0x8">
+ <tp:docstring>The device supports the CCMP cipher.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="WPA" value="0x10">
+ <tp:docstring>The device supports the WPA encryption/authentication protocol.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="RSN" value="0x20">
+ <tp:docstring>The device supports the RSN encryption/authentication protocol.</tp:docstring>
+ </tp:flag>
+ </tp:flags>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wimax.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wimax.xml
new file mode 100644
index 000000000..6e414087f
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device-wimax.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device.WiMax">
+ <method name="GetNspList">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_nsp_list"/>
+ <arg name="nsps" type="ao" direction="out">
+ <tp:docstring>
+ List of NSP object paths
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Get the list of NSPs visible to this device.
+ </tp:docstring>
+ </method>
+
+ <property name="HwAddress" type="s" access="read">
+ <tp:docstring>
+ Hardware address of the device.
+ </tp:docstring>
+ </property>
+
+ <property name="CenterFrequency" type="u" access="read">
+ <tp:docstring>
+ Center frequency (in KHz) of the radio channel the device is using to
+ communicate with the network when connected. Has no meaning when the
+ device is not connected.
+ </tp:docstring>
+ </property>
+
+ <property name="Rssi" type="i" access="read">
+ <tp:docstring>
+ RSSI of the current radio link in dBm. This value indicates how strong
+ the raw received RF signal from the base station is, but does not
+ indicate the overall quality of the radio link. Has no meaning when the
+ device is not connected.
+ </tp:docstring>
+ </property>
+
+ <property name="Cinr" type="i" access="read">
+ <tp:docstring>
+ CINR (Carrier to Interference + Noise Ratio) of the current radio link
+ in dB. CINR is a more accurate measure of radio link quality. Has no
+ meaning when the device is not connected.
+ </tp:docstring>
+ </property>
+
+ <property name="TxPower" type="i" access="read">
+ <tp:docstring>
+ Average power of the last burst transmitted by the device, in units of
+ 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
+ -5.5 dBm. Has no meaning when the device is not connected.
+ </tp:docstring>
+ </property>
+
+ <property name="Bsid" type="s" access="read">
+ <tp:docstring>
+ The ID of the serving base station as received from the network. Has
+ no meaning when the device is not connected.
+ </tp:docstring>
+ </property>
+
+ <property name="ActiveNsp" type="o" access="read">
+ <tp:docstring>
+ Object path of the NSP currently used by the WiMax device.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when the WiMax device's properties changed.
+ </tp:docstring>
+ </signal>
+
+ <signal name="NspAdded">
+ <arg name="nsp" type="o">
+ <tp:docstring>
+ The object path of the newly found NSP.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when a new NSP is found by the device.
+ </tp:docstring>
+ </signal>
+
+ <signal name="NspRemoved">
+ <arg name="nsp" type="o">
+ <tp:docstring>
+ The object path of the NSP that has disappeared.
+ </tp:docstring>
+ </arg>
+ <tp:docstring>
+ Emitted when an NSP disappears from view of the device.
+ </tp:docstring>
+ </signal>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device.xml
new file mode 100644
index 000000000..5b2c98b3c
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-device.xml
@@ -0,0 +1,577 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Device">
+ <property name="Udi" type="s" access="read">
+ <tp:docstring>
+ Operating-system specific transient device hardware identifier. This
+ is an opaque string representing the underlying hardware for the device,
+ and shouldn't be used to keep track of individual devices. For some
+ device types (Bluetooth, Modems) it is an identifier used by the
+ hardware service (ie bluez or ModemManager) to refer to that device,
+ and client programs use it get additional information from those
+ services which NM does not provide. The Udi is not guaranteed to be
+ consistent across reboots or hotplugs of the hardware. If you're looking
+ for a way to uniquely track each device in your application, use the
+ object path. If you're looking for a way to track a specific piece of
+ hardware across reboot or hotplug, use a MAC address or USB serial
+ number.
+ </tp:docstring>
+ </property>
+ <property name="Interface" type="s" access="read">
+ <tp:docstring>
+ The name of the device's control (and often data) interface.
+ </tp:docstring>
+ </property>
+ <property name="IpInterface" type="s" access="read">
+ <tp:docstring>
+ The name of the device's data interface when available. This property
+ may not refer to the actual data interface until the device has
+ successfully established a data connection, indicated by the device's
+ State becoming ACTIVATED.
+ </tp:docstring>
+ </property>
+ <property name="Driver" type="s" access="read">
+ <tp:docstring>
+ The driver handling the device.
+ </tp:docstring>
+ </property>
+ <property name="DriverVersion" type="s" access="read">
+ <tp:docstring>
+ The version of the driver handling the device.
+ </tp:docstring>
+ </property>
+ <property name="FirmwareVersion" type="s" access="read">
+ <tp:docstring>
+ The firmware version for the device.
+ </tp:docstring>
+ </property>
+ <property name="Capabilities" type="u" access="read" tp:type="NM_DEVICE_CAP">
+ <tp:docstring>
+ Flags describing the capabilities of the device.
+ </tp:docstring>
+ </property>
+ <property name="Ip4Address" type="i" access="read">
+ <tp:docstring>
+ The IPv4 address bound to the device. FIXME: what about devices with >1 IP address?
+ </tp:docstring>
+ </property>
+ <property name="State" type="u" access="read" tp:type="NM_DEVICE_STATE">
+ <tp:docstring>
+ The current state of the device.
+ </tp:docstring>
+ </property>
+ <property name="StateReason" type="(uu)" access="read" tp:type="NM_DEVICE_STATE_REASON_STRUCT">
+ <tp:docstring>
+ The current state and reason for changing to that state.
+ </tp:docstring>
+ </property>
+ <property name="ActiveConnection" type="o" access="read">
+ <tp:docstring>
+ Object path of an ActiveConnection object that "owns" this device during
+ activation. The ActiveConnection object tracks the life-cycle of a
+ connection to a specific network and implements the
+ org.freedesktop.NetworkManager.Connection.Active D-Bus interface.
+ </tp:docstring>
+ </property>
+ <property name="Ip4Config" type="o" access="read">
+ <tp:docstring>
+ Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
+ </tp:docstring>
+ </property>
+ <property name="Dhcp4Config" type="o" access="read">
+ <tp:docstring>
+ Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
+ </tp:docstring>
+ </property>
+ <property name="Ip6Config" type="o" access="read">
+ <tp:docstring>
+ Object path of the Ip6Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
+ </tp:docstring>
+ </property>
+ <property name="Dhcp6Config" type="o" access="read">
+ <tp:docstring>
+ Object path of the Dhcp6Config object describing the DHCP options
+ returned by the DHCP server. Only valid when the device is in the
+ NM_DEVICE_STATE_ACTIVATED state.
+ </tp:docstring>
+ </property>
+ <property name="Managed" type="b" access="read">
+ <tp:docstring>
+ Whether or not this device is managed by NetworkManager.
+ </tp:docstring>
+ </property>
+ <property name="Autoconnect" type="b" access="readwrite">
+ <tp:docstring>
+ If TRUE, indicates the device is allowed to autoconnect. If FALSE,
+ manual intervention is required before the device will automatically
+ connect to a known network, such as activating a connection using the
+ device, or setting this property to TRUE.
+ </tp:docstring>
+ </property>
+ <property name="FirmwareMissing" type="b" access="read">
+ <tp:docstring>
+ If TRUE, indicates the device is likely missing firmware necessary for
+ its operation.
+ </tp:docstring>
+ </property>
+ <property name="DeviceType" type="u" access="read" tp:type="NM_DEVICE_TYPE">
+ <tp:docstring>
+ The general type of the network device; ie Ethernet, WiFi, etc.
+ </tp:docstring>
+ </property>
+ <property name="AvailableConnections" type="ao" access="read">
+ <tp:docstring>
+ An array of object paths of every configured connection that is currently 'available' through this device.
+ </tp:docstring>
+ </property>
+
+ <method name="Disconnect">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Disconnects a device and prevents the device from automatically activating further connections without user intervention.
+ </tp:docstring>
+ </method>
+
+ <signal name="StateChanged">
+ <arg name="new_state" type="u" tp:type="NM_DEVICE_STATE">
+ <tp:docstring>
+ The new state of the device.
+ </tp:docstring>
+ </arg>
+ <arg name="old_state" type="u" tp:type="NM_DEVICE_STATE">
+ <tp:docstring>
+ The previous state of the device.
+ </tp:docstring>
+ </arg>
+ <arg name="reason" type="u" tp:type="NM_DEVICE_STATE_REASON">
+ <tp:docstring>
+ A reason for the state transition.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:enum name="NM_DEVICE_STATE" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The device is in an unknown state.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="UNMANAGED" value="10">
+ <tp:docstring>
+ The device is recognized but not managed by NetworkManager.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="UNAVAILABLE" value="20">
+ <tp:docstring>
+ The device cannot be used (carrier off, rfkill, etc).
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DISCONNECTED" value="30">
+ <tp:docstring>
+ The device is not connected.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="PREPARE" value="40">
+ <tp:docstring>
+ The device is preparing to connect.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONFIG" value="50">
+ <tp:docstring>
+ The device is being configured.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NEED_AUTH" value="60">
+ <tp:docstring>
+ The device is awaiting secrets necessary to continue connection.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="IP_CONFIG" value="70">
+ <tp:docstring>
+ The IP settings of the device are being requested and configured.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="IP_CHECK" value="80">
+ <tp:docstring>
+ The device's IP connectivity ability is being determined.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SECONDARIES" value="90">
+ <tp:docstring>
+ The device is waiting for secondary connections to be activated.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ACTIVATED" value="100">
+ <tp:docstring>
+ The device is active.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DEACTIVATING" value="110">
+ <tp:docstring>
+ The device's network connection is being torn down.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="FAILED" value="120">
+ <tp:docstring>
+ The device is in a failure state following an attempt to activate it.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+
+ <tp:enum name="NM_DEVICE_TYPE" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The device type is unknown.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ETHERNET" value="1">
+ <tp:docstring>
+ The device is wired Ethernet device.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="WIFI" value="2">
+ <tp:docstring>
+ The device is an 802.11 WiFi device.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="UNUSED1" value="3">
+ <tp:docstring>Unused</tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="UNUSED2" value="4">
+ <tp:docstring>Unused</tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="BT" value="5">
+ <tp:docstring>
+ The device is Bluetooth device that provides PAN or DUN capabilities.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="OLPC_MESH" value="6">
+ <tp:docstring>
+ The device is an OLPC mesh networking device.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="WIMAX" value="7">
+ <tp:docstring>
+ The device is an 802.16e Mobile WiMAX device.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM" value="8">
+ <tp:docstring>
+ The device is a modem supporting one or more of analog telephone,
+ CDMA/EVDO, GSM/UMTS/HSPA, or LTE standards to access a cellular or
+ wireline data network.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="INFINIBAND" value="9">
+ <tp:docstring>
+ The device is an IP-capable InfiniBand interface.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="BOND" value="10">
+ <tp:docstring>
+ The device is a bond master interface.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="VLAN" value="11">
+ <tp:docstring>
+ The device is a VLAN interface.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ADSL" value="12">
+ <tp:docstring>
+ The device is an ADSL device supporting PPPoE and PPPoATM protocols.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+
+ <tp:flags name="NM_DEVICE_CAP" value-prefix="NM_DEVICE_CAP" type="u">
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>Null capability.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="NM_SUPPORTED" value="0x1">
+ <tp:docstring>The device is supported by NetworkManager.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="CARRIER_DETECT" value="0x2">
+ <tp:docstring>The device supports carrier detection.</tp:docstring>
+ </tp:flag>
+ </tp:flags>
+
+ <tp:enum name="NM_DEVICE_STATE_REASON" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The reason for the device state change is unknown.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NONE" value="1">
+ <tp:docstring>
+ The state change is normal.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NOW_MANAGED" value="2">
+ <tp:docstring>
+ The device is now managed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NOW_UNMANAGED" value="3">
+ <tp:docstring>
+ The device is no longer managed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONFIG_FAILED" value="4">
+ <tp:docstring>
+ The device could not be readied for configuration.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONFIG_UNAVAILABLE" value="5">
+ <tp:docstring>
+ IP configuration could not be reserved (no available address, timeout, etc).
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONFIG_EXPIRED" value="6">
+ <tp:docstring>
+ The IP configuration is no longer valid.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NO_SECRETS" value="7">
+ <tp:docstring>
+ Secrets were required, but not provided.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SUPPLICANT_DISCONNECT" value="8">
+ <tp:docstring>
+ The 802.1X supplicant disconnected from the access point or authentication server.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SUPPLICANT_CONFIG_FAILED" value="9">
+ <tp:docstring>
+ Configuration of the 802.1X supplicant failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SUPPLICANT_FAILED" value="10">
+ <tp:docstring>
+ The 802.1X supplicant quit or failed unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SUPPLICANT_TIMEOUT" value="11">
+ <tp:docstring>
+ The 802.1X supplicant took too long to authenticate.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="PPP_START_FAILED" value="12">
+ <tp:docstring>
+ The PPP service failed to start within the allowed time.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="PPP_DISCONNECT" value="13">
+ <tp:docstring>
+ The PPP service disconnected unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="PPP_FAILED" value="14">
+ <tp:docstring>
+ The PPP service quit or failed unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DHCP_START_FAILED" value="15">
+ <tp:docstring>
+ The DHCP service failed to start within the allowed time.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DHCP_ERROR" value="16">
+ <tp:docstring>
+ The DHCP service reported an unexpected error.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DHCP_FAILED" value="17">
+ <tp:docstring>
+ The DHCP service quit or failed unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SHARED_START_FAILED" value="18">
+ <tp:docstring>
+ The shared connection service failed to start.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SHARED_FAILED" value="19">
+ <tp:docstring>
+ The shared connection service quit or failed unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="AUTOIP_START_FAILED" value="20">
+ <tp:docstring>
+ The AutoIP service failed to start.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="AUTOIP_ERROR" value="21">
+ <tp:docstring>
+ The AutoIP service reported an unexpected error.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="AUTOIP_FAILED" value="22">
+ <tp:docstring>
+ The AutoIP service quit or failed unexpectedly.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_BUSY" value="23">
+ <tp:docstring>
+ Dialing failed because the line was busy.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_NO_DIAL_TONE" value="24">
+ <tp:docstring>
+ Dialing failed because there was no dial tone.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_NO_CARRIER" value="25">
+ <tp:docstring>
+ Dialing failed because there was carrier.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_DIAL_TIMEOUT" value="26">
+ <tp:docstring>
+ Dialing timed out.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_DIAL_FAILED" value="27">
+ <tp:docstring>
+ Dialing failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_INIT_FAILED" value="28">
+ <tp:docstring>
+ Modem initialization failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_APN_FAILED" value="29">
+ <tp:docstring>
+ Failed to select the specified GSM APN.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_REGISTRATION_NOT_SEARCHING" value="30">
+ <tp:docstring>
+ Not searching for networks.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_REGISTRATION_DENIED" value="31">
+ <tp:docstring>
+ Network registration was denied.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_REGISTRATION_TIMEOUT" value="32">
+ <tp:docstring>
+ Network registration timed out.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_REGISTRATION_FAILED" value="33">
+ <tp:docstring>
+ Failed to register with the requested GSM network.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_PIN_CHECK_FAILED" value="34">
+ <tp:docstring>
+ PIN check failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="FIRMWARE_MISSING" value="35">
+ <tp:docstring>
+ Necessary firmware for the device may be missing.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="REMOVED" value="36">
+ <tp:docstring>
+ The device was removed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SLEEPING" value="37">
+ <tp:docstring>
+ NetworkManager went to sleep.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTION_REMOVED" value="38">
+ <tp:docstring>
+ The device's active connection was removed or disappeared.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="USER_REQUESTED" value="39">
+ <tp:docstring>
+ A user or client requested the disconnection.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CARRIER" value="40">
+ <tp:docstring>
+ The device's carrier/link changed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTION_ASSUMED" value="41">
+ <tp:docstring>
+ The device's existing connection was assumed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SUPPLICANT_AVAILABLE" value="42">
+ <tp:docstring>
+ The 802.1x supplicant is now available.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="MODEM_NOT_FOUND" value="43">
+ <tp:docstring>
+ The modem could not be found.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="BT_FAILED" value="44">
+ <tp:docstring>
+ The Bluetooth connection timed out or failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_SIM_NOT_INSERTED" value="45">
+ <tp:docstring>
+ GSM Modem's SIM Card not inserted.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_SIM_PIN_REQUIRED" value="46">
+ <tp:docstring>
+ GSM Modem's SIM Pin required.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_SIM_PUK_REQUIRED" value="47">
+ <tp:docstring>
+ GSM Modem's SIM Puk required.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="GSM_SIM_WRONG" value="48">
+ <tp:docstring>
+ GSM Modem's SIM wrong
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="INFINIBAND_MODE" value="49">
+ <tp:docstring>
+ InfiniBand device does not support connected mode.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DEPENDENCY_FAILED" value="50">
+ <tp:docstring>
+ A dependency of the connection failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="BR2684_FAILED" value="51">
+ <tp:docstring>
+ Problem with the RFC 2684 Ethernet over ADSL bridge.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+
+ <tp:struct name="NM_DEVICE_STATE_REASON_STRUCT">
+ <tp:member type="u" name="state" tp:type="NM_DEVICE_STATE">
+ <tp:docstring>
+ The device state.
+ </tp:docstring>
+ </tp:member>
+ <tp:member type="u" name="reason" tp:type="NM_DEVICE_STATE_REASON">
+ <tp:docstring>
+ The reason for originally changing to the device state.
+ </tp:docstring>
+ </tp:member>
+ </tp:struct>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp4-config.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp4-config.xml
new file mode 100644
index 000000000..c0821ada9
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp4-config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.DHCP4Config">
+ <tp:docstring>
+ Options and configuration returned by the IPv4 DHCP server.
+ </tp:docstring>
+ <property name="Options" type="a{sv}" access="read">
+ <tp:docstring>Configuration options returned by a DHCP server, if any.</tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp6-config.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp6-config.xml
new file mode 100644
index 000000000..93b0f1c8f
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-dhcp6-config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.DHCP6Config">
+ <tp:docstring>
+ Options and configuration returned by the IPv6 DHCP server.
+ </tp:docstring>
+ <property name="Options" type="a{sv}" access="read">
+ <tp:docstring>Configuration options returned by a DHCP server, if any.</tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip4-config.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip4-config.xml
new file mode 100644
index 000000000..70d3e1ce4
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip4-config.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.IP4Config">
+ <property name="Addresses" type="aau" access="read">
+ <tp:docstring>Array of tuples of IPv4 address/prefix/gateway. All 3
+ elements of each tuple are in network byte order. Essentially:
+ [(addr, prefix, gateway), (addr, prefix, gateway), ...]
+ </tp:docstring>
+ </property>
+ <property name="Nameservers" type="au" access="read">
+ <tp:docstring>The nameservers in use.</tp:docstring>
+ </property>
+ <property name="WinsServers" type="au" access="read">
+ <tp:docstring>The Windows Internet Name Service servers associated with the connection. Each address is in network byte order.</tp:docstring>
+ </property>
+ <property name="Domains" type="as" access="read">
+ <tp:docstring>A list of domains this address belongs to.</tp:docstring>
+ </property>
+ <property name="Routes" type="aau" access="read">
+ <tp:docstring>Tuples of IPv4 route/prefix/next-hop/metric. All 4 elements
+ of each tuple are in network byte order. 'route' and 'next hop' are IPv4
+ addresses, while prefix and metric are simple unsigned integers. Essentially:
+ [(route, prefix, next-hop, metric), (route, prefix, next-hop, metric), ...]
+ </tp:docstring>
+ </property>
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip6-config.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip6-config.xml
new file mode 100644
index 000000000..604781857
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ip6-config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.IP6Config">
+ <property name="Addresses" type="a(ayuay)" access="read">
+ <tp:docstring>Tuples of IPv6 address/prefix/gateway.</tp:docstring>
+ </property>
+ <property name="Nameservers" type="aay" access="read">
+ <tp:docstring>The nameservers in use.</tp:docstring>
+ </property>
+ <property name="Domains" type="as" access="read">
+ <tp:docstring>A list of domains this address belongs to.</tp:docstring>
+ </property>
+ <property name="Routes" type="a(ayuayu)" access="read">
+ <tp:docstring>Tuples of IPv6 route/prefix/next-hop/metric.</tp:docstring>
+ </property>
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-manager.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-manager.xml
new file mode 100644
index 000000000..f5fd7abcf
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-manager.xml
@@ -0,0 +1,390 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/org/freedesktop/NetworkManager" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager">
+ <method name="GetDevices">
+ <tp:docstring>
+ Get the list of network devices.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_devices"/>
+ <arg name="devices" type="ao" direction="out">
+ <tp:docstring>
+ List of object paths of network devices known to the system.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="GetDeviceByIpIface">
+ <tp:docstring>
+ Return the object path of the network device referenced by its IP
+ interface name. Note that some devices (usually modems) only have an
+ IP interface name when they are connected.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_device_by_ip_iface"/>
+ <arg name="iface" type="s" direction="in">
+ <tp:docstring>
+ Interface name of the device to find.
+ </tp:docstring>
+ </arg>
+ <arg name="device" type="o" direction="out">
+ <tp:docstring>
+ Object path of the network device.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="ActivateConnection">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_activate_connection"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Activate a connection using the supplied device.
+ </tp:docstring>
+ <arg name="connection" type="o" direction="in">
+ <tp:docstring>
+ The connection to activate the devices with.
+ </tp:docstring>
+ </arg>
+ <arg name="device" type="o" direction="in">
+ <tp:docstring>
+ The object path of device to be activated for physical connections. This parameter is ignored for VPN connections, because the specific_object (if provided) specifies the device to use.
+ </tp:docstring>
+ </arg>
+ <arg name="specific_object" type="o" direction="in">
+ <tp:docstring>
+ The path of a connection-type-specific object this activation should use.
+ This parameter is currently ignored for wired and mobile broadband connections,
+ and the value of "/" should be used (ie, no specific object). For WiFi
+ connections, pass the object path of a specific AP from the card's scan
+ list, or "/" to pick and AP automatically. For VPN connections, pass
+ the object path of an ActiveConnection object that should serve as the
+ "base" connection (to which the VPN connections lifetime will be tied),
+ or pass "/" and NM will automatically use the current default device.
+ </tp:docstring>
+ </arg>
+ <arg name="active_connection" type="o" direction="out">
+ <tp:docstring>
+ The path of the active connection object representing this active connection.
+ </tp:docstring>
+ </arg>
+ <tp:possible-errors>
+ <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/>
+ <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/>
+ <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionActivating">
+ <tp:docstring>Another connection is already activating or the same connection is already active. FIXME: check if the error name is correct. FIXME: split into 2 errors?</tp:docstring>
+ </tp:error>
+ <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid">
+ <tp:docstring>The connection is invalid for this device.</tp:docstring>
+ </tp:error>
+ </tp:possible-errors>
+ </method>
+
+ <method name="AddAndActivateConnection">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_add_and_activate_connection"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Adds a new connection using the given details (if any) as a template
+ (automatically filling in missing settings with the capabilities of the
+ given device and specific object), then activate the new connection.
+ Cannot be used for VPN connections at this time.
+ </tp:docstring>
+ <arg name="connection" type="a{sa{sv}}" direction="in">
+ <tp:docstring>
+ Connection settings and properties; if incomplete missing settings will
+ be automatically completed using the given device and specific object.
+ </tp:docstring>
+ </arg>
+ <arg name="device" type="o" direction="in">
+ <tp:docstring>
+ The object path of device to be activated using the given connection.
+ </tp:docstring>
+ </arg>
+ <arg name="specific_object" type="o" direction="in">
+ <tp:docstring>
+ The path of a connection-type-specific object this activation should use.
+ This parameter is currently ignored for wired and mobile broadband connections,
+ and the value of "/" should be used (ie, no specific object). For WiFi
+ connections, pass the object path of a specific AP from the card's scan
+ list, which will be used to complete the details of the newly added
+ connection.
+ </tp:docstring>
+ </arg>
+ <arg name="path" type="o" direction="out">
+ <tp:docstring>
+ Object path of the new connection that was just added.
+ </tp:docstring>
+ </arg>
+ <arg name="active_connection" type="o" direction="out">
+ <tp:docstring>
+ The path of the active connection object representing this active connection.
+ </tp:docstring>
+ </arg>
+ <tp:possible-errors>
+ <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/>
+ <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/>
+ <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid">
+ <tp:docstring>The connection is invalid for this device.</tp:docstring>
+ </tp:error>
+ </tp:possible-errors>
+ </method>
+
+ <method name="DeactivateConnection">
+ <tp:docstring>
+ Deactivate an active connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="active_connection" type="o" direction="in">
+ <tp:docstring>
+ The currently active connection to deactivate.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="Sleep">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_sleep"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Control the NetworkManager daemon's sleep state. When asleep, all
+ interfaces that it manages are deactivated. When awake, devices are
+ available to be activated. This command should not be called directly
+ by users or clients; it is intended for system suspend/resume tracking.
+ </tp:docstring>
+ <arg name="sleep" type="b" direction="in">
+ <tp:docstring>
+ Indicates whether the NetworkManager daemon should sleep or wake.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="Enable">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_enable"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Control whether overall networking is enabled or disabled. When
+ disabled, all interfaces that NM manages are deactivated. When enabled,
+ all managed interfaces are re-enabled and available to be activated.
+ This command should be used by clients that provide to users the ability
+ to enable/disable all networking.
+ </tp:docstring>
+ <arg name="enable" type="b" direction="in">
+ <tp:docstring>
+ If FALSE, indicates that all networking should be disabled. If TRUE,
+ indicates that NetworkManager should begin managing network devices.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="GetPermissions">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_permissions"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <tp:docstring>
+ Returns the permissions a caller has for various authenticated operations
+ that NetworkManager provides, like Enable/Disable networking, changing
+ WiFi, WWAN, and WiMAX state, etc.
+ </tp:docstring>
+ <arg name="permissions" type="a{ss}" direction="out">
+ <tp:docstring>
+ Dictionary of available permissions and results. Each permission
+ is represented by a name (ie "org.freedesktop.NetworkManager.Foobar")
+ and each result is one of the following values: "yes" (the permission
+ is available), "auth" (the permission is available after a successful
+ authentication), or "no" (the permission is denied). Clients may use
+ these values in the UI to indicate the ability to perform certain
+ operations.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <signal name="CheckPermissions">
+ <tp:docstring>
+ Emitted when system authorization details change, indicating that
+ clients may wish to recheck permissions with GetPermissions.
+ </tp:docstring>
+ </signal>
+
+ <method name="SetLogging">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_set_logging"/>
+ <tp:docstring>
+ Set logging verbosity and which operations are logged.
+ </tp:docstring>
+ <arg name="level" type="s" direction="in">
+ <tp:docstring>
+ One of [ERR, WARN, INFO, DEBUG].
+ </tp:docstring>
+ </arg>
+ <arg name="domains" type="s" direction="in">
+ <tp:docstring>
+ A combination of logging domains separated by commas (','), or "NONE"
+ to disable logging. Each domain enables logging for operations
+ related to that domain. Available domains are: [NONE, HW, RFKILL,
+ ETHER, WIFI, BT, MB, DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4,
+ DNS, VPN, SHARING, SUPPLICANT, USER_SET, SYS_SET, SUSPEND, CORE,
+ DEVICE, OLPC]. If an empty string is given, the log level is changed
+ but the current set of log domains remains unchanged.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="state">
+ <tp:docstring>
+ The overall networking state as determined by the NetworkManager daemon,
+ based on the state of network devices under it's management.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_state"/>
+ <arg name="state" type="u" direction="out" tp:type="NM_STATE"/>
+ </method>
+
+ <property name="NetworkingEnabled" type="b" access="read">
+ <tp:docstring>
+ Indicates if overall networking is currently enabled or not. See the
+ Enable() method.
+ </tp:docstring>
+ </property>
+
+ <property name="WirelessEnabled" type="b" access="readwrite">
+ <tp:docstring>
+ Indicates if wireless is currently enabled or not.
+ </tp:docstring>
+ </property>
+
+ <property name="WirelessHardwareEnabled" type="b" access="read">
+ <tp:docstring>
+ Indicates if the wireless hardware is currently enabled, i.e. the state of the RF kill switch.
+ </tp:docstring>
+ </property>
+
+ <property name="WwanEnabled" type="b" access="readwrite">
+ <tp:docstring>
+ Indicates if mobile broadband devices are currently enabled or not.
+ </tp:docstring>
+ </property>
+
+ <property name="WwanHardwareEnabled" type="b" access="read">
+ <tp:docstring>
+ Indicates if the mobile broadband hardware is currently enabled, i.e. the state of the RF kill switch.
+ </tp:docstring>
+ </property>
+
+ <property name="WimaxEnabled" type="b" access="readwrite">
+ <tp:docstring>
+ Indicates if WiMAX devices are currently enabled or not.
+ </tp:docstring>
+ </property>
+
+ <property name="WimaxHardwareEnabled" type="b" access="read">
+ <tp:docstring>
+ Indicates if the WiMAX hardware is currently enabled, i.e. the state of the RF kill switch.
+ </tp:docstring>
+ </property>
+
+ <property name="ActiveConnections" type="ao" access="read">
+ <tp:docstring>
+ List of active connection object paths.
+ </tp:docstring>
+ </property>
+
+ <property name="Version" type="s" access="read">
+ <tp:docstring>
+ NetworkManager version.
+ </tp:docstring>
+ </property>
+
+ <property name="State" type="u" access="read" tp:type="NM_STATE">
+ <tp:docstring>
+ The overall state of the NetworkManager daemon.
+ </tp:docstring>
+ </property>
+
+ <signal name="StateChanged">
+ <tp:docstring>
+ NetworkManager's state changed.
+ </tp:docstring>
+ <arg name="state" type="u" tp:type="NM_STATE">
+ <tp:docstring>
+ The new state of NetworkManager.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="PropertiesChanged">
+ <tp:docstring>
+ NetworkManager's properties changed.
+ </tp:docstring>
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ The changed properties.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="DeviceAdded">
+ <tp:docstring>
+ A device was added to the system
+ </tp:docstring>
+ <arg name="device_path" type="o">
+ <tp:docstring>
+ The object path of the newly added device.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="DeviceRemoved">
+ <tp:docstring>
+ A device was removed from the system, and is no longer available.
+ </tp:docstring>
+ <arg name="device_path" type="o">
+ <tp:docstring>
+ The object path of the device that was just removed.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:enum name="NM_STATE" type="u">
+ <tp:docstring>
+ Describes the overall state of the daemon.
+ </tp:docstring>
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ Networking state is unknown.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ASLEEP" value="10">
+ <tp:docstring>
+ Networking is inactive and all devices are disabled.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DISCONNECTED" value="20">
+ <tp:docstring>
+ There is no active network connection.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DISCONNECTING" value="30">
+ <tp:docstring>
+ Network connections are being cleaned up.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTING" value="40">
+ <tp:docstring>
+ A network device is connecting to a network and there is no other
+ available network connection.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTED_LOCAL" value="50">
+ <tp:docstring>
+ A network device is connected, but there is only link-local connectivity.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTED_SITE" value="60">
+ <tp:docstring>
+ A network device is connected, but there is only site-local connectivity.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTED_GLOBAL" value="70">
+ <tp:docstring>
+ A network device is connected, with global network connectivity.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ppp-manager.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ppp-manager.xml
new file mode 100644
index 000000000..9e2dfdb1c
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-ppp-manager.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/">
+ <interface name="org.freedesktop.NetworkManager.PPP">
+ <method name="NeedSecrets">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_need_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="username" type="s" direction="out"/>
+ <arg name="password" type="s" direction="out"/>
+ </method>
+
+ <method name="SetIp4Config">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_set_ip4_config"/>
+ <arg name="config" type="a{sv}" direction="in"/>
+ </method>
+
+ <method name="SetState">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_set_state"/>
+ <arg name="state" type="u" direction="in"/>
+ </method>
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-secret-agent.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-secret-agent.xml
new file mode 100644
index 000000000..81a1321b1
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-secret-agent.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+
+ <interface name="org.freedesktop.NetworkManager.SecretAgent">
+ <tp:docstring>
+ Private D-Bus interface used by secret agents that store and provide
+ secrets to NetworkManager. If an agent provides secrets to
+ NetworkManager as part of connection creation, and the some of those
+ secrets are "agent owned" the agent should store those secrets
+ itself and should not expect its SaveSecrets() method to be called.
+ SaveSecrets() will be called eg if some program other than the
+ agent itself (like a connection editor) changes the secrets out of
+ band.
+ </tp:docstring>
+
+ <method name="GetSecrets">
+ <tp:docstring>
+ Retrieve and return stored secrets, if any, or request new
+ secrets from the agent's user.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_secret_agent_get_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="connection" type="a{sa{sv}}" direction="in" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Nested settings maps containing the connection for which
+ secrets are being requested. This may contain system-owned
+ secrets if the agent has successfully authenticated to
+ modify system network settings and the GetSecrets request
+ flags allow user interaction.
+ </tp:docstring>
+ </arg>
+ <arg name="connection_path" type="o" direction="in">
+ <tp:docstring>
+ Object path of the connection for which secrets are being
+ requested.
+ </tp:docstring>
+ </arg>
+ <arg name="setting_name" type="s" direction="in">
+ <tp:docstring>
+ Setting name for which secrets are being requested.
+ </tp:docstring>
+ </arg>
+ <arg name="hints" type="as" direction="in">
+ <tp:docstring>
+ Array of strings of key names in the requested setting for
+ which NetworkManager thinks a secrets may be required,
+ and/or well-known identifiers and data that may be useful
+ to the client in processing the secrets request. The Agent
+ should return any secrets it has, or that it thinks are
+ required, regardless of what hints NetworkManager sends
+ in this request.
+ </tp:docstring>
+ </arg>
+ <arg name="flags" type="u" direction="in" tp:type="NM_SECRET_AGENT_GET_SECRETS_FLAGS">
+ <tp:docstring>
+ Flags which modify the behavior of the secrets request.
+ If true, new secrets are assumed to be invalid or incorrect,
+ and the agent should ask the user for new secrets. If false,
+ existing secrets should be retrieved from storage and
+ returned without interrupting the user.
+ </tp:docstring>
+ </arg>
+
+ <arg name="secrets" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Nested settings maps containing secrets. Each setting MUST
+ contain at least the 'name' field, containing the name of
+ the setting, and one or more secrets.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <tp:flags name="NM_SECRET_AGENT_GET_SECRETS_FLAGS" value-prefix="NM_SECRET_AGENT_GET_SECRETS_FLAG" type="u">
+ <tp:docstring>
+ Flags modifying the behavior of GetSecrets request.
+ </tp:docstring>
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>
+ No special behavior; by default no user interaction is allowed and
+ requests for secrets are fulfilled from persistent storage, or
+ if no secrets are available an error is returned.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="ALLOW_INTERACTION" value="0x1">
+ <tp:docstring>
+ Allows the request to interact with the user, possibly prompting
+ via UI for secrets if any are required, or if none are found in
+ persistent storage.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="REQUEST_NEW" value="0x2">
+ <tp:docstring>
+ Explicitly prompt for new secrets from the user. This flag
+ signals that NetworkManager thinks any existing secrets are
+ invalid or wrong. This flag implies that interaction is allowed.
+ </tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="USER_REQUESTED" value="0x4">
+ <tp:docstring>
+ Set if the request was initiated by user-requested action via the
+ D-Bus interface, as opposed to automatically initiated by
+ NetworkManager in response to (for example) scan results or
+ carrier changes.
+ </tp:docstring>
+ </tp:flag>
+ </tp:flags>
+
+ <method name="CancelGetSecrets">
+ <tp:docstring>
+ Cancel a pending GetSecrets request for secrets of the given
+ connection. Any matching request should be canceled.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_secret_agent_cancel_get_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="connection_path" type="o" direction="in">
+ <tp:docstring>
+ Object path of the connection for which, if secrets are being
+ requested, the request should be canceled.
+ </tp:docstring>
+ </arg>
+ <arg name="setting_name" type="s" direction="in">
+ <tp:docstring>
+ Setting name for which secrets for this connection were
+ originally being requested.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="SaveSecrets">
+ <tp:docstring>
+ Save given secrets to backing storage.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_secret_agent_save_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="connection" type="a{sa{sv}}" direction="in" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Nested settings maps containing the entire connection
+ (including secrets), for which the agent should save the
+ secrets to backing storage. This method will not be called
+ when the agent itself is the process creating or updating
+ a connection; in that case the agent is assumed to have
+ already saved those secrets since it had them already.
+ </tp:docstring>
+ </arg>
+ <arg name="connection_path" type="o" direction="in">
+ <tp:docstring>
+ Object path of the connection for which the agent should
+ save secrets to backing storage.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="DeleteSecrets">
+ <tp:docstring>
+ Delete secrets from backing storage.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_secret_agent_delete_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="connection" type="a{sa{sv}}" direction="in" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Nested settings maps containing the connection properties
+ (sans secrets), for which the agent should delete the
+ secrets from backing storage.
+ </tp:docstring>
+ </arg>
+ <arg name="connection_path" type="o" direction="in">
+ <tp:docstring>
+ Object path of the connection for which the agent should
+ delete secrets from backing storage.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ </interface>
+
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings-connection.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings-connection.xml
new file mode 100644
index 000000000..9089b009a
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings-connection.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+
+ <interface name="org.freedesktop.NetworkManager.Settings.Connection">
+ <tp:docstring>
+ Represents a single network connection configuration.
+ </tp:docstring>
+
+ <method name="Update">
+ <tp:docstring>
+ Update the connection with new settings and properties, replacing
+ all previous settings and properties. Secrets may be part of the
+ update request, and will be either stored in persistent storage or
+ given to a Secret Agent for storage, depending on the request.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_update"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="properties" type="a{sa{sv}}" direction="in">
+ <tp:docstring>
+ New connection settings, properties, and (optionally) secrets.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="Delete">
+ <tp:docstring>
+ Delete the connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_delete"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ </method>
+
+ <method name="GetSettings">
+ <tp:docstring>
+ Get the settings maps describing this network configuration.
+ This will never include any secrets required for connection
+ to the network, as those are often protected. Secrets must
+ be requested separately using the GetSecrets() call.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_get_settings"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ The nested settings maps describing this object.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="GetSecrets">
+ <tp:docstring>
+ Get the secrets belonging to this network configuration. Only
+ secrets from persistent storage or a Secret Agent running in
+ the requestor's session will be returned. The user will never
+ be prompted for secrets as a result of this request.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_get_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="setting_name" type="s" direction="in">
+ <tp:docstring>
+ Name of the setting to return secrets for. If empty, all
+ all secrets will be returned.
+ </tp:docstring>
+ </arg>
+
+ <arg name="secrets" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Nested settings maps containing secrets.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <signal name="Updated">
+ <tp:docstring>
+ Emitted when any settings or permissions change. When handling
+ this signal, clients should re-read the connection using the
+ GetSettings method to get the changes and to ensure the client
+ still has permission to access the connection.
+ </tp:docstring>
+ </signal>
+
+ <signal name="Removed">
+ <tp:docstring>
+ Emitted when this connection is no longer available. This
+ happens when the connection is deleted or if it is no longer
+ accessable by any of the system's logged-in users. After
+ receipt of this signal, the object no longer exists.
+ </tp:docstring>
+ </signal>
+
+ </interface>
+
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings.xml
new file mode 100644
index 000000000..301cde76d
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-settings.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/org/freedesktop/NetworkManager/Settings" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.Settings">
+ <tp:docstring>
+ The Settings interface allows clients to view and administrate the connections stored and used by NetworkManager.
+ </tp:docstring>
+
+ <method name="ListConnections">
+ <tp:docstring>
+ List the connections stored by this Settings object.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_list_connections"/>
+ <arg name="connections" type="ao" direction="out">
+ <tp:docstring>
+ List of connections.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="GetConnectionByUuid">
+ <tp:docstring>
+ Retrieve the object path of a connection, given that connection's UUID.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_get_connection_by_uuid"/>
+ <arg name="uuid" type="s" direction="in">
+ <tp:docstring>
+ The UUID to find the connection object path for.
+ </tp:docstring>
+ </arg>
+ <arg name="connection" type="o" direction="out">
+ <tp:docstring>
+ The connection's object path.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="AddConnection">
+ <tp:docstring>
+ Add new connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="connection" type="a{sa{sv}}" direction="in">
+ <tp:docstring>
+ Connection settings and properties.
+ </tp:docstring>
+ </arg>
+ <arg name="path" type="o" direction="out">
+ <tp:docstring>
+ Object path of the new connection that was just added.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="SaveHostname">
+ <tp:docstring>
+ Save the hostname to persistent configuration.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_save_hostname"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="hostname" type="s" direction="in">
+ <tp:docstring>
+ The hostname to save to persistent configuration. If blank, the persistent hostname is cleared.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <property name="Hostname" type="s" access="read">
+ <tp:docstring>
+ The machine hostname stored in persistent configuration.
+ </tp:docstring>
+ </property>
+
+ <property name="CanModify" type="b" access="read">
+ <tp:docstring>
+ If true, adding and modifying connections is supported.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="NewConnection">
+ <tp:docstring>
+ Emitted when a new connection has been added.
+ </tp:docstring>
+ <arg name="connection" type="o">
+ <tp:docstring>
+ Object path of the new connection.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-connection.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-connection.xml
new file mode 100644
index 000000000..65b917854
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-connection.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.VPN.Connection">
+ <tp:docstring>
+ Represents an active connection to a Virtual Private Network.
+ </tp:docstring>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <property name="VpnState" type="u" access="read" tp:type="NM_VPN_CONNECTION_STATE">
+ <tp:docstring>The VPN-specific state of the connection.</tp:docstring>
+ </property>
+ <property name="Banner" type="s" access="read">
+ <tp:docstring>The banner string of the VPN connection.</tp:docstring>
+ </property>
+
+ <signal name="VpnStateChanged">
+ <tp:docstring>
+ Emitted when the state of the VPN connection has changed.
+ </tp:docstring>
+ <arg name="state" type="u" tp:type="NM_VPN_CONNECTION_STATE">
+ <tp:docstring>
+ The new state of the VPN connection.
+ </tp:docstring>
+ </arg>
+ <arg name="reason" type="u" tp:type="NM_VPN_CONNECTION_STATE_REASON">
+ <tp:docstring>
+ Reason code describing the change to the new state.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:enum name="NM_VPN_CONNECTION_STATE" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The state of the VPN connection is unknown.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="PREPARE" value="1">
+ <tp:docstring>
+ The VPN connection is preparing to connect.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NEED_AUTH" value="2">
+ <tp:docstring>
+ The VPN connection needs authorization credentials.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECT" value="3">
+ <tp:docstring>
+ The VPN connection is being established. FIXME: Should be CONNECTING or CONNECTED.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="IP_CONFIG_GET" value="4">
+ <tp:docstring>
+ The VPN connection is getting an IP address. FIXME: Should be an -ING
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="ACTIVATED" value="5">
+ <tp:docstring>
+ The VPN connection is active.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="FAILED" value="6">
+ <tp:docstring>
+ The VPN connection failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DISCONNECTED" value="7">
+ <tp:docstring>
+ The VPN connection is disconnected.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+ <tp:enum name="NM_VPN_CONNECTION_STATE_REASON" type="u">
+ <tp:enumvalue suffix="UNKNOWN" value="0">
+ <tp:docstring>
+ The reason for the VPN connection state change is unknown.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NONE" value="1">
+ <tp:docstring>
+ No reason was given for the VPN connection state change.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="USER_DISCONNECTED" value="2">
+ <tp:docstring>
+ The VPN connection changed state because the user disconnected it.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="DEVICE_DISCONNECTED" value="3">
+ <tp:docstring>
+ The VPN connection changed state because the device it was using was disconnected.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SERVICE_STOPPED" value="4">
+ <tp:docstring>
+ The service providing the VPN connection was stopped.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="IP_CONFIG_INVALID" value="5">
+ <tp:docstring>
+ The IP config of the VPN connection was invalid.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECT_TIMEOUT" value="6">
+ <tp:docstring>
+ The connection attempt to the VPN service timed out.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SERVICE_START_TIMEOUT" value="7">
+ <tp:docstring>
+ A timeout occurred while starting the service providing the VPN connection.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="SERVICE_START_FAILED" value="8">
+ <tp:docstring>
+ Starting the service starting the service providing the VPN connection failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="NO_SECRETS" value="9">
+ <tp:docstring>
+ Necessary secrets for the VPN connection were not provided.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="LOGIN_FAILED" value="10">
+ <tp:docstring>
+ Authentication to the VPN server failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECTION_REMOVED" value="11">
+ <tp:docstring>
+ The connection was deleted from settings.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+ </interface>
+</node>
+
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-plugin.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-plugin.xml
new file mode 100644
index 000000000..5fb11622a
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-vpn-plugin.xml
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.VPN.Plugin">
+ <tp:docstring>
+ This interface is provided by plugins providing VPN services to the NetworkManager daemon.
+ </tp:docstring>
+ <method name="Connect">
+ <tp:docstring>
+ Tells the plugin to connect.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_connect"/>
+ <arg name="connection" type="a{sa{sv}}" direction="in" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Describes the connection to be established.
+ </tp:docstring>
+ </arg>
+ <tp:possible-errors>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.StartingInProgress"/>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.AlreadyStarted"/>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.StoppingInProgress"/>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.BadArguments"/>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.LaunchFailed"/>
+ </tp:possible-errors>
+ </method>
+
+ <method name="NeedSecrets">
+ <tp:docstring>
+ Asks the plugin whether the provided connection will require secrets to connect successfully.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_need_secrets"/>
+ <arg name="settings" type="a{sa{sv}}" direction="in" tp:type="String_String_Variant_Map_Map">
+ <tp:docstring>
+ Describes the connection that may need secrets.
+ </tp:docstring>
+ </arg>
+ <arg name="setting_name" type="s" direction="out">
+ <tp:docstring>
+ The setting name within the provided connection that requires secrets, if any.
+ </tp:docstring>
+ </arg>
+ <tp:possible-errors>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.ConnectionInvalid"/>
+ </tp:possible-errors>
+ </method>
+
+ <method name="Disconnect">
+ <tp:docstring>
+ Disconnect the plugin.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_disconnect"/>
+ <tp:possible-errors>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.StoppingInProgress"/>
+ <tp:error name="org.freedesktop.NetworkManager.VPN.Error.AlreadyStopped"/>
+ </tp:possible-errors>
+ </method>
+
+ <method name="SetConfig">
+ <tp:docstring>
+ Set generic connection details on the connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_set_config"/>
+ <arg name="config" type="a{sv}" direction="in" tp:type="String_Variant_Map">
+ <tp:docstring>
+ Generic configuration details for the connection.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="SetIp4Config">
+ <tp:docstring>
+ Set IPv4 details on the connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_set_ip4_config"/>
+ <arg name="config" type="a{sv}" direction="in" tp:type="String_Variant_Map">
+ <tp:docstring>
+ Ip4Config details for the connection. You must call
+ SetConfig() before calling this.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="SetIp6Config">
+ <tp:docstring>
+ Set IPv6 details on the connection.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_set_ip6_config"/>
+ <arg name="config" type="a{sv}" direction="in" tp:type="String_Variant_Map">
+ <tp:docstring>
+ Ip6Config details for the connection. You must call
+ SetConfig() before calling this.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="SetFailure">
+ <tp:docstring>
+ Indicate a failure to the plugin.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_vpn_plugin_set_failure"/>
+ <arg name="reason" type="s" direction="in">
+ <tp:docstring>
+ The reason for the failure.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <property name="State" type="u" access="read" tp:type="NM_VPN_CONNECTION_STATE">
+ <tp:docstring>
+ The state of the plugin.
+ </tp:docstring>
+ </property>
+
+ <signal name="StateChanged">
+ <tp:docstring>
+ Emitted when the plugin state changes.
+ </tp:docstring>
+ <arg name="state" type="u" tp:type="NM_VPN_CONNECTION_STATE">
+ <tp:docstring>
+ The new state of the plugin.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="Config">
+ <tp:docstring>
+ The plugin obtained generic configuration information.
+ </tp:docstring>
+ <arg name="config" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ The configuration information.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="Ip4Config">
+ <tp:docstring>
+ The plugin obtained an IPv4 configuration.
+ </tp:docstring>
+ <arg name="ip4config" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ The IPv4 configuration.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="Ip6Config">
+ <tp:docstring>
+ The plugin obtained an IPv6 configuration.
+ </tp:docstring>
+ <arg name="ip6config" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ The IPv6 configuration.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="LoginBanner">
+ <tp:docstring>
+ Emitted when the plugin receives a login banner from the VPN service.
+ </tp:docstring>
+ <arg name="banner" type="s">
+ <tp:docstring>
+ The login banner string.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <signal name="Failure">
+ <tp:docstring>
+ Emitted when a failure in the VPN plugin occurs.
+ </tp:docstring>
+ <arg name="reason" type="u" tp:type="NM_VPN_PLUGIN_FAILURE">
+ <tp:docstring>
+ Reason code for the failure.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:enum name="NM_VPN_PLUGIN_FAILURE" type="u">
+ <tp:enumvalue suffix="LOGIN_FAILED" value="0">
+ <tp:docstring>
+ Login failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="CONNECT_FAILED" value="1">
+ <tp:docstring>
+ Connect failed.
+ </tp:docstring>
+ </tp:enumvalue>
+ <tp:enumvalue suffix="BAD_IP_CONFIG" value="2">
+ <tp:docstring>
+ Invalid IP configuration returned from the VPN plugin.
+ </tp:docstring>
+ </tp:enumvalue>
+ </tp:enum>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-wimax-nsp.xml b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-wimax-nsp.xml
new file mode 100644
index 000000000..55ac4abcf
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/dbus-introspection/nm-wimax-nsp.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <interface name="org.freedesktop.NetworkManager.WiMax.Nsp">
+
+ <property name="Name" type="s" access="read">
+ <tp:docstring>The name of the NSP.</tp:docstring>
+ </property>
+ <property name="SignalQuality" type="u" access="read">
+ <tp:docstring>The current signal quality of the NSP, in percent.</tp:docstring>
+ </property>
+ <property name="NetworkType" type="u" access="read" tp:type="NM_WIMAX_NSP_NETWORK_TYPE">
+ <tp:docstring>The network type of the NSP.</tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values.
+ </tp:docstring>
+ </arg>
+ </signal>
+
+ <tp:flags name="NM_WIMAX_NSP_NETWORK_TYPE" value-prefix="NM_WIMAX_NSP_NETWORK_TYPE" type="u">
+ <tp:docstring>
+ Network type of the NSP.
+ </tp:docstring>
+ <tp:flag suffix="UNKNOWN" value="0x0">
+ <tp:docstring>Unknown network.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="HOME" value="0x1">
+ <tp:docstring>Home network.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="PARTNER" value="0x2">
+ <tp:docstring>Partner network.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="ROAMING_PARTNER" value="0x3">
+ <tp:docstring>Roaming partner network.</tp:docstring>
+ </tp:flag>
+
+ </tp:flags>
+
+ </interface>
+</node>
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
new file mode 100644
index 000000000..a7295beac
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
@@ -0,0 +1,5627 @@
+/* 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.
+*/
+
+#include <tqdir.h>
+
+#include <tqdbusmessage.h>
+
+#include "tdeconfig.h"
+#include "tdehardwaredevices.h"
+
+#include "network-manager.h"
+#include "network-manager_p.h"
+
+// #define DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+#define PRINT_ERROR(x) printf("[TDE NM Backend ERROR] [%s:%d] %s\n", __FILE__, __LINE__, x.ascii());
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+#define PRINT_WARNING(x) printf("[TDE NM Backend WARNING] [%s:%d] %s\n", __FILE__, __LINE__, x.ascii());
+#else
+#define PRINT_WARNING(x)
+#endif
+
+#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
+// Give the user 5 minutes to authenticate to DBUS before timing out
+#define NM_ASYNC_SECRETS_INTERACTION_TIMEOUT_MS (5*60*1000)
+
+// #define WAIT_FOR_OPERATION_BEFORE_RETURNING 1
+#define USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS 1
+
+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, TQString mapKey=TQString::null) {
+ int i;
+ TQString levelIndent = "";
+ for (i=0; i<level; i++) {
+ levelIndent = levelIndent + " ";
+ }
+ TQCString signature = object.buildDBusSignature();
+
+ if (object.type() == TQT_DBusData::String) {
+ printf("%s%s\t%s%s'%s'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toString().ascii()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Bool) {
+ printf("%s%s\t%s%s'%s'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", (object.toBool())?"true":"false"); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Byte) {
+ printf("%s%s\t%s%s'%d'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toByte()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int16) {
+ printf("%s%s\t%s%s'%d'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt16()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt16) {
+ printf("%s%s\t%s%s'%d'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt16()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int32) {
+ printf("%s%s\t%s%s'%d'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt32()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt32) {
+ printf("%s%s\t%s%s'%d'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt32()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::Int64) {
+ printf("%s%s\t%s%s'%lld'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toInt64()); fflush(stdout);
+ }
+ else if (object.type() == TQT_DBusData::UInt64) {
+ printf("%s%s\t%s%s'%lld'\n", levelIndent.ascii(), signature.data(), (mapKey.isNull())?"":mapKey.ascii(), (mapKey.isNull())?"":" = ", object.toUInt64()); fflush(stdout);
+ }
+ else {
+ printf("%s%s\n", 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, it.key());
+ }
+ }
+ else 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, mapKey);
+ }
+}
+
+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;
+}
+
+TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nmVPNStateToTDEGlobalState(TQ_UINT32 nmType) {
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags ret = TDENetworkGlobalManagerFlags::Unknown;
+
+ if (nmType == NM_VPN_STATE_UNKNOWN) {
+ ret |= TDENetworkGlobalManagerFlags::VPNUnknown;
+ }
+ else if (nmType == NM_VPN_STATE_PREPARE) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNEstablishingLink;
+ }
+ else if (nmType == NM_VPN_STATE_NEED_AUTH) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNNeedAuthorization;
+ }
+ else if (nmType == NM_VPN_STATE_CONNECT) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNConfiguringProtocols;
+ }
+ else if (nmType == NM_VPN_STATE_IP_CONFIG_GET) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNVerifyingProtocols;
+ }
+ else if (nmType == NM_VPN_STATE_ACTIVATED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNConnected;
+ }
+ else if (nmType == NM_VPN_STATE_FAILED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ ret |= TDENetworkGlobalManagerFlags::VPNFailed;
+ }
+ else if (nmType == NM_VPN_STATE_DISCONNECTED) {
+ ret |= TDENetworkGlobalManagerFlags::VPNDisconnected;
+ }
+
+ return ret;
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus nmDeviceStateToTDEDeviceState(TQ_UINT32 nmType) {
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus ret = TDENetworkConnectionStatus::None;
+
+ 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;
+}
+
+TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM::nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType) {
+ TDENetworkDeviceType::TDENetworkDeviceType ret = TDENetworkDeviceType::Other;
+
+ if (nmType == NM_DEVICE_TYPE_UNKNOWN) {
+ ret = TDENetworkDeviceType::Other;
+ }
+ else if (nmType == NM_DEVICE_TYPE_ETHERNET) {
+ ret = TDENetworkDeviceType::WiredEthernet;
+ }
+ else if (nmType == NM_DEVICE_TYPE_WIFI) {
+ ret = TDENetworkDeviceType::WiFi;
+ }
+ else if (nmType == NM_DEVICE_TYPE_UNUSED1) {
+ }
+ else if (nmType == NM_DEVICE_TYPE_UNUSED2) {
+ }
+ else if (nmType == NM_DEVICE_TYPE_BT) {
+ ret = TDENetworkDeviceType::Bluetooth;
+ }
+ else if (nmType == NM_DEVICE_TYPE_OLPC_MESH) {
+ ret = TDENetworkDeviceType::OLPCMesh;
+ }
+ else if (nmType == NM_DEVICE_TYPE_WIMAX) {
+ ret = TDENetworkDeviceType::WiMax;
+ }
+ else if (nmType == NM_DEVICE_TYPE_MODEM) {
+ ret = TDENetworkDeviceType::Modem;
+ }
+ else if (nmType == NM_DEVICE_TYPE_INFINIBAND) {
+ ret = TDENetworkDeviceType::Infiniband;
+ }
+ else if (nmType == NM_DEVICE_TYPE_BOND) {
+ ret = TDENetworkDeviceType::Bond;
+ }
+ else if (nmType == NM_DEVICE_TYPE_VLAN) {
+ ret = TDENetworkDeviceType::VLAN;
+ }
+ else if (nmType == NM_DEVICE_TYPE_ADSL) {
+ ret = TDENetworkDeviceType::ADSL;
+ }
+
+ return ret;
+}
+
+TDENetworkConnectionType::TDENetworkConnectionType nmConnectionTypeToTDEConnectionType(TQString nm) {
+ TDENetworkConnectionType::TDENetworkConnectionType ret = TDENetworkConnectionType::Other;
+
+ if (nm.lower() == "802-3-ethernet") {
+ ret = TDENetworkConnectionType::WiredEthernet;
+ }
+ else if (nm.lower() == "infiniband") {
+ ret = TDENetworkConnectionType::Infiniband;
+ }
+ else if (nm.lower() == "802-11-wireless") {
+ ret = TDENetworkConnectionType::WiFi;
+ }
+ else if (nm.lower() == "vpn") {
+ ret = TDENetworkConnectionType::VPN;
+ }
+ else if (nm.lower() == "wimax") {
+ ret = TDENetworkConnectionType::WiMax;
+ }
+ else if (nm.lower() == "vlan") {
+ ret = TDENetworkConnectionType::VLAN;
+ }
+ else if (nm.lower() == "802-11-olpc-mesh") {
+ ret = TDENetworkConnectionType::OLPCMesh;
+ }
+ else if (nm.lower() == "bluetooth") {
+ ret = TDENetworkConnectionType::Bluetooth;
+ }
+ else if (nm.lower() == "cdma") {
+ ret = TDENetworkConnectionType::Modem;
+ }
+ else if (nm.lower() == "gsm") {
+ ret = TDENetworkConnectionType::Modem;
+ }
+
+ return ret;
+}
+
+TQString tdeConnectionTypeToNMConnectionType(TDENetworkConnectionType::TDENetworkConnectionType type, TDEModemConnectionType::TDEModemConnectionType modemType=TDEModemConnectionType::Other) {
+ TQString ret;
+
+ if (type == TDENetworkConnectionType::WiredEthernet) {
+ ret = "802-3-ethernet";
+ }
+ else if (type == TDENetworkConnectionType::Infiniband) {
+ ret = "infiniband";
+ }
+ else if (type == TDENetworkConnectionType::WiFi) {
+ ret = "802-11-wireless";
+ }
+ else if (type == TDENetworkConnectionType::VPN) {
+ ret = "vpn";
+ }
+ else if (type == TDENetworkConnectionType::WiMax) {
+ ret = "wimax";
+ }
+ else if (type == TDENetworkConnectionType::VLAN) {
+ ret = "vlan";
+ }
+ else if (type == TDENetworkConnectionType::OLPCMesh) {
+ ret = "802-11-olpc-mesh";
+ }
+ else if (type == TDENetworkConnectionType::Bluetooth) {
+ ret = "bluetooth";
+ }
+ else if (type == TDENetworkConnectionType::Modem) {
+ if (modemType == TDEModemConnectionType::CDMA) {
+ ret = "cdma";
+ }
+ else if (modemType == TDEModemConnectionType::GSM) {
+ ret = "gsm";
+ }
+ }
+
+ 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;
+}
+
+TDEWiFiMode::TDEWiFiMode nmWiFiModeToTDEWiFiMode(TQString nm) {
+ TDEWiFiMode::TDEWiFiMode ret = TDEWiFiMode::Infrastructure;
+
+ if (nm.lower() == "infrastructure") {
+ ret = TDEWiFiMode::Infrastructure;
+ }
+ else if (nm.lower() == "adhoc") {
+ ret = TDEWiFiMode::AdHoc;
+ }
+
+ return ret;
+}
+
+TQString tdeWiFiModeToNMWiFiMode(TDEWiFiMode::TDEWiFiMode mode) {
+ TQString ret;
+
+ if (mode == TDEWiFiMode::Infrastructure) {
+ ret = "infrastructure";
+ }
+ else if (mode == TDEWiFiMode::AdHoc) {
+ ret = "adhoc";
+ }
+
+ return ret;
+}
+
+TDEWiFiMode::TDEWiFiMode nmWiFiModeToTDEWiFiMode(TQ_UINT32 nm) {
+ TDEWiFiMode::TDEWiFiMode ret = TDEWiFiMode::Infrastructure;
+
+ if (nm == NM_802_11_MODE_INFRASTRUCTURE) {
+ ret = TDEWiFiMode::Infrastructure;
+ }
+ else if (nm == NM_802_11_MODE_ADHOC) {
+ ret = TDEWiFiMode::AdHoc;
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiClientFlags::TDENetworkWiFiClientFlags tdeWiFiFlagsToNMWiFiFlags(TQ_UINT32 nm) {
+ TDENetworkWiFiClientFlags::TDENetworkWiFiClientFlags ret = TDENetworkWiFiClientFlags::None;
+
+ if (nm & NM_802_11_DEVICE_CAP_CIPHER_WEP40) {
+ ret | TDENetworkWiFiClientFlags::CipherWEP40;
+ }
+ if (nm & NM_802_11_DEVICE_CAP_CIPHER_WEP104) {
+ ret | TDENetworkWiFiClientFlags::CipherWEP104;
+ }
+ if (nm & NM_802_11_DEVICE_CAP_CIPHER_TKIP) {
+ ret | TDENetworkWiFiClientFlags::CipherTKIP;
+ }
+ if (nm & NM_802_11_DEVICE_CAP_CIPHER_CCMP) {
+ ret | TDENetworkWiFiClientFlags::CipherCCMP;
+ }
+ if (nm & NM_802_11_DEVICE_CAP_WPA) {
+ ret | TDENetworkWiFiClientFlags::CipherWPA;
+ }
+ if (nm & NM_802_11_DEVICE_CAP_RSN) {
+ ret | TDENetworkWiFiClientFlags::CipherRSN;
+ }
+
+ return ret;
+}
+
+TDEBluetoothConnectionType::TDEBluetoothConnectionType nmBluetoothModeToTDEBluetoothMode(TQString nm) {
+ TDEBluetoothConnectionType::TDEBluetoothConnectionType ret = TDEBluetoothConnectionType::PAN;
+
+ if (nm.lower() == "dun") {
+ ret = TDEBluetoothConnectionType::DUN;
+ }
+ else if (nm.lower() == "panu") {
+ ret = TDEBluetoothConnectionType::PAN;
+ }
+
+ return ret;
+}
+
+TQString tdeBluetoothModeToNMBluetoothMode(TDEBluetoothConnectionType::TDEBluetoothConnectionType type) {
+ TQString ret;
+
+ if (type == TDEBluetoothConnectionType::DUN) {
+ ret = "dun";
+ }
+ else if (type == TDEBluetoothConnectionType::PAN) {
+ ret = "panu";
+ }
+
+ return ret;
+}
+
+TDEGSMNetworkType::TDEGSMNetworkType nmGSMModeToTDEGSMMode(TQ_INT32 nm) {
+ TDEGSMNetworkType::TDEGSMNetworkType ret = TDEGSMNetworkType::Any;
+
+ if (nm == NM_GSM_3G_ONLY) {
+ ret = TDEGSMNetworkType::Only3G;
+ }
+ else if (nm == NM_GSM_GPRS_EDGE_ONLY) {
+ ret = TDEGSMNetworkType::GPRSEdge;
+ }
+ else if (nm == NM_GSM_PREFER_3G) {
+ ret = TDEGSMNetworkType::Prefer3G;
+ }
+ else if (nm == NM_GSM_PREFER_2G) {
+ ret = TDEGSMNetworkType::Prefer2G;
+ }
+
+ return ret;
+}
+
+TQ_INT32 tdeGSMModeToNMGSMMode(TDEGSMNetworkType::TDEGSMNetworkType type) {
+ TQ_INT32 ret = -1;
+
+ if (type == TDEGSMNetworkType::Only3G) {
+ ret = NM_GSM_3G_ONLY;
+ }
+ else if (type == TDEGSMNetworkType::GPRSEdge) {
+ ret = NM_GSM_GPRS_EDGE_ONLY;
+ }
+ else if (type == TDEGSMNetworkType::Prefer3G) {
+ ret = NM_GSM_PREFER_3G;
+ }
+ else if (type == TDEGSMNetworkType::Prefer2G) {
+ ret = NM_GSM_PREFER_2G;
+ }
+
+ return ret;
+}
+
+TDEWiFiFrequencyBand::TDEWiFiFrequencyBand nmWiFiFrequencyBandToTDEWiFiFrequencyBand(TQString nm) {
+ TDEWiFiFrequencyBand::TDEWiFiFrequencyBand ret = TDEWiFiFrequencyBand::Other;
+
+ if (nm.lower() == "") {
+ ret = TDEWiFiFrequencyBand::None;
+ }
+ else if (nm.lower() == "bg") {
+ ret = TDEWiFiFrequencyBand::Band2_4GHz;
+ }
+ else if (nm.lower() == "a") {
+ ret = TDEWiFiFrequencyBand::Band5GHz;
+ }
+
+ return ret;
+}
+
+TQString tdeWiFiFrequencyBandToNMWiFiFrequencyBand(TDEWiFiFrequencyBand::TDEWiFiFrequencyBand mode) {
+ TQString ret;
+
+ if (mode == TDEWiFiFrequencyBand::None) {
+ ret = TQString::null;
+ }
+ else if (mode == TDEWiFiFrequencyBand::Band2_4GHz) {
+ ret = "bg";
+ }
+ else if (mode == TDEWiFiFrequencyBand::Band5GHz) {
+ ret = "a";
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiKeyType::TDENetworkWiFiKeyType nmWiFiKeyTypeToTDEWiFiKeyType(TQString nm) {
+ TDENetworkWiFiKeyType::TDENetworkWiFiKeyType ret = TDENetworkWiFiKeyType::Other;
+
+ if (nm.lower() == "none") {
+ ret = TDENetworkWiFiKeyType::WEP;
+ }
+ else if (nm.lower() == "ieee8021x") {
+ ret = TDENetworkWiFiKeyType::DynamicWEP;
+ }
+ else if (nm.lower() == "wpa-none") {
+ ret = TDENetworkWiFiKeyType::WPAAdHoc;
+ }
+ else if (nm.lower() == "wpa-psk") {
+ ret = TDENetworkWiFiKeyType::WPAInfrastructure;
+ }
+ else if (nm.lower() == "wpa-eap") {
+ ret = TDENetworkWiFiKeyType::WPAEnterprise;
+ }
+
+ return ret;
+}
+
+TQString tdeWiFiKeyTypeToNMWiFiKeyType(TDENetworkWiFiKeyType::TDENetworkWiFiKeyType type) {
+ TQString ret;
+
+ if (type == TDENetworkWiFiKeyType::WEP) {
+ return "none";
+ }
+ else if (type == TDENetworkWiFiKeyType::DynamicWEP) {
+ return "ieee8021x";
+ }
+ else if (type == TDENetworkWiFiKeyType::WPAAdHoc) {
+ return "wpa-none";
+ }
+ else if (type == TDENetworkWiFiKeyType::WPAInfrastructure) {
+ return "wpa-psk";
+ }
+ else if (type == TDENetworkWiFiKeyType::WPAEnterprise) {
+ return "wpa-eap";
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiAuthType::TDENetworkWiFiAuthType nmWiFiAuthTypeToTDEWiFiAuthType(TQString nm) {
+ TDENetworkWiFiAuthType::TDENetworkWiFiAuthType ret = TDENetworkWiFiAuthType::Other;
+
+ if (nm.lower() == "open") {
+ ret = TDENetworkWiFiAuthType::Open;
+ }
+ else if (nm.lower() == "shared") {
+ ret = TDENetworkWiFiAuthType::Shared;
+ }
+ else if (nm.lower() == "leap") {
+ ret = TDENetworkWiFiAuthType::LEAP;
+ }
+
+ return ret;
+}
+
+TQString tdeWiFiAuthTypeToNMWiFiAuthType(TDENetworkWiFiAuthType::TDENetworkWiFiAuthType type) {
+ TQString ret;
+
+ if (type == TDENetworkWiFiAuthType::Open) {
+ return "open";
+ }
+ else if (type == TDENetworkWiFiAuthType::Shared) {
+ return "shared";
+ }
+ else if (type == TDENetworkWiFiAuthType::LEAP) {
+ return "leap";
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags nmWiFiWPAVersionToTDEWiFiWPAVersion(TQStringList nm) {
+ TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags ret = TDENetworkWiFiWPAVersionFlags::None;
+
+ if ((nm.contains("wpa") && nm.contains("rsn")) || (nm.count() < 1)) {
+ ret |= TDENetworkWiFiWPAVersionFlags::Any;
+ }
+ else if (nm.contains("wpa")) {
+ ret |= TDENetworkWiFiWPAVersionFlags::WPA;
+ }
+ else if (nm.contains("rsn")) {
+ ret |= TDENetworkWiFiWPAVersionFlags::RSN;
+ }
+
+ return ret;
+}
+
+TQStringList tdeWiFiWPAVersionToNMWiFiWPAVersion(TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags type) {
+ TQStringList ret;
+
+ if (type & TDENetworkWiFiWPAVersionFlags::WPA) {
+ ret.append("wpa");
+ }
+ if (type & TDENetworkWiFiWPAVersionFlags::RSN) {
+ ret.append("rsn");
+ }
+
+ return ret;
+}
+
+TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher nmWiFiCipherToTDEWiFiCipher(TQString nm) {
+ TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher ret = TDENetworkWiFiConnectionCipher::None;
+
+ if (nm.lower() == "wep40") {
+ ret = TDENetworkWiFiConnectionCipher::CipherWEP40;
+ }
+ else if (nm.lower() == "wep104") {
+ ret = TDENetworkWiFiConnectionCipher::CipherWEP104;
+ }
+ else if (nm.lower() == "tkip") {
+ ret = TDENetworkWiFiConnectionCipher::CipherTKIP;
+ }
+ else if (nm.lower() == "ccmp") {
+ ret = TDENetworkWiFiConnectionCipher::CipherCCMP;
+ }
+
+ return ret;
+}
+
+TQString tdeWiFiCipherToNMWiFiCipher(TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher cipher) {
+ TQString ret;
+
+ if (cipher == TDENetworkWiFiConnectionCipher::CipherWEP40) {
+ ret = "wep40";
+ }
+ else if (cipher == TDENetworkWiFiConnectionCipher::CipherWEP104) {
+ ret = "wep104";
+ }
+ else if (cipher == TDENetworkWiFiConnectionCipher::CipherTKIP) {
+ ret = "tkip";
+ }
+ else if (cipher == TDENetworkWiFiConnectionCipher::CipherCCMP) {
+ ret = "ccmp";
+ }
+
+ return ret;
+}
+
+TDENetworkSlaveDeviceType::TDENetworkSlaveDeviceType nmSlaveTypeToTDESlaveType(TQString nm) {
+ TDENetworkSlaveDeviceType::TDENetworkSlaveDeviceType ret = TDENetworkSlaveDeviceType::None;
+
+ if (nm.lower() == "bond") {
+ ret = TDENetworkSlaveDeviceType::Bond;
+ }
+
+ return ret;
+}
+
+TQString tdeSlaveTypeToNMSlaveType(TDENetworkSlaveDeviceType::TDENetworkSlaveDeviceType slavetype) {
+ TQString ret;
+
+ if (slavetype == TDENetworkSlaveDeviceType::Bond) {
+ ret = "bond";
+ }
+
+ 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;
+}
+
+TDENetworkVLANFlags::TDENetworkVLANFlags nmVLANFlagsToTDEVLANFlags(unsigned int nm) {
+ TDENetworkVLANFlags::TDENetworkVLANFlags ret = TDENetworkVLANFlags::None;
+
+ if (nm & NM_VLAN_REORDER_PACKET_HEADERS) {
+ ret |= TDENetworkVLANFlags::ReorderPacketHeaders;
+ }
+ if (nm & NM_VLAN_USE_GVRP) {
+ ret |= TDENetworkVLANFlags::UseGVRP;
+ }
+ if (nm & NM_VLAN_LOOSE_BINDING) {
+ ret |= TDENetworkVLANFlags::LooseBinding;
+ }
+
+ return ret;
+}
+
+unsigned int tdeVLANFlagsToNMVLANFlags(TDENetworkVLANFlags::TDENetworkVLANFlags flags) {
+ unsigned int ret = 0;
+
+ if (flags & TDENetworkVLANFlags::ReorderPacketHeaders) {
+ ret |= NM_VLAN_REORDER_PACKET_HEADERS;
+ }
+ if (flags & TDENetworkVLANFlags::UseGVRP) {
+ ret |= NM_VLAN_USE_GVRP;
+ }
+ if (flags & TDENetworkVLANFlags::LooseBinding) {
+ ret |= NM_VLAN_LOOSE_BINDING;
+ }
+
+ return ret;
+}
+
+TDENetworkParity::TDENetworkParity nmParityToTDEParity(char nm) {
+ TDENetworkParity::TDENetworkParity ret = TDENetworkParity::None;
+
+ if (nm == 'E') {
+ ret = TDENetworkParity::Even;
+ }
+ else if (nm == 'o') {
+ ret = TDENetworkParity::Odd;
+ }
+
+ return ret;
+}
+
+char tdeParityToNMParity(TDENetworkParity::TDENetworkParity parity) {
+ char ret = 'n';
+
+ if (parity == TDENetworkParity::Even) {
+ ret = 'E';
+ }
+ else if (parity == TDENetworkParity::Odd) {
+ ret = 'o';
+ }
+
+ return ret;
+}
+
+TDENetworkWepKeyType::TDENetworkWepKeyType nmWepKeyTypeToTDEWepKeyType(unsigned int nm, TQString key=TQString::null) {
+ TDENetworkWepKeyType::TDENetworkWepKeyType ret = TDENetworkWepKeyType::Hexadecimal;
+
+ if (nm == NM_WEP_TYPE_HEXADECIMAL) {
+ if (key.isNull()) {
+ ret = TDENetworkWepKeyType::Hexadecimal;
+ }
+ else {
+ if ((key.length() == 10) || (key.length() == 26)) {
+ ret = TDENetworkWepKeyType::Hexadecimal;
+ }
+ else {
+ ret = TDENetworkWepKeyType::Ascii;
+ }
+ }
+ }
+ else if (nm == NM_WEP_TYPE_PASSPHRASE) {
+ ret = TDENetworkWepKeyType::Passphrase;
+ }
+
+ return ret;
+}
+
+unsigned int tdeWepKeyTypeToNMWepKeyType(TDENetworkWepKeyType::TDENetworkWepKeyType type) {
+ unsigned int ret = 0;
+
+ if (type == TDENetworkWepKeyType::Hexadecimal) {
+ ret = NM_WEP_TYPE_HEXADECIMAL;
+ }
+ else if (type == TDENetworkWepKeyType::Ascii) {
+ ret = NM_WEP_TYPE_HEXADECIMAL;
+ }
+ else if (type == TDENetworkWepKeyType::Passphrase) {
+ ret = NM_WEP_TYPE_PASSPHRASE;
+ }
+
+ 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;
+}
+
+TDENetworkInfinibandTransportMode::TDENetworkInfinibandTransportMode nmIBTransportToTDEIBTransport(TQString nm) {
+ TDENetworkInfinibandTransportMode::TDENetworkInfinibandTransportMode ret = TDENetworkInfinibandTransportMode::Other;
+
+ if (nm.lower() == "datagram") {
+ ret = TDENetworkInfinibandTransportMode::Datagram;
+ }
+ else if (nm.lower() == "connected") {
+ ret = TDENetworkInfinibandTransportMode::Connected;
+ }
+
+ return ret;
+}
+
+TQString tdeIBTransportToNMIBTransport(TDENetworkInfinibandTransportMode::TDENetworkInfinibandTransportMode mode) {
+ TQString ret;
+
+ if (mode == TDENetworkInfinibandTransportMode::Datagram) {
+ ret = "datagram";
+ }
+ else if (mode == TDENetworkInfinibandTransportMode::Connected) {
+ ret = "connected";
+ }
+
+ 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());
+ TDENetworkDeviceType::TDENetworkDeviceType deviceType = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ break;
+ }
+ else if (deviceType == TDENetworkDeviceType::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 == TDENetworkDeviceType::Infiniband) {
+ DBus::InfinibandDeviceProxy infinibandDevice(NM_DBUS_SERVICE, (*it));
+ infinibandDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = infinibandDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ if (candidateMACAddress.lower() == macAddress.lower()) {
+ return (*it);
+ }
+ }
+ }
+ else if (deviceType == TDENetworkDeviceType::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);
+ }
+ }
+ }
+ else if (deviceType == TDENetworkDeviceType::WiMax) {
+ DBus::WiMaxDeviceProxy wiMaxDevice(NM_DBUS_SERVICE, (*it));
+ wiMaxDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = wiMaxDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ if (candidateMACAddress.lower() == macAddress.lower()) {
+ return (*it);
+ }
+ }
+ }
+ else if (deviceType == TDENetworkDeviceType::OLPCMesh) {
+ DBus::OlpcMeshDeviceProxy olpcMeshDevice(NM_DBUS_SERVICE, (*it));
+ olpcMeshDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = olpcMeshDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ if (candidateMACAddress.lower() == macAddress.lower()) {
+ return (*it);
+ }
+ }
+ }
+ else if (deviceType == TDENetworkDeviceType::Bluetooth) {
+ DBus::BluetoothDeviceProxy bluetoothDevice(NM_DBUS_SERVICE, (*it));
+ bluetoothDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = bluetoothDevice.getHwAddress(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() + ": " + error.message()))
+ return "";
+ }
+ }
+ else {
+ return "";
+ }
+}
+
+TQString macAddressForGenericDevice(TQT_DBusObjectPath path) {
+ TQT_DBusError error;
+
+ DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, path);
+ genericDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQ_UINT32 deviceType = genericDevice.getDeviceType(error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return TQString();
+ }
+ else if (deviceType == NM_DEVICE_TYPE_ETHERNET) {
+ DBus::EthernetDeviceProxy ethernetDevice(NM_DBUS_SERVICE, path);
+ ethernetDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = ethernetDevice.getPermHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ else if (deviceType == NM_DEVICE_TYPE_INFINIBAND) {
+ DBus::InfinibandDeviceProxy infinibandDevice(NM_DBUS_SERVICE, path);
+ infinibandDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = infinibandDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ else if (deviceType == NM_DEVICE_TYPE_WIFI) {
+ DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, path);
+ wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = wiFiDevice.getPermHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ else if (deviceType == NM_DEVICE_TYPE_WIMAX) {
+ DBus::WiMaxDeviceProxy wiMaxDevice(NM_DBUS_SERVICE, path);
+ wiMaxDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = wiMaxDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ else if (deviceType == NM_DEVICE_TYPE_OLPC_MESH) {
+ DBus::OlpcMeshDeviceProxy olpcMeshDevice(NM_DBUS_SERVICE, path);
+ olpcMeshDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = olpcMeshDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ else if (deviceType == NM_DEVICE_TYPE_BT) {
+ DBus::BluetoothDeviceProxy bluetoothDevice(NM_DBUS_SERVICE, path);
+ bluetoothDevice.setConnection(TQT_DBusConnection::systemBus());
+ TQString candidateMACAddress = bluetoothDevice.getHwAddress(error);
+ if (!error.isValid()) {
+ return candidateMACAddress.lower();
+ }
+ }
+ // FIXME
+ // Add other supported device types here
+
+ return TQString::null;
+}
+
+TQString tdeDeviceUUIDForMACAddress(TQString macAddress) {
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ if (!hwdevices) {
+ return TQString::null;
+ }
+
+ TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
+ for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) {
+ TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
+ if (dev) {
+ if (macAddress.lower() == dev->macAddress().lower()) {
+ return dev->uniqueID();
+ }
+ }
+ }
+
+ return TQString::null;
+}
+
+TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::TDENetworkConnectionManager_BackendNM_DBusSignalReceiver(TDENetworkConnectionManager_BackendNMPrivate* parent) : m_parent(parent) {
+ //
+}
+
+TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::~TDENetworkConnectionManager_BackendNM_DBusSignalReceiver() {
+ //
+}
+
+void TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::dbusSignal(const TQT_DBusMessage& message) {
+ if (message.type() == TQT_DBusMessage::SignalMessage) {
+ TQString interface = message.interface();
+ TQString sender = message.sender();
+ TQString member = message.member();
+ TQString path = message.path();
+
+// printf("[DEBUG] In dbusSignal: sender: %s, member: %s, interface: %s, path: %s, parent path: %s\n", sender.ascii(), member.ascii(), interface.ascii(), path.ascii(), m_parent->m_dbusDeviceString.ascii()); fflush(stdout);
+
+ if (interface == NM_VPN_DBUS_CONNECTION_SERVICE) {
+ if (member == "VpnStateChanged") {
+ // Demarshal data
+ TQ_UINT32 state = message[0].toUInt32();
+ TQ_UINT32 reason = message[1].toUInt32();
+ if (state == NM_VPN_STATE_FAILED) {
+ m_parent->internalProcessVPNFailure(reason);
+ }
+ }
+ }
+ else if (interface == NM_DBUS_DEVICE_SERVICE) {
+ if (path == m_parent->m_dbusDeviceString) {
+ if (member == "StateChanged") {
+ // Demarshal data
+ TQ_UINT32 new_state = message[0].toUInt32();
+ TQ_UINT32 old_state = message[1].toUInt32();
+ TQ_UINT32 reason = message[2].toUInt32();
+ m_parent->internalProcessDeviceStateChanged(new_state, old_state, reason);
+ }
+ }
+ }
+ }
+}
+
+TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TQString macAddress) : TDENetworkConnectionManager(macAddress) {
+ d = new TDENetworkConnectionManager_BackendNMPrivate(this);
+
+ // 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());
+ d->m_vpnProxy = new DBus::VPNPluginProxy(NM_VPN_DBUS_PLUGIN_SERVICE, NM_VPN_DBUS_PLUGIN_PATH);
+ d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus());
+
+ d->m_dbusDeviceString = deviceInterfaceString(macAddress);
+ if (d->m_dbusDeviceString != "") {
+ d->m_networkDeviceProxy = new DBus::DeviceProxy(NM_DBUS_SERVICE, d->m_dbusDeviceString);
+ d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
+ if (deviceType() == TDENetworkDeviceType::WiFi) {
+ d->m_wiFiDeviceProxy = new DBus::WiFiDeviceProxy(NM_DBUS_SERVICE, d->m_dbusDeviceString);
+ d->m_wiFiDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
+ }
+ }
+
+ // Connect global signals
+ connect(d->m_networkManagerProxy, SIGNAL(StateChanged(TQ_UINT32)), d, SLOT(internalProcessGlobalStateChanged(TQ_UINT32)));
+
+ // Connect VPN signals
+ if (d->m_vpnProxy) {
+ connect(d->m_vpnProxy, SIGNAL(StateChanged(TQ_UINT32)), d, SLOT(internalProcessVPNStateChanged(TQ_UINT32)));
+ connect(d->m_vpnProxy, SIGNAL(LoginBanner(const TQString&)), d, SLOT(internalProcessVPNLoginBanner(const TQString&)));
+ connect(d->m_vpnProxy, SIGNAL(Failure(TQ_UINT32)), d, SLOT(internalProcessVPNFailure(TQ_UINT32)));
+ }
+
+ // Connect local signals
+ if (d->m_networkDeviceProxy) {
+ connect(d->m_networkDeviceProxy, SIGNAL(StateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)), d, SLOT(internalProcessDeviceStateChanged(TQ_UINT32, TQ_UINT32, TQ_UINT32)));
+ }
+ if (d->m_wiFiDeviceProxy) {
+ connect(d->m_wiFiDeviceProxy, SIGNAL(AccessPointAdded(const TQT_DBusObjectPath&)), d, SLOT(internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&)));
+ connect(d->m_wiFiDeviceProxy, SIGNAL(AccessPointRemoved(const TQT_DBusObjectPath&)), d, SLOT(internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&)));
+ connect(d->m_wiFiDeviceProxy, SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), d, SLOT(internalProcessWiFiPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
+ }
+
+ // Create public lists
+ m_connectionList = new TDENetworkConnectionList;
+ m_hwNeighborList = new TDENetworkHWNeighborList;
+
+ // Run site survey to populate neighbor list with initial data
+ siteSurvey();
+}
+
+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_BackendNMPrivate::internalProcessGlobalStateChanged(TQ_UINT32 state) {
+ m_parent->internalNetworkConnectionStateChanged(m_parent->backendStatus());
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNStateChanged(TQ_UINT32 state) {
+ m_parent->internalNetworkConnectionStateChanged(m_parent->backendStatus());
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNLoginBanner(const TQString& banner) {
+ m_parent->internalVpnEvent(TDENetworkVPNEventType::LoginBanner, banner);
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessVPNFailure(TQ_UINT32 reason) {
+ // FIXME
+ // This should provide a plain-text interpretation of the NetworkManager-specific error code
+ m_parent->internalVpnEvent(TDENetworkVPNEventType::Failure, TQString("VPN connection attempt failed!<br>NetworkManager returned error %1.").arg(reason));
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason) {
+ Q_UNUSED(oldState)
+
+ if (m_prevDeviceState == newState) return;
+ m_prevDeviceState = newState;
+
+ if (newState == NM_DEVICE_STATE_FAILED) {
+ TQString errorString;
+ if (reason == NM_DEVICE_STATE_REASON_NONE) {
+ errorString = TQString("Connection attempt failed!");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_UNKNOWN) {
+ errorString = TQString("Connection attempt failed!<br>Unknown error detected.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_NOW_MANAGED) {
+ errorString = TQString("Connection attempt failed!<br>Network device is now managed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_NOW_UNMANAGED) {
+ errorString = TQString("Connection attempt failed!<br>Network device is now unmanaged.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_CONFIG_FAILED) {
+ errorString = TQString("Connection attempt failed!<br>Configuration failed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE) {
+ errorString = TQString("Connection attempt failed!<br>IP configuration unavailable.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED) {
+ errorString = TQString("Connection attempt failed!<br>IP configuration expired.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_NO_SECRETS) {
+ errorString = i18n("Connection attempt failed!<br>Secrets were required to establish a connection, but no secrets were available.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT) {
+ errorString = TQString("Connection attempt failed!<br>The supplicant was disconnected while attempting to establish a wireless connection.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED) {
+ errorString = TQString("Connection attempt failed!<br>Supplicant configuration failed while attempting to establish a wireless connection.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The supplicant failed while attempting to establish a wireless connection.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT) {
+ errorString = i18n("Connection attempt failed!<br>The supplicant timed out while attempting to establish a wireless connection.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_PPP_START_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The PPP client failed to start.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_PPP_DISCONNECT) {
+ errorString = i18n("Connection attempt failed!<br>The PPP client was disconnected.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_PPP_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Unknown PPP failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_DHCP_START_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The DHCP client failed to start.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_DHCP_ERROR) {
+ errorString = i18n("Connection attempt failed!<br>The DHCP client encountered an error.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_DHCP_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Uknown DHCP failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SHARED_START_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The connection sharing service failed to start.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SHARED_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The connection sharing service encountered an error.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The AutoIP service failed to start.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_AUTOIP_ERROR) {
+ errorString = i18n("Connection attempt failed!<br>The AutoIP service encountered an error.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_AUTOIP_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Unknown AutoIP failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_BUSY) {
+ errorString = i18n("Connection attempt failed!<br>Modem was busy.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE) {
+ errorString = i18n("Connection attempt failed!<br>No dial tone.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER) {
+ errorString = i18n("Connection attempt failed!<br>No carrier detected.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT) {
+ errorString = i18n("Connection attempt failed!<br>Modem timed out while dialing.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>The modem failed to dial.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Modem initialization failed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_APN_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>GSM APN failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING) {
+ errorString = i18n("Connection attempt failed!<br>GSM registration failed to search for networks.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED) {
+ errorString = i18n("Connection attempt failed!<br>GSM registration attempt was rejected.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT) {
+ errorString = i18n("Connection attempt failed!<br>GSM registration attempt timed out.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>GSM registration attempt failed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>GSM PIN check failed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_FIRMWARE_MISSING) {
+ errorString = i18n("Connection attempt failed!<br>Network device firmware is missing.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_REMOVED) {
+ errorString = i18n("Connection attempt failed!<br>Network device was removed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SLEEPING) {
+ errorString = i18n("Connection attempt failed!<br>Network device is sleeping.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_CONNECTION_REMOVED) {
+ errorString = i18n("Connection attempt failed!<br>Connection was removed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_USER_REQUESTED) {
+ errorString = i18n("Connection attempt failed!<br>User requested device disconnection.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_CARRIER) {
+ errorString = i18n("Connection attempt failed!<br>Carrier or link status changed.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED) {
+ errorString = i18n("Connection attempt failed!<br>Device and/or connection already active.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE) {
+ errorString = i18n("Connection attempt failed!<br>The supplicant is now available.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND) {
+ errorString = i18n("Connection attempt failed!<br>Requested modem was not found.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_BT_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Bluetooth connection timeout.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED) {
+ errorString = i18n("Connection attempt failed!<br>GSM SIM not inserted.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED) {
+ errorString = i18n("Connection attempt failed!<br>GSM PIN required.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED) {
+ errorString = i18n("Connection attempt failed!<br>GSM PUK required.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_GSM_SIM_WRONG) {
+ errorString = i18n("Connection attempt failed!<br>GSM SIM incorrect.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_INFINIBAND_MODE) {
+ errorString = i18n("Connection attempt failed!<br>Incorrect Infiniband mode.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Dependency failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_BR2684_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Unknown bridge failure.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE) {
+ errorString = i18n("Connection attempt failed!<br>ModemManager not available.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SSID_NOT_FOUND) {
+ errorString = i18n("Connection attempt failed!<br>SSID not found.");
+ }
+ else if (reason == NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED) {
+ errorString = i18n("Connection attempt failed!<br>Secondary connection failure.");
+ }
+ else {
+ // FIXME
+ // This should provide a plain-text interpretation of the NetworkManager-specific error code
+ errorString = TQString("Connection attempt failed!<br>NetworkManager returned error %1.").arg(reason);
+ }
+ m_parent->internalNetworkDeviceEvent(TDENetworkDeviceEventType::Failure, errorString);
+ }
+
+ m_parent->internalNetworkDeviceStateChanged(nmDeviceStateToTDEDeviceState(newState), m_parent->m_macAddress);
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath& dbuspath) {
+ TDENetworkWiFiAPInfo* apInfo = m_parent->getAccessPointDetails(dbuspath);
+ if (apInfo) {
+ if (!m_accessPointProxyList.contains(dbuspath)) {
+ // Set up monitoring object
+ DBus::AccessPointProxy* apProxy = new DBus::AccessPointProxy(NM_DBUS_SERVICE, dbuspath);
+ apProxy->setConnection(TQT_DBusConnection::systemBus());
+ connect(apProxy, SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, SLOT(internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
+ m_accessPointProxyList[dbuspath] = (apProxy);
+
+ // Notify client applications
+ m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::Discovered);
+ }
+ delete apInfo;
+ }
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath& dbuspath) {
+ TDENetworkWiFiAPInfo* apInfo = m_parent->getAccessPointDetails(dbuspath);
+ if (apInfo) {
+ // Notify client applications
+ m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::Lost);
+ delete apInfo;
+
+ // Destroy related monitoring object
+ DBus::AccessPointProxy* apProxy = m_accessPointProxyList[dbuspath];
+ m_accessPointProxyList.remove(dbuspath);
+ if (apProxy) {
+ delete apProxy;
+ }
+ }
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& props) {
+ if (m_wiFiDeviceProxy) {
+ if (props.contains("ActiveAccessPoint")) {
+ TQT_DBusError error;
+ TDENetworkWiFiAPInfo* apInfo = m_parent->getAccessPointDetails(m_wiFiDeviceProxy->getActiveAccessPoint(error));
+ if (apInfo) {
+ m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::AccessPointChanged);
+ }
+ }
+ else if (props.contains("Bitrate")) {
+ m_parent->internalNetworkDeviceEvent(TDENetworkDeviceEventType::BitRateChanged, TQString::null);
+ }
+ }
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& props) {
+ const DBus::AccessPointProxy* apProxy = dynamic_cast<const DBus::AccessPointProxy*>(sender());
+ if (apProxy) {
+ TQT_DBusError error;
+ TDEMACAddress BSSID;
+ BSSID.fromString(apProxy->getHwAddress(error));
+ if (props.contains("Strength")) {
+ m_parent->internalAccessPointStatusChanged(BSSID, TDENetworkAPEventType::SignalStrengthChanged);
+ }
+ }
+}
+
+TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM::deviceType() {
+ if (m_macAddress == "") {
+ return TDENetworkDeviceType::BackendOnly;
+ }
+ else {
+ if (d->m_dbusDeviceString != "") {
+ // Query NM for the device type
+ TQT_DBusError error;
+ d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
+ genericDevice.setConnection(TQT_DBusConnection::systemBus());
+ TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return TDENetworkDeviceType::Other;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR(TQString("Invalid DBUS device string '%1'").arg(d->m_dbusDeviceString))
+ return TDENetworkDeviceType::Other;
+ }
+ }
+}
+
+TDENetworkConnectionType::TDENetworkConnectionType TDENetworkConnectionManager_BackendNM::connectionType(TQString dbusPath) {
+ TDENetworkConnectionType::TDENetworkConnectionType connType = TDENetworkConnectionType::Other;
+ TQ_UINT32 ret;
+ TQT_DBusError error;
+
+#ifndef USE_ASYNC_DBUS_CALLS
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, dbusPath);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ TQT_DBusTQStringDataMap connectionSettingsMap;
+ ret = connectionSettings.GetSettings(connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ if (ret) {
+#else // USE_ASYNC_DBUS_CALLS
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, dbusPath);
+ 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() + ": " + error.message()))
+ }
+ 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];
+ if (d->nmConnectionSettingsAsyncSettingsErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].name() + ": " + d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].message()));
+ d->nmConnectionSettingsAsyncSettingsErrorResponse.remove(asyncCallID);
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ if (d->nmConnectionSettingsAsyncSettingsResponse.contains(asyncCallID)) {
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+ }
+#endif // USE_ASYNC_DBUS_CALLS
+
+ // Parse settings to find connection type
+ TQT_DBusTQStringDataMap::const_iterator it2;
+ for (it2 = connectionSettingsMap.begin(); it2 != connectionSettingsMap.end(); ++it2) {
+ TQString outerKeyValue = it2.key();
+ TQT_DBusData dataValue = it2.data();
+
+ 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) {
+ TQT_DBusVariant dataValueVariant = dataValue.toVariant();
+ TQT_DBusData dataValue2 = dataValueVariant.value;
+ if (dataValue2.type() != TQT_DBusData::Variant) {
+ if (outerKeyValue.lower() == "connection") {
+ if (keyValue.lower() == "type") {
+ connType = nmConnectionTypeToTDEConnectionType(dataValue2.toString());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return connType;
+}
+
+TQString TDENetworkConnectionManager_BackendNM::backendName() {
+ return i18n("NetworkManager");
+}
+
+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() + ": " + error.message()))
+ return TDENetworkGlobalManagerFlags::BackendUnavailable;
+ }
+ else {
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags globalFlags = nmGlobalStateToTDEGlobalState(ret);
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags vpnFlags = TDENetworkGlobalManagerFlags::Unknown;
+ if (d->m_vpnProxy) {
+ ret = d->m_vpnProxy->getState(error);
+ if (error.isValid()) {
+ // Error!
+ bool print_error = true;
+ if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") {
+ if (d->vpn_service_error_notified) {
+ print_error = false;
+ }
+ else {
+ d->vpn_service_error_notified = true;
+ }
+ }
+ if (print_error) {
+ PRINT_ERROR(TQString("Attempting to access the network-manager VPN service returned: %1").arg(error.name() + ": " + error.message()))
+ }
+ vpnFlags = TDENetworkGlobalManagerFlags::VPNUnknown;
+ }
+ else {
+ vpnFlags = nmVPNStateToTDEGlobalState(ret);
+ }
+ }
+ return globalFlags | vpnFlags;
+ }
+ }
+ else {
+ return TDENetworkGlobalManagerFlags::BackendUnavailable;
+ }
+}
+
+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));
+ if (error.isValid()) {
+ // Error!
+ bool print_error = true;
+ if (error.name() == "org.freedesktop.DBus.Error.AccessDenied") {
+ if (error.message().contains("org.freedesktop.NetworkManager.Device")) {
+ // Unable to determine if device allows autoconnect
+ // Assume true!
+ ret.autoConnect = true;
+ if (d->device_autoconnect_error_notified) {
+ print_error = false;
+ }
+ else {
+ d->device_autoconnect_error_notified = true;
+ }
+ }
+ }
+ if (print_error) {
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+
+ // Reset error object to avoid spurious error messages on the command line
+ error = TQT_DBusError();
+ }
+
+ // Populate wiFiInfo
+ if ((deviceType() == TDENetworkDeviceType::WiFi) && (d->m_wiFiDeviceProxy)) {
+ ret.wiFiInfo.valid = true;
+ ret.wiFiInfo.hwAddress.fromString(d->m_wiFiDeviceProxy->getHwAddress(error));
+ ret.wiFiInfo.permanentHWAddress.fromString(d->m_wiFiDeviceProxy->getPermHwAddress(error));
+ ret.wiFiInfo.operatingMode = nmWiFiModeToTDEWiFiMode(d->m_wiFiDeviceProxy->getMode(error));
+ ret.wiFiInfo.bitrate = d->m_wiFiDeviceProxy->getBitrate(error);
+ TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(d->m_wiFiDeviceProxy->getActiveAccessPoint(error));
+ if (error.isValid()) {
+ PRINT_ERROR((error.name() + ": " + error.message()))
+
+ // Reset error object to avoid spurious error messages on the command line
+ error = TQT_DBusError();
+ }
+ if (apInfo) {
+ ret.wiFiInfo.activeAccessPointBSSID = apInfo->BSSID;
+ TDENetworkWiFiAPInfo* neighborListAPInfo = findAccessPointByBSSID(ret.wiFiInfo.activeAccessPointBSSID);
+ if (neighborListAPInfo) {
+ *neighborListAPInfo = *apInfo;
+ }
+ delete apInfo;
+ }
+ else {
+ ret.wiFiInfo.activeAccessPointBSSID = TDEMACAddress();
+ }
+ ret.wiFiInfo.wirelessFlags = tdeWiFiFlagsToNMWiFiFlags(d->m_wiFiDeviceProxy->getWirelessCapabilities(error));
+ }
+ else {
+ ret.wiFiInfo.valid = false;
+ }
+
+ // Get active connection UUID
+ TQT_DBusObjectPath connectionPath = d->m_networkDeviceProxy->getActiveConnection(error);
+ if (!error.isValid()) {
+ DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, connectionPath);
+ activeConnection.setConnection(TQT_DBusConnection::systemBus());
+ ret.activeConnectionUUID = activeConnection.getUuid(error);
+ if (error.isValid()) {
+ ret.activeConnectionUUID = TQString::null;
+ }
+ }
+
+ ret.valid = true;
+ }
+
+ return ret;
+}
+
+TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceStatus() {
+ TQT_DBusError error;
+ TDENetworkDeviceInformation ret;
+
+ if (d->m_networkDeviceProxy) {
+ ret.statusFlags = nmDeviceStateToTDEDeviceState(d->m_networkDeviceProxy->getState(error));
+ ret.UUID = d->m_networkDeviceProxy->getUdi(error);
+
+ // Get active connection UUID
+ TQT_DBusObjectPath connectionPath = d->m_networkDeviceProxy->getActiveConnection(error);
+ if (!error.isValid()) {
+ DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, connectionPath);
+ activeConnection.setConnection(TQT_DBusConnection::systemBus());
+ ret.activeConnectionUUID = activeConnection.getUuid(error);
+ if (error.isValid()) {
+ ret.activeConnectionUUID = TQString::null;
+ }
+ }
+
+ 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_BackendNMPrivate::processConnectionSettingsAsyncError(int asyncCallId, const TQT_DBusError error) {
+ nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallId] = error;
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::processConnectionSettingsUpdateAsyncError(int asyncCallId, const TQT_DBusError error) {
+ nmConnectionSettingsUpdateAsyncSettingsErrorResponse[asyncCallId] = error;
+}
+
+void TDENetworkConnectionManager_BackendNMPrivate::processAddConnectionAsyncError(int asyncCallId, const TQT_DBusError error) {
+ nmAddConnectionAsyncErrorResponse[asyncCallId] = error;
+}
+
+void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
+ if (d->nonReentrantCallActive) return;
+
+ d->nonReentrantCallActive = true;
+
+ 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;
+ TDEWiredInfinibandConnection* infinibandConnection = NULL;
+ TDEWiFiConnection* wiFiConnection = NULL;
+ TDEVPNConnection* vpnConnection = NULL;
+ TDEWiMaxConnection* wiMaxConnection = NULL;
+ TDEVLANConnection* vlanConnection = NULL;
+ TDEOLPCMeshConnection* olpcMeshConnection = NULL;
+ TDEBluetoothConnection* bluetoothConnection = NULL;
+ TDEModemConnection* modemConnection = NULL;
+ TDENetworkConnectionType::TDENetworkConnectionType connType = connectionType((*it));
+ if (connType == TDENetworkConnectionType::WiredEthernet) {
+ connection = ethernetConnection = new TDEWiredEthernetConnection;
+ }
+ else if (connType == TDENetworkConnectionType::Infiniband) {
+ connection = infinibandConnection = new TDEWiredInfinibandConnection;
+ }
+ else if (connType == TDENetworkConnectionType::WiFi) {
+ connection = wiFiConnection = new TDEWiFiConnection;
+ }
+ else if (connType == TDENetworkConnectionType::VPN) {
+ connection = vpnConnection = new TDEVPNConnection;
+ }
+ else if (connType == TDENetworkConnectionType::WiMax) {
+ connection = wiMaxConnection = new TDEWiMaxConnection;
+ }
+ else if (connType == TDENetworkConnectionType::VLAN) {
+ connection = vlanConnection = new TDEVLANConnection;
+ }
+ else if (connType == TDENetworkConnectionType::OLPCMesh) {
+ connection = olpcMeshConnection = new TDEOLPCMeshConnection;
+ }
+ else if (connType == TDENetworkConnectionType::Bluetooth) {
+ connection = bluetoothConnection = new TDEBluetoothConnection;
+ }
+ else if (connType == TDENetworkConnectionType::Modem) {
+ connection = modemConnection = new TDEModemConnection;
+ }
+ 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;
+ // Set up NM-specific defaults
+ // Keep in sync with latest NM default settings!
+ // NM 0.9 setting descriptions and default values are available at:
+ // http://projects.gnome.org/NetworkManager/developers/api/09/ref-settings.html
+ connection->autoConnect = true;
+
+ if (wiFiConnection) {
+ wiFiConnection->securitySettings.authType = TDENetworkWiFiAuthType::Open;
+ }
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] %s\n", (*it).data()); fflush(stdout);
+#endif // DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+
+#ifndef USE_ASYNC_DBUS_CALLS
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, (*it));
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ TQT_DBusTQStringDataMap connectionSettingsMap;
+ ret = connectionSettings.GetSettings(connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ if (ret) {
+#else // USE_ASYNC_DBUS_CALLS
+ // 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>&)));
+ connect(&connectionSettings, SIGNAL(AsyncErrorResponseDetected(int, const TQT_DBusError)), d, SLOT(processConnectionSettingsAsyncError(int, const TQT_DBusError)));
+ int asyncCallID;
+ ret = connectionSettings.GetSettingsAsync(asyncCallID, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ 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];
+ if (d->nmConnectionSettingsAsyncSettingsErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].name() + ": " + d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].message()));
+ d->nmConnectionSettingsAsyncSettingsErrorResponse.remove(asyncCallID);
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ if (d->nmConnectionSettingsAsyncSettingsResponse.contains(asyncCallID)) {
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+ }
+#endif // USE_ASYNC_DBUS_CALLS
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] received DBUS object structure map follows:\n"); 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", 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", 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", 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 (keyValue.lower() == "permissions") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQString authString = innerDataValue.toString();
+ TQStringList pieces = TQStringList::split(":", authString);
+ if (pieces[0].lower() == "user") {
+ connection->authorizedUsers.append(pieces[1]);
+ }
+ }
+ }
+ else if (keyValue.lower() == "autoconnect") {
+ connection->autoConnect = dataValue2.toBool();
+ }
+ else if (keyValue.lower() == "read-only") {
+ connection->readOnly = dataValue2.toBool();
+ }
+ else if (keyValue.lower() == "master") {
+ connection->masterConnectionUUID = dataValue2.toString().lower();
+ }
+ else if (keyValue.lower() == "slave-type") {
+ connection->slaveType = nmSlaveTypeToTDESlaveType(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "timestamp") {
+ connection->lastKnownConnection.setTime_t(dataValue2.toUInt64());
+ }
+ }
+ else if (outerKeyValue.lower() == "802-1x") {
+ 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() == "infiniband") {
+ 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() == "mtu") {
+ connection->mtu = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "transport-mode") {
+ infinibandConnection->transportMode = nmIBTransportToTDEIBTransport(dataValue2.toString());
+ }
+ }
+ else if (outerKeyValue.lower() == "802-11-wireless") {
+ if (keyValue.lower() == "ssid") {
+ 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;
+ wiFiConnection->SSID.resize(count+1);
+ wiFiConnection->SSID[count] = innerDataValue.toByte();
+ count++;
+ }
+ }
+ 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 (keyValue.lower() == "mode") {
+ wiFiConnection->operatingMode = nmWiFiModeToTDEWiFiMode(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "band") {
+ wiFiConnection->bandRestriction = nmWiFiFrequencyBandToTDEWiFiFrequencyBand(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "channel") {
+ wiFiConnection->channelRestriction = dataValue2.toUInt32();
+ if (wiFiConnection->channelRestriction == 0) wiFiConnection->channelRestriction = -1;
+ }
+ else if (keyValue.lower() == "rate") {
+ wiFiConnection->bitRateRestriction = dataValue2.toUInt32()*1000;
+ if (wiFiConnection->bitRateRestriction == 0) wiFiConnection->bitRateRestriction = -1;
+ }
+ else if (keyValue.lower() == "tx-power") {
+ wiFiConnection->powerRestriction = dataValue2.toUInt32();
+ if (wiFiConnection->powerRestriction == 0) wiFiConnection->powerRestriction = -1;
+ }
+ else if (keyValue.lower() == "bssid") {
+ 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());
+ }
+ wiFiConnection->accessPointRestriction.setAddress(macAddress);
+ }
+ else if (keyValue.lower() == "mac-address-blacklist") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TDEMACAddress hwAddress;
+ hwAddress.fromString(innerDataValue.toString());
+ wiFiConnection->blacklistedBSSIDs.append(hwAddress);
+ }
+ }
+ else if (keyValue.lower() == "seen-bssids") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TDEMACAddress hwAddress;
+ hwAddress.fromString(innerDataValue.toString());
+ wiFiConnection->heardBSSIDs.append(hwAddress);
+ }
+ }
+ else if (keyValue.lower() == "security") {
+ TQString setting;
+ if (setting.lower() == "802-11-wireless-security") {
+ wiFiConnection->securityRequired = true;
+ }
+ else {
+ wiFiConnection->securityRequired = false;
+ }
+ }
+ else if (keyValue.lower() == "hidden") {
+ wiFiConnection->isHiddenNetwork = dataValue2.toBool();
+ }
+ }
+ else if ((outerKeyValue.lower() == "802-11-wireless-security") && (wiFiConnection)) {
+ if (keyValue.lower() == "key-mgmt") {
+ wiFiConnection->securitySettings.keyType = nmWiFiKeyTypeToTDEWiFiKeyType(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "wep-tx-keyidx") {
+ wiFiConnection->securitySettings.wepKeyIndex = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "auth-alg") {
+ wiFiConnection->securitySettings.authType = nmWiFiAuthTypeToTDEWiFiAuthType(dataValue2.toString());
+ }
+ else if (keyValue.lower() == "proto") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ TQStringList strings;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ strings.append(innerDataValue.toString());
+ }
+ wiFiConnection->securitySettings.wpaVersion = nmWiFiWPAVersionToTDEWiFiWPAVersion(strings);
+ }
+ else if (keyValue.lower() == "pairwise") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ TQStringList strings;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ wiFiConnection->securitySettings.allowedPairWiseCiphers.append(nmWiFiCipherToTDEWiFiCipher(innerDataValue.toString()));
+ }
+ if ((wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40))
+ || (wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104))
+ || (wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP))
+ || (wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP))) {
+ wiFiConnection->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any);
+ }
+ }
+ else if (keyValue.lower() == "group") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ TQStringList strings;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(nmWiFiCipherToTDEWiFiCipher(innerDataValue.toString()));
+ }
+ if ((wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40))
+ || (wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104))
+ || (wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP))
+ || (wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP))) {
+ wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any);
+ }
+ }
+ else if (keyValue.lower() == "leap-username") {
+ wiFiConnection->securitySettings.leapUsername = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "wep-key-flags") {
+ wiFiConnection->securitySettings.wepKeyFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "wep-key-type") {
+ wiFiConnection->securitySettings.wepKeyType = nmWepKeyTypeToTDEWepKeyType(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "psk-flags") {
+ wiFiConnection->securitySettings.pskFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "leap-password-flags") {
+ wiFiConnection->securitySettings.leapPasswordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ wiFiConnection->securitySettings.valid = true;
+ }
+ else if (outerKeyValue.lower() == "vpn") {
+ if (keyValue.lower() == "service-type") {
+ TQString plugin = dataValue2.toString();
+ plugin.replace("org.freedesktop.NetworkManager.", "");
+ vpnConnection->vpnPluginID = plugin;
+ }
+ else if (keyValue.lower() == "user-name") {
+ vpnConnection->lockedUserName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "data") {
+ vpnConnection->pluginData.clear();
+ TQT_DBusTQStringDataMap nestedConnectionSettingsMap = dataValue2.toStringKeyMap();
+ TQT_DBusTQStringDataMap::const_iterator it4;
+ for (it4 = nestedConnectionSettingsMap.begin(); it4 != nestedConnectionSettingsMap.end(); ++it4) {
+ TQString keyValue4 = it4.key();
+ TQT_DBusData dataValue4 = it4.data();
+ if (dataValue4.type() == TQT_DBusData::String) {
+ vpnConnection->pluginData[keyValue4] = dataValue4.toString();
+ }
+ }
+ }
+ }
+ else if (outerKeyValue.lower() == "wimax") {
+ 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() == "network-name") {
+ wiMaxConnection->networkServiceProvider = dataValue2.toString();
+ }
+ }
+ else if (outerKeyValue.lower() == "vlan") {
+ if (keyValue.lower() == "interface-name") {
+ vlanConnection->kernelName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "parent") {
+ vlanConnection->parentConnectionUUID = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "id") {
+ vlanConnection->vlanID = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "flags") {
+ vlanConnection->vlanFlags = nmVLANFlagsToTDEVLANFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "ingress-priority-map") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQStringList pieces = TQStringList::split(":", innerDataValue.toString(), TRUE);
+ vlanConnection->ingressPriorityMap[pieces[0].toUInt()] = pieces[1].toUInt();;
+ }
+ }
+ else if (keyValue.lower() == "egress-priority-map") {
+ TQT_DBusDataValueList valueList = dataValue2.toTQValueList();
+ TQT_DBusDataValueList::const_iterator it4;
+ for (it4 = valueList.begin(); it4 != valueList.end(); ++it4) {
+ TQT_DBusData innerDataValue = *it4;
+ TQStringList pieces = TQStringList::split(":", innerDataValue.toString(), TRUE);
+ vlanConnection->egressPriorityMap[pieces[0].toUInt()] = pieces[1].toUInt();;
+ }
+ }
+ }
+ else if (outerKeyValue.lower() == "serial") {
+ if (keyValue.lower() == "baud") {
+ connection->serialConfig.baudRate = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "bits") {
+ connection->serialConfig.byteWidth = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "parity") {
+ connection->serialConfig.parity = nmParityToTDEParity(dataValue2.toByte());
+ }
+ else if (keyValue.lower() == "stopbits") {
+ connection->serialConfig.stopBits = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "send-delay") {
+ connection->serialConfig.txDelay = dataValue2.toUInt64();
+ }
+ connection->serialConfig.valid = true;
+ }
+ else if (outerKeyValue.lower() == "ppp") {
+ if (keyValue.lower() == "noauth") {
+ connection->pppConfig.requireServerAuthentication = !(dataValue2.toBool());
+ }
+ else if (keyValue.lower() == "refuse-eap") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::DisableEAP;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::DisableEAP;
+ }
+ else if (keyValue.lower() == "refuse-pap") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::DisablePAP;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::DisablePAP;
+ }
+ else if (keyValue.lower() == "refuse-chap") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::DisableCHAP;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::DisableCHAP;
+ }
+ else if (keyValue.lower() == "refuse-mschap") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::DisableMSCHAP;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::DisableMSCHAP;
+ }
+ else if (keyValue.lower() == "refuse-mschapv2") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::DisableMSCHAPv2;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::DisableMSCHAPv2;
+ }
+ else if (keyValue.lower() == "nobsdcomp") {
+ if (dataValue2.toBool()) connection->pppConfig.flags &= ~TDENetworkPPPFlags::AllowBSDCompression;
+ else connection->pppConfig.flags |= TDENetworkPPPFlags::AllowBSDCompression;
+ }
+ else if (keyValue.lower() == "nodeflate") {
+ if (dataValue2.toBool()) connection->pppConfig.flags &= ~TDENetworkPPPFlags::AllowDeflateCompression;
+ else connection->pppConfig.flags |= TDENetworkPPPFlags::AllowDeflateCompression;
+ }
+ else if (keyValue.lower() == "no-vj-comp") {
+ if (dataValue2.toBool()) connection->pppConfig.flags &= ~TDENetworkPPPFlags::AllowVJCompression;
+ else connection->pppConfig.flags |= TDENetworkPPPFlags::AllowVJCompression;
+ }
+ else if (keyValue.lower() == "require-mppe") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::RequireMPPE;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::RequireMPPE;
+ }
+ else if (keyValue.lower() == "require-mppe-128") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::RequireMPPE128;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::RequireMPPE128;
+ }
+ else if (keyValue.lower() == "mppe-stateful") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::StatefulMPPE;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::StatefulMPPE;
+ }
+ else if (keyValue.lower() == "crtscts") {
+ if (dataValue2.toBool()) connection->pppConfig.flags |= TDENetworkPPPFlags::UseHardwareFlowControl;
+ else connection->pppConfig.flags &= ~TDENetworkPPPFlags::UseHardwareFlowControl;
+ }
+ else if (keyValue.lower() == "baud") {
+ connection->pppConfig.baudRate = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "mru") {
+ connection->pppConfig.mru = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "mtu") {
+ connection->pppConfig.mtu = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "lcp-echo-interval") {
+ connection->pppConfig.lcpEchoPingInterval = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "lcp-echo-failure") {
+ connection->pppConfig.lcpEchoFailureThreshold = dataValue2.toUInt32();
+ }
+ connection->pppConfig.valid = true;
+ }
+ else if (outerKeyValue.lower() == "pppoe") {
+ if (keyValue.lower() == "service") {
+ connection->pppoeConfig.networkServiceProvider = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "username") {
+ connection->pppoeConfig.username = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "password-flags") {
+ connection->pppoeConfig.passwordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ connection->pppoeConfig.secretsValid = true;
+ }
+ else if ((outerKeyValue.lower() == "802-11-olpc-mesh") && (olpcMeshConnection)) {
+ if (keyValue.lower() == "ssid") {
+ 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;
+ olpcMeshConnection->SSID.resize(count+1);
+ olpcMeshConnection->SSID[count] = innerDataValue.toByte();
+ count++;
+ }
+ }
+ else if (keyValue.lower() == "channel") {
+ olpcMeshConnection->channel = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "dhcp-anycast-address") {
+ 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;
+ olpcMeshConnection->anycastDHCPHWAddress.resize(count+1);
+ olpcMeshConnection->anycastDHCPHWAddress[count] = innerDataValue.toByte();
+ count++;
+ }
+ }
+ }
+ else if ((outerKeyValue.lower() == "bluetooth") && (bluetoothConnection)) {
+ if (keyValue.lower() == "bdaddr") {
+ 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() == "type") {
+ bluetoothConnection->type = nmBluetoothModeToTDEBluetoothMode(dataValue2.toString());
+ }
+ }
+ else if ((outerKeyValue.lower() == "cdma") && (modemConnection)) {
+ if (keyValue.lower() == "number") {
+ modemConnection->cdmaConfig.providerDataNumber = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "username") {
+ modemConnection->cdmaConfig.username = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "password-flags") {
+ modemConnection->cdmaConfig.passwordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ modemConnection->type = TDEModemConnectionType::CDMA;
+ modemConnection->cdmaConfig.valid = true;
+ }
+ else if ((outerKeyValue.lower() == "gsm") && (modemConnection)) {
+ if (keyValue.lower() == "number") {
+ modemConnection->gsmConfig.providerDataNumber = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "username") {
+ modemConnection->gsmConfig.username = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "password-flags") {
+ modemConnection->gsmConfig.passwordFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "apn") {
+ modemConnection->gsmConfig.accessPointName = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "network-id") {
+ modemConnection->gsmConfig.networkID = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "network-type") {
+ modemConnection->gsmConfig.networkType = nmGSMModeToTDEGSMMode(dataValue2.toInt32());
+ }
+ else if (keyValue.lower() == "pin-flags") {
+ modemConnection->gsmConfig.pinFlags = nmPasswordFlagsToTDEPasswordFlags(dataValue2.toUInt32());
+ }
+ else if (keyValue.lower() == "allowed-bands") {
+ modemConnection->gsmConfig.allowedFrequencyBands = dataValue2.toUInt32();
+ }
+ else if (keyValue.lower() == "home-only") {
+ modemConnection->gsmConfig.allowRoaming = !dataValue2.toBool();
+ }
+ modemConnection->type = TDEModemConnectionType::GSM;
+ modemConnection->gsmConfig.valid = true;
+ }
+ 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;
+ 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;
+ 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;
+ }
+ }
+ else 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);
+ }
+ }
+ connection->ipConfig.valid = true;
+ }
+ 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;
+ }
+ }
+ else 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);
+ }
+ }
+ connection->ipConfig.valid = true;
+ }
+ }
+ 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())) {
+ loadConnectionAllowedValues(connection);
+ m_connectionList->append(connection);
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ internalNetworkManagementEvent(TDENetworkGlobalEventType::ConnectionListChanged);
+ }
+
+ d->nonReentrantCallActive = false;
+}
+
+void TDENetworkConnectionManager_BackendNM::loadConnectionAllowedValues(TDENetworkConnection* connection) {
+ if (connection) {
+ // Insert all allowed EAP phase 2 methods
+ connection->eapConfig.allowedPhase2NonEAPMethods.clear();
+ connection->eapConfig.allowedPhase2NonEAPMethods.append(TDENetworkIEEE8021xType::MD5);
+ connection->eapConfig.allowedPhase2NonEAPMethods.append(TDENetworkIEEE8021xType::MSCHAPV2);
+ connection->eapConfig.allowedPhase2NonEAPMethods.append(TDENetworkIEEE8021xType::OTP);
+ connection->eapConfig.allowedPhase2NonEAPMethods.append(TDENetworkIEEE8021xType::GTC);
+ connection->eapConfig.allowedPhase2NonEAPMethods.append(TDENetworkIEEE8021xType::TLS);
+
+ connection->eapConfig.allowedPhase2EAPMethods.clear();
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::PAP);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::CHAP);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::MSCHAP);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::MSCHAPV2);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::OTP);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::GTC);
+ connection->eapConfig.allowedPhase2EAPMethods.append(TDENetworkIEEE8021xType::TLS);
+
+ connection->eapConfig.allowedValid = true;
+ }
+}
+
+// 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) {
+ 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;
+ }
+ //TDEWiredEthernetConnection* ethernetConnection = dynamic_cast<TDEWiredEthernetConnection*>(connection);
+ //TDEWiredInfinibandConnection* infinibandConnection = dynamic_cast<TDEWiredInfinibandConnection*>(connection);
+ TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
+ TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection);
+ //TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection);
+ //TDEVLANConnection* vlanConnection = dynamic_cast<TDEVLANConnection*>(connection);
+ //TDEOLPCMeshConnection* olpcMeshConnection = dynamic_cast<TDEVLANConnection*>(connection);
+ //TDEBluetoothConnection* bluetoothConnection = dynamic_cast<TDEBluetoothConnection*>(connection);
+ TDEModemConnection* modemConnection = dynamic_cast<TDEModemConnection*>(connection);
+
+ bool ret = TRUE;
+ ret = ret && loadConnectionSecretsForGroup(uuid, "802-1x");
+ if (wiFiConnection) {
+ ret = ret && loadConnectionSecretsForGroup(uuid, "802-11-wireless-security");
+ }
+ if (vpnConnection) {
+ ret = ret && loadConnectionSecretsForGroup(uuid, "vpn");
+ }
+ ret = ret && loadConnectionSecretsForGroup(uuid, "pppoe");
+ if (modemConnection) {
+ ret = ret && loadConnectionSecretsForGroup(uuid, "cdma");
+ ret = ret && loadConnectionSecretsForGroup(uuid, "gsm");
+ }
+ return ret;
+}
+
+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;
+ }
+ //TDEWiredEthernetConnection* ethernetConnection = dynamic_cast<TDEWiredEthernetConnection*>(connection);
+ //TDEWiredInfinibandConnection* infinibandConnection = dynamic_cast<TDEWiredInfinibandConnection*>(connection);
+ TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
+ TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection);
+ //TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection);
+ //TDEVLANConnection* vlanConnection = dynamic_cast<TDEVLANConnection*>(connection);
+ //TDEOLPCMeshConnection* olpcMeshConnection = dynamic_cast<TDEVLANConnection*>(connection);
+ //TDEBluetoothConnection* bluetoothConnection = dynamic_cast<TDEBluetoothConnection*>(connection);
+ TDEModemConnection* modemConnection = dynamic_cast<TDEModemConnection*>(connection);
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ TQT_DBusTQStringDataMap connectionSecretsMap(TQT_DBusData::String);
+ ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
+ if (ret) {
+#ifndef USE_ASYNC_DBUS_CALLS
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ ret = connectionSettings.GetSecrets(group, connectionSecretsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ if (ret) {
+#else // USE_ASYNC_DBUS_CALLS
+ // 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() + ": " + error.message()))
+ }
+ if (ret) {
+ // Wait for the asynchronous call to return...
+ d->nmConnectionSettingsAsyncCallWaiting[asyncCallID] = true;
+ TQTimer nmCallTimeoutTimer;
+ nmCallTimeoutTimer.start(NM_ASYNC_SECRETS_INTERACTION_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];
+ if (d->nmConnectionSettingsAsyncSettingsErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].name() + ": " + d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].message()));
+ d->nmConnectionSettingsAsyncSettingsErrorResponse.remove(asyncCallID);
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ if (d->nmConnectionSettingsAsyncSettingsResponse.contains(asyncCallID)) {
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+ }
+#endif // USE_ASYNC_DBUS_CALLS
+
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] received DBUS object structure map follows:\n"); 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", 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", 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", 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;
+ }
+ if ((outerKeyValue.lower() == "802-11-wireless-security") && (wiFiConnection)) {
+ if (keyValue.lower() == "wep-key0") {
+ wiFiConnection->securitySettings.wepKey0 = dataValue2.toString();
+ wiFiConnection->securitySettings.wepKeyType = nmWepKeyTypeToTDEWepKeyType(tdeWepKeyTypeToNMWepKeyType(wiFiConnection->securitySettings.wepKeyType), wiFiConnection->securitySettings.wepKey0);
+ }
+ else if (keyValue.lower() == "wep-key1") {
+ wiFiConnection->securitySettings.wepKey1 = dataValue2.toString();
+ wiFiConnection->securitySettings.wepKeyType = nmWepKeyTypeToTDEWepKeyType(tdeWepKeyTypeToNMWepKeyType(wiFiConnection->securitySettings.wepKeyType), wiFiConnection->securitySettings.wepKey1);
+ }
+ else if (keyValue.lower() == "wep-key2") {
+ wiFiConnection->securitySettings.wepKey2 = dataValue2.toString();
+ wiFiConnection->securitySettings.wepKeyType = nmWepKeyTypeToTDEWepKeyType(tdeWepKeyTypeToNMWepKeyType(wiFiConnection->securitySettings.wepKeyType), wiFiConnection->securitySettings.wepKey2);
+ }
+ else if (keyValue.lower() == "wep-key3") {
+ wiFiConnection->securitySettings.wepKey3 = dataValue2.toString();
+ wiFiConnection->securitySettings.wepKeyType = nmWepKeyTypeToTDEWepKeyType(tdeWepKeyTypeToNMWepKeyType(wiFiConnection->securitySettings.wepKeyType), wiFiConnection->securitySettings.wepKey3);
+ }
+ else if (keyValue.lower() == "psk") {
+ wiFiConnection->securitySettings.psk = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "eap-password") {
+ wiFiConnection->securitySettings.leapPassword = dataValue2.toString();
+ }
+ }
+ if ((outerKeyValue.lower() == "vpn") && (vpnConnection)) {
+ if (keyValue.lower() == "secrets") {
+ TQT_DBusTQStringDataMap nestedConnectionSettingsMap = dataValue2.toStringKeyMap();
+ TQT_DBusTQStringDataMap::const_iterator it4;
+ for (it4 = nestedConnectionSettingsMap.begin(); it4 != nestedConnectionSettingsMap.end(); ++it4) {
+ vpnConnection->pluginSecrets.clear();
+ TQString keyValue4 = it4.key();
+ TQT_DBusData dataValue4 = it4.data();
+ if (dataValue4.type() == TQT_DBusData::String) {
+ vpnConnection->pluginSecrets[keyValue4] = dataValue4.toString();
+ }
+ }
+ vpnConnection->secretsValid = true;
+ }
+ }
+ if (outerKeyValue.lower() == "pppoe") {
+ if (keyValue.lower() == "password") {
+ connection->pppoeConfig.password = dataValue2.toString();
+ }
+ connection->pppoeConfig.secretsValid = true;
+ }
+ if (outerKeyValue.lower() == "cdma") {
+ if (keyValue.lower() == "password") {
+ modemConnection->cdmaConfig.password = dataValue2.toString();
+ }
+ modemConnection->cdmaConfig.secretsValid = true;
+ }
+ if (outerKeyValue.lower() == "gsm") {
+ if (keyValue.lower() == "password") {
+ modemConnection->gsmConfig.password = dataValue2.toString();
+ }
+ else if (keyValue.lower() == "pin") {
+ modemConnection->gsmConfig.pin = dataValue2.toString();
+ }
+ modemConnection->gsmConfig.secretsValid = true;
+ }
+ }
+ }
+ }
+ }
+ return TRUE;
+ }
+ else {
+ PRINT_ERROR(TQString("Unable to load secrets for connection with uuid '%1'").arg(uuid))
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_WARNING(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::saveConnection(TDENetworkConnection* connection) {
+ bool timed_out = FALSE;
+ bool command_failed = FALSE;
+
+ if (!connection) {
+ PRINT_ERROR(TQString("connection cannot be NULL!"));
+ return FALSE;
+ }
+
+ // If the UUID is blank, generate a new UUID for this connection and also guarantee that it it truly unique
+ if (connection->UUID == "") {
+ bool unique = false;
+ while (!unique) {
+ connection->UUID = TQUuid::createUuid().toString();
+ connection->UUID.replace("{", "");
+ connection->UUID.replace("}", "");
+ if (!findConnectionByUUID(connection->UUID)) {
+ unique = true;
+ }
+ }
+ }
+
+ // 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
+ TDEWiredEthernetConnection* ethernetConnection = dynamic_cast<TDEWiredEthernetConnection*>(connection);
+ TDEWiredInfinibandConnection* infinibandConnection = dynamic_cast<TDEWiredInfinibandConnection*>(connection);
+ TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
+ TDEVPNConnection* vpnConnection = dynamic_cast<TDEVPNConnection*>(connection);
+ TDEWiMaxConnection* wiMaxConnection = dynamic_cast<TDEWiMaxConnection*>(connection);
+ TDEVLANConnection* vlanConnection = dynamic_cast<TDEVLANConnection*>(connection);
+ TDEOLPCMeshConnection* olpcMeshConnection = dynamic_cast<TDEOLPCMeshConnection*>(connection);
+ TDEBluetoothConnection* bluetoothConnection = dynamic_cast<TDEBluetoothConnection*>(connection);
+ TDEModemConnection* modemConnection = dynamic_cast<TDEModemConnection*>(connection);
+ 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) {
+#ifndef USE_ASYNC_DBUS_CALLS
+ // Obtain connection settings from the path specified
+ DBus::ConnectionSettingsInterface connectionSettings(NM_DBUS_SERVICE, existingConnection);
+ connectionSettings.setConnection(TQT_DBusConnection::systemBus());
+ ret = connectionSettings.GetSettings(connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ if (ret) {
+#else // USE_ASYNC_DBUS_CALLS
+ // 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() + ": " + error.message()))
+ }
+ 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!"))
+ timed_out = true;
+ break;
+ }
+ }
+ connectionSettingsMap = d->nmConnectionSettingsAsyncSettingsResponse[asyncCallID];
+ if (d->nmConnectionSettingsAsyncSettingsErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].name() + ": " + d->nmConnectionSettingsAsyncSettingsErrorResponse[asyncCallID].message()));
+ d->nmConnectionSettingsAsyncSettingsErrorResponse.remove(asyncCallID);
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ if (d->nmConnectionSettingsAsyncSettingsResponse.contains(asyncCallID)) {
+ d->nmConnectionSettingsAsyncSettingsResponse.remove(asyncCallID);
+ }
+#endif // USE_ASYNC_DBUS_CALLS
+ existing = true;
+ }
+ }
+
+ // 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();
+ {
+ groupValid = false;
+ dbusData = outerMap["connection"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ settingsMap["id"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->friendlyName));
+ {
+ TQString type;
+ if (ethernetConnection) type = "802-3-ethernet";
+ else if (infinibandConnection) type = "infiniband";
+ else if (wiFiConnection) type = "802-11-wireless";
+ else if (vpnConnection) type = "vpn";
+ else if (wiMaxConnection) type = "wimax";
+ else if (vlanConnection) type = "vlan";
+ else if (olpcMeshConnection) type = "802-11-olpc-mesh";
+ else if (bluetoothConnection) type = "bluetooth";
+ else if (modemConnection) {
+ if (modemConnection->type == TDEModemConnectionType::CDMA) {
+ type = "cdma";
+ }
+ else if (modemConnection->type == TDEModemConnectionType::GSM) {
+ type = "gsm";
+ }
+ }
+ if (!type.isNull()) settingsMap["type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(type));
+ }
+ settingsMap["uuid"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(connection->UUID));
+ {
+ TQT_DBusDataValueList valueList;
+ {
+ for (TQStringList::Iterator it = connection->authorizedUsers.begin(); it != connection->authorizedUsers.end(); ++it) {
+ TQString assembledString = TQString("user:%1:").arg(*it);
+ valueList.append(TQT_DBusData::fromString(assembledString));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["permissions"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("permissions");
+ }
+ settingsMap["autoconnect"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->autoConnect));
+ settingsMap["read-only"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->readOnly));
+ UPDATE_STRING_SETTING_IF_VALID(connection->masterConnectionUUID, "master", settingsMap)
+ {
+ TQString slaveType = tdeSlaveTypeToNMSlaveType(connection->slaveType);
+ if (slaveType != "") settingsMap["slave-type"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(slaveType));
+ else settingsMap.remove("slave-type");
+ }
+ // settingsMap["timestamp"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt64(connection->lastKnownConnection.toTime_t())); // Probably read-only to us
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("connection", dbusData, TRUE); else outerMap.remove("connection");
+
+ groupValid = false;
+ dbusData = outerMap["802-1x"];
+ {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ {
+ // 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;
+ {
+ 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;
+ {
+ 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;
+ {
+ 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)
+ }
+ else {
+ settingsMap.remove("phase1-peapver");
+ settingsMap.remove("phase1-peaplabel");
+ settingsMap.remove("phase1-fast-provisioning");
+ }
+ if (connection->eapConfig.valid) {
+ settingsMap["phase2-auth"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(tdeEAPTypeToNMEAPType(connection->eapConfig.phase2NonEAPAuthMethod)));
+ settingsMap["phase2-autheap"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(tdeEAPTypeToNMEAPType(connection->eapConfig.phase2EAPAuthMethod)));
+ }
+ else {
+ settingsMap.remove("phase2-auth");
+ settingsMap.remove("phase2-autheap");
+ }
+ if (connection->eapConfig.valid) {
+ TQT_DBusDataValueList valueList;
+ {
+ 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;
+ {
+ 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;
+ {
+ 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;
+ {
+ 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;
+ {
+ 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;
+ {
+ 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");
+
+ groupValid = false;
+ dbusData = outerMap["802-3-ethernet"];
+ if (ethernetConnection) {
+ 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("cloned-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");
+
+ groupValid = false;
+ dbusData = outerMap["infiniband"];
+ if (infinibandConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ 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->mtu > 0) {
+ settingsMap["mtu"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->mtu));
+ }
+ else {
+ settingsMap.remove("mtu");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(tdeIBTransportToNMIBTransport(infinibandConnection->transportMode), "transport-mode", settingsMap)
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("infiniband", dbusData, TRUE); else outerMap.remove("infiniband");
+
+ groupValid = false;
+ dbusData = outerMap["802-11-wireless"];
+ if (wiFiConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ {
+ unsigned int i;
+ TQT_DBusDataValueList valueList;
+ for (i=0; i<wiFiConnection->SSID.count(); i++) {
+ TQT_DBusData innerDataValue = TQT_DBusData::fromByte(wiFiConnection->SSID[i]);
+ valueList.append(innerDataValue);
+ }
+ settingsMap["ssid"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ 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("cloned-mac-address");
+ }
+ if (connection->mtu > 0) {
+ settingsMap["mtu"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->mtu));
+ }
+ else {
+ settingsMap.remove("mtu");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(tdeWiFiModeToNMWiFiMode(wiFiConnection->operatingMode), "mode", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(tdeWiFiFrequencyBandToNMWiFiFrequencyBand(wiFiConnection->bandRestriction), "band", settingsMap)
+ if (wiFiConnection->channelRestriction > 0) {
+ settingsMap["channel"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(wiFiConnection->channelRestriction));
+ }
+ else {
+ settingsMap.remove("channel");
+ }
+ if (wiFiConnection->bitRateRestriction > 0) {
+ settingsMap["rate"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(wiFiConnection->bitRateRestriction/1000));
+ }
+ else {
+ settingsMap.remove("rate");
+ }
+ if (wiFiConnection->powerRestriction > 0) {
+ settingsMap["tx-power"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(wiFiConnection->powerRestriction));
+ }
+ else {
+ settingsMap.remove("tx-power");
+ }
+ if (wiFiConnection->accessPointRestriction.isValid()) {
+ TDENetworkByteList address = wiFiConnection->accessPointRestriction.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["bssid"] = convertDBUSDataToVariantData(nmHWAddress);
+ }
+ else {
+ settingsMap.remove("bssid");
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDEMACAddressList::iterator it;
+ for (it = wiFiConnection->blacklistedBSSIDs.begin(); it != wiFiConnection->blacklistedBSSIDs.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString((*it).toString()));
+ }
+ if (valueList.count() > 0) settingsMap["mac-address-blacklist"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDEMACAddressList::iterator it;
+ for (it = wiFiConnection->heardBSSIDs.begin(); it != wiFiConnection->heardBSSIDs.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString((*it).toString()));
+ }
+ if (valueList.count() > 0) settingsMap["seen-bssids"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ {
+ if (wiFiConnection->securityRequired) {
+ settingsMap["security"] = convertDBUSDataToVariantData(TQT_DBusData::fromString("802-11-wireless-security"));
+ }
+ else {
+ settingsMap.remove("security");
+ }
+ }
+ {
+ if (wiFiConnection->isHiddenNetwork) {
+ settingsMap["hidden"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(true));
+ }
+ else {
+ settingsMap.remove("hidden");
+ }
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("802-11-wireless", dbusData, TRUE); else outerMap.remove("802-11-wireless");
+
+ groupValid = false;
+ dbusData = outerMap["802-11-wireless-security"];
+ if (wiFiConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ if (wiFiConnection->securityRequired) {
+ if (wiFiConnection->securityRequired) {
+ settingsMap["key-mgmt"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(tdeWiFiKeyTypeToNMWiFiKeyType(wiFiConnection->securitySettings.keyType)));
+ }
+ if (wiFiConnection->securitySettings.wepKeyIndex > 0) {
+ settingsMap["wep-tx-keyidx"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(wiFiConnection->securitySettings.wepKeyIndex));
+ }
+ else {
+ settingsMap.remove("wep-tx-keyidx");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(tdeWiFiAuthTypeToNMWiFiAuthType(wiFiConnection->securitySettings.authType), "auth-alg", settingsMap)
+ {
+ TQT_DBusDataValueList valueList;
+ {
+ TQStringList strings = tdeWiFiWPAVersionToNMWiFiWPAVersion(wiFiConnection->securitySettings.wpaVersion);
+ for (TQStringList::Iterator it = strings.begin(); it != strings.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(*it));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["proto"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("proto");
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ {
+ if (wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any)) {
+ if (!wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)) wiFiConnection->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP40);
+ if (!wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)) wiFiConnection->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP104);
+ if (!wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) wiFiConnection->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP);
+ if (!wiFiConnection->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) wiFiConnection->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP);
+ }
+ for (TDENetworkWiFiConnectionCipherList::Iterator it = wiFiConnection->securitySettings.allowedPairWiseCiphers.begin(); it != wiFiConnection->securitySettings.allowedPairWiseCiphers.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(tdeWiFiCipherToNMWiFiCipher(*it)));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["pairwise"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("pairwise");
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ {
+ if (wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any)) {
+ if (!wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)) wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP40);
+ if (!wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)) wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP104);
+ if (!wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP);
+ if (!wiFiConnection->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) wiFiConnection->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP);
+ }
+ for (TDENetworkWiFiConnectionCipherList::Iterator it = wiFiConnection->securitySettings.allowedGroupWiseCiphers.begin(); it != wiFiConnection->securitySettings.allowedGroupWiseCiphers.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(tdeWiFiCipherToNMWiFiCipher(*it)));
+ }
+ }
+ if (valueList.count() > 0) settingsMap["group"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ else settingsMap.remove("group");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.leapUsername, "leap-username", settingsMap)
+ settingsMap["wep-key-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(wiFiConnection->securitySettings.wepKeyFlags)));
+ settingsMap["wep-key-type"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdeWepKeyTypeToNMWepKeyType(wiFiConnection->securitySettings.wepKeyType)));
+ settingsMap["psk-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(wiFiConnection->securitySettings.pskFlags)));
+ settingsMap["leap-password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(wiFiConnection->securitySettings.leapPasswordFlags)));
+ if (wiFiConnection->securitySettings.secretsValid) {
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.wepKey0, "wep-key0", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.wepKey1, "wep-key1", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.wepKey2, "wep-key2", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.wepKey3, "wep-key3", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.psk, "psk", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(wiFiConnection->securitySettings.leapPassword, "leap-password", settingsMap)
+ }
+ else {
+ settingsMap.remove("wep-key0");
+ settingsMap.remove("wep-key1");
+ settingsMap.remove("wep-key2");
+ settingsMap.remove("wep-key3");
+ settingsMap.remove("psk");
+ settingsMap.remove("leap-password");
+ }
+ }
+ else {
+ settingsMap.remove("key-mgmt");
+ settingsMap.remove("wep-tx-keyidx");
+ settingsMap.remove("auth-alg");
+ settingsMap.remove("proto");
+ settingsMap.remove("pairwise");
+ settingsMap.remove("group");
+ settingsMap.remove("leap-username");
+ settingsMap.remove("wep-key-flags");
+ settingsMap.remove("wep-key-type");
+ settingsMap.remove("psk-flags");
+ settingsMap.remove("leap-password-flags");
+ settingsMap.remove("wep-key0");
+ settingsMap.remove("wep-key1");
+ settingsMap.remove("wep-key2");
+ settingsMap.remove("wep-key3");
+ settingsMap.remove("psk");
+ settingsMap.remove("leap-password");
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("802-11-wireless-security", dbusData, TRUE); else outerMap.remove("802-11-wireless-security");
+
+ groupValid = false;
+ dbusData = outerMap["vpn"];
+ if (vpnConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ {
+ TQString pluginService = vpnConnection->vpnPluginID;
+ if (pluginService != "") {
+ pluginService = "org.freedesktop.NetworkManager." + pluginService;
+ }
+ UPDATE_STRING_SETTING_IF_VALID(pluginService, "service-type", settingsMap)
+ }
+ UPDATE_STRING_SETTING_IF_VALID(vpnConnection->lockedUserName, "user-name", settingsMap)
+ {
+ TQMap<TQString, TQT_DBusData> nestedConnectionSettingsMap;
+ TDENetworkSettingsMap::const_iterator it;
+ for (it = vpnConnection->pluginData.begin(); it != vpnConnection->pluginData.end(); ++it) {
+ nestedConnectionSettingsMap[it.key()] = TQT_DBusData::fromString(it.data());
+ }
+ if (nestedConnectionSettingsMap.count() > 0) settingsMap["data"] = convertDBUSDataToVariantData(TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(nestedConnectionSettingsMap)));
+ else settingsMap.remove("data");
+ }
+ if (vpnConnection->secretsValid) {
+ TQMap<TQString, TQT_DBusData> nestedConnectionSettingsMap;
+ TDENetworkSettingsMap::const_iterator it;
+ for (it = vpnConnection->pluginSecrets.begin(); it != vpnConnection->pluginSecrets.end(); ++it) {
+ nestedConnectionSettingsMap[it.key()] = TQT_DBusData::fromString(it.data());
+ }
+ if (nestedConnectionSettingsMap.count() > 0) settingsMap["secrets"] = convertDBUSDataToVariantData(TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(nestedConnectionSettingsMap)));
+ else settingsMap.remove("secrets");
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("vpn", dbusData, TRUE); else outerMap.remove("vpn");
+
+ groupValid = false;
+ dbusData = outerMap["wimax"];
+ if (wiMaxConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ 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");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(wiMaxConnection->networkServiceProvider, "network-name", settingsMap)
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("wimax", dbusData, TRUE); else outerMap.remove("wimax");
+
+ groupValid = false;
+ dbusData = outerMap["vlan"];
+ if (vlanConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ UPDATE_STRING_SETTING_IF_VALID(vlanConnection->kernelName, "interface-name", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(vlanConnection->parentConnectionUUID, "parent", settingsMap)
+ settingsMap["id"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(vlanConnection->vlanID));
+ settingsMap["flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdeVLANFlagsToNMVLANFlags(vlanConnection->vlanFlags)));
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkPriorityMap::const_iterator it;
+ for (it = vlanConnection->ingressPriorityMap.begin(); it != vlanConnection->ingressPriorityMap.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(TQString("%1:%2").arg(it.key()).arg(it.data())));
+ }
+ if (valueList.count() > 0) settingsMap["ingress-priority-map"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ {
+ TQT_DBusDataValueList valueList;
+ TDENetworkPriorityMap::const_iterator it;
+ for (it = vlanConnection->egressPriorityMap.begin(); it != vlanConnection->egressPriorityMap.end(); ++it) {
+ valueList.append(TQT_DBusData::fromString(TQString("%1:%2").arg(it.key()).arg(it.data())));
+ }
+ if (valueList.count() > 0) settingsMap["egress-priority-map"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("vlan", dbusData, TRUE); else outerMap.remove("vlan");
+
+ groupValid = false;
+ dbusData = outerMap["serial"];
+ if (connection->serialConfig.valid) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ settingsMap["baud"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->serialConfig.baudRate));
+ settingsMap["bits"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->serialConfig.byteWidth));
+ settingsMap["parity"] = convertDBUSDataToVariantData(TQT_DBusData::fromByte(tdeParityToNMParity(connection->serialConfig.parity)));
+ settingsMap["stopbits"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->serialConfig.stopBits));
+ settingsMap["send-delay"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt64(connection->serialConfig.txDelay));
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("serial", dbusData, TRUE); else outerMap.remove("serial");
+
+ groupValid = false;
+ dbusData = outerMap["ppp"];
+ if (connection->pppConfig.valid) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ settingsMap["noauth"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->pppConfig.requireServerAuthentication)));
+ settingsMap["refuse-eap"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::DisableEAP));
+ settingsMap["refuse-pap"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::DisablePAP));
+ settingsMap["refuse-chap"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::DisableCHAP));
+ settingsMap["refuse-mschap"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAP));
+ settingsMap["refuse-mschapv2"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAPv2));
+ settingsMap["nobsdcomp"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->pppConfig.flags & TDENetworkPPPFlags::AllowBSDCompression)));
+ settingsMap["nodeflate"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->pppConfig.flags & TDENetworkPPPFlags::AllowDeflateCompression)));
+ settingsMap["no-vj-comp"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(connection->pppConfig.flags & TDENetworkPPPFlags::AllowVJCompression)));
+ settingsMap["require-mppe"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE));
+ settingsMap["require-mppe-128"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE128));
+ settingsMap["mppe-stateful"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::StatefulMPPE));
+ settingsMap["crtscts"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(connection->pppConfig.flags & TDENetworkPPPFlags::UseHardwareFlowControl));
+ settingsMap["baud"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->pppConfig.baudRate));
+ if (connection->pppConfig.mru > 0) {
+ settingsMap["mru"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->pppConfig.mru));
+ }
+ else {
+ settingsMap.remove("mru");
+ }
+ if (connection->pppConfig.mtu > 0) {
+ settingsMap["mtu"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->pppConfig.mtu));
+ }
+ else {
+ settingsMap.remove("mtu");
+ }
+ if (connection->pppConfig.mtu > 0) {
+ settingsMap["lcp-echo-interval"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->pppConfig.lcpEchoPingInterval));
+ }
+ else {
+ settingsMap.remove("lcp-echo-interval");
+ }
+ if (connection->pppConfig.mtu > 0) {
+ settingsMap["lcp-echo-failure"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(connection->pppConfig.lcpEchoFailureThreshold));
+ }
+ else {
+ settingsMap.remove("lcp-echo-failure");
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("ppp", dbusData, TRUE); else outerMap.remove("ppp");
+
+ groupValid = false;
+ dbusData = outerMap["pppoe"];
+ if (connection->pppoeConfig.valid) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ UPDATE_STRING_SETTING_IF_VALID(connection->pppoeConfig.networkServiceProvider, "service", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(connection->pppoeConfig.username, "username", settingsMap)
+ if (connection->pppoeConfig.secretsValid) {
+ UPDATE_STRING_SETTING_IF_VALID(connection->pppoeConfig.password, "password", settingsMap)
+ }
+ settingsMap["password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(connection->pppoeConfig.passwordFlags)));
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("pppoe", dbusData, TRUE); else outerMap.remove("pppoe");
+
+ groupValid = false;
+ dbusData = outerMap["802-11-olpc-mesh"];
+ if (olpcMeshConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ {
+ unsigned int i;
+ TQT_DBusDataValueList valueList;
+ for (i=0; i<olpcMeshConnection->SSID.count(); i++) {
+ TQT_DBusData innerDataValue = TQT_DBusData::fromByte(olpcMeshConnection->SSID[i]);
+ valueList.append(innerDataValue);
+ }
+ settingsMap["ssid"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ settingsMap["channel"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(olpcMeshConnection->channel));
+ {
+ unsigned int i;
+ TQT_DBusDataValueList valueList;
+ for (i=0; i<olpcMeshConnection->anycastDHCPHWAddress.count(); i++) {
+ TQT_DBusData innerDataValue = TQT_DBusData::fromByte(olpcMeshConnection->anycastDHCPHWAddress[i]);
+ valueList.append(innerDataValue);
+ }
+ settingsMap["dhcp-anycast-address"] = convertDBUSDataToVariantData(TQT_DBusData::fromTQValueList(valueList));
+ }
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("802-11-olpc-mesh", dbusData, TRUE); else outerMap.remove("802-11-olpc-mesh");
+
+ groupValid = false;
+ dbusData = outerMap["bluetooth"];
+ if (bluetoothConnection) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ 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["bdaddr"] = convertDBUSDataToVariantData(nmHWAddress);
+ }
+ else {
+ settingsMap.remove("bdaddr");
+ }
+ UPDATE_STRING_SETTING_IF_VALID(tdeBluetoothModeToNMBluetoothMode(bluetoothConnection->type), "type", settingsMap)
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("bluetooth", dbusData, TRUE); else outerMap.remove("bluetooth");
+
+ groupValid = false;
+ dbusData = outerMap["cdma"];
+ if ((modemConnection) && (modemConnection->type == TDEModemConnectionType::CDMA)) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->cdmaConfig.providerDataNumber, "number", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->cdmaConfig.username, "username", settingsMap)
+ if (connection->pppoeConfig.secretsValid) {
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->cdmaConfig.password, "password", settingsMap)
+ }
+ settingsMap["password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(modemConnection->cdmaConfig.passwordFlags)));
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("cdma", dbusData, TRUE); else outerMap.remove("cdma");
+
+ groupValid = false;
+ dbusData = outerMap["gsm"];
+ if ((modemConnection) && (modemConnection->type == TDEModemConnectionType::GSM)) {
+ TQMap<TQString, TQT_DBusData> settingsMap = dbusData.toStringKeyMap().toTQMap();
+ {
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.providerDataNumber, "number", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.username, "username", settingsMap)
+ if (connection->pppoeConfig.secretsValid) {
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.password, "password", settingsMap)
+ }
+ settingsMap["password-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(modemConnection->gsmConfig.passwordFlags)));
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.accessPointName, "apn", settingsMap)
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.networkID, "network-id", settingsMap)
+ settingsMap["network-type"] = convertDBUSDataToVariantData(TQT_DBusData::fromInt32(tdeGSMModeToNMGSMMode(modemConnection->gsmConfig.networkType)));
+ if (connection->pppoeConfig.secretsValid) {
+ UPDATE_STRING_SETTING_IF_VALID(modemConnection->gsmConfig.pin, "pin", settingsMap)
+ }
+ settingsMap["pin-flags"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(tdePasswordFlagsToNMPasswordFlags(modemConnection->gsmConfig.pinFlags)));
+ settingsMap["allowed-bands"] = convertDBUSDataToVariantData(TQT_DBusData::fromUInt32(modemConnection->gsmConfig.allowedFrequencyBands));
+ settingsMap["home-only"] = convertDBUSDataToVariantData(TQT_DBusData::fromBool(!(modemConnection->gsmConfig.allowRoaming)));
+ }
+ dbusData = TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(settingsMap));
+ groupValid = (settingsMap.count() > 0);
+ }
+ if (groupValid) outerMap.insert("gsm", dbusData, TRUE); else outerMap.remove("gsm");
+
+ groupValid = false;
+ 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");
+
+ groupValid = false;
+ 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"); 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"); 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() + ": " + error.message()))
+ }
+ 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!"))
+ timed_out = true;
+ break;
+ }
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ return !timed_out;
+ }
+ else {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return FALSE;
+ }
+ }
+ else {
+#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
+ printf("[network-manager comm debug] Creating new connection\n"); 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&)));
+ connect(d->m_networkManagerSettings, SIGNAL(AsyncErrorResponseDetected(int, const TQT_DBusError)), d, SLOT(processAddConnectionAsyncError(int, const TQT_DBusError)));
+ int asyncCallID;
+ ret = d->m_networkManagerSettings->AddConnectionAsync(asyncCallID, connectionSettingsMap, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ 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!"))
+ timed_out = true;
+ break;
+ }
+ tqApp->processEvents();
+ }
+ if (d->nmAddConnectionAsyncErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmAddConnectionAsyncErrorResponse[asyncCallID].name() + ": " + d->nmAddConnectionAsyncErrorResponse[asyncCallID].message()));
+ d->nmAddConnectionAsyncErrorResponse.remove(asyncCallID);
+ }
+ if (!d->nmAddConnectionAsyncResponse[asyncCallID].data()) {
+ PRINT_ERROR(TQString("NetworkManager did not return a new connection object!"))
+ command_failed = true;
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ if (d->nmAddConnectionAsyncResponse.contains(asyncCallID)) {
+ d->nmAddConnectionAsyncResponse.remove(asyncCallID);
+ }
+ return ((!timed_out) && (!command_failed));
+ }
+ else {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return FALSE;
+ }
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::deleteConnection(TQString uuid) {
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool timed_out = false;
+ 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() + ": " + error.message()))
+ }
+ 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!"))
+ timed_out = true;
+ break;
+ }
+ }
+ d->nmConnectionSettingsAsyncCallWaiting.remove(asyncCallID);
+ return !timed_out;
+ }
+ else {
+ PRINT_ERROR(TQString("Unable to remove connection with uuid '%1'").arg(uuid))
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_WARNING(TQString("connection for provided uuid '%1' was not found").arg(uuid));
+ return FALSE;
+ }
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object"));
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type, TDENetworkErrorStringMap* reason) {
+ // FIXME
+ // This should actually attempt to validate all the settings!
+
+ if (!connection) {
+ return false;
+ }
+
+ if (connection->friendlyName == "") {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidConnectionSetting] = i18n("Connection name is invalid");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidConnectionSetting;
+ return false;
+ }
+
+ if (connection->ipConfig.valid) {
+ // Iterate over all addresses
+ TDENetworkSingleIPConfigurationList::iterator it;
+ for (it = connection->ipConfig.ipConfigurations.begin(); it != connection->ipConfig.ipConfigurations.end(); ++it) {
+ if ((*it).isIPv4()) {
+ if (!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP)) {
+ if (!TDENetworkConnectionManager::validateIPAddress((*it).ipAddress)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidIPv4Setting] = i18n("IPv4 address is invalid");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidIPv4Setting;
+ return false;
+ }
+ }
+ }
+ else if ((*it).isIPv6()) {
+ if (!(connection->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV6DHCPIP)) {
+ if (!TDENetworkConnectionManager::validateIPAddress((*it).ipAddress)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidIPv6Setting] = i18n("IPv6 address is invalid");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidIPv6Setting;
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ TDEWiFiConnection* wiFiConnection = dynamic_cast<TDEWiFiConnection*>(connection);
+ if (wiFiConnection) {
+ if (wiFiConnection->SSID.count() < 1) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessSetting] = i18n("No SSID provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessSetting;
+ return false;
+ }
+ if (wiFiConnection->securityRequired) {
+ if (wiFiConnection->securitySettings.secretsValid) {
+ if ((wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::WEP) || ((wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::DynamicWEP) && ((wiFiConnection->securitySettings.authType == TDENetworkWiFiAuthType::Open) || (wiFiConnection->securitySettings.authType == TDENetworkWiFiAuthType::Shared)))) {
+ if (wiFiConnection->securitySettings.wepKeyType == TDENetworkWepKeyType::Hexadecimal) {
+ if (wiFiConnection->securitySettings.wepKey0 != "") {
+ if ((wiFiConnection->securitySettings.wepKey0.length() != 10) && (wiFiConnection->securitySettings.wepKey0.length() != 26)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 0 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey1 != "") {
+ if ((wiFiConnection->securitySettings.wepKey1.length() != 10) && (wiFiConnection->securitySettings.wepKey1.length() != 26)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 1 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey2 != "") {
+ if ((wiFiConnection->securitySettings.wepKey2.length() != 10) && (wiFiConnection->securitySettings.wepKey2.length() != 26)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 2 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey3 != "") {
+ if ((wiFiConnection->securitySettings.wepKey3.length() != 10) && (wiFiConnection->securitySettings.wepKey3.length() != 26)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 3 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if ((wiFiConnection->securitySettings.wepKey0 == "") && (wiFiConnection->securitySettings.wepKey1 == "") && (wiFiConnection->securitySettings.wepKey2 == "") && (wiFiConnection->securitySettings.wepKey3 == "")) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("No WEP key(s) provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ else if (wiFiConnection->securitySettings.wepKeyType == TDENetworkWepKeyType::Ascii) {
+ if (wiFiConnection->securitySettings.wepKey0 != "") {
+ if ((wiFiConnection->securitySettings.wepKey0.length() != 5) && (wiFiConnection->securitySettings.wepKey0.length() != 13)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 0 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey1 != "") {
+ if ((wiFiConnection->securitySettings.wepKey1.length() != 5) && (wiFiConnection->securitySettings.wepKey1.length() != 13)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 1 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey2 != "") {
+ if ((wiFiConnection->securitySettings.wepKey2.length() != 5) && (wiFiConnection->securitySettings.wepKey2.length() != 13)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 2 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if (wiFiConnection->securitySettings.wepKey3 != "") {
+ if ((wiFiConnection->securitySettings.wepKey3.length() != 5) && (wiFiConnection->securitySettings.wepKey3.length() != 13)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("WEP key 3 has invalid length");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ if ((wiFiConnection->securitySettings.wepKey0 == "") && (wiFiConnection->securitySettings.wepKey1 == "") && (wiFiConnection->securitySettings.wepKey2 == "") && (wiFiConnection->securitySettings.wepKey3 == "")) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("No WEP key(s) provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ else if (wiFiConnection->securitySettings.wepKeyType == TDENetworkWepKeyType::Ascii) {
+ if ((wiFiConnection->securitySettings.wepKey0 == "") && (wiFiConnection->securitySettings.wepKey1 == "") && (wiFiConnection->securitySettings.wepKey2 == "") && (wiFiConnection->securitySettings.wepKey3 == "")) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("No WEP key(s) provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ }
+ else if ((wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::DynamicWEP) && (wiFiConnection->securitySettings.authType == TDENetworkWiFiAuthType::LEAP)) {
+ if ((wiFiConnection->securitySettings.leapUsername.length() < 1) || (wiFiConnection->securitySettings.leapPassword.length() < 1)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("LEAP username and/or password not provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ else if ((wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::WPAAdHoc) || (wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::WPAInfrastructure) || (wiFiConnection->securitySettings.keyType == TDENetworkWiFiKeyType::WPAEnterprise)) {
+ if (wiFiConnection->securitySettings.psk.length() == 64) {
+ // Verify that only hex characters are present in the string
+ bool ok;
+ wiFiConnection->securitySettings.psk.toULongLong(&ok, 16);
+ if (!ok) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("Hexadecimal length PSK contains non-hexadecimal characters");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ else if ((wiFiConnection->securitySettings.psk.length() < 8) || (wiFiConnection->securitySettings.psk.length() > 63)) {
+ if (reason) (*reason)[TDENetworkConnectionErrorFlags::InvalidWirelessKey] = i18n("No PSK provided");
+ if (type) *type |= TDENetworkConnectionErrorFlags::InvalidWirelessKey;
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+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) {
+ if (m_macAddress == "") {
+ d->m_dbusDeviceString = "/";
+ }
+ else {
+ d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ }
+#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+ TQT_DBusObjectPath active_connection;
+ ret = d->m_networkManagerProxy->ActivateConnection(existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), active_connection, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ return checkConnectionStatus(uuid);
+#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
+ connect(d->m_networkManagerProxy, SIGNAL(ActivateConnectionAsyncReply(int, const TQT_DBusObjectPath&)), d, SLOT(processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&)));
+ connect(d->m_networkManagerProxy, SIGNAL(AsyncErrorResponseDetected(int, const TQT_DBusError)), d, SLOT(processAddConnectionAsyncError(int, const TQT_DBusError)));
+#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
+ int asyncCallID;
+ ret = d->m_networkManagerProxy->ActivateConnectionAsync(asyncCallID, existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
+ 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);
+ if (d->nmAddConnectionAsyncErrorResponse.contains(asyncCallID)) {
+ PRINT_ERROR((d->nmAddConnectionAsyncErrorResponse[asyncCallID].name() + ": " + d->nmAddConnectionAsyncErrorResponse[asyncCallID].message()));
+ d->nmAddConnectionAsyncErrorResponse.remove(asyncCallID);
+ }
+ if (!d->nmAddConnectionAsyncResponse[asyncCallID].data()) {
+ PRINT_ERROR(TQString("NetworkManager did not return a new connection object!"))
+ }
+ if (d->nmAddConnectionAsyncResponse.contains(asyncCallID)) {
+ d->nmAddConnectionAsyncResponse.remove(asyncCallID);
+ }
+ return checkConnectionStatus(uuid);
+ }
+ else {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return checkConnectionStatus(uuid);
+ }
+#else
+ return checkConnectionStatus(uuid);
+#endif
+#endif // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+ }
+ else {
+ PRINT_WARNING(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"));
+ 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_WARNING(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"));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+}
+
+TQCString TDENetworkConnectionManager_BackendNM::getActiveConnectionPath(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 (*it);
+ }
+ }
+ PRINT_WARNING(TQString("active connection for provided uuid '%1' was not found").arg(uuid));
+ return TQT_DBusObjectPath();
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object"));
+ return TQT_DBusObjectPath();
+ }
+}
+
+TQStringList TDENetworkConnectionManager_BackendNM::connectionPhysicalDeviceUUIDs(TQString uuid) {
+ if (deviceType() == TDENetworkDeviceType::BackendOnly) {
+ return TQStringList();
+ }
+
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ if (d->m_networkManagerProxy) {
+ TQT_DBusObjectPathList activeConnections = d->m_networkManagerProxy->getActiveConnections(error);
+ TQT_DBusObjectPathList::iterator it;
+ TQStringList ret;
+ 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) {
+ TQValueList<TQT_DBusObjectPath> deviceList = activeConnection.getDevices(error);
+ TQT_DBusObjectPathList::iterator it2;
+ for (it2 = deviceList.begin(); it2 != deviceList.end(); ++it2) {
+ TQString macAddress = macAddressForGenericDevice(*it2);
+ TQString devUUID = tdeDeviceUUIDForMACAddress(macAddress);
+ if (devUUID != "") {
+ ret.append(devUUID);
+ }
+ }
+ }
+ }
+ return ret;
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object"));
+ return TQStringList();
+ }
+}
+
+TDENetworkVPNTypeList TDENetworkConnectionManager_BackendNM::availableVPNTypes() {
+ TDENetworkVPNTypeList ret;
+
+ // Query NetworkManager to verify plugin availability before claiming support for a VPN type
+ TQDir serviceDir(NM_PLUGIN_SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
+ TQStringList services = serviceDir.entryList ().grep (".name", true);
+
+ if (services.count () > 0) {
+ // read in all available Services
+ for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) {
+ TQString service = NM_PLUGIN_SERVICE_DIR + TQString ("/") + *i;
+ TDEConfig* tdeconfig = new TDEConfig (service, true, true, "config");
+ tdeconfig->setGroup ("VPN Connection");
+
+ TQString serviceName = tdeconfig->readEntry("name", TQString());
+ serviceName = serviceName.lower();
+
+ if (serviceName == "openvpn") {
+ ret.append(TDENetworkVPNType::OpenVPN);
+ }
+ if (serviceName == "pptp") {
+ ret.append(TDENetworkVPNType::PPTP);
+ }
+ if (serviceName == "strongswan") {
+ ret.append(TDENetworkVPNType::StrongSwan);
+ }
+ if (serviceName == "vpnc") {
+ ret.append(TDENetworkVPNType::VPNC);
+ }
+
+ delete tdeconfig;
+ }
+ }
+
+ return ret;
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManager_BackendNM::deactivateConnection(TQString uuid) {
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ bool ret;
+ if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
+ existingConnection = getActiveConnectionPath(uuid);
+ if (existingConnection.isValid()) {
+ if (m_macAddress == "") {
+ d->m_dbusDeviceString = "/";
+ }
+ else {
+ d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ }
+#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+ ret = d->m_networkManagerProxy->DeactivateConnection(existingConnection, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+ return checkConnectionStatus(uuid);
+#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
+ connect(d->m_networkManagerProxy, SIGNAL(DeactivateConnectionAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
+#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
+ int asyncCallID;
+ ret = d->m_networkManagerProxy->DeactivateConnectionAsync(asyncCallID, existingConnection, error);
+ if (ret && error.isValid()) {
+ ret = 0;
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ }
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
+ 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() + ": " + error.message()))
+ return checkConnectionStatus(uuid);
+ }
+#else
+ return checkConnectionStatus(uuid);
+#endif
+#endif // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+ }
+ else {
+ PRINT_WARNING(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"));
+ return TDENetworkConnectionStatus::Invalid;
+ }
+}
+
+TQStringList TDENetworkConnectionManager_BackendNM::validSettings() {
+ TQStringList ret;
+
+ ret.append("TDENetworkSingleIPConfiguration::ipAddress");
+ ret.append("TDENetworkSingleIPConfiguration::networkMask");
+ ret.append("TDENetworkSingleIPConfiguration::gateway");
+
+ ret.append("TDENetworkSingleRouteConfiguration::ipAddress");
+ ret.append("TDENetworkSingleRouteConfiguration::networkMask");
+ ret.append("TDENetworkSingleRouteConfiguration::gateway");
+
+ ret.append("TDENetworkIEEE8021xConfiguration::valid");
+ ret.append("TDENetworkIEEE8021xConfiguration::allowedValid");
+ ret.append("TDENetworkIEEE8021xConfiguration::secretsValid");
+ ret.append("TDENetworkIEEE8021xConfiguration::type");
+ ret.append("TDENetworkIEEE8021xConfiguration::userName");
+ ret.append("TDENetworkIEEE8021xConfiguration::anonymousUserName");
+ ret.append("TDENetworkIEEE8021xConfiguration::pacFileName");
+ ret.append("TDENetworkIEEE8021xConfiguration::caCertificate");
+ ret.append("TDENetworkIEEE8021xConfiguration::additionalCAFilesPath");
+ ret.append("TDENetworkIEEE8021xConfiguration::authServerCertSubjectMatch");
+ ret.append("TDENetworkIEEE8021xConfiguration::alternateAuthServerCertSubjectMatch");
+ ret.append("TDENetworkIEEE8021xConfiguration::clientCertificate");
+ ret.append("TDENetworkIEEE8021xConfiguration::forcePEAPVersion");
+ ret.append("TDENetworkIEEE8021xConfiguration::forcePEAPLabel");
+ ret.append("TDENetworkIEEE8021xConfiguration::fastProvisioningFlags");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2NonEAPAuthMethod");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2EAPAuthMethod");
+ ret.append("TDENetworkIEEE8021xConfiguration::allowedPhase2NonEAPMethods");
+ ret.append("TDENetworkIEEE8021xConfiguration::allowedPhase2EAPMethods");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2CaCertificate");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2CaFilesPath");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2AuthServerCertSubjectMatch");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2AlternateAuthServerCertSubjectMatch");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2ClientCertificate");
+ ret.append("TDENetworkIEEE8021xConfiguration::password");
+ ret.append("TDENetworkIEEE8021xConfiguration::passwordFlags");
+ ret.append("TDENetworkIEEE8021xConfiguration::binaryPassword");
+ ret.append("TDENetworkIEEE8021xConfiguration::binaryPasswordFlags");
+ ret.append("TDENetworkIEEE8021xConfiguration::privateKey");
+ ret.append("TDENetworkIEEE8021xConfiguration::privateKeyPassword");
+ ret.append("TDENetworkIEEE8021xConfiguration::privateKeyPasswordFlags");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2PrivateKey");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2PrivateKeyPassword");
+ ret.append("TDENetworkIEEE8021xConfiguration::phase2PrivateKeyPasswordFlags");
+ ret.append("TDENetworkIEEE8021xConfiguration::forceSystemCaCertificates");
+
+ ret.append("TDENetworkPPPConfiguration::valid");
+ ret.append("TDENetworkPPPConfiguration::requireServerAuthentication");
+ ret.append("TDENetworkPPPConfiguration::flags");
+ ret.append("TDENetworkPPPConfiguration::baudRate");
+ ret.append("TDENetworkPPPConfiguration::mru");
+ ret.append("TDENetworkPPPConfiguration::mtu");
+ ret.append("TDENetworkPPPConfiguration::lcpEchoPingInterval");
+ ret.append("TDENetworkPPPConfiguration::lcpEchoFailureThreshold");
+
+ ret.append("TDENetworkPPPOEConfiguration::valid");
+ ret.append("TDENetworkPPPOEConfiguration::secretsValid");
+ ret.append("TDENetworkPPPOEConfiguration::networkServiceProvider");
+ ret.append("TDENetworkPPPOEConfiguration::username");
+ ret.append("TDENetworkPPPOEConfiguration::password");
+ ret.append("TDENetworkPPPOEConfiguration::passwordFlags");
+
+ ret.append("TDENetworkSerialConfiguration::valid");
+ ret.append("TDENetworkSerialConfiguration::baudRate");
+ ret.append("TDENetworkSerialConfiguration::byteWidth");
+ ret.append("TDENetworkSerialConfiguration::parity");
+ ret.append("TDENetworkSerialConfiguration::stopBits");
+ ret.append("TDENetworkSerialConfiguration::txDelay");
+
+ ret.append("TDENetworkCDMAConfiguration::valid");
+ ret.append("TDENetworkCDMAConfiguration::secretsValid");
+ ret.append("TDENetworkCDMAConfiguration::providerDataNumber");
+ ret.append("TDENetworkCDMAConfiguration::username");
+ ret.append("TDENetworkCDMAConfiguration::password");
+ ret.append("TDENetworkCDMAConfiguration::passwordFlags");
+
+ ret.append("TDENetworkGSMConfiguration::valid");
+ ret.append("TDENetworkGSMConfiguration::secretsValid");
+ ret.append("TDENetworkGSMConfiguration::providerDataNumber");
+ ret.append("TDENetworkGSMConfiguration::username");
+ ret.append("TDENetworkGSMConfiguration::password");
+ ret.append("TDENetworkGSMConfiguration::passwordFlags");
+ ret.append("TDENetworkGSMConfiguration::accessPointName");
+ ret.append("TDENetworkGSMConfiguration::networkID");
+ ret.append("TDENetworkGSMConfiguration::networkType");
+ ret.append("TDENetworkGSMConfiguration::pin");
+ ret.append("TDENetworkGSMConfiguration::pinFlags");
+ ret.append("TDENetworkGSMConfiguration::allowedFrequencyBands");
+ ret.append("TDENetworkGSMConfiguration::allowRoaming");
+
+ ret.append("TDENetworkWiFiSecurityConfiguration::valid");
+ ret.append("TDENetworkWiFiSecurityConfiguration::secretsValid");
+ ret.append("TDENetworkWiFiSecurityConfiguration::keyType");
+ ret.append("TDENetworkWiFiSecurityConfiguration::authType");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wpaVersion");
+ ret.append("TDENetworkWiFiSecurityConfiguration::cipher");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKey0");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKey1");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKey2");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKey3");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKeyFlags");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKeyIndex");
+ ret.append("TDENetworkWiFiSecurityConfiguration::wepKeyType");
+ ret.append("TDENetworkWiFiSecurityConfiguration::allowedPairWiseCiphers");
+ ret.append("TDENetworkWiFiSecurityConfiguration::allowedGroupWiseCiphers");
+ ret.append("TDENetworkWiFiSecurityConfiguration::psk");
+ ret.append("TDENetworkWiFiSecurityConfiguration::pskFlags");
+ ret.append("TDENetworkWiFiSecurityConfiguration::leapUsername");
+ ret.append("TDENetworkWiFiSecurityConfiguration::leapPassword");
+ ret.append("TDENetworkWiFiSecurityConfiguration::leapPasswordFlags");
+
+ ret.append("TDENetworkIPConfiguration::valid");
+ ret.append("TDENetworkIPConfiguration::connectionFlags");
+ ret.append("TDENetworkIPConfiguration::ipConfigurations");
+ ret.append("TDENetworkIPConfiguration::routeConfigurations");
+ ret.append("TDENetworkIPConfiguration::broadcast");
+ ret.append("TDENetworkIPConfiguration::destination");
+ ret.append("TDENetworkIPConfiguration::resolvers");
+ ret.append("TDENetworkIPConfiguration::searchDomains");
+ ret.append("TDENetworkIPConfiguration::dhcpClientIdentifier");
+
+ ret.append("TDENetworkConnection::UUID");
+ ret.append("TDENetworkConnection::friendlyName");
+ ret.append("TDENetworkConnection::ipConfig");
+ ret.append("TDENetworkConnection::lockedHWAddress");
+ ret.append("TDENetworkConnection::manualHWAddress");
+ ret.append("TDENetworkConnection::readOnly");
+ ret.append("TDENetworkConnection::autoConnect");
+ ret.append("TDENetworkConnection::fullDuplex");
+ ret.append("TDENetworkConnection::requireIPV4");
+ ret.append("TDENetworkConnection::requireIPV6");
+ ret.append("TDENetworkConnection::mtu");
+ ret.append("TDENetworkConnection::eapConfig");
+ ret.append("TDENetworkConnection::pppConfig");
+ ret.append("TDENetworkConnection::pppoeConfig");
+ ret.append("TDENetworkConnection::serialConfig");
+ ret.append("TDENetworkConnection::authorizedUsers");
+ ret.append("TDENetworkConnection::masterConnectionUUID");
+ ret.append("TDENetworkConnection::slaveType");
+ ret.append("TDENetworkConnection::lastKnownConnection");
+
+ ret.append("TDEWiFiConnection::SSID");
+ ret.append("TDEWiFiConnection::operatingMode");
+ ret.append("TDEWiFiConnection::bandRestriction");
+ ret.append("TDEWiFiConnection::channelRestriction");
+ ret.append("TDEWiFiConnection::bitRateRestriction");
+ ret.append("TDEWiFiConnection::powerRestriction");
+ ret.append("TDEWiFiConnection::accessPointRestriction");
+ ret.append("TDEWiFiConnection::blacklistedBSSIDs");
+ ret.append("TDEWiFiConnection::heardBSSIDs");
+ ret.append("TDEWiFiConnection::isHiddenNetwork");
+ ret.append("TDEWiFiConnection::securityRequired");
+ ret.append("TDEWiFiConnection::securitySettings");
+
+ ret.append("TDEWiredInfinibandConnection::transportMode");
+
+ ret.append("TDEVPNConnection::vpnPluginID");
+ ret.append("TDEVPNConnection::lockedUserName");
+ ret.append("TDEVPNConnection::pluginData");
+ ret.append("TDEVPNConnection::secretsValid");
+ ret.append("TDEVPNConnection::pluginSecrets");
+
+ ret.append("TDEWiMaxConnection::networkServiceProvider");
+
+ ret.append("TDEVLANConnection::kernelName");
+ ret.append("TDEVLANConnection::parentConnectionUUID");
+ ret.append("TDEVLANConnection::vlanID");
+ ret.append("TDEVLANConnection::vlanFlags");
+ ret.append("TDEVLANConnection::ingressPriorityMap");
+ ret.append("TDEVLANConnection::egressPriorityMap");
+
+ ret.append("TDEOLPCMeshConnection::SSID");
+ ret.append("TDEOLPCMeshConnection::channel");
+ ret.append("TDEOLPCMeshConnection::anycastDHCPHWAddress");
+
+ ret.append("TDEBluetoothConnection::type");
+
+ ret.append("TDEModemConnection::type");
+ ret.append("TDEModemConnection::cdmaConfig");
+ ret.append("TDEModemConnection::gsmConfig");
+
+ ret.append("TDEWiredInfinibandConnection::transportMode");
+
+ return ret;
+}
+
+TDENetworkWiFiAPInfo* TDENetworkConnectionManager_BackendNM::getAccessPointDetails(TQString dbusPath) {
+ if (dbusPath == "") {
+ return NULL;
+ }
+
+ 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.fromString(accessPoint.getHwAddress(error));
+ apInfo->maxBitrate = accessPoint.getMaxBitrate(error);
+ apInfo->signalQuality = (accessPoint.getStrength(error)/100.0);
+
+ apInfo->valid = true;
+
+ return apInfo;
+}
+
+TDENetworkHWNeighborList* TDENetworkConnectionManager_BackendNM::siteSurvey() {
+ TQT_DBusError error;
+ bool ret;
+
+ TDENetworkDeviceType::TDENetworkDeviceType myDeviceType = deviceType();
+ d->m_dbusDeviceString = deviceInterfaceString(m_macAddress);
+ clearTDENetworkHWNeighborList();
+
+ if (myDeviceType == TDENetworkDeviceType::WiFi) {
+ DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, d->m_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);
+ // Ensure that this AP is monitored for changes
+ d->internalProcessWiFiAccessPointAdded(*it);
+ }
+ }
+ }
+ }
+
+ 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() + ": " + error.message()))
+ 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() + ": " + error.message()))
+ return FALSE;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDENetworkConnectionManager_BackendNM::enableNetworking(bool enable) {
+ // FIXME
+ // Yes, this abuses the Sleep command
+ // Is there a better way to do it?
+ if (d->m_networkManagerProxy) {
+ int asynccallid;
+ TQT_DBusError error;
+ d->m_networkManagerProxy->SleepAsync(asynccallid, !enable, error);
+ if (error.isValid()) {
+ // Error!
+ PRINT_ERROR((error.name() + ": " + error.message()))
+ return FALSE;
+ }
+ else {
+ // FIXME
+ // Wait for async reply before returning...
+ return TRUE;
+ }
+ }
+ 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() + ": " + error.message()))
+ 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() + ": " + error.message()))
+ return FALSE;
+ }
+ else {
+ return ret;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+TQStringList TDENetworkConnectionManager_BackendNM::defaultNetworkDevices() {
+ // Cycle through all available connections and see which one is default, then find all devices for that connection...
+ TQStringList ret;
+
+ 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.getDefault(error)) {
+ // This is the default ipv4 connection
+ TQString uuid = activeConnection.getUuid(error);
+ TQStringList devices = connectionPhysicalDeviceUUIDs(uuid);
+ for (TQStringList::Iterator it2 = devices.begin(); it2 != devices.end(); ++it2) {
+ ret.append(*it);
+ }
+ }
+ else if (activeConnection.getDefault6(error)) {
+ // This is the default ipv6 connection
+ TQString uuid = activeConnection.getUuid(error);
+ TQStringList devices = connectionPhysicalDeviceUUIDs(uuid);
+ for (TQStringList::Iterator it2 = devices.begin(); it2 != devices.end(); ++it2) {
+ ret.append(*it);
+ }
+ }
+ }
+ return ret;
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object"));
+ return TQStringList();
+ }
+}
+
+TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_vpnProxy(NULL), nonReentrantCallActive(false), vpn_service_error_notified(false), device_autoconnect_error_notified(false), m_parent(parent), m_prevDeviceState(-1) {
+ // Set up global signal handler
+ m_dbusSignalConnection = new TQT_DBusConnection(TQT_DBusConnection::systemBus());
+ m_dbusSignalReceiver = new TDENetworkConnectionManager_BackendNM_DBusSignalReceiver(this);
+ m_dbusSignalConnection->connect(m_dbusSignalReceiver, TQT_SLOT(dbusSignal(const TQT_DBusMessage&)));
+}
+
+TDENetworkConnectionManager_BackendNMPrivate::~TDENetworkConnectionManager_BackendNMPrivate() {
+ // Destroy global signal handler
+ if (m_dbusSignalConnection) delete m_dbusSignalConnection;
+ if (m_dbusSignalReceiver) delete m_dbusSignalReceiver;
+
+ // Destroy proxy objects
+ TQMap<TQString, DBus::AccessPointProxy*>::iterator it;
+ for (it = m_accessPointProxyList.begin(); it != m_accessPointProxyList.end(); ++it) {
+ DBus::AccessPointProxy *apProxy = it.data();
+ if (apProxy) {
+ delete apProxy;
+ }
+ }
+ m_accessPointProxyList.clear();
+}
+
+#include "network-manager.moc"
+#include "network-manager_p.moc" \ No newline at end of file
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.h b/tdecore/tdehw/networkbackends/network-manager/network-manager.h
new file mode 100644
index 000000000..a9042f1c4
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.h
@@ -0,0 +1,263 @@
+/* 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_H
+#define _TDENETWORKBACKEND_NETWORKMANAGER_H
+
+#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_VPN_DBUS_PLUGIN_PATH "/org/freedesktop/NetworkManager/VPN/Plugin"
+
+#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
+#define NM_DBUS_ACTIVE_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Connection.Active"
+#define NM_DBUS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device"
+#define NM_DBUS_WIRED_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wired"
+#define NM_DBUS_WIRELESS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wireless"
+#define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings"
+#define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection"
+#define NM_VPN_DBUS_PLUGIN_SERVICE "org.freedesktop.NetworkManager.VPN.Plugin"
+#define NM_VPN_DBUS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.VPN.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_VPN_STATE_UNKNOWN 0
+#define NM_VPN_STATE_PREPARE 1
+#define NM_VPN_STATE_NEED_AUTH 2
+#define NM_VPN_STATE_CONNECT 3
+#define NM_VPN_STATE_IP_CONFIG_GET 4
+#define NM_VPN_STATE_ACTIVATED 5
+#define NM_VPN_STATE_FAILED 6
+#define NM_VPN_STATE_DISCONNECTED 7
+//====================================================================================================
+#define NM_DEVICE_CAP_NONE 0
+#define NM_DEVICE_CAP_NM_SUPPORTED 1
+#define NM_DEVICE_CAP_CARRIER_DETECT 2
+//====================================================================================================
+#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
+//====================================================================================================
+#define NM_WEP_TYPE_HEXADECIMAL 1
+#define NM_WEP_TYPE_PASSPHRASE 2
+//====================================================================================================
+#define NM_VLAN_REORDER_PACKET_HEADERS 0x01
+#define NM_VLAN_USE_GVRP 0x02
+#define NM_VLAN_LOOSE_BINDING 0x04
+//====================================================================================================
+#define NM_GSM_3G_ALL -1
+#define NM_GSM_3G_ONLY 0
+#define NM_GSM_GPRS_EDGE_ONLY 1
+#define NM_GSM_PREFER_3G 2
+#define NM_GSM_PREFER_2G 3
+//====================================================================================================
+#define NM_802_11_MODE_UNKNOWN 0
+#define NM_802_11_MODE_ADHOC 1
+#define NM_802_11_MODE_INFRASTRUCTURE 2
+//====================================================================================================
+#define NM_802_11_DEVICE_CAP_NONE 0x0
+#define NM_802_11_DEVICE_CAP_CIPHER_WEP40 0x1
+#define NM_802_11_DEVICE_CAP_CIPHER_WEP104 0x2
+#define NM_802_11_DEVICE_CAP_CIPHER_TKIP 0x4
+#define NM_802_11_DEVICE_CAP_CIPHER_CCMP 0x8
+#define NM_802_11_DEVICE_CAP_WPA 0x10
+#define NM_802_11_DEVICE_CAP_RSN 0x20
+//====================================================================================================
+#define NM_PLUGIN_SERVICE_DIR "/etc/NetworkManager/VPN"
+//====================================================================================================
+
+//====================================================================================================
+// Device state change reason codes
+// Taken from NetworkManager.h
+//====================================================================================================
+#define NM_DEVICE_STATE_REASON_NONE 0
+#define NM_DEVICE_STATE_REASON_UNKNOWN 1
+#define NM_DEVICE_STATE_REASON_NOW_MANAGED 2
+#define NM_DEVICE_STATE_REASON_NOW_UNMANAGED 3
+#define NM_DEVICE_STATE_REASON_CONFIG_FAILED 4
+#define NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE 5
+#define NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED 6
+#define NM_DEVICE_STATE_REASON_NO_SECRETS 7
+#define NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT 8
+#define NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED 9
+#define NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED 10
+#define NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT 11
+#define NM_DEVICE_STATE_REASON_PPP_START_FAILED 12
+#define NM_DEVICE_STATE_REASON_PPP_DISCONNECT 13
+#define NM_DEVICE_STATE_REASON_PPP_FAILED 14
+#define NM_DEVICE_STATE_REASON_DHCP_START_FAILED 15
+#define NM_DEVICE_STATE_REASON_DHCP_ERROR 16
+#define NM_DEVICE_STATE_REASON_DHCP_FAILED 17
+#define NM_DEVICE_STATE_REASON_SHARED_START_FAILED 18
+#define NM_DEVICE_STATE_REASON_SHARED_FAILED 19
+#define NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED 20
+#define NM_DEVICE_STATE_REASON_AUTOIP_ERROR 21
+#define NM_DEVICE_STATE_REASON_AUTOIP_FAILED 22
+#define NM_DEVICE_STATE_REASON_MODEM_BUSY 23
+#define NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE 24
+#define NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER 25
+#define NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT 26
+#define NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED 27
+#define NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED 28
+#define NM_DEVICE_STATE_REASON_GSM_APN_FAILED 29
+#define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING 30
+#define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED 31
+#define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT 32
+#define NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED 33
+#define NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED 34
+#define NM_DEVICE_STATE_REASON_FIRMWARE_MISSING 35
+#define NM_DEVICE_STATE_REASON_REMOVED 36
+#define NM_DEVICE_STATE_REASON_SLEEPING 37
+#define NM_DEVICE_STATE_REASON_CONNECTION_REMOVED 38
+#define NM_DEVICE_STATE_REASON_USER_REQUESTED 39
+#define NM_DEVICE_STATE_REASON_CARRIER 40
+#define NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED 41
+#define NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE 42
+#define NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND 43
+#define NM_DEVICE_STATE_REASON_BT_FAILED 44
+#define NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED 45
+#define NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED 46
+#define NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED 47
+#define NM_DEVICE_STATE_REASON_GSM_SIM_WRONG 48
+#define NM_DEVICE_STATE_REASON_INFINIBAND_MODE 49
+#define NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED 50
+#define NM_DEVICE_STATE_REASON_BR2684_FAILED 51
+#define NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE 52
+#define NM_DEVICE_STATE_REASON_SSID_NOT_FOUND 53
+#define NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED 54
+//====================================================================================================
+
+class TDENetworkConnectionManager_BackendNMPrivate;
+
+class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkConnectionManager
+{
+ Q_OBJECT
+
+ public:
+ TDENetworkConnectionManager_BackendNM(TQString macAddress);
+ ~TDENetworkConnectionManager_BackendNM();
+
+ virtual TQString backendName();
+ virtual TDENetworkDeviceType::TDENetworkDeviceType deviceType();
+ virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus();
+ virtual TDENetworkDeviceInformation deviceInformation();
+ virtual TDENetworkDeviceInformation deviceStatus();
+
+ virtual void loadConnectionInformation();
+ virtual void loadConnectionAllowedValues(TDENetworkConnection* connection);
+ virtual bool loadConnectionSecrets(TQString uuid);
+ virtual bool saveConnection(TDENetworkConnection* connection);
+ virtual bool deleteConnection(TQString uuid);
+ virtual bool verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type=NULL, TDENetworkErrorStringMap* reason=NULL);
+
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid);
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid);
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid);
+ virtual TQStringList validSettings();
+
+ virtual TDENetworkHWNeighborList* siteSurvey();
+ virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid);
+ virtual TDENetworkVPNTypeList availableVPNTypes();
+
+ virtual bool networkingEnabled();
+ virtual bool wiFiHardwareEnabled();
+
+ virtual bool enableNetworking(bool enable);
+ virtual bool enableWiFi(bool enable);
+ virtual bool wiFiEnabled();
+
+ virtual TQStringList defaultNetworkDevices();
+
+ private:
+ TDENetworkDeviceType::TDENetworkDeviceType nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType);
+ TQString deviceInterfaceString(TQString macAddress);
+ bool loadConnectionSecretsForGroup(TQString uuid, TQString group);
+ TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath);
+ TDENetworkConnectionType::TDENetworkConnectionType connectionType(TQString dbusPath);
+ TQCString getActiveConnectionPath(TQString uuid);
+
+ private:
+ TDENetworkConnectionManager_BackendNMPrivate* d;
+ friend class TDENetworkConnectionManager_BackendNMPrivate;
+};
+
+#endif // _TDENETWORKBACKEND_NETWORKMANAGER_H \ No newline at end of file
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager_p.h b/tdecore/tdehw/networkbackends/network-manager/network-manager_p.h
new file mode 100644
index 000000000..925fd4389
--- /dev/null
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager_p.h
@@ -0,0 +1,140 @@
+/* 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>
+#include <tquuid.h>
+
+/* TDE headers */
+#include <kdebug.h>
+#include <tdelocale.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 "infinibandproxy.h"
+#include "wifiproxy.h"
+#include "wimaxproxy.h"
+#include "bluetoothproxy.h"
+#include "olpcmeshproxy.h"
+#include "activeconnectionproxy.h"
+#include "accesspointproxy.h"
+#include "vpnpluginproxy.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 TQMap<uint, TQT_DBusError> NMAddConnectionAsyncErrorResponseMap;
+
+typedef TQValueList<TQT_DBusObjectPath> TQT_DBusObjectPathList;
+
+class TDENetworkConnectionManager_BackendNM;
+class TDENetworkConnectionManager_BackendNMPrivate;
+
+class TDENetworkConnectionManager_BackendNM_DBusSignalReceiver : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ TDENetworkConnectionManager_BackendNM_DBusSignalReceiver(TDENetworkConnectionManager_BackendNMPrivate*);
+ ~TDENetworkConnectionManager_BackendNM_DBusSignalReceiver();
+
+ public slots:
+ void dbusSignal(const TQT_DBusMessage&);
+
+ private:
+ TDENetworkConnectionManager_BackendNMPrivate* m_parent;
+};
+
+class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM*);
+ ~TDENetworkConnectionManager_BackendNMPrivate();
+
+ public:
+ DBus::NetworkManagerProxy* m_networkManagerProxy;
+ DBus::SettingsInterface* m_networkManagerSettings;
+ DBus::DeviceProxy* m_networkDeviceProxy;
+ DBus::WiFiDeviceProxy* m_wiFiDeviceProxy;
+ DBus::VPNPluginProxy* m_vpnProxy;
+ NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
+ NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
+ NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
+ NMAddConnectionAsyncErrorResponseMap nmConnectionSettingsAsyncSettingsErrorResponse;
+ NMAddConnectionAsyncErrorResponseMap nmConnectionSettingsUpdateAsyncSettingsErrorResponse;
+ NMAddConnectionAsyncErrorResponseMap nmAddConnectionAsyncErrorResponse;
+ bool nonReentrantCallActive;
+ TQString m_dbusDeviceString;
+ bool vpn_service_error_notified;
+ bool device_autoconnect_error_notified;
+
+ public slots:
+ void processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&);
+ void processConnectionSettingsUpdateAsyncReply(int);
+ void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&);
+ void processConnectionSettingsAsyncError(int, const TQT_DBusError);
+ void processConnectionSettingsUpdateAsyncError(int, const TQT_DBusError);
+ void processAddConnectionAsyncError(int, const TQT_DBusError);
+
+ void internalProcessGlobalStateChanged(TQ_UINT32 state);
+ void internalProcessVPNStateChanged(TQ_UINT32 state);
+ void internalProcessVPNLoginBanner(const TQString& banner);
+ void internalProcessVPNFailure(TQ_UINT32 reason);
+ void internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason);
+ void internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&);
+ void internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&);
+ void internalProcessWiFiPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&);
+ void internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&);
+
+ private:
+ TDENetworkConnectionManager_BackendNM* m_parent;
+ TQMap<TQString, DBus::AccessPointProxy*> m_accessPointProxyList;
+ TQT_DBusConnection *m_dbusSignalConnection;
+ TDENetworkConnectionManager_BackendNM_DBusSignalReceiver *m_dbusSignalReceiver;
+ TQ_UINT32 m_prevDeviceState;
+
+ friend class TDENetworkConnectionManager_BackendNM_DBusSignalReceiver;
+};
+
+#endif // _TDENETWORKBACKEND_NETWORKMANAGER_P_H \ No newline at end of file
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
new file mode 100644
index 000000000..69e7856cb
--- /dev/null
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -0,0 +1,6206 @@
+/* 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.
+*/
+
+#include <tdehardwaredevices.h>
+
+#include <tqfile.h>
+#include <tqdir.h>
+#include <tqstringlist.h>
+#include <tqsocketnotifier.h>
+
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <tdetempfile.h>
+#include <ksimpledirwatch.h>
+#include <kstandarddirs.h>
+
+#include <tdeapplication.h>
+#include <dcopclient.h>
+
+#include <libudev.h>
+
+#include <fcntl.h>
+#include <poll.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <linux/cdrom.h>
+
+// Backlight devices
+#include <linux/fb.h>
+
+// Input devices
+#include <linux/input.h>
+
+// Network devices
+#include <sys/types.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+// Network connection manager
+#include "tdenetworkconnections.h"
+
+// Compile-time configuration
+#include "config.h"
+
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+ #include "networkbackends/network-manager/network-manager.h"
+#endif // WITH_NETWORK_MANAGER_BACKEND
+
+// uPower and uDisks2 integration
+#if defined(WITH_UPOWER) || defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+ #include <tqdbusconnection.h>
+#endif // defined(WITH_UPOWER) || defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+#if defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+ #include <tqdbuserror.h>
+ #include <tqdbusdatamap.h>
+ #include <tqdbusobjectpath.h>
+#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+#if defined(WITH_UDISKS)
+ #include "tqdbusdatalist.h"
+#endif // ddefined(WITH_UDISKS)
+
+// BEGIN BLOCK
+// Copied from include/linux/genhd.h
+#define GENHD_FL_REMOVABLE 1
+#define GENHD_FL_MEDIA_CHANGE_NOTIFY 4
+#define GENHD_FL_CD 8
+#define GENHD_FL_UP 16
+#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
+#define GENHD_FL_EXT_DEVT 64
+#define GENHD_FL_NATIVE_CAPACITY 128
+#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256
+// END BLOCK
+
+// NOTE TO DEVELOPERS
+// This command will greatly help when attempting to find properties to distinguish one device from another
+// udevadm info --query=all --path=/sys/....
+
+// This routine is courtsey of an answer on "Stack Overflow"
+// It takes an LSB-first int and makes it an MSB-first int (or vice versa)
+unsigned int reverse_bits(register unsigned int x)
+{
+ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
+ x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
+ x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
+ x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
+ return((x >> 16) | (x << 16));
+}
+
+#define BIT_IS_SET(bits, n) (bits[n >> 3] & (1 << (n & 0x7)))
+
+TDESensorCluster::TDESensorCluster() {
+ label = TQString::null;
+ current = -1;
+ minimum = -1;
+ maximum = -1;
+ warning = -1;
+ critical = -1;
+}
+
+TDEGenericDevice::TDEGenericDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TQObject() {
+ m_deviceType = dt;
+ m_deviceName = dn;
+
+ m_parentDevice = 0;
+ m_friendlyName = TQString::null;
+ m_blacklistedForUpdate = false;
+}
+
+TDEGenericDevice::~TDEGenericDevice() {
+}
+
+TDEGenericDeviceType::TDEGenericDeviceType TDEGenericDevice::type() {
+ return m_deviceType;
+}
+
+TQString TDEGenericDevice::name() {
+ return m_deviceName;
+}
+
+void TDEGenericDevice::internalSetName(TQString dn) {
+ m_deviceName = dn;
+}
+
+TQString TDEGenericDevice::vendorName() {
+ return m_vendorName;
+}
+
+void TDEGenericDevice::internalSetVendorName(TQString vn) {
+ m_vendorName = vn;
+}
+
+TQString TDEGenericDevice::vendorModel() {
+ return m_vendorModel;
+}
+
+void TDEGenericDevice::internalSetVendorModel(TQString vm) {
+ m_vendorModel = vm;
+}
+
+TQString TDEGenericDevice::serialNumber() {
+ return m_serialNumber;
+}
+
+void TDEGenericDevice::internalSetSerialNumber(TQString sn) {
+ m_serialNumber = sn;
+}
+
+TQString TDEGenericDevice::systemPath() {
+ if (!m_systemPath.endsWith("/")) {
+ m_systemPath += "/";
+ }
+ return m_systemPath;
+}
+
+void TDEGenericDevice::internalSetSystemPath(TQString sp) {
+ m_systemPath = sp;
+}
+
+TQString TDEGenericDevice::deviceNode() {
+ return m_deviceNode;
+}
+
+void TDEGenericDevice::internalSetDeviceNode(TQString sn) {
+ m_deviceNode = sn;
+}
+
+TQString TDEGenericDevice::deviceBus() {
+ return m_deviceBus;
+}
+
+void TDEGenericDevice::internalSetDeviceBus(TQString db) {
+ m_deviceBus = db;
+}
+
+TQString TDEGenericDevice::uniqueID() {
+ m_uniqueID = m_systemPath+m_deviceNode;
+ return m_uniqueID;
+}
+
+TQString TDEGenericDevice::vendorID() {
+ return m_vendorID;
+}
+
+void TDEGenericDevice::internalSetVendorID(TQString id) {
+ m_vendorID = id;
+ m_vendorID.replace("0x", "");
+}
+
+TQString TDEGenericDevice::modelID() {
+ return m_modelID;
+}
+
+void TDEGenericDevice::internalSetModelID(TQString id) {
+ m_modelID = id;
+ m_modelID.replace("0x", "");
+}
+
+TQString TDEGenericDevice::vendorEncoded() {
+ return m_vendorenc;
+}
+
+void TDEGenericDevice::internalSetVendorEncoded(TQString id) {
+ m_vendorenc = id;
+}
+
+TQString TDEGenericDevice::modelEncoded() {
+ return m_modelenc;
+}
+
+void TDEGenericDevice::internalSetModelEncoded(TQString id) {
+ m_modelenc = id;
+}
+
+TQString TDEGenericDevice::subVendorID() {
+ return m_subvendorID;
+}
+
+void TDEGenericDevice::internalSetSubVendorID(TQString id) {
+ m_subvendorID = id;
+ m_subvendorID.replace("0x", "");
+}
+
+TQString TDEGenericDevice::PCIClass() {
+ return m_pciClass;
+}
+
+void TDEGenericDevice::internalSetPCIClass(TQString cl) {
+ m_pciClass = cl;
+ m_pciClass.replace("0x", "");
+}
+
+TQString TDEGenericDevice::moduleAlias() {
+ return m_modAlias;
+}
+
+void TDEGenericDevice::internalSetModuleAlias(TQString ma) {
+ m_modAlias = ma;
+}
+
+TQString TDEGenericDevice::deviceDriver() {
+ return m_deviceDriver;
+}
+
+void TDEGenericDevice::internalSetDeviceDriver(TQString dr) {
+ m_deviceDriver = dr;
+}
+
+TQString TDEGenericDevice::subsystem() {
+ return m_subsystem;
+}
+
+void TDEGenericDevice::internalSetSubsystem(TQString ss) {
+ m_subsystem = ss;
+}
+
+TQString TDEGenericDevice::subModelID() {
+ return m_submodelID;
+}
+
+void TDEGenericDevice::internalSetSubModelID(TQString id) {
+ m_submodelID = id;
+ m_submodelID.replace("0x", "");
+}
+
+void TDEGenericDevice::internalSetParentDevice(TDEGenericDevice* pd) {
+ m_parentDevice = pd;
+}
+
+TDEGenericDevice* TDEGenericDevice::parentDevice() {
+ return m_parentDevice;
+}
+
+TQPixmap TDEGenericDevice::icon(TDEIcon::StdSizes size) {
+ return TDEGlobal::hardwareDevices()->getDeviceTypeIconFromType(type(), size);
+}
+
+bool TDEGenericDevice::blacklistedForUpdate() {
+ return m_blacklistedForUpdate;
+}
+
+void TDEGenericDevice::internalSetBlacklistedForUpdate(bool bl) {
+ m_blacklistedForUpdate = bl;
+}
+
+TQString TDEGenericDevice::friendlyDeviceType() {
+ return TDEGlobal::hardwareDevices()->getFriendlyDeviceTypeStringFromType(type());
+}
+
+TQString TDEGenericDevice::busID() {
+ TQString busid = m_systemPath;
+ busid = busid.remove(0, busid.findRev("/")+1);
+ busid = busid.remove(0, busid.find(":")+1);
+ return busid;
+}
+
+TQString TDEGenericDevice::friendlyName() {
+ if (m_friendlyName.isNull()) {
+ if (type() == TDEGenericDeviceType::RootSystem) {
+ m_friendlyName = "Linux System";
+ }
+ else if (type() == TDEGenericDeviceType::Root) {
+ TQString friendlyDriverName = systemPath();
+ friendlyDriverName.truncate(friendlyDriverName.length()-1);
+ friendlyDriverName.remove(0, friendlyDriverName.findRev("/")+1);
+ m_friendlyName = friendlyDriverName;
+ }
+ else if (m_modAlias.lower().startsWith("pci")) {
+ m_friendlyName = TDEGlobal::hardwareDevices()->findPCIDeviceName(m_vendorID, m_modelID, m_subvendorID, m_submodelID);
+ }
+ else if (m_modAlias.lower().startsWith("usb")) {
+ m_friendlyName = TDEGlobal::hardwareDevices()->findUSBDeviceName(m_vendorID, m_modelID, m_subvendorID, m_submodelID);
+ }
+ else {
+ TQString acpigentype = systemPath();
+ acpigentype.truncate(acpigentype.length()-1);
+ acpigentype.remove(0, acpigentype.findRev("/")+1);
+ TQString pnpgentype = acpigentype;
+ pnpgentype.truncate(pnpgentype.find(":"));
+ if (pnpgentype.startsWith("PNP")) {
+ m_friendlyName = TDEGlobal::hardwareDevices()->findPNPDeviceName(pnpgentype);
+ }
+ else if (acpigentype.startsWith("device:")) {
+ acpigentype.remove(0, acpigentype.findRev(":")+1);
+ acpigentype.prepend("0x");
+ m_friendlyName = i18n("ACPI Node %1").arg(acpigentype.toUInt(0,0));
+ }
+ }
+ }
+
+ if (m_friendlyName.isNull()) {
+ // Could not identify based on model/vendor codes
+ // Try to construct something from the model/vendor strings if they are available
+ if (!m_vendorName.isNull() && !m_vendorModel.isNull()) {
+ m_friendlyName = m_vendorName + " " + m_vendorModel;
+ }
+ }
+
+ if (m_friendlyName.isNull()) {
+ // Could not identify based on model/vendor
+ // Guess by type
+ if (type() == TDEGenericDeviceType::CPU) {
+ m_friendlyName = name();
+ }
+ else if (type() == TDEGenericDeviceType::Event) {
+ // Use parent node name
+ if (m_parentDevice) {
+ return m_parentDevice->friendlyName();
+ }
+ else {
+ m_friendlyName = i18n("Generic Event Device");
+ }
+ }
+ else if (type() == TDEGenericDeviceType::Input) {
+ // Use parent node name
+ if (m_parentDevice) {
+ return m_parentDevice->friendlyName();
+ }
+ else {
+ m_friendlyName = i18n("Generic Input Device");
+ }
+ }
+ // Guess by driver
+ else if (!m_deviceDriver.isNull()) {
+ TQString friendlyDriverName = m_deviceDriver.lower();
+ friendlyDriverName[0] = friendlyDriverName[0].upper();
+ m_friendlyName = i18n("Generic %1 Device").arg(friendlyDriverName);
+ }
+ else if (m_systemPath.lower().startsWith("/sys/devices/virtual")) {
+ TQString friendlyDriverName = systemPath();
+ friendlyDriverName.truncate(friendlyDriverName.length()-1);
+ friendlyDriverName.remove(0, friendlyDriverName.findRev("/")+1);
+ if (!friendlyDriverName.isNull()) {
+ m_friendlyName = i18n("Virtual Device %1").arg(friendlyDriverName);
+ }
+ else {
+ m_friendlyName = i18n("Unknown Virtual Device");
+ }
+ }
+ else {
+ // I really have no idea what this peripheral is; say so!
+ m_friendlyName = i18n("Unknown Device") + " " + name();
+ }
+ }
+
+ return m_friendlyName;
+}
+
+TDEStorageDevice::TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn), m_mediaInserted(true) {
+ m_diskType = TDEDiskDeviceType::Null;
+ m_diskStatus = TDEDiskDeviceStatus::Null;
+}
+
+TDEStorageDevice::~TDEStorageDevice() {
+}
+
+TDEDiskDeviceType::TDEDiskDeviceType TDEStorageDevice::diskType() {
+ return m_diskType;
+}
+
+void TDEStorageDevice::internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType dt) {
+ m_diskType = dt;
+}
+
+bool TDEStorageDevice::isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf) {
+ return ((m_diskType&tf)!=TDEDiskDeviceType::Null);
+}
+
+TDEDiskDeviceStatus::TDEDiskDeviceStatus TDEStorageDevice::diskStatus() {
+ return m_diskStatus;
+}
+
+void TDEStorageDevice::internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st) {
+ m_diskStatus = st;
+}
+
+bool TDEStorageDevice::checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf) {
+ return ((m_diskStatus&sf)!=(TDEDiskDeviceStatus::TDEDiskDeviceStatus)0);
+}
+
+bool TDEStorageDevice::lockDriveMedia(bool lock) {
+ int fd = open(deviceNode().ascii(), O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ return false;
+ }
+ if (ioctl(fd, CDROM_LOCKDOOR, (lock)?1:0) != 0) {
+ close(fd);
+ return false;
+ }
+ else {
+ close(fd);
+ return true;
+ }
+}
+
+bool ejectDriveUDisks(TDEStorageDevice* sdevice) {
+#ifdef WITH_UDISKS
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQString blockDeviceString = sdevice->deviceNode();
+ blockDeviceString.replace("/dev/", "");
+ blockDeviceString = "/org/freedesktop/UDisks/devices/" + blockDeviceString;
+
+ // Eject the drive!
+ TQT_DBusError error;
+ TQT_DBusProxy driveControl("org.freedesktop.UDisks", blockDeviceString, "org.freedesktop.UDisks.Device", dbusConn);
+ if (driveControl.canSend()) {
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusDataList options;
+ params << TQT_DBusData::fromList(options);
+ TQT_DBusMessage reply = driveControl.sendWithReply("DriveEject", params, &error);
+ if (error.isValid()) {
+ // Error!
+ printf("[ERROR] %s\n", error.name().ascii()); fflush(stdout);
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UDISKS
+ return FALSE;
+#endif // WITH_UDISKS
+}
+
+bool ejectDriveUDisks2(TDEStorageDevice* sdevice) {
+#ifdef WITH_UDISKS2
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQString blockDeviceString = sdevice->deviceNode();
+ blockDeviceString.replace("/dev/", "");
+ blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString;
+ TQT_DBusProxy hardwareControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.DBus.Properties", dbusConn);
+ if (hardwareControl.canSend()) {
+ // get associated udisks2 drive path
+ TQT_DBusError error;
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Block") << TQT_DBusData::fromString("Drive");
+ TQT_DBusMessage reply = hardwareControl.sendWithReply("Get", params, &error);
+ if (error.isValid()) {
+ // Error!
+ printf("[ERROR] %s\n", error.name().ascii()); fflush(stdout);
+ return FALSE;
+ }
+ else {
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ TQT_DBusObjectPath driveObjectPath = reply[0].toVariant().value.toObjectPath();
+ if (!driveObjectPath.isValid()) {
+ return FALSE;
+ }
+
+ error = TQT_DBusError();
+ TQT_DBusProxy driveInformation("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.DBus.Properties", dbusConn);
+ // can eject?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("Ejectable");
+ TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error);
+ if (error.isValid()) {
+ // Error!
+ printf("[ERROR] %s\n", error.name().ascii()); fflush(stdout);
+ return FALSE;
+ }
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ bool ejectable = reply[0].toVariant().value.toBool();
+ if (!ejectable) {
+ return FALSE;
+ }
+
+ // Eject the drive!
+ TQT_DBusProxy driveControl("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.UDisks2.Drive", dbusConn);
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant);
+ params << TQT_DBusData::fromStringKeyMap(options);
+ TQT_DBusMessage reply = driveControl.sendWithReply("Eject", params, &error);
+ if (error.isValid()) {
+ // Error!
+ printf("[ERROR] %s\n", error.name().ascii()); fflush(stdout);
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UDISKS2
+ return FALSE;
+#endif // WITH_UDISKS2
+}
+
+bool TDEStorageDevice::ejectDrive() {
+ if (ejectDriveUDisks2(this)) {
+ return TRUE;
+ }
+ else {
+#ifdef WITH_UDISKS2
+ printf("[tdehwlib] Failed to eject drive '%s' via udisks2, falling back to alternate mechanism\n", deviceNode().ascii());
+#endif // WITH_UDISKS2
+ if (ejectDriveUDisks(this)) {
+ return TRUE;
+ }
+ else {
+#ifdef WITH_UDISKS
+ printf("[tdehwlib] Failed to eject drive '%s' via udisks, falling back to alternate mechanism\n", deviceNode().ascii());
+#endif // WITH_UDISKS
+ TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode());
+
+ FILE *exepipe = popen(command.ascii(), "r");
+ if (exepipe) {
+ TQString pmount_output;
+ char buffer[8092];
+ pmount_output = fgets(buffer, sizeof(buffer), exepipe);
+ int retcode = pclose(exepipe);
+ if (retcode == 0) {
+ return TRUE;
+ }
+ else {
+ printf("[tdehwlib] Failed to eject drive '%s' via 'eject' command\n", deviceNode().ascii());
+ return FALSE;
+ }
+ }
+ else {
+ printf("[tdehwlib] Failed to eject drive '%s' via 'eject' command\n", deviceNode().ascii());
+ return FALSE;
+ }
+ }
+ }
+}
+
+bool TDEStorageDevice::ejectDriveMedia() {
+ int fd = open(deviceNode().ascii(), O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ return false;
+ }
+ if (ioctl(fd, CDROMEJECT) != 0) {
+ close(fd);
+ return false;
+ }
+ else {
+ close(fd);
+ return true;
+ }
+}
+
+TQString TDEStorageDevice::diskLabel() {
+ return m_diskName;
+}
+
+void TDEStorageDevice::internalSetDiskLabel(TQString dn) {
+ m_diskName = dn;
+}
+
+bool TDEStorageDevice::mediaInserted() {
+ return m_mediaInserted;
+}
+
+void TDEStorageDevice::internalSetMediaInserted(bool inserted) {
+ m_mediaInserted = inserted;
+}
+
+TQString TDEStorageDevice::fileSystemName() {
+ return m_fileSystemName;
+}
+
+void TDEStorageDevice::internalSetFileSystemName(TQString fn) {
+ m_fileSystemName = fn;
+}
+
+TQString TDEStorageDevice::fileSystemUsage() {
+ return m_fileSystemUsage;
+}
+
+void TDEStorageDevice::internalSetFileSystemUsage(TQString fu) {
+ m_fileSystemUsage = fu;
+}
+
+TQString TDEStorageDevice::diskUUID() {
+ return m_diskUUID;
+}
+
+void TDEStorageDevice::internalSetDiskUUID(TQString id) {
+ m_diskUUID = id;
+}
+
+TQStringList TDEStorageDevice::holdingDevices() {
+ return m_holdingDevices;
+}
+
+void TDEStorageDevice::internalSetHoldingDevices(TQStringList hd) {
+ m_holdingDevices = hd;
+}
+
+TQStringList TDEStorageDevice::slaveDevices() {
+ return m_slaveDevices;
+}
+
+void TDEStorageDevice::internalSetSlaveDevices(TQStringList sd) {
+ m_slaveDevices = sd;
+}
+
+TQString TDEStorageDevice::friendlyName() {
+ // Return the actual storage device name
+ TQString devicevendorid = vendorEncoded();
+ TQString devicemodelid = modelEncoded();
+
+ devicevendorid.replace("\\x20", " ");
+ devicemodelid.replace("\\x20", " ");
+
+ devicevendorid = devicevendorid.stripWhiteSpace();
+ devicemodelid = devicemodelid.stripWhiteSpace();
+ devicevendorid = devicevendorid.simplifyWhiteSpace();
+ devicemodelid = devicemodelid.simplifyWhiteSpace();
+
+ TQString devicename = devicevendorid + " " + devicemodelid;
+
+ devicename = devicename.stripWhiteSpace();
+ devicename = devicename.simplifyWhiteSpace();
+
+ if (devicename != "") {
+ return devicename;
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::Camera)) {
+ return TDEGenericDevice::friendlyName();
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::Floppy)) {
+ return friendlyDeviceType();
+ }
+
+ TQString label = diskLabel();
+ if (label.isNull()) {
+ if (deviceSize() > 0) {
+ if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
+ label = i18n("%1 Removable Device").arg(deviceFriendlySize());
+ }
+ else {
+ label = i18n("%1 Fixed Storage Device").arg(deviceFriendlySize());
+ }
+ }
+ }
+
+ if (!label.isNull()) {
+ return label;
+ }
+
+ return friendlyDeviceType();
+}
+
+TQString TDEStorageDevice::friendlyDeviceType() {
+ TQString ret = i18n("Hard Disk Drive");
+
+ // Keep this in sync with TDEStorageDevice::icon(TDEIcon::StdSizes size) below
+ if (isDiskOfType(TDEDiskDeviceType::Floppy)) {
+ ret = i18n("Floppy Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Optical)) {
+ ret = i18n("Optical Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CDROM)) {
+ ret = i18n("CDROM Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CDRW)) {
+ ret = i18n("CDRW Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDROM)) {
+ ret = i18n("DVD Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDRW)) {
+ ret = i18n("DVDRW Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDRAM)) {
+ ret = i18n("DVDRAM Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Zip)) {
+ ret = i18n("Zip Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Tape)) {
+ ret = i18n("Tape Drive");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Camera)) {
+ ret = i18n("Digital Camera");
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::HDD)) {
+ ret = i18n("Hard Disk Drive");
+ if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
+ ret = i18n("Removable Storage");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CompactFlash)) {
+ ret = i18n("Compact Flash");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::MemoryStick)) {
+ ret = i18n("Memory Stick");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::SmartMedia)) {
+ ret = i18n("Smart Media");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::SDMMC)) {
+ ret = i18n("Secure Digital");
+ }
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::RAM)) {
+ ret = i18n("Random Access Memory");
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Loop)) {
+ ret = i18n("Loop Device");
+ }
+
+ return ret;
+}
+
+TQPixmap TDEStorageDevice::icon(TDEIcon::StdSizes size) {
+ TQPixmap ret = DesktopIcon("hdd_unmount", size);
+
+ if (isDiskOfType(TDEDiskDeviceType::Floppy)) {
+ ret = DesktopIcon("3floppy_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Optical)) {
+ ret = DesktopIcon("cdrom_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CDROM)) {
+ ret = DesktopIcon("cdrom_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CDRW)) {
+ ret = DesktopIcon("cdwriter_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDROM)) {
+ ret = DesktopIcon("dvd_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDRW)) {
+ ret = DesktopIcon("dvd_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::DVDRAM)) {
+ ret = DesktopIcon("dvd_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Zip)) {
+ ret = DesktopIcon("zip_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Tape)) {
+ ret = DesktopIcon("tape_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Camera)) {
+ ret = DesktopIcon("camera_unmount");
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::HDD)) {
+ ret = DesktopIcon("hdd_unmount", size);
+ if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
+ ret = DesktopIcon("usbpendrive_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::CompactFlash)) {
+ ret = DesktopIcon("compact_flash_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::MemoryStick)) {
+ ret = DesktopIcon("memory_stick_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::SmartMedia)) {
+ ret = DesktopIcon("smart_media_unmount", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::SDMMC)) {
+ ret = DesktopIcon("sd_mmc_unmount", size);
+ }
+ }
+
+ if (isDiskOfType(TDEDiskDeviceType::RAM)) {
+ ret = DesktopIcon("memory", size);
+ }
+ if (isDiskOfType(TDEDiskDeviceType::Loop)) {
+ ret = DesktopIcon("blockdevice", size);
+ }
+
+ return ret;
+}
+
+unsigned long long TDEStorageDevice::deviceSize() {
+ TQString bsnodename = systemPath();
+ bsnodename.append("/queue/physical_block_size");
+ TQFile bsfile( bsnodename );
+ TQString blocksize;
+ if ( bsfile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &bsfile );
+ blocksize = stream.readLine();
+ bsfile.close();
+ }
+ else {
+ // Drat, I can't get a guaranteed block size. Assume a block size of 512, as everything I have read indicates that /sys/block/<dev>/size is given in terms of a 512 byte block...
+ blocksize = "512";
+ }
+
+ TQString dsnodename = systemPath();
+ dsnodename.append("/size");
+ TQFile dsfile( dsnodename );
+ TQString devicesize;
+ if ( dsfile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &dsfile );
+ devicesize = stream.readLine();
+ dsfile.close();
+ }
+
+ return ((unsigned long long)blocksize.toULong()*(unsigned long long)devicesize.toULong());
+}
+
+TQString TDEStorageDevice::deviceFriendlySize() {
+ return TDEHardwareDevices::bytesToFriendlySizeString(deviceSize());
+}
+
+TQString TDEStorageDevice::mountPath() {
+ // See if this device node is mounted
+ // This requires parsing /proc/mounts, looking for deviceNode()
+
+ // The Device Mapper throws a monkey wrench into this
+ // It likes to advertise mounts as /dev/mapper/<something>,
+ // where <something> is listed in <system path>/dm/name
+
+ // First, ensure that all device information (mainly holders/slaves) is accurate
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+
+ TQString dmnodename = systemPath();
+ dmnodename.append("/dm/name");
+ TQFile namefile( dmnodename );
+ TQString dmaltname;
+ if ( namefile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &namefile );
+ dmaltname = stream.readLine();
+ namefile.close();
+ }
+ if (!dmaltname.isNull()) {
+ dmaltname.prepend("/dev/mapper/");
+ }
+
+ TQStringList lines;
+ TQFile file( "/proc/mounts" );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine();
+ TQStringList mountInfo = TQStringList::split(" ", line, true);
+ TQString testNode = *mountInfo.at(0);
+ // Check for match
+ if ((testNode == deviceNode()) || (testNode == dmaltname) || (testNode == ("/dev/disk/by-uuid/" + diskUUID()))) {
+ TQString ret = *mountInfo.at(1);
+ ret.replace("\\040", " ");
+ return ret;
+ }
+ lines += line;
+ }
+ file.close();
+ }
+
+ // While this device is not directly mounted, it could concievably be mounted via the Device Mapper
+ // If so, try to retrieve the mount path...
+ TQStringList slaveDeviceList = holdingDevices();
+ for ( TQStringList::Iterator slavedevit = slaveDeviceList.begin(); slavedevit != slaveDeviceList.end(); ++slavedevit ) {
+ // Try to locate this device path in the TDE device tree
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEGenericDevice *hwdevice = hwdevices->findBySystemPath(*slavedevit);
+ if ((hwdevice) && (hwdevice->type() == TDEGenericDeviceType::Disk)) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ return sdevice->mountPath();
+ }
+ }
+
+ return TQString::null;
+}
+
+TQString TDEStorageDevice::mountDevice(TQString mediaName, TQString mountOptions, TQString* errRet, int* retcode) {
+ int internal_retcode;
+ if (!retcode) {
+ retcode = &internal_retcode;
+ }
+
+ TQString ret = mountPath();
+
+ if (!ret.isNull()) {
+ return ret;
+ }
+
+ // Create dummy password file
+ KTempFile passwordFile(TQString::null, "tmp", 0600);
+ passwordFile.setAutoDelete(true);
+
+ TQString passFileName = passwordFile.name();
+ TQString devNode = deviceNode();
+ passFileName.replace("'", "'\\''");
+ devNode.replace("'", "'\\''");
+ mediaName.replace("'", "'\\''");
+ TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(mountOptions).arg(devNode).arg(mediaName);
+
+ FILE *exepipe = popen(command.ascii(), "r");
+ if (exepipe) {
+ TQString pmount_output;
+ char buffer[8092];
+ pmount_output = fgets(buffer, sizeof(buffer), exepipe);
+ *retcode = pclose(exepipe);
+ if (errRet) {
+ *errRet = pmount_output;
+ }
+ }
+
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+
+ ret = mountPath();
+
+ return ret;
+}
+
+TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TQString mountOptions, TQString* errRet, int* retcode) {
+ int internal_retcode;
+ if (!retcode) {
+ retcode = &internal_retcode;
+ }
+
+ TQString ret = mountPath();
+
+ if (!ret.isNull()) {
+ return ret;
+ }
+
+ // Create dummy password file
+ KTempFile passwordFile(TQString::null, "tmp", 0600);
+ passwordFile.setAutoDelete(true);
+ TQFile* pwFile = passwordFile.file();
+ if (!pwFile) {
+ return TQString::null;
+ }
+
+ pwFile->writeBlock(passphrase.ascii(), passphrase.length());
+ pwFile->flush();
+
+ TQString passFileName = passwordFile.name();
+ TQString devNode = deviceNode();
+ passFileName.replace("'", "'\\''");
+ devNode.replace("'", "'\\''");
+ mediaName.replace("'", "'\\''");
+ TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(mountOptions).arg(devNode).arg(mediaName);
+
+ FILE *exepipe = popen(command.ascii(), "r");
+ if (exepipe) {
+ TQString pmount_output;
+ char buffer[8092];
+ pmount_output = fgets(buffer, sizeof(buffer), exepipe);
+ *retcode = pclose(exepipe);
+ if (errRet) {
+ *errRet = pmount_output;
+ }
+ }
+
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+
+ ret = mountPath();
+
+ return ret;
+}
+
+bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) {
+ int internal_retcode;
+ if (!retcode) {
+ retcode = &internal_retcode;
+ }
+
+ TQString mountpoint = mountPath();
+
+ if (mountpoint.isNull()) {
+ return true;
+ }
+
+ mountpoint.replace("'", "'\\''");
+ TQString command = TQString("pumount '%1' 2>&1").arg(mountpoint);
+ FILE *exepipe = popen(command.ascii(), "r");
+ if (exepipe) {
+ TQString pmount_output;
+ char buffer[8092];
+ pmount_output = fgets(buffer, sizeof(buffer), exepipe);
+ *retcode = pclose(exepipe);
+ if (*retcode == 0) {
+ return true;
+ }
+ else {
+ if (errRet) {
+ *errRet = pmount_output;
+ }
+ }
+ }
+
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+
+ return false;
+}
+
+TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_frequency = -1;
+ m_minfrequency = -1;
+ m_maxfrequency = -1;
+ m_corenumber = -1;
+ m_transitionlatency = -1;
+}
+
+TDECPUDevice::~TDECPUDevice() {
+}
+
+double TDECPUDevice::frequency() {
+ return m_frequency;
+}
+
+void TDECPUDevice::internalSetFrequency(double fr) {
+ m_frequency = fr;
+}
+
+double TDECPUDevice::minFrequency() {
+ return m_minfrequency;
+}
+
+void TDECPUDevice::internalSetMinFrequency(double fr) {
+ m_minfrequency = fr;
+}
+
+double TDECPUDevice::maxFrequency() {
+ return m_maxfrequency;
+}
+
+void TDECPUDevice::internalSetMaxFrequency(double fr) {
+ m_maxfrequency = fr;
+}
+
+double TDECPUDevice::transitionLatency() {
+ return m_transitionlatency;
+}
+
+void TDECPUDevice::internalSetTransitionLatency(double tl) {
+ m_transitionlatency = tl;
+}
+
+TQString TDECPUDevice::governor() {
+ return m_governor;
+}
+
+void TDECPUDevice::internalSetGovernor(TQString gr) {
+ m_governor = gr;
+}
+
+TQString TDECPUDevice::scalingDriver() {
+ return m_scalingdriver;
+}
+
+void TDECPUDevice::internalSetScalingDriver(TQString dr) {
+ m_scalingdriver = dr;
+}
+
+TQStringList TDECPUDevice::dependentProcessors() {
+ return m_tiedprocs;
+}
+
+void TDECPUDevice::internalSetDependentProcessors(TQStringList dp) {
+ m_tiedprocs = dp;
+}
+
+TQStringList TDECPUDevice::availableFrequencies() {
+ return m_frequencies;
+}
+
+void TDECPUDevice::internalSetAvailableFrequencies(TQStringList af) {
+ m_frequencies = af;
+}
+
+TQStringList TDECPUDevice::availableGovernors() {
+ return m_governers;
+}
+
+void TDECPUDevice::internalSetAvailableGovernors(TQStringList gp) {
+ m_governers = gp;
+}
+
+void TDECPUDevice::internalSetCoreNumber(int cn) {
+ m_corenumber = cn;
+}
+
+bool TDECPUDevice::canSetGovernor() {
+ TQString governornode = systemPath() + "/cpufreq/scaling_governor";
+ int rval = access (governornode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn);
+ if (hardwareControl.canSend()) {
+ // can set CPU governor?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromInt32(coreNumber());
+ TQT_DBusMessage reply = hardwareControl.sendWithReply("CanSetCPUGovernor", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+void TDECPUDevice::setGovernor(TQString gv) {
+ TQString governornode = systemPath() + "/cpufreq/scaling_governor";
+ TQFile file( governornode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQTextStream stream( &file );
+ stream << gv.lower();
+ file.close();
+ }
+#ifdef WITH_UPOWER
+ else {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn);
+ if (hardwareControl.canSend()) {
+ // set CPU governor
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromInt32(coreNumber()) << TQT_DBusData::fromString(gv.lower());
+ hardwareControl.sendWithReply("SetCPUGovernor", params);
+ }
+ else {
+ return;
+ }
+ }
+ else {
+ return;
+ }
+ }
+#endif // WITH_UPOWER
+
+ // Force update of the device information object
+ TDEGlobal::hardwareDevices()->processModifiedCPUs();
+}
+
+bool TDECPUDevice::canSetMaximumScalingFrequency() {
+ TQString freqnode = systemPath() + "/cpufreq/scaling_max_freq";
+ int rval = access (freqnode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+void TDECPUDevice::setMaximumScalingFrequency(double fr) {
+ TQString freqnode = systemPath() + "/cpufreq/scaling_max_freq";
+ TQFile file( freqnode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQTextStream stream( &file );
+ stream << TQString("%1").arg(fr*1000000.0, 0, 'f', 0);
+ file.close();
+ }
+
+ // Force update of the device information object
+ TDEGlobal::hardwareDevices()->processModifiedCPUs();
+}
+
+int TDECPUDevice::coreNumber() {
+ return m_corenumber;
+}
+
+TDESensorDevice::TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDESensorDevice::~TDESensorDevice() {
+}
+
+TDESensorClusterMap TDESensorDevice::values() {
+ return m_sensorValues;
+}
+
+void TDESensorDevice::internalSetValues(TDESensorClusterMap cl) {
+ m_sensorValues = cl;
+}
+
+TDERootSystemDevice::TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_hibernationSpace = -1;
+}
+
+TDERootSystemDevice::~TDERootSystemDevice() {
+}
+
+TDESystemFormFactor::TDESystemFormFactor TDERootSystemDevice::formFactor() {
+ return m_formFactor;
+}
+
+void TDERootSystemDevice::internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff) {
+ m_formFactor = ff;
+}
+
+TDESystemPowerStateList TDERootSystemDevice::powerStates() {
+ return m_powerStates;
+}
+
+void TDERootSystemDevice::internalSetPowerStates(TDESystemPowerStateList ps) {
+ m_powerStates = ps;
+}
+
+TDESystemHibernationMethodList TDERootSystemDevice::hibernationMethods() {
+ return m_hibernationMethods;
+}
+
+void TDERootSystemDevice::internalSetHibernationMethods(TDESystemHibernationMethodList hm) {
+ m_hibernationMethods = hm;
+}
+
+TDESystemHibernationMethod::TDESystemHibernationMethod TDERootSystemDevice::hibernationMethod() {
+ return m_hibernationMethod;
+}
+
+void TDERootSystemDevice::internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
+ m_hibernationMethod = hm;
+}
+
+unsigned long TDERootSystemDevice::diskSpaceNeededForHibernation() {
+ return m_hibernationSpace;
+}
+
+void TDERootSystemDevice::internalSetDiskSpaceNeededForHibernation(unsigned long sz) {
+ m_hibernationSpace = sz;
+}
+
+bool TDERootSystemDevice::canSetHibernationMethod() {
+ TQString hibernationnode = "/sys/power/disk";
+ int rval = access (hibernationnode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDERootSystemDevice::canStandby() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Standby)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDERootSystemDevice::canSuspend() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Suspend)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
+ if (upowerProperties.canSend()) {
+ // can suspend?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
+ TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+bool TDERootSystemDevice::canHibernate() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Hibernate)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
+ if (upowerProperties.canSend()) {
+ // can hibernate?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
+ TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+bool TDERootSystemDevice::canPowerOff() {
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+
+ config->setGroup("General" );
+ bool maysd = false;
+#ifdef WITH_CONSOLEKIT
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
+ if (consoleKitManager.canSend()) {
+ // can power off?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanStop", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ maysd = reply[0].toBool();
+ }
+ else {
+ maysd = false;
+ }
+ }
+ else {
+ maysd = false;
+ }
+ }
+ else {
+ maysd = false;
+ }
+ }
+#else // WITH_CONSOLEKIT
+ // FIXME
+ // Can we power down this system?
+ // This should probably be checked via DCOP and therefore interface with KDM
+ if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
+ maysd = true;
+ }
+#endif // WITH_CONSOLEKIT
+
+ return maysd;
+}
+
+bool TDERootSystemDevice::canReboot() {
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+
+ config->setGroup("General" );
+ bool mayrb = false;
+#ifdef WITH_CONSOLEKIT
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
+ if (consoleKitManager.canSend()) {
+ // can reboot?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanRestart", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ mayrb = reply[0].toBool();
+ }
+ else {
+ mayrb = false;
+ }
+ }
+ else {
+ mayrb = false;
+ }
+ }
+ else {
+ mayrb = false;
+ }
+ }
+#else // WITH_CONSOLEKIT
+ // FIXME
+ // Can we power down this system?
+ // This should probably be checked via DCOP and therefore interface with KDM
+ if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
+ mayrb = true;
+ }
+#endif // WITH_CONSOLEKIT
+
+ return mayrb;
+}
+
+void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
+ TQString hibernationnode = "/sys/power/disk";
+ TQFile file( hibernationnode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQString hibernationCommand;
+ if (hm == TDESystemHibernationMethod::Platform) {
+ hibernationCommand = "platform";
+ }
+ if (hm == TDESystemHibernationMethod::Shutdown) {
+ hibernationCommand = "shutdown";
+ }
+ if (hm == TDESystemHibernationMethod::Reboot) {
+ hibernationCommand = "reboot";
+ }
+ if (hm == TDESystemHibernationMethod::TestProc) {
+ hibernationCommand = "testproc";
+ }
+ if (hm == TDESystemHibernationMethod::Test) {
+ hibernationCommand = "test";
+ }
+ TQTextStream stream( &file );
+ stream << hibernationCommand;
+ file.close();
+ }
+}
+
+bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState ps) {
+ if ((ps == TDESystemPowerState::Standby) || (ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate)) {
+ TQString statenode = "/sys/power/state";
+ TQFile file( statenode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQString powerCommand;
+ if (ps == TDESystemPowerState::Standby) {
+ powerCommand = "standby";
+ }
+ if (ps == TDESystemPowerState::Suspend) {
+ powerCommand = "mem";
+ }
+ if (ps == TDESystemPowerState::Hibernate) {
+ powerCommand = "disk";
+ }
+ TQTextStream stream( &file );
+ stream << powerCommand;
+ file.close();
+ return true;
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ if (ps == TDESystemPowerState::Suspend) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Suspend");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else if (ps == TDESystemPowerState::Hibernate) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Hibernate");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_UPOWER
+ return false;
+#endif // WITH_UPOWER
+ }
+ }
+ else if (ps == TDESystemPowerState::PowerOff) {
+#ifdef WITH_CONSOLEKIT
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+ config->setGroup("General" );
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "Stop");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_CONSOLEKIT
+ // Power down the system using a DCOP command
+ // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
+ TQByteArray data;
+ TQDataStream arg(data, IO_WriteOnly);
+ arg << (int)0 << (int)2 << (int)2;
+ if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
+ return true;
+ }
+ return false;
+#endif // WITH_CONSOLEKIT
+ }
+ else if (ps == TDESystemPowerState::Reboot) {
+#ifdef WITH_CONSOLEKIT
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+ config->setGroup("General" );
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "Restart");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_CONSOLEKIT
+ // Power down the system using a DCOP command
+ // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
+ TQByteArray data;
+ TQDataStream arg(data, IO_WriteOnly);
+ arg << (int)0 << (int)1 << (int)2;
+ if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
+ return true;
+ }
+ return false;
+#endif // WITH_CONSOLEKIT
+ }
+ else if (ps == TDESystemPowerState::Active) {
+ // Ummm...we're already active...
+ return true;
+ }
+
+ return false;
+}
+
+TDEBatteryDevice::TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEBatteryDevice::~TDEBatteryDevice() {
+}
+
+double TDEBatteryDevice::voltage() {
+ return m_currentVoltage;
+}
+
+void TDEBatteryDevice::internalSetVoltage(double vt) {
+ m_currentVoltage = vt;
+}
+
+double TDEBatteryDevice::maximumVoltage() {
+ return m_maximumVoltage;
+}
+
+void TDEBatteryDevice::internalSetMaximumVoltage(double vt) {
+ m_maximumVoltage = vt;
+}
+
+double TDEBatteryDevice::minimumVoltage() {
+ return m_minimumVoltage;
+}
+
+void TDEBatteryDevice::internalSetMinimumVoltage(double vt) {
+ m_minimumVoltage = vt;
+}
+
+double TDEBatteryDevice::maximumDesignVoltage() {
+ return m_maximumDesignVoltage;
+}
+
+void TDEBatteryDevice::internalSetMaximumDesignVoltage(double vt) {
+ m_maximumDesignVoltage = vt;
+}
+
+double TDEBatteryDevice::energy() {
+ return m_currentEnergy;
+}
+
+void TDEBatteryDevice::internalSetEnergy(double vt) {
+ m_currentEnergy = vt;
+}
+
+double TDEBatteryDevice::alarmEnergy() {
+ return m_alarmEnergy;
+}
+
+void TDEBatteryDevice::internalSetAlarmEnergy(double vt) {
+ m_alarmEnergy = vt;
+}
+
+double TDEBatteryDevice::maximumEnergy() {
+ return m_maximumEnergy;
+}
+
+void TDEBatteryDevice::internalSetMaximumEnergy(double vt) {
+ m_maximumEnergy = vt;
+}
+
+double TDEBatteryDevice::maximumDesignEnergy() {
+ return m_maximumDesignEnergy;
+}
+
+void TDEBatteryDevice::internalSetMaximumDesignEnergy(double vt) {
+ m_maximumDesignEnergy = vt;
+}
+
+double TDEBatteryDevice::dischargeRate() {
+ return m_dischargeRate;
+}
+
+void TDEBatteryDevice::internalSetDischargeRate(double vt) {
+ m_dischargeRate = vt;
+}
+
+double TDEBatteryDevice::timeRemaining() {
+ return m_timeRemaining;
+}
+
+void TDEBatteryDevice::internalSetTimeRemaining(double tr) {
+ m_timeRemaining = tr;
+}
+
+TQString TDEBatteryDevice::technology() {
+ return m_technology;
+}
+
+void TDEBatteryDevice::internalSetTechnology(TQString tc) {
+ m_technology = tc;
+}
+
+TDEBatteryStatus::TDEBatteryStatus TDEBatteryDevice::status() {
+ return m_status;
+}
+
+void TDEBatteryDevice::internalSetStatus(TQString tc) {
+ tc = tc.lower();
+
+ if (tc == "charging") {
+ m_status = TDEBatteryStatus::Charging;
+ }
+ else if (tc == "discharging") {
+ m_status = TDEBatteryStatus::Discharging;
+ }
+ else if (tc == "full") {
+ m_status = TDEBatteryStatus::Full;
+ }
+ else {
+ m_status = TDEBatteryStatus::Unknown;
+ }
+}
+
+bool TDEBatteryDevice::installed() {
+ return m_installed;
+}
+
+void TDEBatteryDevice::internalSetInstalled(bool tc) {
+ m_installed = tc;
+}
+
+double TDEBatteryDevice::chargePercent() {
+ return (m_currentEnergy/m_maximumEnergy)*100.0;
+}
+
+TDEMainsPowerDevice::TDEMainsPowerDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEMainsPowerDevice::~TDEMainsPowerDevice() {
+}
+
+bool TDEMainsPowerDevice::online() {
+ return m_online;
+}
+
+void TDEMainsPowerDevice::internalSetOnline(bool tc) {
+ m_online = tc;
+}
+
+TDENetworkDevice::TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_rxbytes = -1;
+ m_txbytes = -1;
+ m_rxpackets = -1;
+ m_txpackets = -1;
+ m_connectionManager = NULL;
+}
+
+TDENetworkDevice::~TDENetworkDevice() {
+ if (m_connectionManager) {
+ delete m_connectionManager;
+ }
+}
+
+TQString TDENetworkDevice::macAddress() {
+ return m_macAddress;
+}
+
+void TDENetworkDevice::internalSetMacAddress(TQString ma) {
+ m_macAddress = ma;
+}
+
+TQString TDENetworkDevice::state() {
+ return m_state;
+}
+
+void TDENetworkDevice::internalSetState(TQString st) {
+ m_state = st;
+}
+
+bool TDENetworkDevice::carrierPresent() {
+ return m_carrier;
+}
+
+void TDENetworkDevice::internalSetCarrierPresent(bool cp) {
+ m_carrier = cp;
+}
+
+bool TDENetworkDevice::dormant() {
+ return m_dormant;
+}
+
+void TDENetworkDevice::internalSetDormant(bool dm) {
+ m_dormant = dm;
+}
+
+TQString TDENetworkDevice::ipV4Address() {
+ return m_ipV4Address;
+}
+
+void TDENetworkDevice::internalSetIpV4Address(TQString ad) {
+ m_ipV4Address = ad;
+}
+
+TQString TDENetworkDevice::ipV6Address() {
+ return m_ipV6Address;
+}
+
+void TDENetworkDevice::internalSetIpV6Address(TQString ad) {
+ m_ipV6Address = ad;
+}
+
+TQString TDENetworkDevice::ipV4Netmask() {
+ return m_ipV4Netmask;
+}
+
+void TDENetworkDevice::internalSetIpV4Netmask(TQString nm) {
+ m_ipV4Netmask = nm;
+}
+
+TQString TDENetworkDevice::ipV6Netmask() {
+ return m_ipV6Netmask;
+}
+
+void TDENetworkDevice::internalSetIpV6Netmask(TQString nm) {
+ m_ipV6Netmask = nm;
+}
+
+TQString TDENetworkDevice::ipV4Broadcast() {
+ return m_ipV4Broadcast;
+}
+
+void TDENetworkDevice::internalSetIpV4Broadcast(TQString br) {
+ m_ipV4Broadcast = br;
+}
+
+TQString TDENetworkDevice::ipV6Broadcast() {
+ return m_ipV6Broadcast;
+}
+
+void TDENetworkDevice::internalSetIpV6Broadcast(TQString br) {
+ m_ipV6Broadcast = br;
+}
+
+TQString TDENetworkDevice::ipV4Destination() {
+ return m_ipV4Destination;
+}
+
+void TDENetworkDevice::internalSetIpV4Destination(TQString ds) {
+ m_ipV4Destination = ds;
+}
+
+TQString TDENetworkDevice::ipV6Destination() {
+ return m_ipV6Destination;
+}
+
+void TDENetworkDevice::internalSetIpV6Destination(TQString ds) {
+ m_ipV6Destination = ds;
+}
+
+double TDENetworkDevice::rxBytes() {
+ return m_rxbytes;
+}
+
+void TDENetworkDevice::internalSetRxBytes(double rx) {
+ m_rxbytes = rx;
+}
+
+double TDENetworkDevice::txBytes() {
+ return m_txbytes;
+}
+
+void TDENetworkDevice::internalSetTxBytes(double tx) {
+ m_txbytes = tx;
+}
+
+double TDENetworkDevice::rxPackets() {
+ return m_rxpackets;
+}
+
+void TDENetworkDevice::internalSetRxPackets(double rx) {
+ m_rxpackets = rx;
+}
+
+double TDENetworkDevice::txPackets() {
+ return m_txpackets;
+}
+
+void TDENetworkDevice::internalSetTxPackets(double tx) {
+ m_txpackets = tx;
+}
+
+TDENetworkConnectionManager* TDENetworkDevice::connectionManager() {
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+ if (!m_connectionManager) {
+ m_connectionManager = new TDENetworkConnectionManager_BackendNM(m_macAddress);
+ }
+#endif // WITH_NETWORK_MANAGER_BACKEND
+
+ return m_connectionManager;
+}
+
+void TDENetworkDevice::internalSetConnectionManager(TDENetworkConnectionManager* mgr) {
+ m_connectionManager = mgr;
+}
+
+TDEBacklightDevice::TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEBacklightDevice::~TDEBacklightDevice() {
+}
+
+TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEBacklightDevice::powerLevel() {
+ return m_powerLevel;
+}
+
+void TDEBacklightDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
+ m_powerLevel = pl;
+}
+
+void TDEBacklightDevice::internalSetMaximumRawBrightness(int br) {
+ m_maximumBrightness = br;
+}
+
+void TDEBacklightDevice::internalSetCurrentRawBrightness(int br) {
+ m_currentBrightness = br;
+}
+
+int TDEBacklightDevice::brightnessSteps() {
+ return m_maximumBrightness + 1;
+}
+
+double TDEBacklightDevice::brightnessPercent() {
+ return (((m_currentBrightness*1.0)/m_maximumBrightness)*100.0);
+}
+
+bool TDEBacklightDevice::canSetBrightness() {
+ TQString brightnessnode = systemPath() + "/brightness";
+ int rval = access (brightnessnode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
+ if (hardwareControl.canSend()) {
+ // can set brightness?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(brightnessnode);
+ TQT_DBusMessage reply = hardwareControl.sendWithReply("CanSetBrightness", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+int TDEBacklightDevice::rawBrightness() {
+ return m_currentBrightness;
+}
+
+void TDEBacklightDevice::setRawBrightness(int br) {
+ TQString brightnessnode = systemPath() + "/brightness";
+ TQString brightnessCommand = TQString("%1").arg(br);
+ TQFile file( brightnessnode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQTextStream stream( &file );
+ stream << brightnessCommand;
+ file.close();
+ }
+#ifdef WITH_UPOWER
+ else {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
+ if (hardwareControl.canSend()) {
+ // set brightness
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(brightnessnode) << TQT_DBusData::fromString(brightnessCommand);
+ hardwareControl.sendWithReply("SetBrightness", params);
+ }
+ else {
+ return;
+ }
+ }
+ else {
+ return;
+ }
+ }
+#endif // WITH_UPOWER
+}
+
+TDEMonitorDevice::TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEMonitorDevice::~TDEMonitorDevice() {
+}
+
+bool TDEMonitorDevice::connected() {
+ return m_connected;
+}
+
+void TDEMonitorDevice::internalSetConnected(bool cn) {
+ m_connected = cn;
+}
+
+bool TDEMonitorDevice::enabled() {
+ return m_enabled;
+}
+
+void TDEMonitorDevice::internalSetEnabled(bool en) {
+ m_enabled = en;
+}
+
+TQByteArray TDEMonitorDevice::edid() {
+ return m_edid;
+}
+
+void TDEMonitorDevice::internalSetEdid(TQByteArray ed) {
+ m_edid = ed;
+}
+
+TDEResolutionList TDEMonitorDevice::resolutions() {
+ return m_resolutions;
+}
+
+void TDEMonitorDevice::internalSetResolutions(TDEResolutionList rs) {
+ m_resolutions = rs;
+}
+
+TQString TDEMonitorDevice::portType() {
+ return m_portType;
+}
+
+void TDEMonitorDevice::internalSetPortType(TQString pt) {
+ m_portType = pt;
+}
+
+TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEMonitorDevice::powerLevel() {
+ return m_powerLevel;
+}
+
+void TDEMonitorDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
+ m_powerLevel = pl;
+}
+
+TDEEventDevice::TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_fd = -1;
+ m_fdMonitorActive = false;
+}
+
+TDEEventDevice::~TDEEventDevice() {
+ if (m_fd >= 0) {
+ close(m_fd);
+ }
+}
+
+TDEEventDeviceType::TDEEventDeviceType TDEEventDevice::eventType() {
+ return m_eventType;
+}
+
+void TDEEventDevice::internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et) {
+ m_eventType = et;
+}
+
+TDESwitchType::TDESwitchType TDEEventDevice::providedSwitches() {
+ return m_providedSwitches;
+}
+
+void TDEEventDevice::internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl) {
+ m_providedSwitches = sl;
+}
+
+TDESwitchType::TDESwitchType TDEEventDevice::activeSwitches() {
+ return m_switchActive;
+}
+
+void TDEEventDevice::internalSetActiveSwitches(TDESwitchType::TDESwitchType sl) {
+ m_switchActive = sl;
+}
+
+// Keep this in sync with the TDESwitchType definition in the header
+TQStringList TDEEventDevice::friendlySwitchList(TDESwitchType::TDESwitchType switches) {
+ TQStringList ret;
+
+ if (switches & TDESwitchType::Lid) {
+ ret.append(i18n("Lid Switch"));
+ }
+ if (switches & TDESwitchType::TabletMode) {
+ ret.append(i18n("Tablet Mode"));
+ }
+ if (switches & TDESwitchType::HeadphoneInsert) {
+ ret.append(i18n("Headphone Inserted"));
+ }
+ if (switches & TDESwitchType::RFKill) {
+ ret.append(i18n("Radio Frequency Device Kill Switch"));
+ }
+ if (switches & TDESwitchType::Radio) {
+ ret.append(i18n("Enable Radio"));
+ }
+ if (switches & TDESwitchType::MicrophoneInsert) {
+ ret.append(i18n("Microphone Inserted"));
+ }
+ if (switches & TDESwitchType::Dock) {
+ ret.append(i18n("Docked"));
+ }
+ if (switches & TDESwitchType::LineOutInsert) {
+ ret.append(i18n("Line Out Inserted"));
+ }
+ if (switches & TDESwitchType::JackPhysicalInsert) {
+ ret.append(i18n("Physical Jack Inserted"));
+ }
+ if (switches & TDESwitchType::VideoOutInsert) {
+ ret.append(i18n("Video Out Inserted"));
+ }
+ if (switches & TDESwitchType::CameraLensCover) {
+ ret.append(i18n("Camera Lens Cover"));
+ }
+ if (switches & TDESwitchType::KeypadSlide) {
+ ret.append(i18n("Keypad Slide"));
+ }
+ if (switches & TDESwitchType::FrontProximity) {
+ ret.append(i18n("Front Proximity"));
+ }
+ if (switches & TDESwitchType::RotateLock) {
+ ret.append(i18n("Rotate Lock"));
+ }
+ if (switches & TDESwitchType::LineInInsert) {
+ ret.append(i18n("Line In Inserted"));
+ }
+
+ return ret;
+}
+
+void TDEEventDevice::internalStartFdMonitoring(TDEHardwareDevices* hwmanager) {
+ if (!m_fdMonitorActive) {
+ // For security and performance reasons, only monitor known ACPI buttons
+ if (eventType() != TDEEventDeviceType::Unknown) {
+ if (m_fd >= 0) {
+ m_eventNotifier = new TQSocketNotifier(m_fd, TQSocketNotifier::Read, this);
+ connect( m_eventNotifier, TQT_SIGNAL(activated(int)), this, TQT_SLOT(eventReceived()) );
+ }
+ connect( this, TQT_SIGNAL(keyPressed(unsigned int, TDEEventDevice*)), hwmanager, TQT_SLOT(processEventDeviceKeyPressed(unsigned int, TDEEventDevice*)) );
+ }
+ m_fdMonitorActive = true;
+ }
+}
+
+void TDEEventDevice::eventReceived() {
+ struct input_event ev;
+ int r;
+ r = read(m_fd, &ev, sizeof(struct input_event));
+ if (r > 0) {
+ if (ev.type == EV_KEY) {
+ emit keyPressed(ev.code, this);
+ }
+ }
+}
+
+TDEInputDevice::TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEInputDevice::~TDEInputDevice() {
+}
+
+TDEInputDeviceType::TDEInputDeviceType TDEInputDevice::inputType() {
+ return m_inputType;
+}
+
+void TDEInputDevice::internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it) {
+ m_inputType = it;
+}
+
+TDEHardwareDevices::TDEHardwareDevices() {
+ // Initialize members
+ pci_id_map = 0;
+ usb_id_map = 0;
+ pnp_id_map = 0;
+ dpy_id_map = 0;
+
+ // Set up device list
+ m_deviceList.setAutoDelete( TRUE ); // the list owns the objects
+
+ // Initialize udev interface
+ m_udevStruct = udev_new();
+ if (!m_udevStruct) {
+ printf("Unable to create udev interface\n");
+ }
+
+ if (m_udevStruct) {
+ // Set up device add/remove monitoring
+ m_udevMonitorStruct = udev_monitor_new_from_netlink(m_udevStruct, "udev");
+ udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitorStruct, NULL, NULL);
+ udev_monitor_enable_receiving(m_udevMonitorStruct);
+
+ int udevmonitorfd = udev_monitor_get_fd(m_udevMonitorStruct);
+ if (udevmonitorfd >= 0) {
+ m_devScanNotifier = new TQSocketNotifier(udevmonitorfd, TQSocketNotifier::Read, this);
+ connect( m_devScanNotifier, TQT_SIGNAL(activated(int)), this, TQT_SLOT(processHotPluggedHardware()) );
+ }
+
+ // Read in the current mount table
+ // Yes, a race condition exists between this and the mount monitor start below, but it shouldn't be a problem 99.99% of the time
+ m_mountTable.clear();
+ TQFile file( "/proc/mounts" );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ m_mountTable.append(stream.readLine());
+ }
+ file.close();
+ }
+
+ // Monitor for changed mounts
+ m_procMountsFd = open("/proc/mounts", O_RDONLY, 0);
+ if (m_procMountsFd >= 0) {
+ m_mountScanNotifier = new TQSocketNotifier(m_procMountsFd, TQSocketNotifier::Exception, this);
+ connect( m_mountScanNotifier, TQT_SIGNAL(activated(int)), this, TQT_SLOT(processModifiedMounts()) );
+ }
+
+ // Read in the current cpu information
+ // Yes, a race condition exists between this and the cpu monitor start below, but it shouldn't be a problem 99.99% of the time
+ m_cpuInfo.clear();
+ TQFile cpufile( "/proc/cpuinfo" );
+ if ( cpufile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &cpufile );
+ while ( !stream.atEnd() ) {
+ m_cpuInfo.append(stream.readLine());
+ }
+ cpufile.close();
+ }
+
+// [FIXME 0.01]
+// Apparently the Linux kernel just does not notify userspace applications of CPU frequency changes
+// This is STUPID, as it means I have to poll the CPU information structures with a 0.5 second or so timer just to keep the information up to date
+#if 0
+ // Monitor for changed cpu information
+ // Watched directories are set up during the initial CPU scan
+ m_cpuWatch = new KSimpleDirWatch(this);
+ connect( m_cpuWatch, TQT_SIGNAL(dirty(const TQString &)), this, TQT_SLOT(processModifiedCPUs()) );
+#else
+ m_cpuWatchTimer = new TQTimer(this);
+ connect( m_cpuWatchTimer, SIGNAL(timeout()), this, SLOT(processModifiedCPUs()) );
+#endif
+
+ // Some devices do not receive update signals from udev
+ // These devices must be polled, and a good polling interval is 1 second
+ m_deviceWatchTimer = new TQTimer(this);
+ connect( m_deviceWatchTimer, SIGNAL(timeout()), this, SLOT(processStatelessDevices()) );
+
+ // Update internal device information
+ queryHardwareInformation();
+ }
+}
+
+TDEHardwareDevices::~TDEHardwareDevices() {
+ // Stop device scanning
+ m_deviceWatchTimer->stop();
+
+// [FIXME 0.01]
+#if 0
+ // Stop CPU scanning
+ m_cpuWatch->stopScan();
+#else
+ m_cpuWatchTimer->stop();
+#endif
+
+ // Stop mount scanning
+ close(m_procMountsFd);
+
+ // Tear down udev interface
+ udev_unref(m_udevStruct);
+
+ // Delete members
+ if (pci_id_map) {
+ delete pci_id_map;
+ }
+ if (usb_id_map) {
+ delete usb_id_map;
+ }
+ if (pnp_id_map) {
+ delete pnp_id_map;
+ }
+ if (dpy_id_map) {
+ delete dpy_id_map;
+ }
+}
+
+void TDEHardwareDevices::setTriggerlessHardwareUpdatesEnabled(bool enable) {
+ if (enable) {
+ TQDir nodezerocpufreq("/sys/devices/system/cpu/cpu0/cpufreq");
+ if (nodezerocpufreq.exists()) {
+ m_cpuWatchTimer->start( 500, FALSE ); // 0.5 second repeating timer
+ }
+ m_deviceWatchTimer->start( 1000, FALSE ); // 1 second repeating timer
+ }
+ else {
+ m_cpuWatchTimer->stop();
+ m_deviceWatchTimer->stop();
+ }
+}
+
+void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice) {
+ rescanDeviceInformation(hwdevice, true);
+}
+
+void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree) {
+ struct udev_device *dev;
+ dev = udev_device_new_from_syspath(m_udevStruct, hwdevice->systemPath().ascii());
+ updateExistingDeviceInformation(hwdevice);
+ if (regenerateDeviceTree) {
+ updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ }
+ udev_device_unref(dev);
+}
+
+TDEGenericDevice* TDEHardwareDevices::findBySystemPath(TQString syspath) {
+ if (!syspath.endsWith("/")) {
+ syspath += "/";
+ }
+ TDEGenericDevice *hwdevice;
+ // We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time
+ TDEGenericHardwareList devList = listAllPhysicalDevices();
+ for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
+ if (hwdevice->systemPath() == syspath) {
+ return hwdevice;
+ }
+ }
+
+ return 0;
+}
+
+TDEGenericDevice* TDEHardwareDevices::findByUniqueID(TQString uid) {
+ TDEGenericDevice *hwdevice;
+ // We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time
+ TDEGenericHardwareList devList = listAllPhysicalDevices();
+ for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
+ if (hwdevice->uniqueID() == uid) {
+ return hwdevice;
+ }
+ }
+
+ return 0;
+}
+
+TDEGenericDevice* TDEHardwareDevices::findByDeviceNode(TQString devnode) {
+ TDEGenericDevice *hwdevice;
+ for ( hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next() ) {
+ if (hwdevice->deviceNode() == devnode) {
+ return hwdevice;
+ }
+ }
+
+ return 0;
+}
+
+TDEStorageDevice* TDEHardwareDevices::findDiskByUID(TQString uid) {
+ TDEGenericDevice *hwdevice;
+ for ( hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next() ) {
+ if (hwdevice->type() == TDEGenericDeviceType::Disk) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ if (sdevice->uniqueID() == uid) {
+ return sdevice;
+ }
+ }
+ }
+
+ return 0;
+}
+
+void TDEHardwareDevices::processHotPluggedHardware() {
+ udev_device* dev = udev_monitor_receive_device(m_udevMonitorStruct);
+ if (dev) {
+ TQString actionevent(udev_device_get_action(dev));
+ if (actionevent == "add") {
+ TDEGenericDevice* device = classifyUnknownDevice(dev);
+
+ // Make sure this device is not a duplicate
+ TDEGenericDevice *hwdevice;
+ for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
+ if (hwdevice->systemPath() == device->systemPath()) {
+ delete device;
+ device = 0;
+ break;
+ }
+ }
+
+ if (device) {
+ m_deviceList.append(device);
+ updateParentDeviceInformation(device); // Update parent/child tables for this device
+ emit hardwareAdded(device);
+ emit hardwareEvent(TDEHardwareEvent::HardwareAdded, device->uniqueID());
+ }
+ }
+ else if (actionevent == "remove") {
+ // Delete device from hardware listing
+ TQString systempath(udev_device_get_syspath(dev));
+ systempath += "/";
+ TDEGenericDevice *hwdevice;
+ for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
+ if (hwdevice->systemPath() == systempath) {
+ emit hardwareRemoved(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareRemoved, hwdevice->uniqueID());
+
+ // If the device is a storage device and has a slave, update it as well
+ if (hwdevice->type() == TDEGenericDeviceType::Disk) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ TQStringList slavedevices = sdevice->slaveDevices();
+ m_deviceList.remove(hwdevice);
+ for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
+ TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
+ if (slavedevice) {
+ rescanDeviceInformation(slavedevice);
+ emit hardwareUpdated(slavedevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, slavedevice->uniqueID());
+ }
+ }
+ }
+ else {
+ m_deviceList.remove(hwdevice);
+ }
+
+ break;
+ }
+ }
+ }
+ else if (actionevent == "change") {
+ // Update device and emit change event
+ TQString systempath(udev_device_get_syspath(dev));
+ systempath += "/";
+ TDEGenericDevice *hwdevice;
+ for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
+ if (hwdevice->systemPath() == systempath) {
+ if (!hwdevice->blacklistedForUpdate()) {
+ classifyUnknownDevice(dev, hwdevice, false);
+ updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ }
+ }
+ else if ((hwdevice->type() == TDEGenericDeviceType::Monitor)
+ && (hwdevice->systemPath().contains(systempath))) {
+ if (!hwdevice->blacklistedForUpdate()) {
+ struct udev_device *slavedev;
+ slavedev = udev_device_new_from_syspath(m_udevStruct, hwdevice->systemPath().ascii());
+ classifyUnknownDevice(slavedev, hwdevice, false);
+ udev_device_unref(slavedev);
+ updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ }
+ }
+ }
+ }
+ }
+}
+
+void TDEHardwareDevices::processModifiedCPUs() {
+ // Detect what changed between the old cpu information and the new information,
+ // and emit appropriate events
+
+ // Read new CPU information table
+ m_cpuInfo.clear();
+ TQFile cpufile( "/proc/cpuinfo" );
+ if ( cpufile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &cpufile );
+ while ( !stream.atEnd() ) {
+ m_cpuInfo.append(stream.readLine());
+ }
+ cpufile.close();
+ }
+
+ // Ensure "processor" is the first entry in each block and determine which cpuinfo type is in use
+ bool cpuinfo_format_x86 = true;
+ bool cpuinfo_format_arm = false;
+
+ TQString curline1;
+ TQString curline2;
+ int blockNumber = 0;
+ TQStringList::Iterator blockBegin = m_cpuInfo.begin();
+ for (TQStringList::Iterator cpuit1 = m_cpuInfo.begin(); cpuit1 != m_cpuInfo.end(); ++cpuit1) {
+ curline1 = *cpuit1;
+ curline1 = curline1.stripWhiteSpace();
+ if (!(*blockBegin).startsWith("processor")) {
+ bool found = false;
+ TQStringList::Iterator cpuit2;
+ for (cpuit2 = blockBegin; cpuit2 != m_cpuInfo.end(); ++cpuit2) {
+ curline2 = *cpuit2;
+ curline2 = curline2.stripWhiteSpace();
+ if (curline2.startsWith("processor")) {
+ found = true;
+ break;
+ }
+ else if (curline2 == "") {
+ break;
+ }
+ }
+ if (found) {
+ m_cpuInfo.insert(blockBegin, (*cpuit2));
+ }
+ else {
+ m_cpuInfo.insert(blockBegin, "processor : 0");
+ }
+ }
+ if (curline1 == "") {
+ blockNumber++;
+ blockBegin = cpuit1;
+ blockBegin++;
+ }
+ if (curline1.startsWith("Processor")) {
+ cpuinfo_format_x86 = false;
+ cpuinfo_format_arm = true;
+ }
+ }
+
+ // Parse CPU information table
+ TDECPUDevice *cdevice;
+ cdevice = 0;
+ bool modified = false;
+ bool have_frequency = false;
+
+ TQString curline;
+ int processorNumber = 0;
+ int processorCount = 0;
+
+ if (cpuinfo_format_x86) {
+ // ===================================================================================================================================
+ // x86/x86_64
+ // ===================================================================================================================================
+ TQStringList::Iterator cpuit;
+ for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) {
+ curline = *cpuit;
+ if (curline.startsWith("processor")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ processorNumber = curline.toInt();
+ if (!cdevice) cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)));
+ if (cdevice) {
+ if (cdevice->coreNumber() != processorNumber) modified = true;
+ cdevice->internalSetCoreNumber(processorNumber);
+ }
+ }
+ if (curline.startsWith("model name")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ if (cdevice) {
+ if (cdevice->name() != curline) modified = true;
+ cdevice->internalSetName(curline);
+ }
+ }
+ if (curline.startsWith("cpu MHz")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ if (cdevice) {
+ if (cdevice->frequency() != curline.toDouble()) modified = true;
+ cdevice->internalSetFrequency(curline.toDouble());
+ have_frequency = true;
+ }
+ }
+ if (curline.startsWith("vendor_id")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ if (cdevice) {
+ if (cdevice->vendorName() != curline) modified = true;
+ cdevice->internalSetVendorName(curline);
+ if (cdevice->vendorEncoded() != curline) modified = true;
+ cdevice->internalSetVendorEncoded(curline);
+ }
+ }
+ curline = curline.stripWhiteSpace();
+ if (curline == "") {
+ cdevice = 0;
+ }
+ }
+ }
+ else if (cpuinfo_format_arm) {
+ // ===================================================================================================================================
+ // ARM
+ // ===================================================================================================================================
+ TQStringList::Iterator cpuit;
+ TQString modelName;
+ TQString vendorName;
+ TQString serialNumber;
+ for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) {
+ curline = *cpuit;
+ if (curline.startsWith("Processor")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ modelName = curline;
+ }
+ if (curline.startsWith("Hardware")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ vendorName = curline;
+ }
+ if (curline.startsWith("Serial")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ serialNumber = curline;
+ }
+ }
+ for (TQStringList::Iterator cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) {
+ curline = *cpuit;
+ if (curline.startsWith("processor")) {
+ curline.remove(0, curline.find(":")+1);
+ curline = curline.stripWhiteSpace();
+ processorNumber = curline.toInt();
+ if (!cdevice) {
+ cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)));
+ if (cdevice) {
+ // Set up CPU information structures
+ if (cdevice->coreNumber() != processorNumber) modified = true;
+ cdevice->internalSetCoreNumber(processorNumber);
+ if (cdevice->name() != modelName) modified = true;
+ cdevice->internalSetName(modelName);
+ if (cdevice->vendorName() != vendorName) modified = true;
+ cdevice->internalSetVendorName(vendorName);
+ if (cdevice->vendorEncoded() != vendorName) modified = true;
+ cdevice->internalSetVendorEncoded(vendorName);
+ if (cdevice->serialNumber() != serialNumber) modified = true;
+ cdevice->internalSetSerialNumber(serialNumber);
+ }
+ }
+ }
+ curline = curline.stripWhiteSpace();
+ if (curline == "") {
+ cdevice = 0;
+ }
+ }
+ }
+
+ processorCount = processorNumber+1;
+
+ // Read in other information from cpufreq, if available
+ for (processorNumber=0; processorNumber<processorCount; processorNumber++) {
+ cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)));
+ TQDir cpufreq_dir(TQString("/sys/devices/system/cpu/cpu%1/cpufreq").arg(processorNumber));
+ TQString scalinggovernor;
+ TQString scalingdriver;
+ double minfrequency = -1;
+ double maxfrequency = -1;
+ double trlatency = -1;
+ TQStringList affectedcpulist;
+ TQStringList frequencylist;
+ TQStringList governorlist;
+ if (cpufreq_dir.exists()) {
+ TQString nodename = cpufreq_dir.path();
+ nodename.append("/scaling_governor");
+ TQFile scalinggovernorfile(nodename);
+ if (scalinggovernorfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &scalinggovernorfile );
+ scalinggovernor = stream.readLine();
+ scalinggovernorfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/scaling_driver");
+ TQFile scalingdriverfile(nodename);
+ if (scalingdriverfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &scalingdriverfile );
+ scalingdriver = stream.readLine();
+ scalingdriverfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/cpuinfo_min_freq");
+ TQFile minfrequencyfile(nodename);
+ if (minfrequencyfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &minfrequencyfile );
+ minfrequency = stream.readLine().toDouble()/1000.0;
+ minfrequencyfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/cpuinfo_max_freq");
+ TQFile maxfrequencyfile(nodename);
+ if (maxfrequencyfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &maxfrequencyfile );
+ maxfrequency = stream.readLine().toDouble()/1000.0;
+ maxfrequencyfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/cpuinfo_transition_latency");
+ TQFile trlatencyfile(nodename);
+ if (trlatencyfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &trlatencyfile );
+ trlatency = stream.readLine().toDouble()/1000.0;
+ trlatencyfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/affected_cpus");
+ TQFile tiedcpusfile(nodename);
+ if (tiedcpusfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &tiedcpusfile );
+ affectedcpulist = TQStringList::split(" ", stream.readLine());
+ tiedcpusfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/scaling_available_frequencies");
+ TQFile availfreqsfile(nodename);
+ if (availfreqsfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &availfreqsfile );
+ frequencylist = TQStringList::split(" ", stream.readLine());
+ availfreqsfile.close();
+ }
+ nodename = cpufreq_dir.path();
+ nodename.append("/scaling_available_governors");
+ TQFile availgvrnsfile(nodename);
+ if (availgvrnsfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &availgvrnsfile );
+ governorlist = TQStringList::split(" ", stream.readLine());
+ availgvrnsfile.close();
+ }
+
+ if (!have_frequency) {
+ nodename = cpufreq_dir.path();
+ nodename.append("/cpuinfo_cur_freq");
+ TQFile cpufreqfile(nodename);
+ if (cpufreqfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &cpufreqfile );
+ if (cdevice) cdevice->internalSetFrequency(stream.readLine().toDouble()/1000.0);
+ cpufreqfile.close();
+ have_frequency = true;
+ }
+ }
+
+ bool frequencyFound;
+ TQStringList::Iterator freqit;
+ frequencyFound = false;
+ for ( freqit = frequencylist.begin(); freqit != frequencylist.end(); ++freqit ) {
+ double thisfrequency = (*freqit).toDouble()/1000.0;
+ if (thisfrequency == minfrequency) {
+ frequencyFound = true;
+ }
+ }
+ if (!frequencyFound) {
+ int minFrequencyInt = (minfrequency*1000.0);
+ frequencylist.prepend(TQString("%1").arg(minFrequencyInt));
+ }
+ frequencyFound = false;
+ for ( freqit = frequencylist.begin(); freqit != frequencylist.end(); ++freqit ) {
+ double thisfrequency = (*freqit).toDouble()/1000.0;
+ if (thisfrequency == maxfrequency) {
+ frequencyFound = true;
+ }
+ }
+ if (!frequencyFound) {
+ int maxfrequencyInt = (maxfrequency*1000.0);
+ frequencylist.append(TQString("%1").arg(maxfrequencyInt));
+ }
+ }
+ else {
+ if (have_frequency) {
+ if (cdevice) {
+ minfrequency = cdevice->frequency();
+ maxfrequency = cdevice->frequency();
+ }
+ }
+ }
+
+ // Update CPU information structure
+ if (cdevice) {
+ if (cdevice->governor() != scalinggovernor) modified = true;
+ cdevice->internalSetGovernor(scalinggovernor);
+ if (cdevice->scalingDriver() != scalingdriver) modified = true;
+ cdevice->internalSetScalingDriver(scalingdriver);
+ if (cdevice->minFrequency() != minfrequency) modified = true;
+ cdevice->internalSetMinFrequency(minfrequency);
+ if (cdevice->maxFrequency() != maxfrequency) modified = true;
+ cdevice->internalSetMaxFrequency(maxfrequency);
+ if (cdevice->transitionLatency() != trlatency) modified = true;
+ cdevice->internalSetTransitionLatency(trlatency);
+ if (cdevice->dependentProcessors().join(" ") != affectedcpulist.join(" ")) modified = true;
+ cdevice->internalSetDependentProcessors(affectedcpulist);
+ if (cdevice->availableFrequencies().join(" ") != frequencylist.join(" ")) modified = true;
+ cdevice->internalSetAvailableFrequencies(frequencylist);
+ if (cdevice->availableGovernors().join(" ") != governorlist.join(" ")) modified = true;
+ cdevice->internalSetAvailableGovernors(governorlist);
+ }
+ }
+
+ if (modified) {
+ for (processorNumber=0; processorNumber<processorCount; processorNumber++) {
+ TDEGenericDevice* hwdevice = findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber));
+ // Signal new information available
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ }
+ }
+}
+
+void TDEHardwareDevices::processStatelessDevices() {
+ // Some devices do not emit changed signals
+ // So far, network cards and sensors need to be polled
+ TDEGenericDevice *hwdevice;
+
+ // We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time
+ TDEGenericHardwareList devList = listAllPhysicalDevices();
+ for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
+ if ((hwdevice->type() == TDEGenericDeviceType::RootSystem) || (hwdevice->type() == TDEGenericDeviceType::Network) || (hwdevice->type() == TDEGenericDeviceType::OtherSensor) || (hwdevice->type() == TDEGenericDeviceType::Event) || (hwdevice->type() == TDEGenericDeviceType::Battery) || (hwdevice->type() == TDEGenericDeviceType::PowerSupply)) {
+ rescanDeviceInformation(hwdevice, false);
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ }
+ }
+}
+
+void TDEHardwareDevices::processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice) {
+ emit eventDeviceKeyPressed(keycode, edevice);
+}
+
+void TDEHardwareDevices::processModifiedMounts() {
+ // Detect what changed between the old mount table and the new one,
+ // and emit appropriate events
+
+ TQStringList deletedEntries = m_mountTable;
+
+ // Read in the new mount table
+ m_mountTable.clear();
+ TQFile file( "/proc/mounts" );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ m_mountTable.append(stream.readLine());
+ }
+ file.close();
+ }
+
+ TQStringList addedEntries = m_mountTable;
+
+ // Remove all entries that are identical in both tables
+ processModifiedMounts_removeagain:
+ for ( TQStringList::Iterator delit = deletedEntries.begin(); delit != deletedEntries.end(); ++delit ) {
+ for ( TQStringList::Iterator addit = addedEntries.begin(); addit != addedEntries.end(); ++addit ) {
+ if ((*delit) == (*addit)) {
+ deletedEntries.remove(delit);
+ addedEntries.remove(addit);
+ // Reset iterators to prevent bugs/crashes
+ // FIXME
+ // Is there any way to completely reset both loops without using goto?
+ goto processModifiedMounts_removeagain;
+ }
+ }
+ }
+
+ TQStringList::Iterator it;
+ for ( it = addedEntries.begin(); it != addedEntries.end(); ++it ) {
+ TQStringList mountInfo = TQStringList::split(" ", (*it), true);
+ // Try to find a device that matches the altered node
+ TDEGenericDevice* hwdevice = findByDeviceNode(*mountInfo.at(0));
+ if (hwdevice) {
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ // If the device is a storage device and has a slave, update it as well
+ if (hwdevice->type() == TDEGenericDeviceType::Disk) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ TQStringList slavedevices = sdevice->slaveDevices();
+ for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
+ TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
+ if (slavedevice) {
+ emit hardwareUpdated(slavedevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, slavedevice->uniqueID());
+ }
+ }
+ }
+ }
+ }
+ for ( it = deletedEntries.begin(); it != deletedEntries.end(); ++it ) {
+ TQStringList mountInfo = TQStringList::split(" ", (*it), true);
+ // Try to find a device that matches the altered node
+ TDEGenericDevice* hwdevice = findByDeviceNode(*mountInfo.at(0));
+ if (hwdevice) {
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ // If the device is a storage device and has a slave, update it as well
+ if (hwdevice->type() == TDEGenericDeviceType::Disk) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
+ TQStringList slavedevices = sdevice->slaveDevices();
+ for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
+ TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
+ if (slavedevice) {
+ emit hardwareUpdated(slavedevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, slavedevice->uniqueID());
+ }
+ }
+ }
+ }
+ }
+
+ emit mountTableModified();
+ emit hardwareEvent(TDEHardwareEvent::MountTableModified, TQString());
+}
+
+TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQString devicebus, const TQString disktypestring, const TQString systempath, const TQString devicevendor, const TQString devicemodel, const TQString filesystemtype, const TQString devicedriver) {
+ // Classify a disk device type to the best of our ability
+ TDEDiskDeviceType::TDEDiskDeviceType disktype = TDEDiskDeviceType::Null;
+
+ if (devicebus.upper() == "USB") {
+ disktype = disktype | TDEDiskDeviceType::USB;
+ }
+
+ if (disktypestring.upper() == "ZIP") {
+ disktype = disktype | TDEDiskDeviceType::Zip;
+ }
+ if ((devicevendor.upper() == "IOMEGA") && (devicemodel.upper().contains("ZIP"))) {
+ disktype = disktype | TDEDiskDeviceType::Zip;
+ }
+
+ if ((devicevendor.upper() == "APPLE") && (devicemodel.upper().contains("IPOD"))) {
+ disktype = disktype | TDEDiskDeviceType::MediaDevice;
+ }
+ if ((devicevendor.upper() == "SANDISK") && (devicemodel.upper().contains("SANSA"))) {
+ disktype = disktype | TDEDiskDeviceType::MediaDevice;
+ }
+
+ if (disktypestring.upper() == "TAPE") {
+ disktype = disktype | TDEDiskDeviceType::Tape;
+ }
+
+ if ((disktypestring.upper() == "COMPACT_FLASH")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_CF")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::CompactFlash;
+ }
+
+ if ((disktypestring.upper() == "MEMORY_STICK")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_MS")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::MemoryStick;
+ }
+
+ if ((disktypestring.upper() == "SMART_MEDIA")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_SM")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::SmartMedia;
+ }
+
+ if ((disktypestring.upper() == "SD_MMC")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_SD")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_SDHC")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_DRIVE_FLASH_MMC")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::SDMMC;
+ }
+
+ if ((disktypestring.upper() == "FLASHKEY")
+ || (TQString(udev_device_get_property_value(dev, " ID_DRIVE_FLASH")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::Flash;
+ }
+
+ if (disktypestring.upper() == "OPTICAL") {
+ disktype = disktype | TDEDiskDeviceType::Optical;
+ }
+
+ if (disktypestring.upper() == "JAZ") {
+ disktype = disktype | TDEDiskDeviceType::Jaz;
+ }
+
+ if (disktypestring.upper() == "DISK") {
+ disktype = disktype | TDEDiskDeviceType::HDD;
+ }
+ if (disktypestring.isNull()) {
+ // Fallback
+ // If we can't recognize the disk type then set it as a simple HDD volume
+ disktype = disktype | TDEDiskDeviceType::HDD;
+ }
+
+ // Certain combinations of media flags should never be set at the same time as they don't make sense
+ // This block is needed as udev is more than happy to provide inconsistent data to us
+ if ((disktype & TDEDiskDeviceType::Zip) || (disktype & TDEDiskDeviceType::Floppy) || (disktype & TDEDiskDeviceType::Jaz) || (disktype & TDEDiskDeviceType::Tape)) {
+ disktype = disktype & ~TDEDiskDeviceType::HDD;
+ }
+
+ if (disktypestring.upper() == "CD") {
+ disktype = disktype & ~TDEDiskDeviceType::HDD;
+ disktype = disktype | TDEDiskDeviceType::Optical;
+
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) == "1") {
+ disktype = disktype | TDEDiskDeviceType::CDROM;
+ }
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_CD_RW")) == "1") {
+ disktype = disktype | TDEDiskDeviceType::CDRW;
+ disktype = disktype & ~TDEDiskDeviceType::CDROM;
+ }
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD")) == "1") {
+ disktype = disktype | TDEDiskDeviceType::DVDROM;
+ disktype = disktype & ~TDEDiskDeviceType::CDROM;
+ }
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RAM")) == "1") {
+ disktype = disktype | TDEDiskDeviceType::DVDRAM;
+ disktype = disktype & ~TDEDiskDeviceType::DVDROM;
+ }
+ if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_R_DL")) == "1")
+ ) {
+ disktype = disktype | TDEDiskDeviceType::DVDRW;
+ disktype = disktype & ~TDEDiskDeviceType::DVDROM;
+ }
+ if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_RW_DL")) == "1")
+ ) {
+ disktype = disktype | TDEDiskDeviceType::DVDRW; // FIXME
+ disktype = disktype & ~TDEDiskDeviceType::DVDROM;
+ }
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD")) == "1") {
+ disktype = disktype | TDEDiskDeviceType::BDROM;
+ disktype = disktype & ~TDEDiskDeviceType::CDROM;
+ }
+ if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_R_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_PLUS_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_MINUS_R")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_R_DL")) == "1")
+ ) {
+ disktype = disktype | TDEDiskDeviceType::BDRW; // FIXME
+ disktype = disktype & ~TDEDiskDeviceType::BDROM;
+ }
+ if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RW_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_PLUS_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_MINUS_RW")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW_DL")) == "1")
+ || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_RW_DL")) == "1")
+ ) {
+ disktype = disktype | TDEDiskDeviceType::BDRW;
+ disktype = disktype & ~TDEDiskDeviceType::BDROM;
+ }
+ if (!TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO")).isNull()) {
+ disktype = disktype | TDEDiskDeviceType::CDAudio;
+ }
+ if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_VCD")) == "1") || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_SDVD")) == "1")) {
+ disktype = disktype | TDEDiskDeviceType::CDVideo;
+ }
+ }
+
+ // Detect RAM and Loop devices, since udev can't seem to...
+ if (systempath.startsWith("/sys/devices/virtual/block/ram")) {
+ disktype = disktype | TDEDiskDeviceType::RAM;
+ }
+ if (systempath.startsWith("/sys/devices/virtual/block/loop")) {
+ disktype = disktype | TDEDiskDeviceType::Loop;
+ }
+
+ if (filesystemtype.upper() == "CRYPTO_LUKS") {
+ disktype = disktype | TDEDiskDeviceType::LUKS;
+ }
+ else if (filesystemtype.upper() == "CRYPTO") {
+ disktype = disktype | TDEDiskDeviceType::OtherCrypted;
+ }
+
+ return disktype;
+}
+
+ // TDEStandardDirs::kde_default
+
+typedef TQMap<TQString, TQString> TDEConfigMap;
+
+TQString readUdevAttribute(udev_device* dev, TQString attr) {
+ return TQString(udev_device_get_property_value(dev, attr.ascii()));
+}
+
+TDEGenericDeviceType::TDEGenericDeviceType readGenericDeviceTypeFromString(TQString query) {
+ TDEGenericDeviceType::TDEGenericDeviceType ret = TDEGenericDeviceType::Other;
+
+ // Keep this in sync with the TDEGenericDeviceType definition in the header
+ if (query == "Root") {
+ ret = TDEGenericDeviceType::Root;
+ }
+ else if (query == "RootSystem") {
+ ret = TDEGenericDeviceType::RootSystem;
+ }
+ else if (query == "CPU") {
+ ret = TDEGenericDeviceType::CPU;
+ }
+ else if (query == "GPU") {
+ ret = TDEGenericDeviceType::GPU;
+ }
+ else if (query == "RAM") {
+ ret = TDEGenericDeviceType::RAM;
+ }
+ else if (query == "Bus") {
+ ret = TDEGenericDeviceType::Bus;
+ }
+ else if (query == "I2C") {
+ ret = TDEGenericDeviceType::I2C;
+ }
+ else if (query == "MDIO") {
+ ret = TDEGenericDeviceType::MDIO;
+ }
+ else if (query == "Mainboard") {
+ ret = TDEGenericDeviceType::Mainboard;
+ }
+ else if (query == "Disk") {
+ ret = TDEGenericDeviceType::Disk;
+ }
+ else if (query == "SCSI") {
+ ret = TDEGenericDeviceType::SCSI;
+ }
+ else if (query == "StorageController") {
+ ret = TDEGenericDeviceType::StorageController;
+ }
+ else if (query == "Mouse") {
+ ret = TDEGenericDeviceType::Mouse;
+ }
+ else if (query == "Keyboard") {
+ ret = TDEGenericDeviceType::Keyboard;
+ }
+ else if (query == "HID") {
+ ret = TDEGenericDeviceType::HID;
+ }
+ else if (query == "Modem") {
+ ret = TDEGenericDeviceType::Modem;
+ }
+ else if (query == "Monitor") {
+ ret = TDEGenericDeviceType::Monitor;
+ }
+ else if (query == "Network") {
+ ret = TDEGenericDeviceType::Network;
+ }
+ else if (query == "Printer") {
+ ret = TDEGenericDeviceType::Printer;
+ }
+ else if (query == "Scanner") {
+ ret = TDEGenericDeviceType::Scanner;
+ }
+ else if (query == "Sound") {
+ ret = TDEGenericDeviceType::Sound;
+ }
+ else if (query == "VideoCapture") {
+ ret = TDEGenericDeviceType::VideoCapture;
+ }
+ else if (query == "IEEE1394") {
+ ret = TDEGenericDeviceType::IEEE1394;
+ }
+ else if (query == "PCMCIA") {
+ ret = TDEGenericDeviceType::PCMCIA;
+ }
+ else if (query == "Camera") {
+ ret = TDEGenericDeviceType::Camera;
+ }
+ else if (query == "Serial") {
+ ret = TDEGenericDeviceType::Serial;
+ }
+ else if (query == "Parallel") {
+ ret = TDEGenericDeviceType::Parallel;
+ }
+ else if (query == "TextIO") {
+ ret = TDEGenericDeviceType::TextIO;
+ }
+ else if (query == "Peripheral") {
+ ret = TDEGenericDeviceType::Peripheral;
+ }
+ else if (query == "Backlight") {
+ ret = TDEGenericDeviceType::Backlight;
+ }
+ else if (query == "Battery") {
+ ret = TDEGenericDeviceType::Battery;
+ }
+ else if (query == "Power") {
+ ret = TDEGenericDeviceType::PowerSupply;
+ }
+ else if (query == "Dock") {
+ ret = TDEGenericDeviceType::Dock;
+ }
+ else if (query == "ThermalSensor") {
+ ret = TDEGenericDeviceType::ThermalSensor;
+ }
+ else if (query == "ThermalControl") {
+ ret = TDEGenericDeviceType::ThermalControl;
+ }
+ else if (query == "Bluetooth") {
+ ret = TDEGenericDeviceType::BlueTooth;
+ }
+ else if (query == "Bridge") {
+ ret = TDEGenericDeviceType::Bridge;
+ }
+ else if (query == "Platform") {
+ ret = TDEGenericDeviceType::Platform;
+ }
+ else if (query == "Cryptography") {
+ ret = TDEGenericDeviceType::Cryptography;
+ }
+ else if (query == "Event") {
+ ret = TDEGenericDeviceType::Event;
+ }
+ else if (query == "Input") {
+ ret = TDEGenericDeviceType::Input;
+ }
+ else if (query == "PNP") {
+ ret = TDEGenericDeviceType::PNP;
+ }
+ else if (query == "OtherACPI") {
+ ret = TDEGenericDeviceType::OtherACPI;
+ }
+ else if (query == "OtherUSB") {
+ ret = TDEGenericDeviceType::OtherUSB;
+ }
+ else if (query == "OtherMultimedia") {
+ ret = TDEGenericDeviceType::OtherMultimedia;
+ }
+ else if (query == "OtherPeripheral") {
+ ret = TDEGenericDeviceType::OtherPeripheral;
+ }
+ else if (query == "OtherSensor") {
+ ret = TDEGenericDeviceType::OtherSensor;
+ }
+ else if (query == "OtherVirtual") {
+ ret = TDEGenericDeviceType::OtherVirtual;
+ }
+ else {
+ ret = TDEGenericDeviceType::Other;
+ }
+
+ return ret;
+}
+
+TDEDiskDeviceType::TDEDiskDeviceType readDiskDeviceSubtypeFromString(TQString query, TDEDiskDeviceType::TDEDiskDeviceType flagsIn=TDEDiskDeviceType::Null) {
+ TDEDiskDeviceType::TDEDiskDeviceType ret = flagsIn;
+
+ // Keep this in sync with the TDEDiskDeviceType definition in the header
+ if (query == "MediaDevice") {
+ ret = ret | TDEDiskDeviceType::MediaDevice;
+ }
+ if (query == "Floppy") {
+ ret = ret | TDEDiskDeviceType::Floppy;
+ }
+ if (query == "CDROM") {
+ ret = ret | TDEDiskDeviceType::CDROM;
+ }
+ if (query == "CDRW") {
+ ret = ret | TDEDiskDeviceType::CDRW;
+ }
+ if (query == "DVDROM") {
+ ret = ret | TDEDiskDeviceType::DVDROM;
+ }
+ if (query == "DVDRAM") {
+ ret = ret | TDEDiskDeviceType::DVDRAM;
+ }
+ if (query == "DVDRW") {
+ ret = ret | TDEDiskDeviceType::DVDRW;
+ }
+ if (query == "BDROM") {
+ ret = ret | TDEDiskDeviceType::BDROM;
+ }
+ if (query == "BDRW") {
+ ret = ret | TDEDiskDeviceType::BDRW;
+ }
+ if (query == "Zip") {
+ ret = ret | TDEDiskDeviceType::Zip;
+ }
+ if (query == "Jaz") {
+ ret = ret | TDEDiskDeviceType::Jaz;
+ }
+ if (query == "Camera") {
+ ret = ret | TDEDiskDeviceType::Camera;
+ }
+ if (query == "LUKS") {
+ ret = ret | TDEDiskDeviceType::LUKS;
+ }
+ if (query == "OtherCrypted") {
+ ret = ret | TDEDiskDeviceType::OtherCrypted;
+ }
+ if (query == "CDAudio") {
+ ret = ret | TDEDiskDeviceType::CDAudio;
+ }
+ if (query == "CDVideo") {
+ ret = ret | TDEDiskDeviceType::CDVideo;
+ }
+ if (query == "DVDVideo") {
+ ret = ret | TDEDiskDeviceType::DVDVideo;
+ }
+ if (query == "BDVideo") {
+ ret = ret | TDEDiskDeviceType::BDVideo;
+ }
+ if (query == "Flash") {
+ ret = ret | TDEDiskDeviceType::Flash;
+ }
+ if (query == "USB") {
+ ret = ret | TDEDiskDeviceType::USB;
+ }
+ if (query == "Tape") {
+ ret = ret | TDEDiskDeviceType::Tape;
+ }
+ if (query == "HDD") {
+ ret = ret | TDEDiskDeviceType::HDD;
+ }
+ if (query == "Optical") {
+ ret = ret | TDEDiskDeviceType::Optical;
+ }
+ if (query == "RAM") {
+ ret = ret | TDEDiskDeviceType::RAM;
+ }
+ if (query == "Loop") {
+ ret = ret | TDEDiskDeviceType::Loop;
+ }
+ if (query == "CompactFlash") {
+ ret = ret | TDEDiskDeviceType::CompactFlash;
+ }
+ if (query == "MemoryStick") {
+ ret = ret | TDEDiskDeviceType::MemoryStick;
+ }
+ if (query == "SmartMedia") {
+ ret = ret | TDEDiskDeviceType::SmartMedia;
+ }
+ if (query == "SDMMC") {
+ ret = ret | TDEDiskDeviceType::SDMMC;
+ }
+ if (query == "UnlockedCrypt") {
+ ret = ret | TDEDiskDeviceType::UnlockedCrypt;
+ }
+
+ return ret;
+}
+
+TDEGenericDevice* createDeviceObjectForType(TDEGenericDeviceType::TDEGenericDeviceType type) {
+ TDEGenericDevice* ret = 0;
+
+ if (type == TDEGenericDeviceType::Disk) {
+ ret = new TDEStorageDevice(type);
+ }
+ else {
+ ret = new TDEGenericDevice(type);
+ }
+
+ return ret;
+}
+
+TDEGenericDevice* TDEHardwareDevices::classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice, bool classifySubDevices) {
+ // This routine expects to see the hardware config files into <prefix>/share/apps/tdehwlib/deviceclasses/, suffixed with "hwclass"
+ TDEGenericDevice* device = existingdevice;
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Other);
+
+ // Handle subtype if needed/desired
+ // To speed things up we rely on the prior scan results stored in m_externalSubtype
+ if (classifySubDevices) {
+ if (!device->m_externalRulesFile.isNull()) {
+ if (device->type() == TDEGenericDeviceType::Disk) {
+ // Disk class
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
+ TQStringList subtype = device->m_externalSubtype;
+ TDEDiskDeviceType::TDEDiskDeviceType desiredSubdeviceType = TDEDiskDeviceType::Null;
+ if (subtype.count()>0) {
+ for ( TQStringList::Iterator paramit = subtype.begin(); paramit != subtype.end(); ++paramit ) {
+ desiredSubdeviceType = readDiskDeviceSubtypeFromString(*paramit, desiredSubdeviceType);
+ }
+ if (desiredSubdeviceType != sdevice->diskType()) {
+ printf("[tdehardwaredevices] Rules file %s used to set device subtype for device at path %s\n", device->m_externalRulesFile.ascii(), device->systemPath().ascii()); fflush(stdout);
+ sdevice->internalSetDiskType(desiredSubdeviceType);
+ }
+ }
+ }
+ }
+ }
+ else {
+ TQStringList hardware_info_directories(TDEGlobal::dirs()->resourceDirs("data"));
+ TQString hardware_info_directory_suffix("tdehwlib/deviceclasses/");
+ TQString hardware_info_directory;
+
+ // Scan the hardware_info_directory for configuration files
+ // For each one, open it with TDEConfig() and apply its rules to classify the device
+ // FIXME
+ // Should this also scan up to <n> subdirectories for the files? That feature might end up being too expensive...
+
+ device->m_externalRulesFile = TQString::null;
+ for ( TQStringList::Iterator it = hardware_info_directories.begin(); it != hardware_info_directories.end(); ++it ) {
+ hardware_info_directory = (*it);
+ hardware_info_directory += hardware_info_directory_suffix;
+
+ if (TDEGlobal::dirs()->exists(hardware_info_directory)) {
+ TQDir d(hardware_info_directory);
+ d.setFilter( TQDir::Files | TQDir::Hidden );
+
+ const TQFileInfoList *list = d.entryInfoList();
+ TQFileInfoListIterator it( *list );
+ TQFileInfo *fi;
+
+ while ((fi = it.current()) != 0) {
+ if (fi->extension(false) == "hwclass") {
+ bool match = true;
+
+ // Open the rules file
+ TDEConfig rulesFile(fi->absFilePath(), true, false);
+ rulesFile.setGroup("Conditions");
+ TDEConfigMap conditionmap = rulesFile.entryMap("Conditions");
+ TDEConfigMap::Iterator cndit;
+ for (cndit = conditionmap.begin(); cndit != conditionmap.end(); ++cndit) {
+ TQStringList conditionList = TQStringList::split(',', cndit.data(), false);
+ bool atleastonematch = false;
+ for ( TQStringList::Iterator paramit = conditionList.begin(); paramit != conditionList.end(); ++paramit ) {
+ if (cndit.key() == "VENDOR_ID") {
+ if (device->vendorID() == (*paramit)) {
+ atleastonematch = true;
+ }
+ }
+ else if (cndit.key() == "MODEL_ID") {
+ if (device->modelID() == (*paramit)) {
+ atleastonematch = true;
+ }
+ }
+ else if (cndit.key() == "DRIVER") {
+ if (device->deviceDriver() == (*paramit)) {
+ atleastonematch = true;
+ }
+ }
+ else if (readUdevAttribute(dev, cndit.key()) == (*paramit)) {
+ atleastonematch = true;
+ }
+ }
+ if (!atleastonematch) {
+ match = false;
+ }
+ }
+
+ if (match) {
+ rulesFile.setGroup("DeviceType");
+ TQString gentype = rulesFile.readEntry("GENTYPE");
+ TDEGenericDeviceType::TDEGenericDeviceType desiredDeviceType = device->type();
+ if (!gentype.isNull()) {
+ desiredDeviceType = readGenericDeviceTypeFromString(gentype);
+ }
+
+ // Handle main type
+ if (desiredDeviceType != device->type()) {
+ printf("[tdehardwaredevices] Rules file %s used to set device type for device at path %s\n", fi->absFilePath().ascii(), device->systemPath().ascii()); fflush(stdout);
+ if (m_deviceList.contains(device)) {
+ m_deviceList.remove(device);
+ }
+ else {
+ delete device;
+ }
+ device = createDeviceObjectForType(desiredDeviceType);
+ }
+
+ // Parse subtype and store in m_externalSubtype for later
+ // This speeds things up considerably due to the expense of the file scanning/parsing/matching operation
+ device->m_externalSubtype = rulesFile.readListEntry("SUBTYPE", ',');
+ device->m_externalRulesFile = fi->absFilePath();
+
+ // Process blacklist entries
+ rulesFile.setGroup("DeviceSettings");
+ device->internalSetBlacklistedForUpdate(rulesFile.readBoolEntry("UPDATE_BLACKLISTED", device->blacklistedForUpdate()));
+ }
+ }
+ ++it;
+ }
+ }
+ }
+ }
+
+ return device;
+}
+
+TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice, bool force_full_classification) {
+ // Classify device and create TDEHW device object
+ TQString devicename;
+ TQString devicetype;
+ TQString devicedriver;
+ TQString devicesubsystem;
+ TQString devicenode;
+ TQString systempath;
+ TQString devicevendorid;
+ TQString devicemodelid;
+ TQString devicevendoridenc;
+ TQString devicemodelidenc;
+ TQString devicesubvendorid;
+ TQString devicesubmodelid;
+ TQString devicetypestring;
+ TQString devicetypestring_alt;
+ TQString devicepciclass;
+ TDEGenericDevice* device = existingdevice;
+ bool temp_udev_device = !dev;
+ if (dev) {
+ devicename = (udev_device_get_sysname(dev));
+ devicetype = (udev_device_get_devtype(dev));
+ devicedriver = (udev_device_get_driver(dev));
+ devicesubsystem = (udev_device_get_subsystem(dev));
+ devicenode = (udev_device_get_devnode(dev));
+ systempath = (udev_device_get_syspath(dev));
+ systempath += "/";
+ devicevendorid = (udev_device_get_property_value(dev, "ID_VENDOR_ID"));
+ devicemodelid = (udev_device_get_property_value(dev, "ID_MODEL_ID"));
+ devicevendoridenc = (udev_device_get_property_value(dev, "ID_VENDOR_ENC"));
+ devicemodelidenc = (udev_device_get_property_value(dev, "ID_MODEL_ENC"));
+ devicesubvendorid = (udev_device_get_property_value(dev, "ID_SUBVENDOR_ID"));
+ devicesubmodelid = (udev_device_get_property_value(dev, "ID_SUBMODEL_ID"));
+ devicetypestring = (udev_device_get_property_value(dev, "ID_TYPE"));
+ devicetypestring_alt = (udev_device_get_property_value(dev, "DEVTYPE"));
+ devicepciclass = (udev_device_get_property_value(dev, "PCI_CLASS"));
+ }
+ else {
+ if (device) {
+ devicename = device->name();
+ devicetype = device->m_udevtype;
+ devicedriver = device->deviceDriver();
+ devicesubsystem = device->subsystem();
+ devicenode = device->deviceNode();
+ systempath = device->systemPath();
+ devicevendorid = device->vendorID();
+ devicemodelid = device->modelID();
+ devicevendoridenc = device->vendorEncoded();
+ devicemodelidenc = device->modelEncoded();
+ devicesubvendorid = device->subVendorID();
+ devicesubmodelid = device->subModelID();
+ devicetypestring = device->m_udevdevicetypestring;
+ devicetypestring_alt = device->udevdevicetypestring_alt;
+ devicepciclass = device->PCIClass();
+ }
+ TQString syspathudev = systempath;
+ syspathudev.truncate(syspathudev.length()-1); // Remove trailing slash
+ dev = udev_device_new_from_syspath(m_udevStruct, syspathudev.ascii());
+ }
+
+ // FIXME
+ // Only a small subset of devices are classified right now
+ // Figure out the remaining udev logic to classify the rest!
+ // Helpful file: http://www.enlightenment.org/svn/e/trunk/PROTO/enna-explorer/src/bin/udev.c
+
+ bool done = false;
+ TQString current_path = systempath;
+ TQString devicemodalias = TQString::null;
+
+ while (done == false) {
+ TQString malnodename = current_path;
+ malnodename.append("/modalias");
+ TQFile malfile(malnodename);
+ if (malfile.open(IO_ReadOnly)) {
+ TQTextStream stream( &malfile );
+ devicemodalias = stream.readLine();
+ malfile.close();
+ }
+ if (devicemodalias.startsWith("pci") || devicemodalias.startsWith("usb")) {
+ done = true;
+ }
+ else {
+ devicemodalias = TQString::null;
+ current_path.truncate(current_path.findRev("/"));
+ if (!current_path.startsWith("/sys/devices")) {
+ // Abort!
+ done = true;
+ }
+ }
+ }
+
+ // Many devices do not provide their vendor/model ID via udev
+ // Worse, sometimes udev provides an invalid model ID!
+ // Go after it manually if needed...
+ if (devicevendorid.isNull() || devicemodelid.isNull() || devicemodelid.contains("/")) {
+ if (devicemodalias != TQString::null) {
+ // For added fun the device string lengths differ between pci and usb
+ if (devicemodalias.startsWith("pci")) {
+ int vloc = devicemodalias.find("v");
+ int dloc = devicemodalias.find("d", vloc);
+ int svloc = devicemodalias.find("sv");
+ int sdloc = devicemodalias.find("sd", vloc);
+
+ devicevendorid = devicemodalias.mid(vloc+1, 8).lower();
+ devicemodelid = devicemodalias.mid(dloc+1, 8).lower();
+ if (svloc != -1) {
+ devicesubvendorid = devicemodalias.mid(svloc+1, 8).lower();
+ devicesubmodelid = devicemodalias.mid(sdloc+1, 8).lower();
+ }
+ devicevendorid.remove(0,4);
+ devicemodelid.remove(0,4);
+ devicesubvendorid.remove(0,4);
+ devicesubmodelid.remove(0,4);
+ }
+ if (devicemodalias.startsWith("usb")) {
+ int vloc = devicemodalias.find("v");
+ int dloc = devicemodalias.find("p", vloc);
+ int svloc = devicemodalias.find("sv");
+ int sdloc = devicemodalias.find("sp", vloc);
+
+ devicevendorid = devicemodalias.mid(vloc+1, 4).lower();
+ devicemodelid = devicemodalias.mid(dloc+1, 4).lower();
+ if (svloc != -1) {
+ devicesubvendorid = devicemodalias.mid(svloc+1, 4).lower();
+ devicesubmodelid = devicemodalias.mid(sdloc+1, 4).lower();
+ }
+ }
+ }
+ }
+
+ // Most of the time udev doesn't barf up a device driver either, so go after it manually...
+ if (devicedriver.isNull()) {
+ TQString driverSymlink = udev_device_get_syspath(dev);
+ TQString driverSymlinkDir = driverSymlink;
+ driverSymlink.append("/device/driver");
+ driverSymlinkDir.append("/device/");
+ TQFileInfo dirfi(driverSymlink);
+ if (dirfi.isSymLink()) {
+ char* collapsedPath = realpath((driverSymlinkDir + dirfi.readLink()).ascii(), NULL);
+ devicedriver = TQString(collapsedPath);
+ free(collapsedPath);
+ devicedriver.remove(0, devicedriver.findRev("/")+1);
+ }
+ }
+
+ // udev removes critical leading zeroes in the PCI device class, so go after it manually...
+ TQString classnodename = systempath;
+ classnodename.append("/class");
+ TQFile classfile( classnodename );
+ if ( classfile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &classfile );
+ devicepciclass = stream.readLine();
+ devicepciclass.replace("0x", "");
+ devicepciclass = devicepciclass.lower();
+ classfile.close();
+ }
+
+ // Classify generic device type and create appropriate object
+
+ // Pull out all event special devices and stuff them under Event
+ TQString syspath_tail = systempath.lower();
+ syspath_tail.truncate(syspath_tail.length()-1);
+ syspath_tail.remove(0, syspath_tail.findRev("/")+1);
+ if (syspath_tail.startsWith("event")) {
+ if (!device) device = new TDEEventDevice(TDEGenericDeviceType::Event);
+ }
+ // Pull out all input special devices and stuff them under Input
+ if (syspath_tail.startsWith("input")) {
+ if (!device) device = new TDEInputDevice(TDEGenericDeviceType::Input);
+ }
+
+ // Check for keyboard
+ // Linux doesn't actually ID the keyboard device itself as such, it instead IDs the input device that is underneath the actual keyboard itseld
+ // Therefore we need to scan <syspath>/input/input* for the ID_INPUT_KEYBOARD attribute
+ bool is_keyboard = false;
+ TQString inputtopdirname = udev_device_get_syspath(dev);
+ inputtopdirname.append("/input/");
+ TQDir inputdir(inputtopdirname);
+ inputdir.setFilter(TQDir::All);
+ const TQFileInfoList *dirlist = inputdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator inputdirsit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = inputdirsit.current()) != 0 ) {
+ if ((dirfi->fileName() != ".") && (dirfi->fileName() != "..")) {
+ struct udev_device *slavedev;
+ slavedev = udev_device_new_from_syspath(m_udevStruct, (inputtopdirname + dirfi->fileName()).ascii());
+ if (udev_device_get_property_value(slavedev, "ID_INPUT_KEYBOARD") != 0) {
+ is_keyboard = true;
+ }
+ udev_device_unref(slavedev);
+ }
+ ++inputdirsit;
+ }
+ }
+ if (is_keyboard) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Keyboard);
+ }
+
+ // Classify specific known devices
+ if (((devicetype == "disk")
+ || (devicetype == "partition")
+ || (devicedriver == "floppy")
+ || (devicesubsystem == "scsi_disk")
+ || (devicesubsystem == "scsi_tape"))
+ && ((devicenode != "")
+ )) {
+ if (!device) device = new TDEStorageDevice(TDEGenericDeviceType::Disk);
+ }
+ else if (devicetype == "host") {
+ if (devicesubsystem == "bluetooth") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::BlueTooth);
+ }
+ }
+ else if (devicetype.isNull()) {
+ if (devicesubsystem == "acpi") {
+ // If the ACPI device exposes a system path ending in /PNPxxxx:yy, the device type can be precisely determined
+ // See ftp://ftp.microsoft.com/developr/drg/plug-and-play/devids.txt for more information
+ TQString pnpgentype = systempath;
+ pnpgentype.remove(0, pnpgentype.findRev("/")+1);
+ pnpgentype.truncate(pnpgentype.find(":"));
+ if (pnpgentype.startsWith("PNP")) {
+ // If a device has been classified as belonging to the ACPI subsystem usually there is a "real" device related to it elsewhere in the system
+ // Furthermore, the "real" device elsewhere almost always has more functionality exposed via sysfs
+ // Therefore all ACPI subsystem devices should be stuffed in the OtherACPI category and largely ignored
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherACPI);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherACPI);
+ }
+ }
+ else if (devicesubsystem == "input") {
+ // Figure out if this device is a mouse, keyboard, or something else
+ // Check for mouse
+ // udev doesn't reliably help here, so guess from the device name
+ if (systempath.contains("/mouse")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Mouse);
+ }
+ if (!device) {
+ // Second mouse check
+ // Look for ID_INPUT_MOUSE property presence
+ if (udev_device_get_property_value(dev, "ID_INPUT_MOUSE") != 0) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Mouse);
+ }
+ }
+ if (!device) {
+ // Check for keyboard
+ // Look for ID_INPUT_KEYBOARD property presence
+ if (udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD") != 0) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Keyboard);
+ }
+ }
+ if (!device) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::HID);
+ }
+ }
+ else if (devicesubsystem == "tty") {
+ if (devicenode.contains("/ttyS")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::TextIO);
+ }
+ }
+ else if (devicesubsystem == "usb-serial") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
+ }
+ else if ((devicesubsystem == "spi_master")
+ || (devicesubsystem == "spidev")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
+ }
+ else if (devicesubsystem == "spi") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ else if (devicesubsystem == "thermal") {
+ // FIXME
+ // Figure out a way to differentiate between ThermalControl (fans and coolers) and ThermalSensor types
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::ThermalControl);
+ }
+ else if (devicesubsystem == "hwmon") {
+ // FIXME
+ // This might pick up thermal sensors
+ if (!device) device = new TDESensorDevice(TDEGenericDeviceType::OtherSensor);
+ }
+ else if (devicesubsystem == "virtio") {
+ if (devicedriver == "virtio_blk") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::SCSI);
+ }
+ if (devicedriver == "virtio_net") {
+ if (!device) device = new TDENetworkDevice(TDEGenericDeviceType::Network);
+ }
+ if (devicedriver == "virtio_balloon") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::RAM);
+ }
+ }
+ }
+
+ // Try to at least generally classify unclassified devices
+ if (device == 0) {
+ if (devicesubsystem == "backlight") {
+ if (!device) device = new TDEBacklightDevice(TDEGenericDeviceType::Backlight);
+ }
+ if (systempath.lower().startsWith("/sys/devices/virtual")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherVirtual);
+ }
+ if (systempath.lower().startsWith("/sys/module/")
+ || (systempath.lower().startsWith("/sys/kernel/"))) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform); // FIXME Should go into a new kernel module category when the tdelibs ABI can be broken again
+ }
+ if ((devicetypestring == "audio")
+ || (devicesubsystem == "sound")
+ || (devicesubsystem == "ac97")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Sound);
+ }
+ if ((devicesubsystem == "video4linux")
+ || (devicesubsystem == "dvb")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::VideoCapture);
+ }
+ if ((devicetypestring_alt == "scsi_target")
+ || (devicesubsystem == "scsi_host")
+ || (devicesubsystem == "scsi_disk")
+ || (devicesubsystem == "scsi_device")
+ || (devicesubsystem == "scsi_generic")
+ || (devicesubsystem == "scsi")
+ || (devicetypestring_alt == "sas_target")
+ || (devicesubsystem == "sas_host")
+ || (devicesubsystem == "sas_port")
+ || (devicesubsystem == "sas_device")
+ || (devicesubsystem == "sas_generic")
+ || (devicesubsystem == "sas_phy")
+ || (devicesubsystem == "sas_end_device")
+ || (devicesubsystem == "spi_transport")
+ || (devicesubsystem == "spi_host")
+ || (devicesubsystem == "ata_port")
+ || (devicesubsystem == "ata_link")
+ || (devicesubsystem == "ata_disk")
+ || (devicesubsystem == "ata_device")
+ || (devicesubsystem == "ata")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "infiniband") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Peripheral);
+ }
+ if ((devicesubsystem == "infiniband_cm")
+ || (devicesubsystem == "infiniband_mad")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if ((devicesubsystem == "enclosure")
+ || (devicesubsystem == "clocksource")
+ || (devicesubsystem == "amba")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "ipmi_si") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Mainboard);
+ }
+ if (devicesubsystem == "misc") {
+ if (devicedriver.startsWith("tpm_")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Cryptography);
+ }
+ }
+ if (devicesubsystem == "leds") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherACPI);
+ }
+ if (devicesubsystem == "net") {
+ if (!device) device = new TDENetworkDevice(TDEGenericDeviceType::Network);
+ }
+ if ((devicesubsystem == "i2c")
+ || (devicesubsystem == "i2c-dev")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::I2C);
+ }
+ if (devicesubsystem == "mdio_bus") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::MDIO);
+ }
+ if (devicesubsystem == "graphics") {
+ if (devicenode.isNull()) { // GPUs do not have associated device nodes
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::GPU);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ }
+ if (devicesubsystem == "tifm_adapter") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::StorageController);
+ }
+ if (devicesubsystem == "mmc_host") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::StorageController);
+ }
+ if (devicesubsystem == "mmc") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if ((devicesubsystem == "event_source")
+ || (devicesubsystem == "rtc")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Mainboard);
+ }
+ if (devicesubsystem == "bsg") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::SCSI);
+ }
+ if (devicesubsystem == "firewire") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::IEEE1394);
+ }
+ if (devicesubsystem == "drm") {
+ if (devicenode.isNull()) { // Monitors do not have associated device nodes
+ if (!device) device = new TDEMonitorDevice(TDEGenericDeviceType::Monitor);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ }
+ if (devicesubsystem == "serio") {
+ if (devicedriver.contains("atkbd")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Keyboard);
+ }
+ else if (devicedriver.contains("mouse")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Mouse);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
+ }
+ }
+ if (devicesubsystem == "ppdev") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Parallel);
+ }
+ if (devicesubsystem == "printer") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Printer);
+ }
+ if (devicesubsystem == "bridge") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Bridge);
+ }
+ if ((devicesubsystem == "pci_bus")
+ || (devicesubsystem == "pci_express")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Bus);
+ }
+ if (devicesubsystem == "pcmcia_socket") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::PCMCIA);
+ }
+ if (devicesubsystem == "platform") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "ieee80211") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "rfkill") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "machinecheck") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ if (devicesubsystem == "pnp") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::PNP);
+ }
+ if ((devicesubsystem == "hid")
+ || (devicesubsystem == "hidraw")
+ || (devicesubsystem == "usbhid")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::HID);
+ }
+ if (devicesubsystem == "power_supply") {
+ TQString powersupplyname(udev_device_get_property_value(dev, "POWER_SUPPLY_NAME"));
+ if (powersupplyname.upper().startsWith("AC")) {
+ if (!device) device = new TDEMainsPowerDevice(TDEGenericDeviceType::PowerSupply);
+ }
+ else {
+ if (!device) device = new TDEBatteryDevice(TDEGenericDeviceType::Battery);
+ }
+ }
+
+ // Moderate accuracy classification, if PCI device class is available
+ // See http://www.acm.uiuc.edu/sigops/roll_your_own/7.c.1.html for codes and meanings
+ if (!devicepciclass.isNull()) {
+ // Pre PCI 2.0
+ if (devicepciclass.startsWith("0001")) {
+ if (devicenode.isNull()) { // GPUs do not have associated device nodes
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::GPU);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ }
+ // Post PCI 2.0
+ TQString devicepcisubclass = devicepciclass;
+ devicepcisubclass = devicepcisubclass.remove(0,2);
+ if (devicepciclass.startsWith("01")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::StorageController);
+ }
+ if (devicepciclass.startsWith("02")) {
+ if (!device) device = new TDENetworkDevice(TDEGenericDeviceType::Network);
+ }
+ if (devicepciclass.startsWith("03")) {
+ if (devicenode.isNull()) { // GPUs do not have associated device nodes
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::GPU);
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ }
+ if (devicepciclass.startsWith("04")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherMultimedia);
+ }
+ if (devicepciclass.startsWith("05")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::RAM);
+ }
+ if (devicepciclass.startsWith("06")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Bridge);
+ }
+ if (devicepciclass.startsWith("07")) {
+ if (devicepcisubclass.startsWith("03")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Modem);
+ }
+ }
+ if (devicepciclass.startsWith("0a")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Dock);
+ }
+ if (devicepciclass.startsWith("0b")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::CPU);
+ }
+ if (devicepciclass.startsWith("0c")) {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
+ }
+ }
+
+ // Last ditch attempt at classification
+ // Likely inaccurate and sweeping
+ if ((devicesubsystem == "usb")
+ || (devicesubsystem == "usb_device")
+ || (devicesubsystem == "usbmon")) {
+ // Get USB interface class for further classification
+ int usbInterfaceClass = -1;
+ {
+ TQFile ifaceprotofile(current_path + "/bInterfaceClass");
+ if (ifaceprotofile.open(IO_ReadOnly)) {
+ TQTextStream stream( &ifaceprotofile );
+ usbInterfaceClass = stream.readLine().toUInt();
+ ifaceprotofile.close();
+ }
+ }
+ // Get USB interface subclass for further classification
+ int usbInterfaceSubClass = -1;
+ {
+ TQFile ifaceprotofile(current_path + "/bInterfaceSubClass");
+ if (ifaceprotofile.open(IO_ReadOnly)) {
+ TQTextStream stream( &ifaceprotofile );
+ usbInterfaceSubClass = stream.readLine().toUInt();
+ ifaceprotofile.close();
+ }
+ }
+ // Get USB interface protocol for further classification
+ int usbInterfaceProtocol = -1;
+ {
+ TQFile ifaceprotofile(current_path + "/bInterfaceProtocol");
+ if (ifaceprotofile.open(IO_ReadOnly)) {
+ TQTextStream stream( &ifaceprotofile );
+ usbInterfaceProtocol = stream.readLine().toUInt();
+ ifaceprotofile.close();
+ }
+ }
+ if ((usbInterfaceClass == 6) && (usbInterfaceSubClass == 1) && (usbInterfaceProtocol == 1)) {
+ // PictBridge
+ if (!device) {
+ device = new TDEStorageDevice(TDEGenericDeviceType::Disk);
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
+ sdevice->internalSetDiskType(TDEDiskDeviceType::Camera);
+ TQString parentsyspathudev = systempath;
+ parentsyspathudev.truncate(parentsyspathudev.length()-1); // Remove trailing slash
+ parentsyspathudev.truncate(parentsyspathudev.findRev("/"));
+ struct udev_device *parentdev;
+ parentdev = udev_device_new_from_syspath(m_udevStruct, parentsyspathudev.ascii());
+ devicenode = (udev_device_get_devnode(parentdev));
+ }
+ }
+ else {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherUSB);
+ }
+ }
+ if (devicesubsystem == "pci") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherPeripheral);
+ }
+ if (devicesubsystem == "cpu") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Platform);
+ }
+ }
+
+ if (device == 0) {
+ // Unhandled
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Other);
+ printf("[FIXME] UNCLASSIFIED DEVICE name: %s type: %s subsystem: %s driver: %s [Node Path: %s] [Syspath: %s] [%s:%s]\n", devicename.ascii(), devicetype.ascii(), devicesubsystem.ascii(), devicedriver.ascii(), devicenode.ascii(), udev_device_get_syspath(dev), devicevendorid.ascii(), devicemodelid.ascii()); fflush(stdout);
+ }
+
+ // Root devices are special
+ if ((device->type() == TDEGenericDeviceType::Root) || (device->type() == TDEGenericDeviceType::RootSystem)) {
+ systempath = device->systemPath();
+ }
+
+ // Set preliminary basic device information
+ device->internalSetName(devicename);
+ device->internalSetDeviceNode(devicenode);
+ device->internalSetSystemPath(systempath);
+ device->internalSetVendorID(devicevendorid);
+ device->internalSetModelID(devicemodelid);
+ device->internalSetVendorEncoded(devicevendoridenc);
+ device->internalSetModelEncoded(devicemodelidenc);
+ device->internalSetSubVendorID(devicesubvendorid);
+ device->internalSetSubModelID(devicesubmodelid);
+ device->internalSetModuleAlias(devicemodalias);
+ device->internalSetDeviceDriver(devicedriver);
+ device->internalSetSubsystem(devicesubsystem);
+ device->internalSetPCIClass(devicepciclass);
+
+ updateBlacklists(device, dev);
+
+ if (force_full_classification) {
+ // Check external rules for possible device type overrides
+ device = classifyUnknownDeviceByExternalRules(dev, device, false);
+ }
+
+ // Internal use only!
+ device->m_udevtype = devicetype;
+ device->m_udevdevicetypestring = devicetypestring;
+ device->udevdevicetypestring_alt = devicetypestring_alt;
+
+ updateExistingDeviceInformation(device, dev);
+
+ if (temp_udev_device) {
+ udev_device_unref(dev);
+ }
+
+ return device;
+}
+
+void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev) {
+ TQString devicename;
+ TQString devicetype;
+ TQString devicedriver;
+ TQString devicesubsystem;
+ TQString devicenode;
+ TQString systempath;
+ TQString devicevendorid;
+ TQString devicemodelid;
+ TQString devicevendoridenc;
+ TQString devicemodelidenc;
+ TQString devicesubvendorid;
+ TQString devicesubmodelid;
+ TQString devicetypestring;
+ TQString devicetypestring_alt;
+ TQString devicepciclass;
+ TDEGenericDevice* device = existingdevice;
+ bool temp_udev_device = !dev;
+
+ devicename = device->name();
+ devicetype = device->m_udevtype;
+ devicedriver = device->deviceDriver();
+ devicesubsystem = device->subsystem();
+ devicenode = device->deviceNode();
+ systempath = device->systemPath();
+ devicevendorid = device->vendorID();
+ devicemodelid = device->modelID();
+ devicevendoridenc = device->vendorEncoded();
+ devicemodelidenc = device->modelEncoded();
+ devicesubvendorid = device->subVendorID();
+ devicesubmodelid = device->subModelID();
+ devicetypestring = device->m_udevdevicetypestring;
+ devicetypestring_alt = device->udevdevicetypestring_alt;
+ devicepciclass = device->PCIClass();
+
+ if (!dev) {
+ TQString syspathudev = systempath;
+ syspathudev.truncate(syspathudev.length()-1); // Remove trailing slash
+ dev = udev_device_new_from_syspath(m_udevStruct, syspathudev.ascii());
+ }
+
+ if (device->type() == TDEGenericDeviceType::Disk) {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
+ if (sdevice->diskType() & TDEDiskDeviceType::Camera) {
+ // PictBridge cameras are special and should not be classified by standard rules
+ sdevice->internalSetDiskStatus(TDEDiskDeviceStatus::Removable);
+ sdevice->internalSetFileSystemName("pictbridge");
+ }
+ else {
+ bool removable = false;
+ bool hotpluggable = false;
+
+ // We can get the removable flag, but we have no idea if the device has the ability to notify on media insertion/removal
+ // If there is no such notification possible, then we should not set the removable flag
+ // udev can be such an amazing pain at times
+ // It exports a /capabilities node with no info on what the bits actually mean
+ // This information is very poorly documented as a set of #defines in include/linux/genhd.h
+ // We are specifically interested in GENHD_FL_REMOVABLE and GENHD_FL_MEDIA_CHANGE_NOTIFY
+ // The "removable" flag should also really be renamed to "hotpluggable", as that is far more precise...
+ TQString capabilitynodename = systempath;
+ capabilitynodename.append("/capability");
+ TQFile capabilityfile( capabilitynodename );
+ unsigned int capabilities = 0;
+ if ( capabilityfile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &capabilityfile );
+ TQString capabilitystring;
+ capabilitystring = stream.readLine();
+ capabilities = capabilitystring.toUInt();
+ capabilityfile.close();
+ }
+ if (capabilities & GENHD_FL_REMOVABLE) {
+ // FIXME
+ // For added fun this is not always true; i.e. GENHD_FL_REMOVABLE can be set when the device cannot be hotplugged (floppy drives).
+ hotpluggable = true;
+ }
+ if (capabilities & GENHD_FL_MEDIA_CHANGE_NOTIFY) {
+ removable = true;
+ }
+
+ // See if any other devices are exclusively using this device, such as the Device Mapper
+ TQStringList holdingDeviceNodes;
+ TQString holdersnodename = udev_device_get_syspath(dev);
+ holdersnodename.append("/holders/");
+ TQDir holdersdir(holdersnodename);
+ holdersdir.setFilter(TQDir::All);
+ const TQFileInfoList *dirlist = holdersdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator holdersdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = holdersdirit.current()) != 0 ) {
+ if (dirfi->isSymLink()) {
+ char* collapsedPath = realpath((holdersnodename + dirfi->readLink()).ascii(), NULL);
+ holdingDeviceNodes.append(TQString(collapsedPath));
+ free(collapsedPath);
+ }
+ ++holdersdirit;
+ }
+ }
+
+ // See if any other physical devices underlie this device, for example when the Device Mapper is in use
+ TQStringList slaveDeviceNodes;
+ TQString slavesnodename = udev_device_get_syspath(dev);
+ slavesnodename.append("/slaves/");
+ TQDir slavedir(slavesnodename);
+ slavedir.setFilter(TQDir::All);
+ dirlist = slavedir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator slavedirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = slavedirit.current()) != 0 ) {
+ if (dirfi->isSymLink()) {
+ char* collapsedPath = realpath((slavesnodename + dirfi->readLink()).ascii(), NULL);
+ slaveDeviceNodes.append(TQString(collapsedPath));
+ free(collapsedPath);
+ }
+ ++slavedirit;
+ }
+ }
+
+ // Determine generic disk information
+ TQString devicevendor(udev_device_get_property_value(dev, "ID_VENDOR"));
+ TQString devicemodel(udev_device_get_property_value(dev, "ID_MODEL"));
+ TQString devicebus(udev_device_get_property_value(dev, "ID_BUS"));
+
+ // Get disk specific info
+ TQString disklabel(udev_device_get_property_value(dev, "ID_FS_LABEL"));
+ TQString diskuuid(udev_device_get_property_value(dev, "ID_FS_UUID"));
+ TQString filesystemtype(udev_device_get_property_value(dev, "ID_FS_TYPE"));
+ TQString filesystemusage(udev_device_get_property_value(dev, "ID_FS_USAGE"));
+
+ device->internalSetVendorName(devicevendor);
+ device->internalSetVendorModel(devicemodel);
+ device->internalSetDeviceBus(devicebus);
+
+ TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
+
+ disktype = classifyDiskType(dev, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
+ sdevice->internalSetDiskType(disktype);
+ device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides
+ disktype = sdevice->diskType(); // The type can be overridden by an external rule
+
+ if ((disktype & TDEDiskDeviceType::CDROM)
+ || (disktype & TDEDiskDeviceType::CDRW)
+ || (disktype & TDEDiskDeviceType::DVDROM)
+ || (disktype & TDEDiskDeviceType::DVDRAM)
+ || (disktype & TDEDiskDeviceType::DVDRW)
+ || (disktype & TDEDiskDeviceType::BDROM)
+ || (disktype & TDEDiskDeviceType::BDRW)
+ || (disktype & TDEDiskDeviceType::CDAudio)
+ || (disktype & TDEDiskDeviceType::CDVideo)
+ || (disktype & TDEDiskDeviceType::DVDVideo)
+ || (disktype & TDEDiskDeviceType::BDVideo)
+ ) {
+ // These drives are guaranteed to be optical
+ disktype = disktype | TDEDiskDeviceType::Optical;
+ }
+
+ if (disktype & TDEDiskDeviceType::Floppy) {
+ // Floppy drives don't work well under udev
+ // I have to look for the block device name manually
+ TQString floppyblknodename = systempath;
+ floppyblknodename.append("/block");
+ TQDir floppyblkdir(floppyblknodename);
+ floppyblkdir.setFilter(TQDir::All);
+ const TQFileInfoList *floppyblkdirlist = floppyblkdir.entryInfoList();
+ if (floppyblkdirlist) {
+ TQFileInfoListIterator floppyblkdirit(*floppyblkdirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = floppyblkdirit.current()) != 0 ) {
+ if ((dirfi->fileName() != ".") && (dirfi->fileName() != "..")) {
+ // Does this routine work with more than one floppy drive in the system?
+ devicenode = TQString("/dev/").append(dirfi->fileName());
+ }
+ ++floppyblkdirit;
+ }
+ }
+
+ // Some interesting information can be gleaned from the CMOS type file
+ // 0 : Defaults
+ // 1 : 5 1/4 DD
+ // 2 : 5 1/4 HD
+ // 3 : 3 1/2 DD
+ // 4 : 3 1/2 HD
+ // 5 : 3 1/2 ED
+ // 6 : 3 1/2 ED
+ // 16 : unknown or not installed
+ TQString floppycmsnodename = systempath;
+ floppycmsnodename.append("/cmos");
+ TQFile floppycmsfile( floppycmsnodename );
+ TQString cmosstring;
+ if ( floppycmsfile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &floppycmsfile );
+ cmosstring = stream.readLine();
+ floppycmsfile.close();
+ }
+ // FIXME
+ // Do something with the information in cmosstring
+
+ if (devicenode.isNull()) {
+ // This floppy drive cannot be mounted, so ignore it
+ disktype = disktype & ~TDEDiskDeviceType::Floppy;
+ }
+ }
+
+ if (devicetypestring.upper() == "CD") {
+ if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_STATE")).upper() == "BLANK") {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::Blank;
+ }
+ sdevice->internalSetMediaInserted((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) != ""));
+ }
+
+ if (disktype & TDEDiskDeviceType::Zip) {
+ // A Zip drive does not advertise its status via udev, but it can be guessed from the size parameter
+ TQString zipnodename = systempath;
+ zipnodename.append("/size");
+ TQFile namefile( zipnodename );
+ TQString zipsize;
+ if ( namefile.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &namefile );
+ zipsize = stream.readLine();
+ namefile.close();
+ }
+ if (!zipsize.isNull()) {
+ sdevice->internalSetMediaInserted((zipsize.toInt() != 0));
+ }
+ }
+
+ if (removable) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::Removable;
+ }
+ if (hotpluggable) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::Hotpluggable;
+ }
+
+ if ((filesystemtype.upper() != "CRYPTO_LUKS") && (filesystemtype.upper() != "CRYPTO") && (filesystemtype.upper() != "SWAP") && (!filesystemtype.isNull())) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::ContainsFilesystem;
+ }
+
+ // Set mountable flag if device is likely to be mountable
+ diskstatus = diskstatus | TDEDiskDeviceStatus::Mountable;
+ if ((devicetypestring.upper().isNull()) && (disktype & TDEDiskDeviceType::HDD)) {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
+ if (removable) {
+ if (sdevice->mediaInserted()) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::Inserted;
+ }
+ else {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
+ }
+ // Swap partitions cannot be mounted
+ if (filesystemtype.upper() == "SWAP") {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
+ // If certain disk types do not report the presence of a filesystem, they are likely not mountable
+ if ((disktype & TDEDiskDeviceType::HDD) || (disktype & TDEDiskDeviceType::Optical)) {
+ if (!(diskstatus & TDEDiskDeviceStatus::ContainsFilesystem)) {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
+ }
+
+ if (holdingDeviceNodes.count() > 0) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::UsedByDevice;
+ }
+
+ if (slaveDeviceNodes.count() > 0) {
+ diskstatus = diskstatus | TDEDiskDeviceStatus::UsesDevice;
+ }
+
+ // See if any slaves were crypted
+ for ( TQStringList::Iterator slaveit = slaveDeviceNodes.begin(); slaveit != slaveDeviceNodes.end(); ++slaveit ) {
+ struct udev_device *slavedev;
+ slavedev = udev_device_new_from_syspath(m_udevStruct, (*slaveit).ascii());
+ TQString slavediskfstype(udev_device_get_property_value(slavedev, "ID_FS_TYPE"));
+ if ((slavediskfstype.upper() == "CRYPTO_LUKS") || (slavediskfstype.upper() == "CRYPTO")) {
+ disktype = disktype | TDEDiskDeviceType::UnlockedCrypt;
+ // Set disk type based on parent device
+ disktype = disktype | classifyDiskType(slavedev, TQString(udev_device_get_property_value(dev, "ID_BUS")), TQString(udev_device_get_property_value(dev, "ID_TYPE")), (*slaveit), TQString(udev_device_get_property_value(dev, "ID_VENDOR")), TQString(udev_device_get_property_value(dev, "ID_MODEL")), TQString(udev_device_get_property_value(dev, "ID_FS_TYPE")), TQString(udev_device_get_driver(dev)));
+ }
+ udev_device_unref(slavedev);
+ }
+
+ sdevice->internalSetDiskType(disktype);
+ sdevice->internalSetDiskUUID(diskuuid);
+ sdevice->internalSetDiskStatus(diskstatus);
+ sdevice->internalSetFileSystemName(filesystemtype);
+ sdevice->internalSetFileSystemUsage(filesystemusage);
+ sdevice->internalSetSlaveDevices(slaveDeviceNodes);
+ sdevice->internalSetHoldingDevices(holdingDeviceNodes);
+
+ // Clean up disk label
+ if ((sdevice->isDiskOfType(TDEDiskDeviceType::CDROM))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo))
+ || (sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo))
+ ) {
+ if (disklabel == "" && sdevice->diskLabel().isNull()) {
+ // Read the volume label in via volname, since udev couldn't be bothered to do this on its own
+ FILE *exepipe = popen(((TQString("volname %1").arg(devicenode).ascii())), "r");
+ if (exepipe) {
+ char buffer[8092];
+ disklabel = fgets(buffer, sizeof(buffer), exepipe);
+ pclose(exepipe);
+ }
+ }
+ }
+
+ sdevice->internalSetDiskLabel(disklabel);
+ }
+ }
+
+ if (device->type() == TDEGenericDeviceType::Network) {
+ // Network devices don't have devices nodes per se, but we can at least return the Linux network name...
+ TQString potentialdevicenode = systempath;
+ if (potentialdevicenode.endsWith("/")) potentialdevicenode.truncate(potentialdevicenode.length()-1);
+ potentialdevicenode.remove(0, potentialdevicenode.findRev("/")+1);
+ TQString potentialparentnode = systempath;
+ if (potentialparentnode.endsWith("/")) potentialparentnode.truncate(potentialparentnode.length()-1);
+ potentialparentnode.remove(0, potentialparentnode.findRev("/", potentialparentnode.findRev("/")-1)+1);
+ if (potentialparentnode.startsWith("net/")) {
+ devicenode = potentialdevicenode;
+ }
+
+ if (devicenode.isNull()) {
+ // Platform device, not a physical device
+ // HACK
+ // This only works because devices of type Platform only access the TDEGenericDevice class!
+ device->m_deviceType = TDEGenericDeviceType::Platform;
+ }
+ else {
+ // Gather network device information
+ TDENetworkDevice* ndevice = dynamic_cast<TDENetworkDevice*>(device);
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "address") {
+ ndevice->internalSetMacAddress(line);
+ }
+ if (nodename == "carrier") {
+ ndevice->internalSetCarrierPresent(line.toInt());
+ }
+ if (nodename == "dormant") {
+ ndevice->internalSetDormant(line.toInt());
+ }
+ if (nodename == "operstate") {
+ TQString friendlyState = line.lower();
+ friendlyState[0] = friendlyState[0].upper();
+ ndevice->internalSetState(friendlyState);
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+ // Gather connection information such as IP addresses
+ if (ndevice->state().upper() == "UP") {
+ struct ifaddrs *ifaddr, *ifa;
+ int family, s;
+ char host[NI_MAXHOST];
+
+ if (getifaddrs(&ifaddr) != -1) {
+ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL) {
+ continue;
+ }
+
+ family = ifa->ifa_addr->sa_family;
+
+ if (TQString(ifa->ifa_name) == devicenode) {
+ if ((family == AF_INET) || (family == AF_INET6)) {
+ s = getnameinfo(ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+ if (s == 0) {
+ TQString address(host);
+ if (family == AF_INET) {
+ ndevice->internalSetIpV4Address(address);
+ }
+ if (family == AF_INET6) {
+ address.truncate(address.findRev("%"));
+ ndevice->internalSetIpV6Address(address);
+ }
+ }
+ s = getnameinfo(ifa->ifa_netmask, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+ if (s == 0) {
+ TQString address(host);
+ if (family == AF_INET) {
+ ndevice->internalSetIpV4Netmask(address);
+ }
+ if (family == AF_INET6) {
+ address.truncate(address.findRev("%"));
+ ndevice->internalSetIpV6Netmask(address);
+ }
+ }
+ s = getnameinfo(ifa->ifa_ifu.ifu_broadaddr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+ if (s == 0) {
+ TQString address(host);
+ if (family == AF_INET) {
+ ndevice->internalSetIpV4Broadcast(address);
+ }
+ if (family == AF_INET6) {
+ address.truncate(address.findRev("%"));
+ ndevice->internalSetIpV6Broadcast(address);
+ }
+ }
+ s = getnameinfo(ifa->ifa_ifu.ifu_dstaddr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+ if (s == 0) {
+ TQString address(host);
+ if (family == AF_INET) {
+ ndevice->internalSetIpV4Destination(address);
+ }
+ if (family == AF_INET6) {
+ address.truncate(address.findRev("%"));
+ ndevice->internalSetIpV6Destination(address);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ // Gather statistics
+ TQString valuesnodename = systempath + "/statistics/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "rx_bytes") {
+ ndevice->internalSetRxBytes(line.toDouble());
+ }
+ if (nodename == "tx_bytes") {
+ ndevice->internalSetTxBytes(line.toDouble());
+ }
+ if (nodename == "rx_packets") {
+ ndevice->internalSetRxPackets(line.toDouble());
+ }
+ if (nodename == "tx_packets") {
+ ndevice->internalSetTxPackets(line.toDouble());
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+ }
+ }
+ }
+
+ if ((device->type() == TDEGenericDeviceType::OtherSensor) || (device->type() == TDEGenericDeviceType::ThermalSensor)) {
+ // Populate all sensor values
+ TDESensorClusterMap sensors;
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ if (nodename.contains("_")) {
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ TQStringList sensornodelist = TQStringList::split("_", nodename);
+ TQString sensornodename = *(sensornodelist.at(0));
+ TQString sensornodetype = *(sensornodelist.at(1));
+ double lineValue = line.toDouble();
+ if (!sensornodename.contains("fan")) {
+ lineValue = lineValue / 1000.0;
+ }
+ if (sensornodetype == "label") {
+ sensors[sensornodename].label = line;
+ }
+ if (sensornodetype == "input") {
+ sensors[sensornodename].current = lineValue;
+ }
+ if (sensornodetype == "min") {
+ sensors[sensornodename].minimum = lineValue;
+ }
+ if (sensornodetype == "max") {
+ sensors[sensornodename].maximum = lineValue;
+ }
+ if (sensornodetype == "warn") {
+ sensors[sensornodename].warning = lineValue;
+ }
+ if (sensornodetype == "crit") {
+ sensors[sensornodename].critical = lineValue;
+ }
+ file.close();
+ }
+ }
+ ++valuesdirit;
+ }
+ }
+
+ TDESensorDevice* sdevice = dynamic_cast<TDESensorDevice*>(device);
+ sdevice->internalSetValues(sensors);
+ }
+
+ if (device->type() == TDEGenericDeviceType::Battery) {
+ // Populate all battery values
+ TDEBatteryDevice* bdevice = dynamic_cast<TDEBatteryDevice*>(device);
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "alarm") {
+ bdevice->internalSetAlarmEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "energy_full") {
+ bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "energy_full_design") {
+ bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "energy_now") {
+ bdevice->internalSetEnergy(line.toDouble()/1000000.0);
+ }
+ if (nodename == "manufacturer") {
+ bdevice->internalSetVendorName(line.stripWhiteSpace());
+ }
+ if (nodename == "model_name") {
+ bdevice->internalSetVendorModel(line.stripWhiteSpace());
+ }
+ if (nodename == "power_now") {
+ bdevice->internalSetDischargeRate(line.toDouble()/1000000.0);
+ }
+ if (nodename == "present") {
+ bdevice->internalSetInstalled(line.toInt());
+ }
+ if (nodename == "serial_number") {
+ bdevice->internalSetSerialNumber(line.stripWhiteSpace());
+ }
+ if (nodename == "status") {
+ bdevice->internalSetStatus(line);
+ }
+ if (nodename == "technology") {
+ bdevice->internalSetTechnology(line);
+ }
+ if (nodename == "voltage_min_design") {
+ bdevice->internalSetMinimumVoltage(line.toDouble()/1000000.0);
+ }
+ if (nodename == "voltage_now") {
+ bdevice->internalSetVoltage(line.toDouble()/1000000.0);
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+
+ // Calculate time remaining
+ // Discharge rate is in watt-hours
+ // Energy is in watt-hours
+ // Therefore, energy/rate = time in hours
+ // Convert to seconds...
+ bdevice->internalSetTimeRemaining((bdevice->energy()/bdevice->dischargeRate())*60*60);
+ }
+
+ if (device->type() == TDEGenericDeviceType::PowerSupply) {
+ // Populate all power supply values
+ TDEMainsPowerDevice* pdevice = dynamic_cast<TDEMainsPowerDevice*>(device);
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "manufacturer") {
+ pdevice->internalSetVendorName(line.stripWhiteSpace());
+ }
+ if (nodename == "model_name") {
+ pdevice->internalSetVendorModel(line.stripWhiteSpace());
+ }
+ if (nodename == "online") {
+ pdevice->internalSetOnline(line.toInt());
+ }
+ if (nodename == "serial_number") {
+ pdevice->internalSetSerialNumber(line.stripWhiteSpace());
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+ }
+
+ if (device->type() == TDEGenericDeviceType::Backlight) {
+ // Populate all backlight values
+ TDEBacklightDevice* bdevice = dynamic_cast<TDEBacklightDevice*>(device);
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "bl_power") {
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel pl = TDEDisplayPowerLevel::On;
+ int rpl = line.toInt();
+ if (rpl == FB_BLANK_UNBLANK) {
+ pl = TDEDisplayPowerLevel::On;
+ }
+ else if (rpl == FB_BLANK_POWERDOWN) {
+ pl = TDEDisplayPowerLevel::Off;
+ }
+ bdevice->internalSetPowerLevel(pl);
+ }
+ if (nodename == "max_brightness") {
+ bdevice->internalSetMaximumRawBrightness(line.toInt());
+ }
+ if (nodename == "actual_brightness") {
+ bdevice->internalSetCurrentRawBrightness(line.toInt());
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+ }
+
+ if (device->type() == TDEGenericDeviceType::Monitor) {
+ TDEMonitorDevice* mdevice = dynamic_cast<TDEMonitorDevice*>(device);
+ TQString valuesnodename = systempath + "/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "status") {
+ mdevice->internalSetConnected(line.lower() == "connected");
+ }
+ if (nodename == "enabled") {
+ mdevice->internalSetEnabled(line.lower() == "enabled");
+ }
+ if (nodename == "modes") {
+ TQStringList resinfo;
+ TQStringList resolutionsStringList = line.upper();
+ while ((!stream.atEnd()) && (!line.isNull())) {
+ line = stream.readLine();
+ if (!line.isNull()) {
+ resolutionsStringList.append(line.upper());
+ }
+ }
+ TDEResolutionList resolutions;
+ resolutions.clear();
+ for (TQStringList::Iterator it = resolutionsStringList.begin(); it != resolutionsStringList.end(); ++it) {
+ resinfo = TQStringList::split('X', *it, true);
+ resolutions.append(TDEResolutionPair((*(resinfo.at(0))).toUInt(), (*(resinfo.at(1))).toUInt()));
+ }
+ mdevice->internalSetResolutions(resolutions);
+ }
+ if (nodename == "dpms") {
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel pl = TDEDisplayPowerLevel::On;
+ if (line == "On") {
+ pl = TDEDisplayPowerLevel::On;
+ }
+ else if (line == "Standby") {
+ pl = TDEDisplayPowerLevel::Standby;
+ }
+ else if (line == "Suspend") {
+ pl = TDEDisplayPowerLevel::Suspend;
+ }
+ else if (line == "Off") {
+ pl = TDEDisplayPowerLevel::Off;
+ }
+ mdevice->internalSetPowerLevel(pl);
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+
+ TQString genericPortName = mdevice->systemPath();
+ genericPortName.remove(0, genericPortName.find("-")+1);
+ genericPortName.truncate(genericPortName.findRev("-"));
+ mdevice->internalSetPortType(genericPortName);
+
+ if (mdevice->connected()) {
+ TQPair<TQString,TQString> monitor_info = getEDIDMonitorName(device->systemPath());
+ if (!monitor_info.first.isNull()) {
+ mdevice->internalSetVendorName(monitor_info.first);
+ mdevice->internalSetVendorModel(monitor_info.second);
+ mdevice->m_friendlyName = monitor_info.first + " " + monitor_info.second;
+ }
+ else {
+ mdevice->m_friendlyName = i18n("Generic %1 Device").arg(genericPortName);
+ }
+ mdevice->internalSetEdid(getEDID(mdevice->systemPath()));
+ }
+ else {
+ mdevice->m_friendlyName = i18n("Disconnected %1 Port").arg(genericPortName);
+ mdevice->internalSetEdid(TQByteArray());
+ mdevice->internalSetResolutions(TDEResolutionList());
+ }
+
+ // FIXME
+ // Much of the code in libtderandr should be integrated into/interfaced with this library
+ }
+
+ if (device->type() == TDEGenericDeviceType::RootSystem) {
+ // Try to obtain as much generic information about this system as possible
+ TDERootSystemDevice* rdevice = dynamic_cast<TDERootSystemDevice*>(device);
+
+ // Guess at my form factor
+ // dmidecode would tell me this, but is somewhat unreliable
+ TDESystemFormFactor::TDESystemFormFactor formfactor = TDESystemFormFactor::Desktop;
+ if (listByDeviceClass(TDEGenericDeviceType::Backlight).count() > 0) { // Is this really a good way to determine if a machine is a laptop?
+ formfactor = TDESystemFormFactor::Laptop;
+ }
+ rdevice->internalSetFormFactor(formfactor);
+
+ TQString valuesnodename = "/sys/power/";
+ TQDir valuesdir(valuesnodename);
+ valuesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = valuesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator valuesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = valuesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ TQFile file( valuesnodename + nodename );
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream( &file );
+ TQString line;
+ line = stream.readLine();
+ if (nodename == "state") {
+ TDESystemPowerStateList powerstates;
+ // Always assume that these two fully on/fully off states are available
+ powerstates.append(TDESystemPowerState::Active);
+ powerstates.append(TDESystemPowerState::PowerOff);
+ if (line.contains("standby")) {
+ powerstates.append(TDESystemPowerState::Standby);
+ }
+ if (line.contains("mem")) {
+ powerstates.append(TDESystemPowerState::Suspend);
+ }
+ if (line.contains("disk")) {
+ powerstates.append(TDESystemPowerState::Hibernate);
+ }
+ rdevice->internalSetPowerStates(powerstates);
+ }
+ if (nodename == "disk") {
+ // Get list of available hibernation methods
+ TDESystemHibernationMethodList hibernationmethods;
+ if (line.contains("platform")) {
+ hibernationmethods.append(TDESystemHibernationMethod::Platform);
+ }
+ if (line.contains("shutdown")) {
+ hibernationmethods.append(TDESystemHibernationMethod::Shutdown);
+ }
+ if (line.contains("reboot")) {
+ hibernationmethods.append(TDESystemHibernationMethod::Reboot);
+ }
+ if (line.contains("testproc")) {
+ hibernationmethods.append(TDESystemHibernationMethod::TestProc);
+ }
+ if (line.contains("test")) {
+ hibernationmethods.append(TDESystemHibernationMethod::Test);
+ }
+ rdevice->internalSetHibernationMethods(hibernationmethods);
+
+ // Get current hibernation method
+ line.truncate(line.findRev("]"));
+ line.remove(0, line.findRev("[")+1);
+ TDESystemHibernationMethod::TDESystemHibernationMethod hibernationmethod = TDESystemHibernationMethod::Unsupported;
+ if (line.contains("platform")) {
+ hibernationmethod = TDESystemHibernationMethod::Platform;
+ }
+ if (line.contains("shutdown")) {
+ hibernationmethod = TDESystemHibernationMethod::Shutdown;
+ }
+ if (line.contains("reboot")) {
+ hibernationmethod = TDESystemHibernationMethod::Reboot;
+ }
+ if (line.contains("testproc")) {
+ hibernationmethod = TDESystemHibernationMethod::TestProc;
+ }
+ if (line.contains("test")) {
+ hibernationmethod = TDESystemHibernationMethod::Test;
+ }
+ rdevice->internalSetHibernationMethod(hibernationmethod);
+ }
+ if (nodename == "image_size") {
+ rdevice->internalSetDiskSpaceNeededForHibernation(line.toULong());
+ }
+ file.close();
+ }
+ ++valuesdirit;
+ }
+ }
+ }
+
+ // NOTE
+ // Keep these two handlers (Event and Input) in sync!
+
+ if (device->type() == TDEGenericDeviceType::Event) {
+ // Try to obtain as much type information about this event device as possible
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(device);
+ if (edevice->systemPath().contains("PNP0C0D")) {
+ edevice->internalSetEventType(TDEEventDeviceType::ACPILidSwitch);
+ }
+ else if (edevice->systemPath().contains("PNP0C0E") || edevice->systemPath().contains("/LNXSLPBN")) {
+ edevice->internalSetEventType(TDEEventDeviceType::ACPISleepButton);
+ }
+ else if (edevice->systemPath().contains("PNP0C0C") || edevice->systemPath().contains("/LNXPWRBN")) {
+ edevice->internalSetEventType(TDEEventDeviceType::ACPIPowerButton);
+ }
+ else {
+ edevice->internalSetEventType(TDEEventDeviceType::Unknown);
+ }
+ }
+
+ if (device->type() == TDEGenericDeviceType::Input) {
+ // Try to obtain as much type information about this input device as possible
+ TDEInputDevice* idevice = dynamic_cast<TDEInputDevice*>(device);
+ if (idevice->systemPath().contains("PNP0C0D")) {
+ idevice->internalSetInputType(TDEInputDeviceType::ACPILidSwitch);
+ }
+ else if (idevice->systemPath().contains("PNP0C0E") || idevice->systemPath().contains("/LNXSLPBN")) {
+ idevice->internalSetInputType(TDEInputDeviceType::ACPISleepButton);
+ }
+ else if (idevice->systemPath().contains("PNP0C0C") || idevice->systemPath().contains("/LNXPWRBN")) {
+ idevice->internalSetInputType(TDEInputDeviceType::ACPIPowerButton);
+ }
+ else {
+ idevice->internalSetInputType(TDEInputDeviceType::Unknown);
+ }
+ }
+
+ if (device->type() == TDEGenericDeviceType::Event) {
+ // Try to obtain as much specific information about this event device as possible
+ TDEEventDevice* edevice = dynamic_cast<TDEEventDevice*>(device);
+ int r;
+ char switches[SW_CNT];
+
+ // Figure out which switch types are supported, if any
+ TDESwitchType::TDESwitchType supportedSwitches = TDESwitchType::Null;
+ if (edevice->m_fd < 0) {
+ edevice->m_fd = open(edevice->deviceNode().ascii(), O_RDONLY);
+ }
+ r = ioctl(edevice->m_fd, EVIOCGBIT(EV_SW, sizeof(switches)), switches);
+ if (r > 0) {
+ if (BIT_IS_SET(switches, SW_LID)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::Lid;
+ }
+ if (BIT_IS_SET(switches, SW_TABLET_MODE)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::TabletMode;
+ }
+ if (BIT_IS_SET(switches, SW_RFKILL_ALL)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::RFKill;
+ }
+ if (BIT_IS_SET(switches, SW_RADIO)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::Radio;
+ }
+ if (BIT_IS_SET(switches, SW_MICROPHONE_INSERT)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::MicrophoneInsert;
+ }
+ if (BIT_IS_SET(switches, SW_DOCK)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::Dock;
+ }
+ if (BIT_IS_SET(switches, SW_LINEOUT_INSERT)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::LineOutInsert;
+ }
+ if (BIT_IS_SET(switches, SW_JACK_PHYSICAL_INSERT)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::JackPhysicalInsert;
+ }
+ if (BIT_IS_SET(switches, SW_VIDEOOUT_INSERT)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::VideoOutInsert;
+ }
+#if 0 // Some old kernels don't provide these defines... [FIXME]
+ if (BIT_IS_SET(switches, SW_CAMERA_LENS_COVER)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::CameraLensCover;
+ }
+ if (BIT_IS_SET(switches, SW_KEYPAD_SLIDE)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::KeypadSlide;
+ }
+ if (BIT_IS_SET(switches, SW_FRONT_PROXIMITY)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::FrontProximity;
+ }
+ if (BIT_IS_SET(switches, SW_ROTATE_LOCK)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::RotateLock;
+ }
+ if (BIT_IS_SET(switches, SW_LINEIN_INSERT)) {
+ supportedSwitches = supportedSwitches | TDESwitchType::LineInInsert;
+ }
+#endif
+ }
+ edevice->internalSetProvidedSwitches(supportedSwitches);
+
+ // Figure out which switch types are active, if any
+ TDESwitchType::TDESwitchType activeSwitches = TDESwitchType::Null;
+ r = ioctl(edevice->m_fd, EVIOCGSW(sizeof(switches)), switches);
+ if (r > 0) {
+ if (BIT_IS_SET(switches, SW_LID)) {
+ activeSwitches = activeSwitches | TDESwitchType::Lid;
+ }
+ if (BIT_IS_SET(switches, SW_TABLET_MODE)) {
+ activeSwitches = activeSwitches | TDESwitchType::TabletMode;
+ }
+ if (BIT_IS_SET(switches, SW_RFKILL_ALL)) {
+ activeSwitches = activeSwitches | TDESwitchType::RFKill;
+ }
+ if (BIT_IS_SET(switches, SW_RADIO)) {
+ activeSwitches = activeSwitches | TDESwitchType::Radio;
+ }
+ if (BIT_IS_SET(switches, SW_MICROPHONE_INSERT)) {
+ activeSwitches = activeSwitches | TDESwitchType::MicrophoneInsert;
+ }
+ if (BIT_IS_SET(switches, SW_DOCK)) {
+ activeSwitches = activeSwitches | TDESwitchType::Dock;
+ }
+ if (BIT_IS_SET(switches, SW_LINEOUT_INSERT)) {
+ activeSwitches = activeSwitches | TDESwitchType::LineOutInsert;
+ }
+ if (BIT_IS_SET(switches, SW_JACK_PHYSICAL_INSERT)) {
+ activeSwitches = activeSwitches | TDESwitchType::JackPhysicalInsert;
+ }
+ if (BIT_IS_SET(switches, SW_VIDEOOUT_INSERT)) {
+ activeSwitches = activeSwitches | TDESwitchType::VideoOutInsert;
+ }
+#if 0 // Some old kernels don't provide these defines... [FIXME]
+ if (BIT_IS_SET(switches, SW_CAMERA_LENS_COVER)) {
+ activeSwitches = activeSwitches | TDESwitchType::CameraLensCover;
+ }
+ if (BIT_IS_SET(switches, SW_KEYPAD_SLIDE)) {
+ activeSwitches = activeSwitches | TDESwitchType::KeypadSlide;
+ }
+ if (BIT_IS_SET(switches, SW_FRONT_PROXIMITY)) {
+ activeSwitches = activeSwitches | TDESwitchType::FrontProximity;
+ }
+ if (BIT_IS_SET(switches, SW_ROTATE_LOCK)) {
+ activeSwitches = activeSwitches | TDESwitchType::RotateLock;
+ }
+ if (BIT_IS_SET(switches, SW_LINEIN_INSERT)) {
+ activeSwitches = activeSwitches | TDESwitchType::LineInInsert;
+ }
+#endif
+ }
+ edevice->internalSetActiveSwitches(activeSwitches);
+
+ edevice->internalStartFdMonitoring(this);
+ }
+
+ // Root devices are still special
+ if ((device->type() == TDEGenericDeviceType::Root) || (device->type() == TDEGenericDeviceType::RootSystem)) {
+ systempath = device->systemPath();
+ }
+
+ // Set basic device information again, as some information may have changed
+ device->internalSetName(devicename);
+ device->internalSetDeviceNode(devicenode);
+ device->internalSetSystemPath(systempath);
+ device->internalSetVendorID(devicevendorid);
+ device->internalSetModelID(devicemodelid);
+ device->internalSetVendorEncoded(devicevendoridenc);
+ device->internalSetModelEncoded(devicemodelidenc);
+ device->internalSetSubVendorID(devicesubvendorid);
+ device->internalSetSubModelID(devicesubmodelid);
+ device->internalSetDeviceDriver(devicedriver);
+ device->internalSetSubsystem(devicesubsystem);
+ device->internalSetPCIClass(devicepciclass);
+
+ // Internal use only!
+ device->m_udevtype = devicetype;
+ device->m_udevdevicetypestring = devicetypestring;
+ device->udevdevicetypestring_alt = devicetypestring_alt;
+
+ if (temp_udev_device) {
+ udev_device_unref(dev);
+ }
+}
+
+void TDEHardwareDevices::updateBlacklists(TDEGenericDevice* hwdevice, udev_device* dev) {
+ // HACK
+ // I am lucky enough to have a Flash drive that spams udev continually with device change events
+ // I imagine I am not the only one, so here is a section in which specific devices can be blacklisted!
+
+ // For "U3 System" fake CD
+ if ((hwdevice->vendorID() == "08ec") && (hwdevice->modelID() == "0020") && (TQString(udev_device_get_property_value(dev, "ID_TYPE")) == "cd")) {
+ hwdevice->internalSetBlacklistedForUpdate(true);
+ }
+}
+
+bool TDEHardwareDevices::queryHardwareInformation() {
+ if (!m_udevStruct) {
+ return false;
+ }
+
+ // Prepare the device list for repopulation
+ m_deviceList.clear();
+ addCoreSystemDevices();
+
+ struct udev_enumerate *enumerate;
+ struct udev_list_entry *devices, *dev_list_entry;
+ struct udev_device *dev;
+
+ // Create a list of all devices
+ enumerate = udev_enumerate_new(m_udevStruct);
+ udev_enumerate_add_match_subsystem(enumerate, NULL);
+ udev_enumerate_scan_devices(enumerate);
+ devices = udev_enumerate_get_list_entry(enumerate);
+ // Get detailed information on each detected device
+ udev_list_entry_foreach(dev_list_entry, devices) {
+ const char *path;
+
+ // Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it
+ path = udev_list_entry_get_name(dev_list_entry);
+ dev = udev_device_new_from_syspath(m_udevStruct, path);
+
+ TDEGenericDevice* device = classifyUnknownDevice(dev);
+
+ // Make sure this device is not a duplicate
+ TDEGenericDevice *hwdevice;
+ for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
+ if (hwdevice->systemPath() == device->systemPath()) {
+ delete device;
+ device = 0;
+ break;
+ }
+ }
+
+ if (device) {
+ m_deviceList.append(device);
+ }
+
+ udev_device_unref(dev);
+ }
+
+ // Free the enumerator object
+ udev_enumerate_unref(enumerate);
+
+ // Update parent/child tables for all devices
+ updateParentDeviceInformation();
+
+ emit hardwareEvent(TDEHardwareEvent::HardwareListModified, TQString());
+
+ return true;
+}
+
+void TDEHardwareDevices::updateParentDeviceInformation(TDEGenericDevice* hwdevice) {
+ // Scan for the first path up the sysfs tree that is available in the main hardware table
+ bool done = false;
+ TQString current_path = hwdevice->systemPath();
+ TDEGenericDevice* parentdevice = 0;
+
+ if (current_path.endsWith("/")) {
+ current_path.truncate(current_path.findRev("/"));
+ }
+ while (done == false) {
+ current_path.truncate(current_path.findRev("/"));
+ if (current_path.startsWith("/sys/devices")) {
+ if (current_path.endsWith("/")) {
+ current_path.truncate(current_path.findRev("/"));
+ }
+ parentdevice = findBySystemPath(current_path);
+ if (parentdevice) {
+ done = true;
+ }
+ }
+ else {
+ // Abort!
+ done = true;
+ }
+ }
+
+ hwdevice->internalSetParentDevice(parentdevice);
+}
+
+void TDEHardwareDevices::updateParentDeviceInformation() {
+ TDEGenericDevice *hwdevice;
+
+ // We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time
+ TDEGenericHardwareList devList = listAllPhysicalDevices();
+ for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
+ updateParentDeviceInformation(hwdevice);
+ }
+}
+
+void TDEHardwareDevices::addCoreSystemDevices() {
+ TDEGenericDevice *hwdevice;
+
+ // Add the Main Root System Device, which provides all other devices
+ hwdevice = new TDERootSystemDevice(TDEGenericDeviceType::RootSystem);
+ hwdevice->internalSetSystemPath("/sys/devices");
+ m_deviceList.append(hwdevice);
+ rescanDeviceInformation(hwdevice);
+
+ // Add core top-level devices in /sys/devices to the hardware listing
+ TQStringList holdingDeviceNodes;
+ TQString devicesnodename = "/sys/devices";
+ TQDir devicesdir(devicesnodename);
+ devicesdir.setFilter(TQDir::All);
+ TQString nodename;
+ const TQFileInfoList *dirlist = devicesdir.entryInfoList();
+ if (dirlist) {
+ TQFileInfoListIterator devicesdirit(*dirlist);
+ TQFileInfo *dirfi;
+ while ( (dirfi = devicesdirit.current()) != 0 ) {
+ nodename = dirfi->fileName();
+ if (nodename != "." && nodename != "..") {
+ hwdevice = new TDEGenericDevice(TDEGenericDeviceType::Root);
+ hwdevice->internalSetSystemPath(dirfi->absFilePath());
+ m_deviceList.append(hwdevice);
+ }
+ ++devicesdirit;
+ }
+ }
+
+ // Handle CPUs, which are currently handled terribly by udev
+ // Parse /proc/cpuinfo to extract some information about the CPUs
+ hwdevice = 0;
+ TQDir d("/sys/devices/system/cpu/");
+ d.setFilter( TQDir::Dirs );
+ const TQFileInfoList *list = d.entryInfoList();
+ TQFileInfoListIterator it( *list );
+ TQFileInfo *fi;
+ while ((fi = it.current()) != 0) {
+ TQString directoryName = fi->fileName();
+ if (directoryName.startsWith("cpu")) {
+ directoryName = directoryName.remove(0,3);
+ bool isInt;
+ int processorNumber = directoryName.toUInt(&isInt, 10);
+ if (isInt) {
+ hwdevice = new TDECPUDevice(TDEGenericDeviceType::CPU);
+ hwdevice->internalSetSystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber));
+ m_deviceList.append(hwdevice);
+ }
+ }
+ ++it;
+ }
+
+ // Populate CPU information
+ processModifiedCPUs();
+}
+
+TQString TDEHardwareDevices::findPCIDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid) {
+ TQString vendorName = TQString::null;
+ TQString modelName = TQString::null;
+ TQString friendlyName = TQString::null;
+
+ if (!pci_id_map) {
+ pci_id_map = new TDEDeviceIDMap;
+
+ TQString database_filename = "/usr/share/pci.ids";
+ if (!TQFile::exists(database_filename)) {
+ database_filename = "/usr/share/misc/pci.ids";
+ }
+ if (!TQFile::exists(database_filename)) {
+ printf("[tdehardwaredevices] Unable to locate PCI information database pci.ids\n"); fflush(stdout);
+ return i18n("Unknown PCI Device");
+ }
+
+ TQFile database(database_filename);
+ if (database.open(IO_ReadOnly)) {
+ TQTextStream stream(&database);
+ TQString line;
+ TQString vendorID;
+ TQString modelID;
+ TQString subvendorID;
+ TQString submodelID;
+ TQString deviceMapKey;
+ TQStringList devinfo;
+ while (!stream.atEnd()) {
+ line = stream.readLine();
+ if ((!line.upper().startsWith("\t")) && (!line.upper().startsWith("#"))) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ vendorID = *(devinfo.at(0));
+ vendorName = line;
+ vendorName.remove(0, vendorName.find(" "));
+ vendorName = vendorName.stripWhiteSpace();
+ modelName = TQString::null;
+ deviceMapKey = vendorID.lower() + ":::";
+ }
+ else {
+ if ((line.upper().startsWith("\t")) && (!line.upper().startsWith("\t\t"))) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ modelID = *(devinfo.at(0));
+ modelName = line;
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ deviceMapKey = vendorID.lower() + ":" + modelID.lower() + "::";
+ }
+ else {
+ if (line.upper().startsWith("\t\t")) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ subvendorID = *(devinfo.at(0));
+ submodelID = *(devinfo.at(1));
+ modelName = line;
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ deviceMapKey = vendorID.lower() + ":" + modelID.lower() + ":" + subvendorID.lower() + ":" + submodelID.lower();
+ }
+ }
+ }
+ if (modelName.isNull()) {
+ pci_id_map->insert(deviceMapKey, "***UNKNOWN DEVICE*** " + vendorName, true);
+ }
+ else {
+ pci_id_map->insert(deviceMapKey, vendorName + " " + modelName, true);
+ }
+ }
+ database.close();
+ }
+ else {
+ printf("[tdehardwaredevices] Unable to open PCI information database %s\n", database_filename.ascii()); fflush(stdout);
+ }
+ }
+
+ if (pci_id_map) {
+ TQString deviceName;
+ TQString deviceMapKey = vendorid.lower() + ":" + modelid.lower() + ":" + subvendorid.lower() + ":" + submodelid.lower();
+
+ deviceName = (*pci_id_map)[deviceMapKey];
+ if (deviceName.isNull() || deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceMapKey = vendorid.lower() + ":" + modelid.lower() + ":" + subvendorid.lower() + ":";
+ deviceName = (*pci_id_map)[deviceMapKey];
+ if (deviceName.isNull() || deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceMapKey = vendorid.lower() + ":" + modelid.lower() + "::";
+ deviceName = (*pci_id_map)[deviceMapKey];
+ }
+ }
+
+ if (deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceName.replace("***UNKNOWN DEVICE*** ", "");
+ deviceName.prepend(i18n("Unknown PCI Device") + " ");
+ if (subvendorid.isNull()) {
+ deviceName.append(TQString(" [%1:%2]").arg(vendorid.lower()).arg(modelid.lower()));
+ }
+ else {
+ deviceName.append(TQString(" [%1:%2] [%3:%4]").arg(vendorid.lower()).arg(modelid.lower()).arg(subvendorid.lower()).arg(submodelid.lower()));
+ }
+ }
+
+ return deviceName;
+ }
+ else {
+ return i18n("Unknown PCI Device");
+ }
+}
+
+TQString TDEHardwareDevices::findUSBDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid) {
+ TQString vendorName = TQString::null;
+ TQString modelName = TQString::null;
+ TQString friendlyName = TQString::null;
+
+ if (!usb_id_map) {
+ usb_id_map = new TDEDeviceIDMap;
+
+ TQString database_filename = "/usr/share/usb.ids";
+ if (!TQFile::exists(database_filename)) {
+ database_filename = "/usr/share/misc/usb.ids";
+ }
+ if (!TQFile::exists(database_filename)) {
+ printf("[tdehardwaredevices] Unable to locate USB information database usb.ids\n"); fflush(stdout);
+ return i18n("Unknown USB Device");
+ }
+
+ TQFile database(database_filename);
+ if (database.open(IO_ReadOnly)) {
+ TQTextStream stream(&database);
+ TQString line;
+ TQString vendorID;
+ TQString modelID;
+ TQString subvendorID;
+ TQString submodelID;
+ TQString deviceMapKey;
+ TQStringList devinfo;
+ while (!stream.atEnd()) {
+ line = stream.readLine();
+ if ((!line.upper().startsWith("\t")) && (!line.upper().startsWith("#"))) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ vendorID = *(devinfo.at(0));
+ vendorName = line;
+ vendorName.remove(0, vendorName.find(" "));
+ vendorName = vendorName.stripWhiteSpace();
+ modelName = TQString::null;
+ deviceMapKey = vendorID.lower() + ":::";
+ }
+ else {
+ if ((line.upper().startsWith("\t")) && (!line.upper().startsWith("\t\t"))) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ modelID = *(devinfo.at(0));
+ modelName = line;
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ deviceMapKey = vendorID.lower() + ":" + modelID.lower() + "::";
+ }
+ else {
+ if (line.upper().startsWith("\t\t")) {
+ line.replace("\t", "");
+ devinfo = TQStringList::split(' ', line, false);
+ subvendorID = *(devinfo.at(0));
+ submodelID = *(devinfo.at(1));
+ modelName = line;
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ modelName.remove(0, modelName.find(" "));
+ modelName = modelName.stripWhiteSpace();
+ deviceMapKey = vendorID.lower() + ":" + modelID.lower() + ":" + subvendorID.lower() + ":" + submodelID.lower();
+ }
+ }
+ }
+ if (modelName.isNull()) {
+ usb_id_map->insert(deviceMapKey, "***UNKNOWN DEVICE*** " + vendorName, true);
+ }
+ else {
+ usb_id_map->insert(deviceMapKey, vendorName + " " + modelName, true);
+ }
+ }
+ database.close();
+ }
+ else {
+ printf("[tdehardwaredevices] Unable to open USB information database %s\n", database_filename.ascii()); fflush(stdout);
+ }
+ }
+
+ if (usb_id_map) {
+ TQString deviceName;
+ TQString deviceMapKey = vendorid.lower() + ":" + modelid.lower() + ":" + subvendorid.lower() + ":" + submodelid.lower();
+
+ deviceName = (*usb_id_map)[deviceMapKey];
+ if (deviceName.isNull() || deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceMapKey = vendorid.lower() + ":" + modelid.lower() + ":" + subvendorid.lower() + ":";
+ deviceName = (*usb_id_map)[deviceMapKey];
+ if (deviceName.isNull() || deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceMapKey = vendorid.lower() + ":" + modelid.lower() + "::";
+ deviceName = (*usb_id_map)[deviceMapKey];
+ }
+ }
+
+ if (deviceName.startsWith("***UNKNOWN DEVICE*** ")) {
+ deviceName.replace("***UNKNOWN DEVICE*** ", "");
+ deviceName.prepend(i18n("Unknown USB Device") + " ");
+ if (subvendorid.isNull()) {
+ deviceName.append(TQString(" [%1:%2]").arg(vendorid.lower()).arg(modelid.lower()));
+ }
+ else {
+ deviceName.append(TQString(" [%1:%2] [%3:%4]").arg(vendorid.lower()).arg(modelid.lower()).arg(subvendorid.lower()).arg(submodelid.lower()));
+ }
+ }
+
+ return deviceName;
+ }
+ else {
+ return i18n("Unknown USB Device");
+ }
+}
+
+TQString TDEHardwareDevices::findPNPDeviceName(TQString pnpid) {
+ TQString friendlyName = TQString::null;
+
+ if (!pnp_id_map) {
+ pnp_id_map = new TDEDeviceIDMap;
+
+ TQStringList hardware_info_directories(TDEGlobal::dirs()->resourceDirs("data"));
+ TQString hardware_info_directory_suffix("tdehwlib/pnpdev/");
+ TQString hardware_info_directory;
+ TQString database_filename;
+
+ for ( TQStringList::Iterator it = hardware_info_directories.begin(); it != hardware_info_directories.end(); ++it ) {
+ hardware_info_directory = (*it);
+ hardware_info_directory += hardware_info_directory_suffix;
+
+ if (TDEGlobal::dirs()->exists(hardware_info_directory)) {
+ database_filename = hardware_info_directory + "pnp.ids";
+ if (TQFile::exists(database_filename)) {
+ break;
+ }
+ }
+ }
+
+ if (!TQFile::exists(database_filename)) {
+ printf("[tdehardwaredevices] Unable to locate PNP information database pnp.ids\n"); fflush(stdout);
+ return i18n("Unknown PNP Device");
+ }
+
+ TQFile database(database_filename);
+ if (database.open(IO_ReadOnly)) {
+ TQTextStream stream(&database);
+ TQString line;
+ TQString pnpID;
+ TQString vendorName;
+ TQString deviceMapKey;
+ TQStringList devinfo;
+ while (!stream.atEnd()) {
+ line = stream.readLine();
+ if ((!line.upper().startsWith("\t")) && (!line.upper().startsWith("#"))) {
+ devinfo = TQStringList::split('\t', line, false);
+ if (devinfo.count() > 1) {
+ pnpID = *(devinfo.at(0));
+ vendorName = *(devinfo.at(1));;
+ vendorName = vendorName.stripWhiteSpace();
+ deviceMapKey = pnpID.upper().stripWhiteSpace();
+ if (!deviceMapKey.isNull()) {
+ pnp_id_map->insert(deviceMapKey, vendorName, true);
+ }
+ }
+ }
+ }
+ database.close();
+ }
+ else {
+ printf("[tdehardwaredevices] Unable to open PNP information database %s\n", database_filename.ascii()); fflush(stdout);
+ }
+ }
+
+ if (pnp_id_map) {
+ TQString deviceName;
+
+ deviceName = (*pnp_id_map)[pnpid];
+
+ return deviceName;
+ }
+ else {
+ return i18n("Unknown PNP Device");
+ }
+}
+
+TQString TDEHardwareDevices::findMonitorManufacturerName(TQString dpyid) {
+ TQString friendlyName = TQString::null;
+
+ if (!dpy_id_map) {
+ dpy_id_map = new TDEDeviceIDMap;
+
+ TQStringList hardware_info_directories(TDEGlobal::dirs()->resourceDirs("data"));
+ TQString hardware_info_directory_suffix("tdehwlib/pnpdev/");
+ TQString hardware_info_directory;
+ TQString database_filename;
+
+ for ( TQStringList::Iterator it = hardware_info_directories.begin(); it != hardware_info_directories.end(); ++it ) {
+ hardware_info_directory = (*it);
+ hardware_info_directory += hardware_info_directory_suffix;
+
+ if (TDEGlobal::dirs()->exists(hardware_info_directory)) {
+ database_filename = hardware_info_directory + "dpy.ids";
+ if (TQFile::exists(database_filename)) {
+ break;
+ }
+ }
+ }
+
+ if (!TQFile::exists(database_filename)) {
+ printf("[tdehardwaredevices] Unable to locate monitor information database dpy.ids\n"); fflush(stdout);
+ return i18n("Unknown Monitor Device");
+ }
+
+ TQFile database(database_filename);
+ if (database.open(IO_ReadOnly)) {
+ TQTextStream stream(&database);
+ TQString line;
+ TQString dpyID;
+ TQString vendorName;
+ TQString deviceMapKey;
+ TQStringList devinfo;
+ while (!stream.atEnd()) {
+ line = stream.readLine();
+ if ((!line.upper().startsWith("\t")) && (!line.upper().startsWith("#"))) {
+ devinfo = TQStringList::split('\t', line, false);
+ if (devinfo.count() > 1) {
+ dpyID = *(devinfo.at(0));
+ vendorName = *(devinfo.at(1));;
+ vendorName = vendorName.stripWhiteSpace();
+ deviceMapKey = dpyID.upper().stripWhiteSpace();
+ if (!deviceMapKey.isNull()) {
+ dpy_id_map->insert(deviceMapKey, vendorName, true);
+ }
+ }
+ }
+ }
+ database.close();
+ }
+ else {
+ printf("[tdehardwaredevices] Unable to open monitor information database %s\n", database_filename.ascii()); fflush(stdout);
+ }
+ }
+
+ if (dpy_id_map) {
+ TQString deviceName;
+
+ deviceName = (*dpy_id_map)[dpyid];
+
+ return deviceName;
+ }
+ else {
+ return i18n("Unknown Monitor Device");
+ }
+}
+
+TQPair<TQString,TQString> TDEHardwareDevices::getEDIDMonitorName(TQString path) {
+ TQPair<TQString,TQString> edid;
+ TQByteArray binaryedid = getEDID(path);
+ if (binaryedid.isNull()) {
+ return TQPair<TQString,TQString>(TQString::null, TQString::null);
+ }
+
+ // Get the manufacturer ID
+ unsigned char letter_1 = ((binaryedid[8]>>2) & 0x1F) + 0x40;
+ unsigned char letter_2 = (((binaryedid[8] & 0x03) << 3) | ((binaryedid[9]>>5) & 0x07)) + 0x40;
+ unsigned char letter_3 = (binaryedid[9] & 0x1F) + 0x40;
+ TQChar qletter_1 = TQChar(letter_1);
+ TQChar qletter_2 = TQChar(letter_2);
+ TQChar qletter_3 = TQChar(letter_3);
+ TQString manufacturer_id = TQString("%1%2%3").arg(qletter_1).arg(qletter_2).arg(qletter_3);
+
+ // Get the model ID
+ unsigned int raw_model_id = (((binaryedid[10] << 8) | binaryedid[11]) << 16) & 0xFFFF0000;
+ // Reverse the bit order
+ unsigned int model_id = reverse_bits(raw_model_id);
+
+ // Try to get the model name
+ bool has_friendly_name = false;
+ unsigned char descriptor_block[18];
+ int i;
+ for (i=72;i<90;i++) {
+ descriptor_block[i-72] = binaryedid[i] & 0xFF;
+ }
+ if ((descriptor_block[0] != 0) || (descriptor_block[1] != 0) || (descriptor_block[3] != 0xFC)) {
+ for (i=90;i<108;i++) {
+ descriptor_block[i-90] = binaryedid[i] & 0xFF;
+ }
+ if ((descriptor_block[0] != 0) || (descriptor_block[1] != 0) || (descriptor_block[3] != 0xFC)) {
+ for (i=108;i<126;i++) {
+ descriptor_block[i-108] = binaryedid[i] & 0xFF;
+ }
+ }
+ }
+
+ TQString monitor_name;
+ if ((descriptor_block[0] == 0) && (descriptor_block[1] == 0) && (descriptor_block[3] == 0xFC)) {
+ char* pos = strchr((char *)(descriptor_block+5), '\n');
+ if (pos) {
+ *pos = 0;
+ has_friendly_name = true;
+ monitor_name = TQString((char *)(descriptor_block+5));
+ }
+ else {
+ has_friendly_name = false;
+ }
+ }
+
+ // Look up manufacturer name
+ TQString manufacturer_name = findMonitorManufacturerName(manufacturer_id);
+ if (manufacturer_name.isNull()) {
+ manufacturer_name = manufacturer_id;
+ }
+
+ if (has_friendly_name) {
+ edid.first = TQString("%1").arg(manufacturer_name);
+ edid.second = TQString("%2").arg(monitor_name);
+ }
+ else {
+ edid.first = TQString("%1").arg(manufacturer_name);
+ edid.second = TQString("0x%2").arg(model_id, 0, 16);
+ }
+
+ return edid;
+}
+
+TQByteArray TDEHardwareDevices::getEDID(TQString path) {
+ TQFile file(TQString("%1/edid").arg(path));
+ if (!file.open (IO_ReadOnly)) {
+ return TQByteArray();
+ }
+ TQByteArray binaryedid = file.readAll();
+ file.close();
+ return binaryedid;
+}
+
+TQString TDEHardwareDevices::getFriendlyDeviceTypeStringFromType(TDEGenericDeviceType::TDEGenericDeviceType query) {
+ TQString ret = "Unknown Device";
+
+ // Keep this in sync with the TDEGenericDeviceType definition in the header
+ if (query == TDEGenericDeviceType::Root) {
+ ret = i18n("Root");
+ }
+ else if (query == TDEGenericDeviceType::RootSystem) {
+ ret = i18n("System Root");
+ }
+ else if (query == TDEGenericDeviceType::CPU) {
+ ret = i18n("CPU");
+ }
+ else if (query == TDEGenericDeviceType::GPU) {
+ ret = i18n("Graphics Processor");
+ }
+ else if (query == TDEGenericDeviceType::RAM) {
+ ret = i18n("RAM");
+ }
+ else if (query == TDEGenericDeviceType::Bus) {
+ ret = i18n("Bus");
+ }
+ else if (query == TDEGenericDeviceType::I2C) {
+ ret = i18n("I2C Bus");
+ }
+ else if (query == TDEGenericDeviceType::MDIO) {
+ ret = i18n("MDIO Bus");
+ }
+ else if (query == TDEGenericDeviceType::Mainboard) {
+ ret = i18n("Mainboard");
+ }
+ else if (query == TDEGenericDeviceType::Disk) {
+ ret = i18n("Disk");
+ }
+ else if (query == TDEGenericDeviceType::SCSI) {
+ ret = i18n("SCSI");
+ }
+ else if (query == TDEGenericDeviceType::StorageController) {
+ ret = i18n("Storage Controller");
+ }
+ else if (query == TDEGenericDeviceType::Mouse) {
+ ret = i18n("Mouse");
+ }
+ else if (query == TDEGenericDeviceType::Keyboard) {
+ ret = i18n("Keyboard");
+ }
+ else if (query == TDEGenericDeviceType::HID) {
+ ret = i18n("HID");
+ }
+ else if (query == TDEGenericDeviceType::Modem) {
+ ret = i18n("Modem");
+ }
+ else if (query == TDEGenericDeviceType::Monitor) {
+ ret = i18n("Monitor and Display");
+ }
+ else if (query == TDEGenericDeviceType::Network) {
+ ret = i18n("Network");
+ }
+ else if (query == TDEGenericDeviceType::Printer) {
+ ret = i18n("Printer");
+ }
+ else if (query == TDEGenericDeviceType::Scanner) {
+ ret = i18n("Scanner");
+ }
+ else if (query == TDEGenericDeviceType::Sound) {
+ ret = i18n("Sound");
+ }
+ else if (query == TDEGenericDeviceType::VideoCapture) {
+ ret = i18n("Video Capture");
+ }
+ else if (query == TDEGenericDeviceType::IEEE1394) {
+ ret = i18n("IEEE1394");
+ }
+ else if (query == TDEGenericDeviceType::PCMCIA) {
+ ret = i18n("PCMCIA");
+ }
+ else if (query == TDEGenericDeviceType::Camera) {
+ ret = i18n("Camera");
+ }
+ else if (query == TDEGenericDeviceType::TextIO) {
+ ret = i18n("Text I/O");
+ }
+ else if (query == TDEGenericDeviceType::Serial) {
+ ret = i18n("Serial Communications Controller");
+ }
+ else if (query == TDEGenericDeviceType::Parallel) {
+ ret = i18n("Parallel Port");
+ }
+ else if (query == TDEGenericDeviceType::Peripheral) {
+ ret = i18n("Peripheral");
+ }
+ else if (query == TDEGenericDeviceType::Backlight) {
+ ret = i18n("Backlight");
+ }
+ else if (query == TDEGenericDeviceType::Battery) {
+ ret = i18n("Battery");
+ }
+ else if (query == TDEGenericDeviceType::PowerSupply) {
+ ret = i18n("Power Supply");
+ }
+ else if (query == TDEGenericDeviceType::Dock) {
+ ret = i18n("Docking Station");
+ }
+ else if (query == TDEGenericDeviceType::ThermalSensor) {
+ ret = i18n("Thermal Sensor");
+ }
+ else if (query == TDEGenericDeviceType::ThermalControl) {
+ ret = i18n("Thermal Control");
+ }
+ else if (query == TDEGenericDeviceType::BlueTooth) {
+ ret = i18n("Bluetooth");
+ }
+ else if (query == TDEGenericDeviceType::Bridge) {
+ ret = i18n("Bridge");
+ }
+ else if (query == TDEGenericDeviceType::Platform) {
+ ret = i18n("Platform");
+ }
+ else if (query == TDEGenericDeviceType::Cryptography) {
+ ret = i18n("Cryptography");
+ }
+ else if (query == TDEGenericDeviceType::Event) {
+ ret = i18n("Platform Event");
+ }
+ else if (query == TDEGenericDeviceType::Input) {
+ ret = i18n("Platform Input");
+ }
+ else if (query == TDEGenericDeviceType::PNP) {
+ ret = i18n("Plug and Play");
+ }
+ else if (query == TDEGenericDeviceType::OtherACPI) {
+ ret = i18n("Other ACPI");
+ }
+ else if (query == TDEGenericDeviceType::OtherUSB) {
+ ret = i18n("Other USB");
+ }
+ else if (query == TDEGenericDeviceType::OtherMultimedia) {
+ ret = i18n("Other Multimedia");
+ }
+ else if (query == TDEGenericDeviceType::OtherPeripheral) {
+ ret = i18n("Other Peripheral");
+ }
+ else if (query == TDEGenericDeviceType::OtherSensor) {
+ ret = i18n("Other Sensor");
+ }
+ else if (query == TDEGenericDeviceType::OtherVirtual) {
+ ret = i18n("Other Virtual");
+ }
+ else {
+ ret = i18n("Unknown Device");
+ }
+
+ return ret;
+}
+
+TQPixmap TDEHardwareDevices::getDeviceTypeIconFromType(TDEGenericDeviceType::TDEGenericDeviceType query, TDEIcon::StdSizes size) {
+ TQPixmap ret = DesktopIcon("misc", size);
+
+// // Keep this in sync with the TDEGenericDeviceType definition in the header
+ if (query == TDEGenericDeviceType::Root) {
+ ret = DesktopIcon("kcmdevices", size);
+ }
+ else if (query == TDEGenericDeviceType::RootSystem) {
+ ret = DesktopIcon("kcmdevices", size);
+ }
+ else if (query == TDEGenericDeviceType::CPU) {
+ ret = DesktopIcon("kcmprocessor", size);
+ }
+ else if (query == TDEGenericDeviceType::GPU) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::RAM) {
+ ret = DesktopIcon("memory", size);
+ }
+ else if (query == TDEGenericDeviceType::Bus) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::I2C) {
+ ret = DesktopIcon("input_devices_settings", size);
+ }
+ else if (query == TDEGenericDeviceType::MDIO) {
+ ret = DesktopIcon("input_devices_settings", size);
+ }
+ else if (query == TDEGenericDeviceType::Mainboard) {
+ ret = DesktopIcon("kcmpci", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::Disk) {
+ ret = DesktopIcon("hdd_unmount", size);
+ }
+ else if (query == TDEGenericDeviceType::SCSI) {
+ ret = DesktopIcon("kcmscsi", size);
+ }
+ else if (query == TDEGenericDeviceType::StorageController) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::Mouse) {
+ ret = DesktopIcon("mouse", size);
+ }
+ else if (query == TDEGenericDeviceType::Keyboard) {
+ ret = DesktopIcon("keyboard", size);
+ }
+ else if (query == TDEGenericDeviceType::HID) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::Modem) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::Monitor) {
+ ret = DesktopIcon("background", size);
+ }
+ else if (query == TDEGenericDeviceType::Network) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::Printer) {
+ ret = DesktopIcon("printer1", size);
+ }
+ else if (query == TDEGenericDeviceType::Scanner) {
+ ret = DesktopIcon("scanner", size);
+ }
+ else if (query == TDEGenericDeviceType::Sound) {
+ ret = DesktopIcon("kcmsound", size);
+ }
+ else if (query == TDEGenericDeviceType::VideoCapture) {
+ ret = DesktopIcon("tv", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::IEEE1394) {
+ ret = DesktopIcon("ieee1394", size);
+ }
+ else if (query == TDEGenericDeviceType::PCMCIA) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::Camera) {
+ ret = DesktopIcon("camera", size);
+ }
+ else if (query == TDEGenericDeviceType::Serial) {
+ ret = DesktopIcon("input_devices_settings", size);
+ }
+ else if (query == TDEGenericDeviceType::Parallel) {
+ ret = DesktopIcon("input_devices_settings", size);
+ }
+ else if (query == TDEGenericDeviceType::TextIO) {
+ ret = DesktopIcon("chardevice", size);
+ }
+ else if (query == TDEGenericDeviceType::Peripheral) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::Backlight) {
+ ret = DesktopIcon("tdescreensaver", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::Battery) {
+ ret = DesktopIcon("energy", size);
+ }
+ else if (query == TDEGenericDeviceType::PowerSupply) {
+ ret = DesktopIcon("energy", size);
+ }
+ else if (query == TDEGenericDeviceType::Dock) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::ThermalSensor) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::ThermalControl) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::BlueTooth) {
+ ret = DesktopIcon("kcmpci", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::Bridge) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::Platform) {
+ ret = DesktopIcon("kcmsystem", size);
+ }
+ else if (query == TDEGenericDeviceType::Cryptography) {
+ ret = DesktopIcon("password", size);
+ }
+ else if (query == TDEGenericDeviceType::Event) {
+ ret = DesktopIcon("kcmsystem", size);
+ }
+ else if (query == TDEGenericDeviceType::Input) {
+ ret = DesktopIcon("kcmsystem", size);
+ }
+ else if (query == TDEGenericDeviceType::PNP) {
+ ret = DesktopIcon("kcmsystem", size);
+ }
+ else if (query == TDEGenericDeviceType::OtherACPI) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::OtherUSB) {
+ ret = DesktopIcon("usb", size);
+ }
+ else if (query == TDEGenericDeviceType::OtherMultimedia) {
+ ret = DesktopIcon("kcmsound", size);
+ }
+ else if (query == TDEGenericDeviceType::OtherPeripheral) {
+ ret = DesktopIcon("kcmpci", size);
+ }
+ else if (query == TDEGenericDeviceType::OtherSensor) {
+ ret = DesktopIcon("kcmdevices", size); // FIXME
+ }
+ else if (query == TDEGenericDeviceType::OtherVirtual) {
+ ret = DesktopIcon("kcmsystem", size);
+ }
+ else {
+ ret = DesktopIcon("hwinfo", size);
+ }
+
+ return ret;
+}
+
+TDERootSystemDevice* TDEHardwareDevices::rootSystemDevice() {
+ TDEGenericDevice *hwdevice;
+ for ( hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next() ) {
+ if (hwdevice->type() == TDEGenericDeviceType::RootSystem) {
+ return dynamic_cast<TDERootSystemDevice*>(hwdevice);
+ }
+ }
+
+ return 0;
+}
+
+TQString TDEHardwareDevices::bytesToFriendlySizeString(double bytes) {
+ TQString prettystring;
+
+ prettystring = TQString("%1B").arg(bytes);
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1KB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1MB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1GB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1TB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1PB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1EB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1ZB").arg(bytes, 0, 'f', 1);
+ }
+
+ if (bytes > 1024) {
+ bytes = bytes / 1024;
+ prettystring = TQString("%1YB").arg(bytes, 0, 'f', 1);
+ }
+
+ return prettystring;
+}
+
+TDEGenericHardwareList TDEHardwareDevices::listByDeviceClass(TDEGenericDeviceType::TDEGenericDeviceType cl) {
+ TDEGenericHardwareList ret;
+ ret.setAutoDelete(false);
+
+ TDEGenericDevice *hwdevice;
+ for ( hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next() ) {
+ if (hwdevice->type() == cl) {
+ ret.append(hwdevice);
+ }
+ }
+
+ return ret;
+}
+
+TDEGenericHardwareList TDEHardwareDevices::listAllPhysicalDevices() {
+ TDEGenericHardwareList ret = m_deviceList;
+ ret.setAutoDelete(false);
+
+ return ret;
+}
+
+#include "tdehardwaredevices.moc"
diff --git a/tdecore/tdehw/tdehardwaredevices.h b/tdecore/tdehw/tdehardwaredevices.h
new file mode 100644
index 000000000..fcf60533d
--- /dev/null
+++ b/tdecore/tdehw/tdehardwaredevices.h
@@ -0,0 +1,2122 @@
+/* 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 _TDEHARDWAREDEVICES_H
+#define _TDEHARDWAREDEVICES_H
+
+// TDE includes
+#include <tqobject.h>
+#include <tqstring.h>
+#include <tqptrlist.h>
+#include <tqstringlist.h>
+#include "kiconloader.h"
+#include "tdelibs_export.h"
+
+// udev includes
+#include <libudev.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <unistd.h>
+
+/**
+ * Hardware Device Access and Monitoring Library
+ *
+ * @author Timothy Pearson
+ */
+
+class TDENetworkConnectionManager;
+
+namespace TDEHardwareEvent {
+enum TDEHardwareEvent {
+ HardwareListModified,
+ MountTableModified,
+ HardwareAdded,
+ HardwareRemoved,
+ HardwareUpdated,
+ Other,
+ Last = Other
+};
+};
+
+// Keep readGenericDeviceTypeFromString(), getFriendlyDeviceTypeStringFromType(), and getDeviceTypeIconFromType() in tdehardwaredevices.cpp in sync with this enum
+namespace TDEGenericDeviceType {
+enum TDEGenericDeviceType {
+ Root,
+ RootSystem,
+ CPU,
+ GPU,
+ RAM,
+ Bus,
+ I2C,
+ MDIO,
+ Mainboard,
+ Disk,
+ SCSI,
+ StorageController,
+ Mouse,
+ Keyboard,
+ HID,
+ Modem,
+ Monitor,
+ Network,
+ Printer,
+ Scanner,
+ Sound,
+ VideoCapture,
+ IEEE1394,
+ PCMCIA,
+ Camera,
+ TextIO,
+ Serial,
+ Parallel,
+ Peripheral,
+ Backlight,
+ Battery,
+ PowerSupply,
+ Dock,
+ ThermalSensor,
+ ThermalControl,
+ BlueTooth,
+ Bridge,
+ Platform,
+ Cryptography,
+ Event,
+ Input,
+ PNP,
+ OtherACPI,
+ OtherUSB,
+ OtherMultimedia,
+ OtherPeripheral,
+ OtherSensor,
+ OtherVirtual,
+ Other,
+ Last = Other
+};
+};
+
+// Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
+namespace TDEDiskDeviceType {
+enum TDEDiskDeviceType {
+ Null = 0x00000000,
+ MediaDevice = 0x00000001,
+ Floppy = 0x00000002,
+ CDROM = 0x00000004,
+ CDRW = 0x00000008,
+ DVDROM = 0x00000010,
+ DVDRAM = 0x00000020,
+ DVDRW = 0x00000040,
+ BDROM = 0x00000080,
+ BDRW = 0x00000100,
+ Zip = 0x00000200,
+ Jaz = 0x00000400,
+ Camera = 0x00000800,
+ LUKS = 0x00001000,
+ OtherCrypted = 0x00002000,
+ CDAudio = 0x00004000,
+ CDVideo = 0x00008000,
+ DVDVideo = 0x00010000,
+ BDVideo = 0x00020000,
+ Flash = 0x00040000,
+ USB = 0x00080000,
+ Tape = 0x00100000,
+ HDD = 0x00200000,
+ Optical = 0x00400000,
+ RAM = 0x00800000,
+ Loop = 0x01000000,
+ CompactFlash = 0x02000000,
+ MemoryStick = 0x04000000,
+ SmartMedia = 0x08000000,
+ SDMMC = 0x10000000,
+ UnlockedCrypt = 0x20000000,
+ Other = 0x80000000
+};
+
+inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
+{
+ return static_cast<TDEDiskDeviceType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
+{
+ return static_cast<TDEDiskDeviceType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
+{
+ return static_cast<TDEDiskDeviceType>(~static_cast<int>(a));
+}
+};
+
+namespace TDEDiskDeviceStatus {
+enum TDEDiskDeviceStatus {
+ Null = 0x00000000,
+ Mountable = 0x00000001,
+ Removable = 0x00000002,
+ Inserted = 0x00000004,
+ Blank = 0x00000008,
+ UsedByDevice = 0x00000010,
+ UsesDevice = 0x00000020,
+ ContainsFilesystem = 0x00000040,
+ Hotpluggable = 0x00000080,
+ Other = 0x80000000
+};
+
+inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
+{
+ return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
+{
+ return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
+{
+ return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
+}
+};
+
+class TDECORE_EXPORT TDESensorCluster
+{
+ public:
+ /**
+ * Constructor.
+ */
+ TDESensorCluster();
+
+ TQString label;
+ double current;
+ double minimum;
+ double maximum;
+ double warning;
+ double critical;
+};
+
+class TDECORE_EXPORT TDEGenericDevice : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEGenericDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEGenericDevice();
+
+ /**
+ * @return a TDEGenericDeviceType::TDEGenericDeviceType specifying the device type
+ */
+ TDEGenericDeviceType::TDEGenericDeviceType type();
+
+ /**
+ * @return a TQString with the device name, if any
+ */
+ TQString name();
+
+ /**
+ * @return a TQString with the vendor name, if any
+ */
+ TQString vendorName();
+
+ /**
+ * @return a TQString with the vendor model, if any
+ */
+ TQString vendorModel();
+
+ /**
+ * @return a TQString with the serial number, if any
+ */
+ TQString serialNumber();
+
+ /**
+ * @return a TQString with a friendly name
+ *
+ * While TDE tries very hard to generate and return a friendly name for this device,
+ * sometimes the best it will be able to do is "Unknown Device [xxxx:yyyy]"
+ */
+ virtual TQString friendlyName();
+
+ /**
+ * @return a TQString with the device bus name, if any
+ */
+ TQString deviceBus();
+
+ /**
+ * @return a TQString with the system path, if any
+ *
+ * This method is non-portable, so be careful!
+ */
+ TQString systemPath();
+
+ /**
+ * @return a TQString with the system device node, if any
+ *
+ * This method is non-portable, so be careful!
+ */
+ TQString deviceNode();
+
+ /**
+ * @return true if this device has been blacklisted for update actions
+ */
+ bool blacklistedForUpdate();
+
+ /**
+ * @return a TQString containing a unique identifier for this device
+ */
+ TQString uniqueID();
+
+ /**
+ * @return a TQString with the vendor ID, if any
+ */
+ TQString vendorID();
+
+ /**
+ * @return a TQString with the model ID, if any
+ */
+ TQString modelID();
+
+ /**
+ * @return a TQString with the encoded vendor, if any
+ */
+ TQString vendorEncoded();
+
+ /**
+ * @return a TQString with the encoded model, if any
+ */
+ TQString modelEncoded();
+
+ /**
+ * @return a TQString with the subvendor ID, if any
+ */
+ TQString subVendorID();
+
+ /**
+ * @return a TQString with the submodel ID, if any
+ */
+ TQString subModelID();
+
+ /**
+ * @return a TQString with the PCI device class, if any
+ */
+ TQString PCIClass();
+
+ /**
+ * @return a TQString with the module alias string, if any
+ */
+ TQString moduleAlias();
+
+ /**
+ * @return a TQString with the device driver, if any
+ */
+ TQString deviceDriver();
+
+ /**
+ * @return a TQString with the subsystem type, if any
+ */
+ TQString subsystem();
+
+ /**
+ * @return a TDEGenericDevice* with the parent device, if any
+ */
+ TDEGenericDevice* parentDevice();
+
+ /**
+ * @return a TQString containing the friendly type name
+ */
+ virtual TQString friendlyDeviceType();
+
+ /**
+ * @return a TQString containing the device bus ID, if any
+ */
+ TQString busID();
+
+ /**
+ * Get an icon for this device
+ * @param size a TDEIcon::StdSizes structure specifying the desired icon size
+ * @return a TQPixmap containing the icon for the specified type
+ */
+ virtual TQPixmap icon(TDEIcon::StdSizes size);
+
+ protected:
+ /**
+ * @param a TQString with the device name, if any
+ * @internal
+ */
+ void internalSetName(TQString dn);
+
+ /**
+ * @param a TQString with the vendor name, if any
+ * @internal
+ */
+ void internalSetVendorName(TQString vn);
+
+ /**
+ * @param a TQString with the vendor model, if any
+ * @internal
+ */
+ void internalSetVendorModel(TQString vm);
+
+ /**
+ * @param a TQString with the serial number, if any
+ * @internal
+ */
+ void internalSetSerialNumber(TQString sn);
+
+ /**
+ * @param a TQString with the device bus name, if any
+ * @internal
+ */
+ void internalSetDeviceBus(TQString db);
+
+ /**
+ * @param a TQString with the system path, if any
+ * @internal
+ *
+ * This method is non-portable, so be careful!
+ */
+ void internalSetSystemPath(TQString sp);
+
+ /**
+ * @param a TQString with the system device node, if any
+ * @internal
+ *
+ * This method is non-portable, so be careful!
+ */
+ void internalSetDeviceNode(TQString sn);
+
+ /**
+ * @param bl true if this device has been blacklisted for update actions
+ * @internal
+ */
+ void internalSetBlacklistedForUpdate(bool bl);
+
+ /**
+ * @param a TQString with the vendor ID, if any
+ * @internal
+ */
+ void internalSetVendorID(TQString id);
+
+ /**
+ * @param a TQString with the model ID, if any
+ * @internal
+ */
+ void internalSetModelID(TQString id);
+
+ /**
+ * @param a TQString with the encoded vendor, if any
+ * @internal
+ */
+ void internalSetVendorEncoded(TQString id);
+
+ /**
+ * @param a TQString with the encoded model, if any
+ * @internal
+ */
+ void internalSetModelEncoded(TQString id);
+
+ /**
+ * @param a TQString with the subvendor ID, if any
+ * @internal
+ */
+ void internalSetSubVendorID(TQString id);
+
+ /**
+ * @param a TQString with the submodel ID, if any
+ * @internal
+ */
+ void internalSetSubModelID(TQString id);
+
+ /**
+ * @param a TQString with the PCI device class, if any
+ * @internal
+ */
+ void internalSetPCIClass(TQString cl);
+
+ /**
+ * @param a TQString with the module alias string, if any
+ * @internal
+ */
+ void internalSetModuleAlias(TQString ma);
+
+ /**
+ * @param a TQString with the device driver, if any
+ * @internal
+ */
+ void internalSetDeviceDriver(TQString dr);
+
+ /**
+ * @param a TQString with the subsystem type, if any
+ * @internal
+ */
+ void internalSetSubsystem(TQString ss);
+
+ /**
+ * @param a TDEGenericDevice* with the parent device, if any
+ * @internal
+ */
+ void internalSetParentDevice(TDEGenericDevice* pd);
+
+ private:
+ TDEGenericDeviceType::TDEGenericDeviceType m_deviceType;
+ TQString m_deviceName;
+ TQString m_systemPath;
+ TQString m_deviceNode;
+ TQString m_vendorName;
+ TQString m_vendorModel;
+ TQString m_serialNumber;
+ TQString m_deviceBus;
+ TQString m_uniqueID;
+ TQString m_vendorID;
+ TQString m_modelID;
+ TQString m_vendorenc;
+ TQString m_modelenc;
+ TQString m_subvendorID;
+ TQString m_submodelID;
+ TQString m_pciClass;
+ TQString m_modAlias;
+ TQString m_deviceDriver;
+ TQString m_subsystem;
+ TQString m_friendlyName;
+ bool m_blacklistedForUpdate;
+ TDEGenericDevice* m_parentDevice;
+
+ // Internal use only!
+ TQStringList m_externalSubtype;
+ TQString m_externalRulesFile;
+ TQString m_udevtype;
+ TQString m_udevdevicetypestring;
+ TQString udevdevicetypestring_alt;
+
+ friend class TDEHardwareDevices;
+};
+
+class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEStorageDevice();
+
+ /**
+ * @return a TQString with the disk or partition label, if any
+ */
+ TQString diskLabel();
+
+ /**
+ * @return a TQString with the disk UUID, if any
+ */
+ TQString diskUUID();
+
+ /**
+ * @return an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
+ */
+ TDEDiskDeviceType::TDEDiskDeviceType diskType();
+
+ /**
+ * @return an OR-ed combination of TDEDiskDeviceStatus::TDEDiskDeviceStatus type flags
+ */
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
+
+ /**
+ * @return true if media inserted, false if no media available
+ */
+ bool mediaInserted();
+
+ /**
+ * @return a TQString with the filesystem name, if any
+ */
+ TQString fileSystemName();
+
+ /**
+ * @return a TQString with the filesystem usage string, if any
+ */
+ TQString fileSystemUsage();
+
+ /**
+ * @return a TQStringList containing system paths to all devices with a lock on this device, if any
+ */
+ TQStringList holdingDevices();
+
+ /**
+ * @return a TQStringList containing system paths to all devices locked by this device, if any
+ */
+ TQStringList slaveDevices();
+
+ /**
+ * Mounts the device if not encrypted
+ *
+ * @param a TQString containing a requested mount name under /media, if desired
+ * @param a TQString containing any mount options for pmount, if desired
+ * @param a pointer to a TQString which will be populated with any error messages from pmount, if desired
+ * @param a pointer to an integer which will be populated with the return code from pmount, if desired
+ *
+ * @return a TQString with the mount path, if successful
+ */
+ TQString mountDevice(TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
+
+ /**
+ * Mounts the encrypted device if the correct passphrase is given
+ *
+ * @param a TQString containing the passphrase
+ * @param a TQString containing a requested mount name under /media, if desired
+ * @param a TQString containing any mount options for pmount, if desired
+ * @param a pointer to a TQString which will be populated with any error messages from pmount, if desired
+ * @param a pointer to an integer which will be populated with the return code from pmount, if desired
+ *
+ * @return a TQString with the mount path, if successful
+ */
+ TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
+
+ /**
+ * Unmounts the device
+ *
+ * @param a pointer to a TQString which will be populated with any error messages from pmount, if desired
+ * @param a pointer to an integer which will be populated with the return code from pmount, if desired
+ *
+ * @return TRUE if unmount was successful
+ */
+ bool unmountDevice(TQString* errRet, int* retcode=0);
+
+ /**
+ * @return a TQString with the mount path, if mounted
+ */
+ TQString mountPath();
+
+ /**
+ * @return an unsigned long with the device size in bytes
+ */
+ unsigned long long deviceSize();
+
+ /**
+ * @return a TQString with the device size in human readable form
+ */
+ TQString deviceFriendlySize();
+
+ /**
+ * Get an icon for this device
+ * @param size a TDEIcon::StdSizes structure specifying the desired icon size
+ * @return a TQPixmap containing the icon for the specified type
+ *
+ * This method overrides TDEGenericDevice::icon(TDEIcon::StdSizes size)
+ */
+ TQPixmap icon(TDEIcon::StdSizes size);
+
+ /**
+ * @return a TQString with a friendly name
+ *
+ * This method overrides TDEGenericDevice::friendlyName()
+ */
+ TQString friendlyName();
+
+ /**
+ * @return a TQString containing the friendly type name
+ *
+ * This method overrides TDEGenericDevice::friendlyDeviceType()
+ */
+ TQString friendlyDeviceType();
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
+ */
+ bool isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf);
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceStatus::TDEDiskDeviceStatus type flags
+ */
+ bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
+
+ /**
+ * @param TRUE to engage media lock, FALSE to disable it
+ * @return TRUE on success, FALSE on failure
+ *
+ * This method currently works on CD-ROM drives and similar devices
+ */
+ bool lockDriveMedia(bool lock);
+
+ /**
+ * @return TRUE on success, FALSE on failure
+ *
+ * This method currently works on CD-ROM drives and similar devices
+ */
+ bool ejectDriveMedia();
+
+ /**
+ * @return TRUE on success, FALSE on failure
+ *
+ * This method currently works on all removable storage devices
+ */
+ bool ejectDrive();
+
+ protected:
+ /**
+ * @param a TQString with the disk or partition label, if any
+ * @internal
+ */
+ void internalSetDiskLabel(TQString dn);
+
+ /**
+ * @param a TQString with the disk UUID, if any
+ * @internal
+ */
+ void internalSetDiskUUID(TQString id);
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
+ * @internal
+ */
+ void internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceStatus::TDEDiskDeviceStatus type flags
+ * @internal
+ */
+ void internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
+
+ /**
+ * @param a bool with the media status
+ * @internal
+ */
+ void internalSetMediaInserted(bool inserted);
+
+ /**
+ * @param a TQString with the filesystem name, if any
+ * @internal
+ */
+ void internalSetFileSystemName(TQString fn);
+
+ /**
+ * @param a TQString with the filesystem usage string, if any
+ * @internal
+ */
+ void internalSetFileSystemUsage(TQString fu);
+
+ /**
+ * @param a TQStringList containing system paths to all devices with a lock on this device, if any
+ * @internal
+ */
+ void internalSetHoldingDevices(TQStringList hd);
+
+ /**
+ * @param a TQStringList containing system paths to all devices locked by this device, if any
+ * @internal
+ */
+ void internalSetSlaveDevices(TQStringList sd);
+
+ private:
+ TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
+ TQString m_diskName;
+ TQString m_diskUUID;
+ TQString m_fileSystemName;
+ TQString m_fileSystemUsage;
+ bool m_mediaInserted;
+ TQString m_mountPath;
+ TQStringList m_holdingDevices;
+ TQStringList m_slaveDevices;
+
+ friend class TDEHardwareDevices;
+};
+
+class TDECORE_EXPORT TDECPUDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDECPUDevice();
+
+ /**
+ * @return a double with the current CPU frequency in MHz, if available
+ */
+ double frequency();
+
+ /**
+ * @return a double with the minimum CPU frequency in MHz, if available
+ */
+ double minFrequency();
+
+ /**
+ * @return a double with the maximum CPU frequency in MHz, if available
+ */
+ double maxFrequency();
+
+ /**
+ * @return a double with the transition latency in ns, if available
+ */
+ double transitionLatency();
+
+ /**
+ * @return a TQString with the current CPU governor policy, if available
+ */
+ TQString governor();
+
+ /**
+ * @return a TQString with the current CPU scaling driver, if available
+ */
+ TQString scalingDriver();
+
+ /**
+ * @return a TQStringList with the IDs of all processors that are dependent on the frequency/power settings of this one, if available
+ */
+ TQStringList dependentProcessors();
+
+ /**
+ * @return a TQStringList with all valid scaling frequencies in Hz, if available
+ */
+ TQStringList availableFrequencies();
+
+ /**
+ * @return a TQStringList with all available governor policies, if available
+ */
+ TQStringList availableGovernors();
+
+ /**
+ * @return TRUE if permissions allow the CPU governor to be set, FALSE if not
+ */
+ bool canSetGovernor();
+
+ /**
+ * @param gv a TQString with the new CPU governor policy name
+ */
+ void setGovernor(TQString gv);
+
+ /**
+ * @return TRUE if permissions allow the CPU maximum frequency to be set, FALSE if not
+ */
+ bool canSetMaximumScalingFrequency();
+
+ /**
+ * @param gv a double with the new CPU maximum frequency in MHz
+ */
+ void setMaximumScalingFrequency(double fr);
+
+ /**
+ * @return an integer with the core number, starting at 0
+ */
+ int coreNumber();
+
+ protected:
+ /**
+ * @param fr a double with the current CPU frequency in MHz, if available
+ * @internal
+ */
+ void internalSetFrequency(double fr);
+
+ /**
+ * @param fr a double with the minimum CPU frequency in MHz, if available
+ * @internal
+ */
+ void internalSetMinFrequency(double fr);
+
+ /**
+ * @param fr a double with the maximum CPU frequency in MHz, if available
+ * @internal
+ */
+ void internalSetMaxFrequency(double fr);
+
+ /**
+ * @param tl a double with the transition latency in ns, if available
+ * @internal
+ */
+ void internalSetTransitionLatency(double tl);
+
+ /**
+ * @param gr a TQString with the current CPU governor policy, if available
+ * @internal
+ */
+ void internalSetGovernor(TQString gr);
+
+ /**
+ * @param dr a TQString with the current CPU scaling driver, if available
+ * @internal
+ */
+ void internalSetScalingDriver(TQString dr);
+
+ /**
+ * @param dp a TQStringList with the IDs of all processors that are dependent on the frequency/power settings of this one, if available
+ * @internal
+ */
+ void internalSetDependentProcessors(TQStringList dp);
+
+ /**
+ * @param af a TQStringList with all valid scaling frequencies in Hz, if available
+ * @internal
+ */
+ void internalSetAvailableFrequencies(TQStringList af);
+
+ /**
+ * @param gp a TQStringList with all available governor policies, if available
+ * @internal
+ */
+ void internalSetAvailableGovernors(TQStringList gp);
+
+ /**
+ * @param cn an integer with the core number, starting at 0
+ * @internal
+ */
+ void internalSetCoreNumber(int cn);
+
+ private:
+ double m_frequency;
+ double m_minfrequency;
+ double m_maxfrequency;
+ double m_transitionlatency;
+ TQString m_governor;
+ TQString m_scalingdriver;
+ TQStringList m_tiedprocs;
+ TQStringList m_frequencies;
+ TQStringList m_governers;
+ int m_corenumber;
+
+ friend class TDEHardwareDevices;
+};
+
+namespace TDEBatteryStatus {
+enum TDEBatteryStatus {
+ Charging,
+ Discharging,
+ Full,
+ Unknown = 0x80000000
+};
+};
+
+class TDECORE_EXPORT TDEBatteryDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEBatteryDevice();
+
+ /**
+ * @return a double with the current battery voltage, if available
+ */
+ double voltage();
+
+ /**
+ * @return a double with the minimum battery voltage, if available
+ */
+ double minimumVoltage();
+
+ /**
+ * @return a double with the maximum battery voltage, if available
+ */
+ double maximumVoltage();
+
+ /**
+ * @return a double with the designed maximum battery voltage, if available
+ */
+ double maximumDesignVoltage();
+
+ /**
+ * @return a double with the current battery energy in watt-hours, if available
+ */
+ double energy();
+
+ /**
+ * @return a double with the current battery alarm energy in watt-hours, if available
+ */
+ double alarmEnergy();
+
+ /**
+ * @return a double with the maximum battery energy in watt-hours, if available
+ */
+ double maximumEnergy();
+
+ /**
+ * @return a double with the designed maximum battery energy in watt-hours, if available
+ */
+ double maximumDesignEnergy();
+
+ /**
+ * @return a double with the current battery discharge rate in watt-hours, if available
+ */
+ double dischargeRate();
+
+ /**
+ * @return a double with the current battery discharge time remaining in seconds, if available
+ */
+ double timeRemaining();
+
+ /**
+ * @return a TQString with the battery technology, if available
+ */
+ TQString technology();
+
+ /**
+ * @return a TDEBatteryStatus::TDEBatteryStatus with the current battery status
+ */
+ TDEBatteryStatus::TDEBatteryStatus status();
+
+ /**
+ * @return TRUE if the battery is installed
+ */
+ bool installed();
+
+ /**
+ * @return a double with the current battery charge in percent, if available
+ */
+ double chargePercent();
+
+ protected:
+ /**
+ * @param a double with the current battery voltage, if available
+ * @internal
+ */
+ void internalSetVoltage(double vt);
+
+ /**
+ * @param a double with the minimum battery voltage, if available
+ * @internal
+ */
+ void internalSetMinimumVoltage(double vt);
+
+ /**
+ * @param a double with the maximum battery voltage, if available
+ * @internal
+ */
+ void internalSetMaximumVoltage(double vt);
+
+ /**
+ * @param a double with the designed maximum battery voltage, if available
+ * @internal
+ */
+ void internalSetMaximumDesignVoltage(double vt);
+
+ /**
+ * @param a double with the current battery energy in watt-hours, if available
+ * @internal
+ */
+ void internalSetEnergy(double vt);
+
+ /**
+ * @param a double with the current battery alarm energy in watt-hours, if available
+ * @internal
+ */
+ void internalSetAlarmEnergy(double vt);
+
+ /**
+ * @param a double with the maximum battery energy in watt-hours, if available
+ * @internal
+ */
+ void internalSetMaximumEnergy(double vt);
+
+ /**
+ * @param a double with the designed maximum battery energy in watt-hours, if available
+ * @internal
+ */
+ void internalSetMaximumDesignEnergy(double vt);
+
+ /**
+ * @param a double with the current battery discharge rate in volt-hours, if available
+ * @internal
+ */
+ void internalSetDischargeRate(double vt);
+
+ /**
+ * @param a double with the current battery discharge time remaining in seconds, if available
+ * @internal
+ */
+ void internalSetTimeRemaining(double tr);
+
+ /**
+ * @param a TQString with the battery technology, if available
+ * @internal
+ */
+ void internalSetTechnology(TQString tc);
+
+ /**
+ * @param a TQString with the battery status, if available
+ * @internal
+ */
+ void internalSetStatus(TQString tc);
+
+ /**
+ * @param TRUE if the battery is installed
+ * @internal
+ */
+ void internalSetInstalled(bool tc);
+
+ private:
+ double m_currentVoltage;
+ double m_minimumVoltage;
+ double m_maximumVoltage;
+ double m_maximumDesignVoltage;
+ double m_alarmEnergy;
+ double m_currentEnergy;
+ double m_maximumEnergy;
+ double m_maximumDesignEnergy;
+ double m_dischargeRate;
+ double m_timeRemaining;
+ TQString m_technology;
+ TDEBatteryStatus::TDEBatteryStatus m_status;
+ bool m_installed;
+
+ friend class TDEHardwareDevices;
+};
+
+class TDECORE_EXPORT TDEMainsPowerDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEMainsPowerDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEMainsPowerDevice();
+
+ /**
+ * @return TRUE if power supply is online via mains power, FALSE if not
+ */
+ bool online();
+
+ protected:
+ /**
+ * @param TRUE if power supply is online via mains power, FALSE if not
+ * @internal
+ */
+ void internalSetOnline(bool vt);
+
+ private:
+ bool m_online;
+
+ friend class TDEHardwareDevices;
+};
+
+class TDECORE_EXPORT TDENetworkDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDENetworkDevice();
+
+ /**
+ * @return a TQString containing the network device's MAC address
+ */
+ TQString macAddress();
+
+ /**
+ * @return a TQString containing the network device's operational state
+ */
+ TQString state();
+
+ /**
+ * @return TRUE if carrier is present, FALSE if not
+ */
+ bool carrierPresent();
+
+ /**
+ * @return TRUE if device is dormant, FALSE if not
+ */
+ bool dormant();
+
+ /**
+ * @return a TQString containing the network device's IPv4 address
+ */
+ TQString ipV4Address();
+
+ /**
+ * @return a TQString containing the network device's IPv6 address
+ */
+ TQString ipV6Address();
+
+ /**
+ * @return a TQString containing the network device's IPv4 netmask
+ */
+ TQString ipV4Netmask();
+
+ /**
+ * @return a TQString containing the network device's IPv6 netmask
+ */
+ TQString ipV6Netmask();
+
+ /**
+ * @return a TQString containing the network device's IPv4 broadcast
+ */
+ TQString ipV4Broadcast();
+
+ /**
+ * @return a TQString containing the network device's IPv6 broadcast
+ */
+ TQString ipV6Broadcast();
+
+ /**
+ * @return a TQString containing the network device's IPv4 destination
+ */
+ TQString ipV4Destination();
+
+ /**
+ * @return a TQString containing the network device's IPv6 destination
+ */
+ TQString ipV6Destination();
+
+ /**
+ * @return a double with the number of received bytes, if available
+ */
+ double rxBytes();
+
+ /**
+ * @return a double with the number of transmitted bytes, if available
+ */
+ double txBytes();
+
+ /**
+ * @return a double with the number of received packets, if available
+ */
+ double rxPackets();
+
+ /**
+ * @return a double with the number of transmitted packets, if available
+ */
+ double txPackets();
+
+ /**
+ * @return a pointer to a TDENetworkConnectionManager object, if available
+ */
+ TDENetworkConnectionManager* connectionManager();
+
+ protected:
+ /**
+ * @param ma a TQString containing the network device's MAC address
+ * @internal
+ */
+ void internalSetMacAddress(TQString ma);
+
+ /**
+ * @param st a TQString containing the network device's operational state
+ * @internal
+ */
+ void internalSetState(TQString st);
+
+ /**
+ * @param TRUE if carrier is present, FALSE if not
+ * @internal
+ */
+ void internalSetCarrierPresent(bool cp);
+
+ /**
+ * @param TRUE if device is dormant, FALSE if not
+ * @internal
+ */
+ void internalSetDormant(bool dm);
+
+ /**
+ * @param ad a TQString containing the network device's IPv4 address
+ * @internal
+ */
+ void internalSetIpV4Address(TQString ad);
+
+ /**
+ * @param ad a TQString containing the network device's IPv6 address
+ * @internal
+ */
+ void internalSetIpV6Address(TQString ad);
+
+ /**
+ * @param nm a TQString containing the network device's IPv4 netmask
+ * @internal
+ */
+ void internalSetIpV4Netmask(TQString nm);
+
+ /**
+ * @param nm a TQString containing the network device's IPv6 netmask
+ * @internal
+ */
+ void internalSetIpV6Netmask(TQString nm);
+
+ /**
+ * @param br a TQString containing the network device's IPv4 broadcast
+ * @internal
+ */
+ void internalSetIpV4Broadcast(TQString br);
+
+ /**
+ * @param br a TQString containing the network device's IPv6 broadcast
+ * @internal
+ */
+ void internalSetIpV6Broadcast(TQString br);
+
+ /**
+ * @param ds a TQString containing the network device's IPv4 destination
+ * @internal
+ */
+ void internalSetIpV4Destination(TQString ds);
+
+ /**
+ * @param ds a TQString containing the network device's IPv6 destination
+ * @internal
+ */
+ void internalSetIpV6Destination(TQString ds);
+
+ /**
+ * @param rx a double with the number of received bytes, if available
+ * @internal
+ */
+ void internalSetRxBytes(double rx);
+
+ /**
+ * @param tx a double with the number of transmitted bytes, if available
+ * @internal
+ */
+ void internalSetTxBytes(double tx);
+
+ /**
+ * @param rx a double with the number of received packets, if available
+ * @internal
+ */
+ void internalSetRxPackets(double rx);
+
+ /**
+ * @param tx a double with the number of transmitted packets, if available
+ * @internal
+ */
+ void internalSetTxPackets(double tx);
+
+ /**
+ * @param mgr a pointer to a TDENetworkConnectionManager object, if available
+ */
+ void internalSetConnectionManager(TDENetworkConnectionManager* mgr);
+
+ private:
+ TQString m_macAddress;
+ TQString m_state;
+ bool m_carrier;
+ bool m_dormant;
+ TQString m_ipV4Address;
+ TQString m_ipV6Address;
+ TQString m_ipV4Netmask;
+ TQString m_ipV6Netmask;
+ TQString m_ipV4Broadcast;
+ TQString m_ipV6Broadcast;
+ TQString m_ipV4Destination;
+ TQString m_ipV6Destination;
+ double m_rxbytes;
+ double m_txbytes;
+ double m_rxpackets;
+ double m_txpackets;
+ TDENetworkConnectionManager* m_connectionManager;
+
+ friend class TDEHardwareDevices;
+};
+
+namespace TDEDisplayPowerLevel {
+enum TDEDisplayPowerLevel {
+ On,
+ Standby,
+ Suspend,
+ Off
+};
+};
+
+class TDECORE_EXPORT TDEBacklightDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEBacklightDevice();
+
+ /**
+ * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ */
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
+
+ /**
+ * @return an integer with the number of discrete control steps available
+ */
+ int brightnessSteps();
+
+ /**
+ * @return a double with the current brightness percentage
+ */
+ double brightnessPercent();
+
+ /**
+ * @return TRUE if permissions allow brightness can be set, FALSE if not
+ */
+ bool canSetBrightness();
+
+ /**
+ * @return an int with the current raw brightness
+ */
+ int rawBrightness();
+
+ /**
+ * @param br an integer with the new raw brightness value
+ */
+ void setRawBrightness(int br);
+
+ protected:
+ /**
+ * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ * @internal
+ */
+ void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
+
+ /**
+ * @param br an integer with the maximum raw brightness value
+ * @internal
+ */
+ void internalSetMaximumRawBrightness(int br);
+
+ /**
+ * @param br an integer with the current raw brightness value
+ * @internal
+ */
+ void internalSetCurrentRawBrightness(int br);
+
+ private:
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
+ int m_currentBrightness;
+ int m_maximumBrightness;
+
+ friend class TDEHardwareDevices;
+};
+
+typedef TQPair<unsigned int, unsigned int> TDEResolutionPair;
+typedef TQValueList< TDEResolutionPair > TDEResolutionList;
+
+class TDECORE_EXPORT TDEMonitorDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEMonitorDevice();
+
+ /**
+ * @return TRUE if a monitor is connected, FALSE if not
+ */
+ bool connected();
+
+ /**
+ * @return TRUE if this port is enabled, FALSE if not
+ */
+ bool enabled();
+
+ /**
+ * @return a TQByteArray containing this monitor's EDID information
+ */
+ TQByteArray edid();
+
+ /**
+ * @return a TDEResolutionList containing this monitor's supported resolutions
+ */
+ TDEResolutionList resolutions();
+
+ /**
+ * @return a TQString containing the display port type
+ */
+ TQString portType();
+
+ /**
+ * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ */
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
+
+ protected:
+ /**
+ * @param TRUE if a monitor is connected, FALSE if not
+ * @internal
+ */
+ void internalSetConnected(bool cn);
+
+ /**
+ * @param TRUE if this port is enabled, FALSE if not
+ * @internal
+ */
+ void internalSetEnabled(bool en);
+
+ /**
+ * @param ed a TQByteArray containing this monitor's EDID information
+ * @internal
+ */
+ void internalSetEdid(TQByteArray ed);
+
+ /**
+ * @param rs a TDEResolutionList containing this monitor's supported resolutions
+ * @internal
+ */
+ void internalSetResolutions(TDEResolutionList rs);
+
+ /**
+ * @param pt a TQString containing the display port type
+ * @internal
+ */
+ void internalSetPortType(TQString pt);
+
+ /**
+ * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ * @internal
+ */
+ void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
+
+ private:
+ bool m_connected;
+ bool m_enabled;
+ TQByteArray m_edid;
+ TDEResolutionList m_resolutions;
+ TQString m_portType;
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
+
+ friend class TDEHardwareDevices;
+};
+
+
+typedef TQMap<TQString, TDESensorCluster> TDESensorClusterMap;
+
+class TDECORE_EXPORT TDESensorDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDESensorDevice();
+
+ /**
+ * @return a TDESensorClusterMap with the current sensor values
+ */
+ TDESensorClusterMap values();
+
+ protected:
+ /**
+ * @param a TDESensorClusterMap with the current sensor values
+ * @internal
+ */
+ void internalSetValues(TDESensorClusterMap cl);
+
+ private:
+ TDESensorClusterMap m_sensorValues;
+
+ friend class TDEHardwareDevices;
+};
+
+namespace TDESystemFormFactor {
+enum TDESystemFormFactor {
+ Unclassified,
+ Desktop,
+ Laptop,
+ Server,
+ Other = 0x80000000
+};
+};
+
+namespace TDESystemPowerState {
+enum TDESystemPowerState {
+ Active,
+ Standby,
+ Suspend,
+ Hibernate,
+ PowerOff,
+ Reboot
+};
+};
+
+namespace TDESystemHibernationMethod {
+enum TDESystemHibernationMethod {
+ Unsupported,
+ Platform,
+ Shutdown,
+ Reboot,
+ TestProc,
+ Test
+};
+};
+
+typedef TQValueList<TDESystemPowerState::TDESystemPowerState> TDESystemPowerStateList;
+typedef TQValueList<TDESystemHibernationMethod::TDESystemHibernationMethod> TDESystemHibernationMethodList;
+
+class TDECORE_EXPORT TDERootSystemDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDERootSystemDevice();
+
+ /**
+ * @return a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
+ */
+ TDESystemFormFactor::TDESystemFormFactor formFactor();
+
+ /**
+ * @return a TDESystemPowerStateList with all available power states
+ */
+ TDESystemPowerStateList powerStates();
+
+ /**
+ * @return a TDESystemHibernationMethodList with all available hibernation methods
+ */
+ TDESystemHibernationMethodList hibernationMethods();
+
+ /**
+ * @return a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
+ */
+ TDESystemHibernationMethod::TDESystemHibernationMethod hibernationMethod();
+
+ /**
+ * @return an unsigned long with the number of bytes required to hibernate
+ */
+ unsigned long diskSpaceNeededForHibernation();
+
+ /**
+ * @return TRUE if permissions allow the hibernation method to be set, FALSE if not
+ */
+ bool canSetHibernationMethod();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to enter standby, FALSE if not
+ */
+ bool canStandby();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to be suspended, FALSE if not
+ */
+ bool canSuspend();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to be hibernated, FALSE if not
+ */
+ bool canHibernate();
+
+ /**
+ * @return TRUE if permissions allow the system to be powered down, FALSE if not
+ */
+ bool canPowerOff();
+
+ /**
+ * @return TRUE if permissions allow the system to be rebooted, FALSE if not
+ */
+ bool canReboot();
+
+ /**
+ * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the desired hibernation method
+ */
+ void setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
+
+ /**
+ * @param ps a TDESystemPowerState::TDESystemPowerState with the desired power state
+ * @return TRUE if power state was set
+ */
+ bool setPowerState(TDESystemPowerState::TDESystemPowerState ps);
+
+ protected:
+ /**
+ * @param ff a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
+ * @internal
+ */
+ void internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff);
+
+ /**
+ * @param ps a TDESystemPowerStateList with all available power states
+ * @internal
+ */
+ void internalSetPowerStates(TDESystemPowerStateList ps);
+
+ /**
+ * @param hm a TDESystemHibernationMethodList with all available hibernation methods
+ * @internal
+ */
+ void internalSetHibernationMethods(TDESystemHibernationMethodList hm);
+
+ /**
+ * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
+ * @internal
+ */
+ void internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
+
+ /**
+ * @param sz an unsigned long with the number of bytes required to hibernate
+ * @internal
+ */
+ void internalSetDiskSpaceNeededForHibernation(unsigned long sz);
+
+ private:
+ TDESystemFormFactor::TDESystemFormFactor m_formFactor;
+ TDESystemPowerStateList m_powerStates;
+ TDESystemHibernationMethodList m_hibernationMethods;
+ TDESystemHibernationMethod::TDESystemHibernationMethod m_hibernationMethod;
+ unsigned long m_hibernationSpace;
+
+ friend class TDEHardwareDevices;
+};
+
+namespace TDEEventDeviceType {
+enum TDEEventDeviceType {
+ Unknown,
+ ACPILidSwitch,
+ ACPISleepButton,
+ ACPIPowerButton,
+ Other = 0x80000000
+};
+};
+
+// Keep friendlySwitchList() in tdehardwaredevices.cpp in sync with this enum
+namespace TDESwitchType {
+enum TDESwitchType {
+ Null = 0x00000000,
+ Lid = 0x00000001,
+ TabletMode = 0x00000002,
+ HeadphoneInsert = 0x00000004,
+ RFKill = 0x00000008,
+ Radio = 0x00000010,
+ MicrophoneInsert = 0x00000020,
+ Dock = 0x00000040,
+ LineOutInsert = 0x00000080,
+ JackPhysicalInsert = 0x00000100,
+ VideoOutInsert = 0x00000200,
+ CameraLensCover = 0x00000400,
+ KeypadSlide = 0x00000800,
+ FrontProximity = 0x00001000,
+ RotateLock = 0x00002000,
+ LineInInsert = 0x00004000
+};
+
+inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDESwitchType operator~(TDESwitchType a)
+{
+ return static_cast<TDESwitchType>(~static_cast<int>(a));
+}
+};
+
+class TQSocketNotifier;
+
+class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEEventDevice();
+
+ /**
+ * @return a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ */
+ TDEEventDeviceType::TDEEventDeviceType eventType();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all switches provided by this device
+ */
+ TDESwitchType::TDESwitchType providedSwitches();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all active switches provided by this device
+ */
+ TDESwitchType::TDESwitchType activeSwitches();
+
+ /**
+ * @param switches a TDESwitchType::TDESwitchType with any switch flags set
+ * @return a TQStringList with friendly names for all set switch flags
+ */
+ static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
+
+ protected:
+ /**
+ * @param et a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ * @internal
+ */
+ void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all switches provided by this device
+ * @internal
+ */
+ void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all active switches provided by this device
+ * @internal
+ */
+ void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param hwmanager the master hardware manager
+ * @internal
+ */
+ void internalStartFdMonitoring(TDEHardwareDevices* hwmanager);
+
+ protected slots:
+ void eventReceived();
+
+ signals:
+ /**
+ * @param keycode the code of the key that was pressed/released
+ * See include/linux/input.h for a complete list of keycodes
+ * @param device a TDEEventDevice* with the device that received the event
+ */
+ void keyPressed(unsigned int keycode, TDEEventDevice* device);
+
+ private:
+ TDEEventDeviceType::TDEEventDeviceType m_eventType;
+ TDESwitchType::TDESwitchType m_providedSwitches;
+ TDESwitchType::TDESwitchType m_switchActive;
+
+ int m_fd;
+ bool m_fdMonitorActive;
+ TQSocketNotifier* m_eventNotifier;
+
+ friend class TDEHardwareDevices;
+};
+
+namespace TDEInputDeviceType {
+enum TDEInputDeviceType {
+ Unknown,
+ ACPILidSwitch,
+ ACPISleepButton,
+ ACPIPowerButton,
+ Other = 0x80000000
+};
+};
+
+class TDECORE_EXPORT TDEInputDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEInputDevice();
+
+ /**
+ * @return a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
+ */
+ TDEInputDeviceType::TDEInputDeviceType inputType();
+
+ protected:
+ /**
+ * @param it a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
+ * @internal
+ */
+ void internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it);
+
+ private:
+ TDEInputDeviceType::TDEInputDeviceType m_inputType;
+
+ friend class TDEHardwareDevices;
+};
+
+typedef TQPtrList<TDEGenericDevice> TDEGenericHardwareList;
+typedef TQMap<TQString, TQString> TDEDeviceIDMap;
+
+class KSimpleDirWatch;
+
+class TDECORE_EXPORT TDEHardwareDevices : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ */
+ TDEHardwareDevices();
+
+ /**
+ * Destructor.
+ */
+ ~TDEHardwareDevices();
+
+ /**
+ * Query all hardware capabilities on all devices
+ * This does not normally need to be called by an application, as
+ * device detection is handled internally and automatically
+ *
+ * A call to this method immediately invalidates any TDEGenericHardwareList
+ * structures returned by listAllPhysicalDevices()
+ *
+ * @return TRUE if successful
+ */
+ bool queryHardwareInformation();
+
+ /**
+ * List all hardware capabilities on all devices
+ * @return TDEGenericHardwareList containing all known hardware devices
+ */
+ TDEGenericHardwareList listAllPhysicalDevices();
+
+ /**
+ * List all hardware capabilities on all devices
+ * @param a TDEGenericDeviceType::TDEGenericDeviceType specifying the device class
+ * @return TDEGenericHardwareList containing all known hardware devices
+ */
+ TDEGenericHardwareList listByDeviceClass(TDEGenericDeviceType::TDEGenericDeviceType cl);
+
+ /**
+ * Return the device with system path @arg syspath, or 0 if no device exists for that path
+ * @return TDEGenericDevice
+ */
+ TDEGenericDevice* findBySystemPath(TQString syspath);
+
+ /**
+ * Return the device with unique ID @arg uid, or 0 if no device exists for that uid
+ * @return TDEGenericDevice
+ */
+ TDEGenericDevice* findByUniqueID(TQString uid);
+
+ /**
+ * Return the device with device node @arg devnode, or 0 if no device exists at that node
+ * @return TDEGenericDevice
+ */
+ TDEGenericDevice* findByDeviceNode(TQString devnode);
+
+ /**
+ * Return the storage device with unique ID @arg uid, or 0 if no device exists for that uid
+ * @return TDEGenericDevice
+ */
+ TDEStorageDevice* findDiskByUID(TQString uid);
+
+ /**
+ * Look up the device in the system PCI database
+ * @param vendorid a TQString containing the vendor ID in hexadecimal
+ * @param modelid a TQString containing the model ID in hexadecimal
+ * @param subvendorid a TQString containing the subvendor ID in hexadecimal
+ * @param submodelid a TQString containing the submodel ID in hexadecimal
+ * @return a TQString containing the device name, if found
+ */
+ TQString findPCIDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid);
+
+ /**
+ * Look up the device in the system USB database
+ * @param vendorid a TQString containing the vendor ID in hexadecimal
+ * @param modelid a TQString containing the model ID in hexadecimal
+ * @param subvendorid a TQString containing the subvendor ID in hexadecimal
+ * @param submodelid a TQString containing the submodel ID in hexadecimal
+ * @return a TQString containing the device name, if found
+ */
+ TQString findUSBDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid);
+
+ /**
+ * Look up the device in the system PNP database
+ * @param pnpid a TQString containing the PNP ID
+ * @return a TQString containing the device name, if found
+ */
+ TQString findPNPDeviceName(TQString pnpid);
+
+ /**
+ * Look up the monitor manufacturer in the system display database
+ * @param pnpid a TQString containing the display manufacturer ID
+ * @return a TQString containing the manufacturer name, if found
+ */
+ TQString findMonitorManufacturerName(TQString dpyid);
+
+ /**
+ * Get a friendly string describing a device type
+ * @param query a TDEGenericDeviceType::TDEGenericDeviceType specifying a device type
+ * @return a TQString containing the friendly type name
+ */
+ TQString getFriendlyDeviceTypeStringFromType(TDEGenericDeviceType::TDEGenericDeviceType query);
+
+ /**
+ * Get an icon for a device type
+ * @param query a TDEGenericDeviceType::TDEGenericDeviceType specifying a device type
+ * @param size a TDEIcon::StdSizes structure specifying the desired icon size
+ * @return a TQPixmap containing the icon for the specified type
+ */
+ TQPixmap getDeviceTypeIconFromType(TDEGenericDeviceType::TDEGenericDeviceType query, TDEIcon::StdSizes size);
+
+ /**
+ * Convenience function to obtain the root system device
+ * @return a pointer to a TDERootSystemDevice object
+ */
+ TDERootSystemDevice* rootSystemDevice();
+
+ /**
+ * Rescan a hardware device to look for changes
+ * WARNING: This method can be very expensive. Use with caution!
+ * @param hwdevice TDEGenericDevice* with the device to rescan
+ */
+ void rescanDeviceInformation(TDEGenericDevice* hwdevice);
+
+ /**
+ * Rescan a hardware device to look for changes
+ * WARNING: This method can be very expensive. Use with caution!
+ * The computational expense can be reduced somewhat if the device tree structure
+ * has not changed by calling this method with regenerateDeviceTree = FALSE.
+ * @param hwdevice TDEGenericDevice* with the device to rescan
+ * @param regenerateDeviceTree TRUE to update parent/child links in device tree
+ */
+ void rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree);
+
+ /**
+ * Enable or disable automatic state updates of triggerless hardware devices
+ * such as CPUs and network cards. When enabled, your application will use
+ * additional CPU resources to continually poll triggerless hardware devices.
+ * Automatic updates are disabled by default.
+ * @param enable a bool specifiying whether or not automatic updates should be enabled
+ */
+ void setTriggerlessHardwareUpdatesEnabled(bool enable);
+
+ /**
+ * Convert a byte count to human readable form
+ * @param bytes a double containing the number of bytes
+ * @return a TQString containing the human readable byte count
+ */
+ static TQString bytesToFriendlySizeString(double bytes);
+
+ signals:
+ void hardwareAdded(TDEGenericDevice*);
+ void hardwareRemoved(TDEGenericDevice*);
+ void hardwareUpdated(TDEGenericDevice*);
+ void mountTableModified();
+ void hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString uuid);
+
+ /**
+ * @param keycode the code of the key that was pressed/released
+ * See include/linux/input.h for a complete list of keycodes
+ * @param device a TDEEventDevice* with the device that received the event
+ */
+ void eventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* device);
+
+ private slots:
+ void processHotPluggedHardware();
+ void processModifiedMounts();
+ void processModifiedCPUs();
+ void processStatelessDevices();
+ void processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice);
+
+ private:
+ void updateBlacklists(TDEGenericDevice* hwdevice, udev_device* dev);
+
+ private:
+ TDEGenericDevice *classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice=0, bool force_full_classification=true);
+ TDEGenericDevice *classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice=0, bool classifySubDevices=false);
+ void updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev=NULL);
+
+ void updateParentDeviceInformation();
+ void updateParentDeviceInformation(TDEGenericDevice* hwdevice);
+
+ void addCoreSystemDevices();
+
+ /**
+ * Get the binary monitor EDID for the specified sysfs path
+ * @return a TQByteArray containing the EDID
+ */
+ TQByteArray getEDID(TQString path);
+
+ /**
+ * Get the monitor EDID name for the specified sysfs path
+ * @return a TQPair<TQString,TQString> containing the monitor vendor and model, if available
+ */
+ TQPair<TQString,TQString> getEDIDMonitorName(TQString path);
+
+ struct udev *m_udevStruct;
+ struct udev_monitor *m_udevMonitorStruct;
+ TDEGenericHardwareList m_deviceList;
+ int m_procMountsFd;
+ KSimpleDirWatch* m_cpuWatch;
+ TQTimer* m_cpuWatchTimer;
+ TQTimer* m_deviceWatchTimer;
+
+ TQSocketNotifier* m_devScanNotifier;
+ TQSocketNotifier* m_mountScanNotifier;
+
+ TQStringList m_mountTable;
+ TQStringList m_cpuInfo;
+
+ TDEDeviceIDMap* pci_id_map;
+ TDEDeviceIDMap* usb_id_map;
+ TDEDeviceIDMap* pnp_id_map;
+ TDEDeviceIDMap* dpy_id_map;
+
+ friend class TDEGenericDevice;
+ friend class TDEStorageDevice;
+ friend class TDECPUDevice;
+};
+
+#endif // _TDEHARDWAREDEVICES_H
diff --git a/tdecore/tdehw/tdenetworkconnections.cpp b/tdecore/tdehw/tdenetworkconnections.cpp
new file mode 100644
index 000000000..6227b095f
--- /dev/null
+++ b/tdecore/tdehw/tdenetworkconnections.cpp
@@ -0,0 +1,1106 @@
+/* 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.
+*/
+
+#include "tdehardwaredevices.h"
+#include "tdenetworkconnections.h"
+
+#include "config.h"
+
+#include <tqtimer.h>
+
+#include <tdelocale.h>
+
+// #define DEBUG_SIGNAL_QUEUE 1
+
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+#include "networkbackends/network-manager/network-manager.h"
+#endif // WITH_NETWORK_MANAGER_BACKEND
+
+#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;
+ unsigned int internalMask = mask;
+ if (!ipv6) {
+ m_ipv4NetMask = 0;
+ for (i=31;i>=(32-internalMask);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-internalMask);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() {
+ if (!m_isValid) {
+ return false;
+ }
+
+ if (m_macAddress.count() > 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+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;
+ }
+}
+
+bool operator<(const TDEMACAddress &a1, const TDEMACAddress &a2) {
+ if (a1.m_macAddress.count() < a2.m_macAddress.count()) {
+ return true;
+ }
+ else {
+ unsigned int i;
+ for (i=0; i<a1.m_macAddress.count(); i++) {
+ if (a1.m_macAddress[i] < a2.m_macAddress[i]) {
+ return true;
+ }
+ if (a1.m_macAddress[i] > a2.m_macAddress[i]) {
+ return false;
+ }
+ }
+ return false;
+ }
+}
+
+/*================================================================================================*/
+/* 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;
+ allowedValid = false;
+ secretsValid = false;
+ type = TDENetworkIEEE8021xType::None;
+ fastProvisioningFlags = TDENetworkIEEE8021xFastFlags::None;
+ phase2NonEAPAuthMethod = TDENetworkIEEE8021xType::None;
+ phase2EAPAuthMethod = TDENetworkIEEE8021xType::None;
+ passwordFlags = TDENetworkPasswordHandlingFlags::None;
+ binaryPasswordFlags = TDENetworkPasswordHandlingFlags::None;
+ privateKeyPasswordFlags = TDENetworkPasswordHandlingFlags::None;
+ phase2PrivateKeyPasswordFlags = TDENetworkPasswordHandlingFlags::None;
+ forceSystemCaCertificates = false;
+}
+
+TDENetworkIEEE8021xConfiguration::~TDENetworkIEEE8021xConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkPPPConfiguration */
+/*================================================================================================*/
+
+TDENetworkPPPConfiguration::TDENetworkPPPConfiguration() {
+ valid = false;
+ requireServerAuthentication = false;
+ flags = TDENetworkPPPFlags::None;
+ baudRate = 115200;
+ mru = 0;
+ mtu = 0;
+ lcpEchoPingInterval = 0;
+ lcpEchoFailureThreshold = 0;
+}
+
+TDENetworkPPPConfiguration::~TDENetworkPPPConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkPPPOEConfiguration */
+/*================================================================================================*/
+
+TDENetworkPPPOEConfiguration::TDENetworkPPPOEConfiguration() {
+ valid = false;
+ secretsValid = false;
+ passwordFlags = TDENetworkPasswordHandlingFlags::None;
+}
+
+TDENetworkPPPOEConfiguration::~TDENetworkPPPOEConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkSerialConfiguration */
+/*================================================================================================*/
+
+TDENetworkSerialConfiguration::TDENetworkSerialConfiguration() {
+ valid = false;
+ baudRate = 115200;
+ byteWidth = 8;
+ parity = TDENetworkParity::None;
+ stopBits = 1;
+ txDelay = 0;
+}
+
+TDENetworkSerialConfiguration::~TDENetworkSerialConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkCDMAConfiguration */
+/*================================================================================================*/
+
+TDENetworkCDMAConfiguration::TDENetworkCDMAConfiguration() {
+ valid = false;
+ secretsValid = false;
+ passwordFlags = TDENetworkPasswordHandlingFlags::None;
+}
+
+TDENetworkCDMAConfiguration::~TDENetworkCDMAConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkGSMConfiguration */
+/*================================================================================================*/
+
+TDENetworkGSMConfiguration::TDENetworkGSMConfiguration() {
+ valid = false;
+ secretsValid = false;
+ passwordFlags = TDENetworkPasswordHandlingFlags::None;
+ networkType = TDEGSMNetworkType::Any;
+ pinFlags = TDENetworkPasswordHandlingFlags::None;
+ allowRoaming = false;
+}
+
+TDENetworkGSMConfiguration::~TDENetworkGSMConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkIPConfiguration */
+/*================================================================================================*/
+
+TDENetworkIPConfiguration::TDENetworkIPConfiguration() {
+ valid = false;
+ connectionFlags = TDENetworkIPConfigurationFlags::IPV4DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV4DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPIP | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPDNS | \
+ TDENetworkIPConfigurationFlags::IPV6DHCPRoutes | \
+ TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
+}
+
+TDENetworkIPConfiguration::~TDENetworkIPConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkWiFiSecurityConfiguration */
+/*================================================================================================*/
+
+TDENetworkWiFiSecurityConfiguration::TDENetworkWiFiSecurityConfiguration() {
+ valid = false;
+ secretsValid = false;
+ keyType = TDENetworkWiFiKeyType::Other;
+ authType = TDENetworkWiFiAuthType::Other;
+ wpaVersion = TDENetworkWiFiWPAVersionFlags::Any;
+ cipher = TDENetworkWiFiConnectionCipher::None;
+ wepKeyFlags = TDENetworkPasswordHandlingFlags::None;
+ wepKeyIndex = 0;
+ wepKeyType = TDENetworkWepKeyType::Hexadecimal;
+ pskFlags = TDENetworkPasswordHandlingFlags::None;
+ leapPasswordFlags = TDENetworkPasswordHandlingFlags::None;
+}
+
+TDENetworkWiFiSecurityConfiguration::~TDENetworkWiFiSecurityConfiguration() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkWiFiDeviceInfo */
+/*================================================================================================*/
+
+TDENetworkWiFiDeviceInfo::TDENetworkWiFiDeviceInfo() {
+ valid = false;
+}
+
+TDENetworkWiFiDeviceInfo::~TDENetworkWiFiDeviceInfo() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkDeviceInformation */
+/*================================================================================================*/
+
+TDENetworkDeviceInformation::TDENetworkDeviceInformation() {
+ valid = false;
+ statusFlags = TDENetworkConnectionStatus::Invalid;
+ capabilityFlags = TDENetworkDeviceCapabilityFlags::None;
+}
+
+TDENetworkDeviceInformation::~TDENetworkDeviceInformation() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkHWNeighbor */
+/*================================================================================================*/
+
+TDENetworkHWNeighbor::TDENetworkHWNeighbor() {
+ valid = false;
+}
+
+TDENetworkHWNeighbor::~TDENetworkHWNeighbor() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkWiFiAPInfo */
+/*================================================================================================*/
+
+TDENetworkWiFiAPInfo::TDENetworkWiFiAPInfo() : TDENetworkHWNeighbor() {
+ //
+}
+
+TDENetworkWiFiAPInfo::~TDENetworkWiFiAPInfo() {
+ //
+}
+
+TQString TDENetworkWiFiAPInfo::friendlySSID() const {
+ TQString ret;
+
+ ret = TQString(SSID);
+ if (ret == "") {
+ ret = "<" + i18n("hidden") + ">";
+ }
+
+ return ret;
+}
+
+/*================================================================================================*/
+/* TDENetworkConnection */
+/*================================================================================================*/
+
+TDENetworkConnection::TDENetworkConnection() {
+ readOnly = false;
+ autoConnect = false;
+ fullDuplex = true;
+ requireIPV4 = false;
+ requireIPV6 = false;
+ mtu = 0;
+}
+
+TDENetworkConnection::~TDENetworkConnection() {
+ //
+}
+
+TDENetworkConnectionType::TDENetworkConnectionType TDENetworkConnection::type() {
+ if (dynamic_cast<TDEWiredEthernetConnection*>(this)) {
+ return TDENetworkConnectionType::WiredEthernet;
+ }
+ else if (dynamic_cast<TDEWiredInfinibandConnection*>(this)) {
+ return TDENetworkConnectionType::Infiniband;
+ }
+ else if (dynamic_cast<TDEVPNConnection*>(this)) {
+ return TDENetworkConnectionType::VPN;
+ }
+ else if (dynamic_cast<TDEWiMaxConnection*>(this)) {
+ return TDENetworkConnectionType::WiMax;
+ }
+ else if (dynamic_cast<TDEVLANConnection*>(this)) {
+ return TDENetworkConnectionType::VLAN;
+ }
+ else if (dynamic_cast<TDEOLPCMeshConnection*>(this)) {
+ return TDENetworkConnectionType::OLPCMesh;
+ }
+ else if (dynamic_cast<TDEBluetoothConnection*>(this)) {
+ return TDENetworkConnectionType::Bluetooth;
+ }
+ else if (dynamic_cast<TDEModemConnection*>(this)) {
+ return TDENetworkConnectionType::Modem;
+ }
+ else if (dynamic_cast<TDEWiFiConnection*>(this)) {
+ return TDENetworkConnectionType::WiFi;
+ }
+ else {
+ return TDENetworkConnectionType::Other;
+ }
+}
+
+/*================================================================================================*/
+/* TDEWiredEthernetConnection */
+/*================================================================================================*/
+
+TDEWiredEthernetConnection::TDEWiredEthernetConnection() : TDENetworkConnection() {
+ //
+}
+
+TDEWiredEthernetConnection::~TDEWiredEthernetConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEWiredInfinibandConnection */
+/*================================================================================================*/
+
+TDEWiredInfinibandConnection::TDEWiredInfinibandConnection() : TDENetworkConnection() {
+ //
+}
+
+TDEWiredInfinibandConnection::~TDEWiredInfinibandConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEVPNConnection */
+/*================================================================================================*/
+
+TDEVPNConnection::TDEVPNConnection() : TDENetworkConnection() {
+ secretsValid = false;
+}
+
+TDEVPNConnection::~TDEVPNConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEWiMaxConnection */
+/*================================================================================================*/
+
+TDEWiMaxConnection::TDEWiMaxConnection() : TDENetworkConnection() {
+ //
+}
+
+TDEWiMaxConnection::~TDEWiMaxConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEVLANConnection */
+/*================================================================================================*/
+
+TDEVLANConnection::TDEVLANConnection() : TDENetworkConnection() {
+ //
+}
+
+TDEVLANConnection::~TDEVLANConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEOLPCMeshConnection */
+/*================================================================================================*/
+
+TDEOLPCMeshConnection::TDEOLPCMeshConnection() : TDENetworkConnection() {
+ channel = 0;
+}
+
+TDEOLPCMeshConnection::~TDEOLPCMeshConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEBluetoothConnection */
+/*================================================================================================*/
+
+TDEBluetoothConnection::TDEBluetoothConnection() : TDENetworkConnection() {
+ type = TDEBluetoothConnectionType::Other;
+}
+
+TDEBluetoothConnection::~TDEBluetoothConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEModemConnection */
+/*================================================================================================*/
+
+TDEModemConnection::TDEModemConnection() : TDENetworkConnection() {
+ type = TDEModemConnectionType::Other;
+}
+
+TDEModemConnection::~TDEModemConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDEWiFiConnection */
+/*================================================================================================*/
+
+TDEWiFiConnection::TDEWiFiConnection() : TDENetworkConnection() {
+ operatingMode = TDEWiFiMode::Other;
+ bandRestriction = TDEWiFiFrequencyBand::None;
+ channelRestriction = -1;
+ bitRateRestriction = -1;
+ powerRestriction = -1;
+ isHiddenNetwork = false;
+ securityRequired = false;
+}
+
+TDEWiFiConnection::~TDEWiFiConnection() {
+ //
+}
+
+/*================================================================================================*/
+/* TDENetworkConnectionManager */
+/*================================================================================================*/
+
+TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_hwNeighborList(NULL), m_macAddress(macAddress), m_prevConnectionStatus(TDENetworkGlobalManagerFlags::Unknown) {
+ m_emissionTimer = new TQTimer();
+ connect(m_emissionTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(emitQueuedSignals()));
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+TDENetworkConnectionManager::~TDENetworkConnectionManager() {
+ m_emissionTimer->stop();
+ delete m_emissionTimer;
+}
+
+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;
+}
+
+TDENetworkDevice* TDENetworkConnectionManager::findDeviceByUUID(TQString uuid) {
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ if (!hwdevices) return NULL;
+
+ TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
+ for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it)
+ {
+ TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
+ if (dev) {
+ TDENetworkConnectionManager* deviceConnectionManager = dev->connectionManager();
+ if (deviceConnectionManager) {
+ if (deviceConnectionManager->deviceInformation().UUID == uuid) {
+ return dev;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+TDENetworkWiFiAPInfo* TDENetworkConnectionManager::findAccessPointByBSSID(TDEMACAddress bssid) {
+ if (!bssid.isValid()) {
+ return NULL;
+ }
+
+ TDENetworkHWNeighbor *neighbor;
+ for (neighbor = m_hwNeighborList->first(); neighbor; neighbor = m_hwNeighborList->next()) {
+ TDENetworkWiFiAPInfo* apInfo = dynamic_cast<TDENetworkWiFiAPInfo*>(neighbor);
+ if (!apInfo) {
+ continue;
+ }
+ if (apInfo->BSSID == bssid) {
+ return apInfo;
+ }
+ }
+ return NULL;
+}
+
+TQString TDENetworkConnectionManager::friendlyConnectionTypeName(TDENetworkConnectionType::TDENetworkConnectionType type) {
+ if (type == TDENetworkConnectionType::WiredEthernet) {
+ return i18n("Wired Ethernet");
+ }
+ else if (type == TDENetworkConnectionType::WiFi) {
+ return i18n("802.11 WiFi");
+ }
+ else if (type == TDENetworkConnectionType::Bluetooth) {
+ return i18n("Bluetooth");
+ }
+ else if (type == TDENetworkConnectionType::OLPCMesh) {
+ return i18n("OLPC Mesh");
+ }
+ else if (type == TDENetworkConnectionType::WiMax) {
+ return i18n("WiMax");
+ }
+ else if (type == TDENetworkConnectionType::Modem) {
+ return i18n("Cellular Modem");
+ }
+ else if (type == TDENetworkConnectionType::Infiniband) {
+ return i18n("Infiniband");
+ }
+ else if (type == TDENetworkConnectionType::Bond) {
+ return i18n("Bond");
+ }
+ else if (type == TDENetworkConnectionType::VLAN) {
+ return i18n("Virtual LAN");
+ }
+ else if (type == TDENetworkConnectionType::ADSL) {
+ return i18n("ADSL");
+ }
+ else if (type == TDENetworkConnectionType::VPN) {
+ return i18n("Virtual Private Network");
+ }
+ else if (type == TDENetworkConnectionType::Other) {
+ return i18n("Other");
+ }
+ else {
+ return TQString::null;
+ }
+}
+
+bool TDENetworkConnectionManager::validateIPAddress(TQHostAddress address) {
+ if (address.isIPv4Address()) {
+ TQ_UINT32 rawaddress = address.toIPv4Address();
+ if ((((rawaddress & 0xff000000) >> 24) == 0) || ((rawaddress & 0x000000ff) == 0) || ((rawaddress & 0x000000ff) == 255)) {
+ return false;
+ }
+ }
+ else if (address.isIPv6Address()) {
+ Q_IPV6ADDR rawaddress = address.toIPv6Address();
+ if (rawaddress.c[0] == 0xff) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool TDENetworkConnectionManager::validateIPNeworkMask(TQHostAddress netmask) {
+ Q_UNUSED(netmask);
+ return TRUE;
+}
+
+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) {
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 0;
+ queuedEvent.newState = newState;
+ queuedEvent.previousState = m_prevConnectionStatus;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+
+ m_prevConnectionStatus = newState;
+}
+
+void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress) {
+ if (!m_prevDeviceStatus.contains(hwAddress)) {
+ m_prevDeviceStatus[hwAddress] = TDENetworkConnectionStatus::Invalid;
+ }
+
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 1;
+ queuedEvent.newConnStatus = newState;
+ queuedEvent.previousConnStatus = m_prevDeviceStatus[hwAddress];
+ queuedEvent.hwAddress = hwAddress;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+
+ m_prevDeviceStatus[hwAddress] = newState;
+}
+
+void TDENetworkConnectionManager::internalAccessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) {
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 2;
+ queuedEvent.BSSID = BSSID;
+ queuedEvent.apevent = event;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+void TDENetworkConnectionManager::internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message) {
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 3;
+ queuedEvent.ndevent = event;
+ queuedEvent.message = message;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+void TDENetworkConnectionManager::internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message) {
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 4;
+ queuedEvent.vpnevent = event;
+ queuedEvent.message = message;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) {
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 5;
+ queuedEvent.globalevent = event;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+void TDENetworkConnectionManager::emitQueuedSignals() {
+ if (!m_globalEventQueueEventList.isEmpty()) {
+#ifdef DEBUG_SIGNAL_QUEUE
+ kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: Going to dequeue " << m_globalEventQueueEventList.count() << " events..." << endl;
+#endif // DEBUG_SIGNAL_QUEUE
+ TDENetworkEventQueueEvent_PrivateList::Iterator it;
+ it = m_globalEventQueueEventList.begin();
+ while (it != m_globalEventQueueEventList.end()) {
+ TDENetworkEventQueueEvent_Private event = (*it);
+ it = m_globalEventQueueEventList.remove(it);
+ if (event.eventType == 0) {
+ emit(networkConnectionStateChanged(event.newState, event.previousState));
+ }
+ else if (event.eventType == 1) {
+ emit(networkDeviceStateChanged(event.newConnStatus, event.previousConnStatus, event.hwAddress));
+ }
+ else if (event.eventType == 2) {
+ emit(accessPointStatusChanged(event.BSSID, event.apevent));
+ }
+ else if (event.eventType == 3) {
+ emit(networkDeviceEvent(event.ndevent, event.message));
+ }
+ else if (event.eventType == 4) {
+ emit(vpnEvent(event.vpnevent, event.message));
+ }
+ else if (event.eventType == 5) {
+ emit(networkManagementEvent(event.globalevent));
+ }
+ }
+#ifdef DEBUG_SIGNAL_QUEUE
+ kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: " << m_globalEventQueueEventList.count() << " events remain in queue" << endl;
+#endif // DEBUG_SIGNAL_QUEUE
+ }
+}
+
+/*================================================================================================*/
+/* TDEGlobalNetworkManager */
+/*================================================================================================*/
+
+TDEGlobalNetworkManager::TDEGlobalNetworkManager() : m_internalConnectionManager(NULL) {
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+ m_internalConnectionManager = new TDENetworkConnectionManager_BackendNM(TQString::null);
+#endif // WITH_NETWORK_MANAGER_BACKEND
+ if (m_internalConnectionManager) {
+ connect(m_internalConnectionManager, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)));
+ connect(m_internalConnectionManager, SIGNAL(vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)), this, SIGNAL(vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)));
+ connect(m_internalConnectionManager, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)), this, SIGNAL(networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType)));
+ }
+}
+
+TDEGlobalNetworkManager::~TDEGlobalNetworkManager() {
+ delete m_internalConnectionManager;
+}
+
+TQString TDEGlobalNetworkManager::backendName() {
+ if (!m_internalConnectionManager) return TQString::null;
+ return m_internalConnectionManager->backendName();
+}
+
+TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags TDEGlobalNetworkManager::backendStatus() {
+ if (!m_internalConnectionManager) return TDENetworkGlobalManagerFlags::BackendUnavailable;
+ return m_internalConnectionManager->backendStatus();
+}
+
+void TDEGlobalNetworkManager::loadConnectionInformation() {
+ if (!m_internalConnectionManager) return;
+ return m_internalConnectionManager->loadConnectionInformation();
+}
+
+void TDEGlobalNetworkManager::loadConnectionAllowedValues(TDENetworkConnection* connection) {
+ if (!m_internalConnectionManager) return;
+ return m_internalConnectionManager->loadConnectionAllowedValues(connection);
+}
+
+bool TDEGlobalNetworkManager::loadConnectionSecrets(TQString uuid) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->loadConnectionSecrets(uuid);
+}
+
+bool TDEGlobalNetworkManager::saveConnection(TDENetworkConnection* connection) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->saveConnection(connection);
+}
+
+bool TDEGlobalNetworkManager::deleteConnection(TQString uuid) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->deleteConnection(uuid);
+}
+
+bool TDEGlobalNetworkManager::verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type, TDENetworkErrorStringMap* reason) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->verifyConnectionSettings(connection, type, reason);
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::initiateConnection(TQString uuid) {
+ if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid;
+ return m_internalConnectionManager->initiateConnection(uuid);
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::checkConnectionStatus(TQString uuid) {
+ if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid;
+ return m_internalConnectionManager->checkConnectionStatus(uuid);
+}
+
+TDENetworkConnectionStatus::TDENetworkConnectionStatus TDEGlobalNetworkManager::deactivateConnection(TQString uuid) {
+ if (!m_internalConnectionManager) return TDENetworkConnectionStatus::Invalid;
+ return m_internalConnectionManager->deactivateConnection(uuid);
+}
+
+TQStringList TDEGlobalNetworkManager::validSettings() {
+ if (!m_internalConnectionManager) return TQStringList();
+ return m_internalConnectionManager->validSettings();
+}
+
+TDENetworkHWNeighborList* TDEGlobalNetworkManager::siteSurvey() {
+ if (!m_internalConnectionManager) return NULL;
+ return m_internalConnectionManager->siteSurvey();
+}
+
+TQStringList TDEGlobalNetworkManager::connectionPhysicalDeviceUUIDs(TQString uuid) {
+ if (!m_internalConnectionManager) return TQStringList();
+ return m_internalConnectionManager->connectionPhysicalDeviceUUIDs(uuid);
+}
+
+TDENetworkVPNTypeList TDEGlobalNetworkManager::availableVPNTypes() {
+ if (!m_internalConnectionManager) return TDENetworkVPNTypeList();
+ return m_internalConnectionManager->availableVPNTypes();
+}
+
+bool TDEGlobalNetworkManager::networkingEnabled() {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->networkingEnabled();
+}
+
+bool TDEGlobalNetworkManager::enableNetworking(bool enable) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->enableNetworking(enable);
+}
+
+bool TDEGlobalNetworkManager::wiFiHardwareEnabled() {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->wiFiHardwareEnabled();
+}
+
+bool TDEGlobalNetworkManager::enableWiFi(bool enable) {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->enableWiFi(enable);
+}
+
+bool TDEGlobalNetworkManager::wiFiEnabled() {
+ if (!m_internalConnectionManager) return false;
+ return m_internalConnectionManager->wiFiEnabled();
+}
+
+TQStringList TDEGlobalNetworkManager::defaultNetworkDevices() {
+ if (!m_internalConnectionManager) return TQStringList();
+ return m_internalConnectionManager->defaultNetworkDevices();
+}
+
+TDENetworkConnectionList* TDEGlobalNetworkManager::connections() {
+ if (!m_internalConnectionManager) return NULL;
+ return m_internalConnectionManager->connections();
+}
+
+TDENetworkConnection* TDEGlobalNetworkManager::findConnectionByUUID(TQString uuid) {
+ if (!m_internalConnectionManager) return NULL;
+ return m_internalConnectionManager->findConnectionByUUID(uuid);
+}
+
+TDENetworkDevice* TDEGlobalNetworkManager::findDeviceByUUID(TQString uuid) {
+ if (!m_internalConnectionManager) return NULL;
+ return m_internalConnectionManager->findDeviceByUUID(uuid);
+}
+
+TDENetworkWiFiAPInfo* TDEGlobalNetworkManager::findAccessPointByBSSID(TDEMACAddress bssid) {
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ if (!hwdevices) {
+ return NULL;
+ }
+
+ TDENetworkWiFiAPInfo* ret = NULL;
+ TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
+ for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) {
+ TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
+ if (dev) {
+ TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ TDENetworkWiFiAPInfo* candidate = deviceConnMan->findAccessPointByBSSID(bssid);
+ if (candidate) {
+ ret = candidate;
+ }
+ }
+ }
+
+ return ret;
+}
+
+/*================================================================================================*/
+/* End */
+/*================================================================================================*/
+
+#include "tdenetworkconnections.moc" \ No newline at end of file
diff --git a/tdecore/tdehw/tdenetworkconnections.h b/tdecore/tdehw/tdenetworkconnections.h
new file mode 100644
index 000000000..b8425196a
--- /dev/null
+++ b/tdecore/tdehw/tdenetworkconnections.h
@@ -0,0 +1,1596 @@
+/* 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 _TDENETWORKCONNECTIONS_H
+#define _TDENETWORKCONNECTIONS_H
+
+// TDE includes
+#include <tqobject.h>
+#include <tqstring.h>
+#include <tqptrlist.h>
+#include <tqdatetime.h>
+#include <tqstringlist.h>
+#include <tqhostaddress.h>
+#include "kiconloader.h"
+#include "tdelibs_export.h"
+
+#define CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(x) \
+ inline x operator|(x a, x b) \
+ { \
+ return static_cast<x>(static_cast<int>(a) | static_cast<int>(b)); \
+ } \
+ \
+ inline x operator&(x a, x b) \
+ { \
+ return static_cast<x>(static_cast<int>(a) & static_cast<int>(b)); \
+ } \
+ \
+ 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; \
+ }
+
+class TDENetworkDevice;
+
+typedef TQValueList<TQ_UINT8> TDENetworkByteList;
+typedef TQValueList<TQHostAddress> TDENetworkAddressList;
+typedef TQMap<TQString, TQString> TDENetworkSettingsMap;
+typedef TQMap<TQ_UINT32, TQ_UINT32> TDENetworkPriorityMap;
+
+namespace TDENetworkDeviceType {
+ enum TDENetworkDeviceType {
+ BackendOnly,
+ WiredEthernet,
+ WiFi,
+ Bluetooth,
+ OLPCMesh,
+ WiMax,
+ Modem,
+ Infiniband,
+ Bond,
+ VLAN,
+ ADSL,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkConnectionType {
+ enum TDENetworkConnectionType {
+ WiredEthernet,
+ WiFi,
+ Bluetooth,
+ OLPCMesh,
+ WiMax,
+ Modem,
+ Infiniband,
+ Bond,
+ VLAN,
+ ADSL,
+ VPN,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkConnectionErrorFlags {
+ enum TDENetworkConnectionErrorFlags {
+ NoError = 0x00000000,
+ InvalidConnectionSetting = 0x00000001,
+ InvalidIPv4Setting = 0x00000002,
+ InvalidIPv6Setting = 0x00000004,
+ InvalidEAPSetting = 0x00000008,
+ InvalidEAPKey = 0x00000010,
+ InvalidWirelessSetting = 0x00000020,
+ InvalidWirelessKey = 0x00000040
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkConnectionErrorFlags)
+};
+
+typedef TQMap<TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags, TQString> TDENetworkErrorStringMap;
+
+namespace TDENetworkInfinibandTransportMode {
+ enum TDENetworkInfinibandTransportMode {
+ Datagram,
+ Connected,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDEWiFiMode {
+ enum TDEWiFiMode {
+ AdHoc,
+ Infrastructure,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDEWiFiFrequencyBand {
+ enum TDEWiFiFrequencyBand {
+ None,
+ Band2_4GHz,
+ Band5GHz,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDEBluetoothConnectionType {
+ enum TDEBluetoothConnectionType {
+ DUN,
+ PAN,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDEModemConnectionType {
+ enum TDEModemConnectionType {
+ CDMA,
+ GSM,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDEGSMNetworkType {
+ enum TDEGSMNetworkType {
+ Any,
+ Only3G,
+ GPRSEdge,
+ Prefer3G,
+ Prefer2G,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkParity {
+ enum TDENetworkParity {
+ None,
+ Even,
+ Odd,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkSlaveDeviceType {
+ enum TDENetworkSlaveDeviceType {
+ None,
+ Bond,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkGlobalEventType {
+ enum TDENetworkGlobalEventType {
+ ConnectionListChanged,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkVPNEventType {
+ enum TDENetworkVPNEventType {
+ LoginBanner,
+ Failure,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkDeviceEventType {
+ enum TDENetworkDeviceEventType {
+ BitRateChanged,
+ Failure,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkAPEventType {
+ enum TDENetworkAPEventType {
+ Discovered,
+ Lost,
+ SignalStrengthChanged,
+ AccessPointChanged,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkGlobalManagerFlags {
+ enum TDENetworkGlobalManagerFlags {
+ Unknown = 0x00000000,
+ Disconnected = 0x00000001,
+ Connected = 0x00000002,
+ EstablishingLink = 0x00000004,
+ DeactivatingLink = 0x00000008,
+ LinkLocalAccess = 0x00000010,
+ SiteLocalAccess = 0x00000020,
+ GlobalAccess = 0x00000040,
+ Sleeping = 0x00000080,
+ BackendUnavailable = 0x00000100,
+ VPNUnknown = 0x00000200,
+ VPNEstablishingLink = 0x00000400,
+ VPNNeedAuthorization = 0x00000800,
+ VPNConfiguringProtocols = 0x00001000,
+ VPNVerifyingProtocols = 0x00002000,
+ VPNConnected = 0x00004000,
+ VPNFailed = 0x00008000,
+ VPNDisconnected = 0x00010000,
+ GlobalMask = 0x000001ff,
+ VPNMask = 0x0001fe00
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkGlobalManagerFlags)
+};
+
+namespace TDENetworkDeviceCapabilityFlags {
+ enum TDENetworkDeviceCapabilityFlags {
+ None = 0x00000000,
+ Supported = 0x00000001,
+ CanDetectLink = 0x00000002
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkDeviceCapabilityFlags)
+};
+
+namespace TDENetworkPPPFlags {
+ enum TDENetworkPPPFlags {
+ None = 0x00000000,
+ DisableEAP = 0x00000001,
+ DisablePAP = 0x00000002,
+ DisableCHAP = 0x00000004,
+ DisableMSCHAP = 0x00000008,
+ DisableMSCHAPv2 = 0x00000010,
+ AllowBSDCompression = 0x00000020,
+ AllowDeflateCompression = 0x00000040,
+ AllowVJCompression = 0x00000080,
+ RequireMPPE = 0x00000100,
+ RequireMPPE128 = 0x00000200,
+ StatefulMPPE = 0x00000400,
+ UseHardwareFlowControl = 0x00000800
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkPPPFlags)
+};
+
+namespace TDENetworkWiFiAPFlags {
+ enum TDENetworkWiFiAPFlags {
+ None = 0x00000000,
+ PrivacySupport = 0x00000001,
+ PairWEP40 = 0x00000002,
+ PairWEP104 = 0x00000004,
+ PairTKIP = 0x00000008,
+ PairCCMP = 0x00000010,
+ GroupWEP40 = 0x00000020,
+ GroupWEP104 = 0x00000040,
+ GroupTKIP = 0x00000080,
+ GroupCCMP = 0x00000100,
+ KeyManagementPSK = 0x00000200,
+ KeyManagement80211 = 0x00000400,
+ GeneralFlagsMask = 0x00000001,
+ EncryptionFlagsMask = 0xfffffffe
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkWiFiAPFlags)
+};
+
+namespace TDENetworkWiFiClientFlags {
+ enum TDENetworkWiFiClientFlags {
+ None = 0x00000000,
+ CipherWEP40 = 0x00000002,
+ CipherWEP104 = 0x00000004,
+ CipherTKIP = 0x00000008,
+ CipherCCMP = 0x00000010,
+ CipherWPA = 0x00000020,
+ CipherRSN = 0x00000040
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkWiFiClientFlags)
+};
+
+namespace TDENetworkVPNType {
+ enum TDENetworkVPNType {
+ OpenVPN,
+ PPTP,
+ StrongSwan,
+ VPNC,
+ Other,
+ Last = Other
+ };
+};
+
+typedef TQValueList<TDENetworkVPNType::TDENetworkVPNType> TDENetworkVPNTypeList;
+
+namespace TDENetworkWiFiConnectionCipher {
+ enum TDENetworkWiFiConnectionCipher {
+ None,
+ CipherWEP40,
+ CipherWEP104,
+ CipherTKIP,
+ CipherCCMP,
+ CipherWPA,
+ CipherRSN,
+ Any
+ };
+};
+
+typedef TQValueList<TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher> TDENetworkWiFiConnectionCipherList;
+
+namespace TDENetworkWepKeyType {
+ enum TDENetworkWepKeyType {
+ Hexadecimal,
+ Ascii,
+ Passphrase
+ };
+};
+
+namespace TDENetworkVLANFlags {
+ enum TDENetworkVLANFlags {
+ None = 0x00000000,
+ ReorderPacketHeaders = 0x00000001,
+ UseGVRP = 0x00000002,
+ LooseBinding = 0x00000004
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkVLANFlags)
+};
+
+namespace TDENetworkWiFiKeyType {
+ enum TDENetworkWiFiKeyType {
+ WEP,
+ DynamicWEP,
+ WPAAdHoc,
+ WPAInfrastructure,
+ WPAEnterprise,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkWiFiAuthType {
+ enum TDENetworkWiFiAuthType {
+ Open,
+ Shared,
+ LEAP,
+ Other,
+ Last = Other
+ };
+};
+
+namespace TDENetworkIEEE8021xType {
+ enum TDENetworkIEEE8021xType {
+ None,
+ LEAP,
+ MD5,
+ PAP,
+ CHAP,
+ MSCHAP,
+ MSCHAPV2,
+ Fast,
+ PSK,
+ PAX,
+ SAKE,
+ GPSK,
+ TLS,
+ PEAP,
+ TTLS,
+ SIM,
+ GTC,
+ OTP
+ };
+};
+
+typedef TQValueList<TDENetworkIEEE8021xType::TDENetworkIEEE8021xType> TDENetworkIEEE8021xTypeList;
+
+namespace TDENetworkIEEE8021xFastFlags {
+ enum TDENetworkIEEE8021xFastFlags {
+ None = 0x00000000,
+ AllowUnauthenticated = 0x00000001,
+ AllowAuthenticated = 0x00000002
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkIEEE8021xFastFlags)
+};
+
+namespace TDENetworkWiFiWPAVersionFlags {
+ enum TDENetworkWiFiWPAVersionFlags {
+ None = 0x00000000,
+ WPA = 0x00000001,
+ RSN = 0x00000002,
+ Any = 0x00000003
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkWiFiWPAVersionFlags)
+};
+
+namespace TDENetworkPasswordHandlingFlags {
+ enum TDENetworkPasswordHandlingFlags {
+ None = 0x00000000,
+ NoSave = 0x00000001,
+ NoPrompt = 0x00000002,
+ ExternalStorage = 0x00000004
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkPasswordHandlingFlags)
+};
+
+namespace TDENetworkConnectionStatus {
+ enum TDENetworkConnectionStatus {
+ None = 0x00000000,
+ Invalid = 0x00000001,
+ Disconnected = 0x00000002,
+ Connected = 0x00000004,
+ LinkUnavailable = 0x00000008,
+ EstablishingLink = 0x00000010,
+ DeactivatingLink = 0x00000020,
+ ConfiguringProtocols = 0x00000040,
+ Reconnecting = 0x00000080,
+ LinkLost = 0x00000100,
+ LinkLocalAccess = 0x00000200,
+ SiteLocalAccess = 0x00000400,
+ GlobalAccess = 0x00000800,
+ UnManaged = 0x00001000,
+ NeedAuthorization = 0x00002000,
+ Failed = 0x00004000,
+ VerifyingProtocols = 0x00008000,
+ DependencyWait = 0x00010000
+ };
+
+ CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkConnectionStatus)
+};
+
+namespace TDENetworkIPConfigurationFlags {
+ enum TDENetworkIPConfigurationFlags {
+ 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);
+ friend bool operator<(const TDEMACAddress &a1, const TDEMACAddress &a2);
+};
+
+TDECORE_EXPORT bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2);
+TDECORE_EXPORT bool operator<(const TDEMACAddress &a1, const TDEMACAddress &a2);
+
+typedef TQValueList<TDEMACAddress> TDEMACAddressList;
+
+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 TDECORE_EXPORT TDENetworkIEEE8021xConfiguration
+{
+ public:
+ TDENetworkIEEE8021xConfiguration();
+ ~TDENetworkIEEE8021xConfiguration();
+
+ public:
+ bool valid;
+ bool allowedValid;
+ 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;
+ TDENetworkIEEE8021xType::TDENetworkIEEE8021xType phase2NonEAPAuthMethod;
+ TDENetworkIEEE8021xType::TDENetworkIEEE8021xType phase2EAPAuthMethod;
+ TDENetworkIEEE8021xTypeList allowedPhase2NonEAPMethods;
+ TDENetworkIEEE8021xTypeList allowedPhase2EAPMethods;
+ 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 TDENetworkPPPConfiguration
+{
+ public:
+ TDENetworkPPPConfiguration();
+ virtual ~TDENetworkPPPConfiguration();
+
+ public:
+ bool valid;
+ bool requireServerAuthentication;
+ TDENetworkPPPFlags::TDENetworkPPPFlags flags;
+ TQ_UINT32 baudRate;
+ TQ_UINT32 mru;
+ TQ_UINT32 mtu;
+ TQ_UINT32 lcpEchoPingInterval;
+ TQ_UINT32 lcpEchoFailureThreshold;
+};
+
+class TDECORE_EXPORT TDENetworkPPPOEConfiguration
+{
+ public:
+ TDENetworkPPPOEConfiguration();
+ virtual ~TDENetworkPPPOEConfiguration();
+
+ public:
+ bool valid;
+ bool secretsValid;
+ TQString networkServiceProvider;
+ TQString username;
+ TQString password;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags passwordFlags;
+};
+
+class TDECORE_EXPORT TDENetworkSerialConfiguration
+{
+ public:
+ TDENetworkSerialConfiguration();
+ virtual ~TDENetworkSerialConfiguration();
+
+ public:
+ bool valid;
+ TQ_UINT32 baudRate;
+ TQ_UINT32 byteWidth;
+ TDENetworkParity::TDENetworkParity parity;
+ TQ_UINT32 stopBits;
+ TQ_UINT64 txDelay;
+};
+
+class TDECORE_EXPORT TDENetworkCDMAConfiguration
+{
+ public:
+ TDENetworkCDMAConfiguration();
+ virtual ~TDENetworkCDMAConfiguration();
+
+ public:
+ bool valid;
+ bool secretsValid;
+ TQString providerDataNumber;
+ TQString username;
+ TQString password;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags passwordFlags;
+};
+
+class TDECORE_EXPORT TDENetworkGSMConfiguration
+{
+ public:
+ TDENetworkGSMConfiguration();
+ virtual ~TDENetworkGSMConfiguration();
+
+ public:
+ bool valid;
+ bool secretsValid;
+ TQString providerDataNumber;
+ TQString username;
+ TQString password;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags passwordFlags;
+ TQString accessPointName;
+ TQString networkID;
+ TDEGSMNetworkType::TDEGSMNetworkType networkType;
+ TQString pin;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags pinFlags;
+ TQ_UINT32 allowedFrequencyBands;
+ bool allowRoaming;
+};
+
+
+class TDENetworkWiFiSecurityConfiguration
+{
+ public:
+ TDENetworkWiFiSecurityConfiguration();
+ ~TDENetworkWiFiSecurityConfiguration();
+
+ public:
+ bool valid;
+ bool secretsValid;
+ TDENetworkWiFiKeyType::TDENetworkWiFiKeyType keyType;
+ TDENetworkWiFiAuthType::TDENetworkWiFiAuthType authType;
+ TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags wpaVersion;
+ TDENetworkWiFiConnectionCipher::TDENetworkWiFiConnectionCipher cipher;
+ TQString wepKey0;
+ TQString wepKey1;
+ TQString wepKey2;
+ TQString wepKey3;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags wepKeyFlags;
+ TQ_UINT32 wepKeyIndex;
+ TDENetworkWepKeyType::TDENetworkWepKeyType wepKeyType;
+ TDENetworkWiFiConnectionCipherList allowedPairWiseCiphers;
+ TDENetworkWiFiConnectionCipherList allowedGroupWiseCiphers;
+ TQString psk;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags pskFlags;
+ TQString leapUsername;
+ TQString leapPassword;
+ TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags leapPasswordFlags;
+};
+
+class TDECORE_EXPORT TDENetworkIPConfiguration
+{
+ public:
+ TDENetworkIPConfiguration();
+ ~TDENetworkIPConfiguration();
+
+ public:
+ bool valid;
+ TDENetworkIPConfigurationFlags::TDENetworkIPConfigurationFlags connectionFlags;
+ TDENetworkSingleIPConfigurationList ipConfigurations;
+ TDENetworkSingleRouteConfigurationList routeConfigurations;
+ TQHostAddress broadcast;
+ TQHostAddress destination;
+ TDENetworkAddressList resolvers;
+ TDENetworkSearchDomainList searchDomains;
+ TQString dhcpClientIdentifier;
+};
+
+class TDECORE_EXPORT TDENetworkWiFiDeviceInfo
+{
+ public:
+ TDENetworkWiFiDeviceInfo();
+ ~TDENetworkWiFiDeviceInfo();
+
+ public:
+ bool valid;
+ TDEMACAddress hwAddress;
+ TDEMACAddress permanentHWAddress;
+ TDEWiFiMode::TDEWiFiMode operatingMode;
+ unsigned int bitrate;
+ TDEMACAddress activeAccessPointBSSID;
+ TDENetworkWiFiClientFlags::TDENetworkWiFiClientFlags wirelessFlags;
+};
+
+class TDECORE_EXPORT TDENetworkDeviceInformation
+{
+ public:
+ TDENetworkDeviceInformation();
+ ~TDENetworkDeviceInformation();
+
+ public:
+ bool valid;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags;
+ TQString UUID;
+ TQString backendDriver;
+ TQString backendDriverVersion;
+ TQString firmwareVersion;
+ TDENetworkDeviceCapabilityFlags::TDENetworkDeviceCapabilityFlags capabilityFlags;
+ TDENetworkIPConfiguration ipConfiguration;
+ bool managed;
+ bool autoConnect;
+ bool firmwareMissing;
+ TDENetworkDeviceType::TDENetworkDeviceType deviceType;
+ TQString activeConnectionUUID;
+ TDENetworkWiFiDeviceInfo wiFiInfo;
+};
+
+class TDECORE_EXPORT TDENetworkHWNeighbor
+{
+ public:
+ TDENetworkHWNeighbor();
+ virtual ~TDENetworkHWNeighbor();
+
+ public:
+ bool valid;
+};
+
+class TDECORE_EXPORT TDENetworkWiFiAPInfo : public TDENetworkHWNeighbor
+{
+ public:
+ TDENetworkWiFiAPInfo();
+ virtual ~TDENetworkWiFiAPInfo();
+
+ public:
+ TQString friendlySSID() const;
+
+ public:
+ TQByteArray SSID;
+ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags wpaFlags;
+ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags rsnFlags;
+ unsigned int frequency;
+ TDEMACAddress BSSID;
+ unsigned int maxBitrate;
+ double signalQuality;
+};
+
+typedef TQPtrList< TDENetworkHWNeighbor > TDENetworkHWNeighborList;
+
+class TDECORE_EXPORT TDENetworkConnection
+{
+ public:
+ TDENetworkConnection();
+ virtual ~TDENetworkConnection();
+
+ public:
+ TDENetworkConnectionType::TDENetworkConnectionType type();
+
+ public:
+ TQString UUID;
+ TQString friendlyName;
+ TDENetworkIPConfiguration ipConfig;
+ TDEMACAddress lockedHWAddress;
+ TDEMACAddress manualHWAddress;
+ bool readOnly;
+ bool autoConnect;
+ bool fullDuplex;
+ bool requireIPV4;
+ bool requireIPV6;
+ TQ_UINT32 mtu;
+ TDENetworkIEEE8021xConfiguration eapConfig;
+ TDENetworkPPPConfiguration pppConfig;
+ TDENetworkPPPOEConfiguration pppoeConfig;
+ TDENetworkSerialConfiguration serialConfig;
+ TQStringList authorizedUsers;
+ TQString masterConnectionUUID;
+ TDENetworkSlaveDeviceType::TDENetworkSlaveDeviceType slaveType;
+ TQDateTime lastKnownConnection;
+};
+
+class TDECORE_EXPORT TDEWiredEthernetConnection : public TDENetworkConnection
+{
+ public:
+ TDEWiredEthernetConnection();
+ virtual ~TDEWiredEthernetConnection();
+};
+
+class TDECORE_EXPORT TDEWiFiConnection : public TDENetworkConnection
+{
+ public:
+ TDEWiFiConnection();
+ virtual ~TDEWiFiConnection();
+
+ public:
+ TQByteArray SSID;
+ TDEWiFiMode::TDEWiFiMode operatingMode;
+ TDEWiFiFrequencyBand::TDEWiFiFrequencyBand bandRestriction;
+ TQ_INT32 channelRestriction;
+ TQ_INT32 bitRateRestriction;
+ TQ_INT32 powerRestriction;
+ TDEMACAddress accessPointRestriction;
+ TDEMACAddressList blacklistedBSSIDs;
+ TDEMACAddressList heardBSSIDs;
+ bool isHiddenNetwork;
+ bool securityRequired;
+ TDENetworkWiFiSecurityConfiguration securitySettings;
+};
+
+class TDECORE_EXPORT TDEWiredInfinibandConnection : public TDENetworkConnection
+{
+ public:
+ TDEWiredInfinibandConnection();
+ virtual ~TDEWiredInfinibandConnection();
+
+ public:
+ TDENetworkInfinibandTransportMode::TDENetworkInfinibandTransportMode transportMode;
+};
+
+class TDECORE_EXPORT TDEVPNConnection : public TDENetworkConnection
+{
+ public:
+ TDEVPNConnection();
+ virtual ~TDEVPNConnection();
+
+ public:
+ TQString vpnPluginID;
+ TQString lockedUserName;
+ TDENetworkSettingsMap pluginData;
+ bool secretsValid;
+ TDENetworkSettingsMap pluginSecrets;
+};
+
+class TDECORE_EXPORT TDEWiMaxConnection : public TDENetworkConnection
+{
+ public:
+ TDEWiMaxConnection();
+ virtual ~TDEWiMaxConnection();
+
+ public:
+ TQString networkServiceProvider;
+};
+
+class TDECORE_EXPORT TDEVLANConnection : public TDENetworkConnection
+{
+ public:
+ TDEVLANConnection();
+ virtual ~TDEVLANConnection();
+
+ public:
+ TQString kernelName;
+ TQString parentConnectionUUID;
+ TQ_UINT32 vlanID;
+ TDENetworkVLANFlags::TDENetworkVLANFlags vlanFlags;
+ TDENetworkPriorityMap ingressPriorityMap;
+ TDENetworkPriorityMap egressPriorityMap;
+};
+
+class TDECORE_EXPORT TDEOLPCMeshConnection : public TDENetworkConnection
+{
+ public:
+ TDEOLPCMeshConnection();
+ virtual ~TDEOLPCMeshConnection();
+
+ public:
+ TQByteArray SSID;
+ TQ_INT32 channel;
+ TQByteArray anycastDHCPHWAddress;
+};
+
+class TDECORE_EXPORT TDEBluetoothConnection : public TDENetworkConnection
+{
+ public:
+ TDEBluetoothConnection();
+ virtual ~TDEBluetoothConnection();
+
+ public:
+ TDEBluetoothConnectionType::TDEBluetoothConnectionType type;
+};
+
+class TDECORE_EXPORT TDEModemConnection : public TDENetworkConnection
+{
+ public:
+ TDEModemConnection();
+ virtual ~TDEModemConnection();
+
+ public:
+ TDEModemConnectionType::TDEModemConnectionType type;
+ TDENetworkCDMAConfiguration cdmaConfig;
+ TDENetworkGSMConfiguration gsmConfig;
+};
+
+typedef TQPtrList< TDENetworkConnection > TDENetworkConnectionList;
+
+/**
+* INTERNAL CLASS
+*/
+class TDENetworkEventQueueEvent_Private
+{
+ public:
+ int eventType;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus newConnStatus;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus previousConnStatus;
+ TDEMACAddress BSSID;
+ TQString message;
+ TQString hwAddress;
+ TDENetworkAPEventType::TDENetworkAPEventType apevent;
+ TDENetworkDeviceEventType::TDENetworkDeviceEventType ndevent;
+ TDENetworkVPNEventType::TDENetworkVPNEventType vpnevent;
+ TDENetworkGlobalEventType::TDENetworkGlobalEventType globalevent;
+};
+typedef TQValueList<TDENetworkEventQueueEvent_Private> TDENetworkEventQueueEvent_PrivateList;
+
+class TQTimer;
+
+class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * 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 (TDENetworkDeviceType::BackendOnly).
+ */
+ TDENetworkConnectionManager(TQString macAddress);
+
+ /**
+ * Destructor.
+ */
+ ~TDENetworkConnectionManager();
+
+ /**
+ * @return a TQString containing the name of the backend in use
+ */
+ virtual TQString backendName() = 0;
+
+ /**
+ * @return the type of connection supported by this device
+ */
+ virtual TDENetworkDeviceType::TDENetworkDeviceType deviceType() = 0;
+
+ /**
+ * @return A TDENetworkGlobalManagerFlags enum value with the current status of the networking backend.
+ */
+ virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus() = 0;
+
+ /**
+ * @return A TDENetworkDeviceInformation object containing the current configuration and status of the network device.
+ */
+ virtual TDENetworkDeviceInformation deviceInformation() = 0;
+
+ /**
+ * @return A TDENetworkDeviceInformation object containing a (limited) current status of the network device.
+ * Only the following object fields are populated:
+ * statusFlags
+ * UUID
+ * activeConnectionUUID
+ * valid
+ */
+ virtual TDENetworkDeviceInformation deviceStatus() = 0;
+
+ /**
+ * 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 pointer to a TDENetworkConnection object containing a
+ * connection in which to load the values allowed by the backend.
+ * This is normally called as part of loadConnectionInformation(), but should
+ * manually be called immediately after creation of a new TDENetworkConnection object.
+ */
+ virtual void loadConnectionAllowedValues(TDENetworkConnection* connection) = 0;
+
+ /**
+ * @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;
+
+ /**
+ * @param uuid a TQString conntaining the UUID of a connection to
+ * delete from the configuration backend.
+ * @return true on success, false on failure.
+ */
+ virtual bool deleteConnection(TQString uuid) = 0;
+
+ /**
+ * @param connection a pointer to a TDENetworkConnection object containing a
+ * connection for which to verify integrity of all settings.
+ * @param type a pointer to an TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags
+ * which will be filled with the generic error type code if provided.
+ * @param reason a pointer to a TDENetworkErrorStringMap which will be filled with translated
+ * strings containing the reason for the failure if provided.
+ * @return true on success, false if invalid settings are detected.
+ */
+ virtual bool verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type=NULL, TDENetworkErrorStringMap* reason=NULL) = 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()
+ * Note that if this manager's type is not TDENetworkDeviceType::BackendOnly, the connection
+ * will be initiated on the internal device specified when this object was created
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid) = 0;
+
+ /**
+ * Checks the status of a connection with UUID @param uuid.
+ * @return A TDENetworkConnectionStatus enum value with the current connection status
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid) = 0;
+
+ /**
+ * Disconnects 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()
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid) = 0;
+
+ /**
+ * @return a TQStringList object containing all valid network settings
+ * Each string has the form "TDENetworkConfigObject::member"
+ * If a setting is not in this list, it is not supported by the backend in use
+ */
+ virtual TQStringList validSettings() = 0;
+
+ /**
+ * @return a TDENetworkHWNeighborList object containing the result of a site survey;
+ * i.e. all nearby access points or devices. This function only returns valid information
+ * if the underlying network device supports site surveys.
+ *
+ * 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
+ * siteSurvey().
+ */
+ virtual TDENetworkHWNeighborList* siteSurvey() = 0;
+
+ /**
+ * @return a TQStringList containing the UUIDs of all physical devices used by the connection
+ * with UUID @param uuid.
+ * This function may return an empty list if the connection is inactive, this behaviour is
+ * dependend on the specific network backend in use.
+ */
+ virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid) = 0;
+
+ /**
+ * @return a TDENetworkVPNTypeList object containing all supported VPN types
+ * If a type is not in this list, it is not supported by the backend in use
+ */
+ virtual TDENetworkVPNTypeList availableVPNTypes() = 0;
+
+ /**
+ * @return true if networking is enabled, false if not.
+ */
+ virtual bool networkingEnabled() = 0;
+
+ /**
+ * @param enable true to enable networking, false to disable it.
+ * @return true on success, false on failure.
+ */
+ virtual bool enableNetworking(bool enable) = 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;
+
+ /**
+ * @return a list of UUIDs of the default network devices, or an empty list if no such devices exist.
+ * The default network devices are normally the devices holding the highest priority default route.
+ */
+ virtual TQStringList defaultNetworkDevices() = 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);
+
+ /**
+ * Emitted whenever the status of a wireless access point changes
+ * The event type that caused the signal is available in @param event
+ */
+ void accessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event);
+
+ /**
+ * Emitted whenever a network device event occurs
+ * The event type that caused the signal is available in @param event
+ * @param message contains additional information if available
+ */
+ void networkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message);
+
+ /**
+ * Emitted whenever a VPN-related event occurs
+ * The event type that caused the signal is available in @param event
+ * @param message contains additional information if available
+ */
+ void vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
+ * Emitted whenever a global network management event occurs
+ * The event type that caused the signal is available in @param event
+ */
+ void networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event);
+
+ 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 the MAC address of this device
+ */
+ TQString deviceMACAddress();
+
+ /**
+ * @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);
+
+ /**
+ * @return a pointer to a TDENetworkDevice object with the specified @param uuid,
+ * or a NULL pointer if no such device exists.
+ *
+ * Note that the returned object is internally managed and must not be deleted!
+ */
+ TDENetworkDevice* findDeviceByUUID(TQString uuid);
+
+ /**
+ * @return a pointer to a TDENetworkWiFiAPInfo object with the specified @param bssid,
+ * or a NULL pointer if no such access point exists.
+ *
+ * Note that the returned object is internally managed and must not be deleted!
+ */
+ TDENetworkWiFiAPInfo* findAccessPointByBSSID(TDEMACAddress bssid);
+
+ /**
+ * @return a string containing the friendly name of the connection type @param type given
+ */
+ static TQString friendlyConnectionTypeName(TDENetworkConnectionType::TDENetworkConnectionType type);
+
+ /**
+ * @return true if @param address is valid, false if not
+ */
+ static bool validateIPAddress(TQHostAddress address);
+
+ /**
+ * @return true if @param netmask is valid, false if not
+ */
+ static bool validateIPNeworkMask(TQHostAddress netmask);
+
+ protected:
+ /**
+ * @internal Safely clears out the master connection list and deletes all member objects
+ */
+ void clearTDENetworkConnectionList();
+
+ /**
+ * @internal Safely clears out the neighboring devices list and deletes all member objects
+ */
+ void clearTDENetworkHWNeighborList();
+
+ /**
+ * @internal This method must be called by the network backend whenever a connection changes state
+ * It emits the appropriate signals to notify client applications of the state change
+ */
+ void internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState);
+
+ /**
+ * @internal This method must be called by the network backend whenever a device changes state
+ * It emits the appropriate signals to notify client applications of the state change
+ */
+ void internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress=TQString::null);
+
+ /**
+ * @internal This method must be called by the network backend whenever a wireless access point changes state
+ * It emits the appropriate signals to notify client applications of the state change
+ */
+ void internalAccessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event);
+
+ /**
+ * @internal This method must be called by the network backend whenever a device event occurs
+ * It emits the appropriate signals to notify client applications of the network device event
+ */
+ void internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message);
+
+ /**
+ * @internal This method must be called by the network backend whenever a VPN event occurs
+ * It emits the appropriate signals to notify client applications of the network device event
+ */
+ void internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
+ * @internal This method must be called by the network backend whenever it changes state
+ * It emits the appropriate signals to notify client applications of the state change
+ */
+ void internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event);
+
+ protected slots:
+ void emitQueuedSignals();
+
+ protected:
+ TDENetworkConnectionList* m_connectionList;
+ TDENetworkHWNeighborList* m_hwNeighborList;
+ TQString m_macAddress;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags m_prevConnectionStatus;
+ TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus;
+ TQTimer* m_emissionTimer;
+ TDENetworkEventQueueEvent_PrivateList m_globalEventQueueEventList;
+};
+
+class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ */
+ TDEGlobalNetworkManager();
+
+ /**
+ * Destructor.
+ */
+ ~TDEGlobalNetworkManager();
+
+ /**
+ * @return a TQString containing the name of the backend in use
+ */
+ virtual TQString backendName();
+
+ /**
+ * @return A TDENetworkGlobalManagerFlags enum value with the current status of the networking backend.
+ */
+ virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus();
+
+ /**
+ * 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();
+
+ /**
+ * @param connection a pointer to a TDENetworkConnection object containing a
+ * connection in which to load the values allowed by the backend.
+ * This is normally called as part of loadConnectionInformation(), but should
+ * manually be called immediately after creation of a new TDENetworkConnection object.
+ */
+ virtual void loadConnectionAllowedValues(TDENetworkConnection* connection);
+
+ /**
+ * @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);
+
+ /**
+ * @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);
+
+ /**
+ * @param uuid a TQString conntaining the UUID of a connection to
+ * delete from the configuration backend.
+ * @return true on success, false on failure.
+ */
+ virtual bool deleteConnection(TQString uuid);
+
+ /**
+ * @param connection a pointer to a TDENetworkConnection object containing a
+ * connection for which to verify integrity of all settings.
+ * @param type a pointer to an TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags
+ * which will be filled with the generic error type code if provided.
+ * @param reason a pointer to a TDENetworkErrorStringMap which will be filled with translated
+ * strings containing the reason for the failure if provided.
+ * @return true on success, false if invalid settings are detected.
+ */
+ virtual bool verifyConnectionSettings(TDENetworkConnection* connection, TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags* type=NULL, TDENetworkErrorStringMap* reason=NULL);
+
+ /**
+ * 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()
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid);
+
+ /**
+ * Checks the status of a connection with UUID @param uuid.
+ * @return A TDENetworkConnectionStatus enum value with the current connection status
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid);
+
+ /**
+ * Disconnects 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()
+ */
+ virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid);
+
+ /**
+ * @return a TQStringList object containing all valid network settings
+ * Each string has the form "TDENetworkConfigObject::member"
+ * If a setting is not in this list, it is not supported by the backend in use
+ */
+ virtual TQStringList validSettings();
+
+ /**
+ * @return a TDENetworkHWNeighborList object containing the result of a site survey;
+ * i.e. all nearby access points or devices. This function only returns valid information
+ * if the underlying network device supports site surveys.
+ *
+ * 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
+ * siteSurvey().
+ */
+ virtual TDENetworkHWNeighborList* siteSurvey();
+
+ /**
+ * @return a TQStringList containing the UUIDs of all physical devices used by the connection
+ * with UUID @param uuid.
+ * This function may return an empty list if the connection is inactive, this behaviour is
+ * dependend on the specific network backend in use.
+ */
+ virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid);
+
+ /**
+ * @return a TDENetworkVPNTypeList object containing all supported VPN types
+ * If a type is not in this list, it is not supported by the backend in use
+ */
+ virtual TDENetworkVPNTypeList availableVPNTypes();
+
+ /**
+ * @return true if networking is enabled, false if not.
+ */
+ virtual bool networkingEnabled();
+
+ /**
+ * @param enable true to enable networking, false to disable it.
+ * @return true on success, false on failure.
+ */
+ virtual bool enableNetworking(bool enable);
+
+ /**
+ * @return true if WiFi hardware is enabled, false if not.
+ */
+ virtual bool wiFiHardwareEnabled();
+
+ /**
+ * @param enable true to enable WiFi, false to disable it.
+ * @return true on success, false on failure.
+ */
+ virtual bool enableWiFi(bool enable);
+
+ /**
+ * @return true if WiFi is enabled, false if not.
+ */
+ virtual bool wiFiEnabled();
+
+ /**
+ * @return a list of UUIDs of the default network devices, or an empty list if no such devices exist.
+ * The default network devices are normally the devices holding the highest priority default route.
+ */
+ virtual TQStringList defaultNetworkDevices();
+
+ 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);
+
+ /**
+ * Emitted whenever the status of a wireless access point changes
+ * The event type that caused the signal is available in @param event
+ */
+ void accessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event);
+
+ /**
+ * Emitted whenever a VPN-related event occurs
+ * The event type that caused the signal is available in @param event
+ * @param message contains additional information if available
+ */
+ void vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
+
+ /**
+ * Emitted whenever a global network management event occurs
+ * The event type that caused the signal is available in @param event
+ */
+ void networkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event);
+
+ 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);
+
+ /**
+ * @return a pointer to a TDENetworkDevice object with the specified @param uuid,
+ * or a NULL pointer if no such device exists.
+ *
+ * Note that the returned object is internally managed and must not be deleted!
+ */
+ TDENetworkDevice* findDeviceByUUID(TQString uuid);
+
+ /**
+ * @return a pointer to a TDENetworkWiFiAPInfo object with the specified @param bssid,
+ * or a NULL pointer if no such access point exists.
+ *
+ * Note that the returned object is internally managed and must not be deleted!
+ */
+ TDENetworkWiFiAPInfo* findAccessPointByBSSID(TDEMACAddress bssid);
+
+ private:
+ TDENetworkConnectionManager* m_internalConnectionManager;
+};
+
+#endif // _TDENETWORKCONNECTIONS_H \ No newline at end of file