More conversion to new TDE API

pull/1/head
Timothy Pearson 12 years ago
parent 9265fa10ad
commit 4c69808733

@ -28,40 +28,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "knetworkmanager-nm_proxy.h" #include "knetworkmanager-nm_proxy.h"
TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
if (m_pixmaps.contains(flag)) { if (m_pixmaps.contains(flag)) {
return m_pixmaps[flag]; return m_pixmaps[flag];
} }
} }
flag = flag >> 1; flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
} }
return TQString::null; return TQString::null;
} }
TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
if (m_movies.contains(flag)) { if (m_movies.contains(flag)) {
return m_movies[flag]; return m_movies[flag];
} }
} }
flag = flag >> 1; flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
} }
return TQString::null; return TQString::null;
} }
TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
while (flag > 0) { while (flag > 0) {
if (state & flag) { if (state & flag) {
if (m_tooltips.contains(flag)) { if (m_tooltips.contains(flag)) {
return m_tooltips[flag]; return m_tooltips[flag];
} }
} }
flag = flag >> 1; flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1);
} }
return TQString::null; return TQString::null;
} }

@ -30,29 +30,12 @@
#include <klocale.h> #include <klocale.h>
#include <kiconloader.h> #include <kiconloader.h>
// TQt DBus
#include <tqdbusobjectpath.h>
// KNM includes // KNM includes
#include "knetworkmanager-cellular_device_tray.h" #include "knetworkmanager-cellular_device_tray.h"
#include "knetworkmanager-cellular_device.h"
#include "knetworkmanager-menuitem.h" #include "knetworkmanager-menuitem.h"
#include "knetworkmanager-menu_subhead.h" #include "knetworkmanager-menu_subhead.h"
#include "knetworkmanager-connection_store.h"
#include "knetworkmanager-cdma_connection.h"
#include "knetworkmanager-gsm_connection.h"
#include "knetworkmanager-nm_proxy.h"
#include "knetworkmanager-connection_setting_info.h"
#include "knetworkmanager-connection_setting_ipv4.h"
#include "knetworkmanager-connection_setting_cdma.h"
#include "knetworkmanager-connection_setting_gsm.h"
#include "knetworkmanager-connection_settings_dialog.h"
#if !defined(NM_CHECK_VERSION) #include "knetworkmanager-connection_settings_dialog.h"
#define NM_CHECK_VERSION(x,y,z) 0
#endif
using namespace ConnectionSettings; using namespace ConnectionSettings;
@ -68,95 +51,58 @@ class CellularDeviceTrayPrivate
void CellularDeviceTray::newConnection() void CellularDeviceTray::newConnection()
{ {
// create an appropriate connection // create an appropriate connection
Connection* conn = 0; TDENetworkConnection* conn = 0;
switch (d->dev->getDeviceType()) { TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
#if NM_CHECK_VERSION(0,8,992) switch (deviceConnMan->deviceType()) {
case NM_DEVICE_TYPE_MODEM: case TDENetworkDeviceType::Modem:
#else conn = new TDEModemConnection();
case DEVICE_TYPE_GSM:
#endif
conn = new GSMConnection();
break;
#if NM_CHECK_VERSION(0,8,992)
#else
case DEVICE_TYPE_CDMA:
conn = new CDMAConnection();
break; break;
#endif
default: default:
break; break;
} }
// edit the new connection // edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, NULL, tray(), "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose);
dlg->show(); dlg->show();
} }
void CellularDeviceTray::addMenuItems(KPopupMenu* menu) void CellularDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
ConnectionStore* connectionStore = ConnectionStore::getInstance();
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", d->dev->getInterface(), SmallIcon("nm_device_wwan", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", d->dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1); menu->insertItem (subhead, -1, -1);
//menu->insertSeparator(); //menu->insertSeparator();
NMProxy* nm = NMProxy::getInstance(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
Connection* active_conn = nm->getActiveConnection(d->dev); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
if (active_conn) TDENetworkConnection* active_conn = NULL;
kdDebug() << active_conn->getObjectPath().data() << endl; if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
}
// get all available Connections for cellular devices // get all available Connections for cellular devices
// WILLTODO : repeat for GSM
TQValueList<Connection*> connections = connectionStore->getConnections(NM_SETTING_CDMA_SETTING_NAME);
for (TQValueList<Connection*>::iterator it = connections.begin(); it != connections.end(); ++it)
{
CDMAConnection* cellularconn = dynamic_cast<CDMAConnection*>(*it);
if (cellularconn)
{
// cellular connection found :)
Info* info = cellularconn->getInfoSetting();
IPv4* ip = cellularconn->getIPv4Setting();
// lets create a nice name for this connection
if (info)
{
TQString title = info->getName();
if (ip)
title += TQString(" (%1)").arg(ip->getMethod() == IPv4::METHOD_DHCP ? i18n("DHCP") : i18n("Manual IP config"));
NetworkMenuItem* item = new NetworkMenuItem(d->dev, cellularconn, TQT_TQOBJECT(menu));
int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); TDENetworkConnectionList* allconmap = nm->connections();
menu->setItemChecked(id, ((*it) == active_conn)); for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
} TDEModemConnection* conn = dynamic_cast<TDEModemConnection*>(*it);
if (!conn) {
continue;
} }
}
connections = connectionStore->getConnections(NM_SETTING_GSM_SETTING_NAME);
for (TQValueList<Connection*>::iterator it = connections.begin(); it != connections.end(); ++it)
{
GSMConnection* cellularconn = dynamic_cast<GSMConnection*>(*it);
if (cellularconn)
{
// cellular connection found :)
Info* info = cellularconn->getInfoSetting();
IPv4* ip = cellularconn->getIPv4Setting();
// lets create a nice name for this connection // lets create a nice name for this connection
if (info) TQString title = conn->friendlyName;
{ if (conn->ipConfig.valid) {
TQString title = info->getName(); title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config"));
if (ip) }
title += TQString(" (%1)").arg(ip->getMethod() == IPv4::METHOD_DHCP ? i18n("DHCP") : i18n("Manual IP config"));
NetworkMenuItem* item = new NetworkMenuItem(d->dev, cellularconn, TQT_TQOBJECT(menu)); NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, 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));
} }
}
}
// bring the device down // bring the device down
KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); KAction* deactivate = tray()->actionCollection()->action("deactivate_device");
@ -172,7 +118,7 @@ CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * par
d = new CellularDeviceTrayPrivate(); d = new CellularDeviceTrayPrivate();
d->dev = dev; d->dev = dev;
setPixmapForState(NM_DEVICE_STATE_ACTIVATED, "nm_device_wwan"); setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wwan");
} }
CellularDeviceTray::~CellularDeviceTray () CellularDeviceTray::~CellularDeviceTray ()

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

@ -42,13 +42,8 @@
#include <tqprogressbar.h> #include <tqprogressbar.h>
#include <tqguardedptr.h> #include <tqguardedptr.h>
#include <NetworkManager.h>
#include "knetworkmanager.h" #include "knetworkmanager.h"
#define NM_DEVICE_STATE_VPN_PREPARE 100
#define NM_DEVICE_STATE_VPN_ACTIVATED 101
class Device;
class DeviceTrayPrivate; class DeviceTrayPrivate;
class DeviceTray : public KSystemTray class DeviceTray : public KSystemTray
@ -57,34 +52,34 @@ class DeviceTray : public KSystemTray
public: public:
DeviceTray (Device*); DeviceTray (TDENetworkDevice*);
~DeviceTray (); ~DeviceTray ();
void contextMenuAboutToShow (KPopupMenu* menu); void contextMenuAboutToShow (KPopupMenu* menu);
virtual void addMenuItems(KPopupMenu* menu) = 0; virtual void addMenuItems(KPopupMenu* menu) = 0;
Device* getDevice() const; TDENetworkDevice* getDevice() const;
protected: protected:
void setPixmapForState(NMDeviceState, TQMovie); void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQMovie);
void setPixmapForState(NMDeviceState, TQPixmap); void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQPixmap);
void resizeEvent ( TQResizeEvent * ); void resizeEvent ( TQResizeEvent * );
virtual TQString getTooltipText(); virtual TQString getTooltipText();
public slots: public slots:
void setPixmap(const TQPixmap &); void setPixmap(const TQPixmap &);
void slotUpdateDeviceState(NMDeviceState); void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void slotUpdateDeviceState(); void slotUpdateDeviceState();
private: private:
void updateTrayIcon(NMDeviceState); void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void updateActions(NMDeviceState); void updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void updateActiveConnection(NMDeviceState); void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void enterEvent (TQEvent*); void enterEvent (TQEvent*);
void loadIcons(); void loadIcons();
DeviceTrayPrivate* d; DeviceTrayPrivate* d;
NMDeviceState m_currentIconState; TDENetworkConnectionStatus::TDENetworkConnectionStatus m_currentIconState;
}; };
#endif /* KNETWORKMANAGER_DEVICE_TRAY_H */ #endif /* KNETWORKMANAGER_DEVICE_TRAY_H */

@ -49,35 +49,24 @@
#include <kconfig.h> #include <kconfig.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <tqdbusobjectpath.h>
#include <tqdbuserror.h>
#include "knetworkmanager-connection.h" #include "knetworkmanager-connection.h"
#include "knetworkmanager-device.h" #include "knetworkmanager-device.h"
#include "knetworkmanager-nm_proxy.h" #include "knetworkmanager-nm_proxy.h"
#include "knetworkmanager-vpn_plugin.h"
#if !defined(NM_CHECK_VERSION)
#define NM_CHECK_VERSION(x,y,z) 0
#endif
TQString currentVPNDevice;
TQT_DBusObjectPath vpn_attempt_this_conn;
using namespace ConnectionSettings; using namespace ConnectionSettings;
class NetworkMenuItemPrivate class NetworkMenuItemPrivate
{ {
public: public:
NetworkMenuItemPrivate(Device* device, Connection* connection) NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection)
: dev(device), conn(connection) : dev(device), conn(connection)
{ {
} }
~NetworkMenuItemPrivate() {} ~NetworkMenuItemPrivate() {}
TQGuardedPtr<Device> dev; TQGuardedPtr<TDENetworkDevice> dev;
TQGuardedPtr<Connection> conn; TQGuardedPtr<TDENetworkConnection> conn;
}; };
void NetworkMenuItem::slotActivate() void NetworkMenuItem::slotActivate()
@ -113,7 +102,6 @@ void NetworkMenuItem::slotActivate()
printf("Activate Connection %s on default device\n\r", d->conn->getObjectPath().data()); printf("Activate Connection %s on default device\n\r", d->conn->getObjectPath().data());
TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection();
TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn);
vpn_attempt_this_conn = d->conn->getObjectPath();
#if NM_CHECK_VERSION(0,8,992) #if NM_CHECK_VERSION(0,8,992)
nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", d->conn->getObjectPath(), device, act_conn, err); nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", d->conn->getObjectPath(), device, act_conn, err);
#else #else

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

@ -46,15 +46,9 @@
// KNM includes // KNM includes
#include "knetworkmanager-wired_device_tray.h" #include "knetworkmanager-wired_device_tray.h"
#include "knetworkmanager-wired_device.h"
#include "knetworkmanager-menuitem.h" #include "knetworkmanager-menuitem.h"
#include "knetworkmanager-menu_subhead.h" #include "knetworkmanager-menu_subhead.h"
#include "knetworkmanager-connection_store.h"
#include "knetworkmanager-wired_connection.h"
#include "knetworkmanager-nm_proxy.h"
#include "knetworkmanager-connection_setting_info.h"
#include "knetworkmanager-connection_setting_ipv4.h"
#include "knetworkmanager-connection_setting_wired.h" #include "knetworkmanager-connection_setting_wired.h"
#include "knetworkmanager-connection_settings_dialog.h" #include "knetworkmanager-connection_settings_dialog.h"
@ -72,69 +66,64 @@ class WiredDeviceTrayPrivate
void WiredDeviceTray::newConnection() void WiredDeviceTray::newConnection()
{ {
// create a new wired connection // create a new wired connection
Connection* conn = new WiredConnection(); TDENetworkConnection* conn = new TDEWiredEthernetConnection();
// edit the new connection // edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, NULL, tray(), "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, tray(), "connect_something", false, TQt::WDestructiveClose);
dlg->show(); dlg->show();
} }
void WiredDeviceTray::addMenuItems(KPopupMenu* menu) void WiredDeviceTray::addMenuItems(KPopupMenu* menu)
{ {
ConnectionStore* connectionStore = ConnectionStore::getInstance();
// device title // device title
Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(d->dev->getInterface()), SmallIcon("wired", TQIconSet::Automatic)); Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(d->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();
if (!d->dev->getCarrier()) TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
{ 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));
menu->insertItem(subhead, -1, -1); menu->insertItem(subhead, -1, -1);
} }
else else {
{ TDEGlobalNetworkManager* nm = KGlobal::networkManager();
NMProxy* nm = NMProxy::getInstance(); TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
Connection* active_conn = nm->getActiveConnection(d->dev); TDENetworkConnection* active_conn = NULL;
if (active_conn) if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
kdDebug() << active_conn->getObjectPath().data() << endl; && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID);
}
// get all available Connections for wired devices // get all available Connections for wired devices
TQValueList<Connection*> connections = connectionStore->getConnections(NM_SETTING_WIRED_SETTING_NAME); TDENetworkConnectionList* connections = nm->connections();
int connectionItems = 0; int connectionItems = 0;
for (TQValueList<Connection*>::iterator it = connections.begin(); it != connections.end(); ++it) for (TDENetworkConnectionList::Iterator it = connections->begin(); it != connections->end(); ++it) {
{ TDEWiredEthernetConnection* conn = dynamic_cast<TDEWiredEthernetConnection*>(*it);
WiredConnection* wiredconn = dynamic_cast<WiredConnection*>(*it); if (!conn) {
if (wiredconn) continue;
{ }
// wired connection found :)
Info* info = wiredconn->getInfoSetting();
IPv4* ip = wiredconn->getIPv4Setting();
// wired connection found :)
// lets create a nice name for this connection // lets create a nice name for this connection
if (info) TQString title = conn->friendlyName;
{ if (conn->ipConfig.valid) {
TQString title = info->getName(); title += TQString(" (%1)").arg((conn->ipConfig.connectionFlags & TDENetworkIPConfigurationFlags::IPV4DHCPIP) ? i18n("DHCP") : i18n("Manual IP config"));
if (ip) }
title += TQString(" (%1)").arg(ip->getMethod() == IPv4::METHOD_DHCP ? i18n("DHCP") : i18n("Manual IP config"));
NetworkMenuItem* item = new NetworkMenuItem(d->dev, wiredconn, TQT_TQOBJECT(menu)); NetworkMenuItem* item = new NetworkMenuItem(d->dev, conn, 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()));
menu->setItemChecked(id, ((*it) == active_conn)); menu->setItemChecked(id, ((*it) == active_conn));
} }
}
}
if ( connectionItems == 0) { if ( connectionItems == 0) {
// menu->insertSeparator(); // menu->insertSeparator();
int id = menu->insertItem(SmallIcon("filenew", TQIconSet::Automatic), i18n("Create new wired connection"), this, TQT_SLOT(newConnection())); menu->insertItem(SmallIcon("filenew", TQIconSet::Automatic), i18n("Create new wired connection"), this, TQT_SLOT(newConnection()));
} }
// bring the device down // bring the device down
KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); KAction* deactivate = tray()->actionCollection()->action("deactivate_device");
@ -150,8 +139,7 @@ WiredDeviceTray::WiredDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, c
d = new WiredDeviceTrayPrivate(); d = new WiredDeviceTrayPrivate();
d->dev = dev; d->dev = dev;
setPixmapForState(NM_DEVICE_STATE_ACTIVATED, "nm_device_wired"); setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wired");
} }
WiredDeviceTray::~WiredDeviceTray () WiredDeviceTray::~WiredDeviceTray ()

@ -42,23 +42,11 @@
#include <klocale.h> #include <klocale.h>
#include <knotifyclient.h> #include <knotifyclient.h>
// QT DBus
#include <tqdbuserror.h>
#include <tqdbusobjectpath.h>
// KNM includes // KNM includes
#include "knetworkmanager-wireless_device_tray.h" #include "knetworkmanager-wireless_device_tray.h"
#include "knetworkmanager-wireless_device.h"
#include "knetworkmanager-wireless_menuitem.h" #include "knetworkmanager-wireless_menuitem.h"
#include "knetworkmanager-wireless_network.h" #include "knetworkmanager-wireless_network.h"
#include "knetworkmanager-accesspoint.h"
#include "knetworkmanager-menu_subhead.h" #include "knetworkmanager-menu_subhead.h"
#include "knetworkmanager-connection_store.h"
#include "knetworkmanager-wireless_connection.h"
#include "knetworkmanager-connection_setting_info.h"
#include "knetworkmanager-connection_setting_wireless.h"
#include "knetworkmanager-connection_setting_wireless_security.h"
#include "knetworkmanager-nm_proxy.h"
#include "knetworkmanager-wireless_manager.h" #include "knetworkmanager-wireless_manager.h"
#include "knetworkmanager-connection_settings_dialog.h" #include "knetworkmanager-connection_settings_dialog.h"

@ -32,8 +32,6 @@
// KNM includes // KNM includes
#include "knetworkmanager.h" #include "knetworkmanager.h"
#include "knetworkmanager-device_tray.h" #include "knetworkmanager-device_tray.h"
#include "knetworkmanager-accesspoint.h"
#include "knetworkmanager-wireless_device.h"
#include "knetworkmanager-wireless_network.h" #include "knetworkmanager-wireless_network.h"
namespace ConnectionSettings namespace ConnectionSettings

@ -56,10 +56,6 @@
#include "knetworkmanager-wireless_connection.h" #include "knetworkmanager-wireless_connection.h"
#include "knetworkmanager-nm_proxy.h" #include "knetworkmanager-nm_proxy.h"
#if !defined(NM_CHECK_VERSION)
#define NM_CHECK_VERSION(x,y,z) 0
#endif
using namespace ConnectionSettings; using namespace ConnectionSettings;
void WirelessNetworkItem::slotActivate() void WirelessNetworkItem::slotActivate()
@ -73,11 +69,7 @@ void WirelessNetworkItem::slotActivate()
if ( _conn ) if ( _conn )
{ {
kdDebug() << "Activate Connection " << _conn->getObjectPath().data() << " on Device " << _dev->getObjectPath().ascii() << endl; kdDebug() << "Activate Connection " << _conn->getObjectPath().data() << " on Device " << _dev->getObjectPath().ascii() << endl;
#if NM_CHECK_VERSION(0,8,992)
if (!nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), TQT_DBusObjectPath(QCString(_dev->getObjectPath())), _conn->getObjectPath(), err)) if (!nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), TQT_DBusObjectPath(QCString(_dev->getObjectPath())), _conn->getObjectPath(), err))
#else
if (!nm->ActivateConnectionAsync(id, NM_DBUS_SERVICE_USER_SETTINGS, _conn->getObjectPath(), TQT_DBusObjectPath(TQCString(_dev->getObjectPath())), _conn->getObjectPath(), err))
#endif
kdDebug() << "ActivateDevice failed" << endl; kdDebug() << "ActivateDevice failed" << endl;
} }
@ -148,7 +140,7 @@ WirelessNetworkItem::sizeHint ()
return TQSize (_width, _height); return TQSize (_width, _height);
} }
WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, Device* dev, WirelessNetwork& net, WirelessConnection* conn, bool adhoc) WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, WirelessConnection* conn, bool adhoc)
: NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem () : NetworkMenuItem(dev, conn, 0, 0 ), TQCustomMenuItem ()
{ {
parent = p; parent = p;
@ -189,7 +181,7 @@ WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, Device* dev, WirelessNetw
_width += _space; /* pbarStrength -> contextMenu */ _width += _space; /* pbarStrength -> contextMenu */
} }
WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, Device* dev, WirelessNetwork& net, bool adhoc) WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc)
: NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem () : NetworkMenuItem(dev, NULL, 0, 0 ), TQCustomMenuItem ()
{ {
parent = p; parent = p;

@ -45,15 +45,14 @@
#include <tqguardedptr.h> #include <tqguardedptr.h>
#include "knetworkmanager-wireless_network.h" #include "knetworkmanager-wireless_network.h"
#include "knetworkmanager-connection.h"
class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
{ {
Q_OBJECT Q_OBJECT
public: public:
WirelessNetworkItem (TQWidget*, Device* dev, WirelessNetwork& net, ConnectionSettings::WirelessConnection* conn, bool adhoc); WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, ConnectionSettings::WirelessConnection* conn, bool adhoc);
WirelessNetworkItem (TQWidget*, Device* dev, WirelessNetwork& net, bool adhoc); WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc);
~WirelessNetworkItem (); ~WirelessNetworkItem ();
TQWidget* parent; TQWidget* parent;
@ -70,7 +69,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem
bool _adhoc; bool _adhoc;
WirelessNetwork _net; WirelessNetwork _net;
Device* _dev; TDENetworkDevice* _dev;
ConnectionSettings::WirelessConnection* _conn; ConnectionSettings::WirelessConnection* _conn;
/* menu item */ /* menu item */

Loading…
Cancel
Save