More API porting

pull/1/head
Timothy Pearson 12 years ago
parent c5bbf78c1b
commit fed6fccc41

@ -57,10 +57,12 @@ tde_add_tdeinit_executable( knetworkmanager AUTOMOC
knetworkmanager-menu_subhead.cpp knetworkmanager-menu_subhead.cpp
sha1.cpp md5.cpp sha1.cpp md5.cpp
knetworkmanager-wireless_network.cpp knetworkmanager-wireless_manager.cpp knetworkmanager-wireless_network.cpp knetworkmanager-wireless_manager.cpp
knetworkmanager-connection_editor.cpp knetworkmanager-plugin.cpp knetworkmanager-vpnplugin.cpp knetworkmanager-connection_editor.cpp
knetworkmanager-pluginmanager.cpp knetworkmanager-vpnservice.cpp knetworkmanager-vpnmanager.cpp devicetraycomponent.cpp traycomponent.cpp
knetworkmanager-vpnauthenticationdialog.cpp devicetraycomponent.cpp traycomponent.cpp #knetworkmanager-plugin.cpp knetworkmanager-vpnplugin.cpp
vpn_tray_component.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 EMBED tdenetwork-connection-configwidgets-static tdenetwork-connection-settings-static
LINK tdecore-shared tdeui-shared kutils-shared ${DBUS_TQT_LIBRARIES} LINK tdecore-shared tdeui-shared kutils-shared ${DBUS_TQT_LIBRARIES}
) )

@ -24,10 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <klocale.h> #include <klocale.h>
#include <ksystemtray.h> #include <ksystemtray.h>
#include "knetworkmanager-device.h" TQString DeviceTrayComponent::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
#include "knetworkmanager-nm_proxy.h"
TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
@ -40,7 +37,7 @@ TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStat
return TQString::null; return TQString::null;
} }
TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TQString DeviceTrayComponent::movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
@ -53,7 +50,7 @@ TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatu
return TQString::null; return TQString::null;
} }
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TQString DeviceTrayComponent::tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
@ -66,7 +63,7 @@ TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionSta
return TQString::null; 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) : TrayComponent(parent, name), m_device(device)
{ {
connect( m_device, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), TQT_SLOT(deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); 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 DeviceTrayComponent::getToolTipText()
{ {
TQStringList list; TQStringList list;
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = m_device->getState(); TDENetworkConnectionManager* deviceConnMan = m_device->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
if (tooltipForConnState(state) != "") { 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))); list.append(i18n("State: %1").arg(tooltipForConnState(state)));
} }
return list; return list;
@ -118,55 +116,55 @@ TQStringList DeviceTrayComponent::getToolTipText()
TQPixmap DeviceTrayComponent::pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) TQPixmap DeviceTrayComponent::pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
if (pixmapForConnState(state) != "") { if (pixmapForConnState(state) != "") {
return KSystemTray::loadIcon(pixmapForConnState(state)); return KSystemTray::loadIcon(pixmapForConnState(state));
} else { }
return TQPixmap(); else {
} return TQPixmap();
}
} }
TQMovie DeviceTrayComponent::movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) TQMovie DeviceTrayComponent::movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
if (movieForConnState(state) != "") { if (movieForConnState(state) != "") {
return TQMovie( KGlobal::iconLoader()->moviePath(movieForConnState(state), KIcon::Panel)); return TQMovie( KGlobal::iconLoader()->moviePath(movieForConnState(state), KIcon::Panel));
} else { }
return TQMovie(); else {
} return TQMovie();
}
} }
void DeviceTrayComponent::setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString movie) void DeviceTrayComponent::setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString movie)
{ {
m_movies[state] = movie; m_movies[state] = movie;
} }
void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString pixmap) void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQString pixmap)
{ {
m_pixmaps[state] = pixmap; m_pixmaps[state] = pixmap;
} }
void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
//check if our device now holds the default active connection //check if our device now holds the default active connection
// if it is the default active connection // if it is the default active connection
// or if it is activating. what if 2 devices are activating simultaneously? // or if it is activating. what if 2 devices are activating simultaneously?
NMProxy * nm = 0; switch (state) {
switch (state) { case TDENetworkConnectionStatus::EstablishingLink:
case TDENetworkConnectionStatus::EstablishingLink: emit needsCenterStage(this, true);
emit needsCenterStage(this, true); break;
break; case TDENetworkConnectionStatus::Connected:
case TDENetworkConnectionStatus::Connected: // if ( m_device == nm->getDefaultDevice() ) {
nm = NMProxy::getInstance(); emit needsCenterStage(this, true);
if ( m_device == nm->getDefaultDevice() ) { // }
emit needsCenterStage(this, true); break;
} case TDENetworkConnectionStatus::LinkUnavailable:
break; case TDENetworkConnectionStatus::Disconnected:
case TDENetworkConnectionStatus::LinkUnavailable: case TDENetworkConnectionStatus::Failed:
case TDENetworkConnectionStatus::Disconnected: emit needsCenterStage(this, false);
case TDENetworkConnectionStatus::Failed: break;
emit needsCenterStage(this, false); default:
break; break;
default: }
break;
}
} }
#include "devicetraycomponent.moc" #include "devicetraycomponent.moc"

@ -37,28 +37,38 @@ class KSystemTray;
class DeviceTrayComponent : public TrayComponent class DeviceTrayComponent : public TrayComponent
{ {
Q_OBJECT Q_OBJECT
public: public:
DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ); DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name );
virtual ~DeviceTrayComponent(); virtual ~DeviceTrayComponent();
TQPixmap pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); TQPixmap pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
TQMovie movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); TQMovie movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
virtual TQStringList getToolTipText(); virtual TQStringList getToolTipText();
TDENetworkDevice* device() const; TDENetworkDevice* device() const;
signals:
void needsCenterStage(TrayComponent *, bool); signals:
public slots: void needsCenterStage(TrayComponent *, bool);
virtual void newConnection() = 0;
protected slots: public slots:
void deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus); virtual void newConnection() = 0;
protected:
void setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); protected slots:
void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString); void deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
private:
TDENetworkDevice * m_device; protected:
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies; void setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString);
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_pixmaps; void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString);
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_tooltips;
private:
TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
private:
TDENetworkDevice * m_device;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_pixmaps;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_tooltips;
}; };
#endif // DEVICE_TRAY_COMPONENT_H #endif // DEVICE_TRAY_COMPONENT_H

@ -43,15 +43,8 @@
// knm headers // knm headers
#include "knetworkmanager-connection_setting_info.h" #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_editor.h"
#include "knetworkmanager-connection_settings_dialog.h" #include "knetworkmanager-connection_settings_dialog.h"
#include "knetworkmanager-vpnservice.h"
#include "knetworkmanager-vpnmanager.h"
using namespace ConnectionSettings; using namespace ConnectionSettings;
@ -66,20 +59,22 @@ class ConnectionListViewItem : public KListViewItem
: KListViewItem(parent) : KListViewItem(parent)
, _conn(connection) , _conn(connection)
{ {
Info* info = _conn->getInfoSetting(); if (_conn) {
if (info) setText(0, _conn->friendlyName);
{ setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(_conn->type()));
setText(0, info->getName());
setText(1, info->getDevType());
// TODO: Move to a Factory // 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)); 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)); 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 if (_conn->type() == TDENetworkConnectionType::VPN) {
else // setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small));
// }
else {
setPixmap(0, KGlobal::iconLoader()->loadIcon("help", KIcon::Small)); 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("wireless", KIcon::Small), i18n("Wireless"), this, TQT_SLOT(slotNewWirelessConnection()));
popup->insertItem(KGlobal::iconLoader()->loadIcon("wired", KIcon::Small), i18n("Wired"), this, TQT_SLOT(slotNewWiredConnection())); popup->insertItem(KGlobal::iconLoader()->loadIcon("wired", KIcon::Small), i18n("Wired"), this, TQT_SLOT(slotNewWiredConnection()));
if (!VPNManager::getVPNServices().isEmpty()) // if (!VPNManager::getVPNServices().isEmpty()) {
popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); // popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection()));
// }
pbNew->setPopup(popup); pbNew->setPopup(popup);
@ -128,8 +124,9 @@ ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, b
ConnectionEditorImpl::~ConnectionEditorImpl() ConnectionEditorImpl::~ConnectionEditorImpl()
{ {
// remove the popupmenu // remove the popupmenu
if (pbNew->popup()) if (pbNew->popup()) {
delete pbNew->popup(); delete pbNew->popup();
}
} }
/* /*
@ -138,7 +135,7 @@ ConnectionEditorImpl::~ConnectionEditorImpl()
void ConnectionEditorImpl::slotNewWirelessConnection() void ConnectionEditorImpl::slotNewWirelessConnection()
{ {
// create a new wireless connection // create a new wireless connection
slotEditNewConnection(new WirelessConnection()); slotEditNewConnection(new TDEWiFiConnection());
} }
/* /*
@ -146,7 +143,7 @@ void ConnectionEditorImpl::slotNewWirelessConnection()
*/ */
void ConnectionEditorImpl::slotNewWiredConnection() void ConnectionEditorImpl::slotNewWiredConnection()
{ {
slotEditNewConnection(new WiredConnection()); slotEditNewConnection(new TDEWiredEthernetConnection());
} }
/* /*
@ -154,7 +151,7 @@ void ConnectionEditorImpl::slotNewWiredConnection()
*/ */
void ConnectionEditorImpl::slotNewVPNConnection() 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 // open a dialog for editing the connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, this, "connect_something", false, TQt::WDestructiveClose); 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(); dlg->show();
} }
void ConnectionEditorImpl::slotRefershConnectionList() void ConnectionEditorImpl::slotRefreshConnectionList()
{ {
fillConnectionList(); fillConnectionList();
} }
@ -179,22 +176,25 @@ void ConnectionEditorImpl::slotRefershConnectionList()
void ConnectionEditorImpl::slotEditCurrentConnection() void ConnectionEditorImpl::slotEditCurrentConnection()
{ {
ConnectionListViewItem* item = dynamic_cast<ConnectionListViewItem*>(lvConnections->currentItem()); ConnectionListViewItem* item = dynamic_cast<ConnectionListViewItem*>(lvConnections->currentItem());
if (!item) if (!item) {
return; return;
}
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (!nm) {
return;
}
TDENetworkConnection* conn = item->_conn; TDENetworkConnection* conn = item->_conn;
Storage* storage = Storage::getInstance();
bool hasSecretsStored = storage->hasSecretsStored(conn);
// we need the secrets for editing // we need the secrets for editing
if (hasSecretsStored) nm->loadConnectionSecrets(conn->UUID);
storage->restoreAllSecrets(conn);
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, this, "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, this, "connect_something", false, TQt::WDestructiveClose);
dlg->show(); dlg->show();
// save all connections (if not done already) // save all connections (if not done already)
storage->saveConnections(); nm->saveConnection(conn);
} }
@ -204,16 +204,21 @@ void ConnectionEditorImpl::slotEditCurrentConnection()
void ConnectionEditorImpl::slotRemoveCurrentConnection() void ConnectionEditorImpl::slotRemoveCurrentConnection()
{ {
ConnectionListViewItem* item = dynamic_cast<ConnectionListViewItem*>(lvConnections->currentItem()); ConnectionListViewItem* item = dynamic_cast<ConnectionListViewItem*>(lvConnections->currentItem());
if (!item) if (!item) {
return;
}
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (!nm) {
return; return;
}
ConnectionStore* cstore = ConnectionStore::getInstance();
TDENetworkConnection* conn = item->_conn; TDENetworkConnection* conn = item->_conn;
lvConnections->takeItem(item); lvConnections->takeItem(item);
delete item; delete item;
cstore->removeConnection(conn); nm->deleteConnection(conn->UUID);
} }
/* /*
@ -221,28 +226,17 @@ void ConnectionEditorImpl::slotRemoveCurrentConnection()
*/ */
void ConnectionEditorImpl::fillConnectionList() void ConnectionEditorImpl::fillConnectionList()
{ {
ConnectionStore* cstore = ConnectionStore::getInstance(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TQValueList<TDENetworkConnection*> conns = cstore->getConnections(); if (!nm) {
TQValueList<TDENetworkConnection*>::Iterator it = conns.begin(); return;
}
lvConnections->clear(); lvConnections->clear();
for (; it != conns.end(); ++it) TDENetworkConnectionList* allconmap = nm->connections();
{ for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDENetworkConnection* conn = *it; TDENetworkConnection* conn = *it;
if (conn) new ConnectionListViewItem(lvConnections, 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;
} }
} }

@ -25,12 +25,16 @@
#ifndef KNETWORKMANAGER_CONNECTION_EDITOR_H #ifndef KNETWORKMANAGER_CONNECTION_EDITOR_H
#define KNETWORKMANAGER_CONNECTION_EDITOR_H #define KNETWORKMANAGER_CONNECTION_EDITOR_H
// qt headers // tqt headers
#include <tqvaluelist.h> #include <tqvaluelist.h>
// qt autogenerated headers // tqt autogenerated headers
#include "connection_editor.h" #include "connection_editor.h"
// TDE headers
#include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
// knm headers // knm headers
#include "knetworkmanager-connection_setting.h" #include "knetworkmanager-connection_setting.h"
@ -57,7 +61,7 @@ class ConnectionEditorImpl : public ConnectionEditor
void slotNewWirelessConnection(); void slotNewWirelessConnection();
void slotNewWiredConnection(); void slotNewWiredConnection();
void slotEditNewConnection(TDENetworkConnection* conn); void slotEditNewConnection(TDENetworkConnection* conn);
void slotRefershConnectionList(); void slotRefreshConnectionList();
void slotNewVPNConnection(); void slotNewVPNConnection();
private: private:

@ -42,6 +42,9 @@
#include <tqprogressbar.h> #include <tqprogressbar.h>
#include <tqguardedptr.h> #include <tqguardedptr.h>
#include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
#include "knetworkmanager.h" #include "knetworkmanager.h"
class DeviceTrayPrivate; class DeviceTrayPrivate;

@ -25,21 +25,8 @@
// other includes // other includes
#include <time.h> #include <time.h>
// QT DBus
#include <tqdbusobjectpath.h>
// KNM includes // KNM includes
#include "knetworkmanager-wireless_manager.h" #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<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match) TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match)
{ {
@ -56,17 +43,13 @@ TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevi
// no hidden APs // no hidden APs
TDENetworkWiFiAPInfo * ap = *apit; TDENetworkWiFiAPInfo * ap = *apit;
if ( ap ) { if ( ap ) {
if (!ap->isValid()) if (ap->SSID.count() == 0) {
continue;
if (ap->getSsid().count() == 0)
continue; continue;
}
// check if we have a network matching this AP // check if we have a network matching this AP
for (TQValueList<WirelessNetwork>::Iterator netIt = nets.begin(); netIt != nets.end(); ++netIt) for (TQValueList<WirelessNetwork>::Iterator netIt = nets.begin(); netIt != nets.end(); ++netIt) {
{ if ((*netIt).contains(ap) ) {
if ((*netIt).contains(ap) )
{
// we alread have a network where this AP belongs to // we alread have a network where this AP belongs to
found = true; found = true;
@ -84,8 +67,7 @@ TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevi
} }
} }
if (!found) if (!found) {
{
// create a new network-descriptor according to this ap // create a new network-descriptor according to this ap
WirelessNetwork net(match); WirelessNetwork net(match);
net.addAP(ap); net.addAP(ap);
@ -96,25 +78,39 @@ TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevi
return nets; return nets;
} }
TQValueList<TDENetworkWiFiAPInfo*> internalGetAccessPoints(TDENetworkDevice* dev) {
TQValueList<TDENetworkWiFiAPInfo*> 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<TDENetworkWiFiAPInfo*>(neighbor);
if (!apInfo) {
continue;
}
list.append(apInfo);
}
}
return list;
}
TQValueList<TDENetworkWiFiAPInfo*> WirelessManager::getAccessPoints(TDENetworkDevice* dev) TQValueList<TDENetworkWiFiAPInfo*> WirelessManager::getAccessPoints(TDENetworkDevice* dev)
{ {
// build up AP list depending on one device or on all devices // build up AP list depending on one device or on all devices
if (dev) { if (dev) {
return dev->accessPoints(); return internalGetAccessPoints(dev);
} }
else { else {
TQValueList<TDENetworkWiFiAPInfo *> aps; TQValueList<TDENetworkWiFiAPInfo *> aps;
DeviceStore* store = DeviceStore::getInstance(); TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (store) if (hwdevices) {
{ TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
TQValueList<Device*> devs = store->getDevices(NM_DEVICE_TYPE_WIFI); for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) {
for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it)
{
TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it); TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it);
if (!wdev) if (wdev) {
continue; aps += internalGetAccessPoints(wdev);
// add all APs from this device }
aps +=wdev->accessPoints();
} }
} }
return aps; return aps;
@ -124,43 +120,61 @@ TQValueList<TDENetworkWiFiAPInfo*> WirelessManager::getAccessPoints(TDENetworkDe
TQValueList<TDEWiFiConnection*> WirelessManager::getWirelessConnections() TQValueList<TDEWiFiConnection*> WirelessManager::getWirelessConnections()
{ {
TQValueList<TDEWiFiConnection*> conns; TQValueList<TDEWiFiConnection*> conns;
ConnectionStore* store = ConnectionStore::getInstance();
// get all wireless connections TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TQValueList<Connection*> connections = store->getConnections(NM_SETTING_WIRELESS_SETTING_NAME); if (nm) {
for (TQValueList<Connection*>::Iterator it = connections.begin(); it != connections.end(); ++it) // get all wireless connections
{ TDENetworkConnectionList* allconmap = nm->connections();
// cast to TDEWiFiConnection* for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDEWiFiConnection* wireless_conn = dynamic_cast<TDEWiFiConnection*>(*it); TDEWiFiConnection* wireless_conn = dynamic_cast<TDEWiFiConnection*>(*it);
if (!wireless_conn) if (!wireless_conn) {
continue; continue;
conns.append(wireless_conn); }
conns.append(wireless_conn);
}
} }
return conns;
return conns;
}
TQValueList<TDENetworkWiFiAPInfo*> internalGetAccessPointsWithESSID(TQByteArray essid, TDENetworkDevice* dev) {
TQValueList<TDENetworkWiFiAPInfo*> 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<TDENetworkWiFiAPInfo*>(neighbor);
if (!apInfo) {
continue;
}
if (apInfo->SSID == essid) {
list.append(apInfo);
}
}
}
return list;
} }
TQValueList<TDENetworkWiFiAPInfo*> WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev) TQValueList<TDENetworkWiFiAPInfo*> WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev)
{ {
// build up AP list depending on one device or on all devices // build up AP list depending on one device or on all devices
if (dev) if (dev) {
return dev->accessPointsForEssid(essid); return internalGetAccessPointsWithESSID(essid, dev);
else }
{ else {
TQValueList<TDENetworkWiFiAPInfo*> aps; TQValueList<TDENetworkWiFiAPInfo*> aps;
DeviceStore* store = DeviceStore::getInstance(); TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (store) if (hwdevices) {
{ TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
TQValueList<Device*> devs = store->getDevices(NM_DEVICE_TYPE_WIFI); for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it) {
for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it)
{
TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it); TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it);
if (!wdev) if (wdev) {
continue; aps += internalGetAccessPointsWithESSID(essid, wdev);
// add all APs from this device }
aps += wdev->accessPointsForEssid(essid);
} }
} }
return aps; return aps;
} }
} }

@ -79,8 +79,9 @@ WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other)
bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) 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; return false;
}
// AP matches // AP matches
return true; return true;
@ -88,8 +89,7 @@ bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap)
bool WirelessNetwork::addAP(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); d->aps.append(ap);
return true; return true;
} }
@ -99,8 +99,9 @@ bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap)
const TQByteArray WirelessNetwork::getSsid() const const TQByteArray WirelessNetwork::getSsid() const
{ {
if ( !d->aps.isEmpty() ) { if ( !d->aps.isEmpty() ) {
return (*(d->aps.begin()))->getSsidByteArray(); return (*(d->aps.begin()))->SSID;
} else { }
else {
return TQByteArray(); return TQByteArray();
} }
} }
@ -108,8 +109,9 @@ const TQByteArray WirelessNetwork::getSsid() const
TQString WirelessNetwork::getDisplaySsid() const TQString WirelessNetwork::getDisplaySsid() const
{ {
if (!d->aps.isEmpty()) { if (!d->aps.isEmpty()) {
return (*(d->aps.begin()))->getDisplaySsid(); return (*(d->aps.begin()))->friendlySSID();
} else { }
else {
return TQString(); return TQString();
} }
} }
@ -117,9 +119,9 @@ TQString WirelessNetwork::getDisplaySsid() const
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const
{ {
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) {
{ flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask);
flags |= (*it)->getFlags(); flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask);
} }
return flags; return flags;
} }
@ -129,7 +131,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() cons
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= (*it)->getWpaFlags(); flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask);
} }
return flags; return flags;
} }
@ -139,7 +141,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() cons
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= (*it)->getRsnFlags(); flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask);
} }
return flags; return flags;
} }
@ -152,10 +154,10 @@ bool WirelessNetwork::isEncrypted() const
TQ_UINT8 WirelessNetwork::getStrength() const TQ_UINT8 WirelessNetwork::getStrength() const
{ {
TQ_UINT8 strength = 0; TQ_UINT8 strength = 0;
for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) {
{ if (((*it)->signalQuality*100.0) > strength) {
if ((*it)->getStrength() > strength) strength = ((*it)->signalQuality*100.0);
strength = (*it)->getStrength(); }
} }
return strength; return strength;
} }

@ -294,35 +294,15 @@ int
ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(Connection* conn) ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(Connection* conn)
{ {
if (conn->getType() == NM_SETTING_WIRELESS_SETTING_NAME) if (conn->getType() == NM_SETTING_WIRELESS_SETTING_NAME)
#if NM_CHECK_VERSION(0,8,992)
return NM_DEVICE_TYPE_WIFI; return NM_DEVICE_TYPE_WIFI;
#else
return DEVICE_TYPE_802_11_WIRELESS;
#endif
else if (conn->getType() == NM_SETTING_WIRED_SETTING_NAME) else if (conn->getType() == NM_SETTING_WIRED_SETTING_NAME)
#if NM_CHECK_VERSION(0,8,992)
return NM_DEVICE_TYPE_ETHERNET; return NM_DEVICE_TYPE_ETHERNET;
#else
return DEVICE_TYPE_802_3_ETHERNET;
#endif
else if (conn->getType() == NM_SETTING_GSM_SETTING_NAME) else if (conn->getType() == NM_SETTING_GSM_SETTING_NAME)
#if NM_CHECK_VERSION(0,8,992)
return NM_DEVICE_TYPE_MODEM; return NM_DEVICE_TYPE_MODEM;
#else
return DEVICE_TYPE_GSM;
#endif
else if (conn->getType() == NM_SETTING_CDMA_SETTING_NAME) else if (conn->getType() == NM_SETTING_CDMA_SETTING_NAME)
#if NM_CHECK_VERSION(0,8,992)
return NM_DEVICE_TYPE_MODEM; return NM_DEVICE_TYPE_MODEM;
#else
return DEVICE_TYPE_CDMA;
#endif
#if NM_CHECK_VERSION(0,8,992)
return NM_DEVICE_TYPE_UNKNOWN; return NM_DEVICE_TYPE_UNKNOWN;
#else
return DEVICE_TYPE_UNKNOWN;
#endif
} }
void void
@ -353,20 +333,12 @@ ConnectionSettingsDialogImpl::slotConnect()
{ {
TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection();
TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); 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); 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 else
{ {
// we need to call ActivateDevice async // 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); 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
} }
} }
} }

Loading…
Cancel
Save