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