|
|
|
@ -37,7 +37,7 @@ class WirelessDialog;
|
|
|
|
|
#include <tqstyle.h>
|
|
|
|
|
#include <tqtimer.h>
|
|
|
|
|
|
|
|
|
|
// KDE includes
|
|
|
|
|
// TDE includes
|
|
|
|
|
#include <dcopclient.h>
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
#include <kdialogbase.h>
|
|
|
|
@ -52,15 +52,14 @@ class WirelessDialog;
|
|
|
|
|
#include <kconfig.h>
|
|
|
|
|
#include <kmessagebox.h>
|
|
|
|
|
#include <kglobalsettings.h>
|
|
|
|
|
#include <tdehardwaredevices.h>
|
|
|
|
|
#include <tdenetworkconnections.h>
|
|
|
|
|
|
|
|
|
|
// KNM includes
|
|
|
|
|
#include "knetworkmanager-device_tray.h"
|
|
|
|
|
#include "knetworkmanager-device.h"
|
|
|
|
|
#include "knetworkmanager-menu_subhead.h"
|
|
|
|
|
#include "knetworkmanager-connection_settings_dialog.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_info.h"
|
|
|
|
|
#include "knetworkmanager-nm_proxy.h"
|
|
|
|
|
#include "knetworkmanager-connection.h"
|
|
|
|
|
|
|
|
|
|
using namespace ConnectionSettings;
|
|
|
|
|
|
|
|
|
@ -71,38 +70,84 @@ class DeviceTrayPrivate
|
|
|
|
|
DeviceTrayPrivate()
|
|
|
|
|
: dev(NULL)
|
|
|
|
|
{
|
|
|
|
|
tooltips[NM_DEVICE_STATE_UNKNOWN] = i18n("Unknown");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_UNAVAILABLE] = i18n("Down");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_UNMANAGED] = i18n("Unmanaged");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_DISCONNECTED] = i18n("Disconnected");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_PREPARE] = i18n("Preparing");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_CONFIG] = i18n("Configuration");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_NEED_AUTH] = i18n("Awaiting authentication");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_IP_CONFIG] = i18n("IP configuration");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_ACTIVATED] = i18n("Activated");
|
|
|
|
|
tooltips[NM_DEVICE_STATE_FAILED] = i18n("Failed");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::Invalid] = i18n("Unknown");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::LinkUnavailable] = i18n("Down");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::UnManaged] = i18n("Unmanaged");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::Disconnected] = i18n("Disconnected");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::EstablishingLink] = i18n("Preparing");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::ConfiguringProtocols] = i18n("Configuration");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::NeedAuthorization] = i18n("Awaiting authentication");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::VerifyingProtocols] = i18n("IP configuration");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::Connected] = i18n("Activated");
|
|
|
|
|
tooltips[TDENetworkConnectionStatus::Failed] = i18n("Failed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~DeviceTrayPrivate() {}
|
|
|
|
|
|
|
|
|
|
Device* dev;
|
|
|
|
|
TQMap<NMDeviceState, TQMovie> movies;
|
|
|
|
|
TQMap<NMDeviceState, TQPixmap> pixmaps;
|
|
|
|
|
TQMap<NMDeviceState, TQString> tooltips;
|
|
|
|
|
TDENetworkDevice* dev;
|
|
|
|
|
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQMovie> movies;
|
|
|
|
|
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQPixmap> pixmaps;
|
|
|
|
|
TQMap<TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString> tooltips;
|
|
|
|
|
|
|
|
|
|
TQPixmap pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
|
|
|
|
|
TQMovie movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
|
|
|
|
|
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Device* DeviceTray::getDevice() const
|
|
|
|
|
TQPixmap DeviceTrayPrivate::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
|
|
|
|
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
|
|
|
|
|
while (flag > 0) {
|
|
|
|
|
if (state & flag) {
|
|
|
|
|
if (pixmaps.contains(flag)) {
|
|
|
|
|
return pixmaps[flag];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
|
|
|
|
|
}
|
|
|
|
|
return TQPixmap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQMovie DeviceTrayPrivate::movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
|
|
|
|
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
|
|
|
|
|
while (flag > 0) {
|
|
|
|
|
if (state & flag) {
|
|
|
|
|
if (movies.contains(flag)) {
|
|
|
|
|
return movies[flag];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
|
|
|
|
|
}
|
|
|
|
|
return TQMovie();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString DeviceTrayPrivate::tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
|
|
|
|
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
|
|
|
|
|
while (flag > 0) {
|
|
|
|
|
if (state & flag) {
|
|
|
|
|
if (tooltips.contains(flag)) {
|
|
|
|
|
return tooltips[flag];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
|
|
|
|
|
}
|
|
|
|
|
return TQString::null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDENetworkDevice* DeviceTray::getDevice() const
|
|
|
|
|
{
|
|
|
|
|
return d->dev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString DeviceTray::getTooltipText()
|
|
|
|
|
{
|
|
|
|
|
NMDeviceState state = d->dev->getState();
|
|
|
|
|
|
|
|
|
|
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
|
|
|
|
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
|
|
|
|
|
TQString tooltip = TQString();
|
|
|
|
|
|
|
|
|
|
if (!d->tooltips[state].isEmpty())
|
|
|
|
|
tooltip += i18n("State: %1").arg(d->tooltips[state]);
|
|
|
|
|
if (!d->tooltipForConnState(state).isEmpty()) {
|
|
|
|
|
tooltip += i18n("State: %1").arg(d->tooltipForConnState(state));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tooltip;
|
|
|
|
|
}
|
|
|
|
@ -113,8 +158,9 @@ void DeviceTray::enterEvent (TQEvent* /*e*/)
|
|
|
|
|
TQToolTip::remove (this);
|
|
|
|
|
TQString tooltip = getTooltipText();
|
|
|
|
|
|
|
|
|
|
if (!tooltip.isEmpty())
|
|
|
|
|
if (!tooltip.isEmpty()) {
|
|
|
|
|
TQToolTip::add (this, tooltip);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -183,8 +229,9 @@ void DeviceTray::contextMenuAboutToShow (KPopupMenu* menu)
|
|
|
|
|
// quit
|
|
|
|
|
menu->insertSeparator ();
|
|
|
|
|
KAction* quitAction = actionCollection ()->action (KStdAction::name (KStdAction::Quit));
|
|
|
|
|
if (quitAction)
|
|
|
|
|
if (quitAction) {
|
|
|
|
|
quitAction->plug (menu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::resizeEvent ( TQResizeEvent * )
|
|
|
|
@ -194,26 +241,26 @@ void DeviceTray::resizeEvent ( TQResizeEvent * )
|
|
|
|
|
updateTrayIcon(m_currentIconState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::setPixmapForState(NMDeviceState state, TQMovie movie)
|
|
|
|
|
void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQMovie movie)
|
|
|
|
|
{
|
|
|
|
|
d->movies[state] = movie;
|
|
|
|
|
slotUpdateDeviceState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::setPixmapForState(NMDeviceState state, TQPixmap pixmap)
|
|
|
|
|
void DeviceTray::setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state, TQPixmap pixmap)
|
|
|
|
|
{
|
|
|
|
|
d->pixmaps[state] = pixmap;
|
|
|
|
|
slotUpdateDeviceState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::updateTrayIcon(NMDeviceState state)
|
|
|
|
|
void DeviceTray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
|
|
|
|
|
{
|
|
|
|
|
// stop the old movie to avoid unnecessary wakups
|
|
|
|
|
if (movie())
|
|
|
|
|
if (movie()) {
|
|
|
|
|
movie()->pause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d->movies.find(state) != d->movies.end() && !d->movies[state].isNull())
|
|
|
|
|
{
|
|
|
|
|
if (!d->movieForConnState(state).isNull()) {
|
|
|
|
|
if (m_currentIconState != state) {
|
|
|
|
|
// Clear the icon pixmap as the movie may be a different size
|
|
|
|
|
TQPixmap nullPixmap;
|
|
|
|
@ -222,11 +269,12 @@ void DeviceTray::updateTrayIcon(NMDeviceState state)
|
|
|
|
|
|
|
|
|
|
// animation desired
|
|
|
|
|
int frame = -1;
|
|
|
|
|
if (movie())
|
|
|
|
|
if (movie()) {
|
|
|
|
|
frame = movie()->frameNumber();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set the movie
|
|
|
|
|
setMovie(d->movies[state]);
|
|
|
|
|
setMovie(d->movieForConnState(state));
|
|
|
|
|
|
|
|
|
|
// start at the same frame as the movie before
|
|
|
|
|
if (frame > 0)
|
|
|
|
@ -235,42 +283,36 @@ void DeviceTray::updateTrayIcon(NMDeviceState state)
|
|
|
|
|
// start the animation
|
|
|
|
|
movie()->unpause();
|
|
|
|
|
}
|
|
|
|
|
else if (d->pixmaps.find(state) != d->pixmaps.end() && !d->pixmaps[state].isNull())
|
|
|
|
|
setPixmap(d->pixmaps[state]);
|
|
|
|
|
else
|
|
|
|
|
else if (!d->pixmapForConnState(state).isNull()) {
|
|
|
|
|
setPixmap(d->pixmapForConnState(state));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setPixmap(loadSizedIcon("KNetworkManager", width()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_currentIconState = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::updateActions(NMDeviceState state)
|
|
|
|
|
void DeviceTray::updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
|
|
|
|
|
{
|
|
|
|
|
// allow device deactivation only when device is activated
|
|
|
|
|
KAction* deactivate = actionCollection()->action("deactivate_device");
|
|
|
|
|
if (deactivate)
|
|
|
|
|
deactivate->setEnabled( (state == NM_DEVICE_STATE_ACTIVATED ||
|
|
|
|
|
state == NM_DEVICE_STATE_IP_CONFIG ||
|
|
|
|
|
state == NM_DEVICE_STATE_PREPARE ||
|
|
|
|
|
state == NM_DEVICE_STATE_CONFIG ||
|
|
|
|
|
state == NM_DEVICE_STATE_NEED_AUTH) );
|
|
|
|
|
deactivate->setEnabled( (state & TDENetworkConnectionStatus::Connected ||
|
|
|
|
|
state & TDENetworkConnectionStatus::VerifyingProtocols ||
|
|
|
|
|
state & TDENetworkConnectionStatus::EstablishingLink ||
|
|
|
|
|
state & TDENetworkConnectionStatus::ConfiguringProtocols ||
|
|
|
|
|
state & TDENetworkConnectionStatus::NeedAuthorization) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::updateActiveConnection(NMDeviceState state)
|
|
|
|
|
void DeviceTray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
|
|
|
|
|
{
|
|
|
|
|
if (state != NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
if (!(state & TDENetworkConnectionStatus::Connected)) {
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
NMProxy* nm = NMProxy::getInstance();
|
|
|
|
|
Connection* active_conn = nm->getActiveConnection(d->dev);
|
|
|
|
|
if (active_conn)
|
|
|
|
|
{
|
|
|
|
|
Info* info = dynamic_cast<Info*>(active_conn->getSetting(NM_SETTING_CONNECTION_SETTING_NAME));
|
|
|
|
|
if (info)
|
|
|
|
|
info->setTimestamp(TQDateTime::currentDateTime());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::slotUpdateDeviceState(NMDeviceState state)
|
|
|
|
|
void DeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
|
|
|
|
|
{
|
|
|
|
|
updateTrayIcon(state);
|
|
|
|
|
updateActions(state);
|
|
|
|
@ -279,42 +321,43 @@ void DeviceTray::slotUpdateDeviceState(NMDeviceState state)
|
|
|
|
|
|
|
|
|
|
void DeviceTray::slotUpdateDeviceState()
|
|
|
|
|
{
|
|
|
|
|
slotUpdateDeviceState(d->dev->getState());
|
|
|
|
|
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
|
|
|
|
|
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceTray::loadIcons() {
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_UNKNOWN] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_UNMANAGED] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_UNAVAILABLE] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_DISCONNECTED] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::Invalid] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::UnManaged] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::LinkUnavailable] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::Disconnected] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
|
|
|
|
|
d->movies[NM_DEVICE_STATE_PREPARE] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage01_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[NM_DEVICE_STATE_PREPARE].pause();
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::EstablishingLink] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage01_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::EstablishingLink].pause();
|
|
|
|
|
|
|
|
|
|
d->movies[NM_DEVICE_STATE_CONFIG] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage02_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[NM_DEVICE_STATE_CONFIG].pause();
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::ConfiguringProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage02_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::ConfiguringProtocols].pause();
|
|
|
|
|
|
|
|
|
|
d->movies[NM_DEVICE_STATE_IP_CONFIG] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage03_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[NM_DEVICE_STATE_IP_CONFIG].pause();
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::VerifyingProtocols] = TQMovie( KGlobal::iconLoader()->moviePath("nm_stage03_connecting", KIcon::Panel));
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::VerifyingProtocols].pause();
|
|
|
|
|
|
|
|
|
|
d->movies[NM_DEVICE_STATE_NEED_AUTH] = d->movies[NM_DEVICE_STATE_CONFIG];
|
|
|
|
|
d->movies[NM_DEVICE_STATE_NEED_AUTH].pause();
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::NeedAuthorization] = d->movies[TDENetworkConnectionStatus::ConfiguringProtocols];
|
|
|
|
|
d->movies[TDENetworkConnectionStatus::NeedAuthorization].pause();
|
|
|
|
|
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_ACTIVATED] = loadSizedIcon("ok", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::Connected] = loadSizedIcon("ok", width());
|
|
|
|
|
|
|
|
|
|
d->pixmaps[NM_DEVICE_STATE_FAILED] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
d->pixmaps[TDENetworkConnectionStatus::Failed] = loadSizedIcon("nm_no_connection", width());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceTray::DeviceTray (Device* dev) : KSystemTray ()
|
|
|
|
|
DeviceTray::DeviceTray (TDENetworkDevice* dev) : KSystemTray ()
|
|
|
|
|
{
|
|
|
|
|
d = new DeviceTrayPrivate();
|
|
|
|
|
d->dev = dev;
|
|
|
|
|
|
|
|
|
|
m_currentIconState = NM_DEVICE_STATE_UNKNOWN;
|
|
|
|
|
m_currentIconState = TDENetworkConnectionStatus::Invalid;
|
|
|
|
|
loadIcons();
|
|
|
|
|
|
|
|
|
|
// get notified when the device state changes
|
|
|
|
|
connect(dev, TQT_SIGNAL(StateChanged(NMDeviceState)), this, TQT_SLOT(slotUpdateDeviceState(NMDeviceState)));
|
|
|
|
|
connect(dev, TQT_SIGNAL(StateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus)), this, TQT_SLOT(slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus)));
|
|
|
|
|
|
|
|
|
|
setMouseTracking (true);
|
|
|
|
|
|
|
|
|
|