1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301 USA.
18 * Copyright 2007 - 2008 Novell, Inc.
19 * Copyright 2007 - 2012 Red Hat, Inc.
26 #include <glib-object.h>
28 #include <dbus/dbus-glib.h>
29 #include <NetworkManager.h>
30 #include "nm-object.h"
31 #include "nm-device.h"
32 #include "nm-active-connection.h"
33 #include "nm-vpn-connection.h"
37 #define NM_TYPE_CLIENT (nm_client_get_type ())
38 #define NM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CLIENT, NMClient))
39 #define NM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CLIENT, NMClientClass))
40 #define NM_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CLIENT))
41 #define NM_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CLIENT))
42 #define NM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CLIENT, NMClientClass))
44 #define NM_CLIENT_VERSION "version"
45 #define NM_CLIENT_STATE "state"
46 #define NM_CLIENT_STARTUP "startup"
47 #define NM_CLIENT_MANAGER_RUNNING "manager-running"
48 #define NM_CLIENT_NETWORKING_ENABLED "networking-enabled"
49 #define NM_CLIENT_WIRELESS_ENABLED "wireless-enabled"
50 #define NM_CLIENT_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
51 #define NM_CLIENT_WWAN_ENABLED "wwan-enabled"
52 #define NM_CLIENT_WWAN_HARDWARE_ENABLED "wwan-hardware-enabled"
53 #define NM_CLIENT_WIMAX_ENABLED "wimax-enabled"
54 #define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled"
55 #define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections"
56 #define NM_CLIENT_CONNECTIVITY "connectivity"
57 #define NM_CLIENT_PRIMARY_CONNECTION "primary-connection"
58 #define NM_CLIENT_ACTIVATING_CONNECTION "activating-connection"
59 #define NM_CLIENT_DEVICES "devices"
60 #define NM_CLIENT_ALL_DEVICES "all-devices"
64 * @NM_CLIENT_PERMISSION_NONE: unknown or no permission
65 * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK: controls whether networking
66 * can be globally enabled or disabled
67 * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI: controls whether Wi-Fi can be
68 * globally enabled or disabled
69 * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN: controls whether WWAN (3G) can be
70 * globally enabled or disabled
71 * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX: controls whether WiMAX can be
72 * globally enabled or disabled
73 * @NM_CLIENT_PERMISSION_SLEEP_WAKE: controls whether the client can ask
74 * NetworkManager to sleep and wake
75 * @NM_CLIENT_PERMISSION_NETWORK_CONTROL: controls whether networking connections
76 * can be started, stopped, and changed
77 * @NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED: controls whether a password
78 * protected Wi-Fi hotspot can be created
79 * @NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN: controls whether an open Wi-Fi hotspot
81 * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM: controls whether connections
82 * that are available to all users can be modified
83 * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN: controls whether connections
84 * owned by the current user can be modified
85 * @NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME: controls whether the
86 * persistent hostname can be changed
87 * @NM_CLIENT_PERMISSION_LAST: a reserved boundary value
89 * #NMClientPermission values indicate various permissions that NetworkManager
90 * clients can obtain to perform certain tasks on behalf of the current user.
93 NM_CLIENT_PERMISSION_NONE = 0,
94 NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1,
95 NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2,
96 NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3,
97 NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX = 4,
98 NM_CLIENT_PERMISSION_SLEEP_WAKE = 5,
99 NM_CLIENT_PERMISSION_NETWORK_CONTROL = 6,
100 NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED = 7,
101 NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN = 8,
102 NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM = 9,
103 NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN = 10,
104 NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME = 11,
106 NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME
107 } NMClientPermission;
110 * NMClientPermissionResult:
111 * @NM_CLIENT_PERMISSION_RESULT_UNKNOWN: unknown or no authorization
112 * @NM_CLIENT_PERMISSION_RESULT_YES: the permission is available
113 * @NM_CLIENT_PERMISSION_RESULT_AUTH: authorization is necessary before the
114 * permission is available
115 * @NM_CLIENT_PERMISSION_RESULT_NO: permission to perform the operation is
116 * denied by system policy
118 * #NMClientPermissionResult values indicate what authorizations and permissions
119 * the user requires to obtain a given #NMClientPermission
122 NM_CLIENT_PERMISSION_RESULT_UNKNOWN = 0,
123 NM_CLIENT_PERMISSION_RESULT_YES,
124 NM_CLIENT_PERMISSION_RESULT_AUTH,
125 NM_CLIENT_PERMISSION_RESULT_NO
126 } NMClientPermissionResult;
130 * @NM_CLIENT_ERROR_UNKNOWN: unknown or unclassified error
131 * @NM_CLIENT_ERROR_MANAGER_NOT_RUNNING: an operation that requires NetworkManager
132 * failed because NetworkManager is not running
134 * Describes errors that may result from operations involving a #NMClient.
137 NM_CLIENT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
138 NM_CLIENT_ERROR_MANAGER_NOT_RUNNING, /*< nick=ManagerNotRunning >*/
141 #define NM_CLIENT_ERROR nm_client_error_quark ()
142 NM_AVAILABLE_IN_0_9_10
143 GQuark nm_client_error_quark (void);
150 NMObjectClass parent;
153 void (*device_added) (NMClient *client, NMDevice *device);
154 void (*device_removed) (NMClient *client, NMDevice *device);
155 void (*permission_changed) (NMClient *client,
156 NMClientPermission permission,
157 NMClientPermissionResult result);
159 /* Padding for future expansion */
160 void (*_reserved1) (void);
161 void (*_reserved2) (void);
162 void (*_reserved3) (void);
163 void (*_reserved4) (void);
164 void (*_reserved5) (void);
165 void (*_reserved6) (void);
168 GType nm_client_get_type (void);
170 NMClient *nm_client_new (void);
172 void nm_client_new_async (GCancellable *cancellable,
173 GAsyncReadyCallback callback,
175 NMClient *nm_client_new_finish (GAsyncResult *result,
178 const GPtrArray *nm_client_get_devices (NMClient *client);
180 const GPtrArray *nm_client_get_all_devices(NMClient *client);
181 NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_path);
182 NMDevice *nm_client_get_device_by_iface (NMClient *client, const char *iface);
184 typedef void (*NMClientActivateFn) (NMClient *client,
185 NMActiveConnection *active_connection,
189 void nm_client_activate_connection (NMClient *client,
190 NMConnection *connection,
192 const char *specific_object,
193 NMClientActivateFn callback,
196 typedef void (*NMClientAddActivateFn) (NMClient *client,
197 NMActiveConnection *connection,
198 const char *new_connection_path,
202 void nm_client_add_and_activate_connection (NMClient *client,
203 NMConnection *partial,
205 const char *specific_object,
206 NMClientAddActivateFn callback,
209 void nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active);
211 gboolean nm_client_networking_get_enabled (NMClient *client);
212 void nm_client_networking_set_enabled (NMClient *client, gboolean enabled);
214 gboolean nm_client_wireless_get_enabled (NMClient *client);
215 void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled);
216 gboolean nm_client_wireless_hardware_get_enabled (NMClient *client);
218 gboolean nm_client_wwan_get_enabled (NMClient *client);
219 void nm_client_wwan_set_enabled (NMClient *client, gboolean enabled);
220 gboolean nm_client_wwan_hardware_get_enabled (NMClient *client);
222 gboolean nm_client_wimax_get_enabled (NMClient *client);
223 void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled);
224 gboolean nm_client_wimax_hardware_get_enabled (NMClient *client);
226 const char *nm_client_get_version (NMClient *client);
227 NMState nm_client_get_state (NMClient *client);
228 NM_AVAILABLE_IN_0_9_10
229 gboolean nm_client_get_startup (NMClient *client);
230 gboolean nm_client_get_manager_running (NMClient *client);
231 const GPtrArray *nm_client_get_active_connections (NMClient *client);
232 void nm_client_sleep (NMClient *client, gboolean sleep_);
234 NMClientPermissionResult nm_client_get_permission_result (NMClient *client,
235 NMClientPermission permission);
237 gboolean nm_client_get_logging (NMClient *client, char **level, char **domains, GError **error);
238 gboolean nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error);
240 NMConnectivityState nm_client_get_connectivity (NMClient *client);
242 NMConnectivityState nm_client_check_connectivity (NMClient *client,
243 GCancellable *cancellable,
245 void nm_client_check_connectivity_async (NMClient *client,
246 GCancellable *cancellable,
247 GAsyncReadyCallback callback,
249 NMConnectivityState nm_client_check_connectivity_finish (NMClient *client,
250 GAsyncResult *result,
253 NMActiveConnection *nm_client_get_primary_connection (NMClient *client);
254 NMActiveConnection *nm_client_get_activating_connection (NMClient *client);
258 #endif /* NM_CLIENT_H */