Store UUIDs and UDIs internally instead of pointers to connection and device objects

pull/1/head
Timothy Pearson 12 years ago
parent 10cd918b01
commit 1a6fd0dfad

@ -5,8 +5,8 @@ This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version the License or (at your option) version 3 or any later version
accepted by the membership of TDE e.V. (or its successor approved accepted by the membership of KDE e.V. (or its successor approved
by the membership of TDE e.V.), which shall act as a proxy by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license. defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -63,10 +63,17 @@ TQString DeviceTrayComponent::tooltipForConnState(TDENetworkConnectionStatus::TD
return TQString::null; return TQString::null;
} }
DeviceTrayComponent::DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ) DeviceTrayComponent::DeviceTrayComponent(TQString 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))); TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
// TDENM FIXME
// This TQt connection will need to be re-established whenever the device list changes, e.g. after a call to TDEHardwareDevices::queryHardwareInformation()
// Therefore, this class should listen to hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString) and reload devices if TDEHardwareEvent::HardwareListModified is passed
connect(deviceConnMan, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), TQT_SLOT(deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)));
m_pixmaps[TDENetworkConnectionStatus::Invalid] = "nm_no_connection"; m_pixmaps[TDENetworkConnectionStatus::Invalid] = "nm_no_connection";
m_pixmaps[TDENetworkConnectionStatus::UnManaged] = "nm_no_connection"; m_pixmaps[TDENetworkConnectionStatus::UnManaged] = "nm_no_connection";
@ -96,18 +103,21 @@ DeviceTrayComponent::~DeviceTrayComponent()
{ {
} }
TDENetworkDevice* DeviceTrayComponent::device() const TQString DeviceTrayComponent::device() const
{ {
return m_device; return m_device;
} }
TQStringList DeviceTrayComponent::getToolTipText() TQStringList DeviceTrayComponent::getToolTipText()
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
TQStringList list; TQStringList list;
TDENetworkConnectionManager* deviceConnMan = m_device->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags; TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
if (tooltipForConnState(state) != "") { if (tooltipForConnState(state) != "") {
list.append(i18n("Device: %1").arg(m_device->deviceNode())); list.append(i18n("Device: %1").arg(dev->deviceNode()));
list.append(i18n("State: %1").arg(tooltipForConnState(state))); list.append(i18n("State: %1").arg(tooltipForConnState(state)));
} }
return list; return list;
@ -146,6 +156,9 @@ void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetwo
void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
// TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
// TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
//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?

@ -5,8 +5,8 @@ This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version the License or (at your option) version 3 or any later version
accepted by the membership of TDE e.V. (or its successor approved accepted by the membership of KDE e.V. (or its successor approved
by the membership of TDE e.V.), which shall act as a proxy by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license. defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -40,12 +40,12 @@ class DeviceTrayComponent : public TrayComponent
Q_OBJECT Q_OBJECT
public: public:
DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name ); DeviceTrayComponent(TQString 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; TQString device() const;
signals: signals:
void needsCenterStage(TrayComponent *, bool); void needsCenterStage(TrayComponent *, bool);
@ -66,7 +66,7 @@ class DeviceTrayComponent : public TrayComponent
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state); TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
private: private:
TDENetworkDevice * m_device; TQString m_device;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies; TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_pixmaps; TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_pixmaps;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_tooltips; TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_tooltips;

@ -45,17 +45,22 @@ class CellularDeviceTrayPrivate
CellularDeviceTrayPrivate() {} CellularDeviceTrayPrivate() {}
~CellularDeviceTrayPrivate() {} ~CellularDeviceTrayPrivate() {}
TDENetworkDevice* dev; TQString dev;
}; };
void CellularDeviceTray::newConnection() void CellularDeviceTray::newConnection()
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// create an appropriate connection // create an appropriate connection
TDENetworkConnection* conn = 0; TDENetworkConnection* conn = 0;
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
switch (deviceConnMan->deviceType()) { switch (deviceConnMan->deviceType()) {
case TDENetworkDeviceType::Modem: case TDENetworkDeviceType::Modem:
conn = new TDEModemConnection(); conn = new TDEModemConnection();
nm->loadConnectionAllowedValues(conn);
break; break;
default: default:
@ -70,13 +75,16 @@ void CellularDeviceTray::newConnection()
void CellularDeviceTray::addMenuItems(KPopupMenu* menu) void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", d->dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1); menu->insertItem (subhead, -1, -1);
//menu->insertSeparator(); //menu->insertSeparator();
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL; TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -98,7 +106,7 @@ void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config"));
} }
NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn->UUID, TQT_TQOBJECT(menu));
int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); int id = menu->insertItem(title, item, TQT_SLOT(slotActivate()));
menu->setItemChecked(id, ((*it) == active_conn)); menu->setItemChecked(id, ((*it) == active_conn));
@ -112,7 +120,7 @@ void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
menu->insertSeparator(); menu->insertSeparator();
} }
CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) CellularDeviceTray::CellularDeviceTray (TQString dev, KSystemTray * parent, const char * name)
: DeviceTrayComponent (dev, parent, name) : DeviceTrayComponent (dev, parent, name)
{ {
d = new CellularDeviceTrayPrivate(); d = new CellularDeviceTrayPrivate();

@ -40,7 +40,7 @@ class CellularDeviceTray : public DeviceTrayComponent
Q_OBJECT Q_OBJECT
public: public:
CellularDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); CellularDeviceTray (TQString, KSystemTray * parent = 0, const char * name = 0);
~CellularDeviceTray (); ~CellularDeviceTray ();
void addMenuItems(KPopupMenu* menu); void addMenuItems(KPopupMenu* menu);

@ -54,32 +54,36 @@ using namespace ConnectionSettings;
class NetworkMenuItemPrivate class NetworkMenuItemPrivate
{ {
public: public:
NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection) NetworkMenuItemPrivate(TQString device, TQString connection)
: dev(device), conn(connection) : dev(device), conn(connection)
{ {
} }
~NetworkMenuItemPrivate() {} ~NetworkMenuItemPrivate() {}
TQGuardedPtr<TDENetworkDevice> dev; TQString dev;
TQGuardedPtr<TDENetworkConnection> conn; TQString conn;
}; };
void NetworkMenuItem::slotActivate() void NetworkMenuItem::slotActivate()
{ {
kdDebug() << "NetworkMenuItem::slotActivate()" << endl; kdDebug() << "NetworkMenuItem::slotActivate()" << endl;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (d->dev && d->conn) TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
TDENetworkConnection* conn = nm->findConnectionByUUID(d->conn);
if (dev && conn)
{ {
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
if (deviceConnMan) if (deviceConnMan)
{ {
kdDebug() << "Activate Connection " << d->conn->UUID.ascii() << " on Device " << d->dev->deviceNode().ascii() << endl; kdDebug() << "Activate Connection " << conn->UUID.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
printf("Activate Connection %s on Device %s\n\r", d->conn->UUID.ascii(), d->dev->deviceNode().ascii()); printf("Activate Connection %s on Device %s\n\r", conn->UUID.ascii(), dev->deviceNode().ascii());
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(d->conn->UUID); TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(conn->UUID);
if ((result == TDENetworkConnectionStatus::Disconnected) if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) { || (result == TDENetworkConnectionStatus::Invalid)) {
// //
@ -89,12 +93,12 @@ void NetworkMenuItem::slotActivate()
} }
} }
} }
else if (d->conn) else if (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->UUID.ascii()); printf("Activate Connection %s on default device\n\r", conn->UUID.ascii());
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(d->conn->UUID); TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(conn->UUID);
if ((result == TDENetworkConnectionStatus::Disconnected) if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) { || (result == TDENetworkConnectionStatus::Invalid)) {
// //
@ -107,7 +111,7 @@ void NetworkMenuItem::slotActivate()
kdDebug() << "Device or Connection invalid" << endl; kdDebug() << "Device or Connection invalid" << endl;
} }
NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name) NetworkMenuItem::NetworkMenuItem (TQString dev, TQString conn, TQObject* parent, const char* name)
: TQObject(parent, name) : TQObject(parent, name)
{ {
d = new NetworkMenuItemPrivate(dev, conn); d = new NetworkMenuItemPrivate(dev, conn);

@ -44,7 +44,7 @@ class NetworkMenuItem : public TQObject
Q_OBJECT Q_OBJECT
public: public:
NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent = 0, const char* name = 0); NetworkMenuItem (TQString dev, TQString conn, TQObject* parent = 0, const char* name = 0);
~NetworkMenuItem (); ~NetworkMenuItem ();
public slots: public slots:

@ -191,8 +191,11 @@ void Tray::slotOnlineMode()
void Tray::contextMenuAboutToShow (KPopupMenu* menu) void Tray::contextMenuAboutToShow (KPopupMenu* menu)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
nm->loadConnectionInformation();
// clear menu // clear menu
menu->clear(); menu->clear();
@ -218,8 +221,9 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*> (*it); DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*> (*it);
KAction * deviceNewConnAction = 0; KAction * deviceNewConnAction = 0;
if (dev_comp) { if (dev_comp) {
TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); TDENetworkDevice* dev_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dev_comp->device()));
TQString menuCaption = TQString("%1").arg(dev_comp->device()->deviceNode()); TQString actionName = TQString("new_connection_%1").arg(dev_comp_dev->deviceNode());
TQString menuCaption = TQString("%1").arg(dev_comp_dev->deviceNode());
if (menuCaption.contains("eth", FALSE) > 0) { if (menuCaption.contains("eth", FALSE) > 0) {
menuCaption = menuCaption.insert(0, "Wired Connection ("); menuCaption = menuCaption.insert(0, "Wired Connection (");
} }
@ -358,14 +362,17 @@ Tray::enterEvent (TQEvent* /*e*/)
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it)
{ {
TrayComponent* comp = *it; TrayComponent* comp = *it;
if (comp->getToolTipText().isEmpty()) if (comp->getToolTipText().isEmpty()) {
continue; continue;
if (!tooltip.isEmpty()) }
if (!tooltip.isEmpty()) {
tooltip += "\n\n"; tooltip += "\n\n";
}
tooltip += comp->getToolTipText().join("\n"); tooltip += comp->getToolTipText().join("\n");
} }
if (!tooltip.isEmpty()) if (!tooltip.isEmpty()) {
TQToolTip::add (this, tooltip); TQToolTip::add (this, tooltip);
}
} }
void void
@ -374,20 +381,21 @@ Tray::slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hi
// For now assume secrets are already in NM... // For now assume secrets are already in NM...
} }
void Tray::slotAddDeviceTrayComponent(TDENetworkDevice* dev) void Tray::slotAddDeviceTrayComponent(TQString dev)
{ {
if (dev) { createDeviceTrayComponent(dev);
createDeviceTrayComponent(dev);
}
} }
void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev) void Tray::slotRemoveDeviceTrayComponent(TQString dev)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it)
{ {
DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*>(*it); DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*>(*it);
if (!dev_comp) if (!dev_comp) {
continue; continue;
}
if (dev_comp->device() == dev) if (dev_comp->device() == dev)
{ {
@ -396,7 +404,8 @@ void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev)
} }
// remove the appropriate action // remove the appropriate action
TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode()); TDENetworkDevice* dev_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dev_comp->device()));
TQString actionName = TQString("new_connection_%1").arg(dev_comp_dev->deviceNode());
KAction * deviceNewConnAction = actionCollection ()->action (actionName); KAction * deviceNewConnAction = actionCollection ()->action (actionName);
if (!deviceNewConnAction) if (!deviceNewConnAction)
@ -417,15 +426,15 @@ void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev)
} }
} }
void Tray::createDeviceTrayComponent(TDENetworkDevice* dev) void Tray::createDeviceTrayComponent(TQString dev)
{ {
bool trayExists = false; bool trayExists = false;
if (!dev) return; TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
// check if we have already a trayicon for this device // check if we have already a trayicon for this device
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it)
{ {
DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*> (*it); DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*> (*it);
if (dev_comp) if (dev_comp)
if (dev_comp->device() == dev) if (dev_comp->device() == dev)
@ -439,7 +448,8 @@ void Tray::createDeviceTrayComponent(TDENetworkDevice* dev)
if (!trayExists) if (!trayExists)
{ {
DeviceTrayComponent* devTray = 0; DeviceTrayComponent* devTray = 0;
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager(); TDENetworkDevice* new_tray_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dev));
TDENetworkConnectionManager* deviceConnMan = new_tray_dev->connectionManager();
// different tray icons for different device types! // different tray icons for different device types!
switch (deviceConnMan->deviceType()) switch (deviceConnMan->deviceType())
{ {
@ -453,15 +463,14 @@ void Tray::createDeviceTrayComponent(TDENetworkDevice* dev)
devTray = new CellularDeviceTray(dev, this, "cellular_device_tray"); devTray = new CellularDeviceTray(dev, this, "cellular_device_tray");
break; break;
default: default:
kdWarning() << k_funcinfo << "UDI: " << dev->uniqueID() << " has unknown devicetype: " << deviceConnMan->deviceType() << endl; kdWarning() << k_funcinfo << "UDI: " << dev << " has unknown devicetype: " << deviceConnMan->deviceType() << endl;
} }
if(devTray) if(devTray)
{ {
connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)), connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)), TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool)));
TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool)));
connect( devTray, TQT_SIGNAL(uiUpdated()), TQT_SLOT(trayUiChanged())); connect( devTray, TQT_SIGNAL(uiUpdated()), TQT_SLOT(trayUiChanged()));
d->trayComponents.append(devTray); d->trayComponents.append(devTray);
//WILLTODO: sort //WILLTODO: sort
} }
} }
} }
@ -479,7 +488,7 @@ void Tray::updateDeviceTrays()
{ {
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it); TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
if (dev) { if (dev) {
createDeviceTrayComponent(dev); createDeviceTrayComponent(dev->uniqueID());
} }
else { else {
kdWarning() << k_funcinfo << "got a NULL-Device" << endl; kdWarning() << k_funcinfo << "got a NULL-Device" << endl;
@ -489,18 +498,18 @@ void Tray::updateDeviceTrays()
void Tray::mousePressEvent( TQMouseEvent *e ) void Tray::mousePressEvent( TQMouseEvent *e )
{ {
if ( !TQT_TQRECT_OBJECT(rect()).contains( e->pos() ) ) { if ( !TQT_TQRECT_OBJECT(rect()).contains( e->pos() ) ) {
return; return;
} }
switch ( e->button() ) { switch ( e->button() ) {
case Qt::LeftButton: case Qt::LeftButton:
contextMenuAboutToShow(contextMenu()); contextMenuAboutToShow(contextMenu());
contextMenu()->popup(e->globalPos()); contextMenu()->popup(e->globalPos());
break; break;
default: default:
KSystemTray::mousePressEvent( e ); KSystemTray::mousePressEvent( e );
break; break;
} }
} }
void Tray::slotDeactivateConnection(int index) void Tray::slotDeactivateConnection(int index)
@ -516,17 +525,21 @@ void Tray::slotDeactivateConnection(int index)
void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt) void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
{ {
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (!hwdevices) return;
DeviceTrayComponent * dtc = dynamic_cast<DeviceTrayComponent*>(component); DeviceTrayComponent * dtc = dynamic_cast<DeviceTrayComponent*>(component);
if (dtc) { if (dtc) {
kdDebug() << k_funcinfo << dtc->device()->deviceNode() << " : " << needsIt << endl; TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
TDENetworkDevice * device = dtc->device(); kdDebug() << k_funcinfo << dtc_comp_dev->deviceNode() << " : " << needsIt << endl;
TDENetworkDevice * device = dtc_comp_dev;
if (needsIt) { if (needsIt) {
if (d->foregroundTrayComponent) { if (d->foregroundTrayComponent) {
disconnect(d->foregroundTrayComponent->device(), TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); TDENetworkDevice* foreground_tray_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
disconnect(foreground_tray_dev, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 );
} }
d->foregroundTrayComponent = dtc; d->foregroundTrayComponent = dtc;
connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
} else { } else {
disconnect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 ); disconnect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 );
// use active default // use active default
@ -545,7 +558,7 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
break; break;
} }
} }
kdDebug() << " Device " << dtc->device()->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl; kdDebug() << " Device " << dtc_comp_dev->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl;
connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)),
TQT_SLOT(slotUpdateDeviceState(NMDeviceState))); TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
slotUpdateDeviceState(device->getState()); slotUpdateDeviceState(device->getState());
@ -568,9 +581,13 @@ void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectio
void Tray::trayUiChanged() void Tray::trayUiChanged()
{ {
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (!hwdevices) return;
DeviceTrayComponent * dtc = d->foregroundTrayComponent; DeviceTrayComponent * dtc = d->foregroundTrayComponent;
if (dtc) { if (dtc) {
TDENetworkConnectionManager* deviceConnMan = dtc->device()->connectionManager(); TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
updateTrayIcon(deviceConnMan->deviceInformation().statusFlags); updateTrayIcon(deviceConnMan->deviceInformation().statusFlags);
} }
} }

@ -96,8 +96,8 @@ class Tray : public KSystemTray
protected slots: protected slots:
void updateDeviceTrays(); void updateDeviceTrays();
void slotAddDeviceTrayComponent(TDENetworkDevice*); void slotAddDeviceTrayComponent(TQString);
void slotRemoveDeviceTrayComponent(TDENetworkDevice*); void slotRemoveDeviceTrayComponent(TQString);
void slotDeactivateConnection(int); void slotDeactivateConnection(int);
void trayComponentNeedsCenterStage(TrayComponent*, bool); void trayComponentNeedsCenterStage(TrayComponent*, bool);
void trayUiChanged(); void trayUiChanged();
@ -107,7 +107,7 @@ class Tray : public KSystemTray
void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void mousePressEvent(TQMouseEvent *e); void mousePressEvent(TQMouseEvent *e);
void createDeviceTrayComponent(TDENetworkDevice*); void createDeviceTrayComponent(TQString);
void enterEvent(TQEvent*); void enterEvent(TQEvent*);
TrayPrivate* d; TrayPrivate* d;

@ -59,13 +59,16 @@ class WiredDeviceTrayPrivate
WiredDeviceTrayPrivate() {} WiredDeviceTrayPrivate() {}
~WiredDeviceTrayPrivate() {} ~WiredDeviceTrayPrivate() {}
TDENetworkDevice* dev; TQString dev;
}; };
void WiredDeviceTray::newConnection() void WiredDeviceTray::newConnection()
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// create a new wired connection // create a new wired connection
TDENetworkConnection* conn = new TDEWiredEthernetConnection(); TDENetworkConnection* conn = new TDEWiredEthernetConnection();
nm->loadConnectionAllowedValues(conn);
// edit the new connection // edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose);
@ -75,14 +78,17 @@ void WiredDeviceTray::newConnection()
void WiredDeviceTray::addMenuItems(KPopupMenu* menu) void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wired", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(dev->deviceNode()), SmallIcon("wired", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1); menu->insertItem (subhead, -1, -1);
// bolding subhead instead // bolding subhead instead
//menu->insertSeparator(); //menu->insertSeparator();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
if (deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::LinkUnavailable) { if (deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::LinkUnavailable) {
// no carrier -> do not show any connections // no carrier -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Cable disconnected"), SmallIcon("no", TQIconSet::Automatic)); subhead = new Subhead(menu, "subhead2", i18n("Cable disconnected"), SmallIcon("no", TQIconSet::Automatic));
@ -90,7 +96,7 @@ void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
} }
else { else {
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL; TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -113,7 +119,7 @@ void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config")); title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config"));
} }
NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu)); NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn->UUID, TQT_TQOBJECT(menu));
connectionItems += 1; connectionItems += 1;
int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); int id = menu->insertItem(title, item, TQT_SLOT(slotActivate()));
@ -132,7 +138,7 @@ void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
} }
} }
WiredDeviceTray::WiredDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name ) WiredDeviceTray::WiredDeviceTray (TQString dev, KSystemTray * parent, const char * name )
: DeviceTrayComponent (dev, parent, name) : DeviceTrayComponent (dev, parent, name)
{ {
d = new WiredDeviceTrayPrivate(); d = new WiredDeviceTrayPrivate();

@ -42,7 +42,7 @@ class WiredDeviceTray : public DeviceTrayComponent
public: public:
WiredDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); WiredDeviceTray (TQString, KSystemTray * parent = 0, const char * name = 0);
~WiredDeviceTray (); ~WiredDeviceTray ();
void addMenuItems(KPopupMenu* menu); void addMenuItems(KPopupMenu* menu);

@ -61,15 +61,18 @@ class WirelessDeviceTrayPrivate
WirelessDeviceTrayPrivate() :dev(0), activeAccessPoint(0) { } WirelessDeviceTrayPrivate() :dev(0), activeAccessPoint(0) { }
~WirelessDeviceTrayPrivate() {} ~WirelessDeviceTrayPrivate() {}
TDENetworkDevice* dev; TQString dev;
TQGuardedPtr<TDENetworkWiFiAPInfo> activeAccessPoint; TQGuardedPtr<TDENetworkWiFiAPInfo> activeAccessPoint;
}; };
TQStringList WirelessDeviceTray::getToolTipText() TQStringList WirelessDeviceTray::getToolTipText()
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
TQStringList tooltip = DeviceTrayComponent::getToolTipText(); TQStringList tooltip = DeviceTrayComponent::getToolTipText();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
if (ap) { if (ap) {
tooltip.append(i18n("Network: %1").arg(ap->friendlySSID())); tooltip.append(i18n("Network: %1").arg(ap->friendlySSID()));
@ -80,8 +83,11 @@ TQStringList WirelessDeviceTray::getToolTipText()
void WirelessDeviceTray::newConnection() void WirelessDeviceTray::newConnection()
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// create a new wireless connection // create a new wireless connection
TDENetworkConnection* conn = new TDEWiFiConnection(); TDENetworkConnection* conn = new TDEWiFiConnection();
nm->loadConnectionAllowedValues(conn);
// 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
@ -127,17 +133,20 @@ TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetw
void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu) void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
printf("Updating wireless network list\n\r"); printf("Updating wireless network list\n\r");
// get all wireless networks // get all wireless networks
TQValueList<WirelessNetwork> nets = WirelessManager::getWirelessNetworks(d->dev); TQValueList<WirelessNetwork> nets = WirelessManager::getWirelessNetworks(dev);
// get all wireless connections // get all wireless connections
TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections(); TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections();
// get the currently active connection // get the currently active connection
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnection* active_conn = NULL; TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -152,13 +161,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
WirelessNetwork net; WirelessNetwork net;
// only show connections which are in range // only show connections which are in range
if ( !findMatchingNetwork(*it, nets, net) ) if ( !findMatchingNetwork(*it, nets, net) ) {
continue; continue;
}
wirelessNetworkItem = new WirelessNetworkItem (menu, wirelessNetworkItem = new WirelessNetworkItem (menu,
d->dev, d->dev,
net, net,
*it, (*it)->UUID,
false); false);
int id = menu->insertItem (wirelessNetworkItem, -1, -1); int id = menu->insertItem (wirelessNetworkItem, -1, -1);
menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn)); menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn));
@ -187,7 +197,7 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
wirelessNetworkItem = new WirelessNetworkItem (menu, wirelessNetworkItem = new WirelessNetworkItem (menu,
d->dev, d->dev,
net, net,
*it, (*it)->UUID,
false); false);
int id = popup->insertItem (wirelessNetworkItem, -1, -1); int id = popup->insertItem (wirelessNetworkItem, -1, -1);
@ -234,11 +244,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
void WirelessDeviceTray::addMenuItems(KPopupMenu* menu) void WirelessDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// get the currently active connection // get the currently active connection
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(d->dev->deviceNode()), SmallIcon("wireless", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", TQString("Wireless Connection (%1)").arg(dev->deviceNode()), SmallIcon("wireless", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1); menu->insertItem (subhead, -1, -1);
// bolding subhead instead // bolding subhead instead
@ -282,11 +295,14 @@ void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetwo
void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
slotCheckActiveAccessPoint(); slotCheckActiveAccessPoint();
if (state == TDENetworkConnectionStatus::Connected) { if (state == TDENetworkConnectionStatus::Connected) {
// trigger an update of the connections seen bssids property // trigger an update of the connections seen bssids property
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID); TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
if (ap) { if (ap) {
int strength = (ap->signalQuality*100.0); int strength = (ap->signalQuality*100.0);
@ -315,9 +331,12 @@ 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
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// get the currently active connection // get the currently active connection
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL; TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -347,8 +366,11 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event)
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
if (event == TDENetworkAPEventType::SignalStrengthChanged) { if (event == TDENetworkAPEventType::SignalStrengthChanged) {
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID); TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID);
if (ap) { if (ap) {
TQ_UINT32 strength = (ap->signalQuality*100.0); TQ_UINT32 strength = (ap->signalQuality*100.0);
@ -384,12 +406,15 @@ void WirelessDeviceTray::slotAccessPointRemoved(const TQString&)
KNotifyClient::event( tray()->winId(), "knm-nm-network-gone", i18n("TDENetworkManager Wireless Network Disappeared") ); KNotifyClient::event( tray()->winId(), "knm-nm-network-gone", i18n("TDENetworkManager Wireless Network Disappeared") );
} }
WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name) WirelessDeviceTray::WirelessDeviceTray (TQString dev, KSystemTray * parent, const char * name)
: DeviceTrayComponent (dev, parent, name) : DeviceTrayComponent (dev, parent, name)
{ {
d = new WirelessDeviceTrayPrivate(); d = new WirelessDeviceTrayPrivate();
d->dev = dev; d->dev = dev;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* hwdev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// we want other icons for wireless devices // we want other icons for wireless devices
setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off"); setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off");
setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off"); setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off");
@ -397,15 +422,19 @@ WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * par
setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless"); setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless");
setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_signal_50"); setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_signal_50");
// TDENM FIXME
// These TQt connections will need to be re-established whenever the device list changes, e.g. after a call to TDEHardwareDevices::queryHardwareInformation()
// Therefore, this class should listen to hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString) and reload devices if TDEHardwareEvent::HardwareListModified is passed
// 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(hwdev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus)));
// if the active access point changed but not the connection we roamed to a new AP // if the active access point changed but not the connection we roamed to a new AP
connect(dev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint())); connect(hwdev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint()));
// get notified of all AP changes // get notified of all AP changes
connect(dev, TQT_SIGNAL(accessPointAdded(TDENetworkWiFiAPInfo*)), this, TQT_SLOT(slotAccessPointAdded(TDENetworkWiFiAPInfo*))); connect(hwdev, TQT_SIGNAL(accessPointAdded(TDENetworkWiFiAPInfo*)), this, TQT_SLOT(slotAccessPointAdded(TDENetworkWiFiAPInfo*)));
connect(dev, TQT_SIGNAL(accessPointRemoved(const TQString&)), this, TQT_SLOT(slotAccessPointRemoved(const TQString&))); connect(hwdev, TQT_SIGNAL(accessPointRemoved(const TQString&)), this, TQT_SLOT(slotAccessPointRemoved(const TQString&)));
} }
WirelessDeviceTray::~WirelessDeviceTray () WirelessDeviceTray::~WirelessDeviceTray ()

@ -42,7 +42,7 @@ class WirelessDeviceTray : public DeviceTrayComponent
public: public:
WirelessDeviceTray (TDENetworkDevice*, KSystemTray * parent = 0, const char * name = 0); WirelessDeviceTray (TQString, KSystemTray * parent = 0, const char * name = 0);
~WirelessDeviceTray (); ~WirelessDeviceTray ();
void addMenuItems(KPopupMenu* menu); void addMenuItems(KPopupMenu* menu);

@ -53,16 +53,21 @@ using namespace ConnectionSettings;
void WirelessNetworkItem::slotActivate() void WirelessNetworkItem::slotActivate()
{ {
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(_dev));
TDENetworkConnectionManager* deviceConnMan = _dev->connectionManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
printf("slotActivate\n\r"); printf("slotActivate\n\r");
if (_dev && deviceConnMan) if (_dev && deviceConnMan)
{ {
if ( _conn ) if ( conn )
{ {
kdDebug() << "Activate Connection " << _conn->UUID.ascii() << " on Device " << _dev->deviceNode().ascii() << endl; kdDebug() << "Activate Connection " << _conn.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn->UUID); TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn);
if ((result == TDENetworkConnectionStatus::Disconnected) if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) { || (result == TDENetworkConnectionStatus::Invalid)) {
kdDebug() << "ActivateDevice failed" << endl; kdDebug() << "ActivateDevice failed" << endl;
@ -80,6 +85,9 @@ void WirelessNetworkItem::slotActivate()
TQString WirelessNetworkItem::getDisplayText() TQString WirelessNetworkItem::getDisplayText()
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
TQString security = ""; TQString security = "";
if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::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"));
@ -91,8 +99,8 @@ TQString WirelessNetworkItem::getDisplayText()
security = TQString("(%2)").arg(i18n("RSN")); security = TQString("(%2)").arg(i18n("RSN"));
} }
if (_conn && (_conn->friendlyName != _net.getDisplaySsid())) { if (conn && (conn->friendlyName != _net.getDisplaySsid())) {
return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(_conn->friendlyName).arg(security); return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(conn->friendlyName).arg(security);
} }
else { else {
return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security); return TQString("%1 %2").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(security);
@ -137,7 +145,7 @@ WirelessNetworkItem::sizeHint ()
return TQSize (_width, _height); return TQSize (_width, _height);
} }
WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, TDEWiFiConnection* conn, bool adhoc) WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TQString dev, WirelessNetwork& net, TQString conn, bool adhoc)
: NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem () : NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem ()
{ {
parent = p; parent = p;
@ -178,7 +186,7 @@ WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, Wi
_width += _space; /* pbarStrength -> contextMenu */ _width += _space; /* pbarStrength -> contextMenu */
} }
WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc) WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TQString dev, WirelessNetwork& net, bool adhoc)
: NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem () : NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem ()
{ {
parent = p; parent = p;

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

Loading…
Cancel
Save