NetworkManagerQt

fakenetwork/activeconnection.cpp
1/*
2 SPDX-FileCopyrightText: 2014 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 "activeconnection.h"
8#include "connection.h"
9
10#include <QDBusConnection>
11
12ActiveConnection::ActiveConnection(QObject *parent)
13 : QObject(parent)
14 , m_connection(QDBusObjectPath("/"))
15 , m_default4(false)
16 , m_default6(false)
17 , m_dhcp4Config(QDBusObjectPath("/"))
18 , m_dhcp6Config(QDBusObjectPath("/"))
19 , m_ip4Config(QDBusObjectPath("/"))
20 , m_ip6Config(QDBusObjectPath("/"))
21 , m_master(QDBusObjectPath("/"))
22 , m_specificObject(QDBusObjectPath("/"))
23 , m_state(0)
24 , m_vpn(false)
25{
26}
27
28ActiveConnection::~ActiveConnection()
29{
30}
31
32QDBusObjectPath ActiveConnection::connection() const
33{
34 return m_connection;
35}
36
37bool ActiveConnection::default4() const
38{
39 return m_default4;
40}
41
42bool ActiveConnection::default6() const
43{
44 return m_default6;
45}
46
47QList<QDBusObjectPath> ActiveConnection::devices() const
48{
49 return m_devices;
50}
51
52QDBusObjectPath ActiveConnection::dhcp4Config() const
53{
54 return m_dhcp4Config;
55}
56
57QDBusObjectPath ActiveConnection::dhcp6Config() const
58{
59 return m_dhcp6Config;
60}
61
62QString ActiveConnection::id() const
63{
64 return m_id;
65}
66
67QDBusObjectPath ActiveConnection::ip4Config() const
68{
69 return m_ip4Config;
70}
71
72QDBusObjectPath ActiveConnection::ip6Config() const
73{
74 return m_ip6Config;
75}
76
77QDBusObjectPath ActiveConnection::master() const
78{
79 return m_master;
80}
81
82QDBusObjectPath ActiveConnection::specificObject() const
83{
84 return m_specificObject;
85}
86
87uint ActiveConnection::state() const
88{
89 return m_state;
90}
91
92QString ActiveConnection::type() const
93{
94 return m_type;
95}
96
97bool ActiveConnection::vpn() const
98{
99 return m_vpn;
100}
101
102QString ActiveConnection::uuid() const
103{
104 return m_uuid;
105}
106
107void ActiveConnection::addDevice(const QDBusObjectPath &device)
108{
109 m_devices << device;
110}
111
112void ActiveConnection::removeDevice(const QDBusObjectPath &device)
113{
114 m_devices.removeAll(device);
115}
116
117QString ActiveConnection::activeConnectionPath() const
118{
119 return m_activeConnectionPath;
120}
121
122void ActiveConnection::setActiveConnectionPath(const QString &path)
123{
124 m_activeConnectionPath = path;
125}
126
127void ActiveConnection::setConnection(const QDBusObjectPath &connection)
128{
129 m_connection = connection;
130
131 Connection *usedConnection = static_cast<Connection *>(QDBusConnection::sessionBus().objectRegisteredAt(connection.path()));
132 if (usedConnection) {
133 NMVariantMapMap settings = usedConnection->GetSettings();
134 setId(settings.value(QLatin1String("connection")).value(QLatin1String("id")).toString());
135 setUuid(settings.value(QLatin1String("connection")).value(QLatin1String("uuid")).toString());
136 setType(settings.value(QLatin1String("connection")).value(QLatin1String("type")).toString());
137 }
138}
139
140void ActiveConnection::setDefault4(bool default4)
141{
142 m_default4 = default4;
143}
144
145void ActiveConnection::setDefault6(bool default6)
146{
147 m_default6 = default6;
148}
149
150void ActiveConnection::setDhcp4Config(const QDBusObjectPath &dhcp4Config)
151{
152 m_dhcp4Config = dhcp4Config;
153}
154
155void ActiveConnection::setDhcp6Config(const QDBusObjectPath &dhcp6Config)
156{
157 m_dhcp6Config = dhcp6Config;
158}
159
160void ActiveConnection::setId(const QString &id)
161{
162 m_id = id;
163}
164
165void ActiveConnection::setIpv4Config(const QDBusObjectPath &ipv4Config)
166{
167 m_ip4Config = ipv4Config;
168}
169
170void ActiveConnection::setIpv6Config(const QDBusObjectPath &ipv6Config)
171{
172 m_ip6Config = ipv6Config;
173}
174
175void ActiveConnection::setMaster(const QDBusObjectPath &master)
176{
177 m_master = master;
178}
179
180void ActiveConnection::setSpecificObject(const QDBusObjectPath &specificObject)
181{
182 m_specificObject = specificObject;
183}
184
185void ActiveConnection::setState(uint state)
186{
187 m_state = state;
188}
189
190void ActiveConnection::setType(const QString &type)
191{
192 m_type = type;
193
194 if (type == QLatin1String("vpn")) {
195 m_vpn = true;
196 }
197}
198
199void ActiveConnection::setUuid(const QString &uuid)
200{
201 m_uuid = uuid;
202}
203
204#include "moc_activeconnection.cpp"
char * toString(const EngineQuery &query)
QString path(const QString &relativePath)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QObject * objectRegisteredAt(const QString &path) const const
QDBusConnection sessionBus()
QString path() const const
qsizetype removeAll(const AT &t)
T value(const Key &key, const T &defaultValue) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.