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 2008 - 2010 Red Hat, Inc.
19 * Copyright 2008 Novell, Inc.
22 #ifndef NM_VPN_PLUGIN_UI_INTERFACE_H
23 #define NM_VPN_PLUGIN_UI_INTERFACE_H
26 #include <glib-object.h>
27 #include <nm-connection.h>
31 typedef struct _NMVpnPluginUiInterface NMVpnPluginUiInterface;
32 typedef struct _NMVpnPluginUiWidgetInterface NMVpnPluginUiWidgetInterface;
34 /* Plugin's factory function that returns a GObject that implements
35 * NMVpnPluginUiInterface.
37 typedef NMVpnPluginUiInterface * (*NMVpnPluginUiFactory) (GError **error);
38 NMVpnPluginUiInterface *nm_vpn_plugin_ui_factory (GError **error);
41 /**************************************************/
42 /* Plugin interface */
43 /**************************************************/
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))
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
57 * Flags that indicate to UI programs certain capabilities of the plugin.
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;
66 /* Short display name of the VPN plugin */
67 #define NM_VPN_PLUGIN_UI_INTERFACE_NAME "name"
69 /* Longer description of the VPN plugin */
70 #define NM_VPN_PLUGIN_UI_INTERFACE_DESC "desc"
72 /* D-Bus service name of the plugin's VPN service */
73 #define NM_VPN_PLUGIN_UI_INTERFACE_SERVICE "service"
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
83 * #GObject property numbers that plugins should override to provide certain
84 * information to UI programs.
88 NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST = 0x1000,
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;
97 struct _NMVpnPluginUiInterface {
98 GTypeInterface g_iface;
100 /* Plugin's factory function that returns a GObject that implements
101 * NMVpnPluginUiWidgetInterface, pre-filled with values from 'connection'
104 NMVpnPluginUiWidgetInterface * (*ui_factory) (NMVpnPluginUiInterface *iface,
105 NMConnection *connection,
108 /* Plugin's capabiltity function that returns a bitmask of capabilities
109 * described by NM_VPN_PLUGIN_UI_CAPABILITY_* defines.
111 guint32 (*get_capabilities) (NMVpnPluginUiInterface *iface);
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.
118 NMConnection * (*import_from_file) (NMVpnPluginUiInterface *iface,
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.
127 gboolean (*export_to_file) (NMVpnPluginUiInterface *iface,
129 NMConnection *connection,
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
136 char * (*get_suggested_name) (NMVpnPluginUiInterface *iface, NMConnection *connection);
138 /* Deprecated and no longer used */
139 gboolean (*delete_connection) (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error);
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);
150 GType nm_vpn_plugin_ui_interface_get_type (void);
152 NMVpnPluginUiWidgetInterface *nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
153 NMConnection *connection,
156 guint32 nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface);
158 NMConnection *nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
162 gboolean nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
164 NMConnection *connection,
167 char *nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
168 NMConnection *connection);
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,
177 /**************************************************/
178 /* UI widget interface */
179 /**************************************************/
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))
186 struct _NMVpnPluginUiWidgetInterface {
187 GTypeInterface g_iface;
189 /* Return the GtkWidget for the VPN's UI */
190 GObject * (*get_widget) (NMVpnPluginUiWidgetInterface *iface);
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.
199 gboolean (*update_connection) (NMVpnPluginUiWidgetInterface *iface,
200 NMConnection *connection,
203 /* Deprecated and no longer used */
204 gboolean (*save_secrets) (NMVpnPluginUiWidgetInterface *iface,
205 NMConnection *connection,
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);
213 GType nm_vpn_plugin_ui_widget_interface_get_type (void);
215 GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface);
217 gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
218 NMConnection *connection,
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,
228 #ifdef NM_VPN_LIBNM_COMPAT
229 #define nm_vpn_editor_plugin_factory nm_vpn_plugin_ui_factory
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)
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
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
246 #define NMVpnEditorPlugin NMVpnPluginUiInterface
247 #define NMVpnEditorPluginInterface NMVpnPluginUiInterface
249 #define get_editor ui_factory
250 #define get_suggested_filename get_suggested_name
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
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)
264 #define NMVpnEditor NMVpnPluginUiWidgetInterface
265 #define NMVpnEditorInterface NMVpnPluginUiWidgetInterface
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
271 #endif /* NM_VPN_LIBNM_COMPAT */
275 #endif /* NM_VPN_PLUGIN_UI_INTERFACE_H */