device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-glib / nm-remote-settings.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
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.
7  *
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.
12  *
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.
17  *
18  * Copyright 2008 Novell, Inc.
19  * Copyright 2009 - 2011 Red Hat, Inc.
20  */
21
22 #ifndef NM_REMOTE_SETTINGS_H
23 #define NM_REMOTE_SETTINGS_H
24
25 #include <gio/gio.h>
26 #include <dbus/dbus-glib.h>
27 #include <nm-connection.h>
28 #include <nm-remote-connection.h>
29
30 G_BEGIN_DECLS
31
32 #define NM_TYPE_REMOTE_SETTINGS            (nm_remote_settings_get_type ())
33 #define NM_REMOTE_SETTINGS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettings))
34 #define NM_REMOTE_SETTINGS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
35 #define NM_IS_REMOTE_SETTINGS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS))
36 #define NM_IS_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_REMOTE_SETTINGS))
37 #define NM_REMOTE_SETTINGS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
38
39 /**
40  * NMRemoteSettingsError:
41  * @NM_REMOTE_SETTINGS_ERROR_UNKNOWN: unknown or unclassified error
42  * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED: the #NMRemoteConnection object
43  *   was removed before it was completely initialized
44  * @NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE: the #NMRemoteConnection object
45  *   is not visible or otherwise unreadable
46  * @NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE: NetworkManager is not running.
47  *   (Since 0.9.10)
48  *
49  * Describes errors that may result from operations involving a #NMRemoteSettings.
50  *
51  **/
52 typedef enum {
53         NM_REMOTE_SETTINGS_ERROR_UNKNOWN = 0,            /*< nick=UnknownError >*/
54         NM_REMOTE_SETTINGS_ERROR_CONNECTION_REMOVED,     /*< nick=ConnectionRemoved >*/
55         NM_REMOTE_SETTINGS_ERROR_CONNECTION_UNAVAILABLE, /*< nick=ConnectionUnavailable >*/
56         NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,    /*< nick=ServiceUnavailable >*/
57 } NMRemoteSettingsError;
58
59 #define NM_REMOTE_SETTINGS_ERROR nm_remote_settings_error_quark ()
60 GQuark nm_remote_settings_error_quark (void);
61
62
63 #define NM_REMOTE_SETTINGS_BUS             "bus"
64 #define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running"
65 #define NM_REMOTE_SETTINGS_HOSTNAME        "hostname"
66 #define NM_REMOTE_SETTINGS_CAN_MODIFY      "can-modify"
67
68 #define NM_REMOTE_SETTINGS_NEW_CONNECTION    "new-connection"
69 #define NM_REMOTE_SETTINGS_CONNECTIONS_READ  "connections-read"
70
71 typedef struct _NMRemoteSettings NMRemoteSettings;
72 typedef struct _NMRemoteSettingsClass NMRemoteSettingsClass;
73
74
75 typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings,
76                                                    NMRemoteConnection *connection,
77                                                    GError *error,
78                                                    gpointer user_data);
79
80 typedef void (*NMRemoteSettingsLoadConnectionsFunc) (NMRemoteSettings *settings,
81                                                      char **failures,
82                                                      GError *error,
83                                                      gpointer user_data);
84
85 typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings,
86                                                   GError *error,
87                                                   gpointer user_data);
88
89
90 struct _NMRemoteSettings {
91         GObject parent;
92 };
93
94 struct _NMRemoteSettingsClass {
95         GObjectClass parent;
96
97         /* Signals */
98         void (*new_connection) (NMRemoteSettings *settings,
99                                 NMRemoteConnection *connection);
100
101         void (*connections_read) (NMRemoteSettings *settings);
102
103         /* Padding for future expansion */
104         void (*_reserved1) (void);
105         void (*_reserved2) (void);
106         void (*_reserved3) (void);
107         void (*_reserved4) (void);
108         void (*_reserved5) (void);
109         void (*_reserved6) (void);
110 };
111
112 GType nm_remote_settings_get_type (void);
113
114 NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus);
115
116 void              nm_remote_settings_new_async  (DBusGConnection      *bus,
117                                                  GCancellable         *cancellable,
118                                                  GAsyncReadyCallback   callback,
119                                                  gpointer              user_data);
120 NMRemoteSettings *nm_remote_settings_new_finish (GAsyncResult         *result,
121                                                  GError              **error);
122
123 GSList *nm_remote_settings_list_connections (NMRemoteSettings *settings);
124
125 NMRemoteConnection *nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings,
126                                                              const char *id);
127
128 NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings,
129                                                                 const char *path);
130
131 NMRemoteConnection *nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings,
132                                                                const char *uuid);
133
134 gboolean nm_remote_settings_add_connection (NMRemoteSettings *settings,
135                                             NMConnection *connection,
136                                             NMRemoteSettingsAddConnectionFunc callback,
137                                             gpointer user_data);
138
139 NM_AVAILABLE_IN_0_9_10
140 gboolean nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
141                                                     NMConnection *connection,
142                                                     NMRemoteSettingsAddConnectionFunc callback,
143                                                     gpointer user_data);
144
145 NM_AVAILABLE_IN_0_9_10
146 gboolean nm_remote_settings_load_connections (NMRemoteSettings *settings,
147                                               char **filenames,
148                                               char ***failures,
149                                               GError **error);
150
151 NM_AVAILABLE_IN_0_9_10
152 gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
153                                                 GError **error);
154
155 gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings,
156                                            const char *hostname,
157                                            NMRemoteSettingsSaveHostnameFunc callback,
158                                            gpointer user_data);
159
160 G_END_DECLS
161
162 #endif /* NM_REMOTE_SETTINGS_H */