mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
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 git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3755 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
26d716cb17
commit
7c802e167c
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
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
|
||||
|
||||
2008-06-12 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Add a GError argument to nm_connection_verify() and nm_setting_verify(),
|
||||
|
|
|
@ -378,6 +378,7 @@ src/backends/Makefile
|
|||
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
|
||||
|
|
|
@ -44,6 +44,7 @@ libnminclude_HEADERS = \
|
|||
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_SOURCES = libnm-glib-test.c
|
|||
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 @@ nm-active-connection-bindings.h: $(top_srcdir)/introspection/nm-active-connectio
|
|||
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)
|
||||
|
|
13
libnm-glib/libnm_glib_vpn.pc.in
Normal file
13
libnm-glib/libnm_glib_vpn.pc.in
Normal file
|
@ -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
|
||||
|
||||
|
193
libnm-glib/nm-vpn-plugin-ui-interface.c
Normal file
193
libnm-glib/nm-vpn-plugin-ui-interface.c
Normal file
|
@ -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);
|
||||
}
|
||||
|
157
libnm-glib/nm-vpn-plugin-ui-interface.h
Normal file
157
libnm-glib/nm-vpn-plugin-ui-interface.h
Normal file
|
@ -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 */
|
Loading…
Reference in a new issue