device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-glib / nm-remote-connection.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 2007 - 2008 Novell, Inc.
19  * Copyright 2007 - 2011 Red Hat, Inc.
20  */
21
22 #ifndef __NM_REMOTE_CONNECTION_H__
23 #define __NM_REMOTE_CONNECTION_H__
24
25 #include <glib-object.h>
26 #include <dbus/dbus-glib.h>
27
28 #include <nm-connection.h>
29
30 G_BEGIN_DECLS
31
32 #define NM_TYPE_REMOTE_CONNECTION            (nm_remote_connection_get_type ())
33 #define NM_REMOTE_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnection))
34 #define NM_REMOTE_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
35 #define NM_IS_REMOTE_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION))
36 #define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_REMOTE_CONNECTION))
37 #define NM_REMOTE_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
38
39
40 /**
41  * NMRemoteConnectionError:
42  * @NM_REMOTE_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
43  * @NM_REMOTE_CONNECTION_ERROR_DISCONNECTED: dbus disconnected
44  */
45 typedef enum {
46         NM_REMOTE_CONNECTION_ERROR_UNKNOWN = 0,             /*< nick=UnknownError >*/
47         NM_REMOTE_CONNECTION_ERROR_DISCONNECTED,            /*< nick=Disconnected >*/
48 } NMRemoteConnectionError;
49
50 #define NM_REMOTE_CONNECTION_ERROR (nm_remote_connection_error_quark ())
51 GQuark nm_remote_connection_error_quark (void);
52
53 /* Properties */
54 #define NM_REMOTE_CONNECTION_UNSAVED         "unsaved"
55
56 /* Signals */
57 #define NM_REMOTE_CONNECTION_UPDATED         "updated"
58 #define NM_REMOTE_CONNECTION_REMOVED         "removed"
59
60 typedef struct {
61         NMConnection parent;
62 } NMRemoteConnection;
63
64 typedef struct {
65         NMConnectionClass parent_class;
66
67         /* Signals */
68         void (*updated) (NMRemoteConnection *connection,
69                          GHashTable *new_settings);
70
71         void (*removed) (NMRemoteConnection *connection);
72
73         /* Padding for future expansion */
74         void (*_reserved1) (void);
75         void (*_reserved2) (void);
76         void (*_reserved3) (void);
77         void (*_reserved4) (void);
78         void (*_reserved5) (void);
79         void (*_reserved6) (void);
80 } NMRemoteConnectionClass;
81
82 /**
83  * NMRemoteConnectionResultFunc:
84  * @connection: the connection for which an operation was performed
85  * @error: on failure, a descriptive error
86  * @user_data: user data passed to function which began the operation
87  *
88  * Called when NetworkManager has finished an asynchronous operation on a
89  * connection, like commit changes, deleting, saving, etc.
90  */
91 typedef void (*NMRemoteConnectionResultFunc) (NMRemoteConnection *connection,
92                                               GError *error,
93                                               gpointer user_data);
94
95 /* Backwards compatibility */
96 typedef NMRemoteConnectionResultFunc NMRemoteConnectionCommitFunc;
97 typedef NMRemoteConnectionResultFunc NMRemoteConnectionDeleteFunc;
98
99 /**
100  * NMRemoteConnectionGetSecretsFunc:
101  * @connection: the connection for which secrets were requested
102  * @secrets: (element-type utf8 GLib.HashTable): on success, a hash table of
103  *  hash tables, with each inner hash mapping a setting property to a #GValue
104  *  containing that property's value
105  * @error: on failure, a descriptive error
106  * @user_data: user data passed to nm_remote_connection_get_secrets()
107  *
108  * Called when NetworkManager returns secrets in response to a request for
109  * secrets via nm_remote_connection_get_secrets().
110  */
111 typedef void (*NMRemoteConnectionGetSecretsFunc) (NMRemoteConnection *connection,
112                                                   GHashTable *secrets,
113                                                   GError *error,
114                                                   gpointer user_data);
115
116 GType nm_remote_connection_get_type (void);
117
118 NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus,
119                                               const char *path);
120
121 void nm_remote_connection_commit_changes (NMRemoteConnection *connection,
122                                           NMRemoteConnectionResultFunc callback,
123                                           gpointer user_data);
124
125 NM_AVAILABLE_IN_0_9_10
126 void nm_remote_connection_commit_changes_unsaved (NMRemoteConnection *connection,
127                                                   NMRemoteConnectionResultFunc callback,
128                                                   gpointer user_data);
129
130 NM_AVAILABLE_IN_0_9_10
131 void nm_remote_connection_save (NMRemoteConnection *connection,
132                                 NMRemoteConnectionResultFunc callback,
133                                 gpointer user_data);
134
135 void nm_remote_connection_delete (NMRemoteConnection *connection,
136                                   NMRemoteConnectionResultFunc callback,
137                                   gpointer user_data);
138
139 void nm_remote_connection_get_secrets (NMRemoteConnection *connection,
140                                        const char *setting_name,
141                                        NMRemoteConnectionGetSecretsFunc callback,
142                                        gpointer user_data);
143
144 NM_AVAILABLE_IN_0_9_10
145 gboolean nm_remote_connection_get_unsaved (NMRemoteConnection *connection);
146
147 G_END_DECLS
148
149 #endif  /* __NM_REMOTE_CONNECTION__ */