Commit 89ec0858 authored by Lamarque Vieira Souza's avatar Lamarque Vieira Souza
Browse files

Indicate active connections in Manager Connections widget.

BUG: 182451
FIXED-IN: nm09 branch
parent fe38c220
......@@ -67,7 +67,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ConnectionIdRole Qt::UserRole + 1
#define ConnectionTypeRole Qt::UserRole + 2
#define ConnectionLastUsedRole Qt::UserRole + 3
#define ConnectionScopeRole Qt::UserRole + 4
#define ConnectionStateRole Qt::UserRole + 4
#define ConnectionNameColumn 0
#define ConnectionLastUsedColumn 1
#define ConnectionStateColumn 2
K_PLUGIN_FACTORY( ManageConnectionWidgetFactory, registerPlugin<ManageConnectionWidget>();)
K_EXPORT_PLUGIN( ManageConnectionWidgetFactory( "kcm_networkmanagement", "libknetworkmanager" ) )
......@@ -245,6 +249,7 @@ void ManageConnectionWidget::restoreConnections()
QStringList itemContents;
itemContents << name;
itemContents << formatDateRelative(lastUsed);
itemContents << QString();
kDebug() << type << name << lastUsed;
QTreeWidgetItem * item = 0;
......@@ -289,6 +294,8 @@ void ManageConnectionWidget::restoreConnections()
mConnEditUi.listPppoe->insertTopLevelItems(0, pppoeItems);
mConnEditUi.listPppoe->resizeColumnToContents(0);
activeConnectionsChanged();
// check which tabs should be enabled depending on the existing hardware
updateTabStates();
}
......@@ -568,31 +575,7 @@ void ManageConnectionWidget::deleteClicked()
mUuidItemHash.remove(connectionId);
// remove secrets from wallet if using encrypted storage
//Knm::ConnectionPersistence::deleteSecrets(connectionId);
// remove connection file
//QFile connFile(KStandardDirs::locateLocal("data",
// Knm::ConnectionPersistence::CONNECTION_PERSISTENCE_PATH + connectionId));
//if (!connFile.exists()) {
// kDebug() << "Connection file not found: " << connFile.fileName();
//}
//connFile.remove();
// remove from networkmanagerrc
//KNetworkManagerServicePrefs * prefs = KNetworkManagerServicePrefs::self();
//prefs->config()->deleteGroup(QLatin1String("Connection_") + connectionId);
//QStringList connectionIds = prefs->connections();
//connectionIds.removeAll(connectionId);
//prefs->setConnections(connectionIds);
//prefs->writeConfig();
//Knm::Connection::Scope conScope = (Knm::Connection::Scope) item->data(0, ConnectionScopeRole).toUInt();
/*
if (conScope == Knm::Connection::User)
mUserSettings->removeConnection(connectionId);
else
*/
mSystemSettings->removeConnection(connectionId);
//Enable this if connections is not removed from plasma-applet
......@@ -716,52 +699,17 @@ void ManageConnectionWidget::connectionTypeMenuTriggered(QAction* action)
void ManageConnectionWidget::activeConnectionsChanged()
{
#if 0
// indicate which connections are in use right now
QStringList activeConnections = Solid::Control::NetworkManagerNm09::activeConnections();
foreach (QString conn, activeConnections) {
OrgFreedesktopNetworkManagerConnectionActiveInterface candidate(NM_DBUS_SERVICE,
conn, QDBusConnection::systemBus(), 0);
// do we own the connection?
if (candidate.serviceName() == NM_DBUS_SERVICE_USER_SETTINGS) {
// get its UUID from our service
QDBusObjectPath connectionPath = candidate.connection();
OrgFreedesktopNetworkManagerSettingsConnectionInterface connection(NM_DBUS_SERVICE_USER_SETTINGS, connectionPath.path(), QDBusConnection::systemBus());
if (connection.isValid()) {
QVariantMapMap settings = connection.GetSettings();
QDBusError lastError = connection.lastError();
if (lastError.isValid()) {
kDebug() << "Could not get settings for " << connectionPath.path();
}
QString connKey = QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME);
if (settings.contains(connKey))
{
QVariantMap connectionSetting = settings.value(connKey);
QString uuidKey = QLatin1String(NM_SETTING_CONNECTION_UUID);
QString typeKey = QLatin1String(NM_SETTING_CONNECTION_TYPE);
if (!connectionSetting.contains(uuidKey)) {
kDebug() << "Settings does not contain UUID!";
}
if (!connectionSetting.contains(typeKey)) {
kDebug() << "Settings does not contain UUID!";
}
QString uuid = connectionSetting.value(uuidKey).toString();
QString type = connectionSetting.value(typeKey).toString();
kDebug() << "Connection at " << connectionPath.path() << " has uuid '" << uuid << "' and type '" << type;
QTreeWidgetItem * item = mUuidItemHash.value(uuid);
if (item) {
kDebug() << "Setting last used text to Now";
item->setText(1, i18nc("Text for connection list entry that is currently in used", "Now"));
}
} else {
kDebug() << "No" << QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME) << "in settings from" << connectionPath.path() << ", keys: " << settings.keys();
}
} else {
kDebug() << "Connection '" << connectionPath.path() << "' is not valid!";
}
QTreeWidgetItem * item = 0;
foreach(QTreeWidgetItem * t, mUuidItemHash.values()) {
t->setText(ConnectionStateColumn, QString());
}
foreach(QString activeConnection, Solid::Control::NetworkManagerNm09::activeConnectionsUuid()) {
activeConnection = "{" + activeConnection + "}";
item = mUuidItemHash.value(activeConnection);
if (item != 0) {
item->setText(ConnectionStateColumn, i18n("Connected"));
}
}
#endif
}
void ManageConnectionWidget::updateLastUsed()
......
......@@ -48,6 +48,11 @@
<string>Last Used</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</item>
<item>
......@@ -84,6 +89,11 @@
<string>Last Used</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</item>
<item>
......@@ -117,6 +127,11 @@
<string>Last Used</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</item>
<item>
......@@ -150,6 +165,11 @@
<string>Last Used</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</item>
<item>
......@@ -183,6 +203,11 @@
<string>Last Used</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</item>
<item>
......
......@@ -78,6 +78,11 @@ namespace Ifaces
*/
virtual bool firmwareMissing() const = 0;
/**
* Current active connection.
*/
virtual QString activeConnection() const = 0;
/**
* Handle for the system driver controlling this network interface
*/
......
......@@ -128,6 +128,11 @@ namespace Ifaces
*/
virtual QStringList activeConnections() const = 0;
/**
* Access the list of active connection UUIDs
*/
virtual QStringList activeConnectionsUuid() const = 0;
/**
* Retrieves the interface types supported by this network manager.
*
......
......@@ -83,6 +83,12 @@ QString Solid::Control::NetworkInterfaceNm09::ipInterfaceName() const
return_SOLID_CALL(Ifaces::NetworkInterfaceNm09 *, d->backendObject(), QString(), ipInterfaceName());
}
QString Solid::Control::NetworkInterfaceNm09::activeConnection() const
{
Q_D(const NetworkInterfaceNm09);
return_SOLID_CALL(Ifaces::NetworkInterfaceNm09 *, d->backendObject(), QString(), activeConnection());
}
QString Solid::Control::NetworkInterfaceNm09::driver() const
{
Q_D(const NetworkInterfaceNm09);
......
......@@ -171,6 +171,11 @@ namespace Control
*/
bool firmwareMissing() const;
/**
* Current active connection.
*/
QString activeConnection() const;
/**
* Handle for the system driver controlling this network interface
*/
......
......@@ -309,5 +309,10 @@ QStringList Solid::Control::NetworkManagerNm09::activeConnections()
return_SOLID_CALL(Ifaces::NetworkManager *, globalNetworkManager->managerBackend(), QStringList(), activeConnections());
}
QStringList Solid::Control::NetworkManagerNm09::activeConnectionsUuid()
{
return_SOLID_CALL(Ifaces::NetworkManager *, globalNetworkManager->managerBackend(), QStringList(), activeConnectionsUuid());
}
#include "networkmanager_p.moc"
#include "networkmanager.moc"
......@@ -156,6 +156,11 @@ namespace Control
*/
QStringList SOLIDCONTROL_EXPORT activeConnections();
/**
* Access the list of any active connections
*/
QStringList SOLIDCONTROL_EXPORT activeConnectionsUuid();
/**
* Retrieves the interface types supported by this network manager.
*
......
......@@ -41,6 +41,7 @@ set( DBUS_INTERFACES_FILES
dbus/nm-device-btinterface.cpp
dbus/nm-ip4-configinterface.cpp
dbus/nm-dhcp4-configinterface.cpp
dbus/nm-active-connectioninterface.cpp
)
......
......@@ -2,12 +2,26 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Connection.Active">
<tp:docstring>
Objects that implement the Connection.Active interface represent an attempt
to connect to a network using the details provided by a Connection object.
The Connection.Active object tracks the life-cycle of the connection
attempt and if successful indicates whether the connected network is the
"default" or preferred network for access.
</tp:docstring>
<property name="Connection" type="o" access="read">
<tp:docstring>The path of the connection.</tp:docstring>
</property>
<property name="SpecificObject" type="o" access="read">
<tp:docstring>A specific object associated with the active connection.</tp:docstring>
</property>
<property name="Uuid" type="s" access="read">
<tp:docstring>
The UUID of the connection, provided as a convenience so that clients
do not have to retrieve all connection details.
</tp:docstring>
</property>
<property name="Devices" type="ao" access="read">
<tp:docstring>Array of object paths representing devices which are part of this active connection.</tp:docstring>
</property>
......@@ -26,6 +40,7 @@
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
<tp:docstring>
A dictionary mapping property names to variant boxed values
</tp:docstring>
......
......@@ -41,7 +41,7 @@
Flags describing the capabilities of the device.
</tp:docstring>
</property>
<property name="Ip4Address" type="i" access="read">
<property name="Ip4Address" type="u" access="read">
<tp:docstring>
The IPv4 address bound to the device. FIXME: what about devices with >1 IP address?
</tp:docstring>
......@@ -51,6 +51,14 @@
The current state of the device.
</tp:docstring>
</property>
<property name="ActiveConnection" type="o" access="read">
<tp:docstring>
Object path of an ActiveConnection object that "owns" this device during
activation. The ActiveConnection object tracks the life-cycle of a
connection to a specific network and implements the
org.freedesktop.NetworkManager.Connection.Active D-Bus interface.
</tp:docstring>
</property>
<property name="Ip4Config" type="o" access="read">
<tp:docstring>
Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
......
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -N -m -p nm-active-connectioninterface introspection/nm-active-connection.xml
*
* qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "nm-active-connectioninterface.h"
/*
* Implementation of interface class OrgFreedesktopNetworkManagerConnectionActiveInterface
*/
OrgFreedesktopNetworkManagerConnectionActiveInterface::OrgFreedesktopNetworkManagerConnectionActiveInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
{
}
OrgFreedesktopNetworkManagerConnectionActiveInterface::~OrgFreedesktopNetworkManagerConnectionActiveInterface()
{
}
#include "nm-active-connectioninterface.moc"
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -N -m -p nm-active-connectioninterface introspection/nm-active-connection.xml
*
* qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef NM_ACTIVE_CONNECTIONINTERFACE_H_1310070406
#define NM_ACTIVE_CONNECTIONINTERFACE_H_1310070406
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.freedesktop.NetworkManager.Connection.Active
*/
class OrgFreedesktopNetworkManagerConnectionActiveInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.freedesktop.NetworkManager.Connection.Active"; }
public:
OrgFreedesktopNetworkManagerConnectionActiveInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~OrgFreedesktopNetworkManagerConnectionActiveInterface();
Q_PROPERTY(QDBusObjectPath Connection READ connection)
inline QDBusObjectPath connection() const
{ return qvariant_cast< QDBusObjectPath >(property("Connection")); }
Q_PROPERTY(bool isDefaultIpV4 READ isDefaultIpV4)
inline bool isDefaultIpV4() const
{ return qvariant_cast< bool >(property("Default")); }
Q_PROPERTY(bool isDefaultIpV6 READ isDefaultIpV6)
inline bool isDefaultIpV6() const
{ return qvariant_cast< bool >(property("Default6")); }
Q_PROPERTY(QList<QDBusObjectPath> Devices READ devices)
inline QList<QDBusObjectPath> devices() const
{ return qvariant_cast< QList<QDBusObjectPath> >(property("Devices")); }
Q_PROPERTY(QDBusObjectPath SpecificObject READ specificObject)
inline QDBusObjectPath specificObject() const
{ return qvariant_cast< QDBusObjectPath >(property("SpecificObject")); }
Q_PROPERTY(uint State READ state)
inline uint state() const
{ return qvariant_cast< uint >(property("State")); }
Q_PROPERTY(QString Uuid READ uuid)
inline QString uuid() const
{ return qvariant_cast< QString >(property("Uuid")); }
Q_PROPERTY(bool Vpn READ vpn)
inline bool vpn() const
{ return qvariant_cast< bool >(property("Vpn")); }
public Q_SLOTS: // METHODS
Q_SIGNALS: // SIGNALS
void PropertiesChanged(const QVariantMap &properties);
};
#endif
......@@ -8,8 +8,8 @@
* Do not edit! All changes made to it will be lost.
*/
#ifndef NM_DEVICEINTERFACE_H_1305476817
#define NM_DEVICEINTERFACE_H_1305476817
#ifndef NM_DEVICEINTERFACE_H_1310067075
#define NM_DEVICEINTERFACE_H_1310067075
#include <QtCore/QObject>
#include <QtCore/QByteArray>
......@@ -35,6 +35,10 @@ public:
~OrgFreedesktopNetworkManagerDeviceInterface();
Q_PROPERTY(QDBusObjectPath ActiveConnection READ activeConnection)
inline QDBusObjectPath activeConnection() const
{ return qvariant_cast< QDBusObjectPath >(property("ActiveConnection")); }
Q_PROPERTY(uint Capabilities READ capabilities)
inline uint capabilities() const
{ return qvariant_cast< uint >(property("Capabilities")); }
......@@ -63,9 +67,9 @@ public:
inline QString interface() const
{ return qvariant_cast< QString >(property("Interface")); }
Q_PROPERTY(int Ip4Address READ ip4Address)
inline int ip4Address() const
{ return qvariant_cast< int >(property("Ip4Address")); }
Q_PROPERTY(uint Ip4Address READ ip4Address)
inline uint ip4Address() const
{ return qvariant_cast< uint >(property("Ip4Address")); }
Q_PROPERTY(QDBusObjectPath Ip4Config READ ip4Config)
inline QDBusObjectPath ip4Config() const
......
......@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wirelessnetworkinterface.h"
#include "networkmodeminterface.h"
#include "networkbtinterface.h"
#include "dbus/nm-active-connectioninterface.h"
NMNetworkManagerPrivate::NMNetworkManagerPrivate()
: iface(NM_DBUS_SERVICE, NM_DBUS_PATH, QDBusConnection::systemBus())
......@@ -240,7 +241,7 @@ void NMNetworkManager::stateChanged(uint state)
d->isWwanHardwareEnabled = d->iface.wwanHardwareEnabled();
d->isWwanEnabled = d->iface.wwanEnabled();
d->isNetworkingEnabled = d->iface.networkingEnabled();
}
}
// set new state
d->nmState = state;
......@@ -358,6 +359,17 @@ QStringList NMNetworkManager::activeConnections() const
return d->activeConnections;
}
QStringList NMNetworkManager::activeConnectionsUuid() const
{
Q_D(const NMNetworkManager);
QStringList r;
foreach(const QString objPath, d->activeConnections) {
OrgFreedesktopNetworkManagerConnectionActiveInterface iface(NM_DBUS_SERVICE, objPath, QDBusConnection::systemBus());
r.append(iface.uuid());
}
return r;
}
Solid::Control::NetworkInterfaceNm09::Types NMNetworkManager::supportedInterfaceTypes() const
{
return (Solid::Control::NetworkInterfaceNm09::Types) (
......
......@@ -52,6 +52,7 @@ public:
QString version() const;
void deactivateConnection(const QString & activeConnection);
QStringList activeConnections() const;
QStringList activeConnectionsUuid() const;
Solid::Control::NetworkInterfaceNm09::Types supportedInterfaceTypes() const;
public Q_SLOTS:
void setNetworkingEnabled(bool enabled);
......
......@@ -134,6 +134,12 @@ bool NMNetworkInterface::firmwareMissing() const
return d->firmwareMissing;
}
QString NMNetworkInterface::activeConnection() const
{
Q_D(const NMNetworkInterface);
return d->deviceIface.activeConnection().path();
}
void NMNetworkInterface::setDriver(const QVariant & driver)
{
Q_D(NMNetworkInterface);
......@@ -146,7 +152,7 @@ QString NMNetworkInterface::udi() const
return d->udi;
}
int NMNetworkInterface::ipV4Address() const
uint NMNetworkInterface::ipV4Address() const
{
Q_D(const NMNetworkInterface);
return d->ipV4Address;
......
......@@ -60,7 +60,7 @@ public:
QString driver() const;
void setDriver(const QVariant&);
void disconnectInterface();
int ipV4Address() const;
uint ipV4Address() const;
Solid::Control::IPv4ConfigNm09 ipV4Config() const;
// TODO: implement IPv6Config.
bool isActive() const;
......@@ -76,6 +76,7 @@ public:
void setManaged(const QVariant&);
QString udi() const;
bool firmwareMissing() const;
QString activeConnection() const;
Q_SIGNALS:
void ipDetailsChanged();
......
......@@ -41,7 +41,7 @@ public:
bool managed;
Solid::Control::IPv4ConfigNm09 ipV4Config;
QString driver;
int ipV4Address;
uint ipV4Address;
QString interfaceName;
bool firmwareMissing;
NMNetworkManager * manager;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment