device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-glib / nm-vpn-plugin-ui-interface.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 - 2010 Red Hat, Inc.
19  * Copyright 2008 Novell, Inc.
20  */
21
22 #ifndef NM_VPN_PLUGIN_UI_INTERFACE_H
23 #define NM_VPN_PLUGIN_UI_INTERFACE_H
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <nm-connection.h>
28
29 G_BEGIN_DECLS
30
31 typedef struct _NMVpnPluginUiInterface NMVpnPluginUiInterface;
32 typedef struct _NMVpnPluginUiWidgetInterface NMVpnPluginUiWidgetInterface;
33
34 /* Plugin's factory function that returns a GObject that implements
35  * NMVpnPluginUiInterface.
36  */
37 typedef NMVpnPluginUiInterface * (*NMVpnPluginUiFactory) (GError **error);
38 NMVpnPluginUiInterface *nm_vpn_plugin_ui_factory (GError **error);
39
40
41 /**************************************************/
42 /* Plugin interface                               */
43 /**************************************************/
44
45 #define NM_TYPE_VPN_PLUGIN_UI_INTERFACE      (nm_vpn_plugin_ui_interface_get_type ())
46 #define NM_VPN_PLUGIN_UI_INTERFACE(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
47 #define NM_IS_VPN_PLUGIN_UI_INTERFACE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE))
48 #define NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
49
50 /**
51  * NMVpnPluginUiCapability:
52  * @NM_VPN_PLUGIN_UI_CAPABILITY_NONE: unknown or no capability
53  * @NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT: the plugin can import new connections
54  * @NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT: the plugin can export connections
55  * @NM_VPN_PLUGIN_UI_CAPABILITY_IPV6: the plugin supports IPv6 addressing
56  *
57  * Flags that indicate to UI programs certain capabilities of the plugin.
58  **/
59 typedef enum /*< flags >*/ {
60         NM_VPN_PLUGIN_UI_CAPABILITY_NONE   = 0x00,
61         NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT = 0x01,
62         NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT = 0x02,
63         NM_VPN_PLUGIN_UI_CAPABILITY_IPV6   = 0x04
64 } NMVpnPluginUiCapability;
65
66 /* Short display name of the VPN plugin */
67 #define NM_VPN_PLUGIN_UI_INTERFACE_NAME "name"
68
69 /* Longer description of the VPN plugin */
70 #define NM_VPN_PLUGIN_UI_INTERFACE_DESC "desc"
71
72 /* D-Bus service name of the plugin's VPN service */
73 #define NM_VPN_PLUGIN_UI_INTERFACE_SERVICE "service"
74
75 /**
76  * NMVpnPluginUiInterfaceProp:
77  * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: the VPN plugin's name
78  * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: description of the VPN plugin and what
79  * VPN services it supports
80  * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: the D-Bus service name used by the
81  * plugin's VPN service daemon
82  *
83  * #GObject property numbers that plugins should override to provide certain
84  * information to UI programs.
85  **/
86 typedef enum {
87         /* private */
88         NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST = 0x1000,
89
90         /* public */
91         NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME = NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST,
92         NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
93         NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE
94 } NMVpnPluginUiInterfaceProp;
95
96
97 struct _NMVpnPluginUiInterface {
98         GTypeInterface g_iface;
99
100         /* Plugin's factory function that returns a GObject that implements
101          * NMVpnPluginUiWidgetInterface, pre-filled with values from 'connection'
102          * if non-NULL.
103          */
104         NMVpnPluginUiWidgetInterface * (*ui_factory) (NMVpnPluginUiInterface *iface,
105                                                       NMConnection *connection,
106                                                       GError **error);
107
108         /* Plugin's capabiltity function that returns a bitmask of capabilities
109          * described by NM_VPN_PLUGIN_UI_CAPABILITY_* defines.
110          */
111         guint32 (*get_capabilities) (NMVpnPluginUiInterface *iface);
112
113         /* Try to import a connection from the specified path.  On success, return a
114          * partial NMConnection object.  On error, return NULL and set 'error' with
115          * additional information.  Note that 'error' can be NULL, in which case no
116          * additional error information should be provided.
117          */
118         NMConnection * (*import_from_file) (NMVpnPluginUiInterface *iface,
119                                             const char *path,
120                                             GError **error);
121
122         /* Export the given connection to the specified path.  Return TRUE on success.
123          * On error, return FALSE and set 'error' with additional error information.
124          * Note that 'error' can be NULL, in which case no additional error information
125          * should be provided.
126          */
127         gboolean (*export_to_file) (NMVpnPluginUiInterface *iface,
128                                     const char *path,
129                                     NMConnection *connection,
130                                     GError **error);
131
132         /* For a given connection, return a suggested file name.  Returned value should
133          * be NULL or a suggested file name allocated via g_malloc/g_new/etc to be freed
134          * by the caller.
135          */
136         char * (*get_suggested_name) (NMVpnPluginUiInterface *iface, NMConnection *connection);
137
138         /* Deprecated and no longer used */
139         gboolean (*delete_connection) (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error);
140
141         /* Padding for future expansion */
142         void (*_reserved1) (void);
143         void (*_reserved2) (void);
144         void (*_reserved3) (void);
145         void (*_reserved4) (void);
146         void (*_reserved5) (void);
147         void (*_reserved6) (void);
148 };
149
150 GType nm_vpn_plugin_ui_interface_get_type (void);
151
152 NMVpnPluginUiWidgetInterface *nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
153                                                                      NMConnection *connection,
154                                                                      GError **error);
155
156 guint32 nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface);
157
158 NMConnection *nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
159                                                  const char *path,
160                                                  GError **error);
161
162 gboolean nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
163                                             const char *path,
164                                             NMConnection *connection,
165                                             GError **error);
166
167 char *nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
168                                                      NMConnection *connection);
169
170 /* Deprecated and no longer used */
171 NM_DEPRECATED_IN_0_9_10
172 gboolean nm_vpn_plugin_ui_interface_delete_connection (NMVpnPluginUiInterface *iface,
173                                                        NMConnection *connection,
174                                                        GError **error);
175
176
177 /**************************************************/
178 /* UI widget interface                            */
179 /**************************************************/
180
181 #define NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE      (nm_vpn_plugin_ui_widget_interface_get_type ())
182 #define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
183 #define NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE))
184 #define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
185
186 struct _NMVpnPluginUiWidgetInterface {
187         GTypeInterface g_iface;
188
189         /* Return the GtkWidget for the VPN's UI */
190         GObject * (*get_widget) (NMVpnPluginUiWidgetInterface *iface);
191
192         /* Called to save the user-entered options to the connection object.  Should
193          * return FALSE and set 'error' if the current options are invalid.  'error'
194          * should contain enough information for the plugin to determine which UI
195          * widget is invalid at a later point in time.  For example, creating unique
196          * error codes for what error occurred and populating the message field
197          * of 'error' with the name of the invalid property.
198          */
199         gboolean (*update_connection) (NMVpnPluginUiWidgetInterface *iface,
200                                        NMConnection *connection,
201                                        GError **error);
202
203         /* Deprecated and no longer used */
204         gboolean (*save_secrets) (NMVpnPluginUiWidgetInterface *iface,
205                                   NMConnection *connection,
206                                   GError **error);
207
208         /* Emitted when the value of a UI widget changes.  May trigger a validity
209          * check via update_connection() to write values to the connection */
210         void (*changed) (NMVpnPluginUiWidgetInterface *iface);
211 };
212
213 GType nm_vpn_plugin_ui_widget_interface_get_type (void);
214
215 GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface);
216
217 gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
218                                                               NMConnection *connection,
219                                                               GError **error);
220
221 /* Deprecated and no longer used */
222 NM_DEPRECATED_IN_0_9_10
223 gboolean nm_vpn_plugin_ui_widget_interface_save_secrets (NMVpnPluginUiWidgetInterface *iface,
224                                                          NMConnection *connection,
225                                                          GError **error);
226
227
228 #ifdef NM_VPN_LIBNM_COMPAT
229 #define nm_vpn_editor_plugin_factory nm_vpn_plugin_ui_factory
230
231 #define NM_TYPE_VPN_EDITOR_PLUGIN               NM_TYPE_VPN_PLUGIN_UI_INTERFACE
232 #define NM_VPN_EDITOR_PLUGIN(obj)               NM_VPN_PLUGIN_UI_INTERFACE(obj)
233 #define NM_IS_VPN_EDITOR_PLUGIN(obj)            NM_IS_VPN_PLUGIN_UI_INTERFACE(obj)
234 #define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE(obj)
235
236 #define NMVpnEditorPluginCapability NMVpnPluginUiCapability
237 #define NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE   NM_VPN_PLUGIN_UI_CAPABILITY_NONE
238 #define NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT
239 #define NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT
240 #define NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6   NM_VPN_PLUGIN_UI_CAPABILITY_IPV6
241
242 #define NM_VPN_EDITOR_PLUGIN_NAME        NM_VPN_PLUGIN_UI_INTERFACE_NAME
243 #define NM_VPN_EDITOR_PLUGIN_DESCRIPTION NM_VPN_PLUGIN_UI_INTERFACE_DESC
244 #define NM_VPN_EDITOR_PLUGIN_SERVICE     NM_VPN_PLUGIN_UI_INTERFACE_SERVICE
245
246 #define NMVpnEditorPlugin NMVpnPluginUiInterface
247 #define NMVpnEditorPluginInterface NMVpnPluginUiInterface
248
249 #define get_editor             ui_factory
250 #define get_suggested_filename get_suggested_name
251
252 #define nm_vpn_editor_plugin_get_type nm_vpn_plugin_ui_interface_get_type
253 #define nm_vpn_editor_plugin_get_editor nm_vpn_plugin_ui_interface_ui_factory
254 #define nm_vpn_editor_plugin_get_capabilities nm_vpn_plugin_ui_interface_get_capabilities
255 #define nm_vpn_editor_plugin_import nm_vpn_plugin_ui_interface_import
256 #define nm_vpn_editor_plugin_export nm_vpn_plugin_ui_interface_export
257 #define nm_vpn_editor_plugin_get_suggested_filename nm_vpn_plugin_ui_interface_get_suggested_name
258
259 #define NM_TYPE_VPN_EDITOR               NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE
260 #define NM_VPN_EDITOR(obj)               NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (obj)
261 #define NM_IS_VPN_EDITOR(obj)            NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (obj)
262 #define NM_VPN_EDITOR_GET_INTERFACE(obj) NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (obj)
263
264 #define NMVpnEditor NMVpnPluginUiWidgetInterface
265 #define NMVpnEditorInterface NMVpnPluginUiWidgetInterface
266
267 #define nm_vpn_editor_get_type nm_vpn_plugin_ui_widget_interface_get_type
268 #define nm_vpn_editor_get_widget nm_vpn_plugin_ui_widget_interface_get_widget
269 #define nm_vpn_editor_update_connection nm_vpn_plugin_ui_widget_interface_update_connection
270
271 #endif /* NM_VPN_LIBNM_COMPAT */
272
273 G_END_DECLS
274
275 #endif  /* NM_VPN_PLUGIN_UI_INTERFACE_H */