From 82102f3f7168b27e115f9f959bad75c99c1ae76a Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 6 Sep 2012 21:16:31 -0500 Subject: Rename files to something more sensible --- tdenetworkmanager/CMakeLists.txt | 2 +- tdenetworkmanager/knetworkmanager.conf | 63 -- tdenetworkmanager/pics/CMakeLists.txt | 4 +- .../pics/hi16-app-knetworkmanager.png | Bin 954 -> 0 bytes .../pics/hi16-app-knetworkmanager_disabled.png | Bin 650 -> 0 bytes tdenetworkmanager/pics/hi16-app-tdenetman.png | Bin 0 -> 954 bytes .../pics/hi16-app-tdenetman_disabled.png | Bin 0 -> 650 bytes .../pics/hi32-app-knetworkmanager.png | Bin 2636 -> 0 bytes .../pics/hi32-app-knetworkmanager_disabled.png | Bin 2202 -> 0 bytes tdenetworkmanager/pics/hi32-app-tdenetman.png | Bin 0 -> 2636 bytes .../pics/hi32-app-tdenetman_disabled.png | Bin 0 -> 2202 bytes .../pics/hi48-app-knetworkmanager.png | Bin 7282 -> 0 bytes .../pics/hi48-app-knetworkmanager_disabled.png | Bin 8390 -> 0 bytes tdenetworkmanager/pics/hi48-app-tdenetman.png | Bin 0 -> 7282 bytes .../pics/hi48-app-tdenetman_disabled.png | Bin 0 -> 8390 bytes tdenetworkmanager/src/CMakeLists.txt | 34 +- ...tworkmanager-connection_setting_cdma_widget.cpp | 93 -- ...networkmanager-connection_setting_cdma_widget.h | 67 -- ...etworkmanager-connection_setting_gsm_widget.cpp | 157 --- ...knetworkmanager-connection_setting_gsm_widget.h | 72 -- ...tworkmanager-connection_setting_info_widget.cpp | 77 -- ...networkmanager-connection_setting_info_widget.h | 68 -- ...tworkmanager-connection_setting_ipv4_widget.cpp | 209 ---- ...networkmanager-connection_setting_ipv4_widget.h | 68 -- ...etworkmanager-connection_setting_ppp_widget.cpp | 145 --- ...knetworkmanager-connection_setting_ppp_widget.h | 68 -- ...orkmanager-connection_setting_serial_widget.cpp | 134 --- ...tworkmanager-connection_setting_serial_widget.h | 71 -- ...etworkmanager-connection_setting_vpn_widget.cpp | 206 ---- ...knetworkmanager-connection_setting_vpn_widget.h | 69 -- ...manager-connection_setting_widget_interface.cpp | 37 - ...rkmanager-connection_setting_widget_interface.h | 47 - ...connection_setting_wireless_security_widget.cpp | 1029 -------------------- ...r-connection_setting_wireless_security_widget.h | 240 ----- ...kmanager-connection_setting_wireless_widget.cpp | 231 ----- ...orkmanager-connection_setting_wireless_widget.h | 74 -- .../knetworkmanager-connection_settings_dialog.cpp | 461 --------- .../knetworkmanager-connection_settings_dialog.h | 90 -- .../tdenetman-connection_setting_cdma_widget.cpp | 93 ++ .../tdenetman-connection_setting_cdma_widget.h | 67 ++ .../tdenetman-connection_setting_gsm_widget.cpp | 156 +++ .../tdenetman-connection_setting_gsm_widget.h | 71 ++ .../tdenetman-connection_setting_info_widget.cpp | 76 ++ .../tdenetman-connection_setting_info_widget.h | 68 ++ .../tdenetman-connection_setting_ipv4_widget.cpp | 208 ++++ .../tdenetman-connection_setting_ipv4_widget.h | 67 ++ .../tdenetman-connection_setting_ppp_widget.cpp | 143 +++ .../tdenetman-connection_setting_ppp_widget.h | 67 ++ .../tdenetman-connection_setting_serial_widget.cpp | 133 +++ .../tdenetman-connection_setting_serial_widget.h | 70 ++ .../tdenetman-connection_setting_vpn_widget.cpp | 206 ++++ .../tdenetman-connection_setting_vpn_widget.h | 69 ++ ...enetman-connection_setting_widget_interface.cpp | 37 + ...tdenetman-connection_setting_widget_interface.h | 47 + ...connection_setting_wireless_security_widget.cpp | 1029 ++++++++++++++++++++ ...n-connection_setting_wireless_security_widget.h | 240 +++++ ...denetman-connection_setting_wireless_widget.cpp | 230 +++++ .../tdenetman-connection_setting_wireless_widget.h | 74 ++ .../tdenetman-connection_settings_dialog.cpp | 461 +++++++++ .../tdenetman-connection_settings_dialog.h | 87 ++ .../src/knetworkmanager-cellular_device_tray.cpp | 130 --- .../src/knetworkmanager-cellular_device_tray.h | 55 -- .../src/knetworkmanager-connection_editor.cpp | 243 ----- .../src/knetworkmanager-connection_editor.h | 71 -- .../src/knetworkmanager-device_tray.cpp | 380 -------- .../src/knetworkmanager-device_tray.h | 88 -- .../src/knetworkmanager-menu_subhead.cpp | 76 -- .../src/knetworkmanager-menu_subhead.h | 56 -- tdenetworkmanager/src/knetworkmanager-menuitem.cpp | 123 --- tdenetworkmanager/src/knetworkmanager-menuitem.h | 57 -- .../src/knetworkmanager-nm_vpn_proxy.cpp | 81 -- .../src/knetworkmanager-nm_vpn_proxy.h | 52 - tdenetworkmanager/src/knetworkmanager-plugin.cpp | 38 - tdenetworkmanager/src/knetworkmanager-plugin.h | 39 - .../src/knetworkmanager-pluginmanager.cpp | 184 ---- .../src/knetworkmanager-pluginmanager.h | 67 -- tdenetworkmanager/src/knetworkmanager-tray.cpp | 766 --------------- tdenetworkmanager/src/knetworkmanager-tray.h | 135 --- .../src/knetworkmanager-vpn_plugin.cpp | 132 --- tdenetworkmanager/src/knetworkmanager-vpn_plugin.h | 62 -- .../knetworkmanager-vpnauthenticationdialog.cpp | 179 ---- .../src/knetworkmanager-vpnauthenticationdialog.h | 69 -- .../src/knetworkmanager-vpnmanager.cpp | 107 -- tdenetworkmanager/src/knetworkmanager-vpnmanager.h | 53 - .../src/knetworkmanager-vpnplugin.cpp | 128 --- tdenetworkmanager/src/knetworkmanager-vpnplugin.h | 79 -- .../src/knetworkmanager-vpnservice.cpp | 123 --- tdenetworkmanager/src/knetworkmanager-vpnservice.h | 63 -- .../src/knetworkmanager-wired_device_tray.cpp | 150 --- .../src/knetworkmanager-wired_device_tray.h | 57 -- .../src/knetworkmanager-wireless_device_tray.cpp | 417 -------- .../src/knetworkmanager-wireless_device_tray.h | 77 -- .../src/knetworkmanager-wireless_manager.cpp | 181 ---- .../src/knetworkmanager-wireless_manager.h | 60 -- .../src/knetworkmanager-wireless_menuitem.cpp | 228 ----- .../src/knetworkmanager-wireless_menuitem.h | 87 -- .../src/knetworkmanager-wireless_network.cpp | 174 ---- .../src/knetworkmanager-wireless_network.h | 92 -- tdenetworkmanager/src/knetworkmanager.cpp | 94 -- tdenetworkmanager/src/knetworkmanager.desktop | 47 - tdenetworkmanager/src/knetworkmanager.h | 57 -- tdenetworkmanager/src/knetworkmanager.la.cpp | 2 - tdenetworkmanager/src/knetworkmanager_dummy.cpp | 3 - .../src/knetworkmanager_plugin.desktop | 31 - .../src/knetworkmanager_vpnplugin.desktop | 33 - tdenetworkmanager/src/main.cpp | 2 +- tdenetworkmanager/src/settings.kcfgc | 2 +- .../knetworkmanager-connection_setting.cpp | 12 +- .../settings/knetworkmanager-connection_setting.h | 2 +- .../knetworkmanager-connection_setting_8021x.cpp | 14 +- .../knetworkmanager-connection_setting_8021x.h | 4 +- .../knetworkmanager-connection_setting_cdma.cpp | 10 +- .../knetworkmanager-connection_setting_cdma.h | 4 +- .../knetworkmanager-connection_setting_gsm.cpp | 10 +- .../knetworkmanager-connection_setting_gsm.h | 4 +- .../knetworkmanager-connection_setting_info.cpp | 10 +- .../knetworkmanager-connection_setting_info.h | 4 +- .../knetworkmanager-connection_setting_ipv4.cpp | 8 +- .../knetworkmanager-connection_setting_ipv4.h | 4 +- .../knetworkmanager-connection_setting_ppp.cpp | 10 +- .../knetworkmanager-connection_setting_ppp.h | 4 +- .../knetworkmanager-connection_setting_serial.cpp | 10 +- .../knetworkmanager-connection_setting_serial.h | 4 +- .../knetworkmanager-connection_setting_vpn.cpp | 8 +- .../knetworkmanager-connection_setting_vpn.h | 4 +- .../knetworkmanager-connection_setting_wired.cpp | 10 +- .../knetworkmanager-connection_setting_wired.h | 4 +- ...knetworkmanager-connection_setting_wireless.cpp | 12 +- .../knetworkmanager-connection_setting_wireless.h | 4 +- ...anager-connection_setting_wireless_security.cpp | 14 +- ...kmanager-connection_setting_wireless_security.h | 4 +- .../src/tdenetman-cellular_device_tray.cpp | 130 +++ .../src/tdenetman-cellular_device_tray.h | 55 ++ .../src/tdenetman-connection_editor.cpp | 242 +++++ .../src/tdenetman-connection_editor.h | 68 ++ tdenetworkmanager/src/tdenetman-device_tray.cpp | 379 +++++++ tdenetworkmanager/src/tdenetman-device_tray.h | 88 ++ tdenetworkmanager/src/tdenetman-menu_subhead.cpp | 76 ++ tdenetworkmanager/src/tdenetman-menu_subhead.h | 56 ++ tdenetworkmanager/src/tdenetman-menuitem.cpp | 123 +++ tdenetworkmanager/src/tdenetman-menuitem.h | 57 ++ tdenetworkmanager/src/tdenetman-nm_vpn_proxy.cpp | 81 ++ tdenetworkmanager/src/tdenetman-nm_vpn_proxy.h | 52 + tdenetworkmanager/src/tdenetman-plugin.cpp | 38 + tdenetworkmanager/src/tdenetman-plugin.h | 39 + tdenetworkmanager/src/tdenetman-pluginmanager.cpp | 184 ++++ tdenetworkmanager/src/tdenetman-pluginmanager.h | 67 ++ tdenetworkmanager/src/tdenetman-tray.cpp | 766 +++++++++++++++ tdenetworkmanager/src/tdenetman-tray.h | 135 +++ tdenetworkmanager/src/tdenetman-vpn_plugin.cpp | 132 +++ tdenetworkmanager/src/tdenetman-vpn_plugin.h | 62 ++ .../src/tdenetman-vpnauthenticationdialog.cpp | 179 ++++ .../src/tdenetman-vpnauthenticationdialog.h | 69 ++ tdenetworkmanager/src/tdenetman-vpnmanager.cpp | 107 ++ tdenetworkmanager/src/tdenetman-vpnmanager.h | 53 + tdenetworkmanager/src/tdenetman-vpnplugin.cpp | 128 +++ tdenetworkmanager/src/tdenetman-vpnplugin.h | 79 ++ tdenetworkmanager/src/tdenetman-vpnservice.cpp | 123 +++ tdenetworkmanager/src/tdenetman-vpnservice.h | 63 ++ .../src/tdenetman-wired_device_tray.cpp | 149 +++ .../src/tdenetman-wired_device_tray.h | 57 ++ .../src/tdenetman-wireless_device_tray.cpp | 417 ++++++++ .../src/tdenetman-wireless_device_tray.h | 77 ++ .../src/tdenetman-wireless_manager.cpp | 181 ++++ tdenetworkmanager/src/tdenetman-wireless_manager.h | 60 ++ .../src/tdenetman-wireless_menuitem.cpp | 227 +++++ .../src/tdenetman-wireless_menuitem.h | 87 ++ .../src/tdenetman-wireless_network.cpp | 174 ++++ tdenetworkmanager/src/tdenetman-wireless_network.h | 92 ++ tdenetworkmanager/src/tdenetman.cpp | 94 ++ tdenetworkmanager/src/tdenetman.h | 57 ++ tdenetworkmanager/src/tdenetman.la.cpp | 2 + tdenetworkmanager/src/tdenetman_dummy.cpp | 3 + tdenetworkmanager/src/tdenetworkmanager.desktop | 47 + .../src/tdenetworkmanager_plugin.desktop | 31 + .../src/tdenetworkmanager_vpnplugin.desktop | 33 + tdenetworkmanager/src/vpn_tray_component.cpp | 18 +- tdenetworkmanager/src/vpn_tray_component.h | 4 +- tdenetworkmanager/tdenetworkmanager.conf | 63 ++ 179 files changed, 9301 insertions(+), 9322 deletions(-) delete mode 100644 tdenetworkmanager/knetworkmanager.conf delete mode 100644 tdenetworkmanager/pics/hi16-app-knetworkmanager.png delete mode 100644 tdenetworkmanager/pics/hi16-app-knetworkmanager_disabled.png create mode 100644 tdenetworkmanager/pics/hi16-app-tdenetman.png create mode 100644 tdenetworkmanager/pics/hi16-app-tdenetman_disabled.png delete mode 100644 tdenetworkmanager/pics/hi32-app-knetworkmanager.png delete mode 100644 tdenetworkmanager/pics/hi32-app-knetworkmanager_disabled.png create mode 100644 tdenetworkmanager/pics/hi32-app-tdenetman.png create mode 100644 tdenetworkmanager/pics/hi32-app-tdenetman_disabled.png delete mode 100644 tdenetworkmanager/pics/hi48-app-knetworkmanager.png delete mode 100644 tdenetworkmanager/pics/hi48-app-knetworkmanager_disabled.png create mode 100644 tdenetworkmanager/pics/hi48-app-tdenetman.png create mode 100644 tdenetworkmanager/pics/hi48-app-tdenetman_disabled.png delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.h delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.cpp delete mode 100644 tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.h create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp create mode 100644 tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-cellular_device_tray.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-connection_editor.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-connection_editor.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-device_tray.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-device_tray.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-menu_subhead.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-menu_subhead.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-menuitem.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-menuitem.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-plugin.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-plugin.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-pluginmanager.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-pluginmanager.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-tray.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-tray.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpn_plugin.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpn_plugin.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnmanager.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnmanager.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnplugin.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnplugin.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnservice.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-vpnservice.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-wired_device_tray.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_device_tray.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_manager.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_network.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager-wireless_network.h delete mode 100644 tdenetworkmanager/src/knetworkmanager.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager.desktop delete mode 100644 tdenetworkmanager/src/knetworkmanager.h delete mode 100644 tdenetworkmanager/src/knetworkmanager.la.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager_dummy.cpp delete mode 100644 tdenetworkmanager/src/knetworkmanager_plugin.desktop delete mode 100644 tdenetworkmanager/src/knetworkmanager_vpnplugin.desktop create mode 100644 tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp create mode 100644 tdenetworkmanager/src/tdenetman-cellular_device_tray.h create mode 100644 tdenetworkmanager/src/tdenetman-connection_editor.cpp create mode 100644 tdenetworkmanager/src/tdenetman-connection_editor.h create mode 100644 tdenetworkmanager/src/tdenetman-device_tray.cpp create mode 100644 tdenetworkmanager/src/tdenetman-device_tray.h create mode 100644 tdenetworkmanager/src/tdenetman-menu_subhead.cpp create mode 100644 tdenetworkmanager/src/tdenetman-menu_subhead.h create mode 100644 tdenetworkmanager/src/tdenetman-menuitem.cpp create mode 100644 tdenetworkmanager/src/tdenetman-menuitem.h create mode 100644 tdenetworkmanager/src/tdenetman-nm_vpn_proxy.cpp create mode 100644 tdenetworkmanager/src/tdenetman-nm_vpn_proxy.h create mode 100644 tdenetworkmanager/src/tdenetman-plugin.cpp create mode 100644 tdenetworkmanager/src/tdenetman-plugin.h create mode 100644 tdenetworkmanager/src/tdenetman-pluginmanager.cpp create mode 100644 tdenetworkmanager/src/tdenetman-pluginmanager.h create mode 100644 tdenetworkmanager/src/tdenetman-tray.cpp create mode 100644 tdenetworkmanager/src/tdenetman-tray.h create mode 100644 tdenetworkmanager/src/tdenetman-vpn_plugin.cpp create mode 100644 tdenetworkmanager/src/tdenetman-vpn_plugin.h create mode 100644 tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.cpp create mode 100644 tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.h create mode 100644 tdenetworkmanager/src/tdenetman-vpnmanager.cpp create mode 100644 tdenetworkmanager/src/tdenetman-vpnmanager.h create mode 100644 tdenetworkmanager/src/tdenetman-vpnplugin.cpp create mode 100644 tdenetworkmanager/src/tdenetman-vpnplugin.h create mode 100644 tdenetworkmanager/src/tdenetman-vpnservice.cpp create mode 100644 tdenetworkmanager/src/tdenetman-vpnservice.h create mode 100644 tdenetworkmanager/src/tdenetman-wired_device_tray.cpp create mode 100644 tdenetworkmanager/src/tdenetman-wired_device_tray.h create mode 100644 tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp create mode 100644 tdenetworkmanager/src/tdenetman-wireless_device_tray.h create mode 100644 tdenetworkmanager/src/tdenetman-wireless_manager.cpp create mode 100644 tdenetworkmanager/src/tdenetman-wireless_manager.h create mode 100644 tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp create mode 100644 tdenetworkmanager/src/tdenetman-wireless_menuitem.h create mode 100644 tdenetworkmanager/src/tdenetman-wireless_network.cpp create mode 100644 tdenetworkmanager/src/tdenetman-wireless_network.h create mode 100644 tdenetworkmanager/src/tdenetman.cpp create mode 100644 tdenetworkmanager/src/tdenetman.h create mode 100644 tdenetworkmanager/src/tdenetman.la.cpp create mode 100644 tdenetworkmanager/src/tdenetman_dummy.cpp create mode 100644 tdenetworkmanager/src/tdenetworkmanager.desktop create mode 100644 tdenetworkmanager/src/tdenetworkmanager_plugin.desktop create mode 100644 tdenetworkmanager/src/tdenetworkmanager_vpnplugin.desktop create mode 100644 tdenetworkmanager/tdenetworkmanager.conf diff --git a/tdenetworkmanager/CMakeLists.txt b/tdenetworkmanager/CMakeLists.txt index 119a77e..1938a55 100644 --- a/tdenetworkmanager/CMakeLists.txt +++ b/tdenetworkmanager/CMakeLists.txt @@ -14,4 +14,4 @@ add_subdirectory( src ) # add_subdirectory( vpn-plugins ) # add_subdirectory( po ) -install( FILES knetworkmanager.conf DESTINATION ${DBUS_SYS_DIR} ) +install( FILES tdenetworkmanager.conf DESTINATION ${DBUS_SYS_DIR} ) diff --git a/tdenetworkmanager/knetworkmanager.conf b/tdenetworkmanager/knetworkmanager.conf deleted file mode 100644 index 82a596f..0000000 --- a/tdenetworkmanager/knetworkmanager.conf +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tdenetworkmanager/pics/CMakeLists.txt b/tdenetworkmanager/pics/CMakeLists.txt index 44de539..edb9979 100644 --- a/tdenetworkmanager/pics/CMakeLists.txt +++ b/tdenetworkmanager/pics/CMakeLists.txt @@ -9,5 +9,5 @@ # ################################################# -tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/knetworkmanager/icons ) -tde_install_icons( knetworkmanager knetworkmanager_disabled ) +tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/tdenetworkmanager/icons ) +tde_install_icons( tdenetworkmanager tdenetworkmanager_disabled ) diff --git a/tdenetworkmanager/pics/hi16-app-knetworkmanager.png b/tdenetworkmanager/pics/hi16-app-knetworkmanager.png deleted file mode 100644 index db29bb8..0000000 Binary files a/tdenetworkmanager/pics/hi16-app-knetworkmanager.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi16-app-knetworkmanager_disabled.png b/tdenetworkmanager/pics/hi16-app-knetworkmanager_disabled.png deleted file mode 100644 index 971f7e3..0000000 Binary files a/tdenetworkmanager/pics/hi16-app-knetworkmanager_disabled.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi16-app-tdenetman.png b/tdenetworkmanager/pics/hi16-app-tdenetman.png new file mode 100644 index 0000000..db29bb8 Binary files /dev/null and b/tdenetworkmanager/pics/hi16-app-tdenetman.png differ diff --git a/tdenetworkmanager/pics/hi16-app-tdenetman_disabled.png b/tdenetworkmanager/pics/hi16-app-tdenetman_disabled.png new file mode 100644 index 0000000..971f7e3 Binary files /dev/null and b/tdenetworkmanager/pics/hi16-app-tdenetman_disabled.png differ diff --git a/tdenetworkmanager/pics/hi32-app-knetworkmanager.png b/tdenetworkmanager/pics/hi32-app-knetworkmanager.png deleted file mode 100644 index 5e98e9c..0000000 Binary files a/tdenetworkmanager/pics/hi32-app-knetworkmanager.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi32-app-knetworkmanager_disabled.png b/tdenetworkmanager/pics/hi32-app-knetworkmanager_disabled.png deleted file mode 100644 index a9ed5f9..0000000 Binary files a/tdenetworkmanager/pics/hi32-app-knetworkmanager_disabled.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi32-app-tdenetman.png b/tdenetworkmanager/pics/hi32-app-tdenetman.png new file mode 100644 index 0000000..5e98e9c Binary files /dev/null and b/tdenetworkmanager/pics/hi32-app-tdenetman.png differ diff --git a/tdenetworkmanager/pics/hi32-app-tdenetman_disabled.png b/tdenetworkmanager/pics/hi32-app-tdenetman_disabled.png new file mode 100644 index 0000000..a9ed5f9 Binary files /dev/null and b/tdenetworkmanager/pics/hi32-app-tdenetman_disabled.png differ diff --git a/tdenetworkmanager/pics/hi48-app-knetworkmanager.png b/tdenetworkmanager/pics/hi48-app-knetworkmanager.png deleted file mode 100644 index 8306829..0000000 Binary files a/tdenetworkmanager/pics/hi48-app-knetworkmanager.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi48-app-knetworkmanager_disabled.png b/tdenetworkmanager/pics/hi48-app-knetworkmanager_disabled.png deleted file mode 100644 index 53eafb4..0000000 Binary files a/tdenetworkmanager/pics/hi48-app-knetworkmanager_disabled.png and /dev/null differ diff --git a/tdenetworkmanager/pics/hi48-app-tdenetman.png b/tdenetworkmanager/pics/hi48-app-tdenetman.png new file mode 100644 index 0000000..8306829 Binary files /dev/null and b/tdenetworkmanager/pics/hi48-app-tdenetman.png differ diff --git a/tdenetworkmanager/pics/hi48-app-tdenetman_disabled.png b/tdenetworkmanager/pics/hi48-app-tdenetman_disabled.png new file mode 100644 index 0000000..53eafb4 Binary files /dev/null and b/tdenetworkmanager/pics/hi48-app-tdenetman_disabled.png differ diff --git a/tdenetworkmanager/src/CMakeLists.txt b/tdenetworkmanager/src/CMakeLists.txt index aa06061..28fa0f8 100644 --- a/tdenetworkmanager/src/CMakeLists.txt +++ b/tdenetworkmanager/src/CMakeLists.txt @@ -33,35 +33,35 @@ link_directories( ##### headers ################################### install( FILES - knetworkmanager-plugin.h knetworkmanager-vpnplugin.h + tdenetman-plugin.h tdenetman-vpnplugin.h DESTINATION ${INCLUDE_INSTALL_DIR} ) ##### other data ################################ -install( FILES knetworkmanager.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) -install( FILES eventsrc DESTINATION ${DATA_INSTALL_DIR}/knetworkmanager ) -install( FILES knetworkmanager_plugin.desktop knetworkmanager_vpnplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) +install( FILES tdenetworkmanager.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install( FILES eventsrc DESTINATION ${DATA_INSTALL_DIR}/tdenetworkmanager ) +install( FILES tdenetworkmanager_plugin.desktop tdenetworkmanager_vpnplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) -##### knetworkmanager (tdeinit) ################# +##### tdenetman (tdeinit) ################# -tde_add_tdeinit_executable( knetworkmanager AUTOMOC +tde_add_tdeinit_executable( tdenetman AUTOMOC SOURCES connection_editor.ui - vpnauthentication.ui main.cpp knetworkmanager.cpp knetworkmanager-tray.cpp - #knetworkmanager-vpn_plugin.cpp - knetworkmanager-cellular_device_tray.cpp knetworkmanager-device_tray.cpp - knetworkmanager-wired_device_tray.cpp knetworkmanager-wireless_device_tray.cpp - knetworkmanager-wireless_menuitem.cpp knetworkmanager-menuitem.cpp - knetworkmanager-menu_subhead.cpp + vpnauthentication.ui main.cpp tdenetman.cpp tdenetman-tray.cpp + #tdenetman-vpn_plugin.cpp + tdenetman-cellular_device_tray.cpp tdenetman-device_tray.cpp + tdenetman-wired_device_tray.cpp tdenetman-wireless_device_tray.cpp + tdenetman-wireless_menuitem.cpp tdenetman-menuitem.cpp + tdenetman-menu_subhead.cpp sha1.cpp md5.cpp - knetworkmanager-wireless_network.cpp knetworkmanager-wireless_manager.cpp - knetworkmanager-connection_editor.cpp + tdenetman-wireless_network.cpp tdenetman-wireless_manager.cpp + tdenetman-connection_editor.cpp devicetraycomponent.cpp traycomponent.cpp - #knetworkmanager-plugin.cpp knetworkmanager-vpnplugin.cpp - #knetworkmanager-pluginmanager.cpp knetworkmanager-vpnservice.cpp knetworkmanager-vpnmanager.cpp - #knetworkmanager-vpnauthenticationdialog.cpp + #tdenetman-plugin.cpp tdenetman-vpnplugin.cpp + #tdenetman-pluginmanager.cpp tdenetman-vpnservice.cpp tdenetman-vpnmanager.cpp + #tdenetman-vpnauthenticationdialog.cpp #vpn_tray_component.cpp EMBED tdenetwork-connection-configwidgets-static #tdenetwork-connection-settings-static LINK tdecore-shared tdeui-shared kutils-shared ${DBUS_TQT_LIBRARIES} diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.cpp deleted file mode 100644 index 09b9ed3..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_cdma_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_cdma_widget.h" - -// ui headers -#include "connection_setting_cdma.h" - -using namespace ConnectionSettings; - -CDMAWidgetImpl::CDMAWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _cdmasetting = dynamic_cast(conn); - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingCdmaWidget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -CDMAWidgetImpl::Init() -{ - if (_cdmasetting->cdmaConfig.valid) { - _mainWid->mUsername->setText( _cdmasetting->cdmaConfig.username ); - _mainWid->mNumber->setText( _cdmasetting->cdmaConfig.providerDataNumber ); - if (_cdmasetting->cdmaConfig.secretsValid) { - _mainWid->mPassword->setText( _cdmasetting->cdmaConfig.password ); - } - } - connect( _mainWid->mUsername, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mPassword, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mNumber, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); -} - -void -CDMAWidgetImpl::Deactivate() -{ -} - -void -CDMAWidgetImpl::Activate() -{ - -} - -void -CDMAWidgetImpl::dirty() -{ - _cdmasetting->cdmaConfig.username = _mainWid->mUsername->text(); - _cdmasetting->cdmaConfig.password = _mainWid->mPassword->text(); - _cdmasetting->cdmaConfig.providerDataNumber = _mainWid->mNumber->text(); - _cdmasetting->cdmaConfig.valid = true; - _cdmasetting->cdmaConfig.secretsValid = true; -} - - -#include "knetworkmanager-connection_setting_cdma_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.h deleted file mode 100644 index 0cbbfee..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_cdma_widget.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_cdma_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H - - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_widget_interface.h" - -//class VPNService; -class ConnectionSettingCdmaWidget; - -namespace ConnectionSettings -{ - -class CDMAWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - CDMAWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - void Deactivate(); - public slots: - void dirty(); - - private: - void Init(); - //VPNConfigWidget* getVPNConfigWidget(VPNService* service); - - - TDEModemConnection* _cdmasetting; - ConnectionSettingCdmaWidget* _mainWid; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.cpp deleted file mode 100644 index 36a9a57..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_gsm_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_gsm.h" -#include "knetworkmanager-connection_setting_gsm_widget.h" - -#include "connection_setting_gsm.h" - -using namespace ConnectionSettings; - -GSMWidgetImpl::GSMWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _gsmsetting = dynamic_cast(conn); - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingGsmWidget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -GSMWidgetImpl::Init() -{ - if (_gsmsetting->gsmConfig.valid) { - _mainWid->mUsername->setText( _gsmsetting->gsmConfig.username ); - _mainWid->mNumber->setText( _gsmsetting->gsmConfig.providerDataNumber ); - _mainWid->mApn->setText( _gsmsetting->gsmConfig.accessPointName ); - _mainWid->mNetworkId->setText( _gsmsetting->gsmConfig.networkID ); - setNetworkType( _gsmsetting->gsmConfig.networkType ); - _mainWid->mBand->setValue( _gsmsetting->gsmConfig.allowedFrequencyBands ); - if (_gsmsetting->gsmConfig.secretsValid) { - _mainWid->mPassword->setText( _gsmsetting->gsmConfig.password ); - _mainWid->mPin->setText( _gsmsetting->gsmConfig.pin ); - } - } - - connect( _mainWid->mUsername, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mPassword, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mPin, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mNumber, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mApn, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mNetworkId, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); - connect( _mainWid->mNetworkType, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); - connect( _mainWid->mBand, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); -} - -void -GSMWidgetImpl::Deactivate() -{ -} - -void -GSMWidgetImpl::Activate() -{ - -} - -void -GSMWidgetImpl::dirty() -{ - _gsmsetting->gsmConfig.username = _mainWid->mUsername->text(); - _gsmsetting->gsmConfig.password = _mainWid->mPassword->text(); - _gsmsetting->gsmConfig.pin = _mainWid->mPin->text(); - _gsmsetting->gsmConfig.providerDataNumber = _mainWid->mNumber->text(); - _gsmsetting->gsmConfig.accessPointName = _mainWid->mApn->text(); - _gsmsetting->gsmConfig.networkID = _mainWid->mNetworkId->text(); - _gsmsetting->gsmConfig.networkType = getNetworkType(); - _gsmsetting->gsmConfig.allowedFrequencyBands = _mainWid->mBand->value(); - - _gsmsetting->gsmConfig.valid = true; - _gsmsetting->gsmConfig.secretsValid = true; -} - -void -GSMWidgetImpl::setNetworkType(TDEGSMNetworkType::TDEGSMNetworkType type) -{ - if (type == TDEGSMNetworkType::Any) { - _mainWid->mBand->setValue(0); - } - else if (type == TDEGSMNetworkType::Only3G) { - _mainWid->mBand->setValue(1); - } - else if (type == TDEGSMNetworkType::GPRSEdge) { - _mainWid->mBand->setValue(2); - } - else if (type == TDEGSMNetworkType::Prefer3G) { - _mainWid->mBand->setValue(3); - } - else if (type == TDEGSMNetworkType::Prefer2G) { - _mainWid->mBand->setValue(4); - } - else { - _mainWid->mBand->setValue(0); - } -} - -TDEGSMNetworkType::TDEGSMNetworkType -GSMWidgetImpl::getNetworkType() -{ - int itemNo = _mainWid->mNetworkType->currentItem(); - if (itemNo == 0) { - return TDEGSMNetworkType::Any; - } - else if (itemNo == 1) { - return TDEGSMNetworkType::Only3G; - } - else if (itemNo == 2) { - return TDEGSMNetworkType::GPRSEdge; - } - else if (itemNo == 3) { - return TDEGSMNetworkType::Prefer3G; - } - else if (itemNo == 4) { - return TDEGSMNetworkType::Prefer2G; - } - else { - return TDEGSMNetworkType::Any; - } -} - -#include "knetworkmanager-connection_setting_gsm_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.h deleted file mode 100644 index f4fd439..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_gsm_widget.h +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_gsm_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H - - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_gsm.h" -#include "knetworkmanager-connection_setting_widget_interface.h" - -//class VPNService; -class ConnectionSettingGsmWidget; - -namespace ConnectionSettings -{ - -class Connection; - -class GSMWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - GSMWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - void Deactivate(); - public slots: - void dirty(); - - private: - void Init(); - //VPNConfigWidget* getVPNConfigWidget(VPNService* service); - - void setNetworkType(TDEGSMNetworkType::TDEGSMNetworkType); - TDEGSMNetworkType::TDEGSMNetworkType getNetworkType(); - - TDEModemConnection* _gsmsetting; - ConnectionSettingGsmWidget* _mainWid; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.cpp deleted file mode 100644 index f0c1972..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-connection_setting_info_widget.h" - -using namespace ConnectionSettings; - -InfoWidgetImpl::InfoWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _infosetting = conn; - - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingInfoWidget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -InfoWidgetImpl::Init() -{ - connect(_mainWid->txtConnectionName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotNameChanged(const TQString&))); - connect(_mainWid->chkAutoConnect, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotAutoconnectChanged(bool))); -} - -void -InfoWidgetImpl::Activate() -{ - _mainWid->txtConnectionName->setText(_infosetting->friendlyName); - _mainWid->chkAutoConnect->setChecked(_infosetting->autoConnect); -} - -void -InfoWidgetImpl::slotNameChanged(const TQString& name) -{ - _infosetting->friendlyName = name; -} - -void -InfoWidgetImpl::slotAutoconnectChanged(bool autoconnect) -{ - _infosetting->autoConnect = autoconnect; -} - -#include "knetworkmanager-connection_setting_info_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.h deleted file mode 100644 index c5900ce..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_info_widget.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H - - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// knm headers -#include "connection_setting_info.h" -#include "knetworkmanager-connection_setting_widget_interface.h" - -namespace ConnectionSettings -{ - -class Info; -class Connection; - -class InfoWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - InfoWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - - public slots: - void slotNameChanged(const TQString&); - void slotAutoconnectChanged(bool); - - private: - void Init(); - - TDENetworkConnection* _infosetting; - ConnectionSettingInfoWidget* _mainWid; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.cpp deleted file mode 100644 index 7b48dfe..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include -#include - -#include "knetworkmanager-connection_setting_ipv4_widget.h" -#include "knetworkmanager-connection_setting_ipv4.h" - -using namespace ConnectionSettings; - -#define IP_INPUT_MASK "900.900.900.900" - -IPv4WidgetImpl::IPv4WidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _ipv4_setting = conn; - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingIPv4Widget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -IPv4WidgetImpl::Init() -{ - _mainWid->groupIPConfig->setChecked(!(_ipv4_setting->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP)); - - connect(_mainWid->groupIPConfig, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotIPConfigEnabled(bool))); - - _mainWid->txtIP->setInputMask(IP_INPUT_MASK); - _mainWid->txtNetmask->setInputMask(IP_INPUT_MASK); - _mainWid->txtGateway->setInputMask(IP_INPUT_MASK); - - if (!_ipv4_setting->ipConfig.ipConfigurations.isEmpty()) - { - _mainWid->txtIP->setText(_ipv4_setting->ipConfig.ipConfigurations[0].ipAddress.toString()); - _mainWid->txtNetmask->setText(_ipv4_setting->ipConfig.ipConfigurations[0].networkMask.toString()); - _mainWid->txtGateway->setText(_ipv4_setting->ipConfig.ipConfigurations[0].gateway.toString()); - } - - if (!_ipv4_setting->ipConfig.resolvers.isEmpty()) - { - TDENetworkAddressList hosts = _ipv4_setting->ipConfig.resolvers; - TQStringList list; - for (TDENetworkAddressList::Iterator it = hosts.begin(); it != hosts.end(); ++it) - { - list.append((*it).toString()); - } - _mainWid->txtDNSAddresses->setText(list.join(" ")); - } - - if (!_ipv4_setting->ipConfig.searchDomains.isEmpty()) - { - TDENetworkSearchDomainList domains = _ipv4_setting->ipConfig.searchDomains; - TQStringList list; - for (TDENetworkSearchDomainList::Iterator it = domains.begin(); it != domains.end(); ++it) - { - list.append((*it).searchDomain()); - } - _mainWid->txtDNSSearch->setText(list.join(" ")); - } - - // connect the signals after setting up the values - connect(_mainWid->txtIP, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotIPAddressChanged(const TQString&))); - connect(_mainWid->txtNetmask, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotNetmaskChanged(const TQString&))); - connect(_mainWid->txtGateway, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotGatewayChanged(const TQString&))); - connect(_mainWid->txtDNSAddresses, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotDNSAddressesChanged(const TQString&))); - connect(_mainWid->txtDNSSearch, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotDNSSearchChanged(const TQString&))); -} - -void -IPv4WidgetImpl::Activate() -{ - -} - -void -IPv4WidgetImpl::slotDNSAddressesChanged(const TQString& adr) -{ - // TODO: use , and ; for splitting too - TQStringList list = TQStringList::split(" ", adr); - TDENetworkAddressList hosts; - for (TQStringList::Iterator it = list.begin(); it != list.end(); ++it) - { - TQHostAddress host(*it); - if (!host.isNull()) - { - hosts.append(host); - } - } - _ipv4_setting->ipConfig.resolvers = hosts; -} - - -void -IPv4WidgetImpl::slotDNSSearchChanged(const TQString& search) -{ - // TODO: use , and ; for splitting too - - TQStringList list = TQStringList::split(" ", search); - TDENetworkSearchDomainList domains; - for (TQStringList::Iterator it = list.begin(); it != list.end(); ++it) - { - if ((*it) != "") { - TDENetworkSearchDomain domain(*it); - domains.append(domain); - } - } - _ipv4_setting->ipConfig.searchDomains = domains; -} - -void -IPv4WidgetImpl::slotIPConfigEnabled(bool enabled) -{ - if (enabled) - { - _ipv4_setting->ipConfig.connectionFlags &= (~TDENetworkIPConfigurationFlags::IPV4DHCPIP); - } - else - { - _ipv4_setting->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPIP; - } -} - -void -IPv4WidgetImpl::slotIPAddressChanged(const TQString& ip) -{ - TQHostAddress ipadr(ip); - if (!ipadr.isNull()) - { - TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; - if (addrs.size() > 0) - { - addrs[0].ipAddress = ipadr; - } - else - { - TDENetworkSingleIPConfiguration adr; - adr.ipAddress = ipadr; - addrs.append(adr); - } - _ipv4_setting->ipConfig.ipConfigurations = addrs; - - // if netmask is not set yet we preset it to a default value depending on the network class - if (_mainWid->txtNetmask->text() == "...") - { - if ( (ipadr.toIPv4Address() & 0xFF000000) < 0xDF000000) - { - if ( (ipadr.toIPv4Address() & 0xFF000000) >= 0xC0000000) { - _mainWid->txtNetmask->setText("255.255.255.0"); // class C - } - else if ( (ipadr.toIPv4Address() & 0xFF000000) >= 0x80000000) { - _mainWid->txtNetmask->setText("255.255.0.0"); // class B - } - else { - _mainWid->txtNetmask->setText("255.0.0.0"); // class A - } - } - } - } -} - -void -IPv4WidgetImpl::slotNetmaskChanged(const TQString& ip) -{ - TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; - TDENetMask mask; - mask.fromString(ip); - addrs[0].networkMask = mask; - _ipv4_setting->ipConfig.ipConfigurations = addrs; -} - -void -IPv4WidgetImpl::slotGatewayChanged(const TQString& ip) -{ - TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; - addrs[0].gateway = TQHostAddress(ip); - _ipv4_setting->ipConfig.ipConfigurations = addrs; -} - -#include "knetworkmanager-connection_setting_ipv4_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.h deleted file mode 100644 index cfee028..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ipv4_widget.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_IPV4_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_IPV4_WIDGET_H - -// tde headers -#include -#include - -// ui headers -#include "connection_setting_ipv4.h" - -// knetworkmanager headers -#include "knetworkmanager-connection_setting_widget_interface.h" -#include "knetworkmanager-connection_setting_ipv4.h" - -namespace ConnectionSettings -{ - class IPv4; - - class IPv4WidgetImpl : public WidgetInterface - { - Q_OBJECT - - - public: - IPv4WidgetImpl(TDENetworkConnection* conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - void Activate(); - - public slots: - void slotIPConfigEnabled(bool); - void slotIPAddressChanged(const TQString&); - void slotNetmaskChanged(const TQString&); - void slotGatewayChanged(const TQString&); - void slotDNSSearchChanged(const TQString&); - void slotDNSAddressesChanged(const TQString&); - - private: - void Init(); - - TDENetworkConnection* _ipv4_setting; - ConnectionSettingIPv4Widget* _mainWid; - }; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_IPv4_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.cpp deleted file mode 100644 index 3bc4783..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_ppp_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include - -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_ppp.h" -#include "knetworkmanager-connection_setting_ppp_widget.h" - -#include "connection_setting_ppp.h" - -using namespace ConnectionSettings; - -PPPWidgetImpl::PPPWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _pppsetting = conn; - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingPppWidget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -PPPWidgetImpl::Init() -{ - if (_pppsetting->pppConfig.valid) { - _mainWid->mNoAuth->setChecked( !(_pppsetting->pppConfig.requireServerAuthentication) ); - _mainWid->mRefuseEap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableEAP ); - _mainWid->mRefusePap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisablePAP ); - _mainWid->mRefuseChap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableCHAP ); - _mainWid->mRefuseMschap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAP ); - _mainWid->mRefuseMschapV2->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAPv2 ); - _mainWid->mNoBsd->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowBSDCompression) ); - _mainWid->mNoDeflate->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowDeflateCompression) ); - _mainWid->mNoVjComp->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowVJCompression) ); - _mainWid->mRequireMppe->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE ); - _mainWid->mRequireMppe128->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE128 ); - _mainWid->mStatefulMppe->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::StatefulMPPE ); - _mainWid->mCrtscts->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::UseHardwareFlowControl ); - - _mainWid->mBaudRate->setValue(_pppsetting->pppConfig.baudRate); - _mainWid->mMru->setValue(_pppsetting->pppConfig.mru); - _mainWid->mMtu->setValue(_pppsetting->pppConfig.mtu); - _mainWid->mLcpEchoFailure->setValue(_pppsetting->pppConfig.lcpEchoFailureThreshold); - _mainWid->mLcpEchoInterval->setValue(_pppsetting->pppConfig.lcpEchoPingInterval); - } - - connect( _mainWid->mNoAuth, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRefuseEap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRefusePap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRefuseChap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRefuseMschap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRefuseMschapV2, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mNoBsd, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mNoDeflate, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRequireMppe, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mRequireMppe128, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mStatefulMppe, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); - connect( _mainWid->mCrtscts, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); -} - -void -PPPWidgetImpl::Deactivate() -{ -} - -void -PPPWidgetImpl::Activate() -{ - -} - -#define SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(x,y,z) { \ - if (z) { \ - x |= y; \ - } \ - else { \ - x &= (~y); \ - } \ - } - -void -PPPWidgetImpl::dirty() -{ - _pppsetting->pppConfig.requireServerAuthentication = ( !(_mainWid->mNoAuth->isChecked()) ); - - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableEAP, _mainWid->mRefuseEap->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisablePAP, _mainWid->mRefusePap->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableCHAP, _mainWid->mRefuseChap->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableMSCHAP, _mainWid->mRefuseMschap->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableMSCHAPv2, _mainWid->mRefuseMschapV2->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowBSDCompression, !(_mainWid->mNoBsd->isChecked()) ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowDeflateCompression, !(_mainWid->mNoDeflate->isChecked()) ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowVJCompression, !(_mainWid->mNoVjComp->isChecked()) ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::RequireMPPE, _mainWid->mRequireMppe->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::RequireMPPE128, _mainWid->mRequireMppe128->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::StatefulMPPE, _mainWid->mStatefulMppe->isChecked() ); - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::UseHardwareFlowControl, _mainWid->mCrtscts->isChecked() ); - - _pppsetting->pppConfig.baudRate = _mainWid->mBaudRate->value(); - _pppsetting->pppConfig.mru = _mainWid->mMru->value(); - _pppsetting->pppConfig.mtu = _mainWid->mMtu->value(); - _pppsetting->pppConfig.lcpEchoFailureThreshold = _mainWid->mLcpEchoFailure->value(); - _pppsetting->pppConfig.lcpEchoPingInterval = _mainWid->mLcpEchoInterval->value(); - - _pppsetting->pppConfig.valid = true; -} - -#include "knetworkmanager-connection_setting_ppp_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.h deleted file mode 100644 index 7cd4121..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_ppp_widget.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_ppp_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H - - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_ppp.h" -#include "knetworkmanager-connection_setting_widget_interface.h" - -//class VPNService; -class ConnectionSettingPppWidget; - -namespace ConnectionSettings -{ - -class Connection; - -class PPPWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - PPPWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - void Deactivate(); - public slots: - void dirty(); - - private: - void Init(); - - TDENetworkConnection* _pppsetting; - ConnectionSettingPppWidget* _mainWid; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.cpp deleted file mode 100644 index 574cdb7..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_serial_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_serial.h" -#include "knetworkmanager-connection_setting_serial_widget.h" - -#include "connection_setting_serial.h" - -using namespace ConnectionSettings; - -SerialWidgetImpl::SerialWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _serialsetting = conn; - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingSerialWidget(this); - layout->addWidget(_mainWid); - _mainWid->mBaudRate->setMaxValue(INT_MAX); - Init(); -} - -void -SerialWidgetImpl::Init() -{ - if (_serialsetting->serialConfig.valid) { - _mainWid->mBaudRate->setValue(_serialsetting->serialConfig.baudRate); - _mainWid->mDataBits->setCurrentItem(_serialsetting->serialConfig.byteWidth - 7); - setParityType(_serialsetting->serialConfig.parity); - _mainWid->mStopBits->setCurrentItem(_serialsetting->serialConfig.stopBits); - _mainWid->mSendDelay->setValue(_serialsetting->serialConfig.txDelay); - } - - connect( _mainWid->mBaudRate, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); - connect( _mainWid->mDataBits, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); - connect( _mainWid->mParity, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); - connect( _mainWid->mStopBits, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); - connect( _mainWid->mSendDelay, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); -} - -void -SerialWidgetImpl::Deactivate() -{ -} - -void -SerialWidgetImpl::Activate() -{ - -} - -void -SerialWidgetImpl::dirty() -{ - _serialsetting->serialConfig.baudRate = _mainWid->mBaudRate->value(); - _serialsetting->serialConfig.byteWidth = _mainWid->mDataBits->currentItem() + 7; - _serialsetting->serialConfig.parity = getParityType(); - _serialsetting->serialConfig.stopBits = _mainWid->mStopBits->currentItem(); - _serialsetting->serialConfig.txDelay = _mainWid->mSendDelay->value(); - - _serialsetting->serialConfig.valid = true; -} - -void -SerialWidgetImpl::setParityType(TDENetworkParity::TDENetworkParity type) -{ - if (type == TDENetworkParity::None) { - _mainWid->mParity->setCurrentItem(0); - } - else if (type == TDENetworkParity::Even) { - _mainWid->mParity->setCurrentItem(1); - } - else if (type == TDENetworkParity::Odd) { - _mainWid->mParity->setCurrentItem(2); - } - else { - _mainWid->mParity->setCurrentItem(0); - } -} - -TDENetworkParity::TDENetworkParity -SerialWidgetImpl::getParityType() -{ - int itemNo = _mainWid->mParity->currentItem(); - if (itemNo == 0) { - return TDENetworkParity::None; - } - else if (itemNo == 1) { - return TDENetworkParity::Even; - } - else if (itemNo == 2) { - return TDENetworkParity::Odd; - } - else { - return TDENetworkParity::None; - } -} - -#include "knetworkmanager-connection_setting_serial_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.h deleted file mode 100644 index d12db89..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_serial_widget.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_serial_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2008 Novell, Inc. - * - * Author: Will Stephenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H - - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_serial.h" -#include "knetworkmanager-connection_setting_widget_interface.h" - -//class VPNService; -class ConnectionSettingSerialWidget; - -namespace ConnectionSettings -{ - -class Connection; - -class SerialWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - SerialWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - void Deactivate(); - public slots: - void dirty(); - - private: - void Init(); - - void setParityType(TDENetworkParity::TDENetworkParity type); - TDENetworkParity::TDENetworkParity getParityType(); - - TDENetworkConnection* _serialsetting; - ConnectionSettingSerialWidget* _mainWid; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.cpp deleted file mode 100644 index 0e9ac95..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_vpn_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_setting_vpn.h" -#include "knetworkmanager-connection_setting_vpn_widget.h" -#include "knetworkmanager-device.h" -#include "knetworkmanager-vpnmanager.h" -#include "knetworkmanager-vpnservice.h" - -using namespace ConnectionSettings; - -VPNWidgetImpl::VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) - , _new_conn(new_conn) -{ - _vpnsetting = dynamic_cast (conn->getSetting(NM_SETTING_VPN_SETTING_NAME)); - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingVPNWidget(this); - layout->addWidget(_mainWid); - - Init(); -} - -void -VPNWidgetImpl::Init() -{ - // fill in all possible VPN services - VPNServiceList list = VPNManager::getVPNServices(); - - if (list.isEmpty()) - { - // FIXME Do something useful here - } - else - { - int index = 0; - for (VPNServiceList::Iterator it = list.begin(); it != list.end(); ++it) - { - TQString icon; - TQString disp_name; - - // get service icon and display name - VPNService* service = *it; - if (service) - { - icon = service->getIcon(); - disp_name = service->getDisplayName(); - } - - if (strcmp(disp_name, "vpnc") == 0) { - disp_name = "Cisco VPN"; - } - else if (strcmp(disp_name, "pptp") == 0) { - disp_name = "Microsoft PPTP VPN"; - } - else if (strcmp(disp_name, "openvpn") == 0) { - disp_name = "Open VPN"; - } - else if (strcmp(disp_name, "strongswan") == 0) { - disp_name = "StrongSwan VPN"; - } - - // the service should not get changed when editing a connection - if (service->getService() != _vpnsetting->getServiceType() && !_new_conn) - continue; - - // no special icon for this service, use default - if (icon.isEmpty()) - icon = "encrypted"; - - _mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index); - _mapServiceCombo.insert(index++, *it); - - if (service->getService() == _vpnsetting->getServiceType()) - { - // preselect the correct service - _mainWid->cboServices->setCurrentItem(index - 1); - slotServiceComboActivated(index - 1); - } - } - } - - // lock the combo when editing an already existing connection - if (!_new_conn) - _mainWid->cboServices->setEnabled(false); - else - { - // preselect the correct service - _mainWid->cboServices->setCurrentItem(0); - slotServiceComboActivated(0); - } - - // update the username to the current one - KUser user; - _vpnsetting->setUserName(user.loginName()); - - // notification if VPN service is selected - connect(_mainWid->cboServices, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotServiceComboActivated(int))); -} - -VPNConfigWidget* -VPNWidgetImpl::getVPNConfigWidget(VPNService* service) -{ - if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) - { - // return the already available config widget - return *_mapServiceWidget.find(service); - } - else - { - // we have to create a new one - VPNPlugin* plugin = service->getVPNPlugin(); - if (plugin) - { - VPNConfigWidget* config = plugin->CreateConfigWidget(_mainWid->widgetStack); - _mapServiceWidget.insert(service, config); - return config; - } - } - return NULL; -} - - -void -VPNWidgetImpl::slotServiceComboActivated(int index) -{ - VPNService* service; - if (_mapServiceCombo.find(index) != _mapServiceCombo.end()) - { - service = *_mapServiceCombo.find(index); - if (service) - { - VPNConfigWidget* config = getVPNConfigWidget(service); - _mainWid->widgetStack->raiseWidget(config); - - config->setVPNData(_vpnsetting->getRoutes(), _vpnsetting->getData()); - } - } - else - { - //FIXME - do something useful here - } -} - -void -VPNWidgetImpl::Deactivate() -{ - // update the setting from the currently selected vpn service - VPNService* service = *_mapServiceCombo.find(_mainWid->cboServices->currentItem()); - if (service) - { - // set the correct service type - _vpnsetting->setServiceType(service->getService()); - - VPNConfigWidget* config = *_mapServiceWidget.find(service); - if (config) - { - // update the vpn properties - _vpnsetting->setData(config->getVPNProperties()); - } - } -} - -void -VPNWidgetImpl::Activate() -{ - -} - -#include "knetworkmanager-connection_setting_vpn_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.h deleted file mode 100644 index f7c16cd..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_vpn_widget.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_vpn_widget.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H - - -// qt headers -#include -#include - -// knm headers -#include "connection_setting_vpn.h" -#include "knetworkmanager-connection_setting_widget_interface.h" -#include "knetworkmanager-device.h" - -class VPNService; -class VPNConfigWidget; - -namespace ConnectionSettings -{ - -class Connection; - -class VPNWidgetImpl : public WidgetInterface -{ - Q_OBJECT - - public: - VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); - void Activate(); - void Deactivate(); - public slots: - void slotServiceComboActivated(int); - - private: - void Init(); - VPNConfigWidget* getVPNConfigWidget(VPNService* service); - - bool _new_conn; - VPN* _vpnsetting; - ConnectionSettingVPNWidget* _mainWid; - TQMap _mapServiceCombo; - TQMap _mapServiceWidget; -}; - -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.cpp deleted file mode 100644 index 2c00288..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_widget_interface.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include "knetworkmanager-connection_setting_widget_interface.h" - -using namespace ConnectionSettings; - -WidgetInterface::WidgetInterface(TQWidget* parent, const char* name, WFlags fl) - : TQWidget(parent, name, fl) -{ - -} - -#include "knetworkmanager-connection_setting_widget_interface.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.h deleted file mode 100644 index 13ea65e..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_widget_interface.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_widget_interface.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H -#define KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H - -// qt headers -#include - -namespace ConnectionSettings -{ - - class WidgetInterface : public TQWidget - { - Q_OBJECT - - public: - WidgetInterface(TQWidget* parent = NULL, const char* name = 0, WFlags fl = 0); - virtual void Activate() = 0; - virtual void Deactivate() {}; - signals: - void next(); - }; -} - -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H */ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.cpp deleted file mode 100644 index 4b6d70a..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.cpp +++ /dev/null @@ -1,1029 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_setting_wireless_security_widget.cpp - * - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -/* qt headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* kde headers */ -#include -#include -#include -#include - -/* knetworkmanager headers */ -#include "knetworkmanager-connection_setting_wireless_security_widget.h" -#include "sha1.h" -#include "md5.h" -#include "knetworkmanager-wireless_manager.h" - -#define WPA_PMK_LEN 32 - -#define SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(x,y,z) { \ - if (z) { \ - x |= y; \ - } \ - else { \ - x &= (~y); \ - } \ - } - -using namespace ConnectionSettings; - -/* - class WirelessSecurityWEPImpl -*/ -WirelessSecurityWEPImpl::WirelessSecurityWEPImpl(TDEWiFiConnection* sec, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityWEP(parent, name, fl) - , _security_setting(sec) - , _wepKeyType( WEPKEY_TYPE_HEX ) -{ - cboAuthentication->insertItem(i18n("Open System"), 0); - cboAuthentication->insertItem(i18n("Shared Key"), 1); - if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Open) { - cboAuthentication->setCurrentItem(0); - } - else if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Shared) { - cboAuthentication->setCurrentItem(1); - } - - cbKeyType->insertItem(i18n("WEP 40/128-bit ASCII"), WEPKEY_TYPE_ASCII); - cbKeyType->insertItem(i18n("WEP 40/128-bit Hexadecimal"), WEPKEY_TYPE_HEX); - cbKeyType->insertItem(i18n("WEP 128-bit passphrase"), WEPKEY_TYPE_PASSPHRASE); - cbKeyType->setCurrentItem(_wepKeyType ); - - txtWEPKey0->setText(_security_setting->securitySettings.wepKey0); - txtWEPKey1->setText(_security_setting->securitySettings.wepKey1); - txtWEPKey2->setText(_security_setting->securitySettings.wepKey2); - txtWEPKey3->setText(_security_setting->securitySettings.wepKey3); - - switch(_security_setting->securitySettings.wepKeyIndex) - { - case 0: - rbKeyIdx0->setChecked(true); - break; - case 1: - rbKeyIdx1->setChecked(true); - break; - case 2: - rbKeyIdx2->setChecked(true); - break; - case 3: - rbKeyIdx3->setChecked(true); - break; - default: - rbKeyIdx0->setChecked(true); - break; - } - - connect(cboAuthentication, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotAuthAlgChanged(int))); - connect(cbKeyType, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotKeyTypeChanged(int))); - connect(txtWEPKey0, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey0Changed(const TQString&))); - connect(txtWEPKey1, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey1Changed(const TQString&))); - connect(txtWEPKey2, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey2Changed(const TQString&))); - connect(txtWEPKey3, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey3Changed(const TQString&))); - - connect(rbKeyIdx0, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx0Checked(bool))); - connect(rbKeyIdx1, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx1Checked(bool))); - connect(rbKeyIdx2, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx2Checked(bool))); - connect(rbKeyIdx3, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx3Checked(bool))); -} - -void WirelessSecurityWEPImpl::slotAuthAlgChanged(int index) -{ - if (index == 0) { - _security_setting->securitySettings.authType =TDENetworkWiFiAuthType::Open; - } - else if (index == 1) { - _security_setting->securitySettings.authType = TDENetworkWiFiAuthType::Shared; - } -} - -void WirelessSecurityWEPImpl::slotKeyTypeChanged(int index) -{ - _wepKeyType = (WEPKEY_TYPE)index; - - // update all WEP-Keys here due to the new key_type -} - -void WirelessSecurityWEPImpl::slotWepKey0Changed(const TQString &key) -{ - TQCString hashed = getHashedWEPKey(key, _wepKeyType); - _security_setting->securitySettings.wepKey0 = hashed; -} - -void WirelessSecurityWEPImpl::slotWepKey1Changed(const TQString &key) -{ - TQCString hashed = getHashedWEPKey(key, _wepKeyType); - _security_setting->securitySettings.wepKey1 = hashed; -} - -void WirelessSecurityWEPImpl::slotWepKey2Changed(const TQString &key) -{ - TQCString hashed = getHashedWEPKey(key, _wepKeyType); - _security_setting->securitySettings.wepKey2 = hashed; -} - -void WirelessSecurityWEPImpl::slotWepKey3Changed(const TQString& key) -{ - TQCString hashed = getHashedWEPKey(key, _wepKeyType); - _security_setting->securitySettings.wepKey3 = hashed; -} - -void WirelessSecurityWEPImpl::slotWepIdx0Checked(bool check) -{ - if (check) { - _security_setting->securitySettings.wepKeyIndex = 0; - } -} - -void WirelessSecurityWEPImpl::slotWepIdx1Checked(bool check) -{ - if (check) { - _security_setting->securitySettings.wepKeyIndex = 1; - } -} - -void WirelessSecurityWEPImpl::slotWepIdx2Checked(bool check) -{ - if (check) { - _security_setting->securitySettings.wepKeyIndex = 2; - } -} - -void WirelessSecurityWEPImpl::slotWepIdx3Checked(bool check) -{ - if (check) { - _security_setting->securitySettings.wepKeyIndex = 3; - } -} - -TQCString -WirelessSecurityWEPImpl::getHashedWEPKey(TQString key, WEPKEY_TYPE type) const -{ - TQCString hashed; - switch(type) - { - case WEPKEY_TYPE_HEX: - return TQCString(key); - break; - case WEPKEY_TYPE_ASCII: - hashed = String2Hex(TQCString(key), key.length() * 2); - return hashed; - break; - case WEPKEY_TYPE_PASSPHRASE: - return getWEP128PassphraseHash(TQCString(key)); - break; - } - return hashed; -} - -TQCString -WirelessSecurityWEPImpl::getWEP128PassphraseHash(TQCString input) const -{ - char md5_data[65]; - TQCString digest(16); - int input_len; - int i; - - if (input.isNull()) return input; - - input_len = input.length(); - if (input_len < 1) - return TQCString(); - - /* Get at least 64 bytes */ - for (i = 0; i < 64; i++) - md5_data [i] = input [i % input_len]; - - /* Null terminate md5 seed data and hash it */ - md5_data[64] = 0; - gnome_keyring_md5_string (md5_data, (unsigned char*)digest.data()); - return (String2Hex(TQByteArray(digest), 26)); - -} - -TQCString -WirelessSecurityWEPImpl::String2Hex(TQByteArray bytes, int final_len) const -{ - TQCString result(final_len+1); - static char hex_digits[] = "0123456789abcdef"; - result.resize(bytes.size() * 2 + 1); - for (uint i = 0; i < bytes.size(); i++) - { - result[2*i] = hex_digits[(bytes[i] >> 4) & 0xf]; - result[2*i+1] = hex_digits[bytes[i] & 0xf]; - } - /* Cut converted key off at the correct length for this cipher type */ - if (final_len > -1) - result[final_len] = '\0'; - return result; -} - - -/* - class WirelessSecurityWEPEncryptionImpl -*/ -WirelessSecurityWEPEncryptionImpl::WirelessSecurityWEPEncryptionImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityWEPEncryption(parent, name, fl) - , _security_setting(security_setting) -{ - cboEncryption->insertItem(i18n("None")); - cboEncryption->insertItem(i18n("Dynamic WEP")); -} - - -/* - class WirelessSecurityWPAVersionImpl -*/ -WirelessSecurityWPAVersionImpl::WirelessSecurityWPAVersionImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityWPAVersion(parent, name, fl) - , _security_setting(security_setting) -{ - cbWPA->setChecked(_security_setting->securitySettings.wpaVersion & TDENetworkWiFiWPAVersionFlags::WPA); - cbRSN->setChecked(_security_setting->securitySettings.wpaVersion & TDENetworkWiFiWPAVersionFlags::RSN); - - connect(cbWPA, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWPA1(bool))); - connect(cbRSN, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWPA2(bool))); - - connect(grpUseWPAVersion, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotAuto(bool))); -} - -void -WirelessSecurityWPAVersionImpl::slotAuto(bool on) -{ - if (!on) { - // auto-select proto - _security_setting->securitySettings.wpaVersion = TDENetworkWiFiWPAVersionFlags::Any; - } - else { - // use selected wpa-version - TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags proto = TDENetworkWiFiWPAVersionFlags::None; - if (cbWPA->isChecked()) { - proto |= TDENetworkWiFiWPAVersionFlags::WPA; - } - if (cbRSN->isChecked()) { - proto |= TDENetworkWiFiWPAVersionFlags::RSN; - } - _security_setting->securitySettings.wpaVersion = proto; - } -} - -void -WirelessSecurityWPAVersionImpl::slotWPA1(bool on) -{ - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(_security_setting->securitySettings.wpaVersion, TDENetworkWiFiWPAVersionFlags::WPA, on); -} - -void -WirelessSecurityWPAVersionImpl::slotWPA2(bool on) -{ - SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(_security_setting->securitySettings.wpaVersion, TDENetworkWiFiWPAVersionFlags::RSN, on); -} - -/* - class WirelessSecurityWPACipherImpl -*/ -WirelessSecurityWPACipherImpl::WirelessSecurityWPACipherImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityWPACipher(parent, name, fl) - , _security_setting(security_setting) -{ - connect(grpUseCipher, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotCipherChangedAuto(bool))); - - connect(chkGroupCipherTKIP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedTKIP(bool))); - connect(chkGroupCipherCCMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedCCMP(bool))); - connect(chkGroupCipherWEP40, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedWEP40(bool))); - connect(chkGroupCipherWEP104, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedWEP104(bool))); - - connect(chkPairwiseCipherTKIP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotPairwiseCipherChangedTKIP(bool))); - connect(chkPairwiseCipherCCMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotPairwiseCipherChangedCCMP(bool))); - - chkPairwiseCipherCCMP->setChecked(_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)); - chkPairwiseCipherTKIP->setChecked(_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)); - - chkGroupCipherCCMP->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)); - chkGroupCipherTKIP->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)); - chkGroupCipherWEP40->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)); - chkGroupCipherWEP104->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)); - -} - -void -WirelessSecurityWPACipherImpl::slotCipherChangedAuto(bool checked) -{ - if (!checked) - { - // select auto for both ciphers - _security_setting->securitySettings.allowedGroupWiseCiphers.clear(); - _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any); - _security_setting->securitySettings.allowedPairWiseCiphers.clear(); - _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any); - } - else - { - // use the already selected ciphers - - // group cipher - TDENetworkWiFiConnectionCipherList cipher; - if (chkGroupCipherTKIP->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherTKIP); - } - if (chkGroupCipherCCMP->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherCCMP); - } - if (chkGroupCipherWEP40->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherWEP40); - } - if (chkGroupCipherWEP104->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherWEP104); - } - _security_setting->securitySettings.allowedGroupWiseCiphers = cipher; - - // pairwise cipher - cipher.clear(); - if (chkPairwiseCipherTKIP->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherTKIP); - } - if (chkPairwiseCipherCCMP->isChecked()) { - cipher.append(TDENetworkWiFiConnectionCipher::CipherCCMP); - } - _security_setting->securitySettings.allowedPairWiseCiphers = cipher; - - } -} - -void -WirelessSecurityWPACipherImpl::slotGroupCipherChangedTKIP(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP); - } - else { - _security_setting->securitySettings.allowedGroupWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherTKIP); - } -} - -void -WirelessSecurityWPACipherImpl::slotGroupCipherChangedCCMP(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP); - } - else { - _security_setting->securitySettings.allowedGroupWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherCCMP); - } -} - -void -WirelessSecurityWPACipherImpl::slotGroupCipherChangedWEP40(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP40); - } - else { - _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherWEP40); - } -} - -void -WirelessSecurityWPACipherImpl::slotGroupCipherChangedWEP104(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP104); - } - else { - _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherWEP104); - } -} - -void -WirelessSecurityWPACipherImpl::slotPairwiseCipherChangedTKIP(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP); - } - else { - _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherTKIP); - } -} - -void -WirelessSecurityWPACipherImpl::slotPairwiseCipherChangedCCMP(bool checked) -{ - if (checked) { - if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP); - } - else { - _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherCCMP); - } -} - -/* - class WirelessSecurityWPAPSK -*/ -WirelessSecurityWPAPSKImpl::WirelessSecurityWPAPSKImpl(TDEWiFiConnection* security_setting, TDEWiFiConnection* wireless_setting, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityWPAPSK(parent, name, fl) - , _security_setting(security_setting) - , _wireless_setting(wireless_setting) -{ - if (_security_setting->securitySettings.secretsValid) { - txtPSK->setText(_security_setting->securitySettings.psk); - } - connect(txtPSK, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotPSKChanged(const TQString&))); -} - -void -WirelessSecurityWPAPSKImpl::slotPSKChanged(const TQString& psk) -{ - if (_wireless_setting) - { - _security_setting->securitySettings.psk = psk; - _security_setting->securitySettings.secretsValid = true; - } -} - -TQCString -WirelessSecurityWPAPSKImpl::String2Hex(TQByteArray bytes, int final_len) const -{ - TQCString result(final_len+1); - static char hex_digits[] = "0123456789abcdef"; - result.resize(bytes.size() * 2 + 1); - for (uint i = 0; i < bytes.size(); i++) - { - result[2*i] = hex_digits[(bytes[i] >> 4) & 0xf]; - result[2*i+1] = hex_digits[bytes[i] & 0xf]; - } - /* Cut converted key off at the correct length for this cipher type */ - if (final_len > -1) - result[final_len] = '\0'; - return result; -} - -/* - class WirelessSecurityEAPImpl -*/ -WirelessSecurityEAPImpl::WirelessSecurityEAPImpl(TDEWiFiConnection* security_setting, WirelessSecurityPhase2Impl* phase2_widget, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityEAP(parent, name, fl) - , _security_setting(security_setting) - , _phase2_widget(phase2_widget) -{ - // insert all EAP-Methods - int index = 0; - cboMethod->insertItem(i18n("None"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::None; - - cboMethod->insertItem(i18n("TTLS"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::TTLS; - - cboMethod->insertItem(i18n("PEAP"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::PEAP; - - cboMethod->insertItem(i18n("TLS"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::TLS; - - cboMethod->insertItem(i18n("Leap"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::LEAP; - - cboMethod->insertItem(i18n("MD5"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::MD5; - - cboMethod->insertItem(i18n("FAST"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::Fast; - - cboMethod->insertItem(i18n("SIM"), ++index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::SIM; - - // preselect the correct method - TQBiDirectionalMap::Iterator it = _eapIndexMap.findData(_security_setting->eapConfig.type); - cboMethod->setCurrentItem(it.key()); - - // update phase2 combobox - _phase2_widget->setAllowedPhase2Methods(_security_setting->eapConfig.allowedPhase2EAPMethods); - - txtIdentity->setText(_security_setting->eapConfig.userName); - txtAnonIdentity->setText(_security_setting->eapConfig.anonymousUserName); - if (_security_setting->eapConfig.secretsValid) { - txtPassword->setText(_security_setting->eapConfig.password); - } - - chkCAStore->setChecked(_security_setting->eapConfig.forceSystemCaCertificates); - kURLCACert->setEnabled(!_security_setting->eapConfig.forceSystemCaCertificates); - - // get notified if the method changes - connect(cboMethod, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMethodChanged(int))); - connect(txtIdentity, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotIdentityChanged(const TQString&))); - connect(txtAnonIdentity, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotAnonIdentityChanged(const TQString&))); - connect(txtPassword, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotPasswordChanged(const TQString&))); - connect(chkCAStore, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUseSystemCaCertChanged(bool))); -} - -void WirelessSecurityEAPImpl::slotUseSystemCaCertChanged(bool on) -{ - _security_setting->eapConfig.forceSystemCaCertificates = on; - kURLCACert->setEnabled(!on); -} - -void WirelessSecurityEAPImpl::slotMethodChanged(int index) -{ - // new method choosen - TDENetworkIEEE8021xType::TDENetworkIEEE8021xType eap = _eapIndexMap[index]; - _security_setting->eapConfig.type = eap; - - _phase2_widget->setAllowedPhase2Methods(_security_setting->eapConfig.allowedPhase2EAPMethods); -} - -void WirelessSecurityEAPImpl::slotIdentityChanged(const TQString& identity) -{ - _security_setting->eapConfig.userName = identity; -} - -void WirelessSecurityEAPImpl::slotAnonIdentityChanged(const TQString& identity) -{ - _security_setting->eapConfig.anonymousUserName = identity; -} - -void WirelessSecurityEAPImpl::slotPasswordChanged(const TQString& pwd) -{ - _security_setting->eapConfig.password = TQString(txtPassword->password()); - _security_setting->eapConfig.secretsValid = true; -} - -/* - class WirelessSecurityPhase2Impl -*/ -WirelessSecurityPhase2Impl::WirelessSecurityPhase2Impl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) - : ConnectionSettingWirelessSecurityPhase2(parent, name, fl) - , _security_setting(security_setting) -{ - _allowed_methods.append(TDENetworkIEEE8021xType::None); - updateMethodComboBox(); - - connect(cboPhase2Method, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotPhase2MethodChanged(int))); -} - -void WirelessSecurityPhase2Impl::updateMethodComboBox() -{ - // insert all phase2 EAP-Methods - int index = 0; - cboPhase2Method->clear(); - _eapIndexMap.clear(); - - for (TQValueList::Iterator it = _allowed_methods.begin(); it != _allowed_methods.end(); ++it) - { - if ((*it) == TDENetworkIEEE8021xType::None) - { - cboPhase2Method->insertItem(i18n("None"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::None; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::MSCHAPV2) - { - cboPhase2Method->insertItem(i18n("MSCHAPv2"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::MSCHAPV2; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::PAP) - { - cboPhase2Method->insertItem(i18n("PAP"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::PAP; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::CHAP) - { - cboPhase2Method->insertItem(i18n("CHAP"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::CHAP; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::MSCHAP) - { - cboPhase2Method->insertItem(i18n("MSCHAP"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::MSCHAP; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::GTC) - { - cboPhase2Method->insertItem(i18n("GTC"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::GTC; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::OTP) - { - cboPhase2Method->insertItem(i18n("OTP"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::OTP; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::MD5) - { - cboPhase2Method->insertItem(i18n("MD5"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::MD5; - index++; - } - else if ((*it) == TDENetworkIEEE8021xType::TLS) - { - cboPhase2Method->insertItem(i18n("TLS"), index); - _eapIndexMap[index] = TDENetworkIEEE8021xType::TLS; - index++; - } - } - - // preselect the correct method - TQBiDirectionalMap::Iterator it = _eapIndexMap.findData(_security_setting->eapConfig.phase2EAPAuthMethod); - if (it != _eapIndexMap.end()) - { - cboPhase2Method->setCurrentItem(it.key()); - _security_setting->eapConfig.phase2EAPAuthMethod = it.data(); - } - else - { - cboPhase2Method->setCurrentItem(0); - _security_setting->eapConfig.phase2EAPAuthMethod = _eapIndexMap[0]; - } -} - -void WirelessSecurityPhase2Impl::setAllowedPhase2Methods(const TQValueList& list) -{ - _allowed_methods = list; - updateMethodComboBox(); -} - -void WirelessSecurityPhase2Impl::slotPhase2MethodChanged(int index) -{ - // new method choosen - TDENetworkIEEE8021xType::TDENetworkIEEE8021xType eap = _eapIndexMap[index]; - _security_setting->eapConfig.phase2EAPAuthMethod = eap; -} - -/* - class WirelessSecurityWidgetImpl -*/ - -WirelessSecurityWidgetImpl::WirelessSecurityWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _security_setting = dynamic_cast (conn); - _wireless_setting = dynamic_cast (conn); - _ieee8021x_setting = dynamic_cast (conn); - _new_conn = new_conn; - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingWirelessSecurityWidget(this); - layout->addWidget(_mainWid); - - TQTimer::singleShot(0, this, TQT_SLOT(slotInit())); -} - -void -WirelessSecurityWidgetImpl::slotInit() -{ - // create all security widgets... - TQWidget* wep = new WirelessSecurityWEPImpl(_security_setting, _mainWid->groupUseEncryption); - TQWidget* phase2 = new WirelessSecurityPhase2Impl(_ieee8021x_setting, _mainWid->groupUseEncryption); - TQWidget* eap = new WirelessSecurityEAPImpl(_ieee8021x_setting, (WirelessSecurityPhase2Impl*)phase2, _mainWid->groupUseEncryption); - TQWidget* wpaversion = new WirelessSecurityWPAVersionImpl(_security_setting, _mainWid->groupUseEncryption); - TQWidget* wpacipher = new WirelessSecurityWPACipherImpl(_security_setting, _mainWid->groupUseEncryption); - TQWidget* wpapsk = new WirelessSecurityWPAPSKImpl(_security_setting, _wireless_setting, _mainWid->groupUseEncryption); - TQWidget* wepencryption = new WirelessSecurityWEPEncryptionImpl(_security_setting, _mainWid->groupUseEncryption); - - wep->setHidden(true); - eap->setHidden(true); - wpaversion->setHidden(true); - wpacipher->setHidden(true); - phase2->setHidden(true); - wpapsk->setHidden(true); - wepencryption->setHidden(true); - - _widgets[SECURITY_WEP].clear(); - _widgets[SECURITY_WPA_PSK].clear(); - _widgets[SECURITY_WPA_EAP].clear(); - _widgets[SECURITY_IEEE8021X].clear(); - - // create WEP widget list - _widgets[SECURITY_WEP].append(wep); - - // create WPA PSK widget list - _extra_widgets[SECURITY_WPA_PSK].append(wpaversion); - _extra_widgets[SECURITY_WPA_PSK].append(wpacipher); - _widgets[SECURITY_WPA_PSK].append(wpapsk); - - // create WPA EAP widget list - _extra_widgets[SECURITY_WPA_EAP].append(wpaversion); - _extra_widgets[SECURITY_WPA_EAP].append(wpacipher); - _widgets[SECURITY_WPA_EAP].append(eap); - _widgets[SECURITY_WPA_EAP].append(phase2); - - // create IEEE8021X widget list - _widgets[SECURITY_IEEE8021X].append(wepencryption); - _widgets[SECURITY_IEEE8021X].append(eap); - - connect(_mainWid->cboSecurity, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotComboSecurityActivated(int))); - connect(_mainWid->groupUseEncryption, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUseEncryptionToggled(bool))); - connect(_mainWid->pbExtra, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotExtraSettingsToggled(bool))); - -} - -void -WirelessSecurityWidgetImpl::Activate() -{ - kdDebug() << "Activate " << (_new_conn ? "New" : "Edit") << endl; - comboSecurityInit(); -} - -void -WirelessSecurityWidgetImpl::comboSecurityInit() -{ - int index = 0; - - TQValueList allowed_methods; - _mainWid->cboSecurity->clear(); - - // TODO: Preselect the right security method - // We should have an Essid already, fetch all possible APs - TQValueList aps; - if (_new_conn && !_wireless_setting->SSID.isEmpty()) { - aps = WirelessManager::getAccessPointsForEssid(_wireless_setting->SSID); -#if 0 - kdDebug() << "Hugo " << TQString(TQCString(_wireless_setting->getEssid())).ascii() << endl; -#endif - } - if (!aps.isEmpty()) { - // if at least one AP has this security setting show the entry in the combobox - for (TQValueList::Iterator it = aps.begin(); it != aps.end(); ++it) { - if (((*it)->wpaFlags & TDENetworkWiFiAPFlags::PrivacySupport) || ((*it)->rsnFlags & TDENetworkWiFiAPFlags::PrivacySupport)) { - kdDebug() << "AP " << (*it)->friendlySSID().ascii() << " is encrypted" << endl; - if ((((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) || (((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) { - // WPA or RSN - if ((*it)->rsnFlags & TDENetworkWiFiAPFlags::KeyManagementPSK || (*it)->wpaFlags & TDENetworkWiFiAPFlags::KeyManagementPSK) { - if (!allowed_methods.contains(SECURITY_WPA_PSK)) { - allowed_methods.append(SECURITY_WPA_PSK); - } - } - - if ((*it)->rsnFlags & TDENetworkWiFiAPFlags::KeyManagement80211 || (*it)->wpaFlags & TDENetworkWiFiAPFlags::KeyManagement80211) { - if (!allowed_methods.contains(SECURITY_WPA_EAP)) { - allowed_methods.append(SECURITY_WPA_EAP); - } - } - } - - // No WPA & RSN => WEP or dynamic WEP with 802.1x authentication - // TODO: an AP can provide WEP in addition to WPA - if (!allowed_methods.contains(SECURITY_WEP)) { - allowed_methods.append(SECURITY_WEP); - } - if (!allowed_methods.contains(SECURITY_IEEE8021X)) { - allowed_methods.append(SECURITY_IEEE8021X); - } - } - } - - // insert only allowed security methods - if (allowed_methods.contains(SECURITY_WPA_PSK)) - { - _securityComboMap.insert(index, SECURITY_WPA_PSK); - _mainWid->cboSecurity->insertItem(i18n("WPA Personal"), index++); - } - - if (allowed_methods.contains(SECURITY_WPA_EAP)) - { - _securityComboMap.insert(index, SECURITY_WPA_EAP); - _mainWid->cboSecurity->insertItem(i18n("WPA Enterprise"), index++); - } - - if (allowed_methods.contains(SECURITY_WEP)) - { - _securityComboMap.insert(index, SECURITY_WEP); - _mainWid->cboSecurity->insertItem(i18n("WEP"), index++); - } - - if (allowed_methods.contains(SECURITY_IEEE8021X)) - { - _securityComboMap.insert(index, SECURITY_IEEE8021X); - _mainWid->cboSecurity->insertItem(i18n("IEEE 802.1X"), index++); - } - } - else - { - // insert all possible authentication methods - _mainWid->cboSecurity->insertItem(i18n("WEP"),SECURITY_WEP ); - _mainWid->cboSecurity->insertItem(i18n("WPA Personal"), SECURITY_WPA_PSK); - _mainWid->cboSecurity->insertItem(i18n("WPA Enterprise"), SECURITY_WPA_EAP); - _mainWid->cboSecurity->insertItem(i18n("IEEE 802.1X"), SECURITY_IEEE8021X); - _securityComboMap.insert(SECURITY_WEP, SECURITY_WEP); - _securityComboMap.insert(SECURITY_WPA_PSK, SECURITY_WPA_PSK); - _securityComboMap.insert(SECURITY_WPA_EAP, SECURITY_WPA_EAP); - _securityComboMap.insert(SECURITY_IEEE8021X, SECURITY_IEEE8021X); - } - - if (!_new_conn) - { - switch(_security_setting->securitySettings.keyType) - { - case TDENetworkWiFiKeyType::WEP: - if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Shared || - !_security_setting->securitySettings.wepKey0.isEmpty() || - !_security_setting->securitySettings.wepKey1.isEmpty() || - !_security_setting->securitySettings.wepKey2.isEmpty() || - !_security_setting->securitySettings.wepKey3.isEmpty() ) - { - _mainWid->groupUseEncryption->setChecked(true); - _mainWid->cboSecurity->setCurrentItem(SECURITY_WEP); - slotComboSecurityActivated(_securityComboMap[SECURITY_WEP]); - } - else - _mainWid->groupUseEncryption->setChecked(false); - break; - case TDENetworkWiFiKeyType::WPAInfrastructure: - _mainWid->groupUseEncryption->setChecked(true); - _mainWid->cboSecurity->setCurrentItem(SECURITY_WPA_PSK); - slotComboSecurityActivated(_securityComboMap[SECURITY_WPA_PSK]); - break; - case TDENetworkWiFiKeyType::WPAEnterprise: - _mainWid->groupUseEncryption->setChecked(true); - _mainWid->cboSecurity->setCurrentItem(SECURITY_WPA_EAP); - slotComboSecurityActivated(_securityComboMap[SECURITY_WPA_EAP]); - break; - case TDENetworkWiFiKeyType::DynamicWEP: - _mainWid->groupUseEncryption->setChecked(true); - _mainWid->cboSecurity->setCurrentItem(SECURITY_IEEE8021X); - slotComboSecurityActivated(_securityComboMap[SECURITY_IEEE8021X]); - break; - - default: - break; - } - } - else - { - // select first possible security method - if (_mainWid->cboSecurity->count() > 0) - { - _mainWid->groupUseEncryption->setChecked(true); - _mainWid->groupUseEncryption->setEnabled(true); - _mainWid->cboSecurity->setCurrentItem(0); - slotComboSecurityActivated(0); - } - else - { - _mainWid->groupUseEncryption->setChecked(false); - _mainWid->groupUseEncryption->setEnabled(false); - } - } -} - -void -WirelessSecurityWidgetImpl::slotUseEncryptionToggled(bool on) -{ - _wireless_setting->securityRequired = on; -} - -void -WirelessSecurityWidgetImpl::slotComboSecurityActivated(int index) -{ - int i = _securityComboMap[index]; - - // authentication switched, we have to show the appropriate widgets and hide some others - switch(i) - { - case SECURITY_WEP: - configureForWEP(); - break; - - case SECURITY_WPA_PSK: - configureForWPAPSK(); - break; - - case SECURITY_WPA_EAP: - configureForWPAEAP(); - break; - - case SECURITY_IEEE8021X: - configureForIEEE8021X(); - break; - - default: - // should not happen, something is broken... - break; - } -} - -void -WirelessSecurityWidgetImpl::configureWidgets(SecurityMethods method) -{ - // store selected method - _currentMethod = method; - - for (int i = 0; i < SECURITY_COUNT; ++i) - { - // remove all current widgets that do not belong to the selected method - if (i != method) - { - for (TQValueList::iterator it = _widgets[i].begin(); it != _widgets[i].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->remove(*it); - (*it)->hide(); - } - // remove extra widgets too - for (TQValueList::iterator it = _extra_widgets[i].begin(); it != _extra_widgets[i].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->remove(*it); - (*it)->hide(); - } - } - } - - // show all widgets widgets for the selected security method - for (TQValueList::iterator it = _widgets[method].begin(); it != _widgets[method].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->add(*it); - (*it)->show(); - } - - if (_mainWid->pbExtra->isOn()) - for (TQValueList::iterator it = _extra_widgets[method].begin(); it != _extra_widgets[method].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->add(*it); - (*it)->show(); - } - - // deactivate button if no extra settings are available - _mainWid->pbExtra->setEnabled(!(_extra_widgets[method].begin() == _extra_widgets[method].end())); -} - -void -WirelessSecurityWidgetImpl::slotExtraSettingsToggled(bool on) -{ - if (on) - for (TQValueList::iterator it = _extra_widgets[_currentMethod].begin(); it != _extra_widgets[_currentMethod].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->add(*it); - (*it)->show(); - } - else - for (TQValueList::iterator it = _extra_widgets[_currentMethod].begin(); it != _extra_widgets[_currentMethod].end(); ++it) - { - _mainWid->groupUseEncryption->layout()->remove(*it); - (*it)->hide(); - } -} - -void -WirelessSecurityWidgetImpl::configureForWEP() -{ - _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WEP; - configureWidgets(SECURITY_WEP); -} - -void -WirelessSecurityWidgetImpl::configureForWPAPSK() -{ - _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WPAInfrastructure; - configureWidgets(SECURITY_WPA_PSK); -} - -void -WirelessSecurityWidgetImpl::configureForWPAEAP() -{ - _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WPAEnterprise; - configureWidgets(SECURITY_WPA_EAP); -} - -void -WirelessSecurityWidgetImpl::configureForIEEE8021X() -{ - _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::DynamicWEP; - configureWidgets(SECURITY_IEEE8021X); -} - - - - -#include "knetworkmanager-connection_setting_wireless_security_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.h deleted file mode 100644 index b6e4a5e..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_security_widget.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H - -/* ui autogenerated headers */ -#include "connection_setting_wireless_security.h" -#include "connection_setting_wireless_security_eap.h" -#include "connection_setting_wireless_security_phase2.h" -#include "connection_setting_wireless_security_wep.h" -#include "connection_setting_wireless_security_wpaversion.h" -#include "connection_setting_wireless_security_wpacipher.h" -#include "connection_setting_wireless_security_wpapsk.h" -#include "connection_setting_wireless_security_wepencryption.h" - -// tde headers -#include -#include - -/* knetworkmanager headers */ -#include "qbidirectionalmap.h" -#include "knetworkmanager-connection_setting_widget_interface.h" - -namespace ConnectionSettings -{ - /* class declarations */ - class WirelessSecurity; - class Wireless; - class WirelessSecurityPhase2Impl; - - class WirelessSecurityWEPImpl : public ConnectionSettingWirelessSecurityWEP - { - Q_OBJECT - - public: - enum WEPKEY_TYPE - { - WEPKEY_TYPE_ASCII = 0 - , WEPKEY_TYPE_HEX - , WEPKEY_TYPE_PASSPHRASE - }; - - WirelessSecurityWEPImpl(TDEWiFiConnection* security, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - TQCString getHashedWEPKey(TQString key, WEPKEY_TYPE type) const; - TQCString getWEP128PassphraseHash(TQCString input) const; - TQCString String2Hex(TQByteArray bytes, int final_len) const; - - public slots: - void slotAuthAlgChanged(int); - void slotKeyTypeChanged(int); - void slotWepKey0Changed(const TQString&); - void slotWepKey1Changed(const TQString&); - void slotWepKey2Changed(const TQString&); - void slotWepKey3Changed(const TQString&); - void slotWepIdx0Checked(bool); - void slotWepIdx1Checked(bool); - void slotWepIdx2Checked(bool); - void slotWepIdx3Checked(bool); - private: - TDEWiFiConnection* _security_setting; - WEPKEY_TYPE _wepKeyType; - }; - - class WirelessSecurityWEPEncryptionImpl : public ConnectionSettingWirelessSecurityWEPEncryption - { - Q_OBJECT - - public: - WirelessSecurityWEPEncryptionImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - private: - TDEWiFiConnection* _security_setting; - }; - - class WirelessSecurityWPAVersionImpl : public ConnectionSettingWirelessSecurityWPAVersion - { - Q_OBJECT - - public: - WirelessSecurityWPAVersionImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - - public slots: - void slotAuto(bool); - void slotWPA1(bool); - void slotWPA2(bool); - - private: - TDEWiFiConnection* _security_setting; - - }; - - class WirelessSecurityWPACipherImpl : public ConnectionSettingWirelessSecurityWPACipher - { - Q_OBJECT - - private: - enum WPA_CIPHERS - { - WPA_CIPHER_AUTO = 0 - , WPA_CIPHER_TKIP - , WPA_CIPHER_CCMP - , WPA_CIPHER_LAST - }; - public: - WirelessSecurityWPACipherImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - - public slots: - void slotCipherChangedAuto(bool); - void slotGroupCipherChangedTKIP(bool); - void slotGroupCipherChangedCCMP(bool); - void slotGroupCipherChangedWEP40(bool); - void slotGroupCipherChangedWEP104(bool); - void slotPairwiseCipherChangedTKIP(bool); - void slotPairwiseCipherChangedCCMP(bool); - - private: - TDEWiFiConnection* _security_setting; - }; - - class WirelessSecurityWPAPSKImpl : public ConnectionSettingWirelessSecurityWPAPSK - { - Q_OBJECT - - public: - WirelessSecurityWPAPSKImpl(TDEWiFiConnection* security_setting, TDEWiFiConnection* wireless_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - TQCString String2Hex(TQByteArray bytes, int final_len) const; - - public slots: - void slotPSKChanged(const TQString&); - - private: - TDEWiFiConnection* _security_setting; - TDEWiFiConnection* _wireless_setting; - }; - - class WirelessSecurityEAPImpl : public ConnectionSettingWirelessSecurityEAP - { - Q_OBJECT - - public: - WirelessSecurityEAPImpl(TDEWiFiConnection* security_setting, WirelessSecurityPhase2Impl* phase2_widget, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - - public slots: - void slotMethodChanged(int index); - void slotIdentityChanged(const TQString&); - void slotAnonIdentityChanged(const TQString&); - void slotPasswordChanged(const TQString&); - void slotUseSystemCaCertChanged(bool on); - - private: - TDEWiFiConnection* _security_setting; - TQBiDirectionalMap _eapIndexMap; - WirelessSecurityPhase2Impl* _phase2_widget; - }; - - class WirelessSecurityPhase2Impl : public ConnectionSettingWirelessSecurityPhase2 - { - Q_OBJECT - - public: - WirelessSecurityPhase2Impl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - public slots: - void setAllowedPhase2Methods(const TQValueList&); - void slotPhase2MethodChanged(int index); - private: - void updateMethodComboBox(); - - TDEWiFiConnection* _security_setting; - TQBiDirectionalMap _eapIndexMap; - TQValueList _allowed_methods; - }; - - class WirelessSecurityWidgetImpl : public WidgetInterface - { - Q_OBJECT - - private: - enum SecurityMethods - { - SECURITY_WEP = 0 - , SECURITY_WPA_PSK - , SECURITY_WPA_EAP - , SECURITY_IEEE8021X - , SECURITY_COUNT - }; - - public: - WirelessSecurityWidgetImpl(TDENetworkConnection*, bool new_conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - void Activate(); - - public slots: - void slotComboSecurityActivated(int); - void slotUseEncryptionToggled(bool); - void slotExtraSettingsToggled(bool); - - private slots: - void slotInit(); - - private: - void comboSecurityInit(); - void configureWidgets(SecurityMethods); - void configureForWEP(); - void configureForWPAPSK(); - void configureForWPAEAP(); - void configureForIEEE8021X(); - - SecurityMethods _currentMethod; - TQValueList _widgets[SECURITY_COUNT]; - TQValueList _extra_widgets[SECURITY_COUNT]; - TDEWiFiConnection* _security_setting; - TDEWiFiConnection* _wireless_setting; - TDEWiFiConnection* _ieee8021x_setting; - ConnectionSettingWirelessSecurityWidget* _mainWid; - bool _new_conn; - TQMap _securityComboMap; - }; -} - -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.cpp deleted file mode 100644 index 5d34190..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "knetworkmanager-connection_setting_widget_interface.h" -#include "knetworkmanager-connection_setting_wireless_widget.h" -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-wireless_manager.h" - -using namespace ConnectionSettings; - -class NetworkListViewItem : public KListViewItem -{ - public: - - NetworkListViewItem(TQListView* parent, WirelessNetwork& net) - : KListViewItem(parent, TQString::fromUtf8(net.getDisplaySsid()), TQString("%1\%").arg(net.getStrength())) - , _net(net) - { - TQ_UINT8 strength = net.getStrength(); - if (strength > 80) - setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_100", KIcon::Small)); - else if (strength > 55) - setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_75", KIcon::Small)); - else if (strength > 30) - setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_50", KIcon::Small)); - else if (strength > 5) - setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_25", KIcon::Small)); - else - setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_00", KIcon::Small)); - - if (net.isEncrypted()) - setPixmap(2, KGlobal::iconLoader()->loadIcon("lock", KIcon::Small)); - } - - WirelessNetwork _net; -}; - -WirelessWidgetImpl::WirelessWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) - : WidgetInterface(parent, name, fl) -{ - _wireless_setting = dynamic_cast(conn); - _info_setting = dynamic_cast(conn); - _security_setting = dynamic_cast(conn); - _hasName = !_info_setting->friendlyName.isEmpty(); - _new_conn = new_conn; - - TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); - _mainWid = new ConnectionSettingWirelessWidget(this); - layout->addWidget(_mainWid); - - // FIXME hide this button until it is implemented - _mainWid->pbExpert->hide(); - - Init(); -} - -void -WirelessWidgetImpl::Init() -{ - TQVBoxLayout* layout = new TQVBoxLayout(_mainWid->framePlaceholder, 1, 1); - _searchLine = new KListViewSearchLineWidget(_mainWid->lvEssids, _mainWid->framePlaceholder); - layout->addWidget(_searchLine); - - connect(_mainWid->txtEssid, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotEssidChanged(const TQString&))); - connect(_mainWid->lvEssids, TQT_SIGNAL(doubleClicked(TQListViewItem*, const TQPoint&, int)), this, TQT_SLOT(slotEssidDoubleClicked(TQListViewItem*, const TQPoint&, int)) ); - connect(_mainWid->lvEssids, TQT_SIGNAL(selectionChanged(TQListViewItem*)), this, TQT_SLOT(slotEssidChanged(TQListViewItem*))); - - if (!_new_conn) - { - _mainWid->chkAutoRefresh->hide(); - _mainWid->lvEssids->hide(); - _searchLine->hide(); - } -} - -void -WirelessWidgetImpl::Activate() -{ - // Fill in all available networks from all devices - // get all aps from all devices grouped together using the ssid - TQValueList nets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID); - - _mainWid->lvEssids->clear(); - - for (TQValueList::Iterator it = nets.begin(); it != nets.end(); ++it) - { - KListViewItem* item = new NetworkListViewItem(_mainWid->lvEssids, (*it)); - - _mainWid->lvEssids->insertItem(item); - } - - // FIXME, if essid contains unprintable characters show the essid in hex - _mainWid->txtEssid->setText(_wireless_setting->SSID); -} - -void WirelessWidgetImpl::slotEssidChanged(TQListViewItem* item) -{ - NetworkListViewItem* net_item = dynamic_cast(item); - if (net_item) - { - // update the settingsobject - updateEssid(net_item->_net.getSsid()); - - // update the textbox to match the selected essid - _mainWid->txtEssid->setText(net_item->_net.getDisplaySsid()); - } -} - -void -WirelessWidgetImpl::slotEssidDoubleClicked(TQListViewItem* item, const TQPoint& /*p*/, int /*i*/) -{ - NetworkListViewItem* net_item = dynamic_cast(item); - if (net_item) - { - updateEssid(net_item->_net.getSsid()); - // essid selected with double click -> goto the next setting - emit next(); - } -} - - -void -WirelessWidgetImpl::slotEssidChanged(const TQString& new_essid) -{ - /* set the newly entered essid */ - /* FIXME perhaps local8Bit is better? */ - /* FIXME allow entering essid in hex */ - /* FIXME select the appropriate essid in the list too */ - - TQByteArray essid(new_essid.utf8()); - - // remove trailing \0 - essid.resize(essid.size() - 1); - - updateEssid(essid); -} - -void -WirelessWidgetImpl::updateEssid(const TQByteArray& essid) -{ - _wireless_setting->SSID = essid; - - if (!_hasName) - { - // the connection has no name yet -> just take the essid for it - _info_setting->friendlyName = TQString(essid); - if (_info_setting->friendlyName == "") { - _info_setting->friendlyName = "<" + i18n("hidden") + ">"; - } - } -} - -TQByteArray WirelessWidgetImpl::byteArrayFromHexString(const TQCString& str) -{ - char c[2]; - TQByteArray arr(str.length() - 1); - TQTextStream stream(str, IO_ReadOnly); - - stream.setf(TQTextStream::hex); - stream.setf(TQTextStream::left); - stream.width(2); - stream.fill('0'); - - // 0x - stream.readRawBytes(c, 2); - - for (uint i = 0; i < (str.length()-1)/2; ++i) - { - stream.readRawBytes(c, 2); - TQString hex; - hex += "0x"; - hex += c[0]; - hex += c[1]; - arr[i] = (unsigned char)hex.toShort(); - } - return arr; -} - -TQString WirelessWidgetImpl::hexStringFromByteArray(const TQByteArray& bytes) -{ - TQString tmp; - TQTextStream stream(&tmp, IO_ReadWrite); - stream.setf(TQTextStream::hex); - stream.setf(TQTextStream::left); - stream.width(2); - stream.fill('0'); - - stream << "0x" ; - for (uint i = 0; i < bytes.size(); ++i) - { - stream << static_cast(bytes[i]); - } - return tmp; -} - -#include "knetworkmanager-connection_setting_wireless_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.h deleted file mode 100644 index 37a3de7..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_setting_wireless_widget.h +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H -#define KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H - -// tde headers -#include -#include - -#include "knetworkmanager-connection_setting_widget_interface.h" -#include "connection_setting_wireless.h" - -class KListViewSearchLineWidget; - -namespace ConnectionSettings -{ - class Wireless; - class WirelessSecurity; - class Info; - - - class WirelessWidgetImpl : public WidgetInterface - { - Q_OBJECT - - public: - WirelessWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); - - void Activate(); - - public slots: - void slotEssidChanged(const TQString& new_essid); - void slotEssidChanged(TQListViewItem*); - void slotEssidDoubleClicked(TQListViewItem*, const TQPoint&, int); - - private: - void Init(); - void updateEssid(const TQByteArray&); - TQByteArray byteArrayFromHexString(const TQCString&); - TQString hexStringFromByteArray(const TQByteArray& ); - - bool _hasName; - TDEWiFiConnection* _wireless_setting; - TDEWiFiConnection* _info_setting; - TDEWiFiConnection* _security_setting; - ConnectionSettingWirelessWidget* _mainWid; - KListViewSearchLineWidget* _searchLine; - bool _new_conn; - }; -} -#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.cpp b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.cpp deleted file mode 100644 index 41d2776..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.cpp +++ /dev/null @@ -1,461 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include -#include -#include -#include - -// kde headers -#include -#include -#include - -// TQt DBus headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_widget_interface.h" -#include "knetworkmanager-connection_settings_dialog.h" -#include "knetworkmanager-connection_setting_cdma_widget.h" -#include "knetworkmanager-connection_setting_gsm_widget.h" -#include "knetworkmanager-connection_setting_ppp_widget.h" -#include "knetworkmanager-connection_setting_serial_widget.h" -#include "knetworkmanager-connection_setting_wireless_widget.h" -#include "knetworkmanager-connection_setting_wireless_security_widget.h" -#include "knetworkmanager-connection_setting_ipv4_widget.h" -#include "knetworkmanager-connection_setting_info_widget.h" -#include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-wireless_manager.h" - -char use_new_wireless_essid = 0; -TQByteArray new_wireless_essid; - -using namespace ConnectionSettings; - -ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, bool modal, WFlags fl) - : ConnectionSettingsDialog(parent, name, modal, fl) - , _conn(conn) - , _new_conn(new_conn) -{ - updateDialogForDeviceType(); - - // get notified if device combo changes - connect(btnConnect, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotConnect()) ); - connect(pbNext, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotNext()) ); - connect(pbBack, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotBack()) ); - connect(pbCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotCancel()) ); - connect(pbSave, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSave()) ); - - // nice images for the buttons - btnConnect->setIconSet(SmallIcon ("connect_creating", TQIconSet::Automatic)); - pbNext->setIconSet(SmallIcon ("1rightarrow", TQIconSet::Automatic)); - pbBack->setIconSet(SmallIcon ("1leftarrow", TQIconSet::Automatic)); - pbCancel->setIconSet(SmallIcon("cancel", TQIconSet::Automatic)); - pbSave->setIconSet(SmallIcon("ok", TQIconSet::Automatic)); - - // enable or disable buttons accroding to the current state - slotEnableButtons(); -} - -ConnectionSettingsDialogImpl::~ConnectionSettingsDialogImpl() -{ - kdDebug() << "ConnectionSettingsDialogImpl::~ConnectionSettingsDialogImpl" << endl; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForWireless(TDENetworkConnection* conn, bool new_conn) -{ - TQValueList ret; - - // widgetlist for wireless connection - ret.append(new ConnectionSettings::WirelessWidgetImpl(conn, new_conn)); - ret.append(new ConnectionSettings::WirelessSecurityWidgetImpl(conn, new_conn)); - ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - if (ret.isEmpty()) - { - // we have a problem here, NetworkManager asked for a setting we do not have - kdError() << k_funcinfo << "Unexpected setting requested" << endl; - } - - return ret; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForWirelessKnownESSID(TDENetworkConnection* conn, bool new_conn, const TQByteArray& essid) -{ - TQValueList ret; - - // Set ESSID -// _wireless_setting = dynamic_cast (conn->getSetting(NM_SETTING_WIRELESS_SETTING_NAME)); -// _info_setting = dynamic_cast (conn->getSetting(NM_SETTING_CONNECTION_SETTING_NAME)); -// _wireless_setting->setEssid(essid); -// if (!_hasName) -// { -// // the connection has no name yet -> just take the essid for it -// _info_setting->setName(essid); -// } - - // widgetlist for wireless connection - ret.append(new ConnectionSettings::WirelessSecurityWidgetImpl(conn, new_conn)); - ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - if (ret.isEmpty()) - { - // we have a problem here, NetworkManager asked for a setting we do not have - kdError() << k_funcinfo << "Unexpected setting requested" << endl; - } - - return ret; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForWired(TDENetworkConnection* conn, bool new_conn) -{ - TQValueList ret; - - // widgetlist for wired connection - ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - return ret; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForVPN(TDENetworkConnection* conn, bool new_conn) -{ - TQValueList ret; - - // widgetlist for wired connection -// ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - return ret; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForCDMA(TDENetworkConnection* conn, bool new_conn) -{ - TQValueList ret; - - // widgetlist for wired connection - ret.append(new ConnectionSettings::CDMAWidgetImpl(conn)); - ret.append(new ConnectionSettings::SerialWidgetImpl(conn)); - ret.append(new ConnectionSettings::PPPWidgetImpl(conn)); - ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - return ret; -} - -TQValueList -ConnectionSettingsDialogImpl::createWidgetsForGSM(TDENetworkConnection* conn, bool new_conn) -{ - TQValueList ret; - - // widgetlist for wired connection - ret.append(new ConnectionSettings::GSMWidgetImpl(conn)); - ret.append(new ConnectionSettings::PPPWidgetImpl(conn)); - ret.append(new ConnectionSettings::SerialWidgetImpl(conn)); - ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); - ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); - - return ret; -} - -void -ConnectionSettingsDialogImpl::createWidgetsForConnection(TDENetworkConnection* conn, bool new_conn) -{ - /* - Currently two modes: - * dev == NULL -> Connection should be edited without the wish to start a connection - * dev != NULL -> A connection should be edited for connection on this device - */ - - if (!conn) { - // TODO: create an empty widget and show an error - kdWarning() << k_funcinfo << "Not handled yet" << endl; - } - else { - TQValueList widgets; - // TODO: move to a factory class - if (conn->type() == TDENetworkConnectionType::WiFi) { - if (use_new_wireless_essid == 0) { - widgets = createWidgetsForWireless(conn, new_conn); - } - else { - createWidgetsForWirelessKnownESSID(conn, new_conn, new_wireless_essid); - new_wireless_essid = TQByteArray(); - } - } - else if (conn->type() == TDENetworkConnectionType::WiredEthernet) { - widgets = createWidgetsForWired(conn, new_conn); - } - else if (conn->type() == TDENetworkConnectionType::Modem) { - TDEModemConnection* modemconn = dynamic_cast(conn); - if (modemconn) { - if (modemconn->type == TDEModemConnectionType::CDMA) { - widgets = createWidgetsForCDMA(conn, new_conn); - } - else if (modemconn->type == TDEModemConnectionType::GSM) { - widgets = createWidgetsForGSM(conn, new_conn); - } - else { - kdWarning() << k_funcinfo << "Specific modem type not handled yet" << endl; - } - } - } -// else if (conn->getType() == NM_SETTING_VPN_SETTING_NAME) { -// widgets = createWidgetsForVPN(conn, new_conn); -// } - else { - kdWarning() << k_funcinfo << "Not handled yet" << endl; - } - - int id; - for (TQValueList::Iterator it = widgets.begin(); it != widgets.end(); ++it) { - id = wstackSettings->addWidget(*it); - _widgetIds.append(id); - } - - if (widgets.begin() != widgets.end()) { - activateWidget(*widgets.begin()); - } - } -} - -void -ConnectionSettingsDialogImpl::updateDialogForDeviceType() -{ - // clear our tabview first - TQWidget *page = NULL; - while ( (page = wstackSettings->visibleWidget()) != NULL) - { - wstackSettings->removeWidget(page); - delete page; - } - - if (_conn) { - createWidgetsForConnection(_conn, _new_conn); - } - else { - // this should never happen - TQLabel* lbl = new TQLabel(wstackSettings, "Unknown Device Type"); - wstackSettings->addWidget(lbl); - - wstackSettings->raiseWidget(lbl); - } -} - -int -ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(TDENetworkConnection* conn) -{ - if (conn->type() == TDENetworkConnectionType::WiFi) { - return TDENetworkDeviceType::WiFi; - } - else if (conn->type() == TDENetworkConnectionType::WiredEthernet) { - return TDENetworkDeviceType::WiredEthernet; - } - else if (conn->type() == TDENetworkConnectionType::Modem) { - return TDENetworkDeviceType::Modem; - } - - return TDENetworkDeviceType::Other; -} - -void -ConnectionSettingsDialogImpl::slotConnect() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - // add/save the connection - nm->saveConnection(_conn); - - // activate device - if (_conn && nm) { -// // VPN connection needs a special specific object -// if (_conn->getType() == NM_SETTING_VPN_SETTING_NAME) { -// TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); -// TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); -// nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), device, act_conn, err); -// } -// else { - // we need to call ActivateDevice async - nm->initiateConnection(_conn->UUID); -// } - } - - emit connectionSaved(); - this->close(true); -} - -void -ConnectionSettingsDialogImpl::slotSave() -{ - // Make sure settings are committed - TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); - if (current != _widgetIds.fromLast()) - { - WidgetInterface* widget = NULL; - - // let the widget know about it being the active one - widget = dynamic_cast(wstackSettings->widget(*current)); - if (widget) { - deactivateWidget(widget); - } - } - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - // save the connection - nm->saveConnection(_conn); - - emit connectionSaved(); - this->close(true); -} - -void -ConnectionSettingsDialogImpl::slotCancel() -{ - close(); -} - -void -ConnectionSettingsDialogImpl::slotNext() -{ - TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); - if (current != _widgetIds.fromLast()) - { - WidgetInterface* widget = NULL; - - // let the widget know about it being the active one - widget = dynamic_cast(wstackSettings->widget(*current)); - if (widget) - deactivateWidget(widget); - - // next widget - current++; - - // let the widget know about it being the active one - widget = dynamic_cast(wstackSettings->widget(*current)); - if (widget) - activateWidget(widget); - } - slotEnableButtons(); -} - -void -ConnectionSettingsDialogImpl::slotBack() -{ - TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); - if (current != _widgetIds.begin()) - { - WidgetInterface* widget = NULL; - - // let the widget know about it being the active one - widget = dynamic_cast(wstackSettings->widget(*current)); - if (widget) - deactivateWidget(widget); - - // one back - current--; - - // let the widget know about it being the active one - widget = dynamic_cast(wstackSettings->widget(*current)); - if (widget) - activateWidget(widget); - } - slotEnableButtons(); -} - -void -ConnectionSettingsDialogImpl::activateWidget(WidgetInterface* widget) -{ - // allow the widget to press next - connect(widget, TQT_SIGNAL(next()), this, TQT_SLOT(slotNext())); - - // allow the widget to do some initialization - widget->Activate(); - - // show the widget - wstackSettings->raiseWidget(widget); - -} - -void -ConnectionSettingsDialogImpl::deactivateWidget(WidgetInterface* widget) -{ - // allow the widget to press next - disconnect(widget, TQT_SIGNAL(next()), this, TQT_SLOT(slotNext())); - - // allow the widget to do some initialization - widget->Deactivate(); -} - -void -ConnectionSettingsDialogImpl::slotEnableButtons() -{ - // enable the buttons according to the current state - - TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); - bool enabled; - - /* - Next: enabled if another widget is available - */ - enabled = true; - if (current == _widgetIds.fromLast()) { - enabled = false; - } - pbNext->setEnabled(enabled); - - /* - Back: enabled if the current widget has a predecessor - */ - enabled = true; - if (current == _widgetIds.begin()) { - enabled = false; - } - pbBack->setEnabled(enabled); - - /* - Connect: only show connect if the connection is valid - */ - if (_conn) { - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - btnConnect->setEnabled(nm->verifyConnectionSettings(_conn)); - pbSave->setEnabled(nm->verifyConnectionSettings(_conn)); - } -} - -#include "knetworkmanager-connection_settings_dialog.moc" diff --git a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.h b/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.h deleted file mode 100644 index f65de7a..0000000 --- a/tdenetworkmanager/src/configwidgets/knetworkmanager-connection_settings_dialog.h +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H -#define KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H - -// tqt headers -#include -#include - -// tde headers -#include -#include - -// ui autogenerated headers -#include "connection_settings.h" - -// knm headers -#include "knetworkmanager-connection_setting.h" - -class TQWidget; -class Device; - -namespace ConnectionSettings -{ - class WidgetInterface; - class ConnectionSetting; -} - -class ConnectionSettingsDialogImpl : public ConnectionSettingsDialog -{ - Q_OBJECT - - public: - ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); - ~ConnectionSettingsDialogImpl(); - - public slots: - void slotConnect(); - void slotCancel(); - void slotSave(); - void slotNext(); - void slotBack(); - void slotEnableButtons(); - - signals: - void connectionSaved(); - - private: - void updateDialogForDeviceType(); - void createWidgetsForConnection(TDENetworkConnection*, bool new_conn); - void activateWidget(ConnectionSettings::WidgetInterface* widget); - void deactivateWidget(ConnectionSettings::WidgetInterface* widget); - int getDeviceTypeFromConnection(TDENetworkConnection* conn); - - // TODO: To be moved to a factory class - TQValueList createWidgetsForWired(TDENetworkConnection* conn, bool new_conn); - TQValueList createWidgetsForWireless(TDENetworkConnection* conn, bool new_conn); - TQValueList createWidgetsForWirelessKnownESSID(TDENetworkConnection* conn, bool new_conn, const TQByteArray& essid); - TQValueList createWidgetsForVPN(TDENetworkConnection* conn, bool new_conn); - TQValueList createWidgetsForCDMA(TDENetworkConnection* conn, bool new_conn); - TQValueList createWidgetsForGSM(TDENetworkConnection* conn, bool new_conn); - - TDENetworkConnection* _conn; - TQValueList _widgetIds; - bool _new_conn; -}; - -#endif /* KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.cpp new file mode 100644 index 0000000..4036518 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_cdma_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_setting_cdma_widget.h" + +// ui headers +#include "connection_setting_cdma.h" + +using namespace ConnectionSettings; + +CDMAWidgetImpl::CDMAWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _cdmasetting = dynamic_cast(conn); + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingCdmaWidget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +CDMAWidgetImpl::Init() +{ + if (_cdmasetting->cdmaConfig.valid) { + _mainWid->mUsername->setText( _cdmasetting->cdmaConfig.username ); + _mainWid->mNumber->setText( _cdmasetting->cdmaConfig.providerDataNumber ); + if (_cdmasetting->cdmaConfig.secretsValid) { + _mainWid->mPassword->setText( _cdmasetting->cdmaConfig.password ); + } + } + connect( _mainWid->mUsername, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mPassword, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mNumber, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); +} + +void +CDMAWidgetImpl::Deactivate() +{ +} + +void +CDMAWidgetImpl::Activate() +{ + +} + +void +CDMAWidgetImpl::dirty() +{ + _cdmasetting->cdmaConfig.username = _mainWid->mUsername->text(); + _cdmasetting->cdmaConfig.password = _mainWid->mPassword->text(); + _cdmasetting->cdmaConfig.providerDataNumber = _mainWid->mNumber->text(); + _cdmasetting->cdmaConfig.valid = true; + _cdmasetting->cdmaConfig.secretsValid = true; +} + + +#include "tdenetman-connection_setting_cdma_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.h new file mode 100644 index 0000000..36c9224 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_cdma_widget.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_cdma_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H + + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// knm headers +#include "tdenetman-connection_setting_widget_interface.h" + +//class VPNService; +class ConnectionSettingCdmaWidget; + +namespace ConnectionSettings +{ + +class CDMAWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + CDMAWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + void Deactivate(); + public slots: + void dirty(); + + private: + void Init(); + //VPNConfigWidget* getVPNConfigWidget(VPNService* service); + + + TDEModemConnection* _cdmasetting; + ConnectionSettingCdmaWidget* _mainWid; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_CDMA_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.cpp new file mode 100644 index 0000000..3df8804 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.cpp @@ -0,0 +1,156 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_gsm_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_setting_gsm_widget.h" + +#include "connection_setting_gsm.h" + +using namespace ConnectionSettings; + +GSMWidgetImpl::GSMWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _gsmsetting = dynamic_cast(conn); + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingGsmWidget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +GSMWidgetImpl::Init() +{ + if (_gsmsetting->gsmConfig.valid) { + _mainWid->mUsername->setText( _gsmsetting->gsmConfig.username ); + _mainWid->mNumber->setText( _gsmsetting->gsmConfig.providerDataNumber ); + _mainWid->mApn->setText( _gsmsetting->gsmConfig.accessPointName ); + _mainWid->mNetworkId->setText( _gsmsetting->gsmConfig.networkID ); + setNetworkType( _gsmsetting->gsmConfig.networkType ); + _mainWid->mBand->setValue( _gsmsetting->gsmConfig.allowedFrequencyBands ); + if (_gsmsetting->gsmConfig.secretsValid) { + _mainWid->mPassword->setText( _gsmsetting->gsmConfig.password ); + _mainWid->mPin->setText( _gsmsetting->gsmConfig.pin ); + } + } + + connect( _mainWid->mUsername, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mPassword, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mPin, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mNumber, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mApn, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mNetworkId, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(dirty())); + connect( _mainWid->mNetworkType, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); + connect( _mainWid->mBand, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); +} + +void +GSMWidgetImpl::Deactivate() +{ +} + +void +GSMWidgetImpl::Activate() +{ + +} + +void +GSMWidgetImpl::dirty() +{ + _gsmsetting->gsmConfig.username = _mainWid->mUsername->text(); + _gsmsetting->gsmConfig.password = _mainWid->mPassword->text(); + _gsmsetting->gsmConfig.pin = _mainWid->mPin->text(); + _gsmsetting->gsmConfig.providerDataNumber = _mainWid->mNumber->text(); + _gsmsetting->gsmConfig.accessPointName = _mainWid->mApn->text(); + _gsmsetting->gsmConfig.networkID = _mainWid->mNetworkId->text(); + _gsmsetting->gsmConfig.networkType = getNetworkType(); + _gsmsetting->gsmConfig.allowedFrequencyBands = _mainWid->mBand->value(); + + _gsmsetting->gsmConfig.valid = true; + _gsmsetting->gsmConfig.secretsValid = true; +} + +void +GSMWidgetImpl::setNetworkType(TDEGSMNetworkType::TDEGSMNetworkType type) +{ + if (type == TDEGSMNetworkType::Any) { + _mainWid->mBand->setValue(0); + } + else if (type == TDEGSMNetworkType::Only3G) { + _mainWid->mBand->setValue(1); + } + else if (type == TDEGSMNetworkType::GPRSEdge) { + _mainWid->mBand->setValue(2); + } + else if (type == TDEGSMNetworkType::Prefer3G) { + _mainWid->mBand->setValue(3); + } + else if (type == TDEGSMNetworkType::Prefer2G) { + _mainWid->mBand->setValue(4); + } + else { + _mainWid->mBand->setValue(0); + } +} + +TDEGSMNetworkType::TDEGSMNetworkType +GSMWidgetImpl::getNetworkType() +{ + int itemNo = _mainWid->mNetworkType->currentItem(); + if (itemNo == 0) { + return TDEGSMNetworkType::Any; + } + else if (itemNo == 1) { + return TDEGSMNetworkType::Only3G; + } + else if (itemNo == 2) { + return TDEGSMNetworkType::GPRSEdge; + } + else if (itemNo == 3) { + return TDEGSMNetworkType::Prefer3G; + } + else if (itemNo == 4) { + return TDEGSMNetworkType::Prefer2G; + } + else { + return TDEGSMNetworkType::Any; + } +} + +#include "tdenetman-connection_setting_gsm_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.h new file mode 100644 index 0000000..6010d3f --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_gsm_widget.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_gsm_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H + + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// knm headers +#include "tdenetman-connection_setting_widget_interface.h" + +//class VPNService; +class ConnectionSettingGsmWidget; + +namespace ConnectionSettings +{ + +class Connection; + +class GSMWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + GSMWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + void Deactivate(); + public slots: + void dirty(); + + private: + void Init(); + //VPNConfigWidget* getVPNConfigWidget(VPNService* service); + + void setNetworkType(TDEGSMNetworkType::TDEGSMNetworkType); + TDEGSMNetworkType::TDEGSMNetworkType getNetworkType(); + + TDEModemConnection* _gsmsetting; + ConnectionSettingGsmWidget* _mainWid; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_GSM_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.cpp new file mode 100644 index 0000000..48a22f7 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Valentine Sinitsyn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_setting_info_widget.h" + +using namespace ConnectionSettings; + +InfoWidgetImpl::InfoWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _infosetting = conn; + + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingInfoWidget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +InfoWidgetImpl::Init() +{ + connect(_mainWid->txtConnectionName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotNameChanged(const TQString&))); + connect(_mainWid->chkAutoConnect, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotAutoconnectChanged(bool))); +} + +void +InfoWidgetImpl::Activate() +{ + _mainWid->txtConnectionName->setText(_infosetting->friendlyName); + _mainWid->chkAutoConnect->setChecked(_infosetting->autoConnect); +} + +void +InfoWidgetImpl::slotNameChanged(const TQString& name) +{ + _infosetting->friendlyName = name; +} + +void +InfoWidgetImpl::slotAutoconnectChanged(bool autoconnect) +{ + _infosetting->autoConnect = autoconnect; +} + +#include "tdenetman-connection_setting_info_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.h new file mode 100644 index 0000000..8cad6c6 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_info_widget.h @@ -0,0 +1,68 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Valentine Sinitsyn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H + + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// knm headers +#include "connection_setting_info.h" +#include "tdenetman-connection_setting_widget_interface.h" + +namespace ConnectionSettings +{ + +class Info; +class Connection; + +class InfoWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + InfoWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + + public slots: + void slotNameChanged(const TQString&); + void slotAutoconnectChanged(bool); + + private: + void Init(); + + TDENetworkConnection* _infosetting; + ConnectionSettingInfoWidget* _mainWid; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_INFO_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.cpp new file mode 100644 index 0000000..e229b2f --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.cpp @@ -0,0 +1,208 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Valentine Sinitsyn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include +#include + +#include "tdenetman-connection_setting_ipv4_widget.h" + +using namespace ConnectionSettings; + +#define IP_INPUT_MASK "900.900.900.900" + +IPv4WidgetImpl::IPv4WidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _ipv4_setting = conn; + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingIPv4Widget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +IPv4WidgetImpl::Init() +{ + _mainWid->groupIPConfig->setChecked(!(_ipv4_setting->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP)); + + connect(_mainWid->groupIPConfig, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotIPConfigEnabled(bool))); + + _mainWid->txtIP->setInputMask(IP_INPUT_MASK); + _mainWid->txtNetmask->setInputMask(IP_INPUT_MASK); + _mainWid->txtGateway->setInputMask(IP_INPUT_MASK); + + if (!_ipv4_setting->ipConfig.ipConfigurations.isEmpty()) + { + _mainWid->txtIP->setText(_ipv4_setting->ipConfig.ipConfigurations[0].ipAddress.toString()); + _mainWid->txtNetmask->setText(_ipv4_setting->ipConfig.ipConfigurations[0].networkMask.toString()); + _mainWid->txtGateway->setText(_ipv4_setting->ipConfig.ipConfigurations[0].gateway.toString()); + } + + if (!_ipv4_setting->ipConfig.resolvers.isEmpty()) + { + TDENetworkAddressList hosts = _ipv4_setting->ipConfig.resolvers; + TQStringList list; + for (TDENetworkAddressList::Iterator it = hosts.begin(); it != hosts.end(); ++it) + { + list.append((*it).toString()); + } + _mainWid->txtDNSAddresses->setText(list.join(" ")); + } + + if (!_ipv4_setting->ipConfig.searchDomains.isEmpty()) + { + TDENetworkSearchDomainList domains = _ipv4_setting->ipConfig.searchDomains; + TQStringList list; + for (TDENetworkSearchDomainList::Iterator it = domains.begin(); it != domains.end(); ++it) + { + list.append((*it).searchDomain()); + } + _mainWid->txtDNSSearch->setText(list.join(" ")); + } + + // connect the signals after setting up the values + connect(_mainWid->txtIP, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotIPAddressChanged(const TQString&))); + connect(_mainWid->txtNetmask, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotNetmaskChanged(const TQString&))); + connect(_mainWid->txtGateway, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotGatewayChanged(const TQString&))); + connect(_mainWid->txtDNSAddresses, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotDNSAddressesChanged(const TQString&))); + connect(_mainWid->txtDNSSearch, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotDNSSearchChanged(const TQString&))); +} + +void +IPv4WidgetImpl::Activate() +{ + +} + +void +IPv4WidgetImpl::slotDNSAddressesChanged(const TQString& adr) +{ + // TODO: use , and ; for splitting too + TQStringList list = TQStringList::split(" ", adr); + TDENetworkAddressList hosts; + for (TQStringList::Iterator it = list.begin(); it != list.end(); ++it) + { + TQHostAddress host(*it); + if (!host.isNull()) + { + hosts.append(host); + } + } + _ipv4_setting->ipConfig.resolvers = hosts; +} + + +void +IPv4WidgetImpl::slotDNSSearchChanged(const TQString& search) +{ + // TODO: use , and ; for splitting too + + TQStringList list = TQStringList::split(" ", search); + TDENetworkSearchDomainList domains; + for (TQStringList::Iterator it = list.begin(); it != list.end(); ++it) + { + if ((*it) != "") { + TDENetworkSearchDomain domain(*it); + domains.append(domain); + } + } + _ipv4_setting->ipConfig.searchDomains = domains; +} + +void +IPv4WidgetImpl::slotIPConfigEnabled(bool enabled) +{ + if (enabled) + { + _ipv4_setting->ipConfig.connectionFlags &= (~TDENetworkIPConfigurationFlags::IPV4DHCPIP); + } + else + { + _ipv4_setting->ipConfig.connectionFlags |= TDENetworkIPConfigurationFlags::IPV4DHCPIP; + } +} + +void +IPv4WidgetImpl::slotIPAddressChanged(const TQString& ip) +{ + TQHostAddress ipadr(ip); + if (!ipadr.isNull()) + { + TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; + if (addrs.size() > 0) + { + addrs[0].ipAddress = ipadr; + } + else + { + TDENetworkSingleIPConfiguration adr; + adr.ipAddress = ipadr; + addrs.append(adr); + } + _ipv4_setting->ipConfig.ipConfigurations = addrs; + + // if netmask is not set yet we preset it to a default value depending on the network class + if (_mainWid->txtNetmask->text() == "...") + { + if ( (ipadr.toIPv4Address() & 0xFF000000) < 0xDF000000) + { + if ( (ipadr.toIPv4Address() & 0xFF000000) >= 0xC0000000) { + _mainWid->txtNetmask->setText("255.255.255.0"); // class C + } + else if ( (ipadr.toIPv4Address() & 0xFF000000) >= 0x80000000) { + _mainWid->txtNetmask->setText("255.255.0.0"); // class B + } + else { + _mainWid->txtNetmask->setText("255.0.0.0"); // class A + } + } + } + } +} + +void +IPv4WidgetImpl::slotNetmaskChanged(const TQString& ip) +{ + TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; + TDENetMask mask; + mask.fromString(ip); + addrs[0].networkMask = mask; + _ipv4_setting->ipConfig.ipConfigurations = addrs; +} + +void +IPv4WidgetImpl::slotGatewayChanged(const TQString& ip) +{ + TDENetworkSingleIPConfigurationList addrs = _ipv4_setting->ipConfig.ipConfigurations; + addrs[0].gateway = TQHostAddress(ip); + _ipv4_setting->ipConfig.ipConfigurations = addrs; +} + +#include "tdenetman-connection_setting_ipv4_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.h new file mode 100644 index 0000000..61fdb12 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ipv4_widget.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_IPV4_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_IPV4_WIDGET_H + +// tde headers +#include +#include + +// ui headers +#include "connection_setting_ipv4.h" + +// tdenetman headers +#include "tdenetman-connection_setting_widget_interface.h" + +namespace ConnectionSettings +{ + class IPv4; + + class IPv4WidgetImpl : public WidgetInterface + { + Q_OBJECT + + + public: + IPv4WidgetImpl(TDENetworkConnection* conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + void Activate(); + + public slots: + void slotIPConfigEnabled(bool); + void slotIPAddressChanged(const TQString&); + void slotNetmaskChanged(const TQString&); + void slotGatewayChanged(const TQString&); + void slotDNSSearchChanged(const TQString&); + void slotDNSAddressesChanged(const TQString&); + + private: + void Init(); + + TDENetworkConnection* _ipv4_setting; + ConnectionSettingIPv4Widget* _mainWid; + }; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_IPv4_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.cpp new file mode 100644 index 0000000..e3688e0 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.cpp @@ -0,0 +1,143 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_ppp_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include + +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_setting_ppp_widget.h" +#include "connection_setting_ppp.h" + +using namespace ConnectionSettings; + +PPPWidgetImpl::PPPWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _pppsetting = conn; + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingPppWidget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +PPPWidgetImpl::Init() +{ + if (_pppsetting->pppConfig.valid) { + _mainWid->mNoAuth->setChecked( !(_pppsetting->pppConfig.requireServerAuthentication) ); + _mainWid->mRefuseEap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableEAP ); + _mainWid->mRefusePap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisablePAP ); + _mainWid->mRefuseChap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableCHAP ); + _mainWid->mRefuseMschap->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAP ); + _mainWid->mRefuseMschapV2->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::DisableMSCHAPv2 ); + _mainWid->mNoBsd->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowBSDCompression) ); + _mainWid->mNoDeflate->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowDeflateCompression) ); + _mainWid->mNoVjComp->setChecked( !(_pppsetting->pppConfig.flags & TDENetworkPPPFlags::AllowVJCompression) ); + _mainWid->mRequireMppe->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE ); + _mainWid->mRequireMppe128->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::RequireMPPE128 ); + _mainWid->mStatefulMppe->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::StatefulMPPE ); + _mainWid->mCrtscts->setChecked( _pppsetting->pppConfig.flags & TDENetworkPPPFlags::UseHardwareFlowControl ); + + _mainWid->mBaudRate->setValue(_pppsetting->pppConfig.baudRate); + _mainWid->mMru->setValue(_pppsetting->pppConfig.mru); + _mainWid->mMtu->setValue(_pppsetting->pppConfig.mtu); + _mainWid->mLcpEchoFailure->setValue(_pppsetting->pppConfig.lcpEchoFailureThreshold); + _mainWid->mLcpEchoInterval->setValue(_pppsetting->pppConfig.lcpEchoPingInterval); + } + + connect( _mainWid->mNoAuth, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRefuseEap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRefusePap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRefuseChap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRefuseMschap, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRefuseMschapV2, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mNoBsd, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mNoDeflate, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRequireMppe, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mRequireMppe128, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mStatefulMppe, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); + connect( _mainWid->mCrtscts, TQT_SIGNAL(toggled(bool)), TQT_SLOT(dirty())); +} + +void +PPPWidgetImpl::Deactivate() +{ +} + +void +PPPWidgetImpl::Activate() +{ + +} + +#define SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(x,y,z) { \ + if (z) { \ + x |= y; \ + } \ + else { \ + x &= (~y); \ + } \ + } + +void +PPPWidgetImpl::dirty() +{ + _pppsetting->pppConfig.requireServerAuthentication = ( !(_mainWid->mNoAuth->isChecked()) ); + + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableEAP, _mainWid->mRefuseEap->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisablePAP, _mainWid->mRefusePap->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableCHAP, _mainWid->mRefuseChap->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableMSCHAP, _mainWid->mRefuseMschap->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::DisableMSCHAPv2, _mainWid->mRefuseMschapV2->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowBSDCompression, !(_mainWid->mNoBsd->isChecked()) ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowDeflateCompression, !(_mainWid->mNoDeflate->isChecked()) ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::AllowVJCompression, !(_mainWid->mNoVjComp->isChecked()) ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::RequireMPPE, _mainWid->mRequireMppe->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::RequireMPPE128, _mainWid->mRequireMppe128->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::StatefulMPPE, _mainWid->mStatefulMppe->isChecked() ); + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE( _pppsetting->pppConfig.flags, TDENetworkPPPFlags::UseHardwareFlowControl, _mainWid->mCrtscts->isChecked() ); + + _pppsetting->pppConfig.baudRate = _mainWid->mBaudRate->value(); + _pppsetting->pppConfig.mru = _mainWid->mMru->value(); + _pppsetting->pppConfig.mtu = _mainWid->mMtu->value(); + _pppsetting->pppConfig.lcpEchoFailureThreshold = _mainWid->mLcpEchoFailure->value(); + _pppsetting->pppConfig.lcpEchoPingInterval = _mainWid->mLcpEchoInterval->value(); + + _pppsetting->pppConfig.valid = true; +} + +#include "tdenetman-connection_setting_ppp_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.h new file mode 100644 index 0000000..983369d --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_ppp_widget.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_ppp_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H + + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// knm headers +#include "tdenetman-connection_setting_widget_interface.h" + +//class VPNService; +class ConnectionSettingPppWidget; + +namespace ConnectionSettings +{ + +class Connection; + +class PPPWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + PPPWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + void Deactivate(); + public slots: + void dirty(); + + private: + void Init(); + + TDENetworkConnection* _pppsetting; + ConnectionSettingPppWidget* _mainWid; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_PPP_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.cpp new file mode 100644 index 0000000..fe1b937 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_serial_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_setting_serial_widget.h" + +#include "connection_setting_serial.h" + +using namespace ConnectionSettings; + +SerialWidgetImpl::SerialWidgetImpl(TDENetworkConnection* conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _serialsetting = conn; + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingSerialWidget(this); + layout->addWidget(_mainWid); + _mainWid->mBaudRate->setMaxValue(INT_MAX); + Init(); +} + +void +SerialWidgetImpl::Init() +{ + if (_serialsetting->serialConfig.valid) { + _mainWid->mBaudRate->setValue(_serialsetting->serialConfig.baudRate); + _mainWid->mDataBits->setCurrentItem(_serialsetting->serialConfig.byteWidth - 7); + setParityType(_serialsetting->serialConfig.parity); + _mainWid->mStopBits->setCurrentItem(_serialsetting->serialConfig.stopBits); + _mainWid->mSendDelay->setValue(_serialsetting->serialConfig.txDelay); + } + + connect( _mainWid->mBaudRate, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); + connect( _mainWid->mDataBits, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); + connect( _mainWid->mParity, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); + connect( _mainWid->mStopBits, TQT_SIGNAL(activated(int)), TQT_SLOT(dirty())); + connect( _mainWid->mSendDelay, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dirty())); +} + +void +SerialWidgetImpl::Deactivate() +{ +} + +void +SerialWidgetImpl::Activate() +{ + +} + +void +SerialWidgetImpl::dirty() +{ + _serialsetting->serialConfig.baudRate = _mainWid->mBaudRate->value(); + _serialsetting->serialConfig.byteWidth = _mainWid->mDataBits->currentItem() + 7; + _serialsetting->serialConfig.parity = getParityType(); + _serialsetting->serialConfig.stopBits = _mainWid->mStopBits->currentItem(); + _serialsetting->serialConfig.txDelay = _mainWid->mSendDelay->value(); + + _serialsetting->serialConfig.valid = true; +} + +void +SerialWidgetImpl::setParityType(TDENetworkParity::TDENetworkParity type) +{ + if (type == TDENetworkParity::None) { + _mainWid->mParity->setCurrentItem(0); + } + else if (type == TDENetworkParity::Even) { + _mainWid->mParity->setCurrentItem(1); + } + else if (type == TDENetworkParity::Odd) { + _mainWid->mParity->setCurrentItem(2); + } + else { + _mainWid->mParity->setCurrentItem(0); + } +} + +TDENetworkParity::TDENetworkParity +SerialWidgetImpl::getParityType() +{ + int itemNo = _mainWid->mParity->currentItem(); + if (itemNo == 0) { + return TDENetworkParity::None; + } + else if (itemNo == 1) { + return TDENetworkParity::Even; + } + else if (itemNo == 2) { + return TDENetworkParity::Odd; + } + else { + return TDENetworkParity::None; + } +} + +#include "tdenetman-connection_setting_serial_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.h new file mode 100644 index 0000000..d597c9b --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_serial_widget.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_serial_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2008 Novell, Inc. + * + * Author: Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H + + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// knm headers +#include "tdenetman-connection_setting_widget_interface.h" + +//class VPNService; +class ConnectionSettingSerialWidget; + +namespace ConnectionSettings +{ + +class Connection; + +class SerialWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + SerialWidgetImpl(TDENetworkConnection* conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + void Deactivate(); + public slots: + void dirty(); + + private: + void Init(); + + void setParityType(TDENetworkParity::TDENetworkParity type); + TDENetworkParity::TDENetworkParity getParityType(); + + TDENetworkConnection* _serialsetting; + ConnectionSettingSerialWidget* _mainWid; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_SERIAL_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp new file mode 100644 index 0000000..4196989 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp @@ -0,0 +1,206 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_vpn_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection.h" +#include "tdenetman-connection_setting_vpn.h" +#include "tdenetman-connection_setting_vpn_widget.h" +#include "tdenetman-device.h" +#include "tdenetman-vpnmanager.h" +#include "tdenetman-vpnservice.h" + +using namespace ConnectionSettings; + +VPNWidgetImpl::VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) + , _new_conn(new_conn) +{ + _vpnsetting = dynamic_cast (conn->getSetting(NM_SETTING_VPN_SETTING_NAME)); + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingVPNWidget(this); + layout->addWidget(_mainWid); + + Init(); +} + +void +VPNWidgetImpl::Init() +{ + // fill in all possible VPN services + VPNServiceList list = VPNManager::getVPNServices(); + + if (list.isEmpty()) + { + // FIXME Do something useful here + } + else + { + int index = 0; + for (VPNServiceList::Iterator it = list.begin(); it != list.end(); ++it) + { + TQString icon; + TQString disp_name; + + // get service icon and display name + VPNService* service = *it; + if (service) + { + icon = service->getIcon(); + disp_name = service->getDisplayName(); + } + + if (strcmp(disp_name, "vpnc") == 0) { + disp_name = "Cisco VPN"; + } + else if (strcmp(disp_name, "pptp") == 0) { + disp_name = "Microsoft PPTP VPN"; + } + else if (strcmp(disp_name, "openvpn") == 0) { + disp_name = "Open VPN"; + } + else if (strcmp(disp_name, "strongswan") == 0) { + disp_name = "StrongSwan VPN"; + } + + // the service should not get changed when editing a connection + if (service->getService() != _vpnsetting->getServiceType() && !_new_conn) + continue; + + // no special icon for this service, use default + if (icon.isEmpty()) + icon = "encrypted"; + + _mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index); + _mapServiceCombo.insert(index++, *it); + + if (service->getService() == _vpnsetting->getServiceType()) + { + // preselect the correct service + _mainWid->cboServices->setCurrentItem(index - 1); + slotServiceComboActivated(index - 1); + } + } + } + + // lock the combo when editing an already existing connection + if (!_new_conn) + _mainWid->cboServices->setEnabled(false); + else + { + // preselect the correct service + _mainWid->cboServices->setCurrentItem(0); + slotServiceComboActivated(0); + } + + // update the username to the current one + KUser user; + _vpnsetting->setUserName(user.loginName()); + + // notification if VPN service is selected + connect(_mainWid->cboServices, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotServiceComboActivated(int))); +} + +VPNConfigWidget* +VPNWidgetImpl::getVPNConfigWidget(VPNService* service) +{ + if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) + { + // return the already available config widget + return *_mapServiceWidget.find(service); + } + else + { + // we have to create a new one + VPNPlugin* plugin = service->getVPNPlugin(); + if (plugin) + { + VPNConfigWidget* config = plugin->CreateConfigWidget(_mainWid->widgetStack); + _mapServiceWidget.insert(service, config); + return config; + } + } + return NULL; +} + + +void +VPNWidgetImpl::slotServiceComboActivated(int index) +{ + VPNService* service; + if (_mapServiceCombo.find(index) != _mapServiceCombo.end()) + { + service = *_mapServiceCombo.find(index); + if (service) + { + VPNConfigWidget* config = getVPNConfigWidget(service); + _mainWid->widgetStack->raiseWidget(config); + + config->setVPNData(_vpnsetting->getRoutes(), _vpnsetting->getData()); + } + } + else + { + //FIXME - do something useful here + } +} + +void +VPNWidgetImpl::Deactivate() +{ + // update the setting from the currently selected vpn service + VPNService* service = *_mapServiceCombo.find(_mainWid->cboServices->currentItem()); + if (service) + { + // set the correct service type + _vpnsetting->setServiceType(service->getService()); + + VPNConfigWidget* config = *_mapServiceWidget.find(service); + if (config) + { + // update the vpn properties + _vpnsetting->setData(config->getVPNProperties()); + } + } +} + +void +VPNWidgetImpl::Activate() +{ + +} + +#include "tdenetman-connection_setting_vpn_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.h new file mode 100644 index 0000000..a00ec17 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_vpn_widget.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H + + +// qt headers +#include +#include + +// knm headers +#include "connection_setting_vpn.h" +#include "tdenetman-connection_setting_widget_interface.h" +#include "tdenetman-device.h" + +class VPNService; +class VPNConfigWidget; + +namespace ConnectionSettings +{ + +class Connection; + +class VPNWidgetImpl : public WidgetInterface +{ + Q_OBJECT + + public: + VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); + void Activate(); + void Deactivate(); + public slots: + void slotServiceComboActivated(int); + + private: + void Init(); + VPNConfigWidget* getVPNConfigWidget(VPNService* service); + + bool _new_conn; + VPN* _vpnsetting; + ConnectionSettingVPNWidget* _mainWid; + TQMap _mapServiceCombo; + TQMap _mapServiceWidget; +}; + +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_VPN_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.cpp new file mode 100644 index 0000000..2be4796 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_widget_interface.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include "tdenetman-connection_setting_widget_interface.h" + +using namespace ConnectionSettings; + +WidgetInterface::WidgetInterface(TQWidget* parent, const char* name, WFlags fl) + : TQWidget(parent, name, fl) +{ + +} + +#include "tdenetman-connection_setting_widget_interface.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.h new file mode 100644 index 0000000..82755b5 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_widget_interface.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_widget_interface.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H +#define KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H + +// qt headers +#include + +namespace ConnectionSettings +{ + + class WidgetInterface : public TQWidget + { + Q_OBJECT + + public: + WidgetInterface(TQWidget* parent = NULL, const char* name = 0, WFlags fl = 0); + virtual void Activate() = 0; + virtual void Deactivate() {}; + signals: + void next(); + }; +} + +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIDGET_INTERFACE_H */ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.cpp new file mode 100644 index 0000000..7647136 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.cpp @@ -0,0 +1,1029 @@ +/*************************************************************************** + * + * tdenetman-connection_setting_wireless_security_widget.cpp + * - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +/* qt headers */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* kde headers */ +#include +#include +#include +#include + +/* tdenetman headers */ +#include "tdenetman-connection_setting_wireless_security_widget.h" +#include "sha1.h" +#include "md5.h" +#include "tdenetman-wireless_manager.h" + +#define WPA_PMK_LEN 32 + +#define SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(x,y,z) { \ + if (z) { \ + x |= y; \ + } \ + else { \ + x &= (~y); \ + } \ + } + +using namespace ConnectionSettings; + +/* + class WirelessSecurityWEPImpl +*/ +WirelessSecurityWEPImpl::WirelessSecurityWEPImpl(TDEWiFiConnection* sec, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityWEP(parent, name, fl) + , _security_setting(sec) + , _wepKeyType( WEPKEY_TYPE_HEX ) +{ + cboAuthentication->insertItem(i18n("Open System"), 0); + cboAuthentication->insertItem(i18n("Shared Key"), 1); + if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Open) { + cboAuthentication->setCurrentItem(0); + } + else if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Shared) { + cboAuthentication->setCurrentItem(1); + } + + cbKeyType->insertItem(i18n("WEP 40/128-bit ASCII"), WEPKEY_TYPE_ASCII); + cbKeyType->insertItem(i18n("WEP 40/128-bit Hexadecimal"), WEPKEY_TYPE_HEX); + cbKeyType->insertItem(i18n("WEP 128-bit passphrase"), WEPKEY_TYPE_PASSPHRASE); + cbKeyType->setCurrentItem(_wepKeyType ); + + txtWEPKey0->setText(_security_setting->securitySettings.wepKey0); + txtWEPKey1->setText(_security_setting->securitySettings.wepKey1); + txtWEPKey2->setText(_security_setting->securitySettings.wepKey2); + txtWEPKey3->setText(_security_setting->securitySettings.wepKey3); + + switch(_security_setting->securitySettings.wepKeyIndex) + { + case 0: + rbKeyIdx0->setChecked(true); + break; + case 1: + rbKeyIdx1->setChecked(true); + break; + case 2: + rbKeyIdx2->setChecked(true); + break; + case 3: + rbKeyIdx3->setChecked(true); + break; + default: + rbKeyIdx0->setChecked(true); + break; + } + + connect(cboAuthentication, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotAuthAlgChanged(int))); + connect(cbKeyType, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotKeyTypeChanged(int))); + connect(txtWEPKey0, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey0Changed(const TQString&))); + connect(txtWEPKey1, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey1Changed(const TQString&))); + connect(txtWEPKey2, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey2Changed(const TQString&))); + connect(txtWEPKey3, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotWepKey3Changed(const TQString&))); + + connect(rbKeyIdx0, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx0Checked(bool))); + connect(rbKeyIdx1, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx1Checked(bool))); + connect(rbKeyIdx2, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx2Checked(bool))); + connect(rbKeyIdx3, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWepIdx3Checked(bool))); +} + +void WirelessSecurityWEPImpl::slotAuthAlgChanged(int index) +{ + if (index == 0) { + _security_setting->securitySettings.authType =TDENetworkWiFiAuthType::Open; + } + else if (index == 1) { + _security_setting->securitySettings.authType = TDENetworkWiFiAuthType::Shared; + } +} + +void WirelessSecurityWEPImpl::slotKeyTypeChanged(int index) +{ + _wepKeyType = (WEPKEY_TYPE)index; + + // update all WEP-Keys here due to the new key_type +} + +void WirelessSecurityWEPImpl::slotWepKey0Changed(const TQString &key) +{ + TQCString hashed = getHashedWEPKey(key, _wepKeyType); + _security_setting->securitySettings.wepKey0 = hashed; +} + +void WirelessSecurityWEPImpl::slotWepKey1Changed(const TQString &key) +{ + TQCString hashed = getHashedWEPKey(key, _wepKeyType); + _security_setting->securitySettings.wepKey1 = hashed; +} + +void WirelessSecurityWEPImpl::slotWepKey2Changed(const TQString &key) +{ + TQCString hashed = getHashedWEPKey(key, _wepKeyType); + _security_setting->securitySettings.wepKey2 = hashed; +} + +void WirelessSecurityWEPImpl::slotWepKey3Changed(const TQString& key) +{ + TQCString hashed = getHashedWEPKey(key, _wepKeyType); + _security_setting->securitySettings.wepKey3 = hashed; +} + +void WirelessSecurityWEPImpl::slotWepIdx0Checked(bool check) +{ + if (check) { + _security_setting->securitySettings.wepKeyIndex = 0; + } +} + +void WirelessSecurityWEPImpl::slotWepIdx1Checked(bool check) +{ + if (check) { + _security_setting->securitySettings.wepKeyIndex = 1; + } +} + +void WirelessSecurityWEPImpl::slotWepIdx2Checked(bool check) +{ + if (check) { + _security_setting->securitySettings.wepKeyIndex = 2; + } +} + +void WirelessSecurityWEPImpl::slotWepIdx3Checked(bool check) +{ + if (check) { + _security_setting->securitySettings.wepKeyIndex = 3; + } +} + +TQCString +WirelessSecurityWEPImpl::getHashedWEPKey(TQString key, WEPKEY_TYPE type) const +{ + TQCString hashed; + switch(type) + { + case WEPKEY_TYPE_HEX: + return TQCString(key); + break; + case WEPKEY_TYPE_ASCII: + hashed = String2Hex(TQCString(key), key.length() * 2); + return hashed; + break; + case WEPKEY_TYPE_PASSPHRASE: + return getWEP128PassphraseHash(TQCString(key)); + break; + } + return hashed; +} + +TQCString +WirelessSecurityWEPImpl::getWEP128PassphraseHash(TQCString input) const +{ + char md5_data[65]; + TQCString digest(16); + int input_len; + int i; + + if (input.isNull()) return input; + + input_len = input.length(); + if (input_len < 1) + return TQCString(); + + /* Get at least 64 bytes */ + for (i = 0; i < 64; i++) + md5_data [i] = input [i % input_len]; + + /* Null terminate md5 seed data and hash it */ + md5_data[64] = 0; + gnome_keyring_md5_string (md5_data, (unsigned char*)digest.data()); + return (String2Hex(TQByteArray(digest), 26)); + +} + +TQCString +WirelessSecurityWEPImpl::String2Hex(TQByteArray bytes, int final_len) const +{ + TQCString result(final_len+1); + static char hex_digits[] = "0123456789abcdef"; + result.resize(bytes.size() * 2 + 1); + for (uint i = 0; i < bytes.size(); i++) + { + result[2*i] = hex_digits[(bytes[i] >> 4) & 0xf]; + result[2*i+1] = hex_digits[bytes[i] & 0xf]; + } + /* Cut converted key off at the correct length for this cipher type */ + if (final_len > -1) + result[final_len] = '\0'; + return result; +} + + +/* + class WirelessSecurityWEPEncryptionImpl +*/ +WirelessSecurityWEPEncryptionImpl::WirelessSecurityWEPEncryptionImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityWEPEncryption(parent, name, fl) + , _security_setting(security_setting) +{ + cboEncryption->insertItem(i18n("None")); + cboEncryption->insertItem(i18n("Dynamic WEP")); +} + + +/* + class WirelessSecurityWPAVersionImpl +*/ +WirelessSecurityWPAVersionImpl::WirelessSecurityWPAVersionImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityWPAVersion(parent, name, fl) + , _security_setting(security_setting) +{ + cbWPA->setChecked(_security_setting->securitySettings.wpaVersion & TDENetworkWiFiWPAVersionFlags::WPA); + cbRSN->setChecked(_security_setting->securitySettings.wpaVersion & TDENetworkWiFiWPAVersionFlags::RSN); + + connect(cbWPA, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWPA1(bool))); + connect(cbRSN, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotWPA2(bool))); + + connect(grpUseWPAVersion, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotAuto(bool))); +} + +void +WirelessSecurityWPAVersionImpl::slotAuto(bool on) +{ + if (!on) { + // auto-select proto + _security_setting->securitySettings.wpaVersion = TDENetworkWiFiWPAVersionFlags::Any; + } + else { + // use selected wpa-version + TDENetworkWiFiWPAVersionFlags::TDENetworkWiFiWPAVersionFlags proto = TDENetworkWiFiWPAVersionFlags::None; + if (cbWPA->isChecked()) { + proto |= TDENetworkWiFiWPAVersionFlags::WPA; + } + if (cbRSN->isChecked()) { + proto |= TDENetworkWiFiWPAVersionFlags::RSN; + } + _security_setting->securitySettings.wpaVersion = proto; + } +} + +void +WirelessSecurityWPAVersionImpl::slotWPA1(bool on) +{ + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(_security_setting->securitySettings.wpaVersion, TDENetworkWiFiWPAVersionFlags::WPA, on); +} + +void +WirelessSecurityWPAVersionImpl::slotWPA2(bool on) +{ + SET_FLAG_IF_TRUE_CLEAR_IF_FALSE(_security_setting->securitySettings.wpaVersion, TDENetworkWiFiWPAVersionFlags::RSN, on); +} + +/* + class WirelessSecurityWPACipherImpl +*/ +WirelessSecurityWPACipherImpl::WirelessSecurityWPACipherImpl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityWPACipher(parent, name, fl) + , _security_setting(security_setting) +{ + connect(grpUseCipher, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotCipherChangedAuto(bool))); + + connect(chkGroupCipherTKIP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedTKIP(bool))); + connect(chkGroupCipherCCMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedCCMP(bool))); + connect(chkGroupCipherWEP40, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedWEP40(bool))); + connect(chkGroupCipherWEP104, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotGroupCipherChangedWEP104(bool))); + + connect(chkPairwiseCipherTKIP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotPairwiseCipherChangedTKIP(bool))); + connect(chkPairwiseCipherCCMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotPairwiseCipherChangedCCMP(bool))); + + chkPairwiseCipherCCMP->setChecked(_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)); + chkPairwiseCipherTKIP->setChecked(_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)); + + chkGroupCipherCCMP->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)); + chkGroupCipherTKIP->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)); + chkGroupCipherWEP40->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)); + chkGroupCipherWEP104->setChecked(_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::Any) || _security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)); + +} + +void +WirelessSecurityWPACipherImpl::slotCipherChangedAuto(bool checked) +{ + if (!checked) + { + // select auto for both ciphers + _security_setting->securitySettings.allowedGroupWiseCiphers.clear(); + _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any); + _security_setting->securitySettings.allowedPairWiseCiphers.clear(); + _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::Any); + } + else + { + // use the already selected ciphers + + // group cipher + TDENetworkWiFiConnectionCipherList cipher; + if (chkGroupCipherTKIP->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherTKIP); + } + if (chkGroupCipherCCMP->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherCCMP); + } + if (chkGroupCipherWEP40->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherWEP40); + } + if (chkGroupCipherWEP104->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherWEP104); + } + _security_setting->securitySettings.allowedGroupWiseCiphers = cipher; + + // pairwise cipher + cipher.clear(); + if (chkPairwiseCipherTKIP->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherTKIP); + } + if (chkPairwiseCipherCCMP->isChecked()) { + cipher.append(TDENetworkWiFiConnectionCipher::CipherCCMP); + } + _security_setting->securitySettings.allowedPairWiseCiphers = cipher; + + } +} + +void +WirelessSecurityWPACipherImpl::slotGroupCipherChangedTKIP(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP); + } + else { + _security_setting->securitySettings.allowedGroupWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherTKIP); + } +} + +void +WirelessSecurityWPACipherImpl::slotGroupCipherChangedCCMP(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedGroupWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) _security_setting->securitySettings.allowedGroupWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP); + } + else { + _security_setting->securitySettings.allowedGroupWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherCCMP); + } +} + +void +WirelessSecurityWPACipherImpl::slotGroupCipherChangedWEP40(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP40)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP40); + } + else { + _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherWEP40); + } +} + +void +WirelessSecurityWPACipherImpl::slotGroupCipherChangedWEP104(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherWEP104)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherWEP104); + } + else { + _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherWEP104); + } +} + +void +WirelessSecurityWPACipherImpl::slotPairwiseCipherChangedTKIP(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherTKIP)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherTKIP); + } + else { + _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherTKIP); + } +} + +void +WirelessSecurityWPACipherImpl::slotPairwiseCipherChangedCCMP(bool checked) +{ + if (checked) { + if (!_security_setting->securitySettings.allowedPairWiseCiphers.contains(TDENetworkWiFiConnectionCipher::CipherCCMP)) _security_setting->securitySettings.allowedPairWiseCiphers.append(TDENetworkWiFiConnectionCipher::CipherCCMP); + } + else { + _security_setting->securitySettings.allowedPairWiseCiphers.remove(TDENetworkWiFiConnectionCipher::CipherCCMP); + } +} + +/* + class WirelessSecurityWPAPSK +*/ +WirelessSecurityWPAPSKImpl::WirelessSecurityWPAPSKImpl(TDEWiFiConnection* security_setting, TDEWiFiConnection* wireless_setting, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityWPAPSK(parent, name, fl) + , _security_setting(security_setting) + , _wireless_setting(wireless_setting) +{ + if (_security_setting->securitySettings.secretsValid) { + txtPSK->setText(_security_setting->securitySettings.psk); + } + connect(txtPSK, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotPSKChanged(const TQString&))); +} + +void +WirelessSecurityWPAPSKImpl::slotPSKChanged(const TQString& psk) +{ + if (_wireless_setting) + { + _security_setting->securitySettings.psk = psk; + _security_setting->securitySettings.secretsValid = true; + } +} + +TQCString +WirelessSecurityWPAPSKImpl::String2Hex(TQByteArray bytes, int final_len) const +{ + TQCString result(final_len+1); + static char hex_digits[] = "0123456789abcdef"; + result.resize(bytes.size() * 2 + 1); + for (uint i = 0; i < bytes.size(); i++) + { + result[2*i] = hex_digits[(bytes[i] >> 4) & 0xf]; + result[2*i+1] = hex_digits[bytes[i] & 0xf]; + } + /* Cut converted key off at the correct length for this cipher type */ + if (final_len > -1) + result[final_len] = '\0'; + return result; +} + +/* + class WirelessSecurityEAPImpl +*/ +WirelessSecurityEAPImpl::WirelessSecurityEAPImpl(TDEWiFiConnection* security_setting, WirelessSecurityPhase2Impl* phase2_widget, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityEAP(parent, name, fl) + , _security_setting(security_setting) + , _phase2_widget(phase2_widget) +{ + // insert all EAP-Methods + int index = 0; + cboMethod->insertItem(i18n("None"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::None; + + cboMethod->insertItem(i18n("TTLS"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::TTLS; + + cboMethod->insertItem(i18n("PEAP"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::PEAP; + + cboMethod->insertItem(i18n("TLS"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::TLS; + + cboMethod->insertItem(i18n("Leap"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::LEAP; + + cboMethod->insertItem(i18n("MD5"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::MD5; + + cboMethod->insertItem(i18n("FAST"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::Fast; + + cboMethod->insertItem(i18n("SIM"), ++index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::SIM; + + // preselect the correct method + TQBiDirectionalMap::Iterator it = _eapIndexMap.findData(_security_setting->eapConfig.type); + cboMethod->setCurrentItem(it.key()); + + // update phase2 combobox + _phase2_widget->setAllowedPhase2Methods(_security_setting->eapConfig.allowedPhase2EAPMethods); + + txtIdentity->setText(_security_setting->eapConfig.userName); + txtAnonIdentity->setText(_security_setting->eapConfig.anonymousUserName); + if (_security_setting->eapConfig.secretsValid) { + txtPassword->setText(_security_setting->eapConfig.password); + } + + chkCAStore->setChecked(_security_setting->eapConfig.forceSystemCaCertificates); + kURLCACert->setEnabled(!_security_setting->eapConfig.forceSystemCaCertificates); + + // get notified if the method changes + connect(cboMethod, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMethodChanged(int))); + connect(txtIdentity, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotIdentityChanged(const TQString&))); + connect(txtAnonIdentity, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotAnonIdentityChanged(const TQString&))); + connect(txtPassword, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotPasswordChanged(const TQString&))); + connect(chkCAStore, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUseSystemCaCertChanged(bool))); +} + +void WirelessSecurityEAPImpl::slotUseSystemCaCertChanged(bool on) +{ + _security_setting->eapConfig.forceSystemCaCertificates = on; + kURLCACert->setEnabled(!on); +} + +void WirelessSecurityEAPImpl::slotMethodChanged(int index) +{ + // new method choosen + TDENetworkIEEE8021xType::TDENetworkIEEE8021xType eap = _eapIndexMap[index]; + _security_setting->eapConfig.type = eap; + + _phase2_widget->setAllowedPhase2Methods(_security_setting->eapConfig.allowedPhase2EAPMethods); +} + +void WirelessSecurityEAPImpl::slotIdentityChanged(const TQString& identity) +{ + _security_setting->eapConfig.userName = identity; +} + +void WirelessSecurityEAPImpl::slotAnonIdentityChanged(const TQString& identity) +{ + _security_setting->eapConfig.anonymousUserName = identity; +} + +void WirelessSecurityEAPImpl::slotPasswordChanged(const TQString& pwd) +{ + _security_setting->eapConfig.password = TQString(txtPassword->password()); + _security_setting->eapConfig.secretsValid = true; +} + +/* + class WirelessSecurityPhase2Impl +*/ +WirelessSecurityPhase2Impl::WirelessSecurityPhase2Impl(TDEWiFiConnection* security_setting, TQWidget* parent, const char* name, WFlags fl) + : ConnectionSettingWirelessSecurityPhase2(parent, name, fl) + , _security_setting(security_setting) +{ + _allowed_methods.append(TDENetworkIEEE8021xType::None); + updateMethodComboBox(); + + connect(cboPhase2Method, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotPhase2MethodChanged(int))); +} + +void WirelessSecurityPhase2Impl::updateMethodComboBox() +{ + // insert all phase2 EAP-Methods + int index = 0; + cboPhase2Method->clear(); + _eapIndexMap.clear(); + + for (TQValueList::Iterator it = _allowed_methods.begin(); it != _allowed_methods.end(); ++it) + { + if ((*it) == TDENetworkIEEE8021xType::None) + { + cboPhase2Method->insertItem(i18n("None"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::None; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::MSCHAPV2) + { + cboPhase2Method->insertItem(i18n("MSCHAPv2"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::MSCHAPV2; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::PAP) + { + cboPhase2Method->insertItem(i18n("PAP"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::PAP; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::CHAP) + { + cboPhase2Method->insertItem(i18n("CHAP"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::CHAP; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::MSCHAP) + { + cboPhase2Method->insertItem(i18n("MSCHAP"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::MSCHAP; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::GTC) + { + cboPhase2Method->insertItem(i18n("GTC"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::GTC; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::OTP) + { + cboPhase2Method->insertItem(i18n("OTP"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::OTP; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::MD5) + { + cboPhase2Method->insertItem(i18n("MD5"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::MD5; + index++; + } + else if ((*it) == TDENetworkIEEE8021xType::TLS) + { + cboPhase2Method->insertItem(i18n("TLS"), index); + _eapIndexMap[index] = TDENetworkIEEE8021xType::TLS; + index++; + } + } + + // preselect the correct method + TQBiDirectionalMap::Iterator it = _eapIndexMap.findData(_security_setting->eapConfig.phase2EAPAuthMethod); + if (it != _eapIndexMap.end()) + { + cboPhase2Method->setCurrentItem(it.key()); + _security_setting->eapConfig.phase2EAPAuthMethod = it.data(); + } + else + { + cboPhase2Method->setCurrentItem(0); + _security_setting->eapConfig.phase2EAPAuthMethod = _eapIndexMap[0]; + } +} + +void WirelessSecurityPhase2Impl::setAllowedPhase2Methods(const TQValueList& list) +{ + _allowed_methods = list; + updateMethodComboBox(); +} + +void WirelessSecurityPhase2Impl::slotPhase2MethodChanged(int index) +{ + // new method choosen + TDENetworkIEEE8021xType::TDENetworkIEEE8021xType eap = _eapIndexMap[index]; + _security_setting->eapConfig.phase2EAPAuthMethod = eap; +} + +/* + class WirelessSecurityWidgetImpl +*/ + +WirelessSecurityWidgetImpl::WirelessSecurityWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _security_setting = dynamic_cast (conn); + _wireless_setting = dynamic_cast (conn); + _ieee8021x_setting = dynamic_cast (conn); + _new_conn = new_conn; + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingWirelessSecurityWidget(this); + layout->addWidget(_mainWid); + + TQTimer::singleShot(0, this, TQT_SLOT(slotInit())); +} + +void +WirelessSecurityWidgetImpl::slotInit() +{ + // create all security widgets... + TQWidget* wep = new WirelessSecurityWEPImpl(_security_setting, _mainWid->groupUseEncryption); + TQWidget* phase2 = new WirelessSecurityPhase2Impl(_ieee8021x_setting, _mainWid->groupUseEncryption); + TQWidget* eap = new WirelessSecurityEAPImpl(_ieee8021x_setting, (WirelessSecurityPhase2Impl*)phase2, _mainWid->groupUseEncryption); + TQWidget* wpaversion = new WirelessSecurityWPAVersionImpl(_security_setting, _mainWid->groupUseEncryption); + TQWidget* wpacipher = new WirelessSecurityWPACipherImpl(_security_setting, _mainWid->groupUseEncryption); + TQWidget* wpapsk = new WirelessSecurityWPAPSKImpl(_security_setting, _wireless_setting, _mainWid->groupUseEncryption); + TQWidget* wepencryption = new WirelessSecurityWEPEncryptionImpl(_security_setting, _mainWid->groupUseEncryption); + + wep->setHidden(true); + eap->setHidden(true); + wpaversion->setHidden(true); + wpacipher->setHidden(true); + phase2->setHidden(true); + wpapsk->setHidden(true); + wepencryption->setHidden(true); + + _widgets[SECURITY_WEP].clear(); + _widgets[SECURITY_WPA_PSK].clear(); + _widgets[SECURITY_WPA_EAP].clear(); + _widgets[SECURITY_IEEE8021X].clear(); + + // create WEP widget list + _widgets[SECURITY_WEP].append(wep); + + // create WPA PSK widget list + _extra_widgets[SECURITY_WPA_PSK].append(wpaversion); + _extra_widgets[SECURITY_WPA_PSK].append(wpacipher); + _widgets[SECURITY_WPA_PSK].append(wpapsk); + + // create WPA EAP widget list + _extra_widgets[SECURITY_WPA_EAP].append(wpaversion); + _extra_widgets[SECURITY_WPA_EAP].append(wpacipher); + _widgets[SECURITY_WPA_EAP].append(eap); + _widgets[SECURITY_WPA_EAP].append(phase2); + + // create IEEE8021X widget list + _widgets[SECURITY_IEEE8021X].append(wepencryption); + _widgets[SECURITY_IEEE8021X].append(eap); + + connect(_mainWid->cboSecurity, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotComboSecurityActivated(int))); + connect(_mainWid->groupUseEncryption, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotUseEncryptionToggled(bool))); + connect(_mainWid->pbExtra, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotExtraSettingsToggled(bool))); + +} + +void +WirelessSecurityWidgetImpl::Activate() +{ + kdDebug() << "Activate " << (_new_conn ? "New" : "Edit") << endl; + comboSecurityInit(); +} + +void +WirelessSecurityWidgetImpl::comboSecurityInit() +{ + int index = 0; + + TQValueList allowed_methods; + _mainWid->cboSecurity->clear(); + + // TODO: Preselect the right security method + // We should have an Essid already, fetch all possible APs + TQValueList aps; + if (_new_conn && !_wireless_setting->SSID.isEmpty()) { + aps = WirelessManager::getAccessPointsForEssid(_wireless_setting->SSID); +#if 0 + kdDebug() << "Hugo " << TQString(TQCString(_wireless_setting->getEssid())).ascii() << endl; +#endif + } + if (!aps.isEmpty()) { + // if at least one AP has this security setting show the entry in the combobox + for (TQValueList::Iterator it = aps.begin(); it != aps.end(); ++it) { + if (((*it)->wpaFlags & TDENetworkWiFiAPFlags::PrivacySupport) || ((*it)->rsnFlags & TDENetworkWiFiAPFlags::PrivacySupport)) { + kdDebug() << "AP " << (*it)->friendlySSID().ascii() << " is encrypted" << endl; + if ((((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) || (((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) { + // WPA or RSN + if ((*it)->rsnFlags & TDENetworkWiFiAPFlags::KeyManagementPSK || (*it)->wpaFlags & TDENetworkWiFiAPFlags::KeyManagementPSK) { + if (!allowed_methods.contains(SECURITY_WPA_PSK)) { + allowed_methods.append(SECURITY_WPA_PSK); + } + } + + if ((*it)->rsnFlags & TDENetworkWiFiAPFlags::KeyManagement80211 || (*it)->wpaFlags & TDENetworkWiFiAPFlags::KeyManagement80211) { + if (!allowed_methods.contains(SECURITY_WPA_EAP)) { + allowed_methods.append(SECURITY_WPA_EAP); + } + } + } + + // No WPA & RSN => WEP or dynamic WEP with 802.1x authentication + // TODO: an AP can provide WEP in addition to WPA + if (!allowed_methods.contains(SECURITY_WEP)) { + allowed_methods.append(SECURITY_WEP); + } + if (!allowed_methods.contains(SECURITY_IEEE8021X)) { + allowed_methods.append(SECURITY_IEEE8021X); + } + } + } + + // insert only allowed security methods + if (allowed_methods.contains(SECURITY_WPA_PSK)) + { + _securityComboMap.insert(index, SECURITY_WPA_PSK); + _mainWid->cboSecurity->insertItem(i18n("WPA Personal"), index++); + } + + if (allowed_methods.contains(SECURITY_WPA_EAP)) + { + _securityComboMap.insert(index, SECURITY_WPA_EAP); + _mainWid->cboSecurity->insertItem(i18n("WPA Enterprise"), index++); + } + + if (allowed_methods.contains(SECURITY_WEP)) + { + _securityComboMap.insert(index, SECURITY_WEP); + _mainWid->cboSecurity->insertItem(i18n("WEP"), index++); + } + + if (allowed_methods.contains(SECURITY_IEEE8021X)) + { + _securityComboMap.insert(index, SECURITY_IEEE8021X); + _mainWid->cboSecurity->insertItem(i18n("IEEE 802.1X"), index++); + } + } + else + { + // insert all possible authentication methods + _mainWid->cboSecurity->insertItem(i18n("WEP"),SECURITY_WEP ); + _mainWid->cboSecurity->insertItem(i18n("WPA Personal"), SECURITY_WPA_PSK); + _mainWid->cboSecurity->insertItem(i18n("WPA Enterprise"), SECURITY_WPA_EAP); + _mainWid->cboSecurity->insertItem(i18n("IEEE 802.1X"), SECURITY_IEEE8021X); + _securityComboMap.insert(SECURITY_WEP, SECURITY_WEP); + _securityComboMap.insert(SECURITY_WPA_PSK, SECURITY_WPA_PSK); + _securityComboMap.insert(SECURITY_WPA_EAP, SECURITY_WPA_EAP); + _securityComboMap.insert(SECURITY_IEEE8021X, SECURITY_IEEE8021X); + } + + if (!_new_conn) + { + switch(_security_setting->securitySettings.keyType) + { + case TDENetworkWiFiKeyType::WEP: + if (_security_setting->securitySettings.authType == TDENetworkWiFiAuthType::Shared || + !_security_setting->securitySettings.wepKey0.isEmpty() || + !_security_setting->securitySettings.wepKey1.isEmpty() || + !_security_setting->securitySettings.wepKey2.isEmpty() || + !_security_setting->securitySettings.wepKey3.isEmpty() ) + { + _mainWid->groupUseEncryption->setChecked(true); + _mainWid->cboSecurity->setCurrentItem(SECURITY_WEP); + slotComboSecurityActivated(_securityComboMap[SECURITY_WEP]); + } + else + _mainWid->groupUseEncryption->setChecked(false); + break; + case TDENetworkWiFiKeyType::WPAInfrastructure: + _mainWid->groupUseEncryption->setChecked(true); + _mainWid->cboSecurity->setCurrentItem(SECURITY_WPA_PSK); + slotComboSecurityActivated(_securityComboMap[SECURITY_WPA_PSK]); + break; + case TDENetworkWiFiKeyType::WPAEnterprise: + _mainWid->groupUseEncryption->setChecked(true); + _mainWid->cboSecurity->setCurrentItem(SECURITY_WPA_EAP); + slotComboSecurityActivated(_securityComboMap[SECURITY_WPA_EAP]); + break; + case TDENetworkWiFiKeyType::DynamicWEP: + _mainWid->groupUseEncryption->setChecked(true); + _mainWid->cboSecurity->setCurrentItem(SECURITY_IEEE8021X); + slotComboSecurityActivated(_securityComboMap[SECURITY_IEEE8021X]); + break; + + default: + break; + } + } + else + { + // select first possible security method + if (_mainWid->cboSecurity->count() > 0) + { + _mainWid->groupUseEncryption->setChecked(true); + _mainWid->groupUseEncryption->setEnabled(true); + _mainWid->cboSecurity->setCurrentItem(0); + slotComboSecurityActivated(0); + } + else + { + _mainWid->groupUseEncryption->setChecked(false); + _mainWid->groupUseEncryption->setEnabled(false); + } + } +} + +void +WirelessSecurityWidgetImpl::slotUseEncryptionToggled(bool on) +{ + _wireless_setting->securityRequired = on; +} + +void +WirelessSecurityWidgetImpl::slotComboSecurityActivated(int index) +{ + int i = _securityComboMap[index]; + + // authentication switched, we have to show the appropriate widgets and hide some others + switch(i) + { + case SECURITY_WEP: + configureForWEP(); + break; + + case SECURITY_WPA_PSK: + configureForWPAPSK(); + break; + + case SECURITY_WPA_EAP: + configureForWPAEAP(); + break; + + case SECURITY_IEEE8021X: + configureForIEEE8021X(); + break; + + default: + // should not happen, something is broken... + break; + } +} + +void +WirelessSecurityWidgetImpl::configureWidgets(SecurityMethods method) +{ + // store selected method + _currentMethod = method; + + for (int i = 0; i < SECURITY_COUNT; ++i) + { + // remove all current widgets that do not belong to the selected method + if (i != method) + { + for (TQValueList::iterator it = _widgets[i].begin(); it != _widgets[i].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->remove(*it); + (*it)->hide(); + } + // remove extra widgets too + for (TQValueList::iterator it = _extra_widgets[i].begin(); it != _extra_widgets[i].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->remove(*it); + (*it)->hide(); + } + } + } + + // show all widgets widgets for the selected security method + for (TQValueList::iterator it = _widgets[method].begin(); it != _widgets[method].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->add(*it); + (*it)->show(); + } + + if (_mainWid->pbExtra->isOn()) + for (TQValueList::iterator it = _extra_widgets[method].begin(); it != _extra_widgets[method].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->add(*it); + (*it)->show(); + } + + // deactivate button if no extra settings are available + _mainWid->pbExtra->setEnabled(!(_extra_widgets[method].begin() == _extra_widgets[method].end())); +} + +void +WirelessSecurityWidgetImpl::slotExtraSettingsToggled(bool on) +{ + if (on) + for (TQValueList::iterator it = _extra_widgets[_currentMethod].begin(); it != _extra_widgets[_currentMethod].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->add(*it); + (*it)->show(); + } + else + for (TQValueList::iterator it = _extra_widgets[_currentMethod].begin(); it != _extra_widgets[_currentMethod].end(); ++it) + { + _mainWid->groupUseEncryption->layout()->remove(*it); + (*it)->hide(); + } +} + +void +WirelessSecurityWidgetImpl::configureForWEP() +{ + _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WEP; + configureWidgets(SECURITY_WEP); +} + +void +WirelessSecurityWidgetImpl::configureForWPAPSK() +{ + _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WPAInfrastructure; + configureWidgets(SECURITY_WPA_PSK); +} + +void +WirelessSecurityWidgetImpl::configureForWPAEAP() +{ + _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::WPAEnterprise; + configureWidgets(SECURITY_WPA_EAP); +} + +void +WirelessSecurityWidgetImpl::configureForIEEE8021X() +{ + _security_setting->securitySettings.keyType = TDENetworkWiFiKeyType::DynamicWEP; + configureWidgets(SECURITY_IEEE8021X); +} + + + + +#include "tdenetman-connection_setting_wireless_security_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.h new file mode 100644 index 0000000..e0605db --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_security_widget.h @@ -0,0 +1,240 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H + +/* ui autogenerated headers */ +#include "connection_setting_wireless_security.h" +#include "connection_setting_wireless_security_eap.h" +#include "connection_setting_wireless_security_phase2.h" +#include "connection_setting_wireless_security_wep.h" +#include "connection_setting_wireless_security_wpaversion.h" +#include "connection_setting_wireless_security_wpacipher.h" +#include "connection_setting_wireless_security_wpapsk.h" +#include "connection_setting_wireless_security_wepencryption.h" + +// tde headers +#include +#include + +/* tdenetman headers */ +#include "qbidirectionalmap.h" +#include "tdenetman-connection_setting_widget_interface.h" + +namespace ConnectionSettings +{ + /* class declarations */ + class WirelessSecurity; + class Wireless; + class WirelessSecurityPhase2Impl; + + class WirelessSecurityWEPImpl : public ConnectionSettingWirelessSecurityWEP + { + Q_OBJECT + + public: + enum WEPKEY_TYPE + { + WEPKEY_TYPE_ASCII = 0 + , WEPKEY_TYPE_HEX + , WEPKEY_TYPE_PASSPHRASE + }; + + WirelessSecurityWEPImpl(TDEWiFiConnection* security, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + TQCString getHashedWEPKey(TQString key, WEPKEY_TYPE type) const; + TQCString getWEP128PassphraseHash(TQCString input) const; + TQCString String2Hex(TQByteArray bytes, int final_len) const; + + public slots: + void slotAuthAlgChanged(int); + void slotKeyTypeChanged(int); + void slotWepKey0Changed(const TQString&); + void slotWepKey1Changed(const TQString&); + void slotWepKey2Changed(const TQString&); + void slotWepKey3Changed(const TQString&); + void slotWepIdx0Checked(bool); + void slotWepIdx1Checked(bool); + void slotWepIdx2Checked(bool); + void slotWepIdx3Checked(bool); + private: + TDEWiFiConnection* _security_setting; + WEPKEY_TYPE _wepKeyType; + }; + + class WirelessSecurityWEPEncryptionImpl : public ConnectionSettingWirelessSecurityWEPEncryption + { + Q_OBJECT + + public: + WirelessSecurityWEPEncryptionImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + private: + TDEWiFiConnection* _security_setting; + }; + + class WirelessSecurityWPAVersionImpl : public ConnectionSettingWirelessSecurityWPAVersion + { + Q_OBJECT + + public: + WirelessSecurityWPAVersionImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + + public slots: + void slotAuto(bool); + void slotWPA1(bool); + void slotWPA2(bool); + + private: + TDEWiFiConnection* _security_setting; + + }; + + class WirelessSecurityWPACipherImpl : public ConnectionSettingWirelessSecurityWPACipher + { + Q_OBJECT + + private: + enum WPA_CIPHERS + { + WPA_CIPHER_AUTO = 0 + , WPA_CIPHER_TKIP + , WPA_CIPHER_CCMP + , WPA_CIPHER_LAST + }; + public: + WirelessSecurityWPACipherImpl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + + public slots: + void slotCipherChangedAuto(bool); + void slotGroupCipherChangedTKIP(bool); + void slotGroupCipherChangedCCMP(bool); + void slotGroupCipherChangedWEP40(bool); + void slotGroupCipherChangedWEP104(bool); + void slotPairwiseCipherChangedTKIP(bool); + void slotPairwiseCipherChangedCCMP(bool); + + private: + TDEWiFiConnection* _security_setting; + }; + + class WirelessSecurityWPAPSKImpl : public ConnectionSettingWirelessSecurityWPAPSK + { + Q_OBJECT + + public: + WirelessSecurityWPAPSKImpl(TDEWiFiConnection* security_setting, TDEWiFiConnection* wireless_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + TQCString String2Hex(TQByteArray bytes, int final_len) const; + + public slots: + void slotPSKChanged(const TQString&); + + private: + TDEWiFiConnection* _security_setting; + TDEWiFiConnection* _wireless_setting; + }; + + class WirelessSecurityEAPImpl : public ConnectionSettingWirelessSecurityEAP + { + Q_OBJECT + + public: + WirelessSecurityEAPImpl(TDEWiFiConnection* security_setting, WirelessSecurityPhase2Impl* phase2_widget, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + + public slots: + void slotMethodChanged(int index); + void slotIdentityChanged(const TQString&); + void slotAnonIdentityChanged(const TQString&); + void slotPasswordChanged(const TQString&); + void slotUseSystemCaCertChanged(bool on); + + private: + TDEWiFiConnection* _security_setting; + TQBiDirectionalMap _eapIndexMap; + WirelessSecurityPhase2Impl* _phase2_widget; + }; + + class WirelessSecurityPhase2Impl : public ConnectionSettingWirelessSecurityPhase2 + { + Q_OBJECT + + public: + WirelessSecurityPhase2Impl(TDEWiFiConnection* security_setting, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + public slots: + void setAllowedPhase2Methods(const TQValueList&); + void slotPhase2MethodChanged(int index); + private: + void updateMethodComboBox(); + + TDEWiFiConnection* _security_setting; + TQBiDirectionalMap _eapIndexMap; + TQValueList _allowed_methods; + }; + + class WirelessSecurityWidgetImpl : public WidgetInterface + { + Q_OBJECT + + private: + enum SecurityMethods + { + SECURITY_WEP = 0 + , SECURITY_WPA_PSK + , SECURITY_WPA_EAP + , SECURITY_IEEE8021X + , SECURITY_COUNT + }; + + public: + WirelessSecurityWidgetImpl(TDENetworkConnection*, bool new_conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + void Activate(); + + public slots: + void slotComboSecurityActivated(int); + void slotUseEncryptionToggled(bool); + void slotExtraSettingsToggled(bool); + + private slots: + void slotInit(); + + private: + void comboSecurityInit(); + void configureWidgets(SecurityMethods); + void configureForWEP(); + void configureForWPAPSK(); + void configureForWPAEAP(); + void configureForIEEE8021X(); + + SecurityMethods _currentMethod; + TQValueList _widgets[SECURITY_COUNT]; + TQValueList _extra_widgets[SECURITY_COUNT]; + TDEWiFiConnection* _security_setting; + TDEWiFiConnection* _wireless_setting; + TDEWiFiConnection* _ieee8021x_setting; + ConnectionSettingWirelessSecurityWidget* _mainWid; + bool _new_conn; + TQMap _securityComboMap; + }; +} + +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_SECURITY_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.cpp new file mode 100644 index 0000000..c5b70bd --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.cpp @@ -0,0 +1,230 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Valentine Sinitsyn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "tdenetman-connection_setting_widget_interface.h" +#include "tdenetman-connection_setting_wireless_widget.h" +#include "tdenetman-wireless_manager.h" + +using namespace ConnectionSettings; + +class NetworkListViewItem : public KListViewItem +{ + public: + + NetworkListViewItem(TQListView* parent, WirelessNetwork& net) + : KListViewItem(parent, TQString::fromUtf8(net.getDisplaySsid()), TQString("%1\%").arg(net.getStrength())) + , _net(net) + { + TQ_UINT8 strength = net.getStrength(); + if (strength > 80) + setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_100", KIcon::Small)); + else if (strength > 55) + setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_75", KIcon::Small)); + else if (strength > 30) + setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_50", KIcon::Small)); + else if (strength > 5) + setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_25", KIcon::Small)); + else + setPixmap(1, KGlobal::iconLoader()->loadIcon("nm_signal_00", KIcon::Small)); + + if (net.isEncrypted()) + setPixmap(2, KGlobal::iconLoader()->loadIcon("lock", KIcon::Small)); + } + + WirelessNetwork _net; +}; + +WirelessWidgetImpl::WirelessWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) + : WidgetInterface(parent, name, fl) +{ + _wireless_setting = dynamic_cast(conn); + _info_setting = dynamic_cast(conn); + _security_setting = dynamic_cast(conn); + _hasName = !_info_setting->friendlyName.isEmpty(); + _new_conn = new_conn; + + TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); + _mainWid = new ConnectionSettingWirelessWidget(this); + layout->addWidget(_mainWid); + + // FIXME hide this button until it is implemented + _mainWid->pbExpert->hide(); + + Init(); +} + +void +WirelessWidgetImpl::Init() +{ + TQVBoxLayout* layout = new TQVBoxLayout(_mainWid->framePlaceholder, 1, 1); + _searchLine = new KListViewSearchLineWidget(_mainWid->lvEssids, _mainWid->framePlaceholder); + layout->addWidget(_searchLine); + + connect(_mainWid->txtEssid, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotEssidChanged(const TQString&))); + connect(_mainWid->lvEssids, TQT_SIGNAL(doubleClicked(TQListViewItem*, const TQPoint&, int)), this, TQT_SLOT(slotEssidDoubleClicked(TQListViewItem*, const TQPoint&, int)) ); + connect(_mainWid->lvEssids, TQT_SIGNAL(selectionChanged(TQListViewItem*)), this, TQT_SLOT(slotEssidChanged(TQListViewItem*))); + + if (!_new_conn) + { + _mainWid->chkAutoRefresh->hide(); + _mainWid->lvEssids->hide(); + _searchLine->hide(); + } +} + +void +WirelessWidgetImpl::Activate() +{ + // Fill in all available networks from all devices + // get all aps from all devices grouped together using the ssid + TQValueList nets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID); + + _mainWid->lvEssids->clear(); + + for (TQValueList::Iterator it = nets.begin(); it != nets.end(); ++it) + { + KListViewItem* item = new NetworkListViewItem(_mainWid->lvEssids, (*it)); + + _mainWid->lvEssids->insertItem(item); + } + + // FIXME, if essid contains unprintable characters show the essid in hex + _mainWid->txtEssid->setText(_wireless_setting->SSID); +} + +void WirelessWidgetImpl::slotEssidChanged(TQListViewItem* item) +{ + NetworkListViewItem* net_item = dynamic_cast(item); + if (net_item) + { + // update the settingsobject + updateEssid(net_item->_net.getSsid()); + + // update the textbox to match the selected essid + _mainWid->txtEssid->setText(net_item->_net.getDisplaySsid()); + } +} + +void +WirelessWidgetImpl::slotEssidDoubleClicked(TQListViewItem* item, const TQPoint& /*p*/, int /*i*/) +{ + NetworkListViewItem* net_item = dynamic_cast(item); + if (net_item) + { + updateEssid(net_item->_net.getSsid()); + // essid selected with double click -> goto the next setting + emit next(); + } +} + + +void +WirelessWidgetImpl::slotEssidChanged(const TQString& new_essid) +{ + /* set the newly entered essid */ + /* FIXME perhaps local8Bit is better? */ + /* FIXME allow entering essid in hex */ + /* FIXME select the appropriate essid in the list too */ + + TQByteArray essid(new_essid.utf8()); + + // remove trailing \0 + essid.resize(essid.size() - 1); + + updateEssid(essid); +} + +void +WirelessWidgetImpl::updateEssid(const TQByteArray& essid) +{ + _wireless_setting->SSID = essid; + + if (!_hasName) + { + // the connection has no name yet -> just take the essid for it + _info_setting->friendlyName = TQString(essid); + if (_info_setting->friendlyName == "") { + _info_setting->friendlyName = "<" + i18n("hidden") + ">"; + } + } +} + +TQByteArray WirelessWidgetImpl::byteArrayFromHexString(const TQCString& str) +{ + char c[2]; + TQByteArray arr(str.length() - 1); + TQTextStream stream(str, IO_ReadOnly); + + stream.setf(TQTextStream::hex); + stream.setf(TQTextStream::left); + stream.width(2); + stream.fill('0'); + + // 0x + stream.readRawBytes(c, 2); + + for (uint i = 0; i < (str.length()-1)/2; ++i) + { + stream.readRawBytes(c, 2); + TQString hex; + hex += "0x"; + hex += c[0]; + hex += c[1]; + arr[i] = (unsigned char)hex.toShort(); + } + return arr; +} + +TQString WirelessWidgetImpl::hexStringFromByteArray(const TQByteArray& bytes) +{ + TQString tmp; + TQTextStream stream(&tmp, IO_ReadWrite); + stream.setf(TQTextStream::hex); + stream.setf(TQTextStream::left); + stream.width(2); + stream.fill('0'); + + stream << "0x" ; + for (uint i = 0; i < bytes.size(); ++i) + { + stream << static_cast(bytes[i]); + } + return tmp; +} + +#include "tdenetman-connection_setting_wireless_widget.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.h new file mode 100644 index 0000000..da78621 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_wireless_widget.h @@ -0,0 +1,74 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Valentine Sinitsyn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H +#define KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H + +// tde headers +#include +#include + +#include "tdenetman-connection_setting_widget_interface.h" +#include "connection_setting_wireless.h" + +class KListViewSearchLineWidget; + +namespace ConnectionSettings +{ + class Wireless; + class WirelessSecurity; + class Info; + + + class WirelessWidgetImpl : public WidgetInterface + { + Q_OBJECT + + public: + WirelessWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent = 0, const char* name = 0, WFlags fl = 0); + + void Activate(); + + public slots: + void slotEssidChanged(const TQString& new_essid); + void slotEssidChanged(TQListViewItem*); + void slotEssidDoubleClicked(TQListViewItem*, const TQPoint&, int); + + private: + void Init(); + void updateEssid(const TQByteArray&); + TQByteArray byteArrayFromHexString(const TQCString&); + TQString hexStringFromByteArray(const TQByteArray& ); + + bool _hasName; + TDEWiFiConnection* _wireless_setting; + TDEWiFiConnection* _info_setting; + TDEWiFiConnection* _security_setting; + ConnectionSettingWirelessWidget* _mainWid; + KListViewSearchLineWidget* _searchLine; + bool _new_conn; + }; +} +#endif /* KNETWORKMANAGER_CONNECTION_SETTING_WIRELESS_WIDGET_H*/ diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp new file mode 100644 index 0000000..a783d23 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp @@ -0,0 +1,461 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include +#include +#include +#include + +// kde headers +#include +#include +#include + +// TQt DBus headers +#include +#include + +// knm headers +#include "tdenetman-connection_setting_widget_interface.h" +#include "tdenetman-connection_settings_dialog.h" +#include "tdenetman-connection_setting_cdma_widget.h" +#include "tdenetman-connection_setting_gsm_widget.h" +#include "tdenetman-connection_setting_ppp_widget.h" +#include "tdenetman-connection_setting_serial_widget.h" +#include "tdenetman-connection_setting_wireless_widget.h" +#include "tdenetman-connection_setting_wireless_security_widget.h" +#include "tdenetman-connection_setting_ipv4_widget.h" +#include "tdenetman-connection_setting_info_widget.h" +#include "tdenetman-wireless_network.h" +#include "tdenetman-wireless_manager.h" + +char use_new_wireless_essid = 0; +TQByteArray new_wireless_essid; + +using namespace ConnectionSettings; + +ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, bool modal, WFlags fl) + : ConnectionSettingsDialog(parent, name, modal, fl) + , _conn(conn) + , _new_conn(new_conn) +{ + updateDialogForDeviceType(); + + // get notified if device combo changes + connect(btnConnect, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotConnect()) ); + connect(pbNext, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotNext()) ); + connect(pbBack, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotBack()) ); + connect(pbCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotCancel()) ); + connect(pbSave, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSave()) ); + + // nice images for the buttons + btnConnect->setIconSet(SmallIcon ("connect_creating", TQIconSet::Automatic)); + pbNext->setIconSet(SmallIcon ("1rightarrow", TQIconSet::Automatic)); + pbBack->setIconSet(SmallIcon ("1leftarrow", TQIconSet::Automatic)); + pbCancel->setIconSet(SmallIcon("cancel", TQIconSet::Automatic)); + pbSave->setIconSet(SmallIcon("ok", TQIconSet::Automatic)); + + // enable or disable buttons accroding to the current state + slotEnableButtons(); +} + +ConnectionSettingsDialogImpl::~ConnectionSettingsDialogImpl() +{ + kdDebug() << "ConnectionSettingsDialogImpl::~ConnectionSettingsDialogImpl" << endl; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForWireless(TDENetworkConnection* conn, bool new_conn) +{ + TQValueList ret; + + // widgetlist for wireless connection + ret.append(new ConnectionSettings::WirelessWidgetImpl(conn, new_conn)); + ret.append(new ConnectionSettings::WirelessSecurityWidgetImpl(conn, new_conn)); + ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + if (ret.isEmpty()) + { + // we have a problem here, NetworkManager asked for a setting we do not have + kdError() << k_funcinfo << "Unexpected setting requested" << endl; + } + + return ret; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForWirelessKnownESSID(TDENetworkConnection* conn, bool new_conn, const TQByteArray& essid) +{ + TQValueList ret; + + // Set ESSID +// _wireless_setting = dynamic_cast (conn->getSetting(NM_SETTING_WIRELESS_SETTING_NAME)); +// _info_setting = dynamic_cast (conn->getSetting(NM_SETTING_CONNECTION_SETTING_NAME)); +// _wireless_setting->setEssid(essid); +// if (!_hasName) +// { +// // the connection has no name yet -> just take the essid for it +// _info_setting->setName(essid); +// } + + // widgetlist for wireless connection + ret.append(new ConnectionSettings::WirelessSecurityWidgetImpl(conn, new_conn)); + ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + if (ret.isEmpty()) + { + // we have a problem here, NetworkManager asked for a setting we do not have + kdError() << k_funcinfo << "Unexpected setting requested" << endl; + } + + return ret; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForWired(TDENetworkConnection* conn, bool new_conn) +{ + TQValueList ret; + + // widgetlist for wired connection + ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + return ret; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForVPN(TDENetworkConnection* conn, bool new_conn) +{ + TQValueList ret; + + // widgetlist for wired connection +// ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + return ret; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForCDMA(TDENetworkConnection* conn, bool new_conn) +{ + TQValueList ret; + + // widgetlist for wired connection + ret.append(new ConnectionSettings::CDMAWidgetImpl(conn)); + ret.append(new ConnectionSettings::SerialWidgetImpl(conn)); + ret.append(new ConnectionSettings::PPPWidgetImpl(conn)); + ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + return ret; +} + +TQValueList +ConnectionSettingsDialogImpl::createWidgetsForGSM(TDENetworkConnection* conn, bool new_conn) +{ + TQValueList ret; + + // widgetlist for wired connection + ret.append(new ConnectionSettings::GSMWidgetImpl(conn)); + ret.append(new ConnectionSettings::PPPWidgetImpl(conn)); + ret.append(new ConnectionSettings::SerialWidgetImpl(conn)); + ret.append(new ConnectionSettings::IPv4WidgetImpl(conn)); + ret.append(new ConnectionSettings::InfoWidgetImpl(conn)); + + return ret; +} + +void +ConnectionSettingsDialogImpl::createWidgetsForConnection(TDENetworkConnection* conn, bool new_conn) +{ + /* + Currently two modes: + * dev == NULL -> Connection should be edited without the wish to start a connection + * dev != NULL -> A connection should be edited for connection on this device + */ + + if (!conn) { + // TODO: create an empty widget and show an error + kdWarning() << k_funcinfo << "Not handled yet" << endl; + } + else { + TQValueList widgets; + // TODO: move to a factory class + if (conn->type() == TDENetworkConnectionType::WiFi) { + if (use_new_wireless_essid == 0) { + widgets = createWidgetsForWireless(conn, new_conn); + } + else { + createWidgetsForWirelessKnownESSID(conn, new_conn, new_wireless_essid); + new_wireless_essid = TQByteArray(); + } + } + else if (conn->type() == TDENetworkConnectionType::WiredEthernet) { + widgets = createWidgetsForWired(conn, new_conn); + } + else if (conn->type() == TDENetworkConnectionType::Modem) { + TDEModemConnection* modemconn = dynamic_cast(conn); + if (modemconn) { + if (modemconn->type == TDEModemConnectionType::CDMA) { + widgets = createWidgetsForCDMA(conn, new_conn); + } + else if (modemconn->type == TDEModemConnectionType::GSM) { + widgets = createWidgetsForGSM(conn, new_conn); + } + else { + kdWarning() << k_funcinfo << "Specific modem type not handled yet" << endl; + } + } + } +// else if (conn->getType() == NM_SETTING_VPN_SETTING_NAME) { +// widgets = createWidgetsForVPN(conn, new_conn); +// } + else { + kdWarning() << k_funcinfo << "Not handled yet" << endl; + } + + int id; + for (TQValueList::Iterator it = widgets.begin(); it != widgets.end(); ++it) { + id = wstackSettings->addWidget(*it); + _widgetIds.append(id); + } + + if (widgets.begin() != widgets.end()) { + activateWidget(*widgets.begin()); + } + } +} + +void +ConnectionSettingsDialogImpl::updateDialogForDeviceType() +{ + // clear our tabview first + TQWidget *page = NULL; + while ( (page = wstackSettings->visibleWidget()) != NULL) + { + wstackSettings->removeWidget(page); + delete page; + } + + if (_conn) { + createWidgetsForConnection(_conn, _new_conn); + } + else { + // this should never happen + TQLabel* lbl = new TQLabel(wstackSettings, "Unknown Device Type"); + wstackSettings->addWidget(lbl); + + wstackSettings->raiseWidget(lbl); + } +} + +int +ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(TDENetworkConnection* conn) +{ + if (conn->type() == TDENetworkConnectionType::WiFi) { + return TDENetworkDeviceType::WiFi; + } + else if (conn->type() == TDENetworkConnectionType::WiredEthernet) { + return TDENetworkDeviceType::WiredEthernet; + } + else if (conn->type() == TDENetworkConnectionType::Modem) { + return TDENetworkDeviceType::Modem; + } + + return TDENetworkDeviceType::Other; +} + +void +ConnectionSettingsDialogImpl::slotConnect() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + // add/save the connection + nm->saveConnection(_conn); + + // activate device + if (_conn && nm) { +// // VPN connection needs a special specific object +// if (_conn->getType() == NM_SETTING_VPN_SETTING_NAME) { +// TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); +// TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); +// nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), device, act_conn, err); +// } +// else { + // we need to call ActivateDevice async + nm->initiateConnection(_conn->UUID); +// } + } + + emit connectionSaved(); + this->close(true); +} + +void +ConnectionSettingsDialogImpl::slotSave() +{ + // Make sure settings are committed + TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); + if (current != _widgetIds.fromLast()) + { + WidgetInterface* widget = NULL; + + // let the widget know about it being the active one + widget = dynamic_cast(wstackSettings->widget(*current)); + if (widget) { + deactivateWidget(widget); + } + } + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + // save the connection + nm->saveConnection(_conn); + + emit connectionSaved(); + this->close(true); +} + +void +ConnectionSettingsDialogImpl::slotCancel() +{ + close(); +} + +void +ConnectionSettingsDialogImpl::slotNext() +{ + TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); + if (current != _widgetIds.fromLast()) + { + WidgetInterface* widget = NULL; + + // let the widget know about it being the active one + widget = dynamic_cast(wstackSettings->widget(*current)); + if (widget) + deactivateWidget(widget); + + // next widget + current++; + + // let the widget know about it being the active one + widget = dynamic_cast(wstackSettings->widget(*current)); + if (widget) + activateWidget(widget); + } + slotEnableButtons(); +} + +void +ConnectionSettingsDialogImpl::slotBack() +{ + TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); + if (current != _widgetIds.begin()) + { + WidgetInterface* widget = NULL; + + // let the widget know about it being the active one + widget = dynamic_cast(wstackSettings->widget(*current)); + if (widget) + deactivateWidget(widget); + + // one back + current--; + + // let the widget know about it being the active one + widget = dynamic_cast(wstackSettings->widget(*current)); + if (widget) + activateWidget(widget); + } + slotEnableButtons(); +} + +void +ConnectionSettingsDialogImpl::activateWidget(WidgetInterface* widget) +{ + // allow the widget to press next + connect(widget, TQT_SIGNAL(next()), this, TQT_SLOT(slotNext())); + + // allow the widget to do some initialization + widget->Activate(); + + // show the widget + wstackSettings->raiseWidget(widget); + +} + +void +ConnectionSettingsDialogImpl::deactivateWidget(WidgetInterface* widget) +{ + // allow the widget to press next + disconnect(widget, TQT_SIGNAL(next()), this, TQT_SLOT(slotNext())); + + // allow the widget to do some initialization + widget->Deactivate(); +} + +void +ConnectionSettingsDialogImpl::slotEnableButtons() +{ + // enable the buttons according to the current state + + TQValueList::Iterator current = _widgetIds.find(wstackSettings->id(wstackSettings->visibleWidget())); + bool enabled; + + /* + Next: enabled if another widget is available + */ + enabled = true; + if (current == _widgetIds.fromLast()) { + enabled = false; + } + pbNext->setEnabled(enabled); + + /* + Back: enabled if the current widget has a predecessor + */ + enabled = true; + if (current == _widgetIds.begin()) { + enabled = false; + } + pbBack->setEnabled(enabled); + + /* + Connect: only show connect if the connection is valid + */ + if (_conn) { + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + btnConnect->setEnabled(nm->verifyConnectionSettings(_conn)); + pbSave->setEnabled(nm->verifyConnectionSettings(_conn)); + } +} + +#include "tdenetman-connection_settings_dialog.moc" diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h new file mode 100644 index 0000000..8337338 --- /dev/null +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H +#define KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H + +// tqt headers +#include +#include + +// tde headers +#include +#include + +// ui autogenerated headers +#include "connection_settings.h" + +class TQWidget; +class Device; + +namespace ConnectionSettings +{ + class WidgetInterface; + class ConnectionSetting; +} + +class ConnectionSettingsDialogImpl : public ConnectionSettingsDialog +{ + Q_OBJECT + + public: + ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); + ~ConnectionSettingsDialogImpl(); + + public slots: + void slotConnect(); + void slotCancel(); + void slotSave(); + void slotNext(); + void slotBack(); + void slotEnableButtons(); + + signals: + void connectionSaved(); + + private: + void updateDialogForDeviceType(); + void createWidgetsForConnection(TDENetworkConnection*, bool new_conn); + void activateWidget(ConnectionSettings::WidgetInterface* widget); + void deactivateWidget(ConnectionSettings::WidgetInterface* widget); + int getDeviceTypeFromConnection(TDENetworkConnection* conn); + + // TODO: To be moved to a factory class + TQValueList createWidgetsForWired(TDENetworkConnection* conn, bool new_conn); + TQValueList createWidgetsForWireless(TDENetworkConnection* conn, bool new_conn); + TQValueList createWidgetsForWirelessKnownESSID(TDENetworkConnection* conn, bool new_conn, const TQByteArray& essid); + TQValueList createWidgetsForVPN(TDENetworkConnection* conn, bool new_conn); + TQValueList createWidgetsForCDMA(TDENetworkConnection* conn, bool new_conn); + TQValueList createWidgetsForGSM(TDENetworkConnection* conn, bool new_conn); + + TDENetworkConnection* _conn; + TQValueList _widgetIds; + bool _new_conn; +}; + +#endif /* KNETWORKMANAGER_CONNECTION_SETTINGS_DIALOG_H*/ diff --git a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp deleted file mode 100644 index d3d23d5..0000000 --- a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-cellular_device_tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -/// TQt includes -#include // for TQt::WidgetFlags - -// KDE includes -#include -#include -#include - -// KNM includes -#include "knetworkmanager-cellular_device_tray.h" -#include "knetworkmanager-menuitem.h" -#include "knetworkmanager-menu_subhead.h" - -#include "knetworkmanager-connection_settings_dialog.h" - -using namespace ConnectionSettings; - -class CellularDeviceTrayPrivate -{ - public: - CellularDeviceTrayPrivate() {} - ~CellularDeviceTrayPrivate() {} - - TDENetworkDevice* dev; -}; - -void CellularDeviceTray::newConnection() -{ - // create an appropriate connection - TDENetworkConnection* conn = 0; - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - switch (deviceConnMan->deviceType()) { - case TDENetworkDeviceType::Modem: - conn = new TDEModemConnection(); - break; - - default: - break; - } - - // edit the new connection - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); - dlg->show(); -} - - -void CellularDeviceTray::addMenuItems(KPopupMenu* menu) -{ - // device title - Subhead* subhead = new Subhead (menu, "subhead", d->dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic)); - menu->insertItem (subhead, -1, -1); - - //menu->insertSeparator(); - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkConnection* active_conn = NULL; - if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) - && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { - active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); - } - - // get all available Connections for cellular devices - - TDENetworkConnectionList* allconmap = nm->connections(); - for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { - TDEModemConnection* conn = dynamic_cast(*it); - if (!conn) { - continue; - } - - // lets create a nice name for this connection - TQString title = conn->friendlyName; - if (conn->ipConfig.valid) { - title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); - } - - NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); - - int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); - menu->setItemChecked(id, ((*it) == active_conn)); - } - - // bring the device down - KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); - if (deactivate) - deactivate->plug(menu); - - menu->insertSeparator(); -} - -CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) - : DeviceTrayComponent (dev, parent, name) -{ - d = new CellularDeviceTrayPrivate(); - d->dev = dev; - - setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wwan"); -} - -CellularDeviceTray::~CellularDeviceTray () -{ - delete d; -} - - -#include "knetworkmanager-cellular_device_tray.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.h b/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.h deleted file mode 100644 index 323a559..0000000 --- a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H -#define KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H - -// KNM includes -#include "knetworkmanager.h" -#include "devicetraycomponent.h" - -// predefs -class CellularDevice; -class CellularDeviceTrayPrivate; - -class CellularDeviceTray : public DeviceTrayComponent -{ - Q_OBJECT - - public: - CellularDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); - ~CellularDeviceTray (); - - void addMenuItems(KPopupMenu* menu); - - public slots: - void newConnection(); - - private: - CellularDeviceTrayPrivate* d; -}; - -#endif /* KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp b/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp deleted file mode 100644 index 6d2368f..0000000 --- a/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_editor.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// qt headers -#include -#include -#include -#include -#include -#include -#include -#include - -// kde headers -#include -#include -#include -#include -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-connection_editor.h" -#include "knetworkmanager-connection_settings_dialog.h" - -using namespace ConnectionSettings; - -/* - * ConnectionListViewItem - */ -class ConnectionListViewItem : public KListViewItem -{ - public: - - ConnectionListViewItem(TQListView* parent, TDENetworkConnection* connection) - : KListViewItem(parent) - , _conn(connection) - { - if (_conn) { - setText(0, _conn->friendlyName); - setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(_conn->type())); - // TODO: Move to a Factory - if (_conn->type() == TDENetworkConnectionType::WiredEthernet) { - setPixmap(0, KGlobal::iconLoader()->loadIcon("wired", KIcon::Small)); - } - else if (_conn->type() == TDENetworkConnectionType::WiFi) { - setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small)); - } -// else if (_conn->type() == TDENetworkConnectionType::VPN) { -// setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small)); -// } - else { - setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small)); - } - } - } - - TDENetworkConnection* _conn; -}; - -/* - * Constructor - */ -ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, bool modal, WFlags fl) - : ConnectionEditor(parent, name, modal, fl) -{ - - // TODO: enable combobox if implemented - cboConnectionType->hide(); - - // TODO: Editmode is not ready yet, hide the button -// pbEdit->hide(); - - - pbNew->setIconSet(KGlobal::iconLoader()->loadIcon("add", KIcon::Small)); - pbDelete->setIconSet(KGlobal::iconLoader()->loadIcon("remove", KIcon::Small)); - pbEdit->setIconSet(KGlobal::iconLoader()->loadIcon("edit", KIcon::Small)); - - TQPopupMenu* popup = new TQPopupMenu(pbNew); - // TODO: move to a factory class - popup->insertItem(KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small), i18n("Wireless"), this, TQT_SLOT(slotNewWirelessConnection())); - popup->insertItem(KGlobal::iconLoader()->loadIcon("wired", KIcon::Small), i18n("Wired"), this, TQT_SLOT(slotNewWiredConnection())); - -// if (!VPNManager::getVPNServices().isEmpty()) { -// popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); -// } - - pbNew->setPopup(popup); - - connect(pbClose, TQT_SIGNAL(clicked()), this, TQT_SLOT(close())); - connect(pbDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotRemoveCurrentConnection())); - connect(pbEdit, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotEditCurrentConnection())); - - // show all connections - fillConnectionList(); -} - -/* - * Destructor - */ -ConnectionEditorImpl::~ConnectionEditorImpl() -{ - // remove the popupmenu - if (pbNew->popup()) { - delete pbNew->popup(); - } -} - -/* - * New Wireless connection - */ -void ConnectionEditorImpl::slotNewWirelessConnection() -{ - // create a new wireless connection - slotEditNewConnection(new TDEWiFiConnection()); -} - -/* - * New Wired connection - */ -void ConnectionEditorImpl::slotNewWiredConnection() -{ - slotEditNewConnection(new TDEWiredEthernetConnection()); -} - -/* - * New VPN connection - */ -void ConnectionEditorImpl::slotNewVPNConnection() -{ -// slotEditNewConnection(new TDEVPNConnection()); -} - -/* - * - */ -void ConnectionEditorImpl::slotEditNewConnection(TDENetworkConnection* conn) -{ - // open a dialog for editing the connection - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, this, "connect_something", false, TQt::WDestructiveClose); - connect(dlg, TQT_SIGNAL(connectionSaved()), this, TQT_SLOT(slotRefreshConnectionList())); - dlg->show(); -} - -void ConnectionEditorImpl::slotRefreshConnectionList() -{ - fillConnectionList(); -} - -/* - * Edit the selected connection - */ -void ConnectionEditorImpl::slotEditCurrentConnection() -{ - ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); - if (!item) { - return; - } - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) { - return; - } - - TDENetworkConnection* conn = item->_conn; - - // we need the secrets for editing - nm->loadConnectionSecrets(conn->UUID); - - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, this, "connect_something", false, TQt::WDestructiveClose); - dlg->show(); - - // save all connections (if not done already) - nm->saveConnection(conn); -} - - -/* - * Delete the selected connection - */ -void ConnectionEditorImpl::slotRemoveCurrentConnection() -{ - ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); - if (!item) { - return; - } - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) { - return; - } - - TDENetworkConnection* conn = item->_conn; - - lvConnections->takeItem(item); - delete item; - - nm->deleteConnection(conn->UUID); -} - -/* - * Fill the connection list - */ -void ConnectionEditorImpl::fillConnectionList() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) { - return; - } - - lvConnections->clear(); - - TDENetworkConnectionList* allconmap = nm->connections(); - for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { - TDENetworkConnection* conn = *it; - new ConnectionListViewItem(lvConnections, conn); - } -} - -#include "knetworkmanager-connection_editor.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-connection_editor.h b/tdenetworkmanager/src/knetworkmanager-connection_editor.h deleted file mode 100644 index 83ec029..0000000 --- a/tdenetworkmanager/src/knetworkmanager-connection_editor.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-connection_editor.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_CONNECTION_EDITOR_H -#define KNETWORKMANAGER_CONNECTION_EDITOR_H - -// tqt headers -#include - -// tqt autogenerated headers -#include "connection_editor.h" - -// TDE headers -#include -#include - -// knm headers -#include "knetworkmanager-connection_setting.h" - -class TQWidget; -class Device; - -namespace ConnectionSettings -{ - class WidgetInterface; - class ConnectionSetting; -} - -class ConnectionEditorImpl : public ConnectionEditor -{ - Q_OBJECT - - public: - ConnectionEditorImpl(TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); - ~ConnectionEditorImpl(); - - protected slots: - void slotRemoveCurrentConnection(); - void slotEditCurrentConnection(); - void slotNewWirelessConnection(); - void slotNewWiredConnection(); - void slotEditNewConnection(TDENetworkConnection* conn); - void slotRefreshConnectionList(); - void slotNewVPNConnection(); - - private: - void fillConnectionList(); -}; - -#endif /* KNETWORKMANAGER_CONNECTION_EDITOR_H*/ diff --git a/tdenetworkmanager/src/knetworkmanager-device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-device_tray.cpp deleted file mode 100644 index 493582a..0000000 --- a/tdenetworkmanager/src/knetworkmanager-device_tray.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-device_tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -class WirelessDialog; - -// TQt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// TDE includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// KNM includes -#include "knetworkmanager-device_tray.h" -#include "knetworkmanager-menu_subhead.h" -#include "knetworkmanager-connection_settings_dialog.h" -#include "knetworkmanager-connection_setting_info.h" - -using namespace ConnectionSettings; - -class DeviceTrayPrivate -{ - public: - - DeviceTrayPrivate() - : dev(NULL) - { - tooltips[TDENetworkConnectionStatus::Invalid] = i18n("Unknown"); - tooltips[TDENetworkConnectionStatus::LinkUnavailable] = i18n("Down"); - tooltips[TDENetworkConnectionStatus::UnManaged] = i18n("Unmanaged"); - tooltips[TDENetworkConnectionStatus::Disconnected] = i18n("Disconnected"); - tooltips[TDENetworkConnectionStatus::EstablishingLink] = i18n("Preparing"); - tooltips[TDENetworkConnectionStatus::ConfiguringProtocols] = i18n("Configuration"); - tooltips[TDENetworkConnectionStatus::NeedAuthorization] = i18n("Awaiting authentication"); - tooltips[TDENetworkConnectionStatus::VerifyingProtocols] = i18n("IP configuration"); - tooltips[TDENetworkConnectionStatus::Connected] = i18n("Activated"); - tooltips[TDENetworkConnectionStatus::Failed] = i18n("Failed"); - } - - ~DeviceTrayPrivate() {} - - TDENetworkDevice* dev; - TQMap movies; - TQMap pixmaps; - TQMap tooltips; - - TQPixmap pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); - TQMovie movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); - TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); -}; - -TQPixmap DeviceTrayPrivate::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; - while (flag > 0) { - if (state & flag) { - if (pixmaps.contains(flag)) { - return pixmaps[flag]; - } - } - flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); - } - return TQPixmap(); -} - -TQMovie DeviceTrayPrivate::movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; - while (flag > 0) { - if (state & flag) { - if (movies.contains(flag)) { - return movies[flag]; - } - } - flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); - } - return TQMovie(); -} - -TQString DeviceTrayPrivate::tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; - while (flag > 0) { - if (state & flag) { - if (tooltips.contains(flag)) { - return tooltips[flag]; - } - } - flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); - } - return TQString::null; -} - -TDENetworkDevice* DeviceTray::getDevice() const -{ - return d->dev; -} - -TQString DeviceTray::getTooltipText() -{ - - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; - TQString tooltip = TQString(); - - if (!d->tooltipForConnState(state).isEmpty()) { - tooltip += i18n("State: %1").arg(d->tooltipForConnState(state)); - } - - return tooltip; -} - -void DeviceTray::enterEvent (TQEvent* /*e*/) -{ - // show tooltip - TQToolTip::remove (this); - TQString tooltip = getTooltipText(); - - if (!tooltip.isEmpty()) { - TQToolTip::add (this, tooltip); - } -} - - -void DeviceTray::setPixmap(const TQPixmap& pixmap) -{ - /* - int oldPixmapWidth = pixmap.size().width(); - int oldPixmapHeight = pixmap.size().height(); - - // we want to show the interface name - TQString iface = d->dev->getInterface(); - - // grab a font - TQFont iface_font = KGlobalSettings::generalFont(); -// iface_font.setBold(true); - - // resize the font to fit the icon's size - float fontSize = iface_font.pointSizeFloat(); - TQFontMetrics qfm(iface_font); - int height = qfm.height(); - int width = qfm.width(iface); - float factor = 1.0f; - float factor2 = 1.0f; - - if (height > (oldPixmapHeight / 2.0f)) - factor = float(oldPixmapHeight / 2.0f) / float(height); - - if (width > (oldPixmapWidth / 1.1f)) - factor2 = float(oldPixmapWidth / 1.1f) / float(width); - - fontSize *= (factor2 < factor) ? factor2 : factor; - - iface_font.setPointSizeFloat( fontSize); - - // draw the text to a bitmap and put is as an overlay on top of the pixmap - TQPixmap iface_pixmap(oldPixmapWidth, oldPixmapHeight); - iface_pixmap.fill(TQt::white); - TQPainter p(&iface_pixmap); - p.setFont(iface_font); - p.setPen(TQt::blue); - p.drawText(iface_pixmap.rect(), TQt::AlignHCenter | TQt::AlignBottom, iface); - iface_pixmap.setMask(iface_pixmap.createHeuristicMask()); - TQImage iface_image = iface_pixmap.convertToImage(); - - TQImage pixmap_with_overlay = pixmap.convertToImage(); - KIconEffect::overlay(pixmap_with_overlay, iface_image); - - TQPixmap new_pixmap; - new_pixmap.convertFromImage(pixmap_with_overlay); - // call base-class setPixmap - KSystemTray::setPixmap(new_pixmap); -*/ - KSystemTray::setPixmap(pixmap); -} - -void DeviceTray::contextMenuAboutToShow (KPopupMenu* menu) -{ - menu->clear(); - - // insert title - menu->insertTitle (SmallIcon ("knetworkmanager", TQIconSet::Automatic), "KNetworkManager", -1, -1); - - // let the specific device_tray add its items - addMenuItems(menu); - - // quit - menu->insertSeparator (); - KAction* quitAction = actionCollection ()->action (KStdAction::name (KStdAction::Quit)); - if (quitAction) { - quitAction->plug (menu); - } -} - -void DeviceTray::resizeEvent ( TQResizeEvent * ) -{ - // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes - loadIcons(); - updateTrayIcon(m_currentIconState); -} - -void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQMovie movie) -{ - d->movies[state] = movie; - slotUpdateDeviceState(); -} - -void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQPixmap pixmap) -{ - d->pixmaps[state] = pixmap; - slotUpdateDeviceState(); -} - -void DeviceTray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - // stop the old movie to avoid unnecessary wakups - if (movie()) { - movie()->pause(); - } - - if (!d->movieForConnState(state).isNull()) { - if (m_currentIconState != state) { - // Clear the icon pixmap as the movie may be a different size - TQPixmap nullPixmap; - setPixmap(nullPixmap); - } - - // animation desired - int frame = -1; - if (movie()) { - frame = movie()->frameNumber(); - } - - // set the movie - setMovie(d->movieForConnState(state)); - - // start at the same frame as the movie before - if (frame > 0) - movie()->step(frame); - - // start the animation - movie()->unpause(); - } - else if (!d->pixmapForConnState(state).isNull()) { - setPixmap(d->pixmapForConnState(state)); - } - else { - setPixmap(loadSizedIcon("KNetworkManager", width())); - } - - m_currentIconState = state; -} - -void DeviceTray::updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - // allow device deactivation only when device is activated - KAction* deactivate = actionCollection()->action("deactivate_device"); - if (deactivate) - deactivate->setEnabled( (state & TDENetworkConnectionStatus::Connected || - state & TDENetworkConnectionStatus::VerifyingProtocols || - state & TDENetworkConnectionStatus::EstablishingLink || - state & TDENetworkConnectionStatus::ConfiguringProtocols || - state & TDENetworkConnectionStatus::NeedAuthorization) ); -} - -void DeviceTray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - if (!(state & TDENetworkConnectionStatus::Connected)) { - return; - } -} - -void DeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - updateTrayIcon(state); - updateActions(state); - updateActiveConnection(state); -} - -void DeviceTray::slotUpdateDeviceState() -{ - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags); -} - -void DeviceTray::loadIcons() { - d->pixmaps[TDENetworkConnectionStatus::Invalid] = loadSizedIcon("nm_no_connection", width()); - d->pixmaps[TDENetworkConnectionStatus::UnManaged] = loadSizedIcon("nm_no_connection", width()); - d->pixmaps[TDENetworkConnectionStatus::LinkUnavailable] = loadSizedIcon("nm_no_connection", width()); - d->pixmaps[TDENetworkConnectionStatus::Disconnected] = loadSizedIcon("nm_no_connection", width()); - - d->movies[TDENetworkConnectionStatus::EstablishingLink] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage01_connecting", KIcon::Panel)); - d->movies[TDENetworkConnectionStatus::EstablishingLink].pause(); - - d->movies[TDENetworkConnectionStatus::ConfiguringProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage02_connecting", KIcon::Panel)); - d->movies[TDENetworkConnectionStatus::ConfiguringProtocols].pause(); - - d->movies[TDENetworkConnectionStatus::VerifyingProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage03_connecting", KIcon::Panel)); - d->movies[TDENetworkConnectionStatus::VerifyingProtocols].pause(); - - d->movies[TDENetworkConnectionStatus::NeedAuthorization] = d->movies[TDENetworkConnectionStatus::ConfiguringProtocols]; - d->movies[TDENetworkConnectionStatus::NeedAuthorization].pause(); - - d->pixmaps[TDENetworkConnectionStatus::Connected] = loadSizedIcon("ok", width()); - - d->pixmaps[TDENetworkConnectionStatus::Failed] = loadSizedIcon("nm_no_connection", width()); -} - -DeviceTray::DeviceTray (TDENetworkDevice* dev) : KSystemTray () -{ - d = new DeviceTrayPrivate(); - d->dev = dev; - - m_currentIconState = TDENetworkConnectionStatus::Invalid; - loadIcons(); - - // get notified when the device state changes - connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); - - setMouseTracking (true); - - // defer the initial call to slotUpdateDeviceState as it will crash knm when called directly from here - // virtual method calls are not allowed in constructor - TQTimer::singleShot(0, this, TQT_SLOT(slotUpdateDeviceState())); - - // Actions used for plugging into the menu - new KAction (i18n ("Deactivate connection..."), - SmallIcon ("no", TQIconSet::Automatic), 0, - dev, TQT_SLOT (slotDeactivate()), actionCollection (), "deactivate_device"); -} - -DeviceTray::~DeviceTray () -{ - delete d; -} - - -#include "knetworkmanager-device_tray.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-device_tray.h b/tdenetworkmanager/src/knetworkmanager-device_tray.h deleted file mode 100644 index 2ee1c87..0000000 --- a/tdenetworkmanager/src/knetworkmanager-device_tray.h +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-device_tray.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_DEVICE_TRAY_H -#define KNETWORKMANAGER_DEVICE_TRAY_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "knetworkmanager.h" - -class DeviceTrayPrivate; - -class DeviceTray : public KSystemTray -{ - Q_OBJECT - - - public: - DeviceTray (TDENetworkDevice*); - ~DeviceTray (); - - void contextMenuAboutToShow (KPopupMenu* menu); - virtual void addMenuItems(KPopupMenu* menu) = 0; - TDENetworkDevice* getDevice() const; - - protected: - void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQMovie); - void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQPixmap); - void resizeEvent ( TQResizeEvent * ); - - virtual TQString getTooltipText(); - - public slots: - void setPixmap(const TQPixmap &); - void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void slotUpdateDeviceState(); - - private: - void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void enterEvent (TQEvent*); - void loadIcons(); - - DeviceTrayPrivate* d; - TDENetworkConnectionStatus::TDENetworkConnectionStatus m_currentIconState; -}; - -#endif /* KNETWORKMANAGER_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-menu_subhead.cpp b/tdenetworkmanager/src/knetworkmanager-menu_subhead.cpp deleted file mode 100644 index 5a69cd5..0000000 --- a/tdenetworkmanager/src/knetworkmanager-menu_subhead.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Valentine Sinitsyn - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -class WirelessDialog; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "knetworkmanager-menu_subhead.h" - -Subhead::Subhead (TQWidget* parent, const char* name, const TQString & caption, const TQPixmap icon) - : TQWidget (parent, name) -{ - TQBoxLayout* l = new TQHBoxLayout (this); - TQLabel* lbl_icon = new TQLabel (NULL, this); - TQLabel* lbl_caption = new TQLabel (caption, this); - TQSpacerItem* sp_item = new TQSpacerItem (20, 10); - TQFont font; - font.setBold(true); - lbl_caption->setFont(font); - - lbl_icon->setPixmap (icon); - - l->addWidget (lbl_icon); - l->addWidget (lbl_caption); - l->addItem (sp_item); - l->activate (); -} - -Subhead::~Subhead() -{ - -} - diff --git a/tdenetworkmanager/src/knetworkmanager-menu_subhead.h b/tdenetworkmanager/src/knetworkmanager-menu_subhead.h deleted file mode 100644 index 8891fc4..0000000 --- a/tdenetworkmanager/src/knetworkmanager-menu_subhead.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_MENU_SUBHEAD_H -#define KNETWORKMANAGER_MENU_SUBHEAD_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "knetworkmanager.h" - -class Subhead : public TQWidget -{ - public: - Subhead (TQWidget*, const char *, const TQString &, const TQPixmap); - ~Subhead (); -}; - -#endif /* KNETWORKMANAGER_MENU_SUBHEAD_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-menuitem.cpp b/tdenetworkmanager/src/knetworkmanager-menuitem.cpp deleted file mode 100644 index 927f1ae..0000000 --- a/tdenetworkmanager/src/knetworkmanager-menuitem.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-menuitem.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006, 2008 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Valentine Sinitsyn - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include "knetworkmanager-menuitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ConnectionSettings; - -class NetworkMenuItemPrivate -{ - public: - NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection) - : dev(device), conn(connection) - { - - } - ~NetworkMenuItemPrivate() {} - - TQGuardedPtr dev; - TQGuardedPtr conn; -}; - -void NetworkMenuItem::slotActivate() -{ - kdDebug() << "NetworkMenuItem::slotActivate()" << endl; - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - if (d->dev && d->conn) - { - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - if (deviceConnMan) - { - kdDebug() << "Activate Connection " << d->conn->UUID.ascii() << " on Device " << d->dev->deviceNode().ascii() << endl; - printf("Activate Connection %s on Device %s\n\r", d->conn->UUID.ascii(), d->dev->deviceNode().ascii()); - - TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(d->conn->UUID); - if ((result == TDENetworkConnectionStatus::Disconnected) - || (result == TDENetworkConnectionStatus::Invalid)) { - // - } - else { - kdDebug() << "ActivateDevice failed" << endl; - } - } - } - else if (d->conn) - { - // no device given, just take the default device - printf("Activate Connection %s on default device\n\r", d->conn->UUID.ascii()); - - TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(d->conn->UUID); - if ((result == TDENetworkConnectionStatus::Disconnected) - || (result == TDENetworkConnectionStatus::Invalid)) { - // - } - else { - kdDebug() << "ActivateConnection failed" << endl; - } - } - else - kdDebug() << "Device or Connection invalid" << endl; -} - -NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name) - : TQObject(parent, name) -{ - d = new NetworkMenuItemPrivate(dev, conn); -} - -NetworkMenuItem::~NetworkMenuItem () -{ - delete d; -} - - - -#include "knetworkmanager-menuitem.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-menuitem.h b/tdenetworkmanager/src/knetworkmanager-menuitem.h deleted file mode 100644 index 86552dc..0000000 --- a/tdenetworkmanager/src/knetworkmanager-menuitem.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-menuitem.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006, 2008 Novell, Inc. - * - * Author: Helmut Schaa , - * Will Stephenson , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_MENUITEM_H -#define KNETWORKMANAGER_MENUITEM_H - -#include - -#include -#include - -class Device; -class NetworkMenuItemPrivate; - -namespace ConnectionSettings -{ - class Connection; -} - -class NetworkMenuItem : public TQObject -{ - Q_OBJECT - - public: - NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent = 0, const char* name = 0); - ~NetworkMenuItem (); - - public slots: - void slotActivate(); - - private: - NetworkMenuItemPrivate* d; -}; - -#endif /* KNETWORKMANAGER_MENUITEM_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.cpp b/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.cpp deleted file mode 100644 index 737f4ef..0000000 --- a/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-device.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// KDE includes -#include - -// TQtDBus includes -#include -#include -#include -#include -#include -#include - -// NM includes -#include -#include - -// KNM includes -#include "knetworkmanager.h" -#include "knetworkmanager-nm_vpn_proxy.h" -#include "knetworkmanager-device.h" -#include "knetworkmanager-devicestore.h" -//#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_store.h" -#include "dbus/vpnconnectionproxy.h" - -class NMVPNProxyPrivate -{ - public: - NMVPNProxyPrivate() - {} - - static NMVPNProxy* nm; -}; - -NMVPNProxy* NMVPNProxyPrivate::nm = NULL; - -NMVPNProxy::NMVPNProxy() - : NetworkManagerVPNProxy(NM_DBUS_SERVICE, NM_DBUS_PATH_VPN_CONNECTION) -{ - d = new NMVPNProxyPrivate(); - NetworkManagerVPNProxy::setConnection(TQDBusConnection::systemBus()); -} - -NMVPNProxy::~NMVPNProxy() -{ - delete d; -} - -NMVPNProxy* NMVPNProxy::getInstance() -{ - if (NMVPNProxyPrivate::nm) - return NMVPNProxyPrivate::nm; - return (NMVPNProxyPrivate::nm = new NMVPNProxy()); -} - - -#include "knetworkmanager-nm_vpn_proxy.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.h b/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.h deleted file mode 100644 index af5f8ec..0000000 --- a/tdenetworkmanager/src/knetworkmanager-nm_vpn_proxy.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-nm_proxy.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_NMVPNPROXY_H -#define KNETWORKMANAGER_NMVPNPROXY_H - -#include "dbus/networkmanagervpnproxy.h" - -namespace ConnectionSettings -{ - class Connection; -} -class Device; -class NMVPNProxyPrivate; - -class NMVPNProxy : public DBus::NetworkManagerVPNProxy -{ - Q_OBJECT - - public: - static NMVPNProxy* getInstance(); - - protected: - NMVPNProxy (); - ~NMVPNProxy (); - - private: - NMVPNProxyPrivate * d; -}; - -#endif /* KNETWORKMANAGER_NMVPNPROXY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-plugin.cpp b/tdenetworkmanager/src/knetworkmanager-plugin.cpp deleted file mode 100644 index cb1d2b7..0000000 --- a/tdenetworkmanager/src/knetworkmanager-plugin.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-plugin.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include "knetworkmanager-plugin.h" - -Plugin::Plugin(TQObject* parent, const char* name, const TQStringList& ) - : TQObject(parent, name) -{ - -} - -Plugin::~Plugin() -{ - -} - -#include "knetworkmanager-plugin.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-plugin.h b/tdenetworkmanager/src/knetworkmanager-plugin.h deleted file mode 100644 index 3a500ac..0000000 --- a/tdenetworkmanager/src/knetworkmanager-plugin.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-plugin.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_PLUGIN_H -#define KNETWORKMANAGER_PLUGIN_H - -#include - -class Plugin : public TQObject -{ - Q_OBJECT - - public: - Plugin(TQObject*, const char*, const TQStringList&); - ~Plugin(); -}; - -#endif /* KNETWORKMANAGER_PLUGIN_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-pluginmanager.cpp b/tdenetworkmanager/src/knetworkmanager-pluginmanager.cpp deleted file mode 100644 index 7654ccd..0000000 --- a/tdenetworkmanager/src/knetworkmanager-pluginmanager.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-pluginmanager.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include - -#include "knetworkmanager-pluginmanager.h" - -PluginManager* PluginManager::_instance; - -PluginManager* PluginManager::getInstance() -{ - if (_instance) - return _instance; - return new PluginManager(TQT_TQOBJECT(KNetworkManager::getInstance()), "pluginmanager"); -} - -PluginManager::PluginManager(TQObject* parent, const char* name) - : TQObject(parent, name) -{ - // get list of available plugins - this->_plugins = KPluginInfo::fromServices( KTrader::self()->query( TQString::fromLatin1( "KNetworkManager/Plugin" ))); - - // a bit debug output - for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - kdDebug() << k_funcinfo << TQString("Found Plugin '%1'").arg((*it)->pluginName()) << endl; -} - -PluginManager::~PluginManager() -{ - // delete all loaded plugins - while(!_loadedPlugins.empty()) - { - PluginMap::Iterator it = _loadedPlugins.begin(); - _loadedPlugins.remove(it); - } - - // delete all available plugininfos - while(!_plugins.empty()) - { - TQValueList::Iterator it = _plugins.begin(); - delete *it; - _plugins.remove(it); - } -} - -TQStringList PluginManager::getPluginList(const TQString& serviceType, const TQString& property, const TQString& value) const -{ - TQStringList ret; - // find a suitable plugin - for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - { - if ((*it)->service()->serviceTypes().contains(serviceType) > 0) - if ((*it)->property(property).toString().contains(value)) - ret.append( (*it)->pluginName() ); - } - return ret; -} - -Plugin* PluginManager::getPlugin(const TQString& pluginID) -{ - KPluginInfo* info = infoForPluginID(pluginID); - if (_loadedPlugins.contains(info)) - { - return _loadedPlugins[info]; - } - else - { - return loadPlugin(pluginID); - } - return NULL; -} - -const KPluginInfo* PluginManager::getPluginInfo(const TQString& pluginID) -{ - return infoForPluginID(pluginID); -} - -const KPluginInfo* PluginManager::getPluginInfo(const Plugin* plugin) -{ - for(PluginMap::ConstIterator it = _loadedPlugins.begin(); it != _loadedPlugins.end(); ++it) - { - if (it.data() == plugin) - return it.key(); - } - return NULL; -} - -void PluginManager::loadAllPlugins() -{ - // iterate over all plugins - for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - { - // load Plugin - loadPlugin((*it)->pluginName()); - } -} - - -Plugin* PluginManager::loadPlugin(const TQString& pluginID) -{ - // try to load Plugin - int error = 0; - KPluginInfo* info = infoForPluginID(pluginID); - Plugin *plugin = KParts::ComponentFactory::createInstanceFromQuery( TQString::fromLatin1( "KNetworkManager/Plugin" ), - TQString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginID ), this, 0, TQStringList(), &error ); - - // plugin loaded? - if (plugin) - { - kdDebug() << k_funcinfo << TQString(i18n("successfully loaded plugin '%1'")).arg(info->pluginName()) << endl; - _loadedPlugins.insert(info, plugin); - } - else - { - // error - switch( error ) - { - case KParts::ComponentFactory::ErrNoServiceFound: - kdDebug( ) << k_funcinfo << "No service implementing the given mimetype " - << "and fullfilling the given constraint expression can be found." << endl; - break; - - case KParts::ComponentFactory::ErrServiceProvidesNoLibrary: - kdDebug( ) << "the specified service provides no shared library." << endl; - break; - - case KParts::ComponentFactory::ErrNoLibrary: - kdDebug( ) << "the specified library could not be loaded." << endl; - break; - - case KParts::ComponentFactory::ErrNoFactory: - kdDebug( ) << "the library does not export a factory for creating components." << endl; - break; - - case KParts::ComponentFactory::ErrNoComponent: - kdDebug( ) << "the factory does not support creating components of the specified type." << endl; - break; - } - - kdDebug() << k_funcinfo << "Loading plugin '" << pluginID << "' failed, KLibLoader reported error: '" << endl - << KLibLoader::self()->lastErrorMessage() << "'" << endl; - - } - - return plugin; -} - -KPluginInfo * PluginManager::infoForPluginID( const TQString& pluginID ) const -{ - TQValueList::ConstIterator it; - for ( it = this->_plugins.begin(); it != this->_plugins.end(); ++it ) - { - if ( ( *it )->pluginName() == pluginID ) - return *it; - } - - return 0L; -} - -#include "knetworkmanager-pluginmanager.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-pluginmanager.h b/tdenetworkmanager/src/knetworkmanager-pluginmanager.h deleted file mode 100644 index efe6c63..0000000 --- a/tdenetworkmanager/src/knetworkmanager-pluginmanager.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-pluginmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_PLUGINMANAGER_H -#define KNETWORKMANAGER_PLUGINMANAGER_H - -#include -#include -#include - -#include "knetworkmanager-plugin.h" -#include "knetworkmanager.h" - -class KPluginInfo; - -typedef TQMap PluginMap; - -class PluginManager : public TQObject -{ - Q_OBJECT - - public: - PluginManager(TQObject*, const char*); - ~PluginManager(); - - TQStringList getPluginList(const TQString&, const TQString&, const TQString&) const; - Plugin* getPlugin(const TQString&); - const KPluginInfo* getPluginInfo(const TQString&); - const KPluginInfo* getPluginInfo(const Plugin*); - - static PluginManager* getInstance (void); - - public slots: - void loadAllPlugins(); - - private: - TQValueList _plugins; - PluginMap _loadedPlugins; - - Plugin* loadPlugin(const TQString& pluginID); - KPluginInfo* infoForPluginID(const TQString& pluginID) const; - - static PluginManager* _instance; -}; - -#endif /* KNETWORKMANAGER_PLUGINMANAGER_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-tray.cpp b/tdenetworkmanager/src/knetworkmanager-tray.cpp deleted file mode 100644 index 7a818cc..0000000 --- a/tdenetworkmanager/src/knetworkmanager-tray.cpp +++ /dev/null @@ -1,766 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Valentine Sinitsyn - * Helmut Schaa , - * Alexander Naumov , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "devicetraycomponent.h" -#include "knetworkmanager-tray.h" - -#include "knetworkmanager-connection_settings_dialog.h" -#include "knetworkmanager-connection_editor.h" -#include "knetworkmanager-menu_subhead.h" - -#include "knetworkmanager-wired_device_tray.h" -#include "knetworkmanager-wireless_device_tray.h" -#include "knetworkmanager-cellular_device_tray.h" - -#include - -TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global; - -NewSecretsDialog::NewSecretsDialog(TDENetworkConnection *connection, TQWidget * parent, const char * name, bool modal, TQt::WFlags f) - : TQDialog(parent, name, modal, f) -{ - _connection = connection; - init(); -} - -NewSecretsDialog::~NewSecretsDialog () -{ - -} - -void NewSecretsDialog::slotDialogEdit() -{ - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(_connection, false, Tray::getInstance(), "Edit connection"); - dlg->show(); - close(); -} - -void NewSecretsDialog::reject() -{ - TQDialog::reject(); -} - -void NewSecretsDialog::init() -{ - TDENetworkConnection* conn = _connection; - - // if we do not have a connection bail out - if (!conn) - { - reject(); - return; - } - - // show a message to the user that the connection failed - // and allow edit or cancel - - TQLabel* label = new TQLabel(tqtr(" The connection %1 could not be established ").arg(conn->friendlyName), this); - TQPushButton* buttonEdit = new TQPushButton(tr("&Edit"), this); - TQPushButton* buttonCancel = new TQPushButton(tr("&Cancel"), this); - - TQHBoxLayout *topLeftLayout = new TQHBoxLayout(); - topLeftLayout->addWidget(buttonEdit); - topLeftLayout->addWidget(buttonCancel); - - TQVBoxLayout *mainLayout = new TQVBoxLayout(this); - mainLayout->setMargin(15); - mainLayout->setSpacing(10); - mainLayout->addWidget(label); - mainLayout->addLayout(topLeftLayout); - - connect(buttonEdit, TQT_SIGNAL(clicked()), TQT_SLOT(slotDialogEdit())); - connect(buttonCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(close())); -} - -class TrayPrivate -{ - public: - TrayPrivate(TQObject* parent) - : foregroundTrayComponent(0) - , signalMapper(parent, "signal_mapper") - , current_idx(0) - {} - ~TrayPrivate() {} - - static Tray* tray; - TQValueList trayComponents; - DeviceTrayComponent * foregroundTrayComponent; - TQSignalMapper signalMapper; - TQMap act_conn_map; - int current_idx; -}; - -Tray* TrayPrivate::tray = NULL; - -Tray* Tray::getInstance() -{ - if (TrayPrivate::tray) - return TrayPrivate::tray; - else return (TrayPrivate::tray = new Tray()); -} - -void Tray::slotEditConnections() -{ - ConnectionEditorImpl* dlg = new ConnectionEditorImpl(this); - dlg->show(); -} - - -void Tray::slotEnableWireless() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) return; - nm->enableWiFi(true); -} - -void Tray::slotDisableWireless() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) return; - nm->enableWiFi(false); -} - -void Tray::slotOfflineMode() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) return; - nm->enableNetworking(false); -} - -void Tray::slotOnlineMode() -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) return; - nm->enableNetworking(true); -} - -void Tray::contextMenuAboutToShow (KPopupMenu* menu) -{ - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - // clear menu - menu->clear(); - - if (!(nm->backendStatus() & TDENetworkGlobalManagerFlags::BackendUnavailable)) { - // actions for each Device - for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) { - (*it)->addMenuItems(menu); - } - - // Submenu title - Subhead* subhead = new Subhead (menu, "subhead", TQString("Connection Management"), SmallIcon("knetworkmanager_disabled", TQIconSet::Automatic)); - menu->insertItem (subhead, -1, -1); - - // New connection - KAction * newConnAction = 0; - int devices = d->trayComponents.count(); - if ( devices > 1 ) { - newConnAction = actionCollection ()->action ("new_connection_menu"); - KActionMenu* newConnActionMenu = static_cast(newConnAction); - newConnActionMenu->popupMenu()->clear(); - TQValueList::Iterator it; - for (it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) { - DeviceTrayComponent* dev_comp = dynamic_cast (*it); - KAction * deviceNewConnAction = 0; - if (dev_comp) { - TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); - TQString menuCaption = TQString("%1").arg(dev_comp->device()->deviceNode()); - if (menuCaption.contains("eth", FALSE) > 0) { - menuCaption = menuCaption.insert(0, "Wired Connection ("); - } - else if (menuCaption.contains("wlan", FALSE) > 0) { - menuCaption = menuCaption.insert(0, "Wireless Connection ("); - } - else if (menuCaption.contains("pan", FALSE) > 0) { - menuCaption = menuCaption.insert(0, "Private Area Connection ("); - } - else { - menuCaption = menuCaption.insert(0, "Unknown Connection ("); - } - menuCaption = menuCaption.append(")"); - deviceNewConnAction = actionCollection ()->action (actionName); - if (!deviceNewConnAction) { - deviceNewConnAction = new KAction (menuCaption, 0, (*it), TQT_SLOT(newConnection()), actionCollection(), actionName); - } - newConnActionMenu->insert(deviceNewConnAction); - } - } - } - else if ( devices == 1 ) { - newConnAction = actionCollection ()->action ("new_connection"); - TQT_BASE_OBJECT_NAME::disconnect( newConnAction, TQT_SIGNAL(activated()) ); - TQT_BASE_OBJECT_NAME::connect( newConnAction, TQT_SIGNAL(activated()), d->trayComponents[0], TQT_SLOT(newConnection())); - } - if (newConnAction) { - newConnAction->plug(menu); - } - - // turn things off - if (nm) { - KActionMenu* disableStuffActionMenu = static_cast(actionCollection ()->action ("deactivate_menu") ); - disableStuffActionMenu->popupMenu()->clear(); - TDENetworkConnectionList* map = nm->connections(); - d->act_conn_map.clear(); - - for (TDENetworkConnectionList::Iterator it = map->begin(); it != map->end(); ++it) { - TDENetworkConnection* conn = (*it); - - if (!conn) { - continue; - } - - if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected) - || (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) { - continue; - } - - TQString actionName = TQString("disable_connection_%1").arg(conn->UUID); - KAction * deviceNewConnAction = actionCollection ()->action (actionName); - TQString actionText = conn->friendlyName; - - if (!deviceNewConnAction) { - deviceNewConnAction = new KAction (actionText, 0, &d->signalMapper, TQT_SLOT(map()), actionCollection(), actionName); - } - d->signalMapper.setMapping(deviceNewConnAction, d->current_idx); - d->act_conn_map.insert(d->current_idx, conn); - d->current_idx++; - disableStuffActionMenu->insert(deviceNewConnAction); - } - - // disable wireless - if (nm->wiFiHardwareEnabled()) { - KAction* wireless = NULL; - if (nm->wiFiEnabled()) { - wireless = actionCollection ()->action ("disable_wireless"); - } else { - wireless = actionCollection ()->action ("enable_wireless"); - } - disableStuffActionMenu->insert(wireless); - } - - // offline vs. online mode - KAction* switch_mode = NULL; - if (nm->backendStatus() != TDENetworkGlobalManagerFlags::Sleeping) { - switch_mode = actionCollection ()->action ("offline_mode"); - } - else { - switch_mode = actionCollection ()->action ("online_mode"); - } - disableStuffActionMenu->insert(switch_mode); - - disableStuffActionMenu->plug(menu); - } - } - else { - Subhead* subhead = new Subhead (menu, "subhead", i18n("NetworkManager is not running"), SmallIcon("stop", TQIconSet::Automatic)); - menu->insertItem (subhead, -1, -1); - } - - // Notifications - KAction* notif = actionCollection()->action("configure_notifications"); - notif->plug(menu); - - // Connection Editor - KAction* edit = actionCollection ()->action ("edit_connections"); - edit->plug(menu); - - // quit - menu->insertSeparator (); - KAction* quitAction = actionCollection ()->action (KStdAction::name (KStdAction::Quit)); - if (quitAction) { - quitAction->plug (menu); - } -} - -void -Tray::slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState) -{ - TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState; - // change tray icon according to NM's state - - if ((nm_state & TDENetworkGlobalManagerFlags::Unknown) - || (nm_state & TDENetworkGlobalManagerFlags::Sleeping) - || (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink) - || (nm_state & TDENetworkGlobalManagerFlags::Disconnected) - || (nm_state & TDENetworkGlobalManagerFlags::BackendUnavailable)) { - setPixmap (loadIcon ("knetworkmanager_disabled")); - } - else if (nm_state & TDENetworkGlobalManagerFlags::Connected) { - setPixmap (loadIcon ("knetworkmanager")); - } - - printf("NM state: %d\n\r", nm_state); -} - -void -Tray::enterEvent (TQEvent* /*e*/) -{ - // show tooltip - TQToolTip::remove (this); - TQString tooltip = ""; - - // build up the tooltip from all tray components - for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) - { - TrayComponent* comp = *it; - if (comp->getToolTipText().isEmpty()) - continue; - if (!tooltip.isEmpty()) - tooltip += "\n\n"; - tooltip += comp->getToolTipText().join("\n"); - } - if (!tooltip.isEmpty()) - TQToolTip::add (this, tooltip); -} - -void -Tray::slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hints, bool request_new) -{ - // For now assume secrets are already in NM... -} - -void Tray::slotAddDeviceTrayComponent(TDENetworkDevice* dev) -{ - if (dev) { - createDeviceTrayComponent(dev); - } -} - -void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev) -{ - for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) - { - DeviceTrayComponent* dev_comp = dynamic_cast(*it); - if (!dev_comp) - continue; - - if (dev_comp->device() == dev) - { - if (d->foregroundTrayComponent && dev_comp->device() == d->foregroundTrayComponent->device() ) { - d->foregroundTrayComponent = 0; - } - - // remove the appropriate action - TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); - KAction * deviceNewConnAction = actionCollection ()->action (actionName); - - if (!deviceNewConnAction) - { - delete deviceNewConnAction; - deviceNewConnAction = NULL; - } - // remove device_tray and delete it - d->trayComponents.remove(it); - delete dev_comp; - - if (contextMenu()->isVisible()) { - contextMenu()->hide(); - } - - break; - } - } -} - -void Tray::createDeviceTrayComponent(TDENetworkDevice* dev) -{ - bool trayExists = false; - - if (!dev) return; - - // check if we have already a trayicon for this device - for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) - { - DeviceTrayComponent* dev_comp = dynamic_cast (*it); - if (dev_comp) - if (dev_comp->device() == dev) - { - trayExists = true; - break; - } - } - - // create the appropriate device tray icon - if (!trayExists) - { - DeviceTrayComponent* devTray = 0; - TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); - // different tray icons for different device types! - switch (deviceConnMan->deviceType()) - { - case TDENetworkDeviceType::WiredEthernet: - devTray = new WiredDeviceTray(dev, this, "wired_device_tray"); - break; - case TDENetworkDeviceType::WiFi: - devTray = new WirelessDeviceTray(dev, this, "wireless_device_tray"); - break; - case TDENetworkDeviceType::Modem: - devTray = new CellularDeviceTray(dev, this, "cellular_device_tray"); - break; - default: - kdWarning() << k_funcinfo << "UDI: " << dev->uniqueID() << " has unknown devicetype: " << deviceConnMan->deviceType() << endl; - } - if(devTray) - { - connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)), - TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool))); - connect( devTray, TQT_SIGNAL(uiUpdated()), TQT_SLOT(trayUiChanged())); - d->trayComponents.append(devTray); - //WILLTODO: sort - } - } -} - -void Tray::updateDeviceTrays() -{ - TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); - if (!hwdevices) return; - - // create one tray-icon for each device - TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); - - // check for newly added devices - for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) - { - TDENetworkDevice* dev = dynamic_cast(*it); - if (dev) { - createDeviceTrayComponent(dev); - } - else { - kdWarning() << k_funcinfo << "got a NULL-Device" << endl; - } - } -} - -void Tray::mousePressEvent( TQMouseEvent *e ) -{ - if ( !TQT_TQRECT_OBJECT(rect()).contains( e->pos() ) ) { - return; - } - switch ( e->button() ) { - case Qt::LeftButton: - contextMenuAboutToShow(contextMenu()); - contextMenu()->popup(e->globalPos()); - break; - default: - KSystemTray::mousePressEvent( e ); - break; - } -} - -void Tray::slotDeactivateConnection(int index) -{ - TDENetworkConnection* conn = d->act_conn_map[index]; - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (!nm) return; - - if (conn) { - nm->deactivateConnection(conn->UUID); - } -} - -void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt) -{ - DeviceTrayComponent * dtc = dynamic_cast(component); - if (dtc) { - kdDebug() << k_funcinfo << dtc->device()->deviceNode() << " : " << needsIt << endl; - TDENetworkDevice * device = dtc->device(); - if (needsIt) { - if (d->foregroundTrayComponent) { - disconnect(d->foregroundTrayComponent->device(), TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); - } - d->foregroundTrayComponent = dtc; - connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), - TQT_SLOT(slotUpdateDeviceState(NMDeviceState))); - } else { - disconnect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); - // use active default -#if 0 - // FIXME - // The TDE network backend has no concept of a default device - // Should it? - device = nm->getDefaultDevice(); - if ( device ) { - // identify the new foreground - for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) - { - DeviceTrayComponent* newDtc = dynamic_cast (*it); - if ( newDtc && newDtc->device() == device ) { - d->foregroundTrayComponent = newDtc; - break; - } - } - kdDebug() << " Device " << dtc->device()->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl; - connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), - TQT_SLOT(slotUpdateDeviceState(NMDeviceState))); - slotUpdateDeviceState(device->getState()); - } -#endif - } - } -} - -void Tray::slotUpdateDeviceState() -{ - // FIXME -} - -void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - updateTrayIcon(state); - updateActiveConnection(state); -} - -void Tray::trayUiChanged() -{ - DeviceTrayComponent * dtc = d->foregroundTrayComponent; - if (dtc) { - TDENetworkConnectionManager* deviceConnMan = dtc->device()->connectionManager(); - updateTrayIcon(deviceConnMan->deviceInformation().statusFlags); - } -} -void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - // Get all active connections - char found_any_active_connection=0; - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - found_any_active_connection = 0; - // Get all active connections - TDENetworkConnectionList* allconmap = nm->connections(); - for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { - TDENetworkConnection* conn = (*it); - - if (!conn) { - continue; - } - - if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected) - || (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) { - continue; - } - - // Found an active connection - found_any_active_connection = 1; - } - -// if (found_any_active_connection == 1) { -// printf("Active connection found\n\r"); -// } - - // stop the old movie to avoid unnecessary wakups - DeviceTrayComponent * dtc = d->foregroundTrayComponent; - - if (movie()) - movie()->pause(); - - if ((dtc) && (found_any_active_connection == 1)) { - - if (!dtc->movieForState(state).isNull()) - { - // animation desired - int frame = -1; - if (movie()) - frame = movie()->frameNumber(); - - // set the movie - setMovie(dtc->movieForState(state)); - - // start at the same frame as the movie before - if (frame > 0) - movie()->step(frame); - - // start the animation - movie()->unpause(); - } - else if (!dtc->pixmapForState(state).isNull()) - setPixmap(dtc->pixmapForState(state)); - else - setPixmap(loadIcon("knetworkmanager")); - } - else { - setPixmap(loadIcon("knetworkmanager")); - } - - nm_device_state_global = state; - //printf("Device state: %d\n\r", nm_device_state_global); -} - -void Tray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - if (state != TDENetworkConnectionStatus::Connected) { - return; - } -} - -void Tray::slotDeviceAddedNotify(TDENetworkDevice* dev) -{ - kdDebug() << "Tray::slotDeviceAddedNotify" << endl; - KNotifyClient::event( winId(), "knm-nm-device-added", i18n("New network device %1 found").arg(dev->deviceNode()) ); -} - -void Tray::slotDeviceRemovedNotify(TDENetworkDevice* dev) -{ - kdDebug() << "Tray::slotDeviceRemovedNotify" << endl; - KNotifyClient::event( winId(), "knm-nm-device-removed", i18n("Network device %1 removed").arg(dev->deviceNode()) ); -} - -void Tray::slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState) -{ - TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState; - - // change tray icon according to NM's state - if (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink) { - KNotifyClient::event( winId(), "knm-nm-connecting", i18n("NetworkManager is connecting") ); - } - else if (nm_state & TDENetworkGlobalManagerFlags::Disconnected) { - KNotifyClient::event( winId(), "knm-nm-disconnected", i18n("NetworkManager is now disconnected") ); - } - else if (nm_state & TDENetworkGlobalManagerFlags::Connected) { - KNotifyClient::event( winId(), "knm-nm-connected", i18n("NetworkManager is now connected") ); - } - else if (nm_state & TDENetworkGlobalManagerFlags::Sleeping) { - KNotifyClient::event( winId(), "knm-nm-sleeping", i18n("KNetworkManager Offline") ); - } - else if (nm_state & TDENetworkGlobalManagerFlags::Unknown) { - // - } -} - -void Tray::slotEditNotifications() -{ - KNotifyDialog::configure(this); -} - -Tray::Tray () : KSystemTray () -{ - d = new TrayPrivate(TQT_TQOBJECT(this)); - - connect(&d->signalMapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(slotDeactivateConnection(int))); - - setPixmap (loadIcon ("knetworkmanager")); - setMouseTracking (true); - - // Actions used for plugging into the menu - new KAction (i18n ("Switch to offline mode"), - SmallIcon ("no", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotOfflineMode()), actionCollection (), "offline_mode"); - - new KAction (i18n ("Switch to online mode"), - SmallIcon ("ok", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotOnlineMode()), actionCollection (), "online_mode"); - - new KAction (i18n ("Disable Wireless"), - SmallIcon ("wireless_off", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotDisableWireless()), actionCollection (), "disable_wireless"); - - new KAction (i18n ("Enable Wireless"), - SmallIcon ("wireless", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotEnableWireless()), actionCollection (), "enable_wireless"); - - new KAction (i18n ("Edit Connections"), - SmallIcon ("edit", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotEditConnections()), actionCollection (), "edit_connections"); - - new KAction (i18n ("Configure Notifications"), - SmallIcon ("knotify", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), TQT_SLOT (slotEditNotifications()), actionCollection (), "configure_notifications"); - - // this action is only connected when the menu is shown, hence the 0 receiver - new KAction (i18n ("New connection ..."), - SmallIcon ("filenew", TQIconSet::Automatic), 0, - TQT_TQOBJECT(this), 0, actionCollection (), "new_connection"); - - new KActionMenu (i18n ("New connection ..."), - SmallIcon ("filenew", TQIconSet::Automatic), - actionCollection(), "new_connection_menu"); - - new KActionMenu (i18n ("Deactivate connection..."), - SmallIcon ("no", TQIconSet::Automatic), - actionCollection (), "deactivate_menu"); - - // get notified when NM's state changes - connect(KGlobal::networkManager(), TQT_SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, TQT_SLOT(slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); - - // get notified about new/removed devices - // FIXME -// DeviceStore* store = DeviceStore::getInstance(); -// connect(store, TQT_SIGNAL(DeviceStoreChanged()), this, TQT_SLOT(updateDeviceTrays())); -// connect(store, TQT_SIGNAL(DeviceAdded(TDENetworkDevice*)), this, TQT_SLOT(slotAddDeviceTrayComponent(TDENetworkDevice*))); -// connect(store, TQT_SIGNAL(DeviceRemoved(TDENetworkDevice*)), this, TQT_SLOT(slotRemoveDeviceTrayComponent(TDENetworkDevice*))); - - // Notifications - connect(KGlobal::networkManager(), TQT_SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, TQT_SLOT(slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); -// connect(store, TQT_SIGNAL(DeviceAdded(TDENetworkDevice*)), this, TQT_SLOT(slotDeviceAddedNotify(TDENetworkDevice*))); -// connect(store, TQT_SIGNAL(DeviceRemoved(TDENetworkDevice*)), this, TQT_SLOT(slotDeviceRemovedNotify(TDENetworkDevice*))); - - - // initial setup of the device-trays - updateDeviceTrays(); - - slotStateChanged(KGlobal::networkManager()->backendStatus(), TDENetworkGlobalManagerFlags::Unknown); -} - -Tray::~Tray () -{ - delete d; -} - -#include "knetworkmanager-tray.moc" - diff --git a/tdenetworkmanager/src/knetworkmanager-tray.h b/tdenetworkmanager/src/knetworkmanager-tray.h deleted file mode 100644 index 6f39948..0000000 --- a/tdenetworkmanager/src/knetworkmanager-tray.h +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Helmut Schaa , - * Alexander Naumov , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_TRAY_H -#define KNETWORKMANAGER_TRAY_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include "knetworkmanager.h" - -namespace ConnectionSettings -{ - class Connection; - class ConnectionSetting; -} - -class TQMouseEvent; -class TrayComponent; -class TrayPrivate; -class TQDialog; -class TQPushButton; -class TQLabel; - -class Tray : public KSystemTray -{ - Q_OBJECT - - - public: - Tray (); - ~Tray (); - static Tray* getInstance(); - void contextMenuAboutToShow (KPopupMenu* menu); - - signals: - - public slots: - void slotOfflineMode(); - void slotOnlineMode(); - void slotEnableWireless(); - void slotDisableWireless(); - void slotEditConnections(); - - void slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState); - void slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hints, bool request_new); - - void slotDeviceAddedNotify(TDENetworkDevice*); - void slotDeviceRemovedNotify(TDENetworkDevice*); - void slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState); - - void slotUpdateDeviceState(); - void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - - protected slots: - void updateDeviceTrays(); - void slotAddDeviceTrayComponent(TDENetworkDevice*); - void slotRemoveDeviceTrayComponent(TDENetworkDevice*); - void slotDeactivateConnection(int); - void trayComponentNeedsCenterStage(TrayComponent*, bool); - void trayUiChanged(); - void slotEditNotifications(); - - private: - void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void mousePressEvent(TQMouseEvent *e); - void createDeviceTrayComponent(TDENetworkDevice*); - void enterEvent(TQEvent*); - - TrayPrivate* d; - -}; - -class NewSecretsDialog : public TQDialog -{ - Q_OBJECT - - - public: - NewSecretsDialog(TDENetworkConnection* connection, TQWidget * parent, const char * name, bool modal = false, TQt::WFlags f = 0); - ~NewSecretsDialog(); - void init(); - - public slots: - void slotDialogEdit(); - void reject(); - - private: - TDENetworkConnection* _connection; -}; - -#endif /* KNETWORKMANAGER_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-vpn_plugin.cpp b/tdenetworkmanager/src/knetworkmanager-vpn_plugin.cpp deleted file mode 100644 index f56b221..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpn_plugin.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpn_plugin.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// KDE includes -#include - -// TQt includes -#include - -// TQT_DBus includes -#include -#include -#include - -// NM includes -#include -#include - -// KNM includes -#include "knetworkmanager.h" -#include "knetworkmanager-tray.h" -#include "knetworkmanager-vpn_plugin.h" -#include "dbus/vpnpluginproxy.h" -#include "knetworkmanager-hal_device_proxy.h" -#include "knetworkmanager-nm_proxy.h" - -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - -unsigned int current_vpn_state = 0; -extern NMDeviceState nm_device_state_global; -extern TQT_DBusObjectPath vpn_attempt_this_conn; -unsigned char vpn_new_credentials_needed = 0; - -class VPNDBUSPluginPrivate -{ -public: - VPNDBUSPluginPrivate(TQString service, TQString obj_path) - : nmVPNDBUS(service, obj_path) - {} - ~VPNDBUSPluginPrivate() {} - - DBus::VPNPluginProxy nmVPNDBUS; -}; - -TQ_UINT32 VPNDBUSPlugin::getState() -{ - TQT_DBusError err; - return d->nmVPNDBUS.getState(err); -} - -void VPNDBUSPlugin::slotStateChanged(TQ_UINT32 state) -{ - current_vpn_state = state+1; - Tray* tray = Tray::getInstance(); - tray->slotUpdateDeviceState(nm_device_state_global); - //emit StateChanged((NMDeviceState)state); -} - -void VPNDBUSPlugin::slotLoginBanner(const TQString& banner) -{ - Tray* tray = Tray::getInstance(); - tray->slotVPNBannerShow(banner); -} - -void VPNDBUSPlugin::slotFailure(TQ_UINT32 failure_reason) -{ - printf("VPN failure code %d\n\r", failure_reason); - - if ((failure_reason == 0) || (failure_reason == 1) || (failure_reason == 2)) { - // Try to connect again using cached information; request new login though - printf("Reactivate VPN connection on default device\n\r"); - vpn_new_credentials_needed = 1; - int id; - TQT_DBusError err; - NMProxy* nm = NMProxy::getInstance(); - TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); - TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); -#if NM_CHECK_VERSION(0,8,992) - nm->ActivateConnectionAsync(id,"org.freedesktop.NetworkManagerUserSettings", vpn_attempt_this_conn, device, act_conn, err); -#else - nm->ActivateConnectionAsync(id,NM_DBUS_SERVICE_USER_SETTINGS, vpn_attempt_this_conn, device, act_conn, err); -#endif - } -} - -VPNDBUSPlugin::VPNDBUSPlugin () - : TQObject() -{ - d = new VPNDBUSPluginPrivate(NM_VPN_DBUS_PLUGIN_INTERFACE, NM_VPN_DBUS_PLUGIN_PATH); - d->nmVPNDBUS.setConnection(TQT_DBusConnection::systemBus()); - - // Connect the state changed signal to the handler - connect(&(d->nmVPNDBUS), TQT_SIGNAL(StateChanged(TQ_UINT32)), this, TQT_SLOT(slotStateChanged(TQ_UINT32))); - - // Connect the failure signal to the handler - connect(&(d->nmVPNDBUS), TQT_SIGNAL(Failure(TQ_UINT32)), this, TQT_SLOT(slotFailure(TQ_UINT32))); - - // And the banner signal - connect(&(d->nmVPNDBUS), TQT_SIGNAL(LoginBanner(const TQString&)), this, TQT_SLOT(slotLoginBanner(const TQString&))); -} - -VPNDBUSPlugin::~VPNDBUSPlugin () -{ - delete d; -} - - -#include "knetworkmanager-vpn_plugin.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-vpn_plugin.h b/tdenetworkmanager/src/knetworkmanager-vpn_plugin.h deleted file mode 100644 index 88c63e0..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpn_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wired_device.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * Author: Timothy Pearson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_VPNDBUSPLUGIN_H -#define KNETWORKMANAGER_VPNDBUSPLUGIN_H - -// std includes -#include - -// KNM includes -#include "knetworkmanager.h" - -class KNetworkManager; - -class VPNDBUSPluginPrivate; - -class VPNDBUSPlugin : public TQObject -{ - Q_OBJECT - - public: - VPNDBUSPlugin (); - ~VPNDBUSPlugin (); - - TQ_UINT32 getState(); - - private: - VPNDBUSPluginPrivate * d; - -// signals: -// void StateChanged(NMDeviceState); - - public slots: - void slotFailure(TQ_UINT32); - void slotStateChanged(TQ_UINT32); - void slotLoginBanner(const TQString&); -// void slotDeactivate(); -}; - -#endif /* KNETWORKMANAGER_VPNDBUSPLUGIN_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.cpp b/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.cpp deleted file mode 100644 index ffeb933..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnauthenticationdialog.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "knetworkmanager-vpnservice.h" -#include "knetworkmanager-vpnmanager.h" -#include "knetworkmanager-vpnauthenticationdialog.h" -#include "knetworkmanager-vpn_connection.h" -#include "knetworkmanager-nm_proxy.h" -#include "knetworkmanager-connection_setting_vpn.h" -#include "knetworkmanager-connection_setting_info.h" - -extern TQT_DBusObjectPath vpn_attempt_this_conn; - -using namespace ConnectionSettings; - - -/* - * class VPNAuthenticationDialog - * - */ -VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, TQWidget* parent, const char* name, bool modal, WFlags fl) - : AuthenticationDialog(parent, name, modal, fl) - , _conn(conn) -{ - this->setIcon(SmallIcon("encrypted", TQIconSet::Automatic)); - this->setCaption(i18n("VPN Authentication for %1").arg(conn->getInfoSetting()->getName())); - labelPixmap->setPixmap(KGlobal::instance()->iconLoader()->loadIcon("encrypted", KIcon::Small, 32)); - - // nice icons - pushOK->setIconSet(SmallIcon("button_ok", TQIconSet::Automatic)); - pushCancel->setIconSet(SmallIcon("button_cancel", TQIconSet::Automatic)); - - // we need the last widget in the focus queue - TQFocusData* foc = focusData(); - TQWidget* lastFocusWidget = foc->last(); - - VPN* vpn = conn->getVPNSetting(); - VPNService* vpnservice = VPNManager::getVPNService(vpn->getServiceType()); - - // get the appropriate plugin and create the authentication widget - VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin(); - if (vpnPlugin) - { - _vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack); - if (_vpnAuthWidget) - { - _vpnAuthWidget->setVPNData(conn->getVPNSetting()->getRoutes(), conn->getVPNSetting()->getData()); - widgetStack->raiseWidget(_vpnAuthWidget); - } - } - - /* - the widgets inside the authenticationwidget are now in the focus queue - ==> we can now search the first widget inside the authenticationwidget - which has to get the focus - */ - TQWidget* widget = foc->home(); - for (int i = 0; i < foc->count(); ++i) - { - if (widget == lastFocusWidget) - { - // the next one is the first widget inside the authwidget - widget = foc->next(); - break; - } - widget = foc->next(); - } - if (widget) - widget->setFocus(); - - // resize - this->resize(minimumSizeHint()); -} - -VPNAuthenticationDialog::~VPNAuthenticationDialog() -{ - -} - -bool VPNAuthenticationDialog::close(bool alsoDelete) -{ - // no secrets provided, tell NM - _conn->slotSecretsError(); - return AuthenticationDialog::close(alsoDelete); -} - -void VPNAuthenticationDialog::ok() -{ - // Good, we have new secrets now, update the settings - TQMap mypwds; - - mypwds = _vpnAuthWidget->getPasswords(); - ConnectionSetting* propcore = _conn->getVPNSettingConnectionCore(); - SettingsMap othersettingsmap = propcore->toMap(); - - // Pull the username and gateway out of mypwds to stuff in the NM standard settings matrix - othersettingsmap.insert("user", TQT_DBusData::fromString(mypwds["user"])); - mypwds.erase("user"); - othersettingsmap.insert("domain", TQT_DBusData::fromString(mypwds["domain"])); - mypwds.erase("domain"); -// othersettingsmap.erase("Commit to disk"); -// if (chkStorePasswordsPermanent->isChecked() == true) { -// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("true")); -// } -// else { -// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("false")); -// } - - propcore->fromMap(othersettingsmap); - VPN* prop = dynamic_cast(propcore); - prop->setSecrets(mypwds); - _conn->slotSecretsProvided(prop); - TQDialog::done(0); -} - -void VPNAuthenticationDialog::setPasswords(TQString name, TQString value) { - if (value.length() > 0) { - chkStorePasswordsPermanent->setChecked(true); - _vpnAuthWidget->setPasswords(name, value); - } -} - -void VPNAuthenticationDialog::cancel() -{ -/* - TQStringList x; - emit done (true, x, false, false); - TQDialog::done(1);*/ - - printf("Attempting to deactivate VPN connection...\n\r"); - - // Disconnect the attempted connection - _conn->slotSecretsError(); - - // Quit the dialog - TQDialog::done(1); -} - -#include "knetworkmanager-vpnauthenticationdialog.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.h b/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.h deleted file mode 100644 index 8c43e7d..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnauthenticationdialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-authenticationdialog.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H -#define KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H - -#include -#include -#include -#include - -#include "knetworkmanager.h" -#include "vpnauthentication.h" -#include "knetworkmanager-vpnplugin.h" -#include "knetworkmanager-vpnmanager.h" - -class KNetworkManager; -class ManageConnectionsDialog; -class VPNService; - -namespace ConnectionSettings -{ - class VPNConnection; -} - -class VPNAuthenticationDialog : public AuthenticationDialog -{ - Q_OBJECT - - public: - VPNAuthenticationDialog(ConnectionSettings::VPNConnection* conn = NULL, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); - ~VPNAuthenticationDialog(); - void setPasswords(TQString name, TQString value); - virtual bool close(bool); - - protected slots: - void ok(); - void cancel(); - - private: - VPNAuthenticationWidget* _vpnAuthWidget; - ConnectionSettings::VPNConnection* _conn; - - signals: - void done(bool, TQStringList &, bool, bool); -}; - -#endif /* KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-vpnmanager.cpp b/tdenetworkmanager/src/knetworkmanager-vpnmanager.cpp deleted file mode 100644 index 5b7e64e..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnmanager.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnmanager.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#define SERVICE_DIR "/etc/NetworkManager/VPN" - -#include -#include -#include -#include - -#include "knetworkmanager-vpnmanager.h" -#include "knetworkmanager-vpnservice.h" -#include "knetworkmanager-vpnplugin.h" - -/* - * class VPNManager - * - */ -VPNServiceList -VPNManager::getVPNServices () -{ - bool status = false; - VPNServiceList list; - - TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); - TQStringList services = serviceDir.entryList ().grep (".name", true); - - if (services.count () > 0) - { - status = true; - // read in all available Services - for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { - TQString service = SERVICE_DIR + TQString ("/") + *i; - KConfig* kconfig = new KConfig (service, true, true, "config"); - kconfig->setGroup ("VPN Connection"); - -kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl; - - // create new VPNService Object - VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(KNetworkManager::getInstance())); - if (!vpnservice->getVPNPlugin()) - delete vpnservice; - else - list.push_back(vpnservice); - delete kconfig; - } - } - - return list; -} - -VPNService* -VPNManager::getVPNService(TQString service_type) -{ - bool status = false; - VPNServiceList list; - - TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); - TQStringList services = serviceDir.entryList ().grep (".name", true); - - if (services.count () > 0) - { - status = true; - // read in all available Services - for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { - TQString service = SERVICE_DIR + TQString ("/") + *i; - KConfig* kconfig = new KConfig (service, true, true, "config"); - kconfig->setGroup ("VPN Connection"); - - if (kconfig->readEntry ("service", TQString()) == service_type) - { - // create new VPNService Object - VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(KNetworkManager::getInstance())); - if (!vpnservice->getVPNPlugin()) - delete vpnservice; - else - return vpnservice; - } - } - } - return NULL; - -} - -#include "knetworkmanager-vpnmanager.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-vpnmanager.h b/tdenetworkmanager/src/knetworkmanager-vpnmanager.h deleted file mode 100644 index 769d2c3..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnmanager.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Helmut Schaa - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_VPNMANAGER_H -#define KNETWORKMANAGER_VPNMANAGER_H - -#include -#include - -#include -#include - -#include "knetworkmanager.h" -#include "knetworkmanager-vpnplugin.h" - -class KNetworkManager; -class VPNService; - -typedef TQValueList VPNServiceList; - -class VPNManager : public TQObject -{ - Q_OBJECT - - - public: - static VPNService* getVPNService(TQString); - static VPNServiceList getVPNServices (); -}; - -#endif /* KNETWORKMANAGER_VPNMANAGER_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-vpnplugin.cpp b/tdenetworkmanager/src/knetworkmanager-vpnplugin.cpp deleted file mode 100644 index 02ef8fe..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnplugin.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnplugin.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include - -#include "knetworkmanager-vpnplugin.h" - -/*********************** -* class VPNConfigWidget -***********************/ - -VPNConfigWidget::~VPNConfigWidget() -{ - -} - -VPNConfigWidget::VPNConfigWidget(TQWidget* parent, const char* name) - : TQWidget(parent, name) -{ - -} - -void VPNConfigWidget::setVPNData(const TQStringList& /*routes*/, const TQMap& /*properties*/) -{ - -} - -TQMap VPNConfigWidget::getVPNProperties() -{ - return TQMap(); -} - -TQStringList VPNConfigWidget::getVPNRoutes() -{ - return TQStringList(); -} - -bool VPNConfigWidget::hasChanged() -{ - return true; -} - -bool VPNConfigWidget::isValid(TQStringList& /*err_msg*/) -{ - return true; -} - -/****************************** -* class VPNAuthentiactionWidget -******************************/ - -VPNAuthenticationWidget::VPNAuthenticationWidget(TQWidget* parent, const char* name) - : TQWidget(parent, name) -{ - -} - -VPNAuthenticationWidget::~VPNAuthenticationWidget() -{ - -} - -TQMap VPNAuthenticationWidget::getPasswords() -{ - return TQMap(); -} - -void VPNAuthenticationWidget::setPasswords(TQString name, TQString value) -{ - -} - -void VPNAuthenticationWidget::setVPNData(const TQStringList& /*routes*/, const TQMap& /*properties*/) -{ - -} - -bool VPNAuthenticationWidget::needsUserInteraction() -{ - return true; -} - -/**************** -* class VPNPlugin -****************/ -VPNPlugin::VPNPlugin(TQObject* parent, const char* name, const TQStringList& args) - : Plugin(parent, name, args) -{ - -} - -VPNPlugin::~VPNPlugin() -{ - -} - -VPNConfigWidget* VPNPlugin::CreateConfigWidget(TQWidget*) -{ - return NULL; -} - -VPNAuthenticationWidget* VPNPlugin::CreateAuthenticationWidget(TQWidget*) -{ - return NULL; -} - -#include "knetworkmanager-vpnplugin.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-vpnplugin.h b/tdenetworkmanager/src/knetworkmanager-vpnplugin.h deleted file mode 100644 index 3b8b625..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnplugin.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnplugin.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_VPNPLUGIN_H -#define KNETWORKMANAGER_VPNPLUGIN_H - -#include -#include -#include -#include -#include "knetworkmanager-plugin.h" - -#define KNETWORKMANAGER_VPNPLUGIN "KNetworkManager/VPNPlugin" - -class VPNConfigWidget : public TQWidget -{ - Q_OBJECT - - public: - virtual ~VPNConfigWidget(); - VPNConfigWidget(TQWidget* parent = NULL, const char* name = NULL); - - virtual void setVPNData(const TQStringList&, const TQMap&); - virtual TQMap getVPNProperties(); - virtual TQStringList getVPNRoutes(); - virtual bool hasChanged(); - virtual bool isValid(TQStringList&); -}; - -class VPNAuthenticationWidget : public TQWidget -{ - Q_OBJECT - - public: - virtual ~VPNAuthenticationWidget(); - VPNAuthenticationWidget(TQWidget* parent = NULL, const char* name = NULL); - - virtual void setVPNData(const TQStringList&, const TQMap&); - virtual TQMap getPasswords(); - virtual void setPasswords(TQString value, TQString data); - virtual bool needsUserInteraction(); -}; - -class VPNPlugin : public Plugin -{ - Q_OBJECT - - public: - VPNPlugin(TQObject*, const char*, const TQStringList&); - virtual ~VPNPlugin(); - - virtual VPNConfigWidget* CreateConfigWidget(TQWidget* parent = 0); - virtual VPNAuthenticationWidget* CreateAuthenticationWidget(TQWidget* parent = 0); -}; - - -#endif /* KNETWORKMANAGER_VPNPLUGIN_H */ - diff --git a/tdenetworkmanager/src/knetworkmanager-vpnservice.cpp b/tdenetworkmanager/src/knetworkmanager-vpnservice.cpp deleted file mode 100644 index 84daa0c..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnservice.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnservice.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#define SERVICE_DIR "/etc/NetworkManager/VPN" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "knetworkmanager-pluginmanager.h" -#include "knetworkmanager-vpnservice.h" -#include "knetworkmanager-vpnplugin.h" - -/* - * class VPNService - * - */ - -VPNService::VPNService(const TQString& serviceName, const TQString& service, TQObject* parent, const char* name) - : TQObject(parent, name) -{ - _name = serviceName; - _service = service; - _vpnPlugin = NULL; - - // query if a plugin for this vpn service is available - PluginManager* plugMan = PluginManager::getInstance(); - if (plugMan) - { - TQStringList list = plugMan->getPluginList("KNetworkManager/VPNPlugin", "X-NetworkManager-Services", serviceName); - if (list.size() > 0) - { - // get the first VPN Plugin handling our VPNService - VPNPlugin* vpnPlugin = dynamic_cast( plugMan->getPlugin(list.first()) ); - if (vpnPlugin) - { - kdDebug() << k_funcinfo << i18n("Using VPN plugin '%1' for service '%2'").arg(list.first()).arg(serviceName) << endl; - _vpnPlugin = vpnPlugin; - } - } - } -} - -VPNService::~VPNService() -{ - -} - -TQString VPNService::getIcon() -{ - if (!_vpnPlugin.isNull()) - { - PluginManager* plugMan = PluginManager::getInstance(); - if (plugMan) - { - const KPluginInfo* info = plugMan->getPluginInfo(_vpnPlugin); - if (info) - { - TQString icon = info->icon(); - if (!icon.isEmpty()) - return icon; - } - } - } - return "encrypted"; -} - -VPNPlugin* VPNService::getVPNPlugin() -{ - return _vpnPlugin; -} - -TQString VPNService::getService() const -{ - return _service; -} - -TQString VPNService::getDisplayName() const -{ - const KPluginInfo* info = NULL; - PluginManager* plugMan = PluginManager::getInstance(); - if (_vpnPlugin && plugMan) - if ( (info = plugMan->getPluginInfo(_vpnPlugin)) ) - if (!info->name().isEmpty()) - return info->name(); - return _name; -} - -TQString VPNService::getName() const -{ - return _name; -} - -#include "knetworkmanager-vpnservice.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-vpnservice.h b/tdenetworkmanager/src/knetworkmanager-vpnservice.h deleted file mode 100644 index 51a03f6..0000000 --- a/tdenetworkmanager/src/knetworkmanager-vpnservice.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-vpnservice.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Helmut Schaa - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_VPN_SERVICE_H -#define KNETWORKMANAGER_VPN_SERVICE_H - -#include -#include - -#include -#include - -#include "knetworkmanager.h" -#include "knetworkmanager-vpnplugin.h" - -class KNetworkManager; -class VPNService; -class KConfigGroup; - -class VPNService : public TQObject -{ - Q_OBJECT - - - public: - VPNService(const TQString& serviceName, const TQString& service, TQObject* parent, const char* name = 0); - ~VPNService(); - - TQString getDisplayName() const; - TQString getName() const; - TQString getService() const; - VPNPlugin* getVPNPlugin(); - TQString getIcon(); - - private: - TQString _name; - TQString _service; - TQGuardedPtr _vpnPlugin; -}; - -#endif /* KNETWORKMANAGER_VPN_SERVICE_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp deleted file mode 100644 index c399a7a..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wired_device_tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// TQt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// KDE includes -#include -#include -#include - -// TQt DBus -#include - - -// KNM includes -#include "knetworkmanager-wired_device_tray.h" -#include "knetworkmanager-menuitem.h" -#include "knetworkmanager-menu_subhead.h" - -#include "knetworkmanager-connection_setting_wired.h" -#include "knetworkmanager-connection_settings_dialog.h" - -using namespace ConnectionSettings; - -class WiredDeviceTrayPrivate -{ - public: - WiredDeviceTrayPrivate() {} - ~WiredDeviceTrayPrivate() {} - - TDENetworkDevice* dev; -}; - -void WiredDeviceTray::newConnection() -{ - // create a new wired connection - TDENetworkConnection* conn = new TDEWiredEthernetConnection(); - - // edit the new connection - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); - dlg->show(); -} - - -void WiredDeviceTray::addMenuItems(KPopupMenu* menu) -{ - // device title - Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wired", TQIconSet::Automatic)); - menu->insertItem (subhead, -1, -1); - - // bolding subhead instead - //menu->insertSeparator(); - - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - if (deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::LinkUnavailable) { - // no carrier -> do not show any connections - subhead = new Subhead(menu, "subhead2", i18n("Cable disconnected"), SmallIcon("no", TQIconSet::Automatic)); - menu->insertItem(subhead, -1, -1); - } - else { - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkConnection* active_conn = NULL; - if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) - && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { - active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); - } - - // get all available Connections for wired devices - TDENetworkConnectionList* connections = nm->connections(); - int connectionItems = 0; - for (TDENetworkConnectionList::Iterator it = connections->begin(); it != connections->end(); ++it) { - TDEWiredEthernetConnection* conn = dynamic_cast(*it); - if (!conn) { - continue; - } - - // wired connection found :) - // lets create a nice name for this connection - TQString title = conn->friendlyName; - if (conn->ipConfig.valid) { - title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); - } - - NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); - connectionItems += 1; - - int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); - menu->setItemChecked(id, ((*it) == active_conn)); - } - - if ( connectionItems == 0) { - // menu->insertSeparator(); - menu->insertItem(SmallIcon("filenew", TQIconSet::Automatic), i18n("Create new wired connection"), this, TQT_SLOT(newConnection())); - } - // bring the device down - KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); - if (deactivate) - deactivate->plug(menu); - - } -} - -WiredDeviceTray::WiredDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name ) - : DeviceTrayComponent (dev, parent, name) -{ - d = new WiredDeviceTrayPrivate(); - d->dev = dev; - - setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wired"); -} - -WiredDeviceTray::~WiredDeviceTray () -{ - delete d; -} - -#include "knetworkmanager-wired_device_tray.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.h b/tdenetworkmanager/src/knetworkmanager-wired_device_tray.h deleted file mode 100644 index b2a2f7d..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_WIRED_DEVICE_TRAY_H -#define KNETWORKMANAGER_WIRED_DEVICE_TRAY_H - -// KNM includes -#include "devicetraycomponent.h" - -#include "knetworkmanager.h" - -// predefs -class WiredDevice; -class WiredDeviceTrayPrivate; - -class WiredDeviceTray : public DeviceTrayComponent -{ - Q_OBJECT - - - public: - WiredDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); - ~WiredDeviceTray (); - - void addMenuItems(KPopupMenu* menu); - - public slots: - void newConnection(); - - private: - WiredDeviceTrayPrivate* d; -}; - -#endif /* KNETWORKMANAGER_WIRED_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp deleted file mode 100644 index 996ea1e..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wireless_device_tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// TQt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// KDE includes -#include -#include -#include -#include - -// KNM includes -#include "knetworkmanager-wireless_device_tray.h" -#include "knetworkmanager-wireless_menuitem.h" -#include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-menu_subhead.h" -#include "knetworkmanager-wireless_manager.h" -#include "knetworkmanager-connection_settings_dialog.h" - -using namespace ConnectionSettings; - -extern char use_new_wireless_essid; -extern TQByteArray new_wireless_essid; - -class WirelessDeviceTrayPrivate -{ - public: - WirelessDeviceTrayPrivate() :dev(0), activeAccessPoint(0) { } - ~WirelessDeviceTrayPrivate() {} - - TDENetworkDevice* dev; - TQGuardedPtr activeAccessPoint; -}; - -TQStringList WirelessDeviceTray::getToolTipText() -{ - TQStringList tooltip = DeviceTrayComponent::getToolTipText(); - - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); - if (ap) { - tooltip.append(i18n("Network: %1").arg(ap->friendlySSID())); - } - - return tooltip; -} - -void WirelessDeviceTray::newConnection() -{ - // create a new wireless connection - TDENetworkConnection* conn = new TDEWiFiConnection(); - - // open a dialog for editing the connection - use_new_wireless_essid = 0; // deactivate autofill for now - ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); - dlg->show(); -} - -bool WirelessDeviceTray::findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList& nets, WirelessNetwork& net) -{ - const TDEWiFiConnection* wireless = dynamic_cast(conn); - - if (!wireless) { - return false; - } - - for (TQValueList::ConstIterator it = nets.begin(); it != nets.end(); ++it) { - if (wireless->SSID == (*it).getSsid()) { - net = *it; - return true; - } - } - return false; -} - -TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetwork& net, const TQValueList& connections) -{ - // try to find a connection matching this network - for (TQValueList::ConstIterator it = connections.begin(); it != connections.end(); ++it) { - const TDEWiFiConnection* wireless = dynamic_cast(*it); - - if (!wireless) { - continue; - } - - if (wireless->SSID == net.getSsid()) - { - return *it; - } - } - - return NULL; -} - -void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu) -{ - printf("Updating wireless network list\n\r"); - - // get all wireless networks - TQValueList nets = WirelessManager::getWirelessNetworks(d->dev); - - // get all wireless connections - TQValueList conns = WirelessManager::getWirelessConnections(); - - // get the currently active connection - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkConnection* active_conn = NULL; - if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) - && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { - active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); - } - - // add all wireless connections in range - // (we may have more then one connection per network) - for (TQValueList::iterator it = conns.begin(); it != conns.end(); ++it) - { - WirelessNetworkItem* wirelessNetworkItem; - WirelessNetwork net; - - // only show connections which are in range - if ( !findMatchingNetwork(*it, nets, net) ) - continue; - - wirelessNetworkItem = new WirelessNetworkItem (menu, - d->dev, - net, - *it, - false); - int id = menu->insertItem (wirelessNetworkItem, -1, -1); - menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn)); - menu->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate())); - } - - // now add all connections which are not in range to a submenu - TQPopupMenu* popup = new TQPopupMenu(menu); - - uint networkItemsAdded = 0; - for (TQValueList::iterator it = conns.begin(); it != conns.end(); ++it) - { - WirelessNetworkItem* wirelessNetworkItem; - WirelessNetwork net; - - // only show connections which are out of range - if ( findMatchingNetwork(*it, nets, net) ) - continue; - - TDEWiFiConnection* wireless = dynamic_cast(*it); - - if (!wireless) { - continue; - } - - wirelessNetworkItem = new WirelessNetworkItem (menu, - d->dev, - net, - *it, - false); - - int id = popup->insertItem (wirelessNetworkItem, -1, -1); - popup->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate())); - networkItemsAdded += 1; - } - - if (networkItemsAdded) { - menu->insertSeparator(); - menu->insertItem(i18n("Connect to saved network"), popup); - } - -// // List available unsaved networks - TQPopupMenu* newpopup = new TQPopupMenu(menu); - uint newnetworkItemsAdded = 0; - TQValueList newnets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID); - - for (TQValueList::Iterator it = newnets.begin(); it != newnets.end(); ++it) - { - // Only display networks with no existing connnection - if ( findMatchingConnection(*it, conns) != NULL) - continue; - - WirelessNetworkItem* wirelessNetworkItem; - wirelessNetworkItem = new WirelessNetworkItem (menu, - d->dev, - *it, - NULL, - false); - - int id = newpopup->insertItem (wirelessNetworkItem, -1, -1); - newpopup->connectItem(id, this, TQT_SLOT(newConnection())); - - newnetworkItemsAdded += 1; - } - - if (newnetworkItemsAdded) { - menu->insertSeparator(); - menu->insertItem(i18n("Connect to new network"), newpopup); - } - // Signal done with wireless menu - //menu->insertSeparator(); -} - -void WirelessDeviceTray::addMenuItems(KPopupMenu* menu) -{ - // get the currently active connection - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - - // device title - Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wireless", TQIconSet::Automatic)); - menu->insertItem (subhead, -1, -1); - - // bolding subhead instead - //menu->insertSeparator(); - - if (!nm->wiFiEnabled()) - { - // wireless disabled -> do not show any connections - subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled"), SmallIcon("no", TQIconSet::Automatic)); - menu->insertItem(subhead, -1, -1); - } - else if (!nm->wiFiHardwareEnabled()) - { - // wireless disabled -> do not show any connections - subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled by Killswitch"), SmallIcon("no", TQIconSet::Automatic)); - menu->insertItem(subhead, -1, -1); - } - else - { - // networks - addWirelessNetworks(menu); - - // bring the device down - KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); - if (deactivate) { - deactivate->plug(menu); - } - } - menu->insertSeparator(); -} - -void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetworkConnectionStatus states, TQString pixmap) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; - while (flag > 0) { - if (states & flag) { - setPixmapForState(flag, pixmap); - } - flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); - } -} - -void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) -{ - slotCheckActiveAccessPoint(); - - if (state == TDENetworkConnectionStatus::Connected) { - // trigger an update of the connections seen bssids property - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); - if (ap) { - int strength = (ap->signalQuality*100.0); - - if (strength > 80) { - setPixmapForStates(state, "nm_signal_100"); - } - else if (strength > 55) { - setPixmapForStates(state, "nm_signal_75"); - } - else if (strength > 30) { - setPixmapForStates(state, "nm_signal_50"); - } - else if (strength > 5) { - setPixmapForStates(state, "nm_signal_25"); - } - else { - setPixmapForStates(state, "nm_signal_00"); - } - } - } -} - -void WirelessDeviceTray::slotCheckActiveAccessPoint() -{ - // the active AP changed, if a connection is already active we have roamed - // thus add the bssid to the list of seen bssids - - // get the currently active connection - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkConnection* active_conn = NULL; - if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) - && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { - active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); - } - - if (active_conn && deviceConnMan->deviceInformation().statusFlags == TDENetworkConnectionStatus::Connected) { - TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); - if ( activeap != d->activeAccessPoint) { - if (!d->activeAccessPoint.isNull()) { - disconnect( deviceConnMan, TQT_SIGNAL(accessPointStatusChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)), this, TQT_SLOT(apPropertyChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType))); - } - - d->activeAccessPoint = activeap; - if ( d->activeAccessPoint ) { - connect( deviceConnMan, TQT_SIGNAL(accessPointStatusChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)), this, TQT_SLOT(apPropertyChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType))); - TDEWiFiConnection* wireless = dynamic_cast(active_conn); - if (wireless) { - if (!(wireless->heardBSSIDs.contains(d->activeAccessPoint->BSSID))) { - wireless->heardBSSIDs.append(d->activeAccessPoint->BSSID); - } - } - } - } - } -} - -void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) -{ - if (event == TDENetworkAPEventType::SignalStrengthChanged) { - TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); - TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID); - if (ap) { - TQ_UINT32 strength = (ap->signalQuality*100.0); - kdDebug() << k_funcinfo << strength << endl; - TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; - if (strength > 80) { - setPixmapForStates(state, "nm_signal_100"); - } - else if (strength > 55) { - setPixmapForStates(state, "nm_signal_75"); - } - else if (strength > 30) { - setPixmapForStates(state, "nm_signal_50"); - } - else if (strength > 5) { - setPixmapForStates(state, "nm_signal_25"); - } - else { - setPixmapForStates(state, "nm_signal_00"); - } - emit uiUpdated(); - } - } -} - -void WirelessDeviceTray::slotAccessPointAdded(TDENetworkWiFiAPInfo* ap) -{ - KNotifyClient::event( tray()->winId(), "knm-nm-network-found", i18n("KNetworkManager New Wireless Network Found") ); -} - -void WirelessDeviceTray::slotAccessPointRemoved(const TQString&) -{ - KNotifyClient::event( tray()->winId(), "knm-nm-network-gone", i18n("KNetworkManager Wireless Network Disappeared") ); -} - -WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) - : DeviceTrayComponent (dev, parent, name) -{ - d = new WirelessDeviceTrayPrivate(); - d->dev = dev; - - // we want other icons for wireless devices - setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off"); - setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off"); - setPixmapForState(TDENetworkConnectionStatus::UnManaged, "wireless_off"); - setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless"); - setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_signal_50"); - - // get notified when the device state changes - connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); - - // if the active access point changed but not the connection we roamed to a new AP - connect(dev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint())); - - // get notified of all AP changes - connect(dev, TQT_SIGNAL(accessPointAdded(TDENetworkWiFiAPInfo*)), this, TQT_SLOT(slotAccessPointAdded(TDENetworkWiFiAPInfo*))); - connect(dev, TQT_SIGNAL(accessPointRemoved(const TQString&)), this, TQT_SLOT(slotAccessPointRemoved(const TQString&))); -} - -WirelessDeviceTray::~WirelessDeviceTray () -{ - delete d; -} - - -#include "knetworkmanager-wireless_device_tray.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.h b/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.h deleted file mode 100644 index a987b77..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H -#define KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H - -// KNM includes -#include "knetworkmanager.h" -#include "devicetraycomponent.h" -#include "knetworkmanager-wireless_network.h" - -// predefinitions -class WirelessDevice; -class WirelessDeviceTrayPrivate; - -class WirelessDeviceTray : public DeviceTrayComponent -{ - Q_OBJECT - - - public: - WirelessDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); - ~WirelessDeviceTray (); - - void addMenuItems(KPopupMenu* menu); - - protected: - /** - * Reimplementation - */ - TQStringList getToolTipText(); - - public slots: - void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); - void slotCheckActiveAccessPoint(); - void newConnection(); - protected slots: - void apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event); - void slotAccessPointAdded(TDENetworkWiFiAPInfo*); - void slotAccessPointRemoved(const TQString&); - - private: - void addWirelessNetworks(KPopupMenu* menu); - TQValueList getWirelessNetworks(); - TQValueList getWirelessConnections(); - TDEWiFiConnection* findMatchingConnection(const WirelessNetwork& net, const TQValueList& connection); - bool findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList& nets, WirelessNetwork& net); - void setPixmapForStates(TDENetworkConnectionStatus::TDENetworkConnectionStatus states, TQString pixmap); - - WirelessDeviceTrayPrivate* d; - -}; - -#endif /* KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp deleted file mode 100644 index baec85f..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wireless_manager.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// other includes -#include - -// KNM includes -#include "knetworkmanager-wireless_manager.h" - -TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match) -{ - TQValueList nets; - TQValueList aps; - // fetch all APs - aps = WirelessManager::getAccessPoints(dev); - - // now group the APs together according to their security settings - for (TQValueList::Iterator apit = aps.begin(); apit != aps.end(); ++apit) - { - bool found = false; - - // no hidden APs - TDENetworkWiFiAPInfo * ap = *apit; - if ( ap ) { - if (ap->SSID.count() == 0) { - continue; - } - - // check if we have a network matching this AP - for (TQValueList::Iterator netIt = nets.begin(); netIt != nets.end(); ++netIt) { - if ((*netIt).contains(ap) ) { - // we alread have a network where this AP belongs to - found = true; - - // attach this ap to the network - (*netIt).addAP(ap); - - /* // FIXME active? - if (active_ap) - { - // here is the active_ap - if (!(*net).getActive() && ((*ap) == *active_ap)) - (*net).setActive(true); - }*/ - break; - } - } - - if (!found) { - // create a new network-descriptor according to this ap - WirelessNetwork net(match); - net.addAP(ap); - nets.append(net); - } - } - } - return nets; -} - -TQValueList internalGetAccessPoints(TDENetworkDevice* dev) { - TQValueList list; - if (dev) { - TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); - TDENetworkHWNeighbor* neighbor; - TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey(); - for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) { - TDENetworkWiFiAPInfo* apInfo = dynamic_cast(neighbor); - if (!apInfo) { - continue; - } - list.append(apInfo); - } - } - return list; -} - -TQValueList WirelessManager::getAccessPoints(TDENetworkDevice* dev) -{ - // build up AP list depending on one device or on all devices - if (dev) { - return internalGetAccessPoints(dev); - } - else { - TQValueList aps; - TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); - if (hwdevices) { - TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); - for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) { - TDENetworkDevice* wdev = dynamic_cast(*it); - if (wdev) { - aps += internalGetAccessPoints(wdev); - } - } - } - return aps; - } -} - -TQValueList WirelessManager::getWirelessConnections() -{ - TQValueList conns; - - TDEGlobalNetworkManager* nm = KGlobal::networkManager(); - if (nm) { - // get all wireless connections - TDENetworkConnectionList* allconmap = nm->connections(); - for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { - TDEWiFiConnection* wireless_conn = dynamic_cast(*it); - if (!wireless_conn) { - continue; - } - conns.append(wireless_conn); - } - } - - return conns; -} - -TQValueList internalGetAccessPointsWithESSID(TQByteArray essid, TDENetworkDevice* dev) { - TQValueList list; - if (dev) { - TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); - TDENetworkHWNeighbor* neighbor; - TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey(); - for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) { - TDENetworkWiFiAPInfo* apInfo = dynamic_cast(neighbor); - if (!apInfo) { - continue; - } - if (apInfo->SSID == essid) { - list.append(apInfo); - } - } - } - return list; -} - -TQValueList WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev) -{ - // build up AP list depending on one device or on all devices - if (dev) { - return internalGetAccessPointsWithESSID(essid, dev); - } - else { - TQValueList aps; - TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); - if (hwdevices) { - TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); - for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) { - TDENetworkDevice* wdev = dynamic_cast(*it); - if (wdev) { - aps += internalGetAccessPointsWithESSID(essid, wdev); - } - } - } - return aps; - } -} - - diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h b/tdenetworkmanager/src/knetworkmanager-wireless_manager.h deleted file mode 100644 index 75d9f4a..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wireless_manager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_WIRELESS_MANAGER_H -#define KNETWORKMANAGER_WIRELESS_MANAGER_H - -// TQt includes -#include -#include - -// KNM includes -#include "knetworkmanager.h" -#include "knetworkmanager-device_tray.h" -#include "knetworkmanager-wireless_network.h" - -namespace ConnectionSettings -{ - class WirelessConnection; -} - -class WirelessManager -{ - public: - // get all accesspoints from device dev or from all devices if dev is NULL - // and group them together using all properties specified in match - static TQValueList getWirelessNetworks(TDENetworkDevice* dev = 0, TQ_UINT32 match = WirelessNetwork::MATCH_SSID); - - // get all aps from either one device or from all available devices - static TQValueList getAccessPoints(TDENetworkDevice* dev = 0); - - // get a list of all known wireless connections - static TQValueList getWirelessConnections(); - - // get a list of all APs with a specific SSID - static TQValueList getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0); - -}; - -#endif /* KNETWORKMANAGER_WIRELESS_MANAGER_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp deleted file mode 100644 index dd7fc81..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-tray.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Will Stephenson , - * Valentine Sinitsyn - * Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "knetworkmanager-wireless_menuitem.h" -#include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-connection_setting_info.h" - -using namespace ConnectionSettings; - -void WirelessNetworkItem::slotActivate() -{ - - TDENetworkConnectionManager* deviceConnMan = _dev->connectionManager(); - - printf("slotActivate\n\r"); - if (_dev && deviceConnMan) - { - if ( _conn ) - { - kdDebug() << "Activate Connection " << _conn->UUID.ascii() << " on Device " << _dev->deviceNode().ascii() << endl; - TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn->UUID); - if ((result == TDENetworkConnectionStatus::Disconnected) - || (result == TDENetworkConnectionStatus::Invalid)) { - kdDebug() << "ActivateDevice failed" << endl; - } - - } - else - { - // TODO: create new connection based upon the network and show the dialog - printf("New network support not implemented yet\n\r"); - } - } -} - - -TQString WirelessNetworkItem::getDisplayText() -{ - TQString security = ""; - if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) { - security = TQString("(%1/%2)").arg(i18n("WPA")).arg(i18n("RSN")); - } - else if ((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) { - security = TQString("(%1)").arg(i18n("WPA")); - } - else if ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) { - security = TQString("(%2)").arg(i18n("RSN")); - } - - if (_conn && (_conn->friendlyName != _net.getDisplaySsid())) { - return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(_conn->friendlyName).arg(security); - } - else { - return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security); - } -} - -void -WirelessNetworkItem::paint (TQPainter *p, const TQColorGroup &/*cg*/, bool highlighted, bool /*enabled*/, int x, int y, int w, int h) -{ - int spacer = 0; - pbarStrength->setTotalSteps (100); - pbarStrength->setSizePolicy (TQSizePolicy ((TQSizePolicy::SizeType) 0, (TQSizePolicy::SizeType) 0, 0, 0, pbarStrength->sizePolicy ().hasHeightForWidth ())); - pbarStrength->setFixedHeight (_height - 2); - pbarStrength->setProgress (_net.getStrength()); - pbarStrength->setPercentageVisible (false); - - if (highlighted) { - p->setPen(parent->palette ().active ().highlightedText ()); - pbarStrength->setBackgroundMode( TQt::PaletteHighlight, TQt::PaletteHighlight ); - } else { - p->setPen(parent->palette ().active ().text ()); - } - p->drawText (x, y, w, h, AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()); - - if (_net.isEncrypted()) { - TQPixmap pmLock = SmallIcon ("lock", TQIconSet::Automatic); - p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space - pmLock.size ().width () - 6, y + _border, pmLock); - spacer = pmLock.size ().width () + 4; - } - - if (_adhoc) { - TQPixmap pmAdHoc = SmallIcon ("system", TQIconSet::Automatic); - p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space - pmAdHoc.size ().width () - spacer - 6, y + _border, pmAdHoc); - } - - p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space, y +_border, TQPixmap::grabWidget (pbarStrength)); -} - -TQSize -WirelessNetworkItem::sizeHint () -{ - return TQSize (_width, _height); -} - -WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc) - : NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem () -{ - parent = p; - _adhoc = adhoc; - _net = net; - _dev = dev; - _conn = conn; - - pbarStrength = new TQProgressBar (this->parent, "pbarStrength"); - pbarStrength->hide(); - // TODO make all this neat or at least static - /* px between pmLock and pbarStrength */ - _space = 5; - - /* the following code should not be used as teaching material in any kind */ - // set the widget height to that of a small icon - _widgetHeight = SmallIcon (NULL, TQIconSet::Automatic).height (); - // figure out the height of the text - _textHeight = kapp->fontMetrics ().size (AlignLeft | AlignVCenter | DontClip | ShowPrefix, _net.getDisplaySsid()).height (); - // the item is height of the text plus the default frame width - _height = _textHeight + kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); - /* _height needs to be at least the height of a SmallIcon plus a border of one px (top & bottom)*/ - if (_height < _widgetHeight) { - _height = _widgetHeight + 2; - } - - /* border required for pmLock and pbarStrength */ - _border = 1; - if (_border == kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth)) - _border += 2 * kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); - if (_border == 0) - _border ++; - - _width = kapp->fontMetrics().size(AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()).width(); /* essid */ - _width += SmallIcon (NULL, TQIconSet::Automatic).width (); /* pmLock */ - _width += _space; /* pmLock <-> pbarStrength */ - _width += 100; /* pbarStrength */ - _width += _space; /* pbarStrength -> contextMenu */ -} - -WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc) - : NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem () -{ - parent = p; - _adhoc = adhoc; - _net = net; - _dev = dev; - - pbarStrength = new TQProgressBar (this->parent, "pbarStrength"); - pbarStrength->hide(); - // TODO make all this neat or at least static - /* px between pmLock and pbarStrength */ - _space = 5; - - /* the following code should not be used as teaching material in any kind */ - // set the widget height to that of a small icon - _widgetHeight = SmallIcon (NULL, TQIconSet::Automatic).height (); - // figure out the height of the text - _textHeight = kapp->fontMetrics ().size (AlignLeft | AlignVCenter | DontClip | ShowPrefix, _net.getDisplaySsid()).height (); - // the item is height of the text plus the default frame width - _height = _textHeight + kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); - /* _height needs to be at least the height of a SmallIcon plus a border of one px (top & bottom)*/ - if (_height < _widgetHeight) { - _height = _widgetHeight + 2; - } - - /* border required for pmLock and pbarStrength */ - _border = 1; - if (_border == kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth)) - _border += 2 * kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); - if (_border == 0) - _border ++; - - _width = kapp->fontMetrics().size(AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()).width(); /* essid */ - _width += SmallIcon (NULL, TQIconSet::Automatic).width (); /* pmLock */ - _width += _space; /* pmLock <-> pbarStrength */ - _width += 100; /* pbarStrength */ - _width += _space; /* pbarStrength -> contextMenu */ -} - -WirelessNetworkItem::~WirelessNetworkItem () -{ -} - - - -#include "knetworkmanager-wireless_menuitem.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h deleted file mode 100644 index 960258e..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_WIRELESSMENUITEM_H -#define KNETWORKMANAGER_WIRELESSMENUITEM_H - -#include "knetworkmanager-menuitem.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "knetworkmanager-wireless_network.h" - -class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem -{ - Q_OBJECT - - public: - WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc); - WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc); - ~WirelessNetworkItem (); - - TQWidget* parent; - TQProgressBar* pbarStrength; - - void paint (TQPainter*, const TQColorGroup&, bool, bool, int, int, int, int); - TQSize sizeHint (); - - public slots: - void slotActivate(); - - private: - TQString getDisplayText(); - - bool _adhoc; - WirelessNetwork _net; - TDENetworkDevice* _dev; - TDEWiFiConnection* _conn; - - /* menu item */ - int _width; - int _height; - int _border; - - /* elements */ - int _textHeight; - int _widgetHeight; - - int _space; -}; - -#endif /* KNETWORKMANAGER_WIRELESSMENUITEM_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp deleted file mode 100644 index b8328ee..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wireless_network.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// KNM includes -#include "knetworkmanager.h" -#include "knetworkmanager-wireless_network.h" - -// TDE includes -#include - -// TQt includes -#include -#include - -class WirelessNetworkPrivate -{ - public: - WirelessNetworkPrivate() - : active(false) - { - } - - ~WirelessNetworkPrivate() - { - } - - bool active; - - TQ_UINT32 match; - TQValueList aps; -}; - -WirelessNetwork::WirelessNetwork(const WirelessNetwork& other) -{ - d = new WirelessNetworkPrivate(*other.d); -} - -WirelessNetwork::WirelessNetwork(TQ_UINT32 match) -{ - d = new WirelessNetworkPrivate(); - - // which attributes have to match - d->match = match; -} - -WirelessNetwork::~WirelessNetwork() -{ - delete d; -} - -WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other) -{ - if (d) - delete d; - d = new WirelessNetworkPrivate(*other.d); - return *this; -} - -bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) -{ - if ( (d->match & MATCH_SSID) && getSsid() != ap->SSID) { - return false; - } - - // AP matches - return true; -} - -bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) -{ - if ( this->contains( ap ) || d->aps.isEmpty()) { - d->aps.append(ap); - return true; - } - return false; -} - -const TQByteArray WirelessNetwork::getSsid() const -{ - if ( !d->aps.isEmpty() ) { - return (*(d->aps.begin()))->SSID; - } - else { - return TQByteArray(); - } -} - -TQString WirelessNetwork::getDisplaySsid() const -{ - if (!d->aps.isEmpty()) { - return (*(d->aps.begin()))->friendlySSID(); - } - else { - return TQString(); - } -} - -TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const -{ - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { - flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); - flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); - } - return flags; -} - -TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const -{ - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) - { - flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); - } - return flags; -} - -TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const -{ - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) - { - flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); - } - return flags; -} - -bool WirelessNetwork::isEncrypted() const -{ - return (getFlags() & TDENetworkWiFiAPFlags::PrivacySupport); -} - -TQ_UINT8 WirelessNetwork::getStrength() const -{ - TQ_UINT8 strength = 0; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { - if (((*it)->signalQuality*100.0) > strength) { - strength = ((*it)->signalQuality*100.0); - } - } - return strength; -} - -void WirelessNetwork::setActive(bool a) -{ - d->active=a; -} - -bool WirelessNetwork::getActive() const -{ - return d->active; -} - diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_network.h b/tdenetworkmanager/src/knetworkmanager-wireless_network.h deleted file mode 100644 index 979eddc..0000000 --- a/tdenetworkmanager/src/knetworkmanager-wireless_network.h +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-wireless_network.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_WIRELESS_NETWORK_H -#define KNETWORKMANAGER_WIRELESS_NETWORK_H - -#include "knetworkmanager.h" - -#include - -#include -#include - -class KNetworkManager; -class WirelessNetworkPrivate; - -/* - A wireless network represents multiple accesspoints - that share the same essid and security-caps -*/ -class WirelessNetwork -{ - public: - // bitwise encoded enum - // allows the specification on how multiple APs get grouped together - enum MATCH_ATTRIBUTES - { - // only match APs with the same ssid - MATCH_SSID = 1 - }; - - WirelessNetwork(const WirelessNetwork& other); - WirelessNetwork (TQ_UINT32 match = MATCH_SSID); - ~WirelessNetwork (); - - WirelessNetwork& operator= (const WirelessNetwork&); - - // check if the AccessPoint represents the same net - bool contains(const TDENetworkWiFiAPInfo * const); - - // add an AP to the Network - bool addAP(const TDENetworkWiFiAPInfo * const); - - // combined flags of all APs - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const; - - // combined wpa-flags of all APs - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getWpaFlags() const; - - // combined rsn-flags of all APs - TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getRsnFlags() const; - - // ssid of all APs - const TQByteArray getSsid() const; - - TQString getDisplaySsid() const; - bool isEncrypted() const; - - // strength of the best AP - TQ_UINT8 getStrength() const; - - void setActive(bool active); - bool getActive() const; - - bool operator==(const WirelessNetwork&); - - private: - WirelessNetworkPrivate * d; -}; - -#endif /* KNETWORKMANAGER_WIRELESS_NETWORK_H */ diff --git a/tdenetworkmanager/src/knetworkmanager.cpp b/tdenetworkmanager/src/knetworkmanager.cpp deleted file mode 100644 index 5a3d281..0000000 --- a/tdenetworkmanager/src/knetworkmanager.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -// TDE includes -#include -#include -#include -#include - -// KNM includes -#include "knetworkmanager.h" -#include "knetworkmanager-tray.h" - -#include - -// TQt includes -#include -#include - -// KDE includes -#include -#include - -extern TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global; - -class KNetworkManagerPrivate -{ - public: - KNetworkManagerPrivate() {} - ~KNetworkManagerPrivate() {} - static KNetworkManager* _ctx; -}; - -KNetworkManager* KNetworkManagerPrivate::_ctx = NULL; - -KNetworkManager* KNetworkManager::getInstance() -{ - return KNetworkManagerPrivate::_ctx; -} - -void -KNetworkManager::slotShutDown() -{ - // -} - -void KNetworkManager::timerEvent( TQTimerEvent *e ) -{ - Tray* tray = Tray::getInstance(); - tray->slotUpdateDeviceState(nm_device_state_global); -} - -KNetworkManager::KNetworkManager () : KUniqueApplication () -{ - d = new KNetworkManagerPrivate(); - d->_ctx = this; - - // we need to get informed when shutting down - connect(this, TQT_SIGNAL(shutDown()), this, TQT_SLOT(slotShutDown())); - - // create the main-tray-icon - Tray* tray = Tray::getInstance(); - tray->show(); - setMainWidget(tray); -} - -KNetworkManager::~KNetworkManager() -{ - delete d; -} - -#include "knetworkmanager.moc" - diff --git a/tdenetworkmanager/src/knetworkmanager.desktop b/tdenetworkmanager/src/knetworkmanager.desktop deleted file mode 100644 index fc9b45f..0000000 --- a/tdenetworkmanager/src/knetworkmanager.desktop +++ /dev/null @@ -1,47 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=KNetworkManager -Name[bn]=কে-নেটওয়ার্ক-ম্যানেজার -Name[sv]=Knetworkmanager -GenericName=Network Manager -GenericName[bn]=নেটওয়ার্ক ম্যানেজার -GenericName[br]=Merour rouedad -GenericName[da]=Netværkshåndtering -GenericName[de]=Netzwerkverwaltung -GenericName[el]=Διαχειριστής δικτύου -GenericName[es]=Gestor de red -GenericName[et]=Võrguhaldur -GenericName[it]=Gestore di rete -GenericName[ja]=ネットワークマネージャ -GenericName[nl]=Netwerkbeheer -GenericName[pt]=Gestor de Redes -GenericName[sr]=Управник мреже -GenericName[sr@Latn]=Upravnik mreže -GenericName[sv]=Nätverksverktyg -GenericName[tr]=Ağ Yöneticisi -Exec=knetworkmanager -Icon=knetworkmanager -Type=Application -Comment=A TDE frontend for NetworkManager -Comment[bg]=Интерфейс за NetworkManager (TDE) -Comment[bn]=নেটওয়ার্ক-ম্যানেজারের জন্য একটি কেডিই ফ্রন্ট-এন্ড -Comment[ca]=Un frontal del TDE per al NetworkManager -Comment[da]=En TDE-grænseflade for Networkmanager -Comment[de]=Eine TDE-Oberfläche für NetworkManager -Comment[el]=Μια διασύνδεση περιβάλλοντος για το NetworkManager -Comment[es]=Una interfaz de TDE a NetworkManager -Comment[et]=TDE NetworkManageri kasutajaliides -Comment[it]=Un front-end di NetworkManager per TDE -Comment[ja]=NetworkManager の TDE フロントエンド -Comment[nl]=Een TDE-schil voor NetworkManager -Comment[pt]=Uma interface para TDE do NetworkManager -Comment[sr]=TDE програм за NetworkManager -Comment[sr@Latn]=TDE program za NetworkManager -Comment[sv]=Ett gränssnitt till Networkmanager för TDE -Comment[tr]=NetworkManager için bir TDE ön yüzü -X-TDE-autostart-after=panel -X-TDE-StartupNotify=false -X-TDE-UniqueApplet=true -X-DCOP-ServiceType=Unique -X-TDE-autostart-condition=knetworkmanagerrc:General:Autostart:true -Categories=Qt;TDE;Network;Applet; diff --git a/tdenetworkmanager/src/knetworkmanager.h b/tdenetworkmanager/src/knetworkmanager.h deleted file mode 100644 index cb48772..0000000 --- a/tdenetworkmanager/src/knetworkmanager.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005 Novell, Inc. - * - * Author: Timo Hoenig , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_H -#define KNETWORKMANAGER_H - -// KDE includes -#include - -// KNM includes -#include "config.h" - -class KNetworkManagerPrivate; -class Device; - -class KNetworkManager : public KUniqueApplication -{ - Q_OBJECT - - - public: - KNetworkManager (); - ~KNetworkManager (); - - static KNetworkManager* getInstance (void); - - public slots: - void slotShutDown(); - private: - KNetworkManagerPrivate* d; - - protected: - void timerEvent( TQTimerEvent *e ); -}; - -#endif /* KNETWORKMANAGER_H */ diff --git a/tdenetworkmanager/src/knetworkmanager.la.cpp b/tdenetworkmanager/src/knetworkmanager.la.cpp deleted file mode 100644 index 3d480c4..0000000 --- a/tdenetworkmanager/src/knetworkmanager.la.cpp +++ /dev/null @@ -1,2 +0,0 @@ -extern "C" int kdemain(int argc, char* argv[]); -int main(int argc, char* argv[]) { return kdemain(argc,argv); } diff --git a/tdenetworkmanager/src/knetworkmanager_dummy.cpp b/tdenetworkmanager/src/knetworkmanager_dummy.cpp deleted file mode 100644 index efd89d8..0000000 --- a/tdenetworkmanager/src/knetworkmanager_dummy.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include -extern "C" int kdemain(int argc, char* argv[]); -extern "C" KDE_EXPORT int tdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); } diff --git a/tdenetworkmanager/src/knetworkmanager_plugin.desktop b/tdenetworkmanager/src/knetworkmanager_plugin.desktop deleted file mode 100644 index ec85a19..0000000 --- a/tdenetworkmanager/src/knetworkmanager_plugin.desktop +++ /dev/null @@ -1,31 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=ServiceType -X-TDE-ServiceType=KNetworkManager/Plugin -X-TDE-Derived=KPluginInfo -Name=KNetworkManager Plugin -Name[et]=KNetworkManageri plugin -Name[ja]=KNetworkManager プラグイン -Name[sr]=Прикључак KNetworkManager-а -Name[sr@Latn]=Прикључак KNetworkManager-а -Name[sv]=Nätverkshantering insticksprogram -Comment=KNetworkManager Plugin -Comment[bg]=Приставка за KNetworkManager -Comment[bn]=কে-নেটওয়ার্ক-ম্যানেজার প্লাগিন -Comment[br]=Lugent KNetworkManager -Comment[ca]=Connector del KNetworkManager -Comment[da]=Netværkshåndtering-plugin -Comment[de]=KNetworkManager-Modul -Comment[el]=Πρόσθετο του KNetworkManager -Comment[es]=Complemento de KNetworkManager -Comment[et]=KNetworkManageri plugin -Comment[it]=Plugin di KNetworkManager -Comment[ja]=KNetworkManager プラグイン -Comment[nl]=KNetworkManager-plugin -Comment[pt]='Plugin' do KNetworkManager -Comment[sr]=Прикључак KNetworkManager-а -Comment[sr@Latn]=Priključak KNetworkManager-a -Comment[sv]=Nätverkshantering insticksprogram -Comment[tr]=KNetworkManager Eklentisi -Comment[xx]=xxKNetworkManager Pluginxx - diff --git a/tdenetworkmanager/src/knetworkmanager_vpnplugin.desktop b/tdenetworkmanager/src/knetworkmanager_vpnplugin.desktop deleted file mode 100644 index 4cf28dc..0000000 --- a/tdenetworkmanager/src/knetworkmanager_vpnplugin.desktop +++ /dev/null @@ -1,33 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=ServiceType -X-TDE-ServiceType=KNetworkManager/VPNPlugin -X-TDE-Derived=KNetworkManager/Plugin -Name=KNetworkManager VPN Plugin -Name[et]=KNetworkManageri VPN-plugin -Name[ja]=KNetworkManager VPN プラグイン -Name[sr]=Прикључак KNetworkManager-а за VPN -Name[sr@Latn]=Прикључак KNetworkManager-а за VPN -Name[sv]=Nätverkshantering VPN-insticksprogram -Comment=KNetworkManager VPN Plugin -Comment[bg]=VPN приставка за KNetworkManager -Comment[bn]=কে-নেটওয়ার্ক-ম্যানেজার ভিপিএন প্লাগিন -Comment[br]=Lugent VPN evit KNetworkManager -Comment[ca]=Connector VPN del KNetworkManager -Comment[da]=KNetworkManager VPN-plugin -Comment[de]=KNetworkManager-VPN-Modul -Comment[el]=Πρόσθετο VPN του KNetworkManager -Comment[es]=Complemento de VPN de KNetworkManager -Comment[et]=KNetworkManageri VPN-plugin -Comment[it]=Plugin VPN di KNetworkManager -Comment[ja]=KNetworkManager VPN プラグイン -Comment[nl]=KNetworkManager VPN-plugin -Comment[pt]='Plugin' de VPN do KNetworkManager -Comment[sr]=Прикључак KNetworkManager-а за VPN -Comment[sr@Latn]=Priključak KNetworkManager-a za VPN -Comment[sv]=Nätverkshantering VPN-insticksprogram -Comment[tr]=KNetworkManager VPN Eklentisi -Comment[xx]=xxKNetworkManager VPN Pluginxx - -[PropertyDef::X-NetworkManager-Services] -Type=TQString diff --git a/tdenetworkmanager/src/main.cpp b/tdenetworkmanager/src/main.cpp index fd11c11..db41130 100644 --- a/tdenetworkmanager/src/main.cpp +++ b/tdenetworkmanager/src/main.cpp @@ -32,7 +32,7 @@ #include // KNM includes -#include "knetworkmanager.h" +#include "tdenetman.h" static const char* knm_version = I18N_NOOP(KNETWORKMANAGER_VERSION_STRING); diff --git a/tdenetworkmanager/src/settings.kcfgc b/tdenetworkmanager/src/settings.kcfgc index 35e7882..a7ab93a 100644 --- a/tdenetworkmanager/src/settings.kcfgc +++ b/tdenetworkmanager/src/settings.kcfgc @@ -1,5 +1,5 @@ # Code generation options for kconfig_compiler -File=knetworkmanager.kcfg +File=tdenetworkmanager.kcfg ClassName=Settings Singleton=true Mutators=true diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.cpp index 50d7423..e4337a9 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,10 +34,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting.h" -#include "knetworkmanager-connection.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting.h" +#include "tdenetman-connection.h" using namespace ConnectionSettings; @@ -103,4 +103,4 @@ ConnectionSetting::emitValidityChanged() emit validityChanged(); } -#include "knetworkmanager-connection_setting.moc" +#include "tdenetman-connection_setting.moc" diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.h index f189117..08b3ba7 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.cpp index 4904f01..21beba8 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_8021x.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_8021x.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,12 +34,12 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_8021x.h" -#include "knetworkmanager-accesspoint.h" -#include "knetworkmanager-connection_setting_wireless.h" -#include "knetworkmanager-connection.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_8021x.h" +#include "tdenetman-accesspoint.h" +#include "tdenetman-connection_setting_wireless.h" +#include "tdenetman-connection.h" #include "sha1.h" #include "md5.h" diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.h index a5c593e..a86a3c7 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_8021x.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_8021x.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_8021x.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" #include "qbidirectionalmap.h" /* NM */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.cpp index 854590c..5e8886e 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_serial.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_serial.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,10 +34,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_setting_cdma.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection.h" +#include "tdenetman-connection_setting_cdma.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.h index c0825b3..a145988 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_cdma.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_cdma.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_cdma.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.cpp index cd38c3f..b0714e0 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_gsm.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_gsm.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,10 +34,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_setting_gsm.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection.h" +#include "tdenetman-connection_setting_gsm.h" /* network-manager headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.h index ac912ae..9ca5e07 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_gsm.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_gsm.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_gsm.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.cpp index 225d002..a433bf5 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,10 +34,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-accesspoint.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_info.h" +#include "tdenetman-accesspoint.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.h index 705387b..facf9c7 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_info.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.cpp index 15f8978..263f65e 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,9 +34,9 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_ipv4.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_ipv4.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.h index 7788769..506631d 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ipv4.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.cpp index 257a012..513a3ca 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_ppp.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_ppp.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -37,10 +37,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_setting_ppp.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection.h" +#include "tdenetman-connection_setting_ppp.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.h index 9f72e42..ddb966a 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_ppp.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_ppp.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_ppp.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" namespace ConnectionSettings { diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.cpp index 4861e7b..d7245a9 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_serial.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_serial.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,10 +34,10 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-connection_setting_serial.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection.h" +#include "tdenetman-connection_setting_serial.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.h index 40099a7..956e3c2 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_serial.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_serial.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_serial.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.cpp index 22e8b20..4d45f2b 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_vpn.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_vpn.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,9 +34,9 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_vpn.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_vpn.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.h index 6850fc2..e1c1a7a 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_vpn.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-connection_setting_vpn.h - A NetworkManager frontend for KDE + * tdenetman-connection_setting_vpn.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.cpp index 03aa61f..068592c 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -37,10 +37,10 @@ /* NM headers */ #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_wired.h" -#include "knetworkmanager-accesspoint.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_wired.h" +#include "tdenetman-accesspoint.h" using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.h index 9da930e..ba430f0 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wired.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -32,7 +32,7 @@ #include #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" #include namespace ConnectionSettings diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.cpp index 2e1db8e..1076994 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -35,11 +35,11 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_wireless.h" -#include "knetworkmanager-connection_setting_wireless_security.h" -#include "knetworkmanager-accesspoint.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_wireless.h" +#include "tdenetman-connection_setting_wireless_security.h" +#include "tdenetman-accesspoint.h" // the bssid should look like XX:XX:XX:XX:XX:XX where X is a hexadecimal digit #define MAC_ADDRESS_PATTERN "[0-9A-Fa-f]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}" diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.h index acdec94..83acae2 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -32,7 +32,7 @@ #include #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" #include "qbidirectionalmap.h" /* NM headers */ #include diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.cpp index a01f8f6..7b72a83 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.cpp @@ -1,6 +1,6 @@ /************************************************************************** * - * knetworkmanager-connection_setting_wireless_security.cpp - A NetworkManager frontend for KDE + * tdenetman-connection_setting_wireless_security.cpp - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -34,12 +34,12 @@ #include #include -/* knetworkmanager headers */ -#include "knetworkmanager.h" -#include "knetworkmanager-connection_setting_wireless_security.h" -#include "knetworkmanager-accesspoint.h" -#include "knetworkmanager-connection_setting_wireless.h" -#include "knetworkmanager-connection.h" +/* tdenetman headers */ +#include "tdenetman.h" +#include "tdenetman-connection_setting_wireless_security.h" +#include "tdenetman-accesspoint.h" +#include "tdenetman-connection_setting_wireless.h" +#include "tdenetman-connection.h" #include "sha1.h" #include "md5.h" diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.h b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.h index 187fd37..34db7b0 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.h +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_setting_wireless_security.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE + * tdenetman-devicestore_dbus.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -33,7 +33,7 @@ #include -#include "knetworkmanager-connection_setting.h" +#include "tdenetman-connection_setting.h" #include "qbidirectionalmap.h" /* NM */ #include diff --git a/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp b/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp new file mode 100644 index 0000000..cdfa153 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + * + * tdenetman-cellular_device_tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +/// TQt includes +#include // for TQt::WidgetFlags + +// KDE includes +#include +#include +#include + +// KNM includes +#include "tdenetman-cellular_device_tray.h" +#include "tdenetman-menuitem.h" +#include "tdenetman-menu_subhead.h" + +#include "tdenetman-connection_settings_dialog.h" + +using namespace ConnectionSettings; + +class CellularDeviceTrayPrivate +{ + public: + CellularDeviceTrayPrivate() {} + ~CellularDeviceTrayPrivate() {} + + TDENetworkDevice* dev; +}; + +void CellularDeviceTray::newConnection() +{ + // create an appropriate connection + TDENetworkConnection* conn = 0; + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + switch (deviceConnMan->deviceType()) { + case TDENetworkDeviceType::Modem: + conn = new TDEModemConnection(); + break; + + default: + break; + } + + // edit the new connection + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); + dlg->show(); +} + + +void CellularDeviceTray::addMenuItems(KPopupMenu* menu) +{ + // device title + Subhead* subhead = new Subhead (menu, "subhead", d->dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic)); + menu->insertItem (subhead, -1, -1); + + //menu->insertSeparator(); + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) + && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { + active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); + } + + // get all available Connections for cellular devices + + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { + TDEModemConnection* conn = dynamic_cast(*it); + if (!conn) { + continue; + } + + // lets create a nice name for this connection + TQString title = conn->friendlyName; + if (conn->ipConfig.valid) { + title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); + } + + NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); + + int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); + menu->setItemChecked(id, ((*it) == active_conn)); + } + + // bring the device down + KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); + if (deactivate) + deactivate->plug(menu); + + menu->insertSeparator(); +} + +CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) + : DeviceTrayComponent (dev, parent, name) +{ + d = new CellularDeviceTrayPrivate(); + d->dev = dev; + + setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wwan"); +} + +CellularDeviceTray::~CellularDeviceTray () +{ + delete d; +} + + +#include "tdenetman-cellular_device_tray.moc" diff --git a/tdenetworkmanager/src/tdenetman-cellular_device_tray.h b/tdenetworkmanager/src/tdenetman-cellular_device_tray.h new file mode 100644 index 0000000..f6fdf89 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-cellular_device_tray.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H +#define KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H + +// KNM includes +#include "tdenetman.h" +#include "devicetraycomponent.h" + +// predefs +class CellularDevice; +class CellularDeviceTrayPrivate; + +class CellularDeviceTray : public DeviceTrayComponent +{ + Q_OBJECT + + public: + CellularDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); + ~CellularDeviceTray (); + + void addMenuItems(KPopupMenu* menu); + + public slots: + void newConnection(); + + private: + CellularDeviceTrayPrivate* d; +}; + +#endif /* KNETWORKMANAGER_CELLULAR_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/tdenetman-connection_editor.cpp b/tdenetworkmanager/src/tdenetman-connection_editor.cpp new file mode 100644 index 0000000..5c3ea1a --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-connection_editor.cpp @@ -0,0 +1,242 @@ +/*************************************************************************** + * + * tdenetman-connection_editor.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// qt headers +#include +#include +#include +#include +#include +#include +#include +#include + +// kde headers +#include +#include +#include +#include +#include +#include + +// knm headers +#include "tdenetman-connection_editor.h" +#include "tdenetman-connection_settings_dialog.h" + +using namespace ConnectionSettings; + +/* + * ConnectionListViewItem + */ +class ConnectionListViewItem : public KListViewItem +{ + public: + + ConnectionListViewItem(TQListView* parent, TDENetworkConnection* connection) + : KListViewItem(parent) + , _conn(connection) + { + if (_conn) { + setText(0, _conn->friendlyName); + setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(_conn->type())); + // TODO: Move to a Factory + if (_conn->type() == TDENetworkConnectionType::WiredEthernet) { + setPixmap(0, KGlobal::iconLoader()->loadIcon("wired", KIcon::Small)); + } + else if (_conn->type() == TDENetworkConnectionType::WiFi) { + setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small)); + } +// else if (_conn->type() == TDENetworkConnectionType::VPN) { +// setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small)); +// } + else { + setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small)); + } + } + } + + TDENetworkConnection* _conn; +}; + +/* + * Constructor + */ +ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, bool modal, WFlags fl) + : ConnectionEditor(parent, name, modal, fl) +{ + + // TODO: enable combobox if implemented + cboConnectionType->hide(); + + // TODO: Editmode is not ready yet, hide the button +// pbEdit->hide(); + + + pbNew->setIconSet(KGlobal::iconLoader()->loadIcon("add", KIcon::Small)); + pbDelete->setIconSet(KGlobal::iconLoader()->loadIcon("remove", KIcon::Small)); + pbEdit->setIconSet(KGlobal::iconLoader()->loadIcon("edit", KIcon::Small)); + + TQPopupMenu* popup = new TQPopupMenu(pbNew); + // TODO: move to a factory class + popup->insertItem(KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small), i18n("Wireless"), this, TQT_SLOT(slotNewWirelessConnection())); + popup->insertItem(KGlobal::iconLoader()->loadIcon("wired", KIcon::Small), i18n("Wired"), this, TQT_SLOT(slotNewWiredConnection())); + +// if (!VPNManager::getVPNServices().isEmpty()) { +// popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); +// } + + pbNew->setPopup(popup); + + connect(pbClose, TQT_SIGNAL(clicked()), this, TQT_SLOT(close())); + connect(pbDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotRemoveCurrentConnection())); + connect(pbEdit, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotEditCurrentConnection())); + + // show all connections + fillConnectionList(); +} + +/* + * Destructor + */ +ConnectionEditorImpl::~ConnectionEditorImpl() +{ + // remove the popupmenu + if (pbNew->popup()) { + delete pbNew->popup(); + } +} + +/* + * New Wireless connection + */ +void ConnectionEditorImpl::slotNewWirelessConnection() +{ + // create a new wireless connection + slotEditNewConnection(new TDEWiFiConnection()); +} + +/* + * New Wired connection + */ +void ConnectionEditorImpl::slotNewWiredConnection() +{ + slotEditNewConnection(new TDEWiredEthernetConnection()); +} + +/* + * New VPN connection + */ +void ConnectionEditorImpl::slotNewVPNConnection() +{ +// slotEditNewConnection(new TDEVPNConnection()); +} + +/* + * + */ +void ConnectionEditorImpl::slotEditNewConnection(TDENetworkConnection* conn) +{ + // open a dialog for editing the connection + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, this, "connect_something", false, TQt::WDestructiveClose); + connect(dlg, TQT_SIGNAL(connectionSaved()), this, TQT_SLOT(slotRefreshConnectionList())); + dlg->show(); +} + +void ConnectionEditorImpl::slotRefreshConnectionList() +{ + fillConnectionList(); +} + +/* + * Edit the selected connection + */ +void ConnectionEditorImpl::slotEditCurrentConnection() +{ + ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); + if (!item) { + return; + } + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } + + TDENetworkConnection* conn = item->_conn; + + // we need the secrets for editing + nm->loadConnectionSecrets(conn->UUID); + + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, this, "connect_something", false, TQt::WDestructiveClose); + dlg->show(); + + // save all connections (if not done already) + nm->saveConnection(conn); +} + + +/* + * Delete the selected connection + */ +void ConnectionEditorImpl::slotRemoveCurrentConnection() +{ + ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); + if (!item) { + return; + } + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } + + TDENetworkConnection* conn = item->_conn; + + lvConnections->takeItem(item); + delete item; + + nm->deleteConnection(conn->UUID); +} + +/* + * Fill the connection list + */ +void ConnectionEditorImpl::fillConnectionList() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } + + lvConnections->clear(); + + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { + TDENetworkConnection* conn = *it; + new ConnectionListViewItem(lvConnections, conn); + } +} + +#include "tdenetman-connection_editor.moc" diff --git a/tdenetworkmanager/src/tdenetman-connection_editor.h b/tdenetworkmanager/src/tdenetman-connection_editor.h new file mode 100644 index 0000000..8026b8d --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-connection_editor.h @@ -0,0 +1,68 @@ +/*************************************************************************** + * + * tdenetman-connection_editor.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_CONNECTION_EDITOR_H +#define KNETWORKMANAGER_CONNECTION_EDITOR_H + +// tqt headers +#include + +// tqt autogenerated headers +#include "connection_editor.h" + +// TDE headers +#include +#include + +class TQWidget; +class Device; + +namespace ConnectionSettings +{ + class WidgetInterface; + class ConnectionSetting; +} + +class ConnectionEditorImpl : public ConnectionEditor +{ + Q_OBJECT + + public: + ConnectionEditorImpl(TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); + ~ConnectionEditorImpl(); + + protected slots: + void slotRemoveCurrentConnection(); + void slotEditCurrentConnection(); + void slotNewWirelessConnection(); + void slotNewWiredConnection(); + void slotEditNewConnection(TDENetworkConnection* conn); + void slotRefreshConnectionList(); + void slotNewVPNConnection(); + + private: + void fillConnectionList(); +}; + +#endif /* KNETWORKMANAGER_CONNECTION_EDITOR_H*/ diff --git a/tdenetworkmanager/src/tdenetman-device_tray.cpp b/tdenetworkmanager/src/tdenetman-device_tray.cpp new file mode 100644 index 0000000..d9bedc0 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-device_tray.cpp @@ -0,0 +1,379 @@ +/*************************************************************************** + * + * tdenetman-device_tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +class WirelessDialog; + +// TQt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TDE includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// KNM includes +#include "tdenetman-device_tray.h" +#include "tdenetman-menu_subhead.h" +#include "tdenetman-connection_settings_dialog.h" + +using namespace ConnectionSettings; + +class DeviceTrayPrivate +{ + public: + + DeviceTrayPrivate() + : dev(NULL) + { + tooltips[TDENetworkConnectionStatus::Invalid] = i18n("Unknown"); + tooltips[TDENetworkConnectionStatus::LinkUnavailable] = i18n("Down"); + tooltips[TDENetworkConnectionStatus::UnManaged] = i18n("Unmanaged"); + tooltips[TDENetworkConnectionStatus::Disconnected] = i18n("Disconnected"); + tooltips[TDENetworkConnectionStatus::EstablishingLink] = i18n("Preparing"); + tooltips[TDENetworkConnectionStatus::ConfiguringProtocols] = i18n("Configuration"); + tooltips[TDENetworkConnectionStatus::NeedAuthorization] = i18n("Awaiting authentication"); + tooltips[TDENetworkConnectionStatus::VerifyingProtocols] = i18n("IP configuration"); + tooltips[TDENetworkConnectionStatus::Connected] = i18n("Activated"); + tooltips[TDENetworkConnectionStatus::Failed] = i18n("Failed"); + } + + ~DeviceTrayPrivate() {} + + TDENetworkDevice* dev; + TQMap movies; + TQMap pixmaps; + TQMap tooltips; + + TQPixmap pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + TQMovie movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); +}; + +TQPixmap DeviceTrayPrivate::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; + while (flag > 0) { + if (state & flag) { + if (pixmaps.contains(flag)) { + return pixmaps[flag]; + } + } + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); + } + return TQPixmap(); +} + +TQMovie DeviceTrayPrivate::movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; + while (flag > 0) { + if (state & flag) { + if (movies.contains(flag)) { + return movies[flag]; + } + } + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); + } + return TQMovie(); +} + +TQString DeviceTrayPrivate::tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; + while (flag > 0) { + if (state & flag) { + if (tooltips.contains(flag)) { + return tooltips[flag]; + } + } + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); + } + return TQString::null; +} + +TDENetworkDevice* DeviceTray::getDevice() const +{ + return d->dev; +} + +TQString DeviceTray::getTooltipText() +{ + + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; + TQString tooltip = TQString(); + + if (!d->tooltipForConnState(state).isEmpty()) { + tooltip += i18n("State: %1").arg(d->tooltipForConnState(state)); + } + + return tooltip; +} + +void DeviceTray::enterEvent (TQEvent* /*e*/) +{ + // show tooltip + TQToolTip::remove (this); + TQString tooltip = getTooltipText(); + + if (!tooltip.isEmpty()) { + TQToolTip::add (this, tooltip); + } +} + + +void DeviceTray::setPixmap(const TQPixmap& pixmap) +{ + /* + int oldPixmapWidth = pixmap.size().width(); + int oldPixmapHeight = pixmap.size().height(); + + // we want to show the interface name + TQString iface = d->dev->getInterface(); + + // grab a font + TQFont iface_font = KGlobalSettings::generalFont(); +// iface_font.setBold(true); + + // resize the font to fit the icon's size + float fontSize = iface_font.pointSizeFloat(); + TQFontMetrics qfm(iface_font); + int height = qfm.height(); + int width = qfm.width(iface); + float factor = 1.0f; + float factor2 = 1.0f; + + if (height > (oldPixmapHeight / 2.0f)) + factor = float(oldPixmapHeight / 2.0f) / float(height); + + if (width > (oldPixmapWidth / 1.1f)) + factor2 = float(oldPixmapWidth / 1.1f) / float(width); + + fontSize *= (factor2 < factor) ? factor2 : factor; + + iface_font.setPointSizeFloat( fontSize); + + // draw the text to a bitmap and put is as an overlay on top of the pixmap + TQPixmap iface_pixmap(oldPixmapWidth, oldPixmapHeight); + iface_pixmap.fill(TQt::white); + TQPainter p(&iface_pixmap); + p.setFont(iface_font); + p.setPen(TQt::blue); + p.drawText(iface_pixmap.rect(), TQt::AlignHCenter | TQt::AlignBottom, iface); + iface_pixmap.setMask(iface_pixmap.createHeuristicMask()); + TQImage iface_image = iface_pixmap.convertToImage(); + + TQImage pixmap_with_overlay = pixmap.convertToImage(); + KIconEffect::overlay(pixmap_with_overlay, iface_image); + + TQPixmap new_pixmap; + new_pixmap.convertFromImage(pixmap_with_overlay); + // call base-class setPixmap + KSystemTray::setPixmap(new_pixmap); +*/ + KSystemTray::setPixmap(pixmap); +} + +void DeviceTray::contextMenuAboutToShow (KPopupMenu* menu) +{ + menu->clear(); + + // insert title + menu->insertTitle (SmallIcon ("tdenetman", TQIconSet::Automatic), "KNetworkManager", -1, -1); + + // let the specific device_tray add its items + addMenuItems(menu); + + // quit + menu->insertSeparator (); + KAction* quitAction = actionCollection ()->action (KStdAction::name (KStdAction::Quit)); + if (quitAction) { + quitAction->plug (menu); + } +} + +void DeviceTray::resizeEvent ( TQResizeEvent * ) +{ + // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes + loadIcons(); + updateTrayIcon(m_currentIconState); +} + +void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQMovie movie) +{ + d->movies[state] = movie; + slotUpdateDeviceState(); +} + +void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQPixmap pixmap) +{ + d->pixmaps[state] = pixmap; + slotUpdateDeviceState(); +} + +void DeviceTray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + // stop the old movie to avoid unnecessary wakups + if (movie()) { + movie()->pause(); + } + + if (!d->movieForConnState(state).isNull()) { + if (m_currentIconState != state) { + // Clear the icon pixmap as the movie may be a different size + TQPixmap nullPixmap; + setPixmap(nullPixmap); + } + + // animation desired + int frame = -1; + if (movie()) { + frame = movie()->frameNumber(); + } + + // set the movie + setMovie(d->movieForConnState(state)); + + // start at the same frame as the movie before + if (frame > 0) + movie()->step(frame); + + // start the animation + movie()->unpause(); + } + else if (!d->pixmapForConnState(state).isNull()) { + setPixmap(d->pixmapForConnState(state)); + } + else { + setPixmap(loadSizedIcon("KNetworkManager", width())); + } + + m_currentIconState = state; +} + +void DeviceTray::updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + // allow device deactivation only when device is activated + KAction* deactivate = actionCollection()->action("deactivate_device"); + if (deactivate) + deactivate->setEnabled( (state & TDENetworkConnectionStatus::Connected || + state & TDENetworkConnectionStatus::VerifyingProtocols || + state & TDENetworkConnectionStatus::EstablishingLink || + state & TDENetworkConnectionStatus::ConfiguringProtocols || + state & TDENetworkConnectionStatus::NeedAuthorization) ); +} + +void DeviceTray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + if (!(state & TDENetworkConnectionStatus::Connected)) { + return; + } +} + +void DeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + updateTrayIcon(state); + updateActions(state); + updateActiveConnection(state); +} + +void DeviceTray::slotUpdateDeviceState() +{ + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags); +} + +void DeviceTray::loadIcons() { + d->pixmaps[TDENetworkConnectionStatus::Invalid] = loadSizedIcon("nm_no_connection", width()); + d->pixmaps[TDENetworkConnectionStatus::UnManaged] = loadSizedIcon("nm_no_connection", width()); + d->pixmaps[TDENetworkConnectionStatus::LinkUnavailable] = loadSizedIcon("nm_no_connection", width()); + d->pixmaps[TDENetworkConnectionStatus::Disconnected] = loadSizedIcon("nm_no_connection", width()); + + d->movies[TDENetworkConnectionStatus::EstablishingLink] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage01_connecting", KIcon::Panel)); + d->movies[TDENetworkConnectionStatus::EstablishingLink].pause(); + + d->movies[TDENetworkConnectionStatus::ConfiguringProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage02_connecting", KIcon::Panel)); + d->movies[TDENetworkConnectionStatus::ConfiguringProtocols].pause(); + + d->movies[TDENetworkConnectionStatus::VerifyingProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage03_connecting", KIcon::Panel)); + d->movies[TDENetworkConnectionStatus::VerifyingProtocols].pause(); + + d->movies[TDENetworkConnectionStatus::NeedAuthorization] = d->movies[TDENetworkConnectionStatus::ConfiguringProtocols]; + d->movies[TDENetworkConnectionStatus::NeedAuthorization].pause(); + + d->pixmaps[TDENetworkConnectionStatus::Connected] = loadSizedIcon("ok", width()); + + d->pixmaps[TDENetworkConnectionStatus::Failed] = loadSizedIcon("nm_no_connection", width()); +} + +DeviceTray::DeviceTray (TDENetworkDevice* dev) : KSystemTray () +{ + d = new DeviceTrayPrivate(); + d->dev = dev; + + m_currentIconState = TDENetworkConnectionStatus::Invalid; + loadIcons(); + + // get notified when the device state changes + connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); + + setMouseTracking (true); + + // defer the initial call to slotUpdateDeviceState as it will crash knm when called directly from here + // virtual method calls are not allowed in constructor + TQTimer::singleShot(0, this, TQT_SLOT(slotUpdateDeviceState())); + + // Actions used for plugging into the menu + new KAction (i18n ("Deactivate connection..."), + SmallIcon ("no", TQIconSet::Automatic), 0, + dev, TQT_SLOT (slotDeactivate()), actionCollection (), "deactivate_device"); +} + +DeviceTray::~DeviceTray () +{ + delete d; +} + + +#include "tdenetman-device_tray.moc" diff --git a/tdenetworkmanager/src/tdenetman-device_tray.h b/tdenetworkmanager/src/tdenetman-device_tray.h new file mode 100644 index 0000000..82f7732 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-device_tray.h @@ -0,0 +1,88 @@ +/*************************************************************************** + * + * tdenetman-device_tray.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_DEVICE_TRAY_H +#define KNETWORKMANAGER_DEVICE_TRAY_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "tdenetman.h" + +class DeviceTrayPrivate; + +class DeviceTray : public KSystemTray +{ + Q_OBJECT + + + public: + DeviceTray (TDENetworkDevice*); + ~DeviceTray (); + + void contextMenuAboutToShow (KPopupMenu* menu); + virtual void addMenuItems(KPopupMenu* menu) = 0; + TDENetworkDevice* getDevice() const; + + protected: + void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQMovie); + void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQPixmap); + void resizeEvent ( TQResizeEvent * ); + + virtual TQString getTooltipText(); + + public slots: + void setPixmap(const TQPixmap &); + void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void slotUpdateDeviceState(); + + private: + void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void enterEvent (TQEvent*); + void loadIcons(); + + DeviceTrayPrivate* d; + TDENetworkConnectionStatus::TDENetworkConnectionStatus m_currentIconState; +}; + +#endif /* KNETWORKMANAGER_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/tdenetman-menu_subhead.cpp b/tdenetworkmanager/src/tdenetman-menu_subhead.cpp new file mode 100644 index 0000000..3821b80 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-menu_subhead.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * + * tdenetman-tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Valentine Sinitsyn + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +class WirelessDialog; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tdenetman-menu_subhead.h" + +Subhead::Subhead (TQWidget* parent, const char* name, const TQString & caption, const TQPixmap icon) + : TQWidget (parent, name) +{ + TQBoxLayout* l = new TQHBoxLayout (this); + TQLabel* lbl_icon = new TQLabel (NULL, this); + TQLabel* lbl_caption = new TQLabel (caption, this); + TQSpacerItem* sp_item = new TQSpacerItem (20, 10); + TQFont font; + font.setBold(true); + lbl_caption->setFont(font); + + lbl_icon->setPixmap (icon); + + l->addWidget (lbl_icon); + l->addWidget (lbl_caption); + l->addItem (sp_item); + l->activate (); +} + +Subhead::~Subhead() +{ + +} + diff --git a/tdenetworkmanager/src/tdenetman-menu_subhead.h b/tdenetworkmanager/src/tdenetman-menu_subhead.h new file mode 100644 index 0000000..a142d3e --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-menu_subhead.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_MENU_SUBHEAD_H +#define KNETWORKMANAGER_MENU_SUBHEAD_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "tdenetman.h" + +class Subhead : public TQWidget +{ + public: + Subhead (TQWidget*, const char *, const TQString &, const TQPixmap); + ~Subhead (); +}; + +#endif /* KNETWORKMANAGER_MENU_SUBHEAD_H */ diff --git a/tdenetworkmanager/src/tdenetman-menuitem.cpp b/tdenetworkmanager/src/tdenetman-menuitem.cpp new file mode 100644 index 0000000..e59102f --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-menuitem.cpp @@ -0,0 +1,123 @@ +/*************************************************************************** + * + * tdenetman-menuitem.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006, 2008 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Valentine Sinitsyn + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include "tdenetman-menuitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ConnectionSettings; + +class NetworkMenuItemPrivate +{ + public: + NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection) + : dev(device), conn(connection) + { + + } + ~NetworkMenuItemPrivate() {} + + TQGuardedPtr dev; + TQGuardedPtr conn; +}; + +void NetworkMenuItem::slotActivate() +{ + kdDebug() << "NetworkMenuItem::slotActivate()" << endl; + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + if (d->dev && d->conn) + { + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + if (deviceConnMan) + { + kdDebug() << "Activate Connection " << d->conn->UUID.ascii() << " on Device " << d->dev->deviceNode().ascii() << endl; + printf("Activate Connection %s on Device %s\n\r", d->conn->UUID.ascii(), d->dev->deviceNode().ascii()); + + TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(d->conn->UUID); + if ((result == TDENetworkConnectionStatus::Disconnected) + || (result == TDENetworkConnectionStatus::Invalid)) { + // + } + else { + kdDebug() << "ActivateDevice failed" << endl; + } + } + } + else if (d->conn) + { + // no device given, just take the default device + printf("Activate Connection %s on default device\n\r", d->conn->UUID.ascii()); + + TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(d->conn->UUID); + if ((result == TDENetworkConnectionStatus::Disconnected) + || (result == TDENetworkConnectionStatus::Invalid)) { + // + } + else { + kdDebug() << "ActivateConnection failed" << endl; + } + } + else + kdDebug() << "Device or Connection invalid" << endl; +} + +NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name) + : TQObject(parent, name) +{ + d = new NetworkMenuItemPrivate(dev, conn); +} + +NetworkMenuItem::~NetworkMenuItem () +{ + delete d; +} + + + +#include "tdenetman-menuitem.moc" diff --git a/tdenetworkmanager/src/tdenetman-menuitem.h b/tdenetworkmanager/src/tdenetman-menuitem.h new file mode 100644 index 0000000..be1584e --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-menuitem.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * + * tdenetman-menuitem.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006, 2008 Novell, Inc. + * + * Author: Helmut Schaa , + * Will Stephenson , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_MENUITEM_H +#define KNETWORKMANAGER_MENUITEM_H + +#include + +#include +#include + +class Device; +class NetworkMenuItemPrivate; + +namespace ConnectionSettings +{ + class Connection; +} + +class NetworkMenuItem : public TQObject +{ + Q_OBJECT + + public: + NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent = 0, const char* name = 0); + ~NetworkMenuItem (); + + public slots: + void slotActivate(); + + private: + NetworkMenuItemPrivate* d; +}; + +#endif /* KNETWORKMANAGER_MENUITEM_H */ diff --git a/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.cpp b/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.cpp new file mode 100644 index 0000000..756f0cc --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * + * tdenetman-device.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// KDE includes +#include + +// TQtDBus includes +#include +#include +#include +#include +#include +#include + +// NM includes +#include +#include + +// KNM includes +#include "tdenetman.h" +#include "tdenetman-nm_vpn_proxy.h" +#include "tdenetman-device.h" +#include "tdenetman-devicestore.h" +//#include "tdenetman-connection.h" +#include "tdenetman-connection_store.h" +#include "dbus/vpnconnectionproxy.h" + +class NMVPNProxyPrivate +{ + public: + NMVPNProxyPrivate() + {} + + static NMVPNProxy* nm; +}; + +NMVPNProxy* NMVPNProxyPrivate::nm = NULL; + +NMVPNProxy::NMVPNProxy() + : NetworkManagerVPNProxy(NM_DBUS_SERVICE, NM_DBUS_PATH_VPN_CONNECTION) +{ + d = new NMVPNProxyPrivate(); + NetworkManagerVPNProxy::setConnection(TQDBusConnection::systemBus()); +} + +NMVPNProxy::~NMVPNProxy() +{ + delete d; +} + +NMVPNProxy* NMVPNProxy::getInstance() +{ + if (NMVPNProxyPrivate::nm) + return NMVPNProxyPrivate::nm; + return (NMVPNProxyPrivate::nm = new NMVPNProxy()); +} + + +#include "tdenetman-nm_vpn_proxy.moc" diff --git a/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.h b/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.h new file mode 100644 index 0000000..b7d5ca7 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-nm_vpn_proxy.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * + * tdenetman-nm_proxy.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_NMVPNPROXY_H +#define KNETWORKMANAGER_NMVPNPROXY_H + +#include "dbus/networkmanagervpnproxy.h" + +namespace ConnectionSettings +{ + class Connection; +} +class Device; +class NMVPNProxyPrivate; + +class NMVPNProxy : public DBus::NetworkManagerVPNProxy +{ + Q_OBJECT + + public: + static NMVPNProxy* getInstance(); + + protected: + NMVPNProxy (); + ~NMVPNProxy (); + + private: + NMVPNProxyPrivate * d; +}; + +#endif /* KNETWORKMANAGER_NMVPNPROXY_H */ diff --git a/tdenetworkmanager/src/tdenetman-plugin.cpp b/tdenetworkmanager/src/tdenetman-plugin.cpp new file mode 100644 index 0000000..017db8d --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-plugin.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * + * tdenetman-plugin.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include "tdenetman-plugin.h" + +Plugin::Plugin(TQObject* parent, const char* name, const TQStringList& ) + : TQObject(parent, name) +{ + +} + +Plugin::~Plugin() +{ + +} + +#include "tdenetman-plugin.moc" diff --git a/tdenetworkmanager/src/tdenetman-plugin.h b/tdenetworkmanager/src/tdenetman-plugin.h new file mode 100644 index 0000000..7bd2e99 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-plugin.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * + * tdenetman-plugin.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_PLUGIN_H +#define KNETWORKMANAGER_PLUGIN_H + +#include + +class Plugin : public TQObject +{ + Q_OBJECT + + public: + Plugin(TQObject*, const char*, const TQStringList&); + ~Plugin(); +}; + +#endif /* KNETWORKMANAGER_PLUGIN_H */ diff --git a/tdenetworkmanager/src/tdenetman-pluginmanager.cpp b/tdenetworkmanager/src/tdenetman-pluginmanager.cpp new file mode 100644 index 0000000..3111385 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-pluginmanager.cpp @@ -0,0 +1,184 @@ +/*************************************************************************** + * + * tdenetman-pluginmanager.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include + +#include "tdenetman-pluginmanager.h" + +PluginManager* PluginManager::_instance; + +PluginManager* PluginManager::getInstance() +{ + if (_instance) + return _instance; + return new PluginManager(TQT_TQOBJECT(KNetworkManager::getInstance()), "pluginmanager"); +} + +PluginManager::PluginManager(TQObject* parent, const char* name) + : TQObject(parent, name) +{ + // get list of available plugins + this->_plugins = KPluginInfo::fromServices( KTrader::self()->query( TQString::fromLatin1( "KNetworkManager/Plugin" ))); + + // a bit debug output + for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) + kdDebug() << k_funcinfo << TQString("Found Plugin '%1'").arg((*it)->pluginName()) << endl; +} + +PluginManager::~PluginManager() +{ + // delete all loaded plugins + while(!_loadedPlugins.empty()) + { + PluginMap::Iterator it = _loadedPlugins.begin(); + _loadedPlugins.remove(it); + } + + // delete all available plugininfos + while(!_plugins.empty()) + { + TQValueList::Iterator it = _plugins.begin(); + delete *it; + _plugins.remove(it); + } +} + +TQStringList PluginManager::getPluginList(const TQString& serviceType, const TQString& property, const TQString& value) const +{ + TQStringList ret; + // find a suitable plugin + for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) + { + if ((*it)->service()->serviceTypes().contains(serviceType) > 0) + if ((*it)->property(property).toString().contains(value)) + ret.append( (*it)->pluginName() ); + } + return ret; +} + +Plugin* PluginManager::getPlugin(const TQString& pluginID) +{ + KPluginInfo* info = infoForPluginID(pluginID); + if (_loadedPlugins.contains(info)) + { + return _loadedPlugins[info]; + } + else + { + return loadPlugin(pluginID); + } + return NULL; +} + +const KPluginInfo* PluginManager::getPluginInfo(const TQString& pluginID) +{ + return infoForPluginID(pluginID); +} + +const KPluginInfo* PluginManager::getPluginInfo(const Plugin* plugin) +{ + for(PluginMap::ConstIterator it = _loadedPlugins.begin(); it != _loadedPlugins.end(); ++it) + { + if (it.data() == plugin) + return it.key(); + } + return NULL; +} + +void PluginManager::loadAllPlugins() +{ + // iterate over all plugins + for(TQValueList::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) + { + // load Plugin + loadPlugin((*it)->pluginName()); + } +} + + +Plugin* PluginManager::loadPlugin(const TQString& pluginID) +{ + // try to load Plugin + int error = 0; + KPluginInfo* info = infoForPluginID(pluginID); + Plugin *plugin = KParts::ComponentFactory::createInstanceFromQuery( TQString::fromLatin1( "KNetworkManager/Plugin" ), + TQString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginID ), this, 0, TQStringList(), &error ); + + // plugin loaded? + if (plugin) + { + kdDebug() << k_funcinfo << TQString(i18n("successfully loaded plugin '%1'")).arg(info->pluginName()) << endl; + _loadedPlugins.insert(info, plugin); + } + else + { + // error + switch( error ) + { + case KParts::ComponentFactory::ErrNoServiceFound: + kdDebug( ) << k_funcinfo << "No service implementing the given mimetype " + << "and fullfilling the given constraint expression can be found." << endl; + break; + + case KParts::ComponentFactory::ErrServiceProvidesNoLibrary: + kdDebug( ) << "the specified service provides no shared library." << endl; + break; + + case KParts::ComponentFactory::ErrNoLibrary: + kdDebug( ) << "the specified library could not be loaded." << endl; + break; + + case KParts::ComponentFactory::ErrNoFactory: + kdDebug( ) << "the library does not export a factory for creating components." << endl; + break; + + case KParts::ComponentFactory::ErrNoComponent: + kdDebug( ) << "the factory does not support creating components of the specified type." << endl; + break; + } + + kdDebug() << k_funcinfo << "Loading plugin '" << pluginID << "' failed, KLibLoader reported error: '" << endl + << KLibLoader::self()->lastErrorMessage() << "'" << endl; + + } + + return plugin; +} + +KPluginInfo * PluginManager::infoForPluginID( const TQString& pluginID ) const +{ + TQValueList::ConstIterator it; + for ( it = this->_plugins.begin(); it != this->_plugins.end(); ++it ) + { + if ( ( *it )->pluginName() == pluginID ) + return *it; + } + + return 0L; +} + +#include "tdenetman-pluginmanager.moc" diff --git a/tdenetworkmanager/src/tdenetman-pluginmanager.h b/tdenetworkmanager/src/tdenetman-pluginmanager.h new file mode 100644 index 0000000..d36ce10 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-pluginmanager.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * + * tdenetman-pluginmanager.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_PLUGINMANAGER_H +#define KNETWORKMANAGER_PLUGINMANAGER_H + +#include +#include +#include + +#include "tdenetman-plugin.h" +#include "tdenetman.h" + +class KPluginInfo; + +typedef TQMap PluginMap; + +class PluginManager : public TQObject +{ + Q_OBJECT + + public: + PluginManager(TQObject*, const char*); + ~PluginManager(); + + TQStringList getPluginList(const TQString&, const TQString&, const TQString&) const; + Plugin* getPlugin(const TQString&); + const KPluginInfo* getPluginInfo(const TQString&); + const KPluginInfo* getPluginInfo(const Plugin*); + + static PluginManager* getInstance (void); + + public slots: + void loadAllPlugins(); + + private: + TQValueList _plugins; + PluginMap _loadedPlugins; + + Plugin* loadPlugin(const TQString& pluginID); + KPluginInfo* infoForPluginID(const TQString& pluginID) const; + + static PluginManager* _instance; +}; + +#endif /* KNETWORKMANAGER_PLUGINMANAGER_H */ diff --git a/tdenetworkmanager/src/tdenetman-tray.cpp b/tdenetworkmanager/src/tdenetman-tray.cpp new file mode 100644 index 0000000..36407e8 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-tray.cpp @@ -0,0 +1,766 @@ +/*************************************************************************** + * + * tdenetman-tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Valentine Sinitsyn + * Helmut Schaa , + * Alexander Naumov , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "devicetraycomponent.h" +#include "tdenetman-tray.h" + +#include "tdenetman-connection_settings_dialog.h" +#include "tdenetman-connection_editor.h" +#include "tdenetman-menu_subhead.h" + +#include "tdenetman-wired_device_tray.h" +#include "tdenetman-wireless_device_tray.h" +#include "tdenetman-cellular_device_tray.h" + +#include + +TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global; + +NewSecretsDialog::NewSecretsDialog(TDENetworkConnection *connection, TQWidget * parent, const char * name, bool modal, TQt::WFlags f) + : TQDialog(parent, name, modal, f) +{ + _connection = connection; + init(); +} + +NewSecretsDialog::~NewSecretsDialog () +{ + +} + +void NewSecretsDialog::slotDialogEdit() +{ + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(_connection, false, Tray::getInstance(), "Edit connection"); + dlg->show(); + close(); +} + +void NewSecretsDialog::reject() +{ + TQDialog::reject(); +} + +void NewSecretsDialog::init() +{ + TDENetworkConnection* conn = _connection; + + // if we do not have a connection bail out + if (!conn) + { + reject(); + return; + } + + // show a message to the user that the connection failed + // and allow edit or cancel + + TQLabel* label = new TQLabel(tqtr(" The connection %1 could not be established ").arg(conn->friendlyName), this); + TQPushButton* buttonEdit = new TQPushButton(tr("&Edit"), this); + TQPushButton* buttonCancel = new TQPushButton(tr("&Cancel"), this); + + TQHBoxLayout *topLeftLayout = new TQHBoxLayout(); + topLeftLayout->addWidget(buttonEdit); + topLeftLayout->addWidget(buttonCancel); + + TQVBoxLayout *mainLayout = new TQVBoxLayout(this); + mainLayout->setMargin(15); + mainLayout->setSpacing(10); + mainLayout->addWidget(label); + mainLayout->addLayout(topLeftLayout); + + connect(buttonEdit, TQT_SIGNAL(clicked()), TQT_SLOT(slotDialogEdit())); + connect(buttonCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(close())); +} + +class TrayPrivate +{ + public: + TrayPrivate(TQObject* parent) + : foregroundTrayComponent(0) + , signalMapper(parent, "signal_mapper") + , current_idx(0) + {} + ~TrayPrivate() {} + + static Tray* tray; + TQValueList trayComponents; + DeviceTrayComponent * foregroundTrayComponent; + TQSignalMapper signalMapper; + TQMap act_conn_map; + int current_idx; +}; + +Tray* TrayPrivate::tray = NULL; + +Tray* Tray::getInstance() +{ + if (TrayPrivate::tray) + return TrayPrivate::tray; + else return (TrayPrivate::tray = new Tray()); +} + +void Tray::slotEditConnections() +{ + ConnectionEditorImpl* dlg = new ConnectionEditorImpl(this); + dlg->show(); +} + + +void Tray::slotEnableWireless() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) return; + nm->enableWiFi(true); +} + +void Tray::slotDisableWireless() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) return; + nm->enableWiFi(false); +} + +void Tray::slotOfflineMode() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) return; + nm->enableNetworking(false); +} + +void Tray::slotOnlineMode() +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) return; + nm->enableNetworking(true); +} + +void Tray::contextMenuAboutToShow (KPopupMenu* menu) +{ + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + // clear menu + menu->clear(); + + if (!(nm->backendStatus() & TDENetworkGlobalManagerFlags::BackendUnavailable)) { + // actions for each Device + for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) { + (*it)->addMenuItems(menu); + } + + // Submenu title + Subhead* subhead = new Subhead (menu, "subhead", TQString("Connection Management"), SmallIcon("tdenetworkmanager_disabled", TQIconSet::Automatic)); + menu->insertItem (subhead, -1, -1); + + // New connection + KAction * newConnAction = 0; + int devices = d->trayComponents.count(); + if ( devices > 1 ) { + newConnAction = actionCollection ()->action ("new_connection_menu"); + KActionMenu* newConnActionMenu = static_cast(newConnAction); + newConnActionMenu->popupMenu()->clear(); + TQValueList::Iterator it; + for (it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) { + DeviceTrayComponent* dev_comp = dynamic_cast (*it); + KAction * deviceNewConnAction = 0; + if (dev_comp) { + TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); + TQString menuCaption = TQString("%1").arg(dev_comp->device()->deviceNode()); + if (menuCaption.contains("eth", FALSE) > 0) { + menuCaption = menuCaption.insert(0, "Wired Connection ("); + } + else if (menuCaption.contains("wlan", FALSE) > 0) { + menuCaption = menuCaption.insert(0, "Wireless Connection ("); + } + else if (menuCaption.contains("pan", FALSE) > 0) { + menuCaption = menuCaption.insert(0, "Private Area Connection ("); + } + else { + menuCaption = menuCaption.insert(0, "Unknown Connection ("); + } + menuCaption = menuCaption.append(")"); + deviceNewConnAction = actionCollection ()->action (actionName); + if (!deviceNewConnAction) { + deviceNewConnAction = new KAction (menuCaption, 0, (*it), TQT_SLOT(newConnection()), actionCollection(), actionName); + } + newConnActionMenu->insert(deviceNewConnAction); + } + } + } + else if ( devices == 1 ) { + newConnAction = actionCollection ()->action ("new_connection"); + TQT_BASE_OBJECT_NAME::disconnect( newConnAction, TQT_SIGNAL(activated()) ); + TQT_BASE_OBJECT_NAME::connect( newConnAction, TQT_SIGNAL(activated()), d->trayComponents[0], TQT_SLOT(newConnection())); + } + if (newConnAction) { + newConnAction->plug(menu); + } + + // turn things off + if (nm) { + KActionMenu* disableStuffActionMenu = static_cast(actionCollection ()->action ("deactivate_menu") ); + disableStuffActionMenu->popupMenu()->clear(); + TDENetworkConnectionList* map = nm->connections(); + d->act_conn_map.clear(); + + for (TDENetworkConnectionList::Iterator it = map->begin(); it != map->end(); ++it) { + TDENetworkConnection* conn = (*it); + + if (!conn) { + continue; + } + + if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected) + || (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) { + continue; + } + + TQString actionName = TQString("disable_connection_%1").arg(conn->UUID); + KAction * deviceNewConnAction = actionCollection ()->action (actionName); + TQString actionText = conn->friendlyName; + + if (!deviceNewConnAction) { + deviceNewConnAction = new KAction (actionText, 0, &d->signalMapper, TQT_SLOT(map()), actionCollection(), actionName); + } + d->signalMapper.setMapping(deviceNewConnAction, d->current_idx); + d->act_conn_map.insert(d->current_idx, conn); + d->current_idx++; + disableStuffActionMenu->insert(deviceNewConnAction); + } + + // disable wireless + if (nm->wiFiHardwareEnabled()) { + KAction* wireless = NULL; + if (nm->wiFiEnabled()) { + wireless = actionCollection ()->action ("disable_wireless"); + } else { + wireless = actionCollection ()->action ("enable_wireless"); + } + disableStuffActionMenu->insert(wireless); + } + + // offline vs. online mode + KAction* switch_mode = NULL; + if (nm->backendStatus() != TDENetworkGlobalManagerFlags::Sleeping) { + switch_mode = actionCollection ()->action ("offline_mode"); + } + else { + switch_mode = actionCollection ()->action ("online_mode"); + } + disableStuffActionMenu->insert(switch_mode); + + disableStuffActionMenu->plug(menu); + } + } + else { + Subhead* subhead = new Subhead (menu, "subhead", i18n("NetworkManager is not running"), SmallIcon("stop", TQIconSet::Automatic)); + menu->insertItem (subhead, -1, -1); + } + + // Notifications + KAction* notif = actionCollection()->action("configure_notifications"); + notif->plug(menu); + + // Connection Editor + KAction* edit = actionCollection ()->action ("edit_connections"); + edit->plug(menu); + + // quit + menu->insertSeparator (); + KAction* quitAction = actionCollection ()->action (KStdAction::name (KStdAction::Quit)); + if (quitAction) { + quitAction->plug (menu); + } +} + +void +Tray::slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState) +{ + TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState; + // change tray icon according to NM's state + + if ((nm_state & TDENetworkGlobalManagerFlags::Unknown) + || (nm_state & TDENetworkGlobalManagerFlags::Sleeping) + || (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink) + || (nm_state & TDENetworkGlobalManagerFlags::Disconnected) + || (nm_state & TDENetworkGlobalManagerFlags::BackendUnavailable)) { + setPixmap (loadIcon ("tdenetworkmanager_disabled")); + } + else if (nm_state & TDENetworkGlobalManagerFlags::Connected) { + setPixmap (loadIcon ("tdenetworkmanager")); + } + + printf("NM state: %d\n\r", nm_state); +} + +void +Tray::enterEvent (TQEvent* /*e*/) +{ + // show tooltip + TQToolTip::remove (this); + TQString tooltip = ""; + + // build up the tooltip from all tray components + for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) + { + TrayComponent* comp = *it; + if (comp->getToolTipText().isEmpty()) + continue; + if (!tooltip.isEmpty()) + tooltip += "\n\n"; + tooltip += comp->getToolTipText().join("\n"); + } + if (!tooltip.isEmpty()) + TQToolTip::add (this, tooltip); +} + +void +Tray::slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hints, bool request_new) +{ + // For now assume secrets are already in NM... +} + +void Tray::slotAddDeviceTrayComponent(TDENetworkDevice* dev) +{ + if (dev) { + createDeviceTrayComponent(dev); + } +} + +void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev) +{ + for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) + { + DeviceTrayComponent* dev_comp = dynamic_cast(*it); + if (!dev_comp) + continue; + + if (dev_comp->device() == dev) + { + if (d->foregroundTrayComponent && dev_comp->device() == d->foregroundTrayComponent->device() ) { + d->foregroundTrayComponent = 0; + } + + // remove the appropriate action + TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); + KAction * deviceNewConnAction = actionCollection ()->action (actionName); + + if (!deviceNewConnAction) + { + delete deviceNewConnAction; + deviceNewConnAction = NULL; + } + // remove device_tray and delete it + d->trayComponents.remove(it); + delete dev_comp; + + if (contextMenu()->isVisible()) { + contextMenu()->hide(); + } + + break; + } + } +} + +void Tray::createDeviceTrayComponent(TDENetworkDevice* dev) +{ + bool trayExists = false; + + if (!dev) return; + + // check if we have already a trayicon for this device + for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) + { + DeviceTrayComponent* dev_comp = dynamic_cast (*it); + if (dev_comp) + if (dev_comp->device() == dev) + { + trayExists = true; + break; + } + } + + // create the appropriate device tray icon + if (!trayExists) + { + DeviceTrayComponent* devTray = 0; + TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); + // different tray icons for different device types! + switch (deviceConnMan->deviceType()) + { + case TDENetworkDeviceType::WiredEthernet: + devTray = new WiredDeviceTray(dev, this, "wired_device_tray"); + break; + case TDENetworkDeviceType::WiFi: + devTray = new WirelessDeviceTray(dev, this, "wireless_device_tray"); + break; + case TDENetworkDeviceType::Modem: + devTray = new CellularDeviceTray(dev, this, "cellular_device_tray"); + break; + default: + kdWarning() << k_funcinfo << "UDI: " << dev->uniqueID() << " has unknown devicetype: " << deviceConnMan->deviceType() << endl; + } + if(devTray) + { + connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)), + TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool))); + connect( devTray, TQT_SIGNAL(uiUpdated()), TQT_SLOT(trayUiChanged())); + d->trayComponents.append(devTray); + //WILLTODO: sort + } + } +} + +void Tray::updateDeviceTrays() +{ + TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); + if (!hwdevices) return; + + // create one tray-icon for each device + TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); + + // check for newly added devices + for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) + { + TDENetworkDevice* dev = dynamic_cast(*it); + if (dev) { + createDeviceTrayComponent(dev); + } + else { + kdWarning() << k_funcinfo << "got a NULL-Device" << endl; + } + } +} + +void Tray::mousePressEvent( TQMouseEvent *e ) +{ + if ( !TQT_TQRECT_OBJECT(rect()).contains( e->pos() ) ) { + return; + } + switch ( e->button() ) { + case Qt::LeftButton: + contextMenuAboutToShow(contextMenu()); + contextMenu()->popup(e->globalPos()); + break; + default: + KSystemTray::mousePressEvent( e ); + break; + } +} + +void Tray::slotDeactivateConnection(int index) +{ + TDENetworkConnection* conn = d->act_conn_map[index]; + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) return; + + if (conn) { + nm->deactivateConnection(conn->UUID); + } +} + +void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt) +{ + DeviceTrayComponent * dtc = dynamic_cast(component); + if (dtc) { + kdDebug() << k_funcinfo << dtc->device()->deviceNode() << " : " << needsIt << endl; + TDENetworkDevice * device = dtc->device(); + if (needsIt) { + if (d->foregroundTrayComponent) { + disconnect(d->foregroundTrayComponent->device(), TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); + } + d->foregroundTrayComponent = dtc; + connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), + TQT_SLOT(slotUpdateDeviceState(NMDeviceState))); + } else { + disconnect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); + // use active default +#if 0 + // FIXME + // The TDE network backend has no concept of a default device + // Should it? + device = nm->getDefaultDevice(); + if ( device ) { + // identify the new foreground + for (TQValueList::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) + { + DeviceTrayComponent* newDtc = dynamic_cast (*it); + if ( newDtc && newDtc->device() == device ) { + d->foregroundTrayComponent = newDtc; + break; + } + } + kdDebug() << " Device " << dtc->device()->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl; + connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), + TQT_SLOT(slotUpdateDeviceState(NMDeviceState))); + slotUpdateDeviceState(device->getState()); + } +#endif + } + } +} + +void Tray::slotUpdateDeviceState() +{ + // FIXME +} + +void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + updateTrayIcon(state); + updateActiveConnection(state); +} + +void Tray::trayUiChanged() +{ + DeviceTrayComponent * dtc = d->foregroundTrayComponent; + if (dtc) { + TDENetworkConnectionManager* deviceConnMan = dtc->device()->connectionManager(); + updateTrayIcon(deviceConnMan->deviceInformation().statusFlags); + } +} +void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + // Get all active connections + char found_any_active_connection=0; + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + found_any_active_connection = 0; + // Get all active connections + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { + TDENetworkConnection* conn = (*it); + + if (!conn) { + continue; + } + + if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected) + || (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) { + continue; + } + + // Found an active connection + found_any_active_connection = 1; + } + +// if (found_any_active_connection == 1) { +// printf("Active connection found\n\r"); +// } + + // stop the old movie to avoid unnecessary wakups + DeviceTrayComponent * dtc = d->foregroundTrayComponent; + + if (movie()) + movie()->pause(); + + if ((dtc) && (found_any_active_connection == 1)) { + + if (!dtc->movieForState(state).isNull()) + { + // animation desired + int frame = -1; + if (movie()) + frame = movie()->frameNumber(); + + // set the movie + setMovie(dtc->movieForState(state)); + + // start at the same frame as the movie before + if (frame > 0) + movie()->step(frame); + + // start the animation + movie()->unpause(); + } + else if (!dtc->pixmapForState(state).isNull()) + setPixmap(dtc->pixmapForState(state)); + else + setPixmap(loadIcon("tdenetworkmanager")); + } + else { + setPixmap(loadIcon("tdenetworkmanager")); + } + + nm_device_state_global = state; + //printf("Device state: %d\n\r", nm_device_state_global); +} + +void Tray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + if (state != TDENetworkConnectionStatus::Connected) { + return; + } +} + +void Tray::slotDeviceAddedNotify(TDENetworkDevice* dev) +{ + kdDebug() << "Tray::slotDeviceAddedNotify" << endl; + KNotifyClient::event( winId(), "knm-nm-device-added", i18n("New network device %1 found").arg(dev->deviceNode()) ); +} + +void Tray::slotDeviceRemovedNotify(TDENetworkDevice* dev) +{ + kdDebug() << "Tray::slotDeviceRemovedNotify" << endl; + KNotifyClient::event( winId(), "knm-nm-device-removed", i18n("Network device %1 removed").arg(dev->deviceNode()) ); +} + +void Tray::slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState) +{ + TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState; + + // change tray icon according to NM's state + if (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink) { + KNotifyClient::event( winId(), "knm-nm-connecting", i18n("NetworkManager is connecting") ); + } + else if (nm_state & TDENetworkGlobalManagerFlags::Disconnected) { + KNotifyClient::event( winId(), "knm-nm-disconnected", i18n("NetworkManager is now disconnected") ); + } + else if (nm_state & TDENetworkGlobalManagerFlags::Connected) { + KNotifyClient::event( winId(), "knm-nm-connected", i18n("NetworkManager is now connected") ); + } + else if (nm_state & TDENetworkGlobalManagerFlags::Sleeping) { + KNotifyClient::event( winId(), "knm-nm-sleeping", i18n("KNetworkManager Offline") ); + } + else if (nm_state & TDENetworkGlobalManagerFlags::Unknown) { + // + } +} + +void Tray::slotEditNotifications() +{ + KNotifyDialog::configure(this); +} + +Tray::Tray () : KSystemTray () +{ + d = new TrayPrivate(TQT_TQOBJECT(this)); + + connect(&d->signalMapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(slotDeactivateConnection(int))); + + setPixmap (loadIcon ("tdenetworkmanager")); + setMouseTracking (true); + + // Actions used for plugging into the menu + new KAction (i18n ("Switch to offline mode"), + SmallIcon ("no", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotOfflineMode()), actionCollection (), "offline_mode"); + + new KAction (i18n ("Switch to online mode"), + SmallIcon ("ok", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotOnlineMode()), actionCollection (), "online_mode"); + + new KAction (i18n ("Disable Wireless"), + SmallIcon ("wireless_off", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotDisableWireless()), actionCollection (), "disable_wireless"); + + new KAction (i18n ("Enable Wireless"), + SmallIcon ("wireless", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotEnableWireless()), actionCollection (), "enable_wireless"); + + new KAction (i18n ("Edit Connections"), + SmallIcon ("edit", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotEditConnections()), actionCollection (), "edit_connections"); + + new KAction (i18n ("Configure Notifications"), + SmallIcon ("knotify", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), TQT_SLOT (slotEditNotifications()), actionCollection (), "configure_notifications"); + + // this action is only connected when the menu is shown, hence the 0 receiver + new KAction (i18n ("New connection ..."), + SmallIcon ("filenew", TQIconSet::Automatic), 0, + TQT_TQOBJECT(this), 0, actionCollection (), "new_connection"); + + new KActionMenu (i18n ("New connection ..."), + SmallIcon ("filenew", TQIconSet::Automatic), + actionCollection(), "new_connection_menu"); + + new KActionMenu (i18n ("Deactivate connection..."), + SmallIcon ("no", TQIconSet::Automatic), + actionCollection (), "deactivate_menu"); + + // get notified when NM's state changes + connect(KGlobal::networkManager(), TQT_SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, TQT_SLOT(slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); + + // get notified about new/removed devices + // FIXME +// DeviceStore* store = DeviceStore::getInstance(); +// connect(store, TQT_SIGNAL(DeviceStoreChanged()), this, TQT_SLOT(updateDeviceTrays())); +// connect(store, TQT_SIGNAL(DeviceAdded(TDENetworkDevice*)), this, TQT_SLOT(slotAddDeviceTrayComponent(TDENetworkDevice*))); +// connect(store, TQT_SIGNAL(DeviceRemoved(TDENetworkDevice*)), this, TQT_SLOT(slotRemoveDeviceTrayComponent(TDENetworkDevice*))); + + // Notifications + connect(KGlobal::networkManager(), TQT_SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, TQT_SLOT(slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags))); +// connect(store, TQT_SIGNAL(DeviceAdded(TDENetworkDevice*)), this, TQT_SLOT(slotDeviceAddedNotify(TDENetworkDevice*))); +// connect(store, TQT_SIGNAL(DeviceRemoved(TDENetworkDevice*)), this, TQT_SLOT(slotDeviceRemovedNotify(TDENetworkDevice*))); + + + // initial setup of the device-trays + updateDeviceTrays(); + + slotStateChanged(KGlobal::networkManager()->backendStatus(), TDENetworkGlobalManagerFlags::Unknown); +} + +Tray::~Tray () +{ + delete d; +} + +#include "tdenetman-tray.moc" + diff --git a/tdenetworkmanager/src/tdenetman-tray.h b/tdenetworkmanager/src/tdenetman-tray.h new file mode 100644 index 0000000..6f49012 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-tray.h @@ -0,0 +1,135 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Helmut Schaa , + * Alexander Naumov , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_TRAY_H +#define KNETWORKMANAGER_TRAY_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "tdenetman.h" + +namespace ConnectionSettings +{ + class Connection; + class ConnectionSetting; +} + +class TQMouseEvent; +class TrayComponent; +class TrayPrivate; +class TQDialog; +class TQPushButton; +class TQLabel; + +class Tray : public KSystemTray +{ + Q_OBJECT + + + public: + Tray (); + ~Tray (); + static Tray* getInstance(); + void contextMenuAboutToShow (KPopupMenu* menu); + + signals: + + public slots: + void slotOfflineMode(); + void slotOnlineMode(); + void slotEnableWireless(); + void slotDisableWireless(); + void slotEditConnections(); + + void slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState); + void slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hints, bool request_new); + + void slotDeviceAddedNotify(TDENetworkDevice*); + void slotDeviceRemovedNotify(TDENetworkDevice*); + void slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState); + + void slotUpdateDeviceState(); + void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + + protected slots: + void updateDeviceTrays(); + void slotAddDeviceTrayComponent(TDENetworkDevice*); + void slotRemoveDeviceTrayComponent(TDENetworkDevice*); + void slotDeactivateConnection(int); + void trayComponentNeedsCenterStage(TrayComponent*, bool); + void trayUiChanged(); + void slotEditNotifications(); + + private: + void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void mousePressEvent(TQMouseEvent *e); + void createDeviceTrayComponent(TDENetworkDevice*); + void enterEvent(TQEvent*); + + TrayPrivate* d; + +}; + +class NewSecretsDialog : public TQDialog +{ + Q_OBJECT + + + public: + NewSecretsDialog(TDENetworkConnection* connection, TQWidget * parent, const char * name, bool modal = false, TQt::WFlags f = 0); + ~NewSecretsDialog(); + void init(); + + public slots: + void slotDialogEdit(); + void reject(); + + private: + TDENetworkConnection* _connection; +}; + +#endif /* KNETWORKMANAGER_TRAY_H */ diff --git a/tdenetworkmanager/src/tdenetman-vpn_plugin.cpp b/tdenetworkmanager/src/tdenetman-vpn_plugin.cpp new file mode 100644 index 0000000..e2ab272 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpn_plugin.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** + * + * tdenetman-vpn_plugin.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// KDE includes +#include + +// TQt includes +#include + +// TQT_DBus includes +#include +#include +#include + +// NM includes +#include +#include + +// KNM includes +#include "tdenetman.h" +#include "tdenetman-tray.h" +#include "tdenetman-vpn_plugin.h" +#include "dbus/vpnpluginproxy.h" +#include "tdenetman-hal_device_proxy.h" +#include "tdenetman-nm_proxy.h" + +#if !defined(NM_CHECK_VERSION) +#define NM_CHECK_VERSION(x,y,z) 0 +#endif + +unsigned int current_vpn_state = 0; +extern NMDeviceState nm_device_state_global; +extern TQT_DBusObjectPath vpn_attempt_this_conn; +unsigned char vpn_new_credentials_needed = 0; + +class VPNDBUSPluginPrivate +{ +public: + VPNDBUSPluginPrivate(TQString service, TQString obj_path) + : nmVPNDBUS(service, obj_path) + {} + ~VPNDBUSPluginPrivate() {} + + DBus::VPNPluginProxy nmVPNDBUS; +}; + +TQ_UINT32 VPNDBUSPlugin::getState() +{ + TQT_DBusError err; + return d->nmVPNDBUS.getState(err); +} + +void VPNDBUSPlugin::slotStateChanged(TQ_UINT32 state) +{ + current_vpn_state = state+1; + Tray* tray = Tray::getInstance(); + tray->slotUpdateDeviceState(nm_device_state_global); + //emit StateChanged((NMDeviceState)state); +} + +void VPNDBUSPlugin::slotLoginBanner(const TQString& banner) +{ + Tray* tray = Tray::getInstance(); + tray->slotVPNBannerShow(banner); +} + +void VPNDBUSPlugin::slotFailure(TQ_UINT32 failure_reason) +{ + printf("VPN failure code %d\n\r", failure_reason); + + if ((failure_reason == 0) || (failure_reason == 1) || (failure_reason == 2)) { + // Try to connect again using cached information; request new login though + printf("Reactivate VPN connection on default device\n\r"); + vpn_new_credentials_needed = 1; + int id; + TQT_DBusError err; + NMProxy* nm = NMProxy::getInstance(); + TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); + TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); +#if NM_CHECK_VERSION(0,8,992) + nm->ActivateConnectionAsync(id,"org.freedesktop.NetworkManagerUserSettings", vpn_attempt_this_conn, device, act_conn, err); +#else + nm->ActivateConnectionAsync(id,NM_DBUS_SERVICE_USER_SETTINGS, vpn_attempt_this_conn, device, act_conn, err); +#endif + } +} + +VPNDBUSPlugin::VPNDBUSPlugin () + : TQObject() +{ + d = new VPNDBUSPluginPrivate(NM_VPN_DBUS_PLUGIN_INTERFACE, NM_VPN_DBUS_PLUGIN_PATH); + d->nmVPNDBUS.setConnection(TQT_DBusConnection::systemBus()); + + // Connect the state changed signal to the handler + connect(&(d->nmVPNDBUS), TQT_SIGNAL(StateChanged(TQ_UINT32)), this, TQT_SLOT(slotStateChanged(TQ_UINT32))); + + // Connect the failure signal to the handler + connect(&(d->nmVPNDBUS), TQT_SIGNAL(Failure(TQ_UINT32)), this, TQT_SLOT(slotFailure(TQ_UINT32))); + + // And the banner signal + connect(&(d->nmVPNDBUS), TQT_SIGNAL(LoginBanner(const TQString&)), this, TQT_SLOT(slotLoginBanner(const TQString&))); +} + +VPNDBUSPlugin::~VPNDBUSPlugin () +{ + delete d; +} + + +#include "tdenetman-vpn_plugin.moc" diff --git a/tdenetworkmanager/src/tdenetman-vpn_plugin.h b/tdenetworkmanager/src/tdenetman-vpn_plugin.h new file mode 100644 index 0000000..784de6d --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpn_plugin.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * + * tdenetman-wired_device.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * Author: Timothy Pearson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_VPNDBUSPLUGIN_H +#define KNETWORKMANAGER_VPNDBUSPLUGIN_H + +// std includes +#include + +// KNM includes +#include "tdenetman.h" + +class KNetworkManager; + +class VPNDBUSPluginPrivate; + +class VPNDBUSPlugin : public TQObject +{ + Q_OBJECT + + public: + VPNDBUSPlugin (); + ~VPNDBUSPlugin (); + + TQ_UINT32 getState(); + + private: + VPNDBUSPluginPrivate * d; + +// signals: +// void StateChanged(NMDeviceState); + + public slots: + void slotFailure(TQ_UINT32); + void slotStateChanged(TQ_UINT32); + void slotLoginBanner(const TQString&); +// void slotDeactivate(); +}; + +#endif /* KNETWORKMANAGER_VPNDBUSPLUGIN_H */ diff --git a/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.cpp b/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.cpp new file mode 100644 index 0000000..e29d744 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** + * + * tdenetman-vpnauthenticationdialog.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "tdenetman-vpnservice.h" +#include "tdenetman-vpnmanager.h" +#include "tdenetman-vpnauthenticationdialog.h" +#include "tdenetman-vpn_connection.h" +#include "tdenetman-nm_proxy.h" +#include "tdenetman-connection_setting_vpn.h" +#include "tdenetman-connection_setting_info.h" + +extern TQT_DBusObjectPath vpn_attempt_this_conn; + +using namespace ConnectionSettings; + + +/* + * class VPNAuthenticationDialog + * + */ +VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, TQWidget* parent, const char* name, bool modal, WFlags fl) + : AuthenticationDialog(parent, name, modal, fl) + , _conn(conn) +{ + this->setIcon(SmallIcon("encrypted", TQIconSet::Automatic)); + this->setCaption(i18n("VPN Authentication for %1").arg(conn->getInfoSetting()->getName())); + labelPixmap->setPixmap(KGlobal::instance()->iconLoader()->loadIcon("encrypted", KIcon::Small, 32)); + + // nice icons + pushOK->setIconSet(SmallIcon("button_ok", TQIconSet::Automatic)); + pushCancel->setIconSet(SmallIcon("button_cancel", TQIconSet::Automatic)); + + // we need the last widget in the focus queue + TQFocusData* foc = focusData(); + TQWidget* lastFocusWidget = foc->last(); + + VPN* vpn = conn->getVPNSetting(); + VPNService* vpnservice = VPNManager::getVPNService(vpn->getServiceType()); + + // get the appropriate plugin and create the authentication widget + VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin(); + if (vpnPlugin) + { + _vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack); + if (_vpnAuthWidget) + { + _vpnAuthWidget->setVPNData(conn->getVPNSetting()->getRoutes(), conn->getVPNSetting()->getData()); + widgetStack->raiseWidget(_vpnAuthWidget); + } + } + + /* + the widgets inside the authenticationwidget are now in the focus queue + ==> we can now search the first widget inside the authenticationwidget + which has to get the focus + */ + TQWidget* widget = foc->home(); + for (int i = 0; i < foc->count(); ++i) + { + if (widget == lastFocusWidget) + { + // the next one is the first widget inside the authwidget + widget = foc->next(); + break; + } + widget = foc->next(); + } + if (widget) + widget->setFocus(); + + // resize + this->resize(minimumSizeHint()); +} + +VPNAuthenticationDialog::~VPNAuthenticationDialog() +{ + +} + +bool VPNAuthenticationDialog::close(bool alsoDelete) +{ + // no secrets provided, tell NM + _conn->slotSecretsError(); + return AuthenticationDialog::close(alsoDelete); +} + +void VPNAuthenticationDialog::ok() +{ + // Good, we have new secrets now, update the settings + TQMap mypwds; + + mypwds = _vpnAuthWidget->getPasswords(); + ConnectionSetting* propcore = _conn->getVPNSettingConnectionCore(); + SettingsMap othersettingsmap = propcore->toMap(); + + // Pull the username and gateway out of mypwds to stuff in the NM standard settings matrix + othersettingsmap.insert("user", TQT_DBusData::fromString(mypwds["user"])); + mypwds.erase("user"); + othersettingsmap.insert("domain", TQT_DBusData::fromString(mypwds["domain"])); + mypwds.erase("domain"); +// othersettingsmap.erase("Commit to disk"); +// if (chkStorePasswordsPermanent->isChecked() == true) { +// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("true")); +// } +// else { +// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("false")); +// } + + propcore->fromMap(othersettingsmap); + VPN* prop = dynamic_cast(propcore); + prop->setSecrets(mypwds); + _conn->slotSecretsProvided(prop); + TQDialog::done(0); +} + +void VPNAuthenticationDialog::setPasswords(TQString name, TQString value) { + if (value.length() > 0) { + chkStorePasswordsPermanent->setChecked(true); + _vpnAuthWidget->setPasswords(name, value); + } +} + +void VPNAuthenticationDialog::cancel() +{ +/* + TQStringList x; + emit done (true, x, false, false); + TQDialog::done(1);*/ + + printf("Attempting to deactivate VPN connection...\n\r"); + + // Disconnect the attempted connection + _conn->slotSecretsError(); + + // Quit the dialog + TQDialog::done(1); +} + +#include "tdenetman-vpnauthenticationdialog.moc" diff --git a/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.h b/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.h new file mode 100644 index 0000000..ee48410 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnauthenticationdialog.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * + * tdenetman-authenticationdialog.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H +#define KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H + +#include +#include +#include +#include + +#include "tdenetman.h" +#include "vpnauthentication.h" +#include "tdenetman-vpnplugin.h" +#include "tdenetman-vpnmanager.h" + +class KNetworkManager; +class ManageConnectionsDialog; +class VPNService; + +namespace ConnectionSettings +{ + class VPNConnection; +} + +class VPNAuthenticationDialog : public AuthenticationDialog +{ + Q_OBJECT + + public: + VPNAuthenticationDialog(ConnectionSettings::VPNConnection* conn = NULL, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); + ~VPNAuthenticationDialog(); + void setPasswords(TQString name, TQString value); + virtual bool close(bool); + + protected slots: + void ok(); + void cancel(); + + private: + VPNAuthenticationWidget* _vpnAuthWidget; + ConnectionSettings::VPNConnection* _conn; + + signals: + void done(bool, TQStringList &, bool, bool); +}; + +#endif /* KNETWORKMANAGER_VPNAUTHENTICATIONDIALOG_H */ diff --git a/tdenetworkmanager/src/tdenetman-vpnmanager.cpp b/tdenetworkmanager/src/tdenetman-vpnmanager.cpp new file mode 100644 index 0000000..62a0b8f --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnmanager.cpp @@ -0,0 +1,107 @@ +/*************************************************************************** + * + * tdenetman-vpnmanager.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#define SERVICE_DIR "/etc/NetworkManager/VPN" + +#include +#include +#include +#include + +#include "tdenetman-vpnmanager.h" +#include "tdenetman-vpnservice.h" +#include "tdenetman-vpnplugin.h" + +/* + * class VPNManager + * + */ +VPNServiceList +VPNManager::getVPNServices () +{ + bool status = false; + VPNServiceList list; + + TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); + TQStringList services = serviceDir.entryList ().grep (".name", true); + + if (services.count () > 0) + { + status = true; + // read in all available Services + for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { + TQString service = SERVICE_DIR + TQString ("/") + *i; + KConfig* kconfig = new KConfig (service, true, true, "config"); + kconfig->setGroup ("VPN Connection"); + +kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl; + + // create new VPNService Object + VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(KNetworkManager::getInstance())); + if (!vpnservice->getVPNPlugin()) + delete vpnservice; + else + list.push_back(vpnservice); + delete kconfig; + } + } + + return list; +} + +VPNService* +VPNManager::getVPNService(TQString service_type) +{ + bool status = false; + VPNServiceList list; + + TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); + TQStringList services = serviceDir.entryList ().grep (".name", true); + + if (services.count () > 0) + { + status = true; + // read in all available Services + for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { + TQString service = SERVICE_DIR + TQString ("/") + *i; + KConfig* kconfig = new KConfig (service, true, true, "config"); + kconfig->setGroup ("VPN Connection"); + + if (kconfig->readEntry ("service", TQString()) == service_type) + { + // create new VPNService Object + VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(KNetworkManager::getInstance())); + if (!vpnservice->getVPNPlugin()) + delete vpnservice; + else + return vpnservice; + } + } + } + return NULL; + +} + +#include "tdenetman-vpnmanager.moc" diff --git a/tdenetworkmanager/src/tdenetman-vpnmanager.h b/tdenetworkmanager/src/tdenetman-vpnmanager.h new file mode 100644 index 0000000..3030c07 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnmanager.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * + * tdenetman-vpnmanager.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Helmut Schaa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_VPNMANAGER_H +#define KNETWORKMANAGER_VPNMANAGER_H + +#include +#include + +#include +#include + +#include "tdenetman.h" +#include "tdenetman-vpnplugin.h" + +class KNetworkManager; +class VPNService; + +typedef TQValueList VPNServiceList; + +class VPNManager : public TQObject +{ + Q_OBJECT + + + public: + static VPNService* getVPNService(TQString); + static VPNServiceList getVPNServices (); +}; + +#endif /* KNETWORKMANAGER_VPNMANAGER_H */ diff --git a/tdenetworkmanager/src/tdenetman-vpnplugin.cpp b/tdenetworkmanager/src/tdenetman-vpnplugin.cpp new file mode 100644 index 0000000..dbeeb18 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnplugin.cpp @@ -0,0 +1,128 @@ +/*************************************************************************** + * + * tdenetman-vpnplugin.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include + +#include "tdenetman-vpnplugin.h" + +/*********************** +* class VPNConfigWidget +***********************/ + +VPNConfigWidget::~VPNConfigWidget() +{ + +} + +VPNConfigWidget::VPNConfigWidget(TQWidget* parent, const char* name) + : TQWidget(parent, name) +{ + +} + +void VPNConfigWidget::setVPNData(const TQStringList& /*routes*/, const TQMap& /*properties*/) +{ + +} + +TQMap VPNConfigWidget::getVPNProperties() +{ + return TQMap(); +} + +TQStringList VPNConfigWidget::getVPNRoutes() +{ + return TQStringList(); +} + +bool VPNConfigWidget::hasChanged() +{ + return true; +} + +bool VPNConfigWidget::isValid(TQStringList& /*err_msg*/) +{ + return true; +} + +/****************************** +* class VPNAuthentiactionWidget +******************************/ + +VPNAuthenticationWidget::VPNAuthenticationWidget(TQWidget* parent, const char* name) + : TQWidget(parent, name) +{ + +} + +VPNAuthenticationWidget::~VPNAuthenticationWidget() +{ + +} + +TQMap VPNAuthenticationWidget::getPasswords() +{ + return TQMap(); +} + +void VPNAuthenticationWidget::setPasswords(TQString name, TQString value) +{ + +} + +void VPNAuthenticationWidget::setVPNData(const TQStringList& /*routes*/, const TQMap& /*properties*/) +{ + +} + +bool VPNAuthenticationWidget::needsUserInteraction() +{ + return true; +} + +/**************** +* class VPNPlugin +****************/ +VPNPlugin::VPNPlugin(TQObject* parent, const char* name, const TQStringList& args) + : Plugin(parent, name, args) +{ + +} + +VPNPlugin::~VPNPlugin() +{ + +} + +VPNConfigWidget* VPNPlugin::CreateConfigWidget(TQWidget*) +{ + return NULL; +} + +VPNAuthenticationWidget* VPNPlugin::CreateAuthenticationWidget(TQWidget*) +{ + return NULL; +} + +#include "tdenetman-vpnplugin.moc" diff --git a/tdenetworkmanager/src/tdenetman-vpnplugin.h b/tdenetworkmanager/src/tdenetman-vpnplugin.h new file mode 100644 index 0000000..10f5d25 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnplugin.h @@ -0,0 +1,79 @@ +/*************************************************************************** + * + * tdenetman-vpnplugin.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_VPNPLUGIN_H +#define KNETWORKMANAGER_VPNPLUGIN_H + +#include +#include +#include +#include +#include "tdenetman-plugin.h" + +#define KNETWORKMANAGER_VPNPLUGIN "KNetworkManager/VPNPlugin" + +class VPNConfigWidget : public TQWidget +{ + Q_OBJECT + + public: + virtual ~VPNConfigWidget(); + VPNConfigWidget(TQWidget* parent = NULL, const char* name = NULL); + + virtual void setVPNData(const TQStringList&, const TQMap&); + virtual TQMap getVPNProperties(); + virtual TQStringList getVPNRoutes(); + virtual bool hasChanged(); + virtual bool isValid(TQStringList&); +}; + +class VPNAuthenticationWidget : public TQWidget +{ + Q_OBJECT + + public: + virtual ~VPNAuthenticationWidget(); + VPNAuthenticationWidget(TQWidget* parent = NULL, const char* name = NULL); + + virtual void setVPNData(const TQStringList&, const TQMap&); + virtual TQMap getPasswords(); + virtual void setPasswords(TQString value, TQString data); + virtual bool needsUserInteraction(); +}; + +class VPNPlugin : public Plugin +{ + Q_OBJECT + + public: + VPNPlugin(TQObject*, const char*, const TQStringList&); + virtual ~VPNPlugin(); + + virtual VPNConfigWidget* CreateConfigWidget(TQWidget* parent = 0); + virtual VPNAuthenticationWidget* CreateAuthenticationWidget(TQWidget* parent = 0); +}; + + +#endif /* KNETWORKMANAGER_VPNPLUGIN_H */ + diff --git a/tdenetworkmanager/src/tdenetman-vpnservice.cpp b/tdenetworkmanager/src/tdenetman-vpnservice.cpp new file mode 100644 index 0000000..978a183 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnservice.cpp @@ -0,0 +1,123 @@ +/*************************************************************************** + * + * tdenetman-vpnservice.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#define SERVICE_DIR "/etc/NetworkManager/VPN" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tdenetman-pluginmanager.h" +#include "tdenetman-vpnservice.h" +#include "tdenetman-vpnplugin.h" + +/* + * class VPNService + * + */ + +VPNService::VPNService(const TQString& serviceName, const TQString& service, TQObject* parent, const char* name) + : TQObject(parent, name) +{ + _name = serviceName; + _service = service; + _vpnPlugin = NULL; + + // query if a plugin for this vpn service is available + PluginManager* plugMan = PluginManager::getInstance(); + if (plugMan) + { + TQStringList list = plugMan->getPluginList("KNetworkManager/VPNPlugin", "X-NetworkManager-Services", serviceName); + if (list.size() > 0) + { + // get the first VPN Plugin handling our VPNService + VPNPlugin* vpnPlugin = dynamic_cast( plugMan->getPlugin(list.first()) ); + if (vpnPlugin) + { + kdDebug() << k_funcinfo << i18n("Using VPN plugin '%1' for service '%2'").arg(list.first()).arg(serviceName) << endl; + _vpnPlugin = vpnPlugin; + } + } + } +} + +VPNService::~VPNService() +{ + +} + +TQString VPNService::getIcon() +{ + if (!_vpnPlugin.isNull()) + { + PluginManager* plugMan = PluginManager::getInstance(); + if (plugMan) + { + const KPluginInfo* info = plugMan->getPluginInfo(_vpnPlugin); + if (info) + { + TQString icon = info->icon(); + if (!icon.isEmpty()) + return icon; + } + } + } + return "encrypted"; +} + +VPNPlugin* VPNService::getVPNPlugin() +{ + return _vpnPlugin; +} + +TQString VPNService::getService() const +{ + return _service; +} + +TQString VPNService::getDisplayName() const +{ + const KPluginInfo* info = NULL; + PluginManager* plugMan = PluginManager::getInstance(); + if (_vpnPlugin && plugMan) + if ( (info = plugMan->getPluginInfo(_vpnPlugin)) ) + if (!info->name().isEmpty()) + return info->name(); + return _name; +} + +TQString VPNService::getName() const +{ + return _name; +} + +#include "tdenetman-vpnservice.moc" diff --git a/tdenetworkmanager/src/tdenetman-vpnservice.h b/tdenetworkmanager/src/tdenetman-vpnservice.h new file mode 100644 index 0000000..baf87a5 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-vpnservice.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * + * tdenetman-vpnservice.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Helmut Schaa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_VPN_SERVICE_H +#define KNETWORKMANAGER_VPN_SERVICE_H + +#include +#include + +#include +#include + +#include "tdenetman.h" +#include "tdenetman-vpnplugin.h" + +class KNetworkManager; +class VPNService; +class KConfigGroup; + +class VPNService : public TQObject +{ + Q_OBJECT + + + public: + VPNService(const TQString& serviceName, const TQString& service, TQObject* parent, const char* name = 0); + ~VPNService(); + + TQString getDisplayName() const; + TQString getName() const; + TQString getService() const; + VPNPlugin* getVPNPlugin(); + TQString getIcon(); + + private: + TQString _name; + TQString _service; + TQGuardedPtr _vpnPlugin; +}; + +#endif /* KNETWORKMANAGER_VPN_SERVICE_H */ diff --git a/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp b/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp new file mode 100644 index 0000000..68a6069 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp @@ -0,0 +1,149 @@ +/*************************************************************************** + * + * tdenetman-wired_device_tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// TQt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// KDE includes +#include +#include +#include + +// TQt DBus +#include + + +// KNM includes +#include "tdenetman-wired_device_tray.h" +#include "tdenetman-menuitem.h" +#include "tdenetman-menu_subhead.h" + +#include "tdenetman-connection_settings_dialog.h" + +using namespace ConnectionSettings; + +class WiredDeviceTrayPrivate +{ + public: + WiredDeviceTrayPrivate() {} + ~WiredDeviceTrayPrivate() {} + + TDENetworkDevice* dev; +}; + +void WiredDeviceTray::newConnection() +{ + // create a new wired connection + TDENetworkConnection* conn = new TDEWiredEthernetConnection(); + + // edit the new connection + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); + dlg->show(); +} + + +void WiredDeviceTray::addMenuItems(KPopupMenu* menu) +{ + // device title + Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wired", TQIconSet::Automatic)); + menu->insertItem (subhead, -1, -1); + + // bolding subhead instead + //menu->insertSeparator(); + + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + if (deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::LinkUnavailable) { + // no carrier -> do not show any connections + subhead = new Subhead(menu, "subhead2", i18n("Cable disconnected"), SmallIcon("no", TQIconSet::Automatic)); + menu->insertItem(subhead, -1, -1); + } + else { + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) + && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { + active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); + } + + // get all available Connections for wired devices + TDENetworkConnectionList* connections = nm->connections(); + int connectionItems = 0; + for (TDENetworkConnectionList::Iterator it = connections->begin(); it != connections->end(); ++it) { + TDEWiredEthernetConnection* conn = dynamic_cast(*it); + if (!conn) { + continue; + } + + // wired connection found :) + // lets create a nice name for this connection + TQString title = conn->friendlyName; + if (conn->ipConfig.valid) { + title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); + } + + NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); + connectionItems += 1; + + int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); + menu->setItemChecked(id, ((*it) == active_conn)); + } + + if ( connectionItems == 0) { + // menu->insertSeparator(); + menu->insertItem(SmallIcon("filenew", TQIconSet::Automatic), i18n("Create new wired connection"), this, TQT_SLOT(newConnection())); + } + // bring the device down + KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); + if (deactivate) + deactivate->plug(menu); + + } +} + +WiredDeviceTray::WiredDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name ) + : DeviceTrayComponent (dev, parent, name) +{ + d = new WiredDeviceTrayPrivate(); + d->dev = dev; + + setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wired"); +} + +WiredDeviceTray::~WiredDeviceTray () +{ + delete d; +} + +#include "tdenetman-wired_device_tray.moc" diff --git a/tdenetworkmanager/src/tdenetman-wired_device_tray.h b/tdenetworkmanager/src/tdenetman-wired_device_tray.h new file mode 100644 index 0000000..1ec550e --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wired_device_tray.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_WIRED_DEVICE_TRAY_H +#define KNETWORKMANAGER_WIRED_DEVICE_TRAY_H + +// KNM includes +#include "devicetraycomponent.h" + +#include "tdenetman.h" + +// predefs +class WiredDevice; +class WiredDeviceTrayPrivate; + +class WiredDeviceTray : public DeviceTrayComponent +{ + Q_OBJECT + + + public: + WiredDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); + ~WiredDeviceTray (); + + void addMenuItems(KPopupMenu* menu); + + public slots: + void newConnection(); + + private: + WiredDeviceTrayPrivate* d; +}; + +#endif /* KNETWORKMANAGER_WIRED_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp b/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp new file mode 100644 index 0000000..d1b209e --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp @@ -0,0 +1,417 @@ +/*************************************************************************** + * + * tdenetman-wireless_device_tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// TQt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// KDE includes +#include +#include +#include +#include + +// KNM includes +#include "tdenetman-wireless_device_tray.h" +#include "tdenetman-wireless_menuitem.h" +#include "tdenetman-wireless_network.h" +#include "tdenetman-menu_subhead.h" +#include "tdenetman-wireless_manager.h" +#include "tdenetman-connection_settings_dialog.h" + +using namespace ConnectionSettings; + +extern char use_new_wireless_essid; +extern TQByteArray new_wireless_essid; + +class WirelessDeviceTrayPrivate +{ + public: + WirelessDeviceTrayPrivate() :dev(0), activeAccessPoint(0) { } + ~WirelessDeviceTrayPrivate() {} + + TDENetworkDevice* dev; + TQGuardedPtr activeAccessPoint; +}; + +TQStringList WirelessDeviceTray::getToolTipText() +{ + TQStringList tooltip = DeviceTrayComponent::getToolTipText(); + + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); + if (ap) { + tooltip.append(i18n("Network: %1").arg(ap->friendlySSID())); + } + + return tooltip; +} + +void WirelessDeviceTray::newConnection() +{ + // create a new wireless connection + TDENetworkConnection* conn = new TDEWiFiConnection(); + + // open a dialog for editing the connection + use_new_wireless_essid = 0; // deactivate autofill for now + ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); + dlg->show(); +} + +bool WirelessDeviceTray::findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList& nets, WirelessNetwork& net) +{ + const TDEWiFiConnection* wireless = dynamic_cast(conn); + + if (!wireless) { + return false; + } + + for (TQValueList::ConstIterator it = nets.begin(); it != nets.end(); ++it) { + if (wireless->SSID == (*it).getSsid()) { + net = *it; + return true; + } + } + return false; +} + +TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetwork& net, const TQValueList& connections) +{ + // try to find a connection matching this network + for (TQValueList::ConstIterator it = connections.begin(); it != connections.end(); ++it) { + const TDEWiFiConnection* wireless = dynamic_cast(*it); + + if (!wireless) { + continue; + } + + if (wireless->SSID == net.getSsid()) + { + return *it; + } + } + + return NULL; +} + +void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu) +{ + printf("Updating wireless network list\n\r"); + + // get all wireless networks + TQValueList nets = WirelessManager::getWirelessNetworks(d->dev); + + // get all wireless connections + TQValueList conns = WirelessManager::getWirelessConnections(); + + // get the currently active connection + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) + && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { + active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); + } + + // add all wireless connections in range + // (we may have more then one connection per network) + for (TQValueList::iterator it = conns.begin(); it != conns.end(); ++it) + { + WirelessNetworkItem* wirelessNetworkItem; + WirelessNetwork net; + + // only show connections which are in range + if ( !findMatchingNetwork(*it, nets, net) ) + continue; + + wirelessNetworkItem = new WirelessNetworkItem (menu, + d->dev, + net, + *it, + false); + int id = menu->insertItem (wirelessNetworkItem, -1, -1); + menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn)); + menu->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate())); + } + + // now add all connections which are not in range to a submenu + TQPopupMenu* popup = new TQPopupMenu(menu); + + uint networkItemsAdded = 0; + for (TQValueList::iterator it = conns.begin(); it != conns.end(); ++it) + { + WirelessNetworkItem* wirelessNetworkItem; + WirelessNetwork net; + + // only show connections which are out of range + if ( findMatchingNetwork(*it, nets, net) ) + continue; + + TDEWiFiConnection* wireless = dynamic_cast(*it); + + if (!wireless) { + continue; + } + + wirelessNetworkItem = new WirelessNetworkItem (menu, + d->dev, + net, + *it, + false); + + int id = popup->insertItem (wirelessNetworkItem, -1, -1); + popup->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate())); + networkItemsAdded += 1; + } + + if (networkItemsAdded) { + menu->insertSeparator(); + menu->insertItem(i18n("Connect to saved network"), popup); + } + +// // List available unsaved networks + TQPopupMenu* newpopup = new TQPopupMenu(menu); + uint newnetworkItemsAdded = 0; + TQValueList newnets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID); + + for (TQValueList::Iterator it = newnets.begin(); it != newnets.end(); ++it) + { + // Only display networks with no existing connnection + if ( findMatchingConnection(*it, conns) != NULL) + continue; + + WirelessNetworkItem* wirelessNetworkItem; + wirelessNetworkItem = new WirelessNetworkItem (menu, + d->dev, + *it, + NULL, + false); + + int id = newpopup->insertItem (wirelessNetworkItem, -1, -1); + newpopup->connectItem(id, this, TQT_SLOT(newConnection())); + + newnetworkItemsAdded += 1; + } + + if (newnetworkItemsAdded) { + menu->insertSeparator(); + menu->insertItem(i18n("Connect to new network"), newpopup); + } + // Signal done with wireless menu + //menu->insertSeparator(); +} + +void WirelessDeviceTray::addMenuItems(KPopupMenu* menu) +{ + // get the currently active connection + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + + // device title + Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wireless", TQIconSet::Automatic)); + menu->insertItem (subhead, -1, -1); + + // bolding subhead instead + //menu->insertSeparator(); + + if (!nm->wiFiEnabled()) + { + // wireless disabled -> do not show any connections + subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled"), SmallIcon("no", TQIconSet::Automatic)); + menu->insertItem(subhead, -1, -1); + } + else if (!nm->wiFiHardwareEnabled()) + { + // wireless disabled -> do not show any connections + subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled by Killswitch"), SmallIcon("no", TQIconSet::Automatic)); + menu->insertItem(subhead, -1, -1); + } + else + { + // networks + addWirelessNetworks(menu); + + // bring the device down + KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); + if (deactivate) { + deactivate->plug(menu); + } + } + menu->insertSeparator(); +} + +void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetworkConnectionStatus states, TQString pixmap) { + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; + while (flag > 0) { + if (states & flag) { + setPixmapForState(flag, pixmap); + } + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); + } +} + +void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) +{ + slotCheckActiveAccessPoint(); + + if (state == TDENetworkConnectionStatus::Connected) { + // trigger an update of the connections seen bssids property + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); + if (ap) { + int strength = (ap->signalQuality*100.0); + + if (strength > 80) { + setPixmapForStates(state, "nm_signal_100"); + } + else if (strength > 55) { + setPixmapForStates(state, "nm_signal_75"); + } + else if (strength > 30) { + setPixmapForStates(state, "nm_signal_50"); + } + else if (strength > 5) { + setPixmapForStates(state, "nm_signal_25"); + } + else { + setPixmapForStates(state, "nm_signal_00"); + } + } + } +} + +void WirelessDeviceTray::slotCheckActiveAccessPoint() +{ + // the active AP changed, if a connection is already active we have roamed + // thus add the bssid to the list of seen bssids + + // get the currently active connection + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) + && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { + active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); + } + + if (active_conn && deviceConnMan->deviceInformation().statusFlags == TDENetworkConnectionStatus::Connected) { + TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); + if ( activeap != d->activeAccessPoint) { + if (!d->activeAccessPoint.isNull()) { + disconnect( deviceConnMan, TQT_SIGNAL(accessPointStatusChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)), this, TQT_SLOT(apPropertyChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType))); + } + + d->activeAccessPoint = activeap; + if ( d->activeAccessPoint ) { + connect( deviceConnMan, TQT_SIGNAL(accessPointStatusChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)), this, TQT_SLOT(apPropertyChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType))); + TDEWiFiConnection* wireless = dynamic_cast(active_conn); + if (wireless) { + if (!(wireless->heardBSSIDs.contains(d->activeAccessPoint->BSSID))) { + wireless->heardBSSIDs.append(d->activeAccessPoint->BSSID); + } + } + } + } + } +} + +void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) +{ + if (event == TDENetworkAPEventType::SignalStrengthChanged) { + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID); + if (ap) { + TQ_UINT32 strength = (ap->signalQuality*100.0); + kdDebug() << k_funcinfo << strength << endl; + TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; + if (strength > 80) { + setPixmapForStates(state, "nm_signal_100"); + } + else if (strength > 55) { + setPixmapForStates(state, "nm_signal_75"); + } + else if (strength > 30) { + setPixmapForStates(state, "nm_signal_50"); + } + else if (strength > 5) { + setPixmapForStates(state, "nm_signal_25"); + } + else { + setPixmapForStates(state, "nm_signal_00"); + } + emit uiUpdated(); + } + } +} + +void WirelessDeviceTray::slotAccessPointAdded(TDENetworkWiFiAPInfo* ap) +{ + KNotifyClient::event( tray()->winId(), "knm-nm-network-found", i18n("KNetworkManager New Wireless Network Found") ); +} + +void WirelessDeviceTray::slotAccessPointRemoved(const TQString&) +{ + KNotifyClient::event( tray()->winId(), "knm-nm-network-gone", i18n("KNetworkManager Wireless Network Disappeared") ); +} + +WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) + : DeviceTrayComponent (dev, parent, name) +{ + d = new WirelessDeviceTrayPrivate(); + d->dev = dev; + + // we want other icons for wireless devices + setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off"); + setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off"); + setPixmapForState(TDENetworkConnectionStatus::UnManaged, "wireless_off"); + setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless"); + setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_signal_50"); + + // get notified when the device state changes + connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); + + // if the active access point changed but not the connection we roamed to a new AP + connect(dev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint())); + + // get notified of all AP changes + connect(dev, TQT_SIGNAL(accessPointAdded(TDENetworkWiFiAPInfo*)), this, TQT_SLOT(slotAccessPointAdded(TDENetworkWiFiAPInfo*))); + connect(dev, TQT_SIGNAL(accessPointRemoved(const TQString&)), this, TQT_SLOT(slotAccessPointRemoved(const TQString&))); +} + +WirelessDeviceTray::~WirelessDeviceTray () +{ + delete d; +} + + +#include "tdenetman-wireless_device_tray.moc" diff --git a/tdenetworkmanager/src/tdenetman-wireless_device_tray.h b/tdenetworkmanager/src/tdenetman-wireless_device_tray.h new file mode 100644 index 0000000..9fb386e --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_device_tray.h @@ -0,0 +1,77 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H +#define KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H + +// KNM includes +#include "tdenetman.h" +#include "devicetraycomponent.h" +#include "tdenetman-wireless_network.h" + +// predefinitions +class WirelessDevice; +class WirelessDeviceTrayPrivate; + +class WirelessDeviceTray : public DeviceTrayComponent +{ + Q_OBJECT + + + public: + WirelessDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); + ~WirelessDeviceTray (); + + void addMenuItems(KPopupMenu* menu); + + protected: + /** + * Reimplementation + */ + TQStringList getToolTipText(); + + public slots: + void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void slotCheckActiveAccessPoint(); + void newConnection(); + protected slots: + void apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event); + void slotAccessPointAdded(TDENetworkWiFiAPInfo*); + void slotAccessPointRemoved(const TQString&); + + private: + void addWirelessNetworks(KPopupMenu* menu); + TQValueList getWirelessNetworks(); + TQValueList getWirelessConnections(); + TDEWiFiConnection* findMatchingConnection(const WirelessNetwork& net, const TQValueList& connection); + bool findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList& nets, WirelessNetwork& net); + void setPixmapForStates(TDENetworkConnectionStatus::TDENetworkConnectionStatus states, TQString pixmap); + + WirelessDeviceTrayPrivate* d; + +}; + +#endif /* KNETWORKMANAGER_WIRELESS_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/tdenetman-wireless_manager.cpp b/tdenetworkmanager/src/tdenetman-wireless_manager.cpp new file mode 100644 index 0000000..3f823b2 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_manager.cpp @@ -0,0 +1,181 @@ +/*************************************************************************** + * + * tdenetman-wireless_manager.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// other includes +#include + +// KNM includes +#include "tdenetman-wireless_manager.h" + +TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match) +{ + TQValueList nets; + TQValueList aps; + // fetch all APs + aps = WirelessManager::getAccessPoints(dev); + + // now group the APs together according to their security settings + for (TQValueList::Iterator apit = aps.begin(); apit != aps.end(); ++apit) + { + bool found = false; + + // no hidden APs + TDENetworkWiFiAPInfo * ap = *apit; + if ( ap ) { + if (ap->SSID.count() == 0) { + continue; + } + + // check if we have a network matching this AP + for (TQValueList::Iterator netIt = nets.begin(); netIt != nets.end(); ++netIt) { + if ((*netIt).contains(ap) ) { + // we alread have a network where this AP belongs to + found = true; + + // attach this ap to the network + (*netIt).addAP(ap); + + /* // FIXME active? + if (active_ap) + { + // here is the active_ap + if (!(*net).getActive() && ((*ap) == *active_ap)) + (*net).setActive(true); + }*/ + break; + } + } + + if (!found) { + // create a new network-descriptor according to this ap + WirelessNetwork net(match); + net.addAP(ap); + nets.append(net); + } + } + } + return nets; +} + +TQValueList internalGetAccessPoints(TDENetworkDevice* dev) { + TQValueList list; + if (dev) { + TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); + TDENetworkHWNeighbor* neighbor; + TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey(); + for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) { + TDENetworkWiFiAPInfo* apInfo = dynamic_cast(neighbor); + if (!apInfo) { + continue; + } + list.append(apInfo); + } + } + return list; +} + +TQValueList WirelessManager::getAccessPoints(TDENetworkDevice* dev) +{ + // build up AP list depending on one device or on all devices + if (dev) { + return internalGetAccessPoints(dev); + } + else { + TQValueList aps; + TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); + if (hwdevices) { + TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); + for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) { + TDENetworkDevice* wdev = dynamic_cast(*it); + if (wdev) { + aps += internalGetAccessPoints(wdev); + } + } + } + return aps; + } +} + +TQValueList WirelessManager::getWirelessConnections() +{ + TQValueList conns; + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (nm) { + // get all wireless connections + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { + TDEWiFiConnection* wireless_conn = dynamic_cast(*it); + if (!wireless_conn) { + continue; + } + conns.append(wireless_conn); + } + } + + return conns; +} + +TQValueList internalGetAccessPointsWithESSID(TQByteArray essid, TDENetworkDevice* dev) { + TQValueList list; + if (dev) { + TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); + TDENetworkHWNeighbor* neighbor; + TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey(); + for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) { + TDENetworkWiFiAPInfo* apInfo = dynamic_cast(neighbor); + if (!apInfo) { + continue; + } + if (apInfo->SSID == essid) { + list.append(apInfo); + } + } + } + return list; +} + +TQValueList WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev) +{ + // build up AP list depending on one device or on all devices + if (dev) { + return internalGetAccessPointsWithESSID(essid, dev); + } + else { + TQValueList aps; + TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); + if (hwdevices) { + TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network); + for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) { + TDENetworkDevice* wdev = dynamic_cast(*it); + if (wdev) { + aps += internalGetAccessPointsWithESSID(essid, wdev); + } + } + } + return aps; + } +} + + diff --git a/tdenetworkmanager/src/tdenetman-wireless_manager.h b/tdenetworkmanager/src/tdenetman-wireless_manager.h new file mode 100644 index 0000000..59c3cae --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_manager.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * + * tdenetman-wireless_manager.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_WIRELESS_MANAGER_H +#define KNETWORKMANAGER_WIRELESS_MANAGER_H + +// TQt includes +#include +#include + +// KNM includes +#include "tdenetman.h" +#include "tdenetman-device_tray.h" +#include "tdenetman-wireless_network.h" + +namespace ConnectionSettings +{ + class WirelessConnection; +} + +class WirelessManager +{ + public: + // get all accesspoints from device dev or from all devices if dev is NULL + // and group them together using all properties specified in match + static TQValueList getWirelessNetworks(TDENetworkDevice* dev = 0, TQ_UINT32 match = WirelessNetwork::MATCH_SSID); + + // get all aps from either one device or from all available devices + static TQValueList getAccessPoints(TDENetworkDevice* dev = 0); + + // get a list of all known wireless connections + static TQValueList getWirelessConnections(); + + // get a list of all APs with a specific SSID + static TQValueList getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0); + +}; + +#endif /* KNETWORKMANAGER_WIRELESS_MANAGER_H */ diff --git a/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp b/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp new file mode 100644 index 0000000..de37cfb --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp @@ -0,0 +1,227 @@ +/*************************************************************************** + * + * tdenetman-tray.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Timo Hoenig , + * Will Stephenson , + * Valentine Sinitsyn + * Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tdenetman-wireless_menuitem.h" +#include "tdenetman-wireless_network.h" + +using namespace ConnectionSettings; + +void WirelessNetworkItem::slotActivate() +{ + + TDENetworkConnectionManager* deviceConnMan = _dev->connectionManager(); + + printf("slotActivate\n\r"); + if (_dev && deviceConnMan) + { + if ( _conn ) + { + kdDebug() << "Activate Connection " << _conn->UUID.ascii() << " on Device " << _dev->deviceNode().ascii() << endl; + TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn->UUID); + if ((result == TDENetworkConnectionStatus::Disconnected) + || (result == TDENetworkConnectionStatus::Invalid)) { + kdDebug() << "ActivateDevice failed" << endl; + } + + } + else + { + // TODO: create new connection based upon the network and show the dialog + printf("New network support not implemented yet\n\r"); + } + } +} + + +TQString WirelessNetworkItem::getDisplayText() +{ + TQString security = ""; + if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) { + security = TQString("(%1/%2)").arg(i18n("WPA")).arg(i18n("RSN")); + } + else if ((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) { + security = TQString("(%1)").arg(i18n("WPA")); + } + else if ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) { + security = TQString("(%2)").arg(i18n("RSN")); + } + + if (_conn && (_conn->friendlyName != _net.getDisplaySsid())) { + return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(_conn->friendlyName).arg(security); + } + else { + return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security); + } +} + +void +WirelessNetworkItem::paint (TQPainter *p, const TQColorGroup &/*cg*/, bool highlighted, bool /*enabled*/, int x, int y, int w, int h) +{ + int spacer = 0; + pbarStrength->setTotalSteps (100); + pbarStrength->setSizePolicy (TQSizePolicy ((TQSizePolicy::SizeType) 0, (TQSizePolicy::SizeType) 0, 0, 0, pbarStrength->sizePolicy ().hasHeightForWidth ())); + pbarStrength->setFixedHeight (_height - 2); + pbarStrength->setProgress (_net.getStrength()); + pbarStrength->setPercentageVisible (false); + + if (highlighted) { + p->setPen(parent->palette ().active ().highlightedText ()); + pbarStrength->setBackgroundMode( TQt::PaletteHighlight, TQt::PaletteHighlight ); + } else { + p->setPen(parent->palette ().active ().text ()); + } + p->drawText (x, y, w, h, AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()); + + if (_net.isEncrypted()) { + TQPixmap pmLock = SmallIcon ("lock", TQIconSet::Automatic); + p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space - pmLock.size ().width () - 6, y + _border, pmLock); + spacer = pmLock.size ().width () + 4; + } + + if (_adhoc) { + TQPixmap pmAdHoc = SmallIcon ("system", TQIconSet::Automatic); + p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space - pmAdHoc.size ().width () - spacer - 6, y + _border, pmAdHoc); + } + + p->drawPixmap (parent->sizeHint ().width () - pbarStrength->width () - _space, y +_border, TQPixmap::grabWidget (pbarStrength)); +} + +TQSize +WirelessNetworkItem::sizeHint () +{ + return TQSize (_width, _height); +} + +WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc) + : NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem () +{ + parent = p; + _adhoc = adhoc; + _net = net; + _dev = dev; + _conn = conn; + + pbarStrength = new TQProgressBar (this->parent, "pbarStrength"); + pbarStrength->hide(); + // TODO make all this neat or at least static + /* px between pmLock and pbarStrength */ + _space = 5; + + /* the following code should not be used as teaching material in any kind */ + // set the widget height to that of a small icon + _widgetHeight = SmallIcon (NULL, TQIconSet::Automatic).height (); + // figure out the height of the text + _textHeight = kapp->fontMetrics ().size (AlignLeft | AlignVCenter | DontClip | ShowPrefix, _net.getDisplaySsid()).height (); + // the item is height of the text plus the default frame width + _height = _textHeight + kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); + /* _height needs to be at least the height of a SmallIcon plus a border of one px (top & bottom)*/ + if (_height < _widgetHeight) { + _height = _widgetHeight + 2; + } + + /* border required for pmLock and pbarStrength */ + _border = 1; + if (_border == kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth)) + _border += 2 * kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); + if (_border == 0) + _border ++; + + _width = kapp->fontMetrics().size(AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()).width(); /* essid */ + _width += SmallIcon (NULL, TQIconSet::Automatic).width (); /* pmLock */ + _width += _space; /* pmLock <-> pbarStrength */ + _width += 100; /* pbarStrength */ + _width += _space; /* pbarStrength -> contextMenu */ +} + +WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc) + : NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem () +{ + parent = p; + _adhoc = adhoc; + _net = net; + _dev = dev; + + pbarStrength = new TQProgressBar (this->parent, "pbarStrength"); + pbarStrength->hide(); + // TODO make all this neat or at least static + /* px between pmLock and pbarStrength */ + _space = 5; + + /* the following code should not be used as teaching material in any kind */ + // set the widget height to that of a small icon + _widgetHeight = SmallIcon (NULL, TQIconSet::Automatic).height (); + // figure out the height of the text + _textHeight = kapp->fontMetrics ().size (AlignLeft | AlignVCenter | DontClip | ShowPrefix, _net.getDisplaySsid()).height (); + // the item is height of the text plus the default frame width + _height = _textHeight + kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); + /* _height needs to be at least the height of a SmallIcon plus a border of one px (top & bottom)*/ + if (_height < _widgetHeight) { + _height = _widgetHeight + 2; + } + + /* border required for pmLock and pbarStrength */ + _border = 1; + if (_border == kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth)) + _border += 2 * kapp->style ().pixelMetric (TQStyle::PM_DefaultFrameWidth); + if (_border == 0) + _border ++; + + _width = kapp->fontMetrics().size(AlignLeft | AlignVCenter | DontClip | ShowPrefix, getDisplayText()).width(); /* essid */ + _width += SmallIcon (NULL, TQIconSet::Automatic).width (); /* pmLock */ + _width += _space; /* pmLock <-> pbarStrength */ + _width += 100; /* pbarStrength */ + _width += _space; /* pbarStrength -> contextMenu */ +} + +WirelessNetworkItem::~WirelessNetworkItem () +{ +} + + + +#include "tdenetman-wireless_menuitem.moc" diff --git a/tdenetworkmanager/src/tdenetman-wireless_menuitem.h b/tdenetworkmanager/src/tdenetman-wireless_menuitem.h new file mode 100644 index 0000000..0be3726 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_menuitem.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_WIRELESSMENUITEM_H +#define KNETWORKMANAGER_WIRELESSMENUITEM_H + +#include "tdenetman-menuitem.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "tdenetman-wireless_network.h" + +class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem +{ + Q_OBJECT + + public: + WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc); + WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc); + ~WirelessNetworkItem (); + + TQWidget* parent; + TQProgressBar* pbarStrength; + + void paint (TQPainter*, const TQColorGroup&, bool, bool, int, int, int, int); + TQSize sizeHint (); + + public slots: + void slotActivate(); + + private: + TQString getDisplayText(); + + bool _adhoc; + WirelessNetwork _net; + TDENetworkDevice* _dev; + TDEWiFiConnection* _conn; + + /* menu item */ + int _width; + int _height; + int _border; + + /* elements */ + int _textHeight; + int _widgetHeight; + + int _space; +}; + +#endif /* KNETWORKMANAGER_WIRELESSMENUITEM_H */ diff --git a/tdenetworkmanager/src/tdenetman-wireless_network.cpp b/tdenetworkmanager/src/tdenetman-wireless_network.cpp new file mode 100644 index 0000000..bd9dbff --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_network.cpp @@ -0,0 +1,174 @@ +/*************************************************************************** + * + * tdenetman-wireless_network.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// KNM includes +#include "tdenetman.h" +#include "tdenetman-wireless_network.h" + +// TDE includes +#include + +// TQt includes +#include +#include + +class WirelessNetworkPrivate +{ + public: + WirelessNetworkPrivate() + : active(false) + { + } + + ~WirelessNetworkPrivate() + { + } + + bool active; + + TQ_UINT32 match; + TQValueList aps; +}; + +WirelessNetwork::WirelessNetwork(const WirelessNetwork& other) +{ + d = new WirelessNetworkPrivate(*other.d); +} + +WirelessNetwork::WirelessNetwork(TQ_UINT32 match) +{ + d = new WirelessNetworkPrivate(); + + // which attributes have to match + d->match = match; +} + +WirelessNetwork::~WirelessNetwork() +{ + delete d; +} + +WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other) +{ + if (d) + delete d; + d = new WirelessNetworkPrivate(*other.d); + return *this; +} + +bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) +{ + if ( (d->match & MATCH_SSID) && getSsid() != ap->SSID) { + return false; + } + + // AP matches + return true; +} + +bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) +{ + if ( this->contains( ap ) || d->aps.isEmpty()) { + d->aps.append(ap); + return true; + } + return false; +} + +const TQByteArray WirelessNetwork::getSsid() const +{ + if ( !d->aps.isEmpty() ) { + return (*(d->aps.begin()))->SSID; + } + else { + return TQByteArray(); + } +} + +TQString WirelessNetwork::getDisplaySsid() const +{ + if (!d->aps.isEmpty()) { + return (*(d->aps.begin()))->friendlySSID(); + } + else { + return TQString(); + } +} + +TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const +{ + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { + flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); + flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); + } + return flags; +} + +TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const +{ + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + { + flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); + } + return flags; +} + +TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const +{ + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + { + flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); + } + return flags; +} + +bool WirelessNetwork::isEncrypted() const +{ + return (getFlags() & TDENetworkWiFiAPFlags::PrivacySupport); +} + +TQ_UINT8 WirelessNetwork::getStrength() const +{ + TQ_UINT8 strength = 0; + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { + if (((*it)->signalQuality*100.0) > strength) { + strength = ((*it)->signalQuality*100.0); + } + } + return strength; +} + +void WirelessNetwork::setActive(bool a) +{ + d->active=a; +} + +bool WirelessNetwork::getActive() const +{ + return d->active; +} + diff --git a/tdenetworkmanager/src/tdenetman-wireless_network.h b/tdenetworkmanager/src/tdenetman-wireless_network.h new file mode 100644 index 0000000..0970df1 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman-wireless_network.h @@ -0,0 +1,92 @@ +/*************************************************************************** + * + * tdenetman-wireless_network.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_WIRELESS_NETWORK_H +#define KNETWORKMANAGER_WIRELESS_NETWORK_H + +#include "tdenetman.h" + +#include + +#include +#include + +class KNetworkManager; +class WirelessNetworkPrivate; + +/* + A wireless network represents multiple accesspoints + that share the same essid and security-caps +*/ +class WirelessNetwork +{ + public: + // bitwise encoded enum + // allows the specification on how multiple APs get grouped together + enum MATCH_ATTRIBUTES + { + // only match APs with the same ssid + MATCH_SSID = 1 + }; + + WirelessNetwork(const WirelessNetwork& other); + WirelessNetwork (TQ_UINT32 match = MATCH_SSID); + ~WirelessNetwork (); + + WirelessNetwork& operator= (const WirelessNetwork&); + + // check if the AccessPoint represents the same net + bool contains(const TDENetworkWiFiAPInfo * const); + + // add an AP to the Network + bool addAP(const TDENetworkWiFiAPInfo * const); + + // combined flags of all APs + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const; + + // combined wpa-flags of all APs + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getWpaFlags() const; + + // combined rsn-flags of all APs + TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getRsnFlags() const; + + // ssid of all APs + const TQByteArray getSsid() const; + + TQString getDisplaySsid() const; + bool isEncrypted() const; + + // strength of the best AP + TQ_UINT8 getStrength() const; + + void setActive(bool active); + bool getActive() const; + + bool operator==(const WirelessNetwork&); + + private: + WirelessNetworkPrivate * d; +}; + +#endif /* KNETWORKMANAGER_WIRELESS_NETWORK_H */ diff --git a/tdenetworkmanager/src/tdenetman.cpp b/tdenetworkmanager/src/tdenetman.cpp new file mode 100644 index 0000000..adc3cf2 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * + * tdenetman.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +// TDE includes +#include +#include +#include +#include + +// KNM includes +#include "tdenetman.h" +#include "tdenetman-tray.h" + +#include + +// TQt includes +#include +#include + +// KDE includes +#include +#include + +extern TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global; + +class KNetworkManagerPrivate +{ + public: + KNetworkManagerPrivate() {} + ~KNetworkManagerPrivate() {} + static KNetworkManager* _ctx; +}; + +KNetworkManager* KNetworkManagerPrivate::_ctx = NULL; + +KNetworkManager* KNetworkManager::getInstance() +{ + return KNetworkManagerPrivate::_ctx; +} + +void +KNetworkManager::slotShutDown() +{ + // +} + +void KNetworkManager::timerEvent( TQTimerEvent *e ) +{ + Tray* tray = Tray::getInstance(); + tray->slotUpdateDeviceState(nm_device_state_global); +} + +KNetworkManager::KNetworkManager () : KUniqueApplication () +{ + d = new KNetworkManagerPrivate(); + d->_ctx = this; + + // we need to get informed when shutting down + connect(this, TQT_SIGNAL(shutDown()), this, TQT_SLOT(slotShutDown())); + + // create the main-tray-icon + Tray* tray = Tray::getInstance(); + tray->show(); + setMainWidget(tray); +} + +KNetworkManager::~KNetworkManager() +{ + delete d; +} + +#include "tdenetman.moc" + diff --git a/tdenetworkmanager/src/tdenetman.h b/tdenetworkmanager/src/tdenetman.h new file mode 100644 index 0000000..76dcb93 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * + * tdenetman.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2005 Novell, Inc. + * + * Author: Timo Hoenig , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_H +#define KNETWORKMANAGER_H + +// KDE includes +#include + +// KNM includes +#include "config.h" + +class KNetworkManagerPrivate; +class Device; + +class KNetworkManager : public KUniqueApplication +{ + Q_OBJECT + + + public: + KNetworkManager (); + ~KNetworkManager (); + + static KNetworkManager* getInstance (void); + + public slots: + void slotShutDown(); + private: + KNetworkManagerPrivate* d; + + protected: + void timerEvent( TQTimerEvent *e ); +}; + +#endif /* KNETWORKMANAGER_H */ diff --git a/tdenetworkmanager/src/tdenetman.la.cpp b/tdenetworkmanager/src/tdenetman.la.cpp new file mode 100644 index 0000000..3d480c4 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman.la.cpp @@ -0,0 +1,2 @@ +extern "C" int kdemain(int argc, char* argv[]); +int main(int argc, char* argv[]) { return kdemain(argc,argv); } diff --git a/tdenetworkmanager/src/tdenetman_dummy.cpp b/tdenetworkmanager/src/tdenetman_dummy.cpp new file mode 100644 index 0000000..efd89d8 --- /dev/null +++ b/tdenetworkmanager/src/tdenetman_dummy.cpp @@ -0,0 +1,3 @@ +#include +extern "C" int kdemain(int argc, char* argv[]); +extern "C" KDE_EXPORT int tdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); } diff --git a/tdenetworkmanager/src/tdenetworkmanager.desktop b/tdenetworkmanager/src/tdenetworkmanager.desktop new file mode 100644 index 0000000..c313d6f --- /dev/null +++ b/tdenetworkmanager/src/tdenetworkmanager.desktop @@ -0,0 +1,47 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=TDENetworkManager +Name[bn]=কে-নেটওয়ার্ক-ম্যানেজার +Name[sv]=TDEnetworkmanager +GenericName=Network Manager +GenericName[bn]=নেটওয়ার্ক ম্যানেজার +GenericName[br]=Merour rouedad +GenericName[da]=Netværkshåndtering +GenericName[de]=Netzwerkverwaltung +GenericName[el]=Διαχειριστής δικτύου +GenericName[es]=Gestor de red +GenericName[et]=Võrguhaldur +GenericName[it]=Gestore di rete +GenericName[ja]=ネットワークマネージャ +GenericName[nl]=Netwerkbeheer +GenericName[pt]=Gestor de Redes +GenericName[sr]=Управник мреже +GenericName[sr@Latn]=Upravnik mreže +GenericName[sv]=Nätverksverktyg +GenericName[tr]=Ağ Yöneticisi +Exec=tdenetworkmanager +Icon=tdenetworkmanager +Type=Application +Comment=A TDE frontend for NetworkManager +Comment[bg]=Интерфейс за NetworkManager (TDE) +Comment[bn]=নেটওয়ার্ক-ম্যানেজারের জন্য একটি কেডিই ফ্রন্ট-এন্ড +Comment[ca]=Un frontal del TDE per al NetworkManager +Comment[da]=En TDE-grænseflade for Networkmanager +Comment[de]=Eine TDE-Oberfläche für NetworkManager +Comment[el]=Μια διασύνδεση περιβάλλοντος για το NetworkManager +Comment[es]=Una interfaz de TDE a NetworkManager +Comment[et]=TDE NetworkManageri kasutajaliides +Comment[it]=Un front-end di NetworkManager per TDE +Comment[ja]=NetworkManager の TDE フロントエンド +Comment[nl]=Een TDE-schil voor NetworkManager +Comment[pt]=Uma interface para TDE do NetworkManager +Comment[sr]=TDE програм за NetworkManager +Comment[sr@Latn]=TDE program za NetworkManager +Comment[sv]=Ett gränssnitt till Networkmanager för TDE +Comment[tr]=NetworkManager için bir TDE ön yüzü +X-TDE-autostart-after=panel +X-TDE-StartupNotify=false +X-TDE-UniqueApplet=true +X-DCOP-ServiceType=Unique +X-TDE-autostart-condition=tdenetworkmanagerrc:General:Autostart:true +Categories=Qt;TDE;Network;Applet; diff --git a/tdenetworkmanager/src/tdenetworkmanager_plugin.desktop b/tdenetworkmanager/src/tdenetworkmanager_plugin.desktop new file mode 100644 index 0000000..d215c1f --- /dev/null +++ b/tdenetworkmanager/src/tdenetworkmanager_plugin.desktop @@ -0,0 +1,31 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=ServiceType +X-TDE-ServiceType=TDENetworkManager/Plugin +X-TDE-Derived=KPluginInfo +Name=TDENetworkManager Plugin +Name[et]=TDENetworkManageri plugin +Name[ja]=TDENetworkManager プラグイン +Name[sr]=Прикључак TDENetworkManager-а +Name[sr@Latn]=Прикључак TDENetworkManager-а +Name[sv]=Nätverkshantering insticksprogram +Comment=TDENetworkManager Plugin +Comment[bg]=Приставка за TDENetworkManager +Comment[bn]=কে-নেটওয়ার্ক-ম্যানেজার প্লাগিন +Comment[br]=Lugent TDENetworkManager +Comment[ca]=Connector del TDENetworkManager +Comment[da]=Netværkshåndtering-plugin +Comment[de]=TDENetworkManager-Modul +Comment[el]=Πρόσθετο του TDENetworkManager +Comment[es]=Complemento de TDENetworkManager +Comment[et]=TDENetworkManageri plugin +Comment[it]=Plugin di TDENetworkManager +Comment[ja]=TDENetworkManager プラグイン +Comment[nl]=TDENetworkManager-plugin +Comment[pt]='Plugin' do TDENetworkManager +Comment[sr]=Прикључак TDENetworkManager-а +Comment[sr@Latn]=Priključak TDENetworkManager-a +Comment[sv]=Nätverkshantering insticksprogram +Comment[tr]=TDENetworkManager Eklentisi +Comment[xx]=xxTDENetworkManager Pluginxx + diff --git a/tdenetworkmanager/src/tdenetworkmanager_vpnplugin.desktop b/tdenetworkmanager/src/tdenetworkmanager_vpnplugin.desktop new file mode 100644 index 0000000..9c7f5b3 --- /dev/null +++ b/tdenetworkmanager/src/tdenetworkmanager_vpnplugin.desktop @@ -0,0 +1,33 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=ServiceType +X-TDE-ServiceType=TDENetworkManager/VPNPlugin +X-TDE-Derived=TDENetworkManager/Plugin +Name=TDENetworkManager VPN Plugin +Name[et]=TDENetworkManageri VPN-plugin +Name[ja]=TDENetworkManager VPN プラグイン +Name[sr]=Прикључак TDENetworkManager-а за VPN +Name[sr@Latn]=Прикључак TDENetworkManager-а за VPN +Name[sv]=Nätverkshantering VPN-insticksprogram +Comment=TDENetworkManager VPN Plugin +Comment[bg]=VPN приставка за TDENetworkManager +Comment[bn]=কে-নেটওয়ার্ক-ম্যানেজার ভিপিএন প্লাগিন +Comment[br]=Lugent VPN evit TDENetworkManager +Comment[ca]=Connector VPN del TDENetworkManager +Comment[da]=TDENetworkManager VPN-plugin +Comment[de]=TDENetworkManager-VPN-Modul +Comment[el]=Πρόσθετο VPN του TDENetworkManager +Comment[es]=Complemento de VPN de TDENetworkManager +Comment[et]=TDENetworkManageri VPN-plugin +Comment[it]=Plugin VPN di TDENetworkManager +Comment[ja]=TDENetworkManager VPN プラグイン +Comment[nl]=TDENetworkManager VPN-plugin +Comment[pt]='Plugin' de VPN do TDENetworkManager +Comment[sr]=Прикључак TDENetworkManager-а за VPN +Comment[sr@Latn]=Priključak TDENetworkManager-a za VPN +Comment[sv]=Nätverkshantering VPN-insticksprogram +Comment[tr]=TDENetworkManager VPN Eklentisi +Comment[xx]=xxTDENetworkManager VPN Pluginxx + +[PropertyDef::X-NetworkManager-Services] +Type=TQString diff --git a/tdenetworkmanager/src/vpn_tray_component.cpp b/tdenetworkmanager/src/vpn_tray_component.cpp index 68ad8a1..f4f3534 100644 --- a/tdenetworkmanager/src/vpn_tray_component.cpp +++ b/tdenetworkmanager/src/vpn_tray_component.cpp @@ -33,15 +33,15 @@ // KNM includes #include "vpn_tray_component.h" -#include "knetworkmanager-menuitem.h" -#include "knetworkmanager-menu_subhead.h" -#include "knetworkmanager-connection_store.h" -#include "knetworkmanager-vpn_connection.h" -#include "knetworkmanager-nm_proxy.h" - -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-connection_setting_vpn.h" -#include "knetworkmanager-connection_settings_dialog.h" +#include "tdenetman-menuitem.h" +#include "tdenetman-menu_subhead.h" +#include "tdenetman-connection_store.h" +#include "tdenetman-vpn_connection.h" +#include "tdenetman-nm_proxy.h" + +#include "tdenetman-connection_setting_info.h" +#include "tdenetman-connection_setting_vpn.h" +#include "tdenetman-connection_settings_dialog.h" #include using namespace ConnectionSettings; diff --git a/tdenetworkmanager/src/vpn_tray_component.h b/tdenetworkmanager/src/vpn_tray_component.h index 2af5b55..a42ae83 100644 --- a/tdenetworkmanager/src/vpn_tray_component.h +++ b/tdenetworkmanager/src/vpn_tray_component.h @@ -1,6 +1,6 @@ /*************************************************************************** * - * knetworkmanager.h - A NetworkManager frontend for KDE + * tdenetman.h - A NetworkManager frontend for KDE * * Copyright (C) 2005, 2006 Novell, Inc. * @@ -28,7 +28,7 @@ // KNM includes #include "traycomponent.h" -#include "knetworkmanager.h" +#include "tdenetman.h" class VPNTrayComponent : public TrayComponent { diff --git a/tdenetworkmanager/tdenetworkmanager.conf b/tdenetworkmanager/tdenetworkmanager.conf new file mode 100644 index 0000000..82a596f --- /dev/null +++ b/tdenetworkmanager/tdenetworkmanager.conf @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1