NetworkManagerQt

vpnplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "vpnplugin.h"
8
9#include "manager_p.h"
10#include "vpnplugininterface.h"
11
12class NetworkManager::VpnPluginPrivate
13{
14public:
15 VpnPluginPrivate(const QString &path);
16
18 OrgFreedesktopNetworkManagerVPNPluginInterface iface;
19};
20
21NetworkManager::VpnPluginPrivate::VpnPluginPrivate(const QString &path)
22#ifdef NMQT_STATIC
23 : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
24#else
25 : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
26#endif
27{
28}
29
30NetworkManager::VpnPlugin::VpnPlugin(const QString &path, QObject *parent)
31 : QObject(parent)
32 , d_ptr(new VpnPluginPrivate(path))
33{
34 Q_D(VpnPlugin);
35 d->state = (NetworkManager::VpnConnection::State)d->iface.state();
36
37 QObject::connect(&d->iface, SIGNAL(Config(QVariantMap)), this, SLOT(setConfig(QVariantMap)));
38 QObject::connect(&d->iface, SIGNAL(Failure(uint)), this, SLOT(setFailure(QString)));
39 QObject::connect(&d->iface, SIGNAL(Ip4Config(QVariantMap)), this, SLOT(setIp4Config(QVariantMap)));
40 QObject::connect(&d->iface, SIGNAL(Ip6Config(QVariantMap)), this, SLOT(setIp6Config(QVariantMap)));
41 // QObject::connect(&d->iface, SIGNAL(LoginBanner(QString)),
42 // this, SLOT(onLoginBanner(QString)));
43 QObject::connect(&d->iface, SIGNAL(StateChanged(uint)), this, SLOT(onStateChanged(uint)));
44}
45
46NetworkManager::VpnPlugin::~VpnPlugin()
47{
48 delete d_ptr;
49}
50
51void NetworkManager::VpnPlugin::connect(const NMVariantMapMap &connection)
52{
53 Q_D(VpnPlugin);
54
55 QDBusPendingReply<> reply = d->iface.Connect(connection);
56}
57
58void NetworkManager::VpnPlugin::disconnect()
59{
60 Q_D(VpnPlugin);
61
62 QDBusPendingReply<> reply = d->iface.Disconnect();
63}
64
65QString NetworkManager::VpnPlugin::needSecrets(const NMVariantMapMap &connection)
66{
67 Q_D(VpnPlugin);
68
69 QDBusPendingReply<QString> reply = d->iface.NeedSecrets(connection);
70
71 return reply.value();
72}
73
74void NetworkManager::VpnPlugin::setConfig(const QVariantMap &configuration)
75{
76 Q_D(VpnPlugin);
77
78 QDBusPendingReply<QString> reply = d->iface.SetConfig(configuration);
79
80 Q_EMIT configChanged(configuration);
81}
82
83void NetworkManager::VpnPlugin::setFailure(const QString &reason)
84{
85 Q_D(VpnPlugin);
86
87 QDBusPendingReply<QString> reply = d->iface.SetFailure(reason);
88
89 // TODO
90 // Q_EMIT failureChanged(reason);
91}
92
93void NetworkManager::VpnPlugin::setIp4Config(const QVariantMap &config)
94{
95 Q_D(VpnPlugin);
96
97 QDBusPendingReply<> reply = d->iface.SetIp4Config(config);
98
99 Q_EMIT ip4ConfigChanged(config);
100}
101
102void NetworkManager::VpnPlugin::setIp6Config(const QVariantMap &config)
103{
104 Q_D(VpnPlugin);
105
106 QDBusPendingReply<> reply = d->iface.SetIp6Config(config);
107
108 Q_EMIT ip6ConfigChanged(config);
109}
110
111void NetworkManager::VpnPlugin::onStateChanged(uint state)
112{
113 Q_D(VpnPlugin);
114
115 d->state = (VpnConnection::State)state;
116
117 Q_EMIT stateChanged(d->state);
118}
119
120#include "moc_vpnplugin.cpp"
State
Enum describing the possible VPN connection states.
QString path(const QString &relativePath)
QDBusConnection sessionBus()
QDBusConnection systemBus()
typename Select< 0 >::Type value() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.