Use BSSID instead of storing APInfo pointers internally

pull/1/head
Timothy Pearson 12 years ago
parent 083f3b3b04
commit 69038478eb

@ -121,7 +121,7 @@ WirelessSecurityWEPImpl::WirelessSecurityWEPImpl(TDEWiFiConnection* sec, TQWidge
void WirelessSecurityWEPImpl::slotAuthAlgChanged(int index) void WirelessSecurityWEPImpl::slotAuthAlgChanged(int index)
{ {
if (index == 0) { if (index == 0) {
_security_setting->securitySettings.authType =TDENetworkWiFiAuthType::Open; _security_setting->securitySettings.authType = TDENetworkWiFiAuthType::Open;
} }
else if (index == 1) { else if (index == 1) {
_security_setting->securitySettings.authType = TDENetworkWiFiAuthType::Shared; _security_setting->securitySettings.authType = TDENetworkWiFiAuthType::Shared;

@ -49,12 +49,12 @@ TQValueList<WirelessNetwork> WirelessManager::getWirelessNetworks(TDENetworkDevi
// 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->BSSID) ) {
// we alread have a network where this AP belongs to // we alread have a network where this AP belongs to
found = true; found = true;
// attach this ap to the network // attach this ap to the network
(*netIt).addAP(ap); (*netIt).addAP(ap->BSSID, (dev)?dev->uniqueID():TQString::null);
/* // FIXME active? /* // FIXME active?
if (active_ap) if (active_ap)
@ -70,7 +70,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->BSSID, (dev)?dev->uniqueID():TQString::null);
nets.append(net); nets.append(net);
} }
} }

@ -48,7 +48,7 @@ class WirelessNetworkPrivate
bool active; bool active;
TQ_UINT32 match; TQ_UINT32 match;
TQValueList<const TDENetworkWiFiAPInfo*> aps; TQMap<TDEMACAddress,TQString> aps;
}; };
WirelessNetwork::WirelessNetwork(const WirelessNetwork& other) WirelessNetwork::WirelessNetwork(const WirelessNetwork& other)
@ -71,15 +71,35 @@ WirelessNetwork::~WirelessNetwork()
WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other) WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other)
{ {
if (d) if (d) {
delete d; delete d;
}
d = new WirelessNetworkPrivate(*other.d); d = new WirelessNetworkPrivate(*other.d);
return *this; return *this;
} }
bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) bool WirelessNetwork::contains(const TDEMACAddress ap)
{ {
if ( (d->match & MATCH_SSID) && getSsid() != ap->SSID) { TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->aps[ap]));
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(ap);
}
else if (d->aps[ap] == "") {
apInfo = nm->findAccessPointByBSSID(ap);
}
if (apInfo) {
if ( (d->match & MATCH_SSID) && (getSsid() != apInfo->SSID)) {
return false;
}
}
else {
// AP was not found in list
return false; return false;
} }
@ -87,10 +107,10 @@ bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap)
return true; return true;
} }
bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) bool WirelessNetwork::addAP(const TDEMACAddress ap, const TQString dev)
{ {
if ( this->contains( ap ) || d->aps.isEmpty()) { if ( this->contains(ap) || d->aps.isEmpty()) {
d->aps.append(ap); d->aps[ap] = dev;
return true; return true;
} }
return false; return false;
@ -98,8 +118,26 @@ bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap)
const TQByteArray WirelessNetwork::getSsid() const const TQByteArray WirelessNetwork::getSsid() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if ( !d->aps.isEmpty() ) { if ( !d->aps.isEmpty() ) {
return (*(d->aps.begin()))->SSID; TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->aps.begin().data()));
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
}
else if (d->aps.begin().data() == "") {
apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
}
if (apInfo) {
return apInfo->SSID;
}
else {
return TQByteArray();
}
} }
else { else {
return TQByteArray(); return TQByteArray();
@ -108,8 +146,26 @@ const TQByteArray WirelessNetwork::getSsid() const
TQString WirelessNetwork::getDisplaySsid() const TQString WirelessNetwork::getDisplaySsid() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (!d->aps.isEmpty()) { if (!d->aps.isEmpty()) {
return (*(d->aps.begin()))->friendlySSID(); TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->aps.begin().data()));
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
}
else if (d->aps.begin().data() == "") {
apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
}
if (apInfo) {
return apInfo->friendlySSID();
}
else {
return TQString();
}
} }
else { else {
return TQString(); return TQString();
@ -118,30 +174,75 @@ TQString WirelessNetwork::getDisplaySsid() const
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
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 (TQMap<TDEMACAddress,TQString>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) {
flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(it.data()));
flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask); TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
}
else if (it.data() == "") {
apInfo = nm->findAccessPointByBSSID(it.key());
}
if (apInfo) {
flags |= (apInfo->wpaFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask);
flags |= (apInfo->rsnFlags & TDENetworkWiFiAPFlags::GeneralFlagsMask);
}
} }
return flags; return flags;
} }
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
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 (TQMap<TDEMACAddress,TQString>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= ((*it)->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(it.data()));
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
}
else if (it.data() == "") {
apInfo = nm->findAccessPointByBSSID(it.key());
}
if (apInfo) {
flags |= (apInfo->wpaFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask);
}
} }
return flags; return flags;
} }
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
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 (TQMap<TDEMACAddress,TQString>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
{ {
flags |= ((*it)->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask); TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(it.data()));
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
}
else if (it.data() == "") {
apInfo = nm->findAccessPointByBSSID(it.key());
}
if (apInfo) {
flags |= (apInfo->rsnFlags & TDENetworkWiFiAPFlags::EncryptionFlagsMask);
}
} }
return flags; return flags;
} }
@ -153,10 +254,25 @@ bool WirelessNetwork::isEncrypted() const
TQ_UINT8 WirelessNetwork::getStrength() const TQ_UINT8 WirelessNetwork::getStrength() const
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TQ_UINT8 strength = 0; TQ_UINT8 strength = 0;
for (TQValueList<const TDENetworkWiFiAPInfo*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { for (TQMap<TDEMACAddress,TQString>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) {
if (((*it)->signalQuality*100.0) > strength) { TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(it.data()));
strength = ((*it)->signalQuality*100.0); TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
}
else if (it.data() == "") {
apInfo = nm->findAccessPointByBSSID(it.key());
}
if (apInfo) {
if ((apInfo->signalQuality*100.0) > strength) {
strength = (apInfo->signalQuality*100.0);
}
} }
} }
return strength; return strength;

@ -57,10 +57,10 @@ class WirelessNetwork
WirelessNetwork& operator= (const WirelessNetwork&); WirelessNetwork& operator= (const WirelessNetwork&);
// check if the AccessPoint represents the same net // check if the AccessPoint represents the same net
bool contains(const TDENetworkWiFiAPInfo * const); bool contains(const TDEMACAddress);
// add an AP to the Network // add an AP to the Network
bool addAP(const TDENetworkWiFiAPInfo * const); bool addAP(const TDEMACAddress, const TQString);
// combined flags of all APs // combined flags of all APs
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const; TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const;

Loading…
Cancel
Save