Fix slow icon loading and overall poor performance

pull/1/head
Timothy Pearson 12 years ago
parent 7f11dfba69
commit 851d4cc245

@ -1,4 +1,5 @@
/*
Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
Copyright 2008 Will Stephenson <wstephenson@kde.org>
This program is free software; you can redistribute it and/or
@ -69,6 +70,8 @@ TQString DeviceTrayComponent::tooltipForConnState(TDENetworkConnectionStatus::TD
DeviceTrayComponent::DeviceTrayComponent(TQString device, KSystemTray * parent, const char * name )
: TrayComponent(parent, name), m_tray(dynamic_cast<Tray*>(parent)), m_device(device)
{
lastKnownState = TDENetworkConnectionStatus::Invalid;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
// Listen for hardware change events
@ -136,7 +139,7 @@ TQStringList DeviceTrayComponent::getToolTipText()
TQStringList list;
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceStatus().statusFlags;
if (tooltipForConnState(state) != "") {
list.append(i18n("Device: %1").arg(dev->deviceNode()));
list.append(i18n("State: %1").arg(tooltipForConnState(state)));
@ -150,6 +153,11 @@ TQPixmap DeviceTrayComponent::pixmapForState(TDENetworkConnectionStatus::TDENetw
if (pixmapForConnState(state) != "") {
TQString pixmapPath = pixmapForConnState(state);
if (pixmapPath != "") {
if (m_tray) {
if (m_tray->m_pixmapCache.contains(pixmapPath)) {
return m_tray->m_pixmapCache[pixmapPath];
}
}
return KSystemTray::loadIcon(pixmapPath);
}
else {
@ -166,6 +174,11 @@ TQMovie DeviceTrayComponent::movieForState(TDENetworkConnectionStatus::TDENetwor
if (movieForConnState(state) != "") {
TQString moviePath = movieForConnState(state);
if (moviePath != "") {
if (m_tray) {
if (m_tray->m_movieCache.contains(moviePath)) {
return m_tray->m_movieCache[moviePath];
}
}
if (m_tray) {
return TQMovie(KGlobal::iconLoader()->moviePath(moviePath, KIcon::Panel, m_tray->width()));
}
@ -194,32 +207,45 @@ void DeviceTrayComponent::setPixmapForState(TDENetworkConnectionStatus::TDENetwo
void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus prevState, TQString hwAddress)
{
lastKnownState = newState;
TDEHardwareDevices* hwdevices = KGlobal::hardwareDevices();
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
if (dev->macAddress() != hwAddress) {
printf("[WARNING] Got networkDeviceStateChanged signal for HW address '%s', but my HW address is '%s'! Ignoring...\n\r", hwAddress.ascii(), dev->macAddress().ascii());
kdDebug() << k_funcinfo << "WARNING: Got networkDeviceStateChanged signal for HW address '" << hwAddress << "', but my HW address is '" << dev->macAddress() << "'! Ignoring...";
return;
}
#ifdef DEBUG_STATE
printf("Device tray state: 0x%08x\n\r", newState);
#endif // DEBUG_STATE
//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?
if (newState & TDENetworkConnectionStatus::EstablishingLink) {
emit needsCenterStage(this, true);
TQTimer::singleShot(0, this, TQT_SLOT(sendGetCenterStage()));
}
else if (newState & TDENetworkConnectionStatus::Connected) {
if (nm->defaultNetworkDevices().contains(m_device)) {
emit needsCenterStage(this, true);
TQTimer::singleShot(0, this, TQT_SLOT(sendGetCenterStage()));
}
}
else if ((newState & TDENetworkConnectionStatus::LinkUnavailable)
|| (newState & TDENetworkConnectionStatus::Disconnected)
|| (newState & TDENetworkConnectionStatus::Failed)) {
emit needsCenterStage(this, false);
TQTimer::singleShot(0, this, TQT_SLOT(sendReleaseCenterStage()));
}
}
void DeviceTrayComponent::sendGetCenterStage() {
emit needsCenterStage(this, true);
}
void DeviceTrayComponent::sendReleaseCenterStage() {
emit needsCenterStage(this, false);
}
#include "devicetraycomponent.moc"

@ -1,4 +1,5 @@
/*
Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
Copyright 2008 Will Stephenson <wstephenson@kde.org>
This program is free software; you can redistribute it and/or
@ -70,9 +71,16 @@ class DeviceTrayComponent : public TrayComponent
TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
public:
TDENetworkConnectionStatus::TDENetworkConnectionStatus lastKnownState;
protected:
Tray* m_tray;
private slots:
void sendGetCenterStage();
void sendReleaseCenterStage();
private:
TQString m_device;
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> m_movies;

@ -2,6 +2,7 @@
*
* tdenetman-tray.cpp - A NetworkManager frontend for TDE
*
* Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
@ -144,7 +145,7 @@ class TrayPrivate
TQValueList<TrayComponent*> trayComponents;
DeviceTrayComponent * foregroundTrayComponent;
TQSignalMapper signalMapper;
TQMap<int, TDENetworkConnection*> act_conn_map;
TQMap<int, TQString> act_conn_map;
int current_idx;
};
@ -198,7 +199,7 @@ void Tray::slotOnlineMode()
void Tray::slotNewVPNConnection()
{
printf("Creating new VPN connection\n\r");
kdDebug() << k_funcinfo << "Creating new VPN connection";
// create a new VPN connection
TDEVPNConnection* conn = new TDEVPNConnection();
@ -209,7 +210,7 @@ void Tray::slotNewVPNConnection()
void Tray::slotVPNBannerShow(const TQString& vpnbanner)
{
printf("VPN banner: %s\n\r", vpnbanner.ascii());
kdDebug() << k_funcinfo << "VPN banner: " << vpnbanner;
KNotifyClient::event(winId(), "knm-nm-vpn-banner", vpnbanner);
}
@ -313,7 +314,7 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
deviceNewConnAction = new KAction (actionText, 0, &d->signalMapper, TQT_SLOT(map()), actionCollection(), actionName);
}
d->signalMapper.setMapping(deviceNewConnAction, d->current_idx);
d->act_conn_map.insert(d->current_idx, conn);
d->act_conn_map.insert(d->current_idx, conn->UUID);
d->current_idx++;
disableStuffActionMenu->insert(deviceNewConnAction);
}
@ -364,23 +365,29 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
}
void
Tray::slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState)
Tray::setBaseStateIcon(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state)
{
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState;
// change tray icon according to NM's state
if ((nm_state & TDENetworkGlobalManagerFlags::Unknown)
if ((nm_state == TDENetworkGlobalManagerFlags::Unknown)
|| (nm_state & TDENetworkGlobalManagerFlags::Sleeping)
|| (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink)
|| (nm_state & TDENetworkGlobalManagerFlags::Disconnected)
|| (nm_state & TDENetworkGlobalManagerFlags::BackendUnavailable)) {
setPixmap (loadIcon ("tdenetworkmanager_disabled"));
setPixmap (m_pixmapCache["tdenetworkmanager_disabled"]);
}
else if (nm_state & TDENetworkGlobalManagerFlags::Connected) {
setPixmap (loadIcon ("tdenetworkmanager"));
setPixmap (m_pixmapCache["tdenetworkmanager"]);
}
}
printf("NM state: 0x%08x\n\r", nm_state);
void
Tray::slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags prevState)
{
setBaseStateIcon(newState);
#ifdef DEBUG_STATE
printf("NM state: 0x%08x\n\r", newState);
#endif // DEBUG_STATE
showActiveDeviceTray();
}
@ -574,10 +581,10 @@ void Tray::mousePressEvent( TQMouseEvent *e )
void Tray::slotDeactivateConnection(int index)
{
TDENetworkConnection* conn = d->act_conn_map[index];
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (!nm) return;
TDENetworkConnection* conn = nm->findConnectionByUUID(d->act_conn_map[index]);
if (conn) {
nm->deactivateConnection(conn->UUID);
}
@ -589,7 +596,7 @@ void Tray::connectTrayDeviceManager() {
if (foreground_tray_dev) {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags, TDENetworkConnectionStatus::Invalid, TQString());
slotUpdateDeviceState(deviceConnMan->deviceStatus().statusFlags, d->foregroundTrayComponent->lastKnownState, TQString());
connect(deviceConnMan, TQT_SIGNAL(networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)));
}
}
@ -602,7 +609,7 @@ void Tray::disconnectTrayDeviceManager() {
if (foreground_tray_dev) {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags, TDENetworkConnectionStatus::Invalid, TQString());
slotUpdateDeviceState(deviceConnMan->deviceStatus().statusFlags, d->foregroundTrayComponent->lastKnownState, TQString());
disconnect(deviceConnMan, TQT_SIGNAL(networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)), this, 0);
}
}
@ -615,7 +622,7 @@ void Tray::updateTrayDeviceManagerState() {
if (foreground_tray_dev) {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags, TDENetworkConnectionStatus::Invalid, TQString());
slotUpdateDeviceState(deviceConnMan->deviceStatus().statusFlags, d->foregroundTrayComponent->lastKnownState, TQString());
}
}
}
@ -669,10 +676,18 @@ void Tray::slotUpdateDeviceState()
void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus prevState, TQString hwAddress)
{
printf("Device state: 0x%08x\n\r", newState);
#ifdef DEBUG_STATE
printf("Device state: 0x%08x was: 0x%08x\n\r", newState, prevState);
#endif // DEBUG_STATE
if (newState != prevState) {
if (d->foregroundTrayComponent) {
d->foregroundTrayComponent->lastKnownState = newState;
}
updateTrayIcon(newState);
updateActiveConnection(newState);
updateTrayIcon(newState);
updateActiveConnection(newState);
}
}
void Tray::trayUiChanged()
@ -681,7 +696,7 @@ void Tray::trayUiChanged()
if (dtc) {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
updateTrayIcon(deviceConnMan->deviceInformation().statusFlags);
updateTrayIcon(deviceConnMan->deviceStatus().statusFlags);
}
}
@ -691,7 +706,7 @@ void Tray::showActiveDeviceTray() {
if (d->foregroundTrayComponent) {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceInformation().statusFlags;
TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
|| (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (statusFlags & TDENetworkConnectionStatus::Invalid)
@ -713,7 +728,7 @@ void Tray::showActiveDeviceTray() {
if (newDtc) {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(newDtc->device()));
TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceInformation().statusFlags;
TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
|| (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (statusFlags & TDENetworkConnectionStatus::Invalid)
@ -743,9 +758,6 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
char found_any_active_connection=0;
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionList* allconmap;
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
// Make sure the current state will be displayed
if (d->foregroundTrayComponent) {
@ -753,58 +765,29 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
if (foreground_tray_dev) {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
state = deviceConnMan->deviceInformation().statusFlags;
state = deviceConnMan->deviceStatus().statusFlags;
}
}
}
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags globalState = nm->backendStatus();
// get all available VPN Connections
active_vpn = 0;
allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDEVPNConnection* conn = dynamic_cast<TDEVPNConnection*>(*it);
if (!conn) {
continue;
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus connStatus = nm->checkConnectionStatus(conn->UUID);
if ((connStatus & TDENetworkConnectionStatus::Connected)
|| (connStatus & TDENetworkConnectionStatus::EstablishingLink)
|| (connStatus & TDENetworkConnectionStatus::ConfiguringProtocols)
|| (connStatus & TDENetworkConnectionStatus::Reconnecting)
|| (connStatus & TDENetworkConnectionStatus::VerifyingProtocols)
|| (connStatus & TDENetworkConnectionStatus::NeedAuthorization)
|| (connStatus & TDENetworkConnectionStatus::DependencyWait)) {
// This VPN connection is active!
active_vpn = 1;
}
if ((globalState & TDENetworkGlobalManagerFlags::VPNConnected) | ((globalState & TDENetworkGlobalManagerFlags::VPNDisconnected) && (globalState & TDENetworkGlobalManagerFlags::VPNEstablishingLink))) {
active_vpn = 1;
}
found_any_active_connection = 0;
// Get all active connections
allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDENetworkConnection* conn = (*it);
if (!conn) {
continue;
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus status = nm->checkConnectionStatus(conn->UUID);
if ((status == TDENetworkConnectionStatus::Disconnected)
|| (status == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (status & TDENetworkConnectionStatus::Invalid)
) {
continue;
}
// Found an active connection
if ((globalState & TDENetworkGlobalManagerFlags::Connected) | ((globalState & TDENetworkGlobalManagerFlags::Disconnected) && (globalState & TDENetworkGlobalManagerFlags::EstablishingLink))) {
found_any_active_connection = 1;
}
#ifdef DEBUG_STATE
// if (found_any_active_connection == 1) {
// printf("Active connection found\n\r");
// }
#endif // DEBUG_STATE
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (KGlobal::networkManager()->backendStatus() & TDENetworkGlobalManagerFlags::VPNMask);
if ((current_vpn_state & TDENetworkGlobalManagerFlags::VPNFailed) || (current_vpn_state & TDENetworkGlobalManagerFlags::VPNDisconnected)) {
@ -820,8 +803,8 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
if (active_vpn == 0) {
if ((dtc) && (found_any_active_connection == 1)) {
if (!dtc->movieForState(state).isNull())
{
TQMovie stateMovie = dtc->movieForState(state);
if (!stateMovie.isNull()) {
// animation desired
int frame = -1;
if (movie()) {
@ -829,7 +812,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
// set the movie
setMovie(dtc->movieForState(state));
setMovie(stateMovie);
// start at the same frame as the movie before
if (frame > 0) {
@ -839,21 +822,26 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
// start the animation
movie()->unpause();
}
else if (!dtc->pixmapForState(state).isNull()) {
setPixmap(dtc->pixmapForState(state));
}
else {
setPixmap(loadIcon("tdenetworkmanager"));
TQPixmap statePixmap = dtc->pixmapForState(state);
if (!statePixmap.isNull()) {
setPixmap(statePixmap);
}
else {
setPixmap(m_pixmapCache["tdenetworkmanager"]);
}
}
}
else {
setPixmap(loadIcon("tdenetworkmanager"));
setBaseStateIcon(nm->backendStatus());
}
}
else {
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (KGlobal::networkManager()->backendStatus() & TDENetworkGlobalManagerFlags::VPNMask);
#ifdef DEBUG_STATE
printf("VPN state: 0x%08x\n\r", current_vpn_state);
//printf("Activated is: %d\n\r", TDENetworkConnectionStatus::Connected);
#endif // DEBUG_STATE
// stop the old movie to avoid unnecessary wakups
DeviceTrayComponent * dtc = d->foregroundTrayComponent;
@ -862,7 +850,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
if (dtc) {
if (current_vpn_state & TDENetworkGlobalManagerFlags::VPNConnected) {
setPixmap(loadIcon("nm_device_vpn"));
setPixmap(m_pixmapCache["nm_device_vpn"]);
}
if ((current_vpn_state & TDENetworkGlobalManagerFlags::VPNEstablishingLink)
|| (current_vpn_state & TDENetworkGlobalManagerFlags::VPNNeedAuthorization)
@ -893,7 +881,9 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
nm_device_state_global = state;
#ifdef DEBUG_STATE
//printf("Device state: 0x%08x\n\r", nm_device_state_global);
#endif // DEBUG_STATE
}
void Tray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
@ -919,7 +909,7 @@ void Tray::slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobal
{
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state = newState;
// change tray icon according to NM's state
// popup notification according to NM's state
if (nm_state & TDENetworkGlobalManagerFlags::EstablishingLink) {
KNotifyClient::event( winId(), "tdenm-nm-connecting", i18n("NetworkManager is connecting") );
}
@ -975,15 +965,57 @@ void Tray::slotVPNEventHandler(TDENetworkVPNEventType::TDENetworkVPNEventType ev
}
}
TQPixmap Tray::pixmapForName(TQString pixmapPath)
{
if (pixmapPath != "") {
return KSystemTray::loadIcon(pixmapPath);
}
else {
return TQPixmap();
}
}
TQMovie Tray::movieForName(TQString moviePath)
{
if (moviePath != "") {
return TQMovie(KGlobal::iconLoader()->moviePath(moviePath, KIcon::Panel, width()));
}
else {
return TQMovie();
}
}
void Tray::updateGraphicsCache() {
m_pixmapCache["tdenetworkmanager"] = pixmapForName("tdenetworkmanager");
m_pixmapCache["tdenetworkmanager_disabled"] = pixmapForName("tdenetworkmanager_disabled");
m_pixmapCache["nm_no_connection"] = pixmapForName("nm_no_connection");
m_pixmapCache["nm_device_vpn"] = pixmapForName("nm_device_vpn");
m_pixmapCache["ok"] = pixmapForName("ok");
m_pixmapCache["nm_signal_00"] = pixmapForName("nm_signal_00");
m_pixmapCache["nm_signal_25"] = pixmapForName("nm_signal_25");
m_pixmapCache["nm_signal_50"] = pixmapForName("nm_signal_50");
m_pixmapCache["nm_signal_75"] = pixmapForName("nm_signal_75");
m_pixmapCache["nm_signal_100"] = pixmapForName("nm_signal_100");
// FIXME
// TQMovie objects are explicitly shared
// A cache cannot be implemented until these objects support deep copy!
// m_movieCache["nm_stage01_connecting"] = movieForName("nm_stage01_connecting");
// m_movieCache["nm_stage02_connecting"] = movieForName("nm_stage02_connecting");
// m_movieCache["nm_stage03_connecting"] = movieForName("nm_stage03_connecting");
}
Tray::Tray() : KSystemTray()
{
hwdevices = KGlobal::hardwareDevices();
updateGraphicsCache();
d = new TrayPrivate(TQT_TQOBJECT(this));
connect(&d->signalMapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(slotDeactivateConnection(int)));
setPixmap (loadIcon ("tdenetworkmanager"));
setPixmap (m_pixmapCache["tdenetworkmanager"]);
setMouseTracking (true);
// Actions used for plugging into the menu

@ -2,6 +2,7 @@
*
* tdenetman.h - A NetworkManager frontend for TDE
*
* Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
@ -51,6 +52,8 @@
#include "tdenetman.h"
// #define DEBUG_STATE 1
namespace ConnectionSettings
{
class Connection;
@ -112,6 +115,16 @@ class Tray : public KSystemTray
void slotGenericHardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString);
void slotVPNEventHandler(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message);
private:
TQMovie movieForName(TQString moviePath);
TQPixmap pixmapForName(TQString pixmapPath);
void updateGraphicsCache();
public:
TQMap<TQString, TQMovie> m_movieCache;
TQMap<TQString, TQPixmap> m_pixmapCache;
private:
void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
@ -123,6 +136,7 @@ class Tray : public KSystemTray
void disconnectTrayDeviceManager();
void updateTrayDeviceManagerState();
void showActiveDeviceTray();
void setBaseStateIcon(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags nm_state);
TrayPrivate* d;
TDEHardwareDevices* hwdevices;

@ -2,6 +2,7 @@
*
* tdenetman-wireless_device_tray.cpp - A NetworkManager frontend for TDE
*
* Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
@ -142,7 +143,9 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
#ifdef DEBUG_STATE
printf("Updating wireless network list\n\r");
#endif // DEBUG_STATE
// get all wireless networks
TQValueList<WirelessNetwork> nets = WirelessManager::getWirelessNetworks(dev);
@ -153,9 +156,10 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
// get the currently active connection
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
}
// add all wireless connections in range
@ -304,11 +308,13 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
if (dev->macAddress() != hwAddress) {
printf("[WARNING] Got networkDeviceStateChanged signal for HW address '%s', but my HW address is '%s'! Ignoring...\n\r", hwAddress.ascii(), dev->macAddress().ascii());
kdDebug() << k_funcinfo << "WARNING: Got networkDeviceStateChanged signal for HW address '" << hwAddress << "', but my HW address is '" << dev->macAddress() << "'! Ignoring...";
return;
}
#ifdef DEBUG_STATE
printf("Wireless state: 0x%08x\n\r", newState);
#endif // DEBUG_STATE
slotCheckActiveAccessPoint();
@ -338,7 +344,7 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
}
// Update tray icon
emit uiUpdated();
TQTimer::singleShot(0, this, TQT_SLOT(sendUpdateUI()));
}
void WirelessDeviceTray::slotCheckActiveAccessPoint()
@ -352,13 +358,16 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
}
if (active_conn && deviceConnMan->deviceInformation().statusFlags == TDENetworkConnectionStatus::Connected) {
TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
if (active_conn && devInfo.statusFlags == TDENetworkConnectionStatus::Connected) {
TDENetworkDeviceInformation devInfo = deviceConnMan->deviceInformation();
TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(devInfo.wiFiInfo.activeAccessPointBSSID);
if ( activeap != d->activeAccessPoint) {
d->activeAccessPoint = activeap;
if ( d->activeAccessPoint ) {
@ -399,7 +408,7 @@ void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEven
else {
setPixmapForStates(state, "nm_signal_00");
}
emit uiUpdated();
TQTimer::singleShot(0, this, TQT_SLOT(sendUpdateUI()));
}
}
}
@ -454,6 +463,11 @@ void WirelessDeviceTray::tdeAccessPointStatusChangedHandler(TDEMACAddress BSSID,
}
}
void WirelessDeviceTray::sendUpdateUI()
{
emit uiUpdated();
}
WirelessDeviceTray::WirelessDeviceTray (TQString dev, KSystemTray * parent, const char * name)
: DeviceTrayComponent (dev, parent, name)
{

@ -2,6 +2,7 @@
*
* tdenetman.h - A NetworkManager frontend for TDE
*
* Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
@ -67,6 +68,7 @@ class WirelessDeviceTray : public DeviceTrayComponent
private slots:
void tdeHardwareEventHandler(TDEHardwareEvent::TDEHardwareEvent, TQString);
void tdeAccessPointStatusChangedHandler(TDEMACAddress, TDENetworkAPEventType::TDENetworkAPEventType);
void sendUpdateUI();
private:
void addWirelessNetworks(KPopupMenu* menu);

@ -2,6 +2,7 @@
*
* tdenetman-tray.cpp - A NetworkManager frontend for TDE
*
* Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>

Loading…
Cancel
Save