1/*
2 SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
3 SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#ifndef NETWORKMANAGERQT_SETTINGS_H
10#define NETWORKMANAGERQT_SETTINGS_H
11
12#include <networkmanagerqt/networkmanagerqt_export.h>
13
14#include "connection.h"
15#include "generictypes.h"
16#include "manager.h"
17#include <QObject>
18
19#include <QString>
20
21namespace NetworkManager
22{
23/**
24 * This class manages provides access to connections and notify about new ones
25 */
26class NETWORKMANAGERQT_EXPORT SettingsNotifier : public QObject
27{
28 Q_OBJECT
29Q_SIGNALS:
30 /**
31 * Emitted when the settings are modifiable by user
32 * @param canModify @p true if the user can modify the settings
33 */
34 void canModifyChanged(bool canModify);
35 /**
36 * Emitted when the hostname has changed
37 * @param hostname new hostname
38 */
39 void hostnameChanged(const QString &hostname);
40 /**
41 * Emitted when a new connection is added
42 *
43 * \note This signal is not emitted when the Network Manager
44 * daemon starts, if you are interested in keeping an
45 * updated listing of connections you must also watch for
46 * NetworkManager::Notifier::serviceAppeared() and
47 * NetworkManager::Notifier::serviceDisappeared() signals
48 */
49 void connectionAdded(const QString &path);
50 /**
51 * Emitted when a new connection is removed
52 *
53 * \note This signal is not emitted when the Network Manager
54 * daemon starts, if you are interested in keeping an
55 * updated listing of connections you must also watch for
56 * NetworkManager::Notifier::serviceAppeared() and
57 * NetworkManager::Notifier::serviceDisappeared() signals
58 */
59 void connectionRemoved(const QString &path);
60};
61/**
62 * Retrieves the list of connections.
63 */
64NETWORKMANAGERQT_EXPORT NetworkManager::Connection::List listConnections();
65
66/**
67 * Retrieves the connection for the given path, returns null if not found
68 */
69NETWORKMANAGERQT_EXPORT NetworkManager::Connection::Ptr findConnection(const QString &path);
70
71/**
72 * Add new connection and save it to disk. This operation does not start
73 * the network connection unless (1) device is idle and able to connect to
74 * the network described by the new connection, and (2) the connection
75 * is allowed to be started automatically.
76 * Once the connection has been added, you will get a notification through
77 * SettingsNotifier::connectionAddComplete()
78 *
79 * @returns Uuid of the new connection that was just added.
80 *
81 * @since 0.9.9.0
82 */
83NETWORKMANAGERQT_EXPORT QDBusPendingReply<QDBusObjectPath> addConnection(const NMVariantMapMap &settings);
84
85/**
86 * Add new connection but do not save it to disk immediately. This
87 * operation does not start the network connection unless (1) device is
88 * idle and able to connect to the network described by the new connection,
89 * and (2) the connection is allowed to be started automatically.
90 *
91 * Use the 'Save' method on the connection to save these changes
92 * to disk. Note that unsaved changes will be lost if the
93 * connection is reloaded from disk (either automatically on file
94 * change or due to an explicit ReloadConnections call).
95 *
96 * Once the connection has been added, you will get a notification through
97 * SettingsNotifier::connectionAddComplete()
98 *
99 * @returns Uuid of the new connection that was just added.
100 *
101 * @since 0.9.9.0
102 */
103NETWORKMANAGERQT_EXPORT QDBusPendingReply<QDBusObjectPath> addConnectionUnsaved(const NMVariantMapMap &settings);
104
105/**
106 * Retrieves the connection for the given @p uuid, returns null if not found
107 */
108NETWORKMANAGERQT_EXPORT NetworkManager::Connection::Ptr findConnectionByUuid(const QString &uuid);
109
110/**
111 * Loads or reloads the indicated connections from disk. You
112 * should call this after making changes directly to an on-disk
113 * connection file to make sure that NetworkManager sees the
114 * changes. (If "monitor-connection-files" in NetworkManager.conf
115 * is "true", then this will have no real effect, but is
116 * harmless.) As with AddConnection(), this operation does not
117 * necessarily start the network connection.
118 *
119 * @returns Success or failure of the operation as a whole. True if
120 * NetworkManager at least tried to load the indicated
121 * connections, even if it did not succeed. False if an error
122 * occurred before trying to load the connections (eg,
123 * permission denied).
124 *
125 * @returns Paths of connection files that could not be loaded.
126 *
127 * @since 0.9.9.0
128 */
129NETWORKMANAGERQT_EXPORT QDBusPendingReply<bool, QStringList> loadConnections(const QStringList &filenames);
130
131/**
132 * Tells NetworkManager to reload all connection files from disk,
133 * including noticing any added or deleted connection files. By
134 * default, connections are re-read automatically any time they
135 * change, so you only need to use this command if you have set
136 * "monitor-connection-files=false" in NetworkManager.conf.
137 *
138 * @returns Success or failure.
139 *
140 * @since 0.9.9.0
141 */
142NETWORKMANAGERQT_EXPORT QDBusPendingReply<bool> reloadConnections();
143
144/**
145 * Configure the following hostname
146 */
147NETWORKMANAGERQT_EXPORT void saveHostname(const QString &hostname);
148
149/**
150 * Returns @p true if the user can modify the settings
151 */
152NETWORKMANAGERQT_EXPORT bool canModify();
153
154/**
155 * Returns hostname of the machine
156 */
157NETWORKMANAGERQT_EXPORT QString hostname();
158
159/**
160 * Notifier object for connecting signals
161 */
162NETWORKMANAGERQT_EXPORT SettingsNotifier *settingsNotifier();
163}
164
165#endif
166

source code of networkmanager-qt/src/settings.h