From fed6fccc41db9ffac1b1e88411faa7e2debc8b71 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 6 Sep 2012 10:37:18 -0500 Subject: [PATCH] More API porting --- tdenetworkmanager/src/CMakeLists.txt | 10 +- tdenetworkmanager/src/devicetraycomponent.cpp | 84 ++++++----- tdenetworkmanager/src/devicetraycomponent.h | 56 +++++--- .../src/knetworkmanager-connection_editor.cpp | 98 ++++++------- .../src/knetworkmanager-connection_editor.h | 10 +- .../src/knetworkmanager-device_tray.h | 3 + .../src/knetworkmanager-wireless_manager.cpp | 136 ++++++++++-------- .../src/knetworkmanager-wireless_network.cpp | 34 ++--- ...workmanager-connection_settings_dialog.cpp | 28 ---- 9 files changed, 229 insertions(+), 230 deletions(-) diff --git a/tdenetworkmanager/src/CMakeLists.txt b/tdenetworkmanager/src/CMakeLists.txt index 9c89dfc..a379be9 100644 --- a/tdenetworkmanager/src/CMakeLists.txt +++ b/tdenetworkmanager/src/CMakeLists.txt @@ -57,10 +57,12 @@ tde_add_tdeinit_executable( knetworkmanager AUTOMOC knetworkmanager-menu_subhead.cpp sha1.cpp md5.cpp knetworkmanager-wireless_network.cpp knetworkmanager-wireless_manager.cpp - knetworkmanager-connection_editor.cpp knetworkmanager-plugin.cpp knetworkmanager-vpnplugin.cpp - knetworkmanager-pluginmanager.cpp knetworkmanager-vpnservice.cpp knetworkmanager-vpnmanager.cpp - knetworkmanager-vpnauthenticationdialog.cpp devicetraycomponent.cpp traycomponent.cpp - vpn_tray_component.cpp + knetworkmanager-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 + #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/devicetraycomponent.cpp b/tdenetworkmanager/src/devicetraycomponent.cpp index d0b0929..648ffa8 100644 --- a/tdenetworkmanager/src/devicetraycomponent.cpp +++ b/tdenetworkmanager/src/devicetraycomponent.cpp @@ -24,10 +24,7 @@ along with this program. If not, see . #include #include -#include "knetworkmanager-device.h" -#include "knetworkmanager-nm_proxy.h" - -TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { +TQString DeviceTrayComponent::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { @@ -40,7 +37,7 @@ TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStat return TQString::null; } -TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { +TQString DeviceTrayComponent::movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { @@ -53,7 +50,7 @@ TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatu return TQString::null; } -TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { +TQString DeviceTrayComponent::tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { @@ -66,7 +63,7 @@ TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionSta return TQString::null; } -DeviceTrayComponent::DeviceTrayComponent(Device * device, KSystemTray * parent, const char * name ) +DeviceTrayComponent::DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ) : TrayComponent(parent, name), m_device(device) { connect( m_device, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), TQT_SLOT(deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); @@ -107,9 +104,10 @@ TDENetworkDevice* DeviceTrayComponent::device() const TQStringList DeviceTrayComponent::getToolTipText() { TQStringList list; - TDENetworkConnectionStatus::TDENetworkConnectionStatus state = m_device->getState(); + TDENetworkConnectionManager* deviceConnMan = m_device->connectionManager(); + TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; if (tooltipForConnState(state) != "") { - list.append(i18n("Device: %1").arg(m_device->getInterface())); + list.append(i18n("Device: %1").arg(m_device->deviceNode())); list.append(i18n("State: %1").arg(tooltipForConnState(state))); } return list; @@ -118,55 +116,55 @@ TQStringList DeviceTrayComponent::getToolTipText() TQPixmap DeviceTrayComponent::pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - if (pixmapForConnState(state) != "") { - return KSystemTray::loadIcon(pixmapForConnState(state)); - } else { - return TQPixmap(); - } + if (pixmapForConnState(state) != "") { + return KSystemTray::loadIcon(pixmapForConnState(state)); + } + else { + return TQPixmap(); + } } TQMovie DeviceTrayComponent::movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - if (movieForConnState(state) != "") { - return TQMovie( KGlobal::iconLoader()->moviePath(movieForConnState(state), KIcon::Panel)); - } else { - return TQMovie(); - } + if (movieForConnState(state) != "") { + return TQMovie( KGlobal::iconLoader()->moviePath(movieForConnState(state), KIcon::Panel)); + } + else { + return TQMovie(); + } } void DeviceTrayComponent::setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString movie) { - m_movies[state] = movie; + m_movies[state] = movie; } void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString pixmap) { - m_pixmaps[state] = pixmap; + m_pixmaps[state] = pixmap; } void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - //check if our device now holds the default active connection - // if it is the default active connection - // or if it is activating. what if 2 devices are activating simultaneously? - NMProxy * nm = 0; - switch (state) { - case TDENetworkConnectionStatus::EstablishingLink: - emit needsCenterStage(this, true); - break; - case TDENetworkConnectionStatus::Connected: - nm = NMProxy::getInstance(); - if ( m_device == nm->getDefaultDevice() ) { - emit needsCenterStage(this, true); - } - break; - case TDENetworkConnectionStatus::LinkUnavailable: - case TDENetworkConnectionStatus::Disconnected: - case TDENetworkConnectionStatus::Failed: - emit needsCenterStage(this, false); - break; - default: - break; - } + //check if our device now holds the default active connection + // if it is the default active connection + // or if it is activating. what if 2 devices are activating simultaneously? + switch (state) { + case TDENetworkConnectionStatus::EstablishingLink: + emit needsCenterStage(this, true); + break; + case TDENetworkConnectionStatus::Connected: +// if ( m_device == nm->getDefaultDevice() ) { + emit needsCenterStage(this, true); +// } + break; + case TDENetworkConnectionStatus::LinkUnavailable: + case TDENetworkConnectionStatus::Disconnected: + case TDENetworkConnectionStatus::Failed: + emit needsCenterStage(this, false); + break; + default: + break; + } } #include "devicetraycomponent.moc" diff --git a/tdenetworkmanager/src/devicetraycomponent.h b/tdenetworkmanager/src/devicetraycomponent.h index e162020..52a9bea 100644 --- a/tdenetworkmanager/src/devicetraycomponent.h +++ b/tdenetworkmanager/src/devicetraycomponent.h @@ -37,28 +37,38 @@ class KSystemTray; class DeviceTrayComponent : public TrayComponent { -Q_OBJECT - -public: - DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ); - virtual ~DeviceTrayComponent(); - TQPixmap pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); - TQMovie movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); - virtual TQStringList getToolTipText(); - TDENetworkDevice* device() const; -signals: - void needsCenterStage(TrayComponent *, bool); -public slots: - virtual void newConnection() = 0; -protected slots: - void deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus); -protected: - void setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); - void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); -private: - TDENetworkDevice * m_device; - TQMap m_movies; - TQMap m_pixmaps; - TQMap m_tooltips; + Q_OBJECT + + public: + DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ); + virtual ~DeviceTrayComponent(); + TQPixmap pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + TQMovie movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + virtual TQStringList getToolTipText(); + TDENetworkDevice* device() const; + + signals: + void needsCenterStage(TrayComponent *, bool); + + public slots: + virtual void newConnection() = 0; + + protected slots: + void deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + + protected: + void setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); + void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); + + private: + TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); + + private: + TDENetworkDevice * m_device; + TQMap m_movies; + TQMap m_pixmaps; + TQMap m_tooltips; }; #endif // DEVICE_TRAY_COMPONENT_H diff --git a/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp b/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp index a80f014..6d2368f 100644 --- a/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp +++ b/tdenetworkmanager/src/knetworkmanager-connection_editor.cpp @@ -43,15 +43,8 @@ // knm headers #include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-wired_connection.h" -#include "knetworkmanager-wireless_connection.h" -#include "knetworkmanager-vpn_connection.h" -#include "knetworkmanager-connection_store.h" #include "knetworkmanager-connection_editor.h" #include "knetworkmanager-connection_settings_dialog.h" -#include "knetworkmanager-vpnservice.h" -#include "knetworkmanager-vpnmanager.h" using namespace ConnectionSettings; @@ -66,20 +59,22 @@ class ConnectionListViewItem : public KListViewItem : KListViewItem(parent) , _conn(connection) { - Info* info = _conn->getInfoSetting(); - if (info) - { - setText(0, info->getName()); - setText(1, info->getDevType()); + if (_conn) { + setText(0, _conn->friendlyName); + setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(_conn->type())); // TODO: Move to a Factory - if (info->getDevType() == NM_SETTING_WIRED_SETTING_NAME) + if (_conn->type() == TDENetworkConnectionType::WiredEthernet) { setPixmap(0, KGlobal::iconLoader()->loadIcon("wired", KIcon::Small)); - else if (info->getDevType() == NM_SETTING_WIRELESS_SETTING_NAME) + } + else if (_conn->type() == TDENetworkConnectionType::WiFi) { setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small)); - else if (info->getDevType() == NM_SETTING_VPN_SETTING_NAME) - setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small)); - else + } +// else if (_conn->type() == TDENetworkConnectionType::VPN) { +// setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small)); +// } + else { setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small)); + } } } @@ -109,8 +104,9 @@ ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, b 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())); +// if (!VPNManager::getVPNServices().isEmpty()) { +// popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); +// } pbNew->setPopup(popup); @@ -128,8 +124,9 @@ ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, b ConnectionEditorImpl::~ConnectionEditorImpl() { // remove the popupmenu - if (pbNew->popup()) + if (pbNew->popup()) { delete pbNew->popup(); + } } /* @@ -138,7 +135,7 @@ ConnectionEditorImpl::~ConnectionEditorImpl() void ConnectionEditorImpl::slotNewWirelessConnection() { // create a new wireless connection - slotEditNewConnection(new WirelessConnection()); + slotEditNewConnection(new TDEWiFiConnection()); } /* @@ -146,7 +143,7 @@ void ConnectionEditorImpl::slotNewWirelessConnection() */ void ConnectionEditorImpl::slotNewWiredConnection() { - slotEditNewConnection(new WiredConnection()); + slotEditNewConnection(new TDEWiredEthernetConnection()); } /* @@ -154,7 +151,7 @@ void ConnectionEditorImpl::slotNewWiredConnection() */ void ConnectionEditorImpl::slotNewVPNConnection() { - slotEditNewConnection(new VPNConnection()); +// slotEditNewConnection(new TDEVPNConnection()); } /* @@ -164,11 +161,11 @@ 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(slotRefershConnectionList())); + connect(dlg, TQT_SIGNAL(connectionSaved()), this, TQT_SLOT(slotRefreshConnectionList())); dlg->show(); } -void ConnectionEditorImpl::slotRefershConnectionList() +void ConnectionEditorImpl::slotRefreshConnectionList() { fillConnectionList(); } @@ -179,22 +176,25 @@ void ConnectionEditorImpl::slotRefershConnectionList() void ConnectionEditorImpl::slotEditCurrentConnection() { ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); - if (!item) + if (!item) { return; + } + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } TDENetworkConnection* conn = item->_conn; - Storage* storage = Storage::getInstance(); - bool hasSecretsStored = storage->hasSecretsStored(conn); // we need the secrets for editing - if (hasSecretsStored) - storage->restoreAllSecrets(conn); + 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) - storage->saveConnections(); + nm->saveConnection(conn); } @@ -204,16 +204,21 @@ void ConnectionEditorImpl::slotEditCurrentConnection() void ConnectionEditorImpl::slotRemoveCurrentConnection() { ConnectionListViewItem* item = dynamic_cast(lvConnections->currentItem()); - if (!item) + if (!item) { return; + } + + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } - ConnectionStore* cstore = ConnectionStore::getInstance(); TDENetworkConnection* conn = item->_conn; lvConnections->takeItem(item); delete item; - cstore->removeConnection(conn); + nm->deleteConnection(conn->UUID); } /* @@ -221,28 +226,17 @@ void ConnectionEditorImpl::slotRemoveCurrentConnection() */ void ConnectionEditorImpl::fillConnectionList() { - ConnectionStore* cstore = ConnectionStore::getInstance(); - TQValueList conns = cstore->getConnections(); - TQValueList::Iterator it = conns.begin(); + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } lvConnections->clear(); - for (; it != conns.end(); ++it) - { + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { TDENetworkConnection* conn = *it; - if (conn) - { - Info* info = conn->getInfoSetting(); - if (info) - { - new ConnectionListViewItem(lvConnections, conn); - } - else - kdWarning() << k_funcinfo << "Connection without Info setting, drop it." << endl; - } - else - kdWarning() << k_funcinfo << "non-generic connection, dropping it." << endl; - + new ConnectionListViewItem(lvConnections, conn); } } diff --git a/tdenetworkmanager/src/knetworkmanager-connection_editor.h b/tdenetworkmanager/src/knetworkmanager-connection_editor.h index e853787..83ec029 100644 --- a/tdenetworkmanager/src/knetworkmanager-connection_editor.h +++ b/tdenetworkmanager/src/knetworkmanager-connection_editor.h @@ -25,12 +25,16 @@ #ifndef KNETWORKMANAGER_CONNECTION_EDITOR_H #define KNETWORKMANAGER_CONNECTION_EDITOR_H -// qt headers +// tqt headers #include -// qt autogenerated headers +// tqt autogenerated headers #include "connection_editor.h" +// TDE headers +#include +#include + // knm headers #include "knetworkmanager-connection_setting.h" @@ -57,7 +61,7 @@ class ConnectionEditorImpl : public ConnectionEditor void slotNewWirelessConnection(); void slotNewWiredConnection(); void slotEditNewConnection(TDENetworkConnection* conn); - void slotRefershConnectionList(); + void slotRefreshConnectionList(); void slotNewVPNConnection(); private: diff --git a/tdenetworkmanager/src/knetworkmanager-device_tray.h b/tdenetworkmanager/src/knetworkmanager-device_tray.h index 60f6888..2ee1c87 100644 --- a/tdenetworkmanager/src/knetworkmanager-device_tray.h +++ b/tdenetworkmanager/src/knetworkmanager-device_tray.h @@ -42,6 +42,9 @@ #include #include +#include +#include + #include "knetworkmanager.h" class DeviceTrayPrivate; diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp index 2137939..baec85f 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp @@ -25,21 +25,8 @@ // other includes #include -// QT DBus -#include - // KNM includes #include "knetworkmanager-wireless_manager.h" -#include "knetworkmanager-wireless_device.h" -#include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-accesspoint.h" -#include "knetworkmanager-connection_store.h" -#include "knetworkmanager-wireless_connection.h" -#include "knetworkmanager-connection_setting_info.h" -#include "knetworkmanager-connection_setting_wireless.h" -#include "knetworkmanager-connection_setting_wireless_security.h" -#include "knetworkmanager-nm_proxy.h" -#include "knetworkmanager-devicestore.h" TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match) { @@ -56,17 +43,13 @@ TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevi // no hidden APs TDENetworkWiFiAPInfo * ap = *apit; if ( ap ) { - if (!ap->isValid()) - continue; - - if (ap->getSsid().count() == 0) + 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) ) - { + 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; @@ -84,8 +67,7 @@ TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevi } } - if (!found) - { + if (!found) { // create a new network-descriptor according to this ap WirelessNetwork net(match); net.addAP(ap); @@ -96,25 +78,39 @@ TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevi 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 dev->accessPoints(); + return internalGetAccessPoints(dev); } else { TQValueList aps; - DeviceStore* store = DeviceStore::getInstance(); - if (store) - { - TQValueList devs = store->getDevices(NM_DEVICE_TYPE_WIFI); - for (TQValueList::Iterator it = devs.begin(); it != devs.end(); ++it) - { + 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) - continue; - // add all APs from this device - aps +=wdev->accessPoints(); + if (wdev) { + aps += internalGetAccessPoints(wdev); + } } } return aps; @@ -124,43 +120,61 @@ TQValueList WirelessManager::getAccessPoints(TDENetworkDe TQValueList WirelessManager::getWirelessConnections() { TQValueList conns; - ConnectionStore* store = ConnectionStore::getInstance(); - // get all wireless connections - TQValueList connections = store->getConnections(NM_SETTING_WIRELESS_SETTING_NAME); - for (TQValueList::Iterator it = connections.begin(); it != connections.end(); ++it) - { - // cast to TDEWiFiConnection* - TDEWiFiConnection* wireless_conn = dynamic_cast(*it); - if (!wireless_conn) - continue; - conns.append(wireless_conn); + 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; + + 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 dev->accessPointsForEssid(essid); - else - { - TQValueList aps; - DeviceStore* store = DeviceStore::getInstance(); - if (store) - { - TQValueList devs = store->getDevices(NM_DEVICE_TYPE_WIFI); - for (TQValueList::Iterator it = devs.begin(); it != devs.end(); ++it) - { + 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) - continue; - // add all APs from this device - aps += wdev->accessPointsForEssid(essid); + if (wdev) { + aps += internalGetAccessPointsWithESSID(essid, wdev); + } } } - return aps; + return aps; } } diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp index 3b96bb2..b8328ee 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp @@ -79,8 +79,9 @@ WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other) bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) { - if ( (d->match & MATCH_SSID) && getSsid() != ap->getSsidByteArray()) + if ( (d->match & MATCH_SSID) && getSsid() != ap->SSID) { return false; + } // AP matches return true; @@ -88,8 +89,7 @@ bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) { - if ( this->contains( ap ) || d->aps.isEmpty()) - { + if ( this->contains( ap ) || d->aps.isEmpty()) { d->aps.append(ap); return true; } @@ -99,8 +99,9 @@ bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) const TQByteArray WirelessNetwork::getSsid() const { if ( !d->aps.isEmpty() ) { - return (*(d->aps.begin()))->getSsidByteArray(); - } else { + return (*(d->aps.begin()))->SSID; + } + else { return TQByteArray(); } } @@ -108,8 +109,9 @@ const TQByteArray WirelessNetwork::getSsid() const TQString WirelessNetwork::getDisplaySsid() const { if (!d->aps.isEmpty()) { - return (*(d->aps.begin()))->getDisplaySsid(); - } else { + return (*(d->aps.begin()))->friendlySSID(); + } + else { return TQString(); } } @@ -117,9 +119,9 @@ TQString WirelessNetwork::getDisplaySsid() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const { TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) - { - flags |= (*it)->getFlags(); + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { + flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); + flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); } return flags; } @@ -129,7 +131,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() cons TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { - flags |= (*it)->getWpaFlags(); + flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); } return flags; } @@ -139,7 +141,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() cons TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { - flags |= (*it)->getRsnFlags(); + flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); } return flags; } @@ -152,10 +154,10 @@ bool WirelessNetwork::isEncrypted() const TQ_UINT8 WirelessNetwork::getStrength() const { TQ_UINT8 strength = 0; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) - { - if ((*it)->getStrength() > strength) - strength = (*it)->getStrength(); + 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; } diff --git a/tdenetworkmanager/src/settings/knetworkmanager-connection_settings_dialog.cpp b/tdenetworkmanager/src/settings/knetworkmanager-connection_settings_dialog.cpp index cc3b8f7..88a3d11 100644 --- a/tdenetworkmanager/src/settings/knetworkmanager-connection_settings_dialog.cpp +++ b/tdenetworkmanager/src/settings/knetworkmanager-connection_settings_dialog.cpp @@ -294,35 +294,15 @@ int ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(Connection* conn) { if (conn->getType() == NM_SETTING_WIRELESS_SETTING_NAME) -#if NM_CHECK_VERSION(0,8,992) return NM_DEVICE_TYPE_WIFI; -#else - return DEVICE_TYPE_802_11_WIRELESS; -#endif else if (conn->getType() == NM_SETTING_WIRED_SETTING_NAME) -#if NM_CHECK_VERSION(0,8,992) return NM_DEVICE_TYPE_ETHERNET; -#else - return DEVICE_TYPE_802_3_ETHERNET; -#endif else if (conn->getType() == NM_SETTING_GSM_SETTING_NAME) -#if NM_CHECK_VERSION(0,8,992) return NM_DEVICE_TYPE_MODEM; -#else - return DEVICE_TYPE_GSM; -#endif else if (conn->getType() == NM_SETTING_CDMA_SETTING_NAME) -#if NM_CHECK_VERSION(0,8,992) return NM_DEVICE_TYPE_MODEM; -#else - return DEVICE_TYPE_CDMA; -#endif -#if NM_CHECK_VERSION(0,8,992) return NM_DEVICE_TYPE_UNKNOWN; -#else - return DEVICE_TYPE_UNKNOWN; -#endif } void @@ -353,20 +333,12 @@ ConnectionSettingsDialogImpl::slotConnect() { 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", _conn->getObjectPath(), device, act_conn, err); -#else - nm->ActivateConnectionAsync(id,NM_DBUS_SERVICE_USER_SETTINGS, _conn->getObjectPath(), device, act_conn, err); -#endif } else { // we need to call ActivateDevice async -#if NM_CHECK_VERSION(0,8,992) nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), TQT_DBusObjectPath(QCString(dev->getObjectPath())), _conn->getObjectPath(), err); -#else - nm->ActivateConnectionAsync(id, NM_DBUS_SERVICE_USER_SETTINGS, _conn->getObjectPath(), TQT_DBusObjectPath(TQCString(dev->getObjectPath())), _conn->getObjectPath(), err); -#endif } } }