2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License or (at your option) version 3 or any later version
8
accepted by the membership of KDE e.V. (or its successor approved
9
by the membership of KDE e.V.), which shall act as a proxy
10
defined in Section 14 of version 3 of the license.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include "remoteconnection.h"
23
#include <NetworkManager.h>
24
#include <nm-setting-cdma.h>
25
#include <nm-setting-connection.h>
26
#include <nm-setting-gsm.h>
27
#include <nm-setting-pppoe.h>
28
#include <nm-setting-vpn.h>
29
#include <nm-setting-wired.h>
30
#include <nm-setting-wireless.h>
32
#include <QDBusConnection>
36
#include <solid/control/networkmanager.h>
38
#include "nm-active-connectioninterface.h"
40
RemoteConnection::RemoteConnection(const QString& service, const QString & path, QObject * parent)
41
: OrgFreedesktopNetworkManagerSettingsConnectionInterface(service, path, QDBusConnection::systemBus(), parent)
43
qDBusRegisterMetaType<QMap<QString, QVariant> >();
44
qDBusRegisterMetaType<QMap<QString, QMap<QString, QVariant> > >();
46
m_connection = GetSettings();
48
m_type = Solid::Control::NetworkInterface::UnknownType;
50
//kDebug() << m_connection;
52
if ( m_connection.contains(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME))) {
53
QVariantMap connectionSetting = m_connection.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME));
54
if (connectionSetting.contains(QLatin1String(NM_SETTING_CONNECTION_ID))) {
55
m_id = connectionSetting.value(QLatin1String(NM_SETTING_CONNECTION_ID)).toString();
58
if (connectionSetting.contains(QLatin1String(NM_SETTING_CONNECTION_TYPE))) {
59
nmType = connectionSetting.value(QLatin1String(NM_SETTING_CONNECTION_TYPE)).toString();
62
if (nmType == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) {
63
m_type = Solid::Control::NetworkInterface::Cdma;
64
} else if (nmType == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) {
65
m_type = Solid::Control::NetworkInterface::Gsm;
66
} else if (nmType == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) {
67
m_type = Solid::Control::NetworkInterface::Serial;
68
} else if (nmType == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) {
69
m_type = Solid::Control::NetworkInterface::Ieee8023;
70
} else if (nmType == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) {
71
m_type = Solid::Control::NetworkInterface::Ieee80211;
76
RemoteConnection::~RemoteConnection()
80
QString RemoteConnection::id() const
85
Solid::Control::NetworkInterface::Type RemoteConnection::type() const
90
QVariantMapMap RemoteConnection::settings() const
95
bool RemoteConnection::active() const
97
QStringList activeConnections = Solid::Control::NetworkManager::activeConnections();
98
foreach (QString conn, activeConnections) {
99
OrgFreedesktopNetworkManagerConnectionActiveInterface candidate(NM_DBUS_SERVICE,
100
conn, QDBusConnection::systemBus(), 0);
101
if (candidate.serviceName() == service() && candidate.connection().path() == path()) {
108
QString RemoteConnection::path() const
112
// vim: sw=4 sts=4 et tw=100