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
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of TDE e.V. (or its successor approved
by the membership of TDE e.V.), which shall act as a proxy
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
@ -63,10 +63,17 @@ TQString DeviceTrayComponent::tooltipForConnState(TDENetworkConnectionStatus::TD
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)
{
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::UnManaged] = "nm_no_connection";
@ -96,18 +103,21 @@ DeviceTrayComponent::~DeviceTrayComponent()
{
}
TDENetworkDevice* DeviceTrayComponent::device() const
TQString DeviceTrayComponent::device() const
{
return m_device;
}
TQStringList DeviceTrayComponent::getToolTipText()
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
TQStringList list;
TDENetworkConnectionManager* deviceConnMan = m_device->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
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)));
}
return list;
@ -146,6 +156,9 @@ void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetwo
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
// if it is the default active connection
// 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
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of TDE e.V. (or its successor approved
by the membership of TDE e.V.), which shall act as a proxy
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
@ -40,12 +40,12 @@ class DeviceTrayComponent : public TrayComponent
Q_OBJECT
public:
DeviceTrayComponent(TDENetworkDevice * device, KSystemTray * parent, const char * name );
DeviceTrayComponent(TQString device, KSystemTray * parent, const char * name );
virtual ~DeviceTrayComponent();
TQPixmap pixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
TQMovie movieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
virtual TQStringList getToolTipText();
TDENetworkDevice* device() const;
TQString device() const;
signals:
void needsCenterStage(TrayComponent *, bool);
@ -66,7 +66,7 @@ class DeviceTrayComponent : public TrayComponent
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
private:
TDENetworkDevice * m_device;
TQString m_device;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_pixmaps;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_tooltips;

@ -45,17 +45,22 @@ class CellularDeviceTrayPrivate
CellularDeviceTrayPrivate() {}
~CellularDeviceTrayPrivate() {}
TDENetworkDevice* dev;
TQString dev;
};
void CellularDeviceTray::newConnection()
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// create an appropriate connection
TDENetworkConnection* conn = 0;
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
switch (deviceConnMan->deviceType()) {
case TDENetworkDeviceType::Modem:
conn = new TDEModemConnection();
nm->loadConnectionAllowedValues(conn);
break;
default:
@ -70,13 +75,16 @@ void CellularDeviceTray::newConnection()
void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// 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->insertSeparator();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(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"));
}
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()));
menu->setItemChecked(id, ((*it) == active_conn));
@ -112,7 +120,7 @@ void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
menu->insertSeparator();
}
CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name)
CellularDeviceTray::CellularDeviceTray (TQString dev, KSystemTray * parent, const char * name)
: DeviceTrayComponent (dev, parent, name)
{
d = new CellularDeviceTrayPrivate();

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

@ -54,32 +54,36 @@ using namespace ConnectionSettings;
class NetworkMenuItemPrivate
{
public:
NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection)
NetworkMenuItemPrivate(TQString device, TQString connection)
: dev(device), conn(connection)
{
}
~NetworkMenuItemPrivate() {}
TQGuardedPtr<TDENetworkDevice> dev;
TQGuardedPtr<TDENetworkConnection> conn;
TQString dev;
TQString conn;
};
void NetworkMenuItem::slotActivate()
{
kdDebug() << "NetworkMenuItem::slotActivate()" << endl;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
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)
{
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());
kdDebug() << "Activate Connection " << conn->UUID.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
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)
|| (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
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)
|| (result == TDENetworkConnectionStatus::Invalid)) {
//
@ -107,7 +111,7 @@ void NetworkMenuItem::slotActivate()
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)
{
d = new NetworkMenuItemPrivate(dev, conn);

@ -44,7 +44,7 @@ class NetworkMenuItem : public TQObject
Q_OBJECT
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 ();
public slots:

@ -191,8 +191,11 @@ void Tray::slotOnlineMode()
void Tray::contextMenuAboutToShow (KPopupMenu* menu)
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
nm->loadConnectionInformation();
// clear menu
menu->clear();
@ -218,8 +221,9 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*> (*it);
KAction * deviceNewConnAction = 0;
if (dev_comp) {
TQString actionName = TQString("new_connection_%1").arg(dev_comp->device()->deviceNode());
TQString menuCaption = TQString("%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());
TQString menuCaption = TQString("%1").arg(dev_comp_dev->deviceNode());
if (menuCaption.contains("eth", FALSE) > 0) {
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)
{
TrayComponent* comp = *it;
if (comp->getToolTipText().isEmpty())
if (comp->getToolTipText().isEmpty()) {
continue;
if (!tooltip.isEmpty())
}
if (!tooltip.isEmpty()) {
tooltip += "\n\n";
}
tooltip += comp->getToolTipText().join("\n");
}
if (!tooltip.isEmpty())
if (!tooltip.isEmpty()) {
TQToolTip::add (this, tooltip);
}
}
void
@ -374,20 +381,21 @@ Tray::slotSecretsNeeded(TDENetworkConnection* connection, const TQStringList& hi
// For now assume secrets are already in NM...
}
void Tray::slotAddDeviceTrayComponent(TDENetworkDevice* dev)
void Tray::slotAddDeviceTrayComponent(TQString dev)
{
if (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)
{
DeviceTrayComponent* dev_comp = dynamic_cast<DeviceTrayComponent*>(*it);
if (!dev_comp)
if (!dev_comp) {
continue;
}
if (dev_comp->device() == dev)
{
@ -396,7 +404,8 @@ void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev)
}
// 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);
if (!deviceNewConnAction)
@ -417,11 +426,11 @@ void Tray::slotRemoveDeviceTrayComponent(TDENetworkDevice* dev)
}
}
void Tray::createDeviceTrayComponent(TDENetworkDevice* dev)
void Tray::createDeviceTrayComponent(TQString dev)
{
bool trayExists = false;
if (!dev) return;
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
// check if we have already a trayicon for this device
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it)
@ -439,7 +448,8 @@ void Tray::createDeviceTrayComponent(TDENetworkDevice* dev)
if (!trayExists)
{
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!
switch (deviceConnMan->deviceType())
{
@ -453,12 +463,11 @@ void Tray::createDeviceTrayComponent(TDENetworkDevice* dev)
devTray = new CellularDeviceTray(dev, this, "cellular_device_tray");
break;
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)
{
connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)),
TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool)));
connect( devTray, TQT_SIGNAL(needsCenterStage(TrayComponent*,bool)), TQT_SLOT(trayComponentNeedsCenterStage(TrayComponent*,bool)));
connect( devTray, TQT_SIGNAL(uiUpdated()), TQT_SLOT(trayUiChanged()));
d->trayComponents.append(devTray);
//WILLTODO: sort
@ -479,7 +488,7 @@ void Tray::updateDeviceTrays()
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
if (dev) {
createDeviceTrayComponent(dev);
createDeviceTrayComponent(dev->uniqueID());
}
else {
kdWarning() << k_funcinfo << "got a NULL-Device" << endl;
@ -516,17 +525,21 @@ void Tray::slotDeactivateConnection(int index)
void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
{
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (!hwdevices) return;
DeviceTrayComponent * dtc = dynamic_cast<DeviceTrayComponent*>(component);
if (dtc) {
kdDebug() << k_funcinfo << dtc->device()->deviceNode() << " : " << needsIt << endl;
TDENetworkDevice * device = dtc->device();
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
kdDebug() << k_funcinfo << dtc_comp_dev->deviceNode() << " : " << needsIt << endl;
TDENetworkDevice * device = dtc_comp_dev;
if (needsIt) {
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;
connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)),
TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
connect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
} else {
disconnect(device, TQT_SIGNAL(StateChanged(NMDeviceState)), this, 0 );
// use active default
@ -545,7 +558,7 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
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)),
TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
slotUpdateDeviceState(device->getState());
@ -568,9 +581,13 @@ void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectio
void Tray::trayUiChanged()
{
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (!hwdevices) return;
DeviceTrayComponent * dtc = d->foregroundTrayComponent;
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);
}
}

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

@ -59,13 +59,16 @@ class WiredDeviceTrayPrivate
WiredDeviceTrayPrivate() {}
~WiredDeviceTrayPrivate() {}
TDENetworkDevice* dev;
TQString dev;
};
void WiredDeviceTray::newConnection()
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// create a new wired connection
TDENetworkConnection* conn = new TDEWiredEthernetConnection();
nm->loadConnectionAllowedValues(conn);
// edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose);
@ -75,14 +78,17 @@ void WiredDeviceTray::newConnection()
void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// 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);
// bolding subhead instead
//menu->insertSeparator();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
if (deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::LinkUnavailable) {
// no carrier -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Cable disconnected"), SmallIcon("no", TQIconSet::Automatic));
@ -90,7 +96,7 @@ void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
}
else {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(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"));
}
NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, TQT_TQOBJECT(menu));
NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn->UUID, TQT_TQOBJECT(menu));
connectionItems += 1;
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)
{
d = new WiredDeviceTrayPrivate();

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

@ -61,15 +61,18 @@ class WirelessDeviceTrayPrivate
WirelessDeviceTrayPrivate() :dev(0), activeAccessPoint(0) { }
~WirelessDeviceTrayPrivate() {}
TDENetworkDevice* dev;
TQString dev;
TQGuardedPtr<TDENetworkWiFiAPInfo> activeAccessPoint;
};
TQStringList WirelessDeviceTray::getToolTipText()
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
TQStringList tooltip = DeviceTrayComponent::getToolTipText();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
if (ap) {
tooltip.append(i18n("Network: %1").arg(ap->friendlySSID()));
@ -80,8 +83,11 @@ TQStringList WirelessDeviceTray::getToolTipText()
void WirelessDeviceTray::newConnection()
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// create a new wireless connection
TDENetworkConnection* conn = new TDEWiFiConnection();
nm->loadConnectionAllowedValues(conn);
// open a dialog for editing the connection
use_new_wireless_essid = 0; // deactivate autofill for now
@ -127,17 +133,20 @@ TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetw
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");
// get all wireless networks
TQValueList<WirelessNetwork> nets = WirelessManager::getWirelessNetworks(d->dev);
TQValueList<WirelessNetwork> nets = WirelessManager::getWirelessNetworks(dev);
// get all wireless connections
TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections();
// get the currently active connection
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -152,13 +161,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
WirelessNetwork net;
// only show connections which are in range
if ( !findMatchingNetwork(*it, nets, net) )
if ( !findMatchingNetwork(*it, nets, net) ) {
continue;
}
wirelessNetworkItem = new WirelessNetworkItem (menu,
d->dev,
net,
*it,
(*it)->UUID,
false);
int id = menu->insertItem (wirelessNetworkItem, -1, -1);
menu->setItemChecked(id, ((TDENetworkConnection*)(*it) == active_conn));
@ -187,7 +197,7 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
wirelessNetworkItem = new WirelessNetworkItem (menu,
d->dev,
net,
*it,
(*it)->UUID,
false);
int id = popup->insertItem (wirelessNetworkItem, -1, -1);
@ -234,11 +244,14 @@ void WirelessDeviceTray::addWirelessNetworks(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
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// 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);
// bolding subhead instead
@ -282,11 +295,14 @@ void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetwo
void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
slotCheckActiveAccessPoint();
if (state == TDENetworkConnectionStatus::Connected) {
// 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);
if (ap) {
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
// 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
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
@ -347,8 +366,11 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
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) {
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID);
if (ap) {
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") );
}
WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, const char * name)
WirelessDeviceTray::WirelessDeviceTray (TQString dev, KSystemTray * parent, const char * name)
: DeviceTrayComponent (dev, parent, name)
{
d = new WirelessDeviceTrayPrivate();
d->dev = dev;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDENetworkDevice* hwdev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
// we want other icons for wireless devices
setPixmapForState(TDENetworkConnectionStatus::Invalid, "wireless_off");
setPixmapForState(TDENetworkConnectionStatus::LinkUnavailable, "wireless_off");
@ -397,15 +422,19 @@ WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * par
setPixmapForState(TDENetworkConnectionStatus::Disconnected, "wireless");
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
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
connect(dev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint()));
connect(hwdev, TQT_SIGNAL(propertiesChanged()), this, TQT_SLOT(slotCheckActiveAccessPoint()));
// get notified of all AP changes
connect(dev, 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(accessPointAdded(TDENetworkWiFiAPInfo*)), this, TQT_SLOT(slotAccessPointAdded(TDENetworkWiFiAPInfo*)));
connect(hwdev, TQT_SIGNAL(accessPointRemoved(const TQString&)), this, TQT_SLOT(slotAccessPointRemoved(const TQString&)));
}
WirelessDeviceTray::~WirelessDeviceTray ()

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

@ -53,16 +53,21 @@ using namespace ConnectionSettings;
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");
if (_dev && deviceConnMan)
{
if ( _conn )
if ( conn )
{
kdDebug() << "Activate Connection " << _conn->UUID.ascii() << " on Device " << _dev->deviceNode().ascii() << endl;
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn->UUID);
kdDebug() << "Activate Connection " << _conn.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn);
if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) {
kdDebug() << "ActivateDevice failed" << endl;
@ -80,6 +85,9 @@ void WirelessNetworkItem::slotActivate()
TQString WirelessNetworkItem::getDisplayText()
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
TQString security = "";
if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) {
security = TQString("(%1/%2)").arg(i18n("WPA")).arg(i18n("RSN"));
@ -91,8 +99,8 @@ TQString WirelessNetworkItem::getDisplayText()
security = TQString("(%2)").arg(i18n("RSN"));
}
if (_conn && (_conn->friendlyName != _net.getDisplaySsid())) {
return TQString("%2/%1 %3").arg(TQString::fromUtf8(_net.getDisplaySsid())).arg(_conn->friendlyName).arg(security);
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);
@ -137,7 +145,7 @@ WirelessNetworkItem::sizeHint ()
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 ()
{
parent = p;
@ -178,7 +186,7 @@ WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, Wi
_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 ()
{
parent = p;

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

Loading…
Cancel
Save