|
|
|
@ -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,29 +81,27 @@ 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -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
|
|
|
|
|
slotCheckActiveAccessPoint();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = d->dev->getActiveAccessPoint();
|
|
|
|
|
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");
|
|
|
|
|
emit uiUpdated();
|
|
|
|
|
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)));
|
|
|
|
|