NetworkManager r3755 - in trunk: . libnm-glib



Author: dcbw
Date: Mon Jun 16 19:26:30 2008
New Revision: 3755
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3755&view=rev

Log:
2008-06-16  Dan Williams  <dcbw redhat com>

	* configure.in
	  libnm-glib/libnm_glib_vpn.pc.in
		- add a .pc file for libnm_glib_vpn

	* libnm-glib/nm-vpn-plugin-ui-interface.c
	  libnm-glib/nm-vpn-plugin-ui-interface.h
		- Move the glib/GNOME VPN UI plugin interface into libnm-glib and
			rework it substantially



Added:
   trunk/libnm-glib/libnm_glib_vpn.pc.in
   trunk/libnm-glib/nm-vpn-plugin-ui-interface.c
   trunk/libnm-glib/nm-vpn-plugin-ui-interface.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/libnm-glib/Makefile.am

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon Jun 16 19:26:30 2008
@@ -378,6 +378,7 @@
 libnm-util/libnm-util.pc
 libnm-util/Makefile
 libnm-glib/libnm_glib.pc
+libnm-glib/libnm_glib_vpn.pc
 libnm-glib/Makefile
 gfilemonitor/Makefile
 callouts/Makefile

Modified: trunk/libnm-glib/Makefile.am
==============================================================================
--- trunk/libnm-glib/Makefile.am	(original)
+++ trunk/libnm-glib/Makefile.am	Mon Jun 16 19:26:30 2008
@@ -44,6 +44,7 @@
 	nm-serial-device.h \
 	nm-vpn-connection.h \
 	nm-vpn-plugin.h \
+	nm-vpn-plugin-ui-interface.h \
 	nm-types.h \
 	nm-active-connection.h \
 	nm-dbus-connection.h \
@@ -92,7 +93,8 @@
 libnm_glib_test_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
 libnm_glib_test_LDADD = libnm_glib.la $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS)
 
-libnm_glib_vpn_la_SOURCES = nm-vpn-plugin.c
+
+libnm_glib_vpn_la_SOURCES = nm-vpn-plugin.c nm-vpn-plugin-ui-interface.c
 libnm_glib_vpn_la_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
 libnm_glib_vpn_la_LIBADD = $(top_builddir)/libnm-util/libnm-util.la $(GLIB_LIBS) $(DBUS_LIBS)
 
@@ -137,11 +139,11 @@
 	dbus-binding-tool --prefix=nm_active_connection --mode=glib-client --output=nm-active-connection-bindings.h $(top_srcdir)/introspection/nm-active-connection.xml
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libnm_glib.pc
+pkgconfig_DATA = libnm_glib.pc libnm_glib_vpn.pc
 
-DISTCLEANFILES = libnm_glib.pc
+DISTCLEANFILES = libnm_glib.pc libnm_glib.pc
 
-EXTRA_DIST = libnm_glib.pc.in
+EXTRA_DIST = libnm_glib.pc.in libnm_glib_vpn.pc.in
 
 CLEANFILES = \
 	$(BUILT_SOURCES)

Added: trunk/libnm-glib/libnm_glib_vpn.pc.in
==============================================================================
--- (empty file)
+++ trunk/libnm-glib/libnm_glib_vpn.pc.in	Mon Jun 16 19:26:30 2008
@@ -0,0 +1,13 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: libnm_glib_vpn
+Description: Convenience library for clients of NetworkManager
+Version: @VERSION@
+Requires: NetworkManager >= 0.7.0 glib-2.0 dbus-glib-1
+Cflags: -I${includedir}/libnm-glib
+Libs: -L${libdir} -lnm_glib_vpn
+
+

Added: trunk/libnm-glib/nm-vpn-plugin-ui-interface.c
==============================================================================
--- (empty file)
+++ trunk/libnm-glib/nm-vpn-plugin-ui-interface.c	Mon Jun 16 19:26:30 2008
@@ -0,0 +1,193 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#include "nm-vpn-plugin-ui-interface.h"
+
+static void
+interface_init (gpointer g_iface)
+{
+	static gboolean initialized = FALSE;
+
+	if (initialized)
+		return;
+
+	/* Properties */
+	g_object_interface_install_property (g_iface,
+		 g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_NAME,
+							  "Name",
+							  "VPN Plugin name",
+							  NULL,
+							  G_PARAM_READABLE));
+
+	g_object_interface_install_property (g_iface,
+		 g_param_spec_string (NM_VPN_PLUGIN_UI_INTERFACE_SERVICE,
+							  "Service",
+							  "VPN Plugin D-Bus service name",
+							  NULL,
+							  G_PARAM_READABLE));
+
+	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;
+}
+
+
+NMVpnPluginUiWidgetInterface *
+nm_vpn_plugin_ui_interface_ui_factory (NMVpnPluginUiInterface *iface,
+                                       NMConnection *connection,
+                                       GError **error)
+{
+	return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->ui_factory (iface, connection, error);
+}
+
+guint32
+nm_vpn_plugin_ui_interface_get_capabilities (NMVpnPluginUiInterface *iface)
+{
+	return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->get_capabilities (iface);
+}
+
+NMConnection *
+nm_vpn_plugin_ui_interface_import (NMVpnPluginUiInterface *iface,
+                                   const char *path,
+                                   GError **error)
+{
+	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 != NULL, NULL);
+		return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->import (iface, path, error);
+	}
+	return NULL;
+}
+
+gboolean
+nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
+                                   const char *path,
+                                   NMConnection *connection,
+                                   GError **error)
+{
+	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 != NULL, FALSE);
+		return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->export (iface, path, connection, error);
+	}
+	return FALSE;
+}
+
+char *
+nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
+                                               NMConnection *connection)
+{
+	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 ("validity-changed",
+				  iface_type,
+				  G_SIGNAL_RUN_FIRST,
+				  G_STRUCT_OFFSET (NMVpnPluginUiWidgetInterface, validity_changed),
+				  NULL, NULL,
+				  g_cclosure_marshal_VOID__BOOLEAN,
+				  G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+	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;
+}
+
+GObject *
+nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface)
+{
+	return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->get_widget (iface);
+}
+
+void
+nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
+                                                     NMConnection *connection)
+{
+	return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->update_connection (iface, connection);
+}
+

Added: trunk/libnm-glib/nm-vpn-plugin-ui-interface.h
==============================================================================
--- (empty file)
+++ trunk/libnm-glib/nm-vpn-plugin-ui-interface.h	Mon Jun 16 19:26:30 2008
@@ -0,0 +1,157 @@
+/* NetworkManager -- Network link manager
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#ifndef NM_VPN_PLUGIN_UI_INTERFACE_H
+#define NM_VPN_PLUGIN_UI_INTERFACE_H
+
+#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.
+ */
+typedef NMVpnPluginUiInterface * (*NMVpnPluginUiFactory) (GError **error);
+NMVpnPluginUiInterface *nm_vpn_plugin_ui_factory (GError **error);
+
+
+/**************************************************/
+/* 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))
+
+#define NM_VPN_PLUGIN_UI_CAPABILITY_NONE     0x00
+#define NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT   0x01
+#define NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT   0x02
+
+/* Display name of the VPN plugin */
+#define NM_VPN_PLUGIN_UI_INTERFACE_NAME "name"
+
+/* D-Bus service name of the plugin's VPN service */
+#define NM_VPN_PLUGIN_UI_INTERFACE_SERVICE "service"
+
+typedef enum {
+	NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST = 0x1000,
+
+	NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME = NM_VPN_PLUGIN_UI_INTERFACE_PROP_FIRST,
+	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) (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) (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 */
+	void (*update_connection) (NMVpnPluginUiWidgetInterface *iface,
+	                           NMConnection *connection);
+
+	/* Emitted when the validity of the user-entered options changes */
+	void (*validity_changed) (NMVpnPluginUiWidgetInterface *iface, gboolean valid);
+};
+
+GType nm_vpn_plugin_ui_widget_interface_get_type (void);
+
+GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface);
+
+void nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface,
+                                                          NMConnection *connection);
+
+G_END_DECLS
+
+#endif	/* NM_VPN_PLUGIN_UI_INTERFACE_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]