Convert various wireless elements to the new TDE API

pull/1/head
Timothy Pearson 12 years ago
parent 4c69808733
commit 26cdc6b2b5

@ -49,10 +49,6 @@
#include <kconfig.h> #include <kconfig.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include "knetworkmanager-connection.h"
#include "knetworkmanager-device.h"
#include "knetworkmanager-nm_proxy.h"
using namespace ConnectionSettings; using namespace ConnectionSettings;
class NetworkMenuItemPrivate class NetworkMenuItemPrivate
@ -71,48 +67,47 @@ class NetworkMenuItemPrivate
void NetworkMenuItem::slotActivate() void NetworkMenuItem::slotActivate()
{ {
int id;
TQT_DBusError err;
kdDebug() << "NetworkMenuItem::slotActivate()" << endl; kdDebug() << "NetworkMenuItem::slotActivate()" << endl;
NMProxy* nm = NMProxy::getInstance();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (d->dev && d->conn) if (d->dev && d->conn)
{ {
NMProxy* nm = NMProxy::getInstance(); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if (nm) if (deviceConnMan)
{
kdDebug() << "Activate Connection " << d->conn->getObjectPath().data() << " on Device " << d->dev->getObjectPath().ascii() << endl;
printf("Activate Connection %s on Device %s\n\r", d->conn->getObjectPath().data(), d->dev->getObjectPath().ascii());
#if NM_CHECK_VERSION(0,8,992)
if (nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", d->conn->getObjectPath(), TQT_DBusObjectPath(QCString(d->dev->getObjectPath())), d->conn->getObjectPath(), err))
#else
if (nm->ActivateConnectionAsync(id, NM_DBUS_SERVICE_USER_SETTINGS, d->conn->getObjectPath(), TQT_DBusObjectPath(TQCString(d->dev->getObjectPath())), d->conn->getObjectPath(), err))
#endif
{ {
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 else {
kdDebug() << "ActivateDevice failed" << endl; kdDebug() << "ActivateDevice failed" << endl;
} }
} }
}
else if (d->conn) else if (d->conn)
{ {
// no device given, just take the default device // no device given, just take the default device
printf("Activate Connection %s on default device\n\r", d->conn->getObjectPath().data()); printf("Activate Connection %s on default device\n\r", d->conn->UUID.ascii());
TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection();
TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(d->conn->UUID);
#if NM_CHECK_VERSION(0,8,992) if ((result == TDENetworkConnectionStatus::Disconnected)
nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", d->conn->getObjectPath(), device, act_conn, err); || (result == TDENetworkConnectionStatus::Invalid)) {
#else //
nm->ActivateConnectionAsync(id,NM_DBUS_SERVICE_USER_SETTINGS, d->conn->getObjectPath(), device, act_conn, err); }
#endif else {
kdDebug() << "ActivateConnection failed" << endl;
}
} }
else else
kdDebug() << "Device or Connection invalid" << endl; kdDebug() << "Device or Connection invalid" << endl;
} }
NetworkMenuItem::NetworkMenuItem (Device* dev, Connection* conn, TQObject* parent, const char* name) NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name)
: TQObject(parent, name) : TQObject(parent, name)
{ {
d = new NetworkMenuItemPrivate(dev, conn); d = new NetworkMenuItemPrivate(dev, conn);

@ -28,6 +28,9 @@
#include <tqobject.h> #include <tqobject.h>
#include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
class Device; class Device;
class NetworkMenuItemPrivate; class NetworkMenuItemPrivate;

@ -69,9 +69,11 @@ TQStringList WirelessDeviceTray::getToolTipText()
{ {
TQStringList tooltip = DeviceTrayComponent::getToolTipText(); TQStringList tooltip = DeviceTrayComponent::getToolTipText();
TDENetworkWiFiAPInfo * ap = d->dev->getActiveAccessPoint(); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if (ap) TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
tooltip.append(i18n("Network: %1").arg(ap->getDisplaySsid())); if (ap) {
tooltip.append(i18n("Network: %1").arg(ap->friendlySSID()));
}
return tooltip; return tooltip;
} }
@ -79,26 +81,24 @@ TQStringList WirelessDeviceTray::getToolTipText()
void WirelessDeviceTray::newConnection() void WirelessDeviceTray::newConnection()
{ {
// create a new wireless connection // create a new wireless connection
Connection* conn = new TDEWiFiConnection(); TDENetworkConnection* conn = new TDEWiFiConnection();
// open a dialog for editing the connection // open a dialog for editing the connection
use_new_wireless_essid = 0; // deactivate autofill for now use_new_wireless_essid = 0; // deactivate autofill for now
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, NULL, tray(), "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose);
dlg->show(); dlg->show();
} }
bool WirelessDeviceTray::findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList<WirelessNetwork>& nets, WirelessNetwork& net) bool WirelessDeviceTray::findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList<WirelessNetwork>& nets, WirelessNetwork& net)
{ {
Wireless* wireless = conn->getWirelessSetting(); const TDEWiFiConnection* wireless = dynamic_cast<const TDEWiFiConnection*>(conn);
WirelessSecurity* security = conn->getWirelessSecuritySetting();
if (!wireless && !security) if (!wireless) {
return false; return false;
}
for (TQValueList<WirelessNetwork>::ConstIterator it = nets.begin(); it != nets.end(); ++it) for (TQValueList<WirelessNetwork>::ConstIterator it = nets.begin(); it != nets.end(); ++it) {
{ if (wireless->SSID == (*it).getSsid()) {
if (wireless->getEssid() == (*it).getSsid())
{
net = *it; net = *it;
return true; return true;
} }
@ -109,16 +109,14 @@ bool WirelessDeviceTray::findMatchingNetwork(const TDEWiFiConnection* conn, cons
TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetwork& net, const TQValueList<TDEWiFiConnection*>& connections) TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetwork& net, const TQValueList<TDEWiFiConnection*>& connections)
{ {
// try to find a connection matching this network // try to find a connection matching this network
for (TQValueList<TDEWiFiConnection*>::ConstIterator it = connections.begin(); it != connections.end(); ++it) for (TQValueList<TDEWiFiConnection*>::ConstIterator it = connections.begin(); it != connections.end(); ++it) {
{ const TDEWiFiConnection* wireless = dynamic_cast<const TDEWiFiConnection*>(*it);
Wireless* wireless = (*it)->getWirelessSetting();
WirelessSecurity* security = (*it)->getWirelessSecuritySetting();
// should not happen but its ever better to check if (!wireless) {
if (!wireless || !security)
continue; continue;
}
if (wireless->getEssid() == net.getSsid()) if (wireless->SSID == net.getSsid())
{ {
return *it; return *it;
} }
@ -138,10 +136,13 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections(); TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections();
// get the currently active connection // get the currently active connection
NMProxy* nm = NMProxy::getInstance(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
Connection* active_conn = nm->getActiveConnection(d->dev); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if (active_conn) TDENetworkConnection* active_conn = NULL;
kdDebug() << active_conn->getObjectPath().data() << endl; if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
}
// add all wireless connections in range // add all wireless connections in range
// (we may have more then one connection per network) // (we may have more then one connection per network)
@ -160,7 +161,7 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
*it, *it,
false); false);
int id = menu->insertItem (wirelessNetworkItem, -1, -1); int id = menu->insertItem (wirelessNetworkItem, -1, -1);
menu->setItemChecked(id, ((Connection*)(*it) == active_conn)); menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn));
menu->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate())); menu->connectItem(id, wirelessNetworkItem, TQT_SLOT(slotActivate()));
} }
@ -177,11 +178,11 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
if ( findMatchingNetwork(*it, nets, net) ) if ( findMatchingNetwork(*it, nets, net) )
continue; continue;
Info* info = (*it)->getInfoSetting(); TDEWiFiConnection* wireless = dynamic_cast<const TDEWiFiConnection*>(*it);
Wireless* wireless = (*it)->getWirelessSetting();
if (!info || !wireless) if (!wireless) {
continue; continue;
}
wirelessNetworkItem = new WirelessNetworkItem (menu, wirelessNetworkItem = new WirelessNetworkItem (menu,
d->dev, d->dev,
@ -201,7 +202,6 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
// // List available unsaved networks // // List available unsaved networks
TQPopupMenu* newpopup = new TQPopupMenu(menu); TQPopupMenu* newpopup = new TQPopupMenu(menu);
TDEWiFiConnection* newconn;
uint newnetworkItemsAdded = 0; uint newnetworkItemsAdded = 0;
TQValueList<WirelessNetwork> newnets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID); TQValueList<WirelessNetwork> newnets = WirelessManager::getWirelessNetworks(0, WirelessNetwork::MATCH_SSID);
@ -234,23 +234,23 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
void WirelessDeviceTray::addMenuItems(KPopupMenu* menu) void WirelessDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
NMProxy* nm = NMProxy::getInstance(); // get the currently active connection
TQT_DBusError err; TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(d->dev->getInterface()), SmallIcon("wireless", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wireless", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1); menu->insertItem (subhead, -1, -1);
// bolding subhead instead // bolding subhead instead
//menu->insertSeparator(); //menu->insertSeparator();
if (!nm->getWirelessEnabled(err)) if (!nm->wiFiEnabled())
{ {
// wireless disabled -> do not show any connections // wireless disabled -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled"), SmallIcon("no", TQIconSet::Automatic)); subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled"), SmallIcon("no", TQIconSet::Automatic));
menu->insertItem(subhead, -1, -1); menu->insertItem(subhead, -1, -1);
} }
else if (!nm->getWirelessHardwareEnabled(err)) else if (!nm->wiFiHardwareEnabled())
{ {
// wireless disabled -> do not show any connections // wireless disabled -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled by Killswitch"), SmallIcon("no", TQIconSet::Automatic)); subhead = new Subhead(menu, "subhead2", i18n("Wireless disabled by Killswitch"), SmallIcon("no", TQIconSet::Automatic));
@ -263,33 +263,49 @@ void WirelessDeviceTray::addMenuItems(KPopupMenu* menu)
// bring the device down // bring the device down
KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); KAction* deactivate = tray()->actionCollection()->action("deactivate_device");
if (deactivate) if (deactivate) {
deactivate->plug(menu); deactivate->plug(menu);
} }
}
menu->insertSeparator(); 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) void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
slotCheckActiveAccessPoint(); slotCheckActiveAccessPoint();
if (state == NM_DEVICE_STATE_ACTIVATED)
{
// trigger an update of the connections seen bssids property
TDENetworkWiFiAPInfo * ap = d->dev->getActiveAccessPoint(); 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) { if (ap) {
int strength = ap->getStrength(); int strength = (ap->signalQuality*100.0);
if (strength > 80) if (strength > 80) {
setPixmapForState((TDENetworkConnectionStatus::TDENetworkConnectionStatus)state, "nm_signal_100"); setPixmapForStates(state, "nm_signal_100");
else if (strength > 55) }
setPixmapForState((TDENetworkConnectionStatus::TDENetworkConnectionStatus)state, "nm_signal_75"); else if (strength > 55) {
else if (strength > 30) setPixmapForStates(state, "nm_signal_75");
setPixmapForState((TDENetworkConnectionStatus::TDENetworkConnectionStatus)state, "nm_signal_50"); }
else if (strength > 5) else if (strength > 30) {
setPixmapForState((TDENetworkConnectionStatus::TDENetworkConnectionStatus)state, "nm_signal_25"); setPixmapForStates(state, "nm_signal_50");
else }
setPixmapForState((TDENetworkConnectionStatus::TDENetworkConnectionStatus)state, "nm_signal_00"); else if (strength > 5) {
setPixmapForStates(state, "nm_signal_25");
}
else {
setPixmapForStates(state, "nm_signal_00");
}
} }
} }
} }
@ -298,42 +314,64 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
{ {
// the active AP changed, if a connection is already active we have roamed // the active AP changed, if a connection is already active we have roamed
// thus add the bssid to the list of seen bssids // thus add the bssid to the list of seen bssids
NMProxy* nm = NMProxy::getInstance();
if (!nm)
return;
TDEWiFiConnection* active_conn = dynamic_cast<TDEWiFiConnection*>(nm->getActiveConnection(d->dev)); // get the currently active connection
if (active_conn && d->dev->getState() == NM_DEVICE_STATE_ACTIVATED) TDEGlobalNetworkManager* nm = KGlobal::networkManager();
{ TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if ( d->dev->getActiveAccessPoint() != d->activeAccessPoint) { TDENetworkConnection* active_conn = NULL;
if (!d->activeAccessPoint.isNull()) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
disconnect( d->activeAccessPoint, TQT_SIGNAL(strengthChanged(TQ_UINT8)), this, TQT_SLOT(apStrengthChanged(TQ_UINT8))); && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
}
d->activeAccessPoint = d->dev->getActiveAccessPoint(); 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 ) { if ( d->activeAccessPoint ) {
connect( d->activeAccessPoint, TQT_SIGNAL(strengthChanged(TQ_UINT8)), this, TQT_SLOT(apStrengthChanged(TQ_UINT8))); connect( deviceConnMan, TQT_SIGNAL(accessPointStatusChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)), this, TQT_SLOT(apPropertyChanged(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType)));
ConnectionSettings::Wireless* wireless = active_conn->getWirelessSetting(); TDEWiFiConnection* wireless = dynamic_cast<TDEWiFiConnection*>(active_conn);
wireless->addSeenBssid(d->activeAccessPoint->getHwAddress()); if (wireless) {
if (!(wireless->heardBSSIDs.contains(d->activeAccessPoint->BSSID))) {
wireless->heardBSSIDs.append(d->activeAccessPoint->BSSID);
}
}
} }
} }
} }
} }
void WirelessDeviceTray::apStrengthChanged(TQ_UINT8 strength) void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event)
{ {
kdDebug() << k_funcinfo << (uint)strength << endl; if (event == TDENetworkAPEventType::SignalStrengthChanged) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = device()->getState(); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if (strength > 80) TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID);
setPixmapForState(state, "nm_signal_100"); if (ap) {
else if (strength > 55) TQ_UINT32 strength = (ap->signalQuality*100.0);
setPixmapForState(state, "nm_signal_75"); kdDebug() << k_funcinfo << strength << endl;
else if (strength > 30) TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
setPixmapForState(state, "nm_signal_50"); if (strength > 80) {
else if (strength > 5) setPixmapForStates(state, "nm_signal_100");
setPixmapForState(state, "nm_signal_25"); }
else else if (strength > 55) {
setPixmapForState(state, "nm_signal_00"); 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(); emit uiUpdated();
}
}
} }
void WirelessDeviceTray::slotAccessPointAdded(TDENetworkWiFiAPInfo* ap) void WirelessDeviceTray::slotAccessPointAdded(TDENetworkWiFiAPInfo* ap)
@ -353,11 +391,11 @@ WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * par
d->dev = dev; d->dev = dev;
// we want other icons for wireless devices // we want other icons for wireless devices
setPixmapForState(NM_DEVICE_STATE_UNKNOWN, "wireless_off"); setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off");
setPixmapForState(NM_DEVICE_STATE_UNAVAILABLE, "wireless_off"); setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off");
setPixmapForState(NM_DEVICE_STATE_UNMANAGED, "wireless_off"); setPixmapForState(TDENetworkConnectionStatus::UnManaged, "wireless_off");
setPixmapForState(NM_DEVICE_STATE_DISCONNECTED, "wireless"); setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless");
setPixmapForState(NM_DEVICE_STATE_ACTIVATED, "nm_signal_50"); setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_signal_50");
// get notified when the device state changes // get notified when the device state changes
connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus))); connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus)));

@ -58,7 +58,7 @@ class WirelessDeviceTray : public DeviceTrayComponent
void slotCheckActiveAccessPoint(); void slotCheckActiveAccessPoint();
void newConnection(); void newConnection();
protected slots: protected slots:
void apStrengthChanged(TQ_UINT8 strength); void apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event);
void slotAccessPointAdded(TDENetworkWiFiAPInfo*); void slotAccessPointAdded(TDENetworkWiFiAPInfo*);
void slotAccessPointRemoved(const TQString&); void slotAccessPointRemoved(const TQString&);
@ -68,6 +68,7 @@ class WirelessDeviceTray : public DeviceTrayComponent
TQValueList<TDEWiFiConnection*> getWirelessConnections(); TQValueList<TDEWiFiConnection*> getWirelessConnections();
TDEWiFiConnection* findMatchingConnection(const WirelessNetwork& net, const TQValueList<TDEWiFiConnection*>& connection); TDEWiFiConnection* findMatchingConnection(const WirelessNetwork& net, const TQValueList<TDEWiFiConnection*>& connection);
bool findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList<WirelessNetwork>& nets, WirelessNetwork& net); bool findMatchingNetwork(const TDEWiFiConnection* conn, const TQValueList<WirelessNetwork>& nets, WirelessNetwork& net);
void setPixmapForStates(TDENetworkConnectionStatus::TDENetworkConnectionStatus states, TQString pixmap);
WirelessDeviceTrayPrivate* d; WirelessDeviceTrayPrivate* d;

@ -45,7 +45,7 @@
#define NM_CHECK_VERSION(x,y,z) 0 #define NM_CHECK_VERSION(x,y,z) 0
#endif #endif
TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(WirelessDevice* dev, TQ_UINT32 match) TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match)
{ {
TQValueList<WirelessNetwork> nets; TQValueList<WirelessNetwork> nets;
TQValueList<AccessPoint*> aps; TQValueList<AccessPoint*> aps;
@ -100,7 +100,7 @@ TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(WirelessDevice
return nets; return nets;
} }
TQValueList<AccessPoint*> WirelessManager::getAccessPoints(WirelessDevice* dev) TQValueList<AccessPoint*> 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) {
@ -118,7 +118,7 @@ TQValueList<AccessPoint*> WirelessManager::getAccessPoints(WirelessDevice* dev)
#endif #endif
for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it) for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it)
{ {
WirelessDevice* wdev = dynamic_cast<WirelessDevice*>(*it); TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it);
if (!wdev) if (!wdev)
continue; continue;
// add all APs from this device // add all APs from this device
@ -129,17 +129,17 @@ TQValueList<AccessPoint*> WirelessManager::getAccessPoints(WirelessDevice* dev)
} }
} }
TQValueList<WirelessConnection*> WirelessManager::getWirelessConnections() TQValueList<TDEWiFiConnection*> WirelessManager::getWirelessConnections()
{ {
TQValueList<WirelessConnection*> conns; TQValueList<TDEWiFiConnection*> conns;
ConnectionStore* store = ConnectionStore::getInstance(); ConnectionStore* store = ConnectionStore::getInstance();
// get all wireless connections // get all wireless connections
TQValueList<Connection*> connections = store->getConnections(NM_SETTING_WIRELESS_SETTING_NAME); TQValueList<Connection*> connections = store->getConnections(NM_SETTING_WIRELESS_SETTING_NAME);
for (TQValueList<Connection*>::Iterator it = connections.begin(); it != connections.end(); ++it) for (TQValueList<Connection*>::Iterator it = connections.begin(); it != connections.end(); ++it)
{ {
// cast to WirelessConnection* // cast to TDEWiFiConnection*
WirelessConnection* wireless_conn = dynamic_cast<WirelessConnection*>(*it); TDEWiFiConnection* wireless_conn = dynamic_cast<TDEWiFiConnection*>(*it);
if (!wireless_conn) if (!wireless_conn)
continue; continue;
conns.append(wireless_conn); conns.append(wireless_conn);
@ -147,7 +147,7 @@ TQValueList<WirelessConnection*> WirelessManager::getWirelessConnections()
return conns; return conns;
} }
TQValueList<AccessPoint*> WirelessManager::getAccessPointsForEssid(TQByteArray essid, WirelessDevice* dev) TQValueList<AccessPoint*> 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)
@ -165,7 +165,7 @@ TQValueList<AccessPoint*> WirelessManager::getAccessPointsForEssid(TQByteArray e
#endif #endif
for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it) for (TQValueList<Device*>::Iterator it = devs.begin(); it != devs.end(); ++it)
{ {
WirelessDevice* wdev = dynamic_cast<WirelessDevice*>(*it); TDENetworkDevice* wdev = dynamic_cast<TDENetworkDevice*>(*it);
if (!wdev) if (!wdev)
continue; continue;
// add all APs from this device // add all APs from this device

@ -44,16 +44,16 @@ class WirelessManager
public: public:
// get all accesspoints from device dev or from all devices if dev is NULL // get all accesspoints from device dev or from all devices if dev is NULL
// and group them together using all properties specified in match // and group them together using all properties specified in match
static TQValueList<WirelessNetwork> getWirelessNetworks(WirelessDevice* dev = 0, TQ_UINT32 match = WirelessNetwork::MATCH_SSID); static TQValueList<WirelessNetwork> getWirelessNetworks(TDENetworkDevice* dev = 0, TQ_UINT32 match = WirelessNetwork::MATCH_SSID);
// get all aps from either one device or from all available devices // get all aps from either one device or from all available devices
static TQValueList<AccessPoint*> getAccessPoints(WirelessDevice* dev = 0); static TQValueList<AccessPoint*> getAccessPoints(TDENetworkDevice* dev = 0);
// get a list of all known wireless connections // get a list of all known wireless connections
static TQValueList<ConnectionSettings::WirelessConnection*> getWirelessConnections(); static TQValueList<TDEWiFiConnection*> getWirelessConnections();
// get a list of all APs with a specific SSID // get a list of all APs with a specific SSID
static TQValueList<AccessPoint*> getAccessPointsForEssid(TQByteArray, WirelessDevice* dev = 0); static TQValueList<AccessPoint*> getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0);
}; };

@ -45,32 +45,29 @@
#include <kiconloader.h> #include <kiconloader.h>
#include <kconfig.h> #include <kconfig.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <NetworkManager.h>
#include <tqdbusobjectpath.h>
#include <tqdbuserror.h>
#include "knetworkmanager-wireless_menuitem.h" #include "knetworkmanager-wireless_menuitem.h"
#include "knetworkmanager-wireless_network.h" #include "knetworkmanager-wireless_network.h"
#include "knetworkmanager-connection_setting_info.h" #include "knetworkmanager-connection_setting_info.h"
#include "knetworkmanager-wireless_connection.h"
#include "knetworkmanager-nm_proxy.h"
using namespace ConnectionSettings; using namespace ConnectionSettings;
void WirelessNetworkItem::slotActivate() void WirelessNetworkItem::slotActivate()
{ {
NMProxy* nm = NMProxy::getInstance();
int id; TDENetworkConnectionManager* deviceConnMan = _dev->connectionManager();
TQT_DBusError err;
printf("slotActivate\n\r"); printf("slotActivate\n\r");
if (_dev && nm) if (_dev && deviceConnMan)
{ {
if ( _conn ) if ( _conn )
{ {
kdDebug() << "Activate Connection " << _conn->getObjectPath().data() << " on Device " << _dev->getObjectPath().ascii() << endl; kdDebug() << "Activate Connection " << _conn->UUID.ascii() << " on Device " << _dev->deviceNode().ascii() << endl;
if (!nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), TQT_DBusObjectPath(QCString(_dev->getObjectPath())), _conn->getObjectPath(), err)) TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn->UUID);
if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) {
kdDebug() << "ActivateDevice failed" << endl; kdDebug() << "ActivateDevice failed" << endl;
}
} }
else else
@ -85,21 +82,22 @@ void WirelessNetworkItem::slotActivate()
TQString WirelessNetworkItem::getDisplayText() TQString WirelessNetworkItem::getDisplayText()
{ {
TQString security = ""; TQString security = "";
if (_net.getWpaFlags() != NM_802_11_AP_SEC_NONE && _net.getRsnFlags() != NM_802_11_AP_SEC_NONE) if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) {
security = TQString("(%1/%2)").arg(i18n("WPA")).arg(i18n("RSN")); security = TQString("(%1/%2)").arg(i18n("WPA")).arg(i18n("RSN"));
else if (_net.getWpaFlags() != NM_802_11_AP_SEC_NONE) }
else if ((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) {
security = TQString("(%1)").arg(i18n("WPA")); security = TQString("(%1)").arg(i18n("WPA"));
else if (_net.getRsnFlags() != NM_802_11_AP_SEC_NONE) }
else if ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) {
security = TQString("(%2)").arg(i18n("RSN")); security = TQString("(%2)").arg(i18n("RSN"));
}
Info* info = NULL; if (_conn && (_conn->friendlyName != _net.getDisplaySsid())) {
if (_conn) return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(_conn->friendlyName).arg(security);
info = _conn->getInfoSetting(); }
else {
if (info && info->getName() != _net.getDisplaySsid())
return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(info->getName()).arg(security);
else
return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security); return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security);
}
} }
void void
@ -140,7 +138,7 @@ WirelessNetworkItem::sizeHint ()
return TQSize (_width, _height); return TQSize (_width, _height);
} }
WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, WirelessConnection* conn, bool adhoc) WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc)
: NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem () : NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem ()
{ {
parent = p; parent = p;

@ -51,7 +51,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
Q_OBJECT Q_OBJECT
public: public:
WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, ConnectionSettings::WirelessConnection* conn, bool adhoc); WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc);
WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc); WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc);
~WirelessNetworkItem (); ~WirelessNetworkItem ();
@ -70,7 +70,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
bool _adhoc; bool _adhoc;
WirelessNetwork _net; WirelessNetwork _net;
TDENetworkDevice* _dev; TDENetworkDevice* _dev;
ConnectionSettings::WirelessConnection* _conn; TDEWiFiConnection* _conn;
/* menu item */ /* menu item */
int _width; int _width;

@ -121,9 +121,9 @@ TQString WirelessNetwork::getDisplaySsid() const
} }
} }
TQ_UINT32 WirelessNetwork::getFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const
{ {
TQ_UINT32 flags = NM_802_11_AP_FLAGS_NONE; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= (*it)->getFlags(); flags |= (*it)->getFlags();
@ -131,9 +131,9 @@ TQ_UINT32 WirelessNetwork::getFlags() const
return flags; return flags;
} }
TQ_UINT32 WirelessNetwork::getWpaFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const
{ {
TQ_UINT32 flags = NM_802_11_AP_SEC_NONE; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= (*it)->getWpaFlags(); flags |= (*it)->getWpaFlags();
@ -141,9 +141,9 @@ TQ_UINT32 WirelessNetwork::getWpaFlags() const
return flags; return flags;
} }
TQ_UINT32 WirelessNetwork::getRsnFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const
{ {
TQ_UINT32 flags = NM_802_11_AP_SEC_NONE; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None;
for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) for (TQValueList<const AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= (*it)->getRsnFlags(); flags |= (*it)->getRsnFlags();
@ -153,7 +153,7 @@ TQ_UINT32 WirelessNetwork::getRsnFlags() const
bool WirelessNetwork::isEncrypted() const bool WirelessNetwork::isEncrypted() const
{ {
return (getFlags() && NM_802_11_AP_FLAGS_PRIVACY); return (getFlags() & TDENetworkWiFiAPFlags::PrivacySupport);
} }
TQ_UINT8 WirelessNetwork::getStrength() const TQ_UINT8 WirelessNetwork::getStrength() const

@ -61,13 +61,13 @@ class WirelessNetwork
bool addAP(const AccessPoint * const); bool addAP(const AccessPoint * const);
// combined flags of all APs // combined flags of all APs
TQ_UINT32 getFlags() const; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const;
// combined wpa-flags of all APs // combined wpa-flags of all APs
TQ_UINT32 getWpaFlags() const; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getWpaFlags() const;
// combined rsn-flags of all APs // combined rsn-flags of all APs
TQ_UINT32 getRsnFlags() const; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getRsnFlags() const;
// ssid of all APs // ssid of all APs
const TQByteArray getSsid() const; const TQByteArray getSsid() const;

Loading…
Cancel
Save