summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-11-05 11:01:09 -0500
committerDan Winship <danw@gnome.org>2014-11-06 18:16:36 -0500
commitccb4d231c3898c3d53bc31a178059d80aebcc5b3 (patch)
treedbe69550227c8f55f441c2d4bd5456cdd1da766b
parent098d655ef148445dedc23aea6d014881889b364f (diff)
downloadNetworkManager-danw/vpn-prep-bgo719768.tar.gz
libnm: rename NMVpnPluginUiInterface, add to NetworkManager.hdanw/vpn-prep-bgo719768
Rename NMVpnPluginUiInterface to NMVpnEditorPlugin (to clarify that it's unrelated to NMVpnPlugin), and add it to NetworkManager.h. Rename NMVpnPluginUiWidgetInterface to NMVpnEditor, because it's not a widget, and will soon be used for non-gui editing too. (Also, add a placeholder for the method that non-gui editing will use.) Fix the typedefs to not mix up the (dummy) NMVpnEditorPlugin and NMVpnEditor types with the types of their interface structs. Update to use G_DEFINE_INTERFACE. Drop NMVpnPluginUiInterfaceProp; it doesn't matter what codes plugin implementations use for the interface properties that they implement.
-rw-r--r--libnm/Makefile.am4
-rw-r--r--libnm/NetworkManager.h1
-rw-r--r--libnm/libnm.ver21
-rw-r--r--libnm/nm-types.h2
-rw-r--r--libnm/nm-vpn-editor-plugin.c179
-rw-r--r--libnm/nm-vpn-editor-plugin.h178
-rw-r--r--libnm/nm-vpn-plugin-ui-interface.c244
-rw-r--r--libnm/nm-vpn-plugin-ui-interface.h206
8 files changed, 372 insertions, 463 deletions
diff --git a/libnm/Makefile.am b/libnm/Makefile.am
index e14dc83a3f..c506ff6270 100644
--- a/libnm/Makefile.am
+++ b/libnm/Makefile.am
@@ -53,7 +53,7 @@ libnminclude_hfiles = \
nm-secret-agent.h \
nm-types.h \
nm-vpn-connection.h \
- nm-vpn-plugin-ui-interface.h \
+ nm-vpn-editor-plugin.h \
nm-wimax-nsp.h
libnminclude_nointrospect_hfiles = \
@@ -104,7 +104,7 @@ libnm_la_csources = \
nm-secret-agent.c \
nm-vpn-connection.c \
nm-vpn-plugin-old.c \
- nm-vpn-plugin-ui-interface.c \
+ nm-vpn-editor-plugin.c \
nm-wimax-nsp.c
libnm_la_SOURCES = \
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h
index ce7bec74c2..2e9854e698 100644
--- a/libnm/NetworkManager.h
+++ b/libnm/NetworkManager.h
@@ -83,6 +83,7 @@
#include <nm-version.h>
#include <nm-vpn-connection.h>
#include <nm-vpn-dbus-interface.h>
+#include <nm-vpn-editor-plugin.h>
#include <nm-wimax-nsp.h>
#undef __NETWORKMANAGER_H_INSIDE__
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index d735a30e38..b83198cde4 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -857,6 +857,16 @@ global:
nm_vpn_connection_get_vpn_state;
nm_vpn_connection_state_get_type;
nm_vpn_connection_state_reason_get_type;
+ nm_vpn_editor_get_type;
+ nm_vpn_editor_get_widget;
+ nm_vpn_editor_plugin_capability_get_type;
+ nm_vpn_editor_plugin_export;
+ nm_vpn_editor_plugin_get_capabilities;
+ nm_vpn_editor_plugin_get_editor;
+ nm_vpn_editor_plugin_get_suggested_filename;
+ nm_vpn_editor_plugin_get_type;
+ nm_vpn_editor_plugin_import;
+ nm_vpn_editor_update_connection;
nm_vpn_plugin_error_get_type;
nm_vpn_plugin_error_quark;
nm_vpn_plugin_failure_get_type;
@@ -871,17 +881,6 @@ global:
nm_vpn_plugin_old_set_ip4_config;
nm_vpn_plugin_old_set_login_banner;
nm_vpn_plugin_old_set_state;
- nm_vpn_plugin_ui_capability_get_type;
- nm_vpn_plugin_ui_interface_export;
- nm_vpn_plugin_ui_interface_get_capabilities;
- nm_vpn_plugin_ui_interface_get_suggested_name;
- nm_vpn_plugin_ui_interface_get_type;
- nm_vpn_plugin_ui_interface_import;
- nm_vpn_plugin_ui_interface_prop_get_type;
- nm_vpn_plugin_ui_interface_ui_factory;
- nm_vpn_plugin_ui_widget_interface_get_type;
- nm_vpn_plugin_ui_widget_interface_get_widget;
- nm_vpn_plugin_ui_widget_interface_update_connection;
nm_vpn_service_state_get_type;
nm_wep_key_type_get_type;
nm_wimax_nsp_connection_valid;
diff --git a/libnm/nm-types.h b/libnm/nm-types.h
index 940a329454..5f066f329e 100644
--- a/libnm/nm-types.h
+++ b/libnm/nm-types.h
@@ -51,6 +51,8 @@ typedef struct _NMObject NMObject;
typedef struct _NMRemoteConnection NMRemoteConnection;
typedef struct _NMSecretAgent NMSecretAgent;
typedef struct _NMVpnConnection NMVpnConnection;
+typedef struct _NMVpnEditorPlugin NMVpnEditorPlugin;
+typedef struct _NMVpnEditor NMVpnEditor;
typedef struct _NMWimaxNsp NMWimaxNsp;
#endif /* NM_TYPES_H */
diff --git a/libnm/nm-vpn-editor-plugin.c b/libnm/nm-vpn-editor-plugin.c
new file mode 100644
index 0000000000..02393fa8e8
--- /dev/null
+++ b/libnm/nm-vpn-editor-plugin.c
@@ -0,0 +1,179 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2008 - 2010 Red Hat, Inc.
+ * Copyright 2008 Novell, Inc.
+ */
+
+#include "nm-vpn-editor-plugin.h"
+
+static void nm_vpn_editor_plugin_default_init (NMVpnEditorPluginInterface *iface);
+
+G_DEFINE_INTERFACE (NMVpnEditorPlugin, nm_vpn_editor_plugin, G_TYPE_OBJECT)
+
+static void
+nm_vpn_editor_plugin_default_init (NMVpnEditorPluginInterface *iface)
+{
+ /* Properties */
+
+ /**
+ * NMVpnEditorPlugin:name:
+ *
+ * Short display name of the VPN plugin.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string (NM_VPN_EDITOR_PLUGIN_NAME, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * NMVpnEditorPlugin:description:
+ *
+ * Longer description of the VPN plugin.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string (NM_VPN_EDITOR_PLUGIN_DESCRIPTION, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * NMVpnEditorPlugin:service:
+ *
+ * D-Bus service name of the plugin's VPN service.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string (NM_VPN_EDITOR_PLUGIN_SERVICE, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * nm_vpn_editor_plugin_get_editor:
+ *
+ * Returns: (transfer full):
+ */
+NMVpnEditor *
+nm_vpn_editor_plugin_get_editor (NMVpnEditorPlugin *plugin,
+ NMConnection *connection,
+ GError **error)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
+
+ return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_editor (plugin, connection, error);
+}
+
+NMVpnEditorPluginCapability
+nm_vpn_editor_plugin_get_capabilities (NMVpnEditorPlugin *plugin)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), 0);
+
+ return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_capabilities (plugin);
+}
+
+/**
+ * nm_vpn_editor_plugin_import:
+ *
+ * Returns: (transfer full):
+ */
+NMConnection *
+nm_vpn_editor_plugin_import (NMVpnEditorPlugin *plugin,
+ const char *path,
+ GError **error)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
+
+ if (nm_vpn_editor_plugin_get_capabilities (plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT) {
+ g_return_val_if_fail (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->import_from_file != NULL, NULL);
+ return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->import_from_file (plugin, path, error);
+ }
+ return NULL;
+}
+
+gboolean
+nm_vpn_editor_plugin_export (NMVpnEditorPlugin *plugin,
+ const char *path,
+ NMConnection *connection,
+ GError **error)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), FALSE);
+
+ if (nm_vpn_editor_plugin_get_capabilities (plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT) {
+ g_return_val_if_fail (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->export_to_file != NULL, FALSE);
+ return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->export_to_file (plugin, path, connection, error);
+ }
+ return FALSE;
+}
+
+char *
+nm_vpn_editor_plugin_get_suggested_filename (NMVpnEditorPlugin *plugin,
+ NMConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
+
+ if (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_suggested_filename)
+ return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_suggested_filename (plugin, connection);
+ return NULL;
+}
+
+
+static void nm_vpn_editor_default_init (NMVpnEditorInterface *iface);
+
+G_DEFINE_INTERFACE (NMVpnEditor, nm_vpn_editor, G_TYPE_OBJECT)
+
+static void
+nm_vpn_editor_default_init (NMVpnEditorInterface *iface)
+{
+ GType iface_type = G_TYPE_FROM_INTERFACE (iface);
+
+ /* Signals */
+ g_signal_new ("changed",
+ iface_type,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMVpnEditorInterface, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+/**
+ * nm_vpn_editor_get_widget:
+ *
+ * Returns: (transfer none):
+ */
+GObject *
+nm_vpn_editor_get_widget (NMVpnEditor *editor)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), NULL);
+
+ return NM_VPN_EDITOR_GET_INTERFACE (editor)->get_widget (editor);
+}
+
+gboolean
+nm_vpn_editor_update_connection (NMVpnEditor *editor,
+ NMConnection *connection,
+ GError **error)
+{
+ g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), FALSE);
+
+ if (error)
+ g_return_val_if_fail (*error == NULL, FALSE);
+
+ return NM_VPN_EDITOR_GET_INTERFACE (editor)->update_connection (editor, connection, error);
+}
diff --git a/libnm/nm-vpn-editor-plugin.h b/libnm/nm-vpn-editor-plugin.h
new file mode 100644
index 0000000000..76b365876e
--- /dev/null
+++ b/libnm/nm-vpn-editor-plugin.h
@@ -0,0 +1,178 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2008 - 2014 Red Hat, Inc.
+ * Copyright 2008 Novell, Inc.
+ */
+
+#ifndef __NM_VPN_EDITOR_PLUGIN_H__
+#define __NM_VPN_EDITOR_PLUGIN_H__
+
+#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
+#error "Only <NetworkManager.h> can be included directly."
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+#include <nm-types.h>
+
+G_BEGIN_DECLS
+
+/* Plugin's factory function that returns a GObject that implements
+ * NMVpnEditorPlugin.
+ */
+#ifndef __GI_SCANNER__
+typedef NMVpnEditorPlugin * (*NMVpnEditorPluginFactory) (GError **error);
+NMVpnEditorPlugin *nm_vpn_editor_plugin_factory (GError **error);
+#endif
+
+
+/**************************************************/
+/* Editor plugin interface */
+/**************************************************/
+
+#define NM_TYPE_VPN_EDITOR_PLUGIN (nm_vpn_editor_plugin_get_type ())
+#define NM_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPlugin))
+#define NM_IS_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_EDITOR_PLUGIN))
+#define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPluginInterface))
+
+/**
+ * NMVpnEditorPluginCapability:
+ * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE: unknown or no capability
+ * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT: the plugin can import new connections
+ * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT: the plugin can export connections
+ * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6: the plugin supports IPv6 addressing
+ *
+ * Flags that indicate certain capabilities of the plugin to editor programs.
+ **/
+typedef enum /*< flags >*/ {
+ NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE = 0x00,
+ NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT = 0x01,
+ NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT = 0x02,
+ NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6 = 0x04
+} NMVpnEditorPluginCapability;
+
+/* Short display name of the VPN plugin */
+#define NM_VPN_EDITOR_PLUGIN_NAME "name"
+
+/* Longer description of the VPN plugin */
+#define NM_VPN_EDITOR_PLUGIN_DESCRIPTION "description"
+
+/* D-Bus service name of the plugin's VPN service */
+#define NM_VPN_EDITOR_PLUGIN_SERVICE "service"
+
+typedef struct {
+ GTypeInterface g_iface;
+
+ /* Returns an #NMVpnEditor, pre-filled with values from @connection if
+ * non-%NULL.
+ */
+ NMVpnEditor * (*get_editor) (NMVpnEditorPlugin *plugin,
+ NMConnection *connection,
+ GError **error);
+
+ /* Plugin's capabiltity function that returns a bitmask of capabilities. */
+ NMVpnEditorPluginCapability (*get_capabilities) (NMVpnEditorPlugin *plugin);
+
+ /* Try to import a connection from the specified path. On success, return a
+ * partial #NMConnection object. On error, return %NULL and set @error with
+ * additional information. Note that @error can be %NULL, in which case no
+ * additional error information should be provided.
+ */
+ NMConnection * (*import_from_file) (NMVpnEditorPlugin *plugin,
+ const char *path,
+ GError **error);
+
+ /* Export the given connection to the specified path. Return %TRUE on success.
+ * On error, return %FALSE and set @error with additional error information.
+ * Note that @error can be %NULL, in which case no additional error information
+ * should be provided.
+ */
+ gboolean (*export_to_file) (NMVpnEditorPlugin *plugin,
+ const char *path,
+ NMConnection *connection,
+ GError **error);
+
+ /* For a given connection, return a suggested file name. Returned value
+ * will be %NULL or a suggested file name to be freed by the caller.
+ */
+ char * (*get_suggested_filename) (NMVpnEditorPlugin *plugin, NMConnection *connection);
+} NMVpnEditorPluginInterface;
+
+GType nm_vpn_editor_plugin_get_type (void);
+
+NMVpnEditor *nm_vpn_editor_plugin_get_editor (NMVpnEditorPlugin *plugin,
+ NMConnection *connection,
+ GError **error);
+
+NMVpnEditorPluginCapability nm_vpn_editor_plugin_get_capabilities (NMVpnEditorPlugin *plugin);
+
+NMConnection *nm_vpn_editor_plugin_import (NMVpnEditorPlugin *plugin,
+ const char *path,
+ GError **error);
+gboolean nm_vpn_editor_plugin_export (NMVpnEditorPlugin *plugin,
+ const char *path,
+ NMConnection *connection,
+ GError **error);
+char *nm_vpn_editor_plugin_get_suggested_filename (NMVpnEditorPlugin *plugin,
+ NMConnection *connection);
+
+/**************************************************/
+/* Editor interface */
+/**************************************************/
+
+#define NM_TYPE_VPN_EDITOR (nm_vpn_editor_get_type ())
+#define NM_VPN_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_EDITOR, NMVpnEditor))
+#define NM_IS_VPN_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_EDITOR))
+#define NM_VPN_EDITOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_EDITOR, NMVpnEditorInterface))
+
+typedef struct {
+ GTypeInterface g_iface;
+
+ /* Return the #GtkWidget for the VPN editor's UI */
+ GObject * (*get_widget) (NMVpnEditor *editor);
+
+ void (*placeholder) (void);
+
+ /* Called to save the user-entered options to the connection object. Should
+ * return %FALSE and set @error if the current options are invalid. @error
+ * should contain enough information for the plugin to determine which UI
+ * widget is invalid at a later point in time. For example, creating unique
+ * error codes for what error occurred and populating the message field
+ * of @error with the name of the invalid property.
+ */
+ gboolean (*update_connection) (NMVpnEditor *editor,
+ NMConnection *connection,
+ GError **error);
+
+ /* Emitted when the value of a UI widget changes. May trigger a validity
+ * check via update_connection() to write values to the connection.
+ */
+ void (*changed) (NMVpnEditor *editor);
+} NMVpnEditorInterface;
+
+GType nm_vpn_editor_get_type (void);
+
+GObject * nm_vpn_editor_get_widget (NMVpnEditor *editor);
+
+gboolean nm_vpn_editor_update_connection (NMVpnEditor *editor,
+ NMConnection *connection,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* NM_VPN_EDITOR_PLUGIN_H */
diff --git a/libnm/nm-vpn-plugin-ui-interface.c b/libnm/nm-vpn-plugin-ui-interface.c
deleted file mode 100644
index af00cfd1da..0000000000
--- a/libnm/nm-vpn-plugin-ui-interface.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2010 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#include "nm-vpn-plugin-ui-interface.h"
-
-static void
-interface_init (gpointer g_iface)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Properties */
-
- /**
- * NMVpnPluginUiInterface:name:
- *
- * Short display name of the VPN plugin.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_NAME, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVpnPluginUiInterface:desc:
- *
- * Longer description of the VPN plugin.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_DESC, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * NMVpnPluginUiInterface:service:
- *
- * D-Bus service name of the plugin's VPN service.
- */
- g_object_interface_install_property (g_iface,
- g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_SERVICE, "", "",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- initialized = TRUE;
-}
-
-
-GType
-nm_vpn_plugin_ui_interface_get_type (void)
-{
- static GType vpn_plugin_ui_interface_type = 0;
-
- if (!vpn_plugin_ui_interface_type) {
- const GTypeInfo vpn_plugin_ui_interface_info = {
- sizeof (NMVpnPluginUiInterface), /* class_size */
- interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- vpn_plugin_ui_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "NMVpnPluginUiInterface",
- &vpn_plugin_ui_interface_info,
- 0);
-
- g_type_interface_add_prerequisite (vpn_plugin_ui_interface_type, G_TYPE_OBJECT);
- }
-
- return vpn_plugin_ui_interface_type;
-}
-
-
-/**
- * nm_vpn_plugin_ui_interface_ui_factory:
- *
- * Returns: (transfer full):
- */
-NMVpnPluginUiWidgetInterface *
-nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->ui_factory (iface, connection, error);
-}
-
-guint32
-nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), 0);
-
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_capabilities (iface);
-}
-
-/**
- * nm_vpn_plugin_ui_interface_import:
- *
- * Returns: (transfer full):
- */
-NMConnection *
-nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT) {
- g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file != NULL, NULL);
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import_from_file (iface, path, error);
- }
- return NULL;
-}
-
-gboolean
-nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), FALSE);
-
- if (nm_vpn_plugin_ui_interface_get_capabilities (iface) & NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT) {
- g_return_val_if_fail (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file != NULL, FALSE);
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export_to_file (iface, path, connection, error);
- }
- return FALSE;
-}
-
-char *
-nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
- NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), NULL);
-
- if (NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_suggested_name)
- return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_suggested_name (iface, connection);
- return NULL;
-}
-
-
-static void
-widget_interface_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Signals */
- g_signal_new ("changed",
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMVpnPluginUiWidgetInterface, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
-
-GType
-nm_vpn_plugin_ui_widget_interface_get_type (void)
-{
- static GType vpn_plugin_ui_widget_interface_type = 0;
-
- if (!vpn_plugin_ui_widget_interface_type) {
- const GTypeInfo vpn_plugin_ui_widget_interface_info = {
- sizeof (NMVpnPluginUiWidgetInterface), /* class_size */
- widget_interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- vpn_plugin_ui_widget_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "NMVpnPluginUiWidgetInterface",
- &vpn_plugin_ui_widget_interface_info,
- 0);
-
- g_type_interface_add_prerequisite (vpn_plugin_ui_widget_interface_type, G_TYPE_OBJECT);
- }
-
- return vpn_plugin_ui_widget_interface_type;
-}
-
-/**
- * nm_vpn_plugin_ui_widget_interface_get_widget:
- *
- * Returns: (transfer none):
- */
-GObject *
-nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (iface), NULL);
-
- return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->get_widget (iface);
-}
-
-gboolean
-nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (iface), FALSE);
-
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
-
- return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->update_connection (iface, connection, error);
-}
diff --git a/libnm/nm-vpn-plugin-ui-interface.h b/libnm/nm-vpn-plugin-ui-interface.h
deleted file mode 100644
index 4aab74482e..0000000000
--- a/libnm/nm-vpn-plugin-ui-interface.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2008 - 2010 Red Hat, Inc.
- * Copyright 2008 Novell, Inc.
- */
-
-#ifndef __NM_VPN_PLUGIN_UI_INTERFACE_H__
-#define __NM_VPN_PLUGIN_UI_INTERFACE_H__
-
-#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
-#error "Only <NetworkManager.h> can be included directly."
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-#include <nm-connection.h>
-
-G_BEGIN_DECLS
-
-typedef struct _NMVpnPluginUiInterface NMVpnPluginUiInterface;
-typedef struct _NMVpnPluginUiWidgetInterface NMVpnPluginUiWidgetInterface;
-
-/* Plugin's factory function that returns a GObject that implements
- * NMVpnPluginUiInterface.
- */
-#ifndef __GI_SCANNER__
-typedef NMVpnPluginUiInterface * (*NMVpnPluginUiFactory) (GError **error);
-NMVpnPluginUiInterface *nm_vpn_plugin_ui_factory (GError **error);
-#endif
-
-
-/**************************************************/
-/* Plugin interface */
-/**************************************************/
-
-#define NM_TYPE_VPN_PLUGIN_UI_INTERFACE (nm_vpn_plugin_ui_interface_get_type ())
-#define NM_VPN_PLUGIN_UI_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
-#define NM_IS_VPN_PLUGIN_UI_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE))
-#define NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_INTERFACE, NMVpnPluginUiInterface))
-
-/**
- * NMVpnPluginUiCapability:
- * @NM_VPN_PLUGIN_UI_CAPABILITY_NONE: unknown or no capability
- * @NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT: the plugin can import new connections
- * @NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT: the plugin can export connections
- * @NM_VPN_PLUGIN_UI_CAPABILITY_IPV6: the plugin supports IPv6 addressing
- *
- * Flags that indicate to UI programs certain capabilities of the plugin.
- **/
-typedef enum /*< flags >*/ {
- NM_VPN_PLUGIN_UI_CAPABILITY_NONE = 0x00,
- NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT = 0x01,
- NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT = 0x02,
- NM_VPN_PLUGIN_UI_CAPABILITY_IPV6 = 0x04
-} NMVpnPluginUiCapability;
-
-/* Short display name of the VPN plugin */
-#define NM_VPN_PLUGIN_UI_INTERFACE_NAME "name"
-
-/* Longer description of the VPN plugin */
-#define NM_VPN_PLUGIN_UI_INTERFACE_DESC "desc"
-
-/* D-Bus service name of the plugin's VPN service */
-#define NM_VPN_PLUGIN_UI_INTERFACE_SERVICE "service"
-
-/**
- * NMVpnPluginUiInterfaceProp:
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: the VPN plugin's name
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: description of the VPN plugin and what
- * VPN services it supports
- * @NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: the D-Bus service name used by the
- * plugin's VPN service daemon
- *
- * #GObject property numbers that plugins should override to provide certain
- * information to UI programs.
- **/
-typedef enum {
- /* private */
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST = 0x1000,
-
- /* public */
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME = NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE
-} NMVpnPluginUiInterfaceProp;
-
-
-struct _NMVpnPluginUiInterface {
- GTypeInterface g_iface;
-
- /* Plugin's factory function that returns a GObject that implements
- * NMVpnPluginUiWidgetInterface, pre-filled with values from 'connection'
- * if non-NULL.
- */
- NMVpnPluginUiWidgetInterface * (*ui_factory) (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error);
-
- /* Plugin's capabiltity function that returns a bitmask of capabilities
- * described by NM_VPN_PLUGIN_UI_CAPABILITY_* defines.
- */
- guint32 (*get_capabilities) (NMVpnPluginUiInterface *iface);
-
- /* Try to import a connection from the specified path. On success, return a
- * partial NMConnection object. On error, return NULL and set 'error' with
- * additional information. Note that 'error' can be NULL, in which case no
- * additional error information should be provided.
- */
- NMConnection * (*import_from_file) (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error);
-
- /* Export the given connection to the specified path. Return TRUE on success.
- * On error, return FALSE and set 'error' with additional error information.
- * Note that 'error' can be NULL, in which case no additional error information
- * should be provided.
- */
- gboolean (*export_to_file) (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error);
-
- /* For a given connection, return a suggested file name. Returned value should
- * be NULL or a suggested file name allocated via g_malloc/g_new/etc to be freed
- * by the caller.
- */
- char * (*get_suggested_name) (NMVpnPluginUiInterface *iface, NMConnection *connection);
-};
-
-GType nm_vpn_plugin_ui_interface_get_type (void);
-
-NMVpnPluginUiWidgetInterface *nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
- NMConnection *connection,
- GError **error);
-
-guint32 nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface);
-
-NMConnection *nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
- const char *path,
- GError **error);
-
-gboolean nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
- const char *path,
- NMConnection *connection,
- GError **error);
-
-char *nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
- NMConnection *connection);
-
-/**************************************************/
-/* UI widget interface */
-/**************************************************/
-
-#define NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE (nm_vpn_plugin_ui_widget_interface_get_type ())
-#define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
-#define NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE))
-#define NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, NMVpnPluginUiWidgetInterface))
-
-struct _NMVpnPluginUiWidgetInterface {
- GTypeInterface g_iface;
-
- /* Return the GtkWidget for the VPN's UI */
- GObject * (*get_widget) (NMVpnPluginUiWidgetInterface *iface);
-
- /* Called to save the user-entered options to the connection object. Should
- * return FALSE and set 'error' if the current options are invalid. 'error'
- * should contain enough information for the plugin to determine which UI
- * widget is invalid at a later point in time. For example, creating unique
- * error codes for what error occurred and populating the message field
- * of 'error' with the name of the invalid property.
- */
- gboolean (*update_connection) (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
- /* Emitted when the value of a UI widget changes. May trigger a validity
- * check via update_connection() to write values to the connection */
- void (*changed) (NMVpnPluginUiWidgetInterface *iface);
-};
-
-GType nm_vpn_plugin_ui_widget_interface_get_type (void);
-
-GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface);
-
-gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
- NMConnection *connection,
- GError **error);
-
-G_END_DECLS
-
-#endif /* NM_VPN_PLUGIN_UI_INTERFACE_H */