From 4c6980873386dff306b3083e4ed861fdee45e37b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 4 Sep 2012 20:41:08 -0500 Subject: [PATCH] More conversion to new TDE API --- tdenetworkmanager/src/devicetraycomponent.cpp | 12 +- .../knetworkmanager-cellular_device_tray.cpp | 120 ++++-------- .../src/knetworkmanager-device_tray.cpp | 183 +++++++++++------- .../src/knetworkmanager-device_tray.h | 23 +-- .../src/knetworkmanager-menuitem.cpp | 18 +- .../src/knetworkmanager-menuitem.h | 2 +- .../src/knetworkmanager-wired_device_tray.cpp | 80 ++++---- .../knetworkmanager-wireless_device_tray.cpp | 12 -- .../src/knetworkmanager-wireless_manager.h | 2 - .../src/knetworkmanager-wireless_menuitem.cpp | 12 +- .../src/knetworkmanager-wireless_menuitem.h | 7 +- 11 files changed, 204 insertions(+), 267 deletions(-) diff --git a/tdenetworkmanager/src/devicetraycomponent.cpp b/tdenetworkmanager/src/devicetraycomponent.cpp index d0a3f97..d0b0929 100644 --- a/tdenetworkmanager/src/devicetraycomponent.cpp +++ b/tdenetworkmanager/src/devicetraycomponent.cpp @@ -28,40 +28,40 @@ along with this program. If not, see . #include "knetworkmanager-nm_proxy.h" TQString pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { if (m_pixmaps.contains(flag)) { return m_pixmaps[flag]; } } - flag = flag >> 1; + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); } return TQString::null; } TQString movieForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { if (m_movies.contains(flag)) { return m_movies[flag]; } } - flag = flag >> 1; + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); } return TQString::null; } TQString tooltipForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) { - TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = 0x80000000; + TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000; while (flag > 0) { if (state & flag) { if (m_tooltips.contains(flag)) { return m_tooltips[flag]; } } - flag = flag >> 1; + flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)(flag >> 1); } return TQString::null; } diff --git a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp index 49a3ab2..d3d23d5 100644 --- a/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp +++ b/tdenetworkmanager/src/knetworkmanager-cellular_device_tray.cpp @@ -30,29 +30,12 @@ #include #include -// TQt DBus -#include - - // KNM includes #include "knetworkmanager-cellular_device_tray.h" -#include "knetworkmanager-cellular_device.h" #include "knetworkmanager-menuitem.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) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif +#include "knetworkmanager-connection_settings_dialog.h" using namespace ConnectionSettings; @@ -68,94 +51,57 @@ class CellularDeviceTrayPrivate void CellularDeviceTray::newConnection() { // create an appropriate connection - Connection* conn = 0; - switch (d->dev->getDeviceType()) { -#if NM_CHECK_VERSION(0,8,992) - case NM_DEVICE_TYPE_MODEM: -#else - case DEVICE_TYPE_GSM: -#endif - conn = new GSMConnection(); + TDENetworkConnection* conn = 0; + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + switch (deviceConnMan->deviceType()) { + case TDENetworkDeviceType::Modem: + conn = new TDEModemConnection(); break; -#if NM_CHECK_VERSION(0,8,992) -#else - case DEVICE_TYPE_CDMA: - conn = new CDMAConnection(); - break; -#endif + default: break; } // 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(); } void CellularDeviceTray::addMenuItems(KPopupMenu* menu) { - ConnectionStore* connectionStore = ConnectionStore::getInstance(); - // 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->insertSeparator(); - NMProxy* nm = NMProxy::getInstance(); - Connection* active_conn = nm->getActiveConnection(d->dev); - if (active_conn) - kdDebug() << active_conn->getObjectPath().data() << endl; + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + 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 - // WILLTODO : repeat for GSM - TQValueList connections = connectionStore->getConnections(NM_SETTING_CDMA_SETTING_NAME); - for (TQValueList::iterator it = connections.begin(); it != connections.end(); ++it) - { - CDMAConnection* cellularconn = dynamic_cast(*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())); - menu->setItemChecked(id, ((*it) == active_conn)); - } + + TDENetworkConnectionList* allconmap = nm->connections(); + for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { + TDEModemConnection* conn = dynamic_cast(*it); + if (!conn) { + continue; } - } - connections = connectionStore->getConnections(NM_SETTING_GSM_SETTING_NAME); - for (TQValueList::iterator it = connections.begin(); it != connections.end(); ++it) - { - GSMConnection* cellularconn = dynamic_cast(*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())); - menu->setItemChecked(id, ((*it) == active_conn)); - } + + // lets create a nice name for this connection + TQString title = conn->friendlyName; + if (conn->ipConfig.valid) { + 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)); + + int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); + menu->setItemChecked(id, ((*it) == active_conn)); } // bring the device down @@ -172,7 +118,7 @@ CellularDeviceTray::CellularDeviceTray (TDENetworkDevice* dev, KSystemTray * par d = new CellularDeviceTrayPrivate(); d->dev = dev; - setPixmapForState(NM_DEVICE_STATE_ACTIVATED, "nm_device_wwan"); + setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wwan"); } CellularDeviceTray::~CellularDeviceTray () diff --git a/tdenetworkmanager/src/knetworkmanager-device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-device_tray.cpp index e0c05a9..493582a 100644 --- a/tdenetworkmanager/src/knetworkmanager-device_tray.cpp +++ b/tdenetworkmanager/src/knetworkmanager-device_tray.cpp @@ -37,7 +37,7 @@ class WirelessDialog; #include #include -// KDE includes +// TDE includes #include #include #include @@ -52,15 +52,14 @@ class WirelessDialog; #include #include #include +#include +#include // 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 movies; - TQMap pixmaps; - TQMap tooltips; + TDENetworkDevice* dev; + TQMap movies; + TQMap pixmaps; + TQMap 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(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); diff --git a/tdenetworkmanager/src/knetworkmanager-device_tray.h b/tdenetworkmanager/src/knetworkmanager-device_tray.h index 5b390ad..60f6888 100644 --- a/tdenetworkmanager/src/knetworkmanager-device_tray.h +++ b/tdenetworkmanager/src/knetworkmanager-device_tray.h @@ -42,13 +42,8 @@ #include #include -#include #include "knetworkmanager.h" -#define NM_DEVICE_STATE_VPN_PREPARE 100 -#define NM_DEVICE_STATE_VPN_ACTIVATED 101 - -class Device; class DeviceTrayPrivate; class DeviceTray : public KSystemTray @@ -57,34 +52,34 @@ class DeviceTray : public KSystemTray public: - DeviceTray (Device*); + DeviceTray (TDENetworkDevice*); ~DeviceTray (); void contextMenuAboutToShow (KPopupMenu* menu); virtual void addMenuItems(KPopupMenu* menu) = 0; - Device* getDevice() const; + TDENetworkDevice* getDevice() const; protected: - void setPixmapForState(NMDeviceState, TQMovie); - void setPixmapForState(NMDeviceState, TQPixmap); + void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQMovie); + void setPixmapForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQPixmap); void resizeEvent ( TQResizeEvent * ); virtual TQString getTooltipText(); public slots: void setPixmap(const TQPixmap &); - void slotUpdateDeviceState(NMDeviceState); + void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void slotUpdateDeviceState(); private: - void updateTrayIcon(NMDeviceState); - void updateActions(NMDeviceState); - void updateActiveConnection(NMDeviceState); + void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void updateActions(TDENetworkConnectionStatus::TDENetworkConnectionStatus); + void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void enterEvent (TQEvent*); void loadIcons(); DeviceTrayPrivate* d; - NMDeviceState m_currentIconState; + TDENetworkConnectionStatus::TDENetworkConnectionStatus m_currentIconState; }; #endif /* KNETWORKMANAGER_DEVICE_TRAY_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-menuitem.cpp b/tdenetworkmanager/src/knetworkmanager-menuitem.cpp index b13563e..f44ebfa 100644 --- a/tdenetworkmanager/src/knetworkmanager-menuitem.cpp +++ b/tdenetworkmanager/src/knetworkmanager-menuitem.cpp @@ -49,35 +49,24 @@ #include #include -#include -#include - #include "knetworkmanager-connection.h" #include "knetworkmanager-device.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; class NetworkMenuItemPrivate { public: - NetworkMenuItemPrivate(Device* device, Connection* connection) + NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection) : dev(device), conn(connection) { } ~NetworkMenuItemPrivate() {} - TQGuardedPtr dev; - TQGuardedPtr conn; + TQGuardedPtr dev; + TQGuardedPtr conn; }; void NetworkMenuItem::slotActivate() @@ -113,7 +102,6 @@ void NetworkMenuItem::slotActivate() printf("Activate Connection %s on default device\n\r", d->conn->getObjectPath().data()); TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); - vpn_attempt_this_conn = d->conn->getObjectPath(); #if NM_CHECK_VERSION(0,8,992) nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", d->conn->getObjectPath(), device, act_conn, err); #else diff --git a/tdenetworkmanager/src/knetworkmanager-menuitem.h b/tdenetworkmanager/src/knetworkmanager-menuitem.h index 5f9f6eb..e384d8c 100644 --- a/tdenetworkmanager/src/knetworkmanager-menuitem.h +++ b/tdenetworkmanager/src/knetworkmanager-menuitem.h @@ -41,7 +41,7 @@ class NetworkMenuItem : public TQObject Q_OBJECT 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 (); public slots: diff --git a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp index 9f2e9ed..c399a7a 100644 --- a/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wired_device_tray.cpp @@ -46,15 +46,9 @@ // KNM includes #include "knetworkmanager-wired_device_tray.h" -#include "knetworkmanager-wired_device.h" #include "knetworkmanager-menuitem.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_settings_dialog.h" @@ -72,69 +66,64 @@ class WiredDeviceTrayPrivate void WiredDeviceTray::newConnection() { // create a new wired connection - Connection* conn = new WiredConnection(); + TDENetworkConnection* conn = new TDEWiredEthernetConnection(); // 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(); } void WiredDeviceTray::addMenuItems(KPopupMenu* menu) { - ConnectionStore* connectionStore = ConnectionStore::getInstance(); - // 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); - // bolding subhead instead + // bolding subhead instead //menu->insertSeparator(); - if (!d->dev->getCarrier()) - { + TDENetworkConnectionManager* deviceConnMan = d->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)); menu->insertItem(subhead, -1, -1); } - else - { - NMProxy* nm = NMProxy::getInstance(); - Connection* active_conn = nm->getActiveConnection(d->dev); - if (active_conn) - kdDebug() << active_conn->getObjectPath().data() << endl; + else { + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager(); + TDENetworkConnection* active_conn = NULL; + if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected)) + && (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) { + active_conn = nm->findConnectionByUUID(deviceConnMan->deviceInformation().activeConnectionUUID); + } // get all available Connections for wired devices - TQValueList connections = connectionStore->getConnections(NM_SETTING_WIRED_SETTING_NAME); + TDENetworkConnectionList* connections = nm->connections(); int connectionItems = 0; - for (TQValueList::iterator it = connections.begin(); it != connections.end(); ++it) - { - WiredConnection* wiredconn = dynamic_cast(*it); - if (wiredconn) - { - // wired connection found :) - Info* info = wiredconn->getInfoSetting(); - IPv4* ip = wiredconn->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, wiredconn, TQT_TQOBJECT(menu)); - connectionItems += 1; - - int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); - menu->setItemChecked(id, ((*it) == active_conn)); - } + for (TDENetworkConnectionList::Iterator it = connections->begin(); it != connections->end(); ++it) { + TDEWiredEthernetConnection* conn = dynamic_cast(*it); + if (!conn) { + continue; + } + + // wired connection found :) + // lets create a nice name for this connection + TQString title = conn->friendlyName; + if (conn->ipConfig.valid) { + 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)); + connectionItems += 1; + + int id = menu->insertItem(title, item, TQT_SLOT(slotActivate())); + menu->setItemChecked(id, ((*it) == active_conn)); } if ( connectionItems == 0) { // 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 KAction* deactivate = tray()->actionCollection()->action("deactivate_device"); @@ -150,8 +139,7 @@ WiredDeviceTray::WiredDeviceTray (TDENetworkDevice* dev, KSystemTray * parent, c d = new WiredDeviceTrayPrivate(); d->dev = dev; - setPixmapForState(NM_DEVICE_STATE_ACTIVATED, "nm_device_wired"); - + setPixmapForState(TDENetworkConnectionStatus::Connected, "nm_device_wired"); } WiredDeviceTray::~WiredDeviceTray () diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp index b56cb00..a1a59ab 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_device_tray.cpp @@ -42,23 +42,11 @@ #include #include -// QT DBus -#include -#include - // KNM includes #include "knetworkmanager-wireless_device_tray.h" -#include "knetworkmanager-wireless_device.h" #include "knetworkmanager-wireless_menuitem.h" #include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-accesspoint.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-connection_settings_dialog.h" diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h b/tdenetworkmanager/src/knetworkmanager-wireless_manager.h index f90fce7..ab32ee6 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h +++ b/tdenetworkmanager/src/knetworkmanager-wireless_manager.h @@ -32,8 +32,6 @@ // KNM includes #include "knetworkmanager.h" #include "knetworkmanager-device_tray.h" -#include "knetworkmanager-accesspoint.h" -#include "knetworkmanager-wireless_device.h" #include "knetworkmanager-wireless_network.h" namespace ConnectionSettings diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp index f8bedae..5956e85 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.cpp @@ -56,10 +56,6 @@ #include "knetworkmanager-wireless_connection.h" #include "knetworkmanager-nm_proxy.h" -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - using namespace ConnectionSettings; void WirelessNetworkItem::slotActivate() @@ -73,11 +69,7 @@ void WirelessNetworkItem::slotActivate() if ( _conn ) { 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)) -#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; } @@ -148,7 +140,7 @@ WirelessNetworkItem::sizeHint () 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 () { parent = p; @@ -189,7 +181,7 @@ WirelessNetworkItem::WirelessNetworkItem (TQWidget* p, Device* dev, WirelessNetw _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 () { parent = p; diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h index 98b6321..1021cc6 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h +++ b/tdenetworkmanager/src/knetworkmanager-wireless_menuitem.h @@ -45,15 +45,14 @@ #include #include "knetworkmanager-wireless_network.h" -#include "knetworkmanager-connection.h" class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem { Q_OBJECT public: - WirelessNetworkItem (TQWidget*, Device* dev, WirelessNetwork& net, ConnectionSettings::WirelessConnection* conn, bool adhoc); - WirelessNetworkItem (TQWidget*, Device* dev, WirelessNetwork& net, bool adhoc); + WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, ConnectionSettings::WirelessConnection* conn, bool adhoc); + WirelessNetworkItem (TQWidget*, TDENetworkDevice* dev, WirelessNetwork& net, bool adhoc); ~WirelessNetworkItem (); TQWidget* parent; @@ -70,7 +69,7 @@ class WirelessNetworkItem : public NetworkMenuItem, public TQCustomMenuItem bool _adhoc; WirelessNetwork _net; - Device* _dev; + TDENetworkDevice* _dev; ConnectionSettings::WirelessConnection* _conn; /* menu item */