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"
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;
}

@ -30,29 +30,12 @@
#include <klocale.h>
#include <kiconloader.h>
// TQt DBus
#include <tqdbusobjectpath.h>
// 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,95 +51,58 @@ 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();
break;
#if NM_CHECK_VERSION(0,8,992)
#else
case DEVICE_TYPE_CDMA:
conn = new CDMAConnection();
TDENetworkConnection* conn = 0;
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
switch (deviceConnMan->deviceType()) {
case TDENetworkDeviceType::Modem:
conn = new TDEModemConnection();
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<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()));
menu->setItemChecked(id, ((*it) == active_conn));
}
TDENetworkConnectionList* allconmap = nm->connections();
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
if (info)
{
TQString title = info->getName();
if (ip)
title += TQString(" (%1)").arg(ip->getMethod() == IPv4::METHOD_DHCP ? i18n("DHCP") : i18n("Manual IP config"));
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, cellularconn, TQT_TQOBJECT(menu));
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
KAction* deactivate = tray()->actionCollection()->action("deactivate_device");
@ -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 ()

@ -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);

@ -42,13 +42,8 @@
#include <tqprogressbar.h>
#include <tqguardedptr.h>
#include <NetworkManager.h>
#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 */

@ -49,35 +49,24 @@
#include <kconfig.h>
#include <kmessagebox.h>
#include <tqdbusobjectpath.h>
#include <tqdbuserror.h>
#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<Device> dev;
TQGuardedPtr<Connection> conn;
TQGuardedPtr<TDENetworkDevice> dev;
TQGuardedPtr<TDENetworkConnection> 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

@ -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:

@ -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
//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<Connection*> connections = connectionStore->getConnections(NM_SETTING_WIRED_SETTING_NAME);
TDENetworkConnectionList* connections = nm->connections();
int connectionItems = 0;
for (TQValueList<Connection*>::iterator it = connections.begin(); it != connections.end(); ++it)
{
WiredConnection* wiredconn = dynamic_cast<WiredConnection*>(*it);
if (wiredconn)
{
// wired connection found :)
Info* info = wiredconn->getInfoSetting();
IPv4* ip = wiredconn->getIPv4Setting();
for (TDENetworkConnectionList::Iterator it = connections->begin(); it != connections->end(); ++it) {
TDEWiredEthernetConnection* conn = dynamic_cast<TDEWiredEthernetConnection*>(*it);
if (!conn) {
continue;
}
// wired connection found :)
// 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"));
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, wiredconn, TQT_TQOBJECT(menu));
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 ()

@ -42,23 +42,11 @@
#include <klocale.h>
#include <knotifyclient.h>
// QT DBus
#include <tqdbuserror.h>
#include <tqdbusobjectpath.h>
// 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"

@ -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

@ -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;

@ -45,15 +45,14 @@
#include <tqguardedptr.h>
#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 */

Loading…
Cancel
Save