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

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

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

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

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

@ -44,16 +44,16 @@ class WirelessManager
public:
// get all accesspoints from device dev or from all devices if dev is NULL
// and group them together using all properties specified in match
static TQValueList<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
static TQValueList<AccessPoint*> getAccessPoints(WirelessDevice* dev = 0);
static TQValueList<AccessPoint*> getAccessPoints(TDENetworkDevice* dev = 0);
// 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
static TQValueList<AccessPoint*> getAccessPointsForEssid(TQByteArray, WirelessDevice* dev = 0);
static TQValueList<AccessPoint*> getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0);
};

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

@ -51,7 +51,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
Q_OBJECT
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 ();
@ -70,7 +70,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
bool _adhoc;
WirelessNetwork _net;
TDENetworkDevice* _dev;
ConnectionSettings::WirelessConnection* _conn;
TDEWiFiConnection* _conn;
/* menu item */
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)
{
flags |= (*it)->getFlags();
@ -131,9 +131,9 @@ TQ_UINT32 WirelessNetwork::getFlags() const
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)
{
flags |= (*it)->getWpaFlags();
@ -141,9 +141,9 @@ TQ_UINT32 WirelessNetwork::getWpaFlags() const
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)
{
flags |= (*it)->getRsnFlags();
@ -153,7 +153,7 @@ TQ_UINT32 WirelessNetwork::getRsnFlags() const
bool WirelessNetwork::isEncrypted() const
{
return (getFlags() && NM_802_11_AP_FLAGS_PRIVACY);
return (getFlags() & TDENetworkWiFiAPFlags::PrivacySupport);
}
TQ_UINT8 WirelessNetwork::getStrength() const

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

Loading…
Cancel
Save