diff options
| author | Michael Biebl <biebl@debian.org> | 2012-03-24 01:37:02 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2012-03-24 01:37:02 +0100 |
| commit | de06e5715e780baade318f3490ac7a4c9ce84e32 (patch) | |
| tree | 23fbc3fafc12072476eff98bee60100eb54c29db /src/vpn-manager | |
| parent | b436a68a20ff3114ded32a7a3d70cdd4954039f9 (diff) | |
Imported Upstream version 0.9.4.0 upstream/0.9.4.0
Diffstat (limited to 'src/vpn-manager')
| -rw-r--r-- | src/vpn-manager/Makefile.am | 13 | ||||
| -rw-r--r-- | src/vpn-manager/Makefile.in | 34 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-connection-base.c | 209 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-connection-base.h | 57 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-connection.c | 91 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-connection.h | 9 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-manager.c | 38 | ||||
| -rw-r--r-- | src/vpn-manager/nm-vpn-manager.h | 23 |
8 files changed, 100 insertions, 374 deletions
diff --git a/src/vpn-manager/Makefile.am b/src/vpn-manager/Makefile.am index ce99728e..c3c5b525 100644 --- a/src/vpn-manager/Makefile.am +++ b/src/vpn-manager/Makefile.am @@ -1,10 +1,13 @@ INCLUDES = \ -I${top_srcdir} \ -I${top_srcdir}/include \ + -I${top_builddir}/include \ -I${top_srcdir}/libnm-util \ + -I${top_builddir}/libnm-util \ + -I${top_srcdir}/src/generated \ + -I${top_builddir}/src/generated \ -I${top_srcdir}/src/logging \ -I${top_srcdir}/src \ - -I${top_builddir}/marshallers \ -I${top_srcdir}/src/dns-manager \ -DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\" @@ -16,8 +19,6 @@ libvpn_manager_la_SOURCES = \ nm-vpn-manager.h \ nm-vpn-service.c \ nm-vpn-service.h \ - nm-vpn-connection-base.c \ - nm-vpn-connection-base.h \ nm-vpn-connection.c \ nm-vpn-connection.h @@ -28,16 +29,13 @@ libvpn_manager_la_CPPFLAGS = \ -DG_DISABLE_DEPRECATED libvpn_manager_la_LIBADD = \ - $(top_builddir)/marshallers/libmarshallers.la \ + $(top_builddir)/src/generated/libnm-generated.la \ $(top_builddir)/src/logging/libnm-logging.la \ $(top_builddir)/libnm-util/libnm-util.la \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(GLIB_LIBS) -nm-vpn-connection-base-glue.h: $(top_srcdir)/introspection/nm-active-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection_base --mode=glib-server --output=$@ $< - nm-vpn-connection-glue.h: $(top_srcdir)/introspection/nm-vpn-connection.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-server --output=$@ $< @@ -46,7 +44,6 @@ nm-vpn-plugin-bindings.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml BUILT_SOURCES = \ - nm-vpn-connection-base-glue.h \ nm-vpn-connection-glue.h \ nm-vpn-plugin-bindings.h diff --git a/src/vpn-manager/Makefile.in b/src/vpn-manager/Makefile.in index 51a12507..9a7e5e42 100644 --- a/src/vpn-manager/Makefile.in +++ b/src/vpn-manager/Makefile.in @@ -57,13 +57,12 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libvpn_manager_la_DEPENDENCIES = \ - $(top_builddir)/marshallers/libmarshallers.la \ + $(top_builddir)/src/generated/libnm-generated.la \ $(top_builddir)/src/logging/libnm-logging.la \ $(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_libvpn_manager_la_OBJECTS = libvpn_manager_la-nm-vpn-manager.lo \ libvpn_manager_la-nm-vpn-service.lo \ - libvpn_manager_la-nm-vpn-connection-base.lo \ libvpn_manager_la-nm-vpn-connection.lo libvpn_manager_la_OBJECTS = $(am_libvpn_manager_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) @@ -145,6 +144,8 @@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMSGFMT = @GMSGFMT@ @@ -199,11 +200,15 @@ LIBNL2_LIBS = @LIBNL2_LIBS@ LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_GENL3_CFLAGS = @LIBNL_GENL3_CFLAGS@ +LIBNL_GENL3_LIBS = @LIBNL_GENL3_LIBS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -214,6 +219,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -253,6 +259,8 @@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ @@ -319,10 +327,13 @@ top_srcdir = @top_srcdir@ INCLUDES = \ -I${top_srcdir} \ -I${top_srcdir}/include \ + -I${top_builddir}/include \ -I${top_srcdir}/libnm-util \ + -I${top_builddir}/libnm-util \ + -I${top_srcdir}/src/generated \ + -I${top_builddir}/src/generated \ -I${top_srcdir}/src/logging \ -I${top_srcdir}/src \ - -I${top_builddir}/marshallers \ -I${top_srcdir}/src/dns-manager \ -DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\" @@ -332,8 +343,6 @@ libvpn_manager_la_SOURCES = \ nm-vpn-manager.h \ nm-vpn-service.c \ nm-vpn-service.h \ - nm-vpn-connection-base.c \ - nm-vpn-connection-base.h \ nm-vpn-connection.c \ nm-vpn-connection.h @@ -344,7 +353,7 @@ libvpn_manager_la_CPPFLAGS = \ -DG_DISABLE_DEPRECATED libvpn_manager_la_LIBADD = \ - $(top_builddir)/marshallers/libmarshallers.la \ + $(top_builddir)/src/generated/libnm-generated.la \ $(top_builddir)/src/logging/libnm-logging.la \ $(top_builddir)/libnm-util/libnm-util.la \ $(LIBNL_LIBS) \ @@ -352,7 +361,6 @@ libvpn_manager_la_LIBADD = \ $(GLIB_LIBS) BUILT_SOURCES = \ - nm-vpn-connection-base-glue.h \ nm-vpn-connection-glue.h \ nm-vpn-plugin-bindings.h @@ -410,7 +418,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvpn_manager_la-nm-vpn-connection-base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvpn_manager_la-nm-vpn-connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvpn_manager_la-nm-vpn-manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvpn_manager_la-nm-vpn-service.Plo@am__quote@ @@ -458,14 +465,6 @@ libvpn_manager_la-nm-vpn-service.lo: nm-vpn-service.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libvpn_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libvpn_manager_la-nm-vpn-service.lo `test -f 'nm-vpn-service.c' || echo '$(srcdir)/'`nm-vpn-service.c -libvpn_manager_la-nm-vpn-connection-base.lo: nm-vpn-connection-base.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libvpn_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libvpn_manager_la-nm-vpn-connection-base.lo -MD -MP -MF $(DEPDIR)/libvpn_manager_la-nm-vpn-connection-base.Tpo -c -o libvpn_manager_la-nm-vpn-connection-base.lo `test -f 'nm-vpn-connection-base.c' || echo '$(srcdir)/'`nm-vpn-connection-base.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvpn_manager_la-nm-vpn-connection-base.Tpo $(DEPDIR)/libvpn_manager_la-nm-vpn-connection-base.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nm-vpn-connection-base.c' object='libvpn_manager_la-nm-vpn-connection-base.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libvpn_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libvpn_manager_la-nm-vpn-connection-base.lo `test -f 'nm-vpn-connection-base.c' || echo '$(srcdir)/'`nm-vpn-connection-base.c - libvpn_manager_la-nm-vpn-connection.lo: nm-vpn-connection.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libvpn_manager_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libvpn_manager_la-nm-vpn-connection.lo -MD -MP -MF $(DEPDIR)/libvpn_manager_la-nm-vpn-connection.Tpo -c -o libvpn_manager_la-nm-vpn-connection.lo `test -f 'nm-vpn-connection.c' || echo '$(srcdir)/'`nm-vpn-connection.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvpn_manager_la-nm-vpn-connection.Tpo $(DEPDIR)/libvpn_manager_la-nm-vpn-connection.Plo @@ -682,9 +681,6 @@ uninstall-am: pdf pdf-am ps ps-am tags uninstall uninstall-am -nm-vpn-connection-base-glue.h: $(top_srcdir)/introspection/nm-active-connection.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection_base --mode=glib-server --output=$@ $< - nm-vpn-connection-glue.h: $(top_srcdir)/introspection/nm-vpn-connection.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-server --output=$@ $< diff --git a/src/vpn-manager/nm-vpn-connection-base.c b/src/vpn-manager/nm-vpn-connection-base.c deleted file mode 100644 index bc2cffb2..00000000 --- a/src/vpn-manager/nm-vpn-connection-base.c +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2005 - 2011 Red Hat, Inc. - * Copyright (C) 2007 - 2008 Novell, Inc. - */ - -#include "NetworkManager.h" -#include "nm-vpn-connection-base.h" -#include "nm-active-connection.h" -#include "nm-vpn-connection-base-glue.h" -#include "nm-dbus-manager.h" - -G_DEFINE_ABSTRACT_TYPE (NMVpnConnectionBase, nm_vpn_connection_base, G_TYPE_OBJECT) - -#define NM_VPN_CONNECTION_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_VPN_CONNECTION_BASE, \ - NMVpnConnectionBasePrivate)) - -typedef struct { - gboolean disposed; - - NMConnection *connection; - char *ac_path; - char *specific_object; - gboolean is_default; - gboolean is_default6; - NMActiveConnectionState state; -} NMVpnConnectionBasePrivate; - -enum { - PROP_0, - PROP_CONNECTION, - PROP_UUID, - PROP_SPECIFIC_OBJECT, - PROP_DEVICES, - PROP_STATE, - PROP_DEFAULT, - PROP_DEFAULT6, - PROP_VPN, - - LAST_PROP -}; - -/****************************************************************/ - -void -nm_vpn_connection_base_set_state (NMVpnConnectionBase *self, - NMVPNConnectionState vpn_state) -{ - NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self); - NMActiveConnectionState new_ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; - - /* Set the NMActiveConnection state based on VPN state */ - switch (vpn_state) { - case NM_VPN_CONNECTION_STATE_PREPARE: - case NM_VPN_CONNECTION_STATE_NEED_AUTH: - case NM_VPN_CONNECTION_STATE_CONNECT: - case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: - new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING; - break; - case NM_VPN_CONNECTION_STATE_ACTIVATED: - new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED; - break; - default: - break; - } - - if (new_ac_state != priv->state) { - priv->state = new_ac_state; - g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE); - } -} - -const char * -nm_vpn_connection_base_get_ac_path (NMVpnConnectionBase *self) -{ - return NM_VPN_CONNECTION_BASE_GET_PRIVATE (self)->ac_path; -} - -const char * -nm_vpn_connection_base_get_specific_object (NMVpnConnectionBase *self) -{ - return NM_VPN_CONNECTION_BASE_GET_PRIVATE (self)->specific_object; -} - -void -nm_vpn_connection_base_export (NMVpnConnectionBase *self, - NMConnection *connection, - const char *specific_object) -{ - NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self); - NMDBusManager *dbus_mgr; - - g_return_if_fail (priv->connection == NULL); - - priv->connection = g_object_ref (connection); - priv->specific_object = g_strdup (specific_object); - - dbus_mgr = nm_dbus_manager_get (); - dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (dbus_mgr), - priv->ac_path, G_OBJECT (self)); - g_object_unref (dbus_mgr); -} - -/****************************************************************/ - -static void -nm_vpn_connection_base_init (NMVpnConnectionBase *self) -{ - NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self); - - priv->state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; - priv->ac_path = nm_active_connection_get_next_object_path (); -} - -static void -dispose (GObject *object) -{ - NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (object); - - if (!priv->disposed) { - priv->disposed = TRUE; - - g_free (priv->ac_path); - g_free (priv->specific_object); - g_object_unref (priv->connection); - } - - G_OBJECT_CLASS (nm_vpn_connection_base_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_CONNECTION: - g_value_set_boxed (value, nm_connection_get_path (priv->connection)); - break; - case PROP_UUID: - g_value_set_string (value, nm_connection_get_uuid (priv->connection)); - break; - case PROP_SPECIFIC_OBJECT: - g_value_set_boxed (value, priv->specific_object); - break; - case PROP_DEVICES: - g_value_take_boxed (value, g_ptr_array_new ()); - break; - case PROP_STATE: - g_value_set_uint (value, priv->state); - break; - case PROP_DEFAULT: - g_value_set_boolean (value, priv->is_default); - break; - case PROP_DEFAULT6: - g_value_set_boolean (value, priv->is_default6); - break; - case PROP_VPN: - g_value_set_boolean (value, TRUE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nm_vpn_connection_base_class_init (NMVpnConnectionBaseClass *vpn_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (vpn_class); - - g_type_class_add_private (vpn_class, sizeof (NMVpnConnectionBasePrivate)); - - /* virtual methods */ - object_class->get_property = get_property; - object_class->dispose = dispose; - - /* properties */ - nm_active_connection_install_properties (object_class, - PROP_CONNECTION, - PROP_UUID, - PROP_SPECIFIC_OBJECT, - PROP_DEVICES, - PROP_STATE, - PROP_DEFAULT, - PROP_DEFAULT6, - PROP_VPN); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (vpn_class), - &dbus_glib_nm_vpn_connection_base_object_info); -} - diff --git a/src/vpn-manager/nm-vpn-connection-base.h b/src/vpn-manager/nm-vpn-connection-base.h deleted file mode 100644 index 6f19e7c5..00000000 --- a/src/vpn-manager/nm-vpn-connection-base.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2005 - 2011 Red Hat, Inc. - */ - -#ifndef NM_VPN_CONNECTION_BASE_H -#define NM_VPN_CONNECTION_BASE_H - -#include <glib-object.h> -#include "NetworkManagerVPN.h" -#include "nm-connection.h" - -#define NM_TYPE_VPN_CONNECTION_BASE (nm_vpn_connection_base_get_type ()) -#define NM_VPN_CONNECTION_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBase)) -#define NM_VPN_CONNECTION_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBaseClass)) -#define NM_IS_VPN_CONNECTION_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_CONNECTION_BASE)) -#define NM_IS_VPN_CONNECTION_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_VPN_CONNECTION_BASE)) -#define NM_VPN_CONNECTION_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBaseClass)) - -typedef struct { - GObject parent; -} NMVpnConnectionBase; - -typedef struct { - GObjectClass parent; -} NMVpnConnectionBaseClass; - -GType nm_vpn_connection_base_get_type (void); - -const char *nm_vpn_connection_base_get_ac_path (NMVpnConnectionBase *self); - -const char *nm_vpn_connection_base_get_specific_object (NMVpnConnectionBase *self); - -void nm_vpn_connection_base_export (NMVpnConnectionBase *self, - NMConnection *connection, - const char *specific_object); - -void nm_vpn_connection_base_set_state (NMVpnConnectionBase *self, - NMVPNConnectionState vpn_state); - -#endif /* NM_VPN_CONNECTION_BASE_H */ - diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 73f2b553..b391f1ec 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2005 - 2011 Red Hat, Inc. + * Copyright (C) 2005 - 2012 Red Hat, Inc. * Copyright (C) 2006 - 2008 Novell, Inc. */ @@ -30,7 +30,6 @@ #include "NetworkManager.h" #include "NetworkManagerVPN.h" #include "nm-vpn-connection.h" -#include "nm-device-interface.h" #include "nm-setting-connection.h" #include "nm-setting-vpn.h" #include "nm-setting-ip4-config.h" @@ -52,7 +51,7 @@ #include "nm-vpn-connection-glue.h" -G_DEFINE_TYPE (NMVPNConnection, nm_vpn_connection, NM_TYPE_VPN_CONNECTION_BASE) +G_DEFINE_TYPE (NMVPNConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) typedef enum { /* Only system secrets */ @@ -108,12 +107,31 @@ enum { PROP_0, PROP_VPN_STATE, PROP_BANNER, + PROP_MASTER = 2000, LAST_PROP }; static void get_secrets (NMVPNConnection *self, SecretsReq secrets_idx); +static NMActiveConnectionState +ac_state_from_vpn_state (NMVPNConnectionState vpn_state) +{ + /* Set the NMActiveConnection state based on VPN state */ + switch (vpn_state) { + case NM_VPN_CONNECTION_STATE_PREPARE: + case NM_VPN_CONNECTION_STATE_NEED_AUTH: + case NM_VPN_CONNECTION_STATE_CONNECT: + case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: + return NM_ACTIVE_CONNECTION_STATE_ACTIVATING; + case NM_VPN_CONNECTION_STATE_ACTIVATED: + return NM_ACTIVE_CONNECTION_STATE_ACTIVATED; + default: + break; + } + return NM_ACTIVE_CONNECTION_STATE_UNKNOWN; +} + static void nm_vpn_connection_set_vpn_state (NMVPNConnection *connection, NMVPNConnectionState vpn_state, @@ -134,7 +152,8 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection, priv->vpn_state = vpn_state; /* Update active connection base class state */ - nm_vpn_connection_base_set_state (NM_VPN_CONNECTION_BASE (connection), vpn_state); + nm_active_connection_set_state (NM_ACTIVE_CONNECTION (connection), + ac_state_from_vpn_state (vpn_state)); /* Save ip_iface since when the VPN goes down it may get freed * before we're done with it. @@ -231,7 +250,10 @@ nm_vpn_connection_new (NMConnection *connection, g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_DEVICE (parent_device), NULL); - self = (NMVPNConnection *) g_object_new (NM_TYPE_VPN_CONNECTION, NULL); + self = (NMVPNConnection *) g_object_new (NM_TYPE_VPN_CONNECTION, + NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, + NM_ACTIVE_CONNECTION_VPN, TRUE, + NULL); if (!self) return NULL; @@ -246,11 +268,16 @@ nm_vpn_connection_new (NMConnection *connection, G_CALLBACK (device_state_changed), self); - priv->device_ip4 = g_signal_connect (parent_device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG, + priv->device_ip4 = g_signal_connect (parent_device, "notify::" NM_DEVICE_IP4_CONFIG, G_CALLBACK (device_ip4_config_changed), self); - nm_vpn_connection_base_export (NM_VPN_CONNECTION_BASE (self), connection, specific_object); + if (!nm_active_connection_export (NM_ACTIVE_CONNECTION (self), + connection, + nm_device_get_path (parent_device))) { + g_object_unref (self); + self = NULL; + } return self; } @@ -259,10 +286,10 @@ static const char * nm_vpn_connection_get_service (NMVPNConnection *connection) { NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); - NMSettingVPN *setting; + NMSettingVPN *s_vpn; - setting = (NMSettingVPN *) nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_VPN); - return nm_setting_vpn_get_service_type (setting); + s_vpn = nm_connection_get_setting_vpn (priv->connection); + return nm_setting_vpn_get_service_type (s_vpn); } static void @@ -452,7 +479,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, /* Grab the interface index for address/routing operations */ priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface); - if (!priv->ip_ifindex) { + if (priv->ip_ifindex < 0) { nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface); goto error; } @@ -520,6 +547,15 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, if (val) nm_ip4_config_add_domain (config, g_value_get_string (val)); + val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS); + if (val) { + const char **domains = g_value_get_boxed (val); + const char **domain; + + for (domain = domains; domain && *domain; domain++) + nm_ip4_config_add_domain (config, *domain); + } + val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_BANNER); if (val) { g_free (priv->banner); @@ -559,7 +595,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, print_vpn_config (config, priv->ip4_internal_gw, priv->ip_iface, priv->banner); /* Merge in user overrides from the NMConnection's IPv4 setting */ - s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_IP4_CONFIG)); + s_ip4 = nm_connection_get_setting_ip4_config (priv->connection); nm_utils_merge_ip4_config (config, s_ip4); nm_system_iface_set_up (priv->ip_ifindex, TRUE, NULL); @@ -646,22 +682,22 @@ static GHashTable * _hash_with_username (NMConnection *connection, const char *username) { NMConnection *dup; - NMSetting *s_vpn; + NMSettingVPN *s_vpn; GHashTable *hash; const char *existing; /* Shortcut if we weren't given a username or if there already was one in * the VPN setting; don't bother duplicating the connection and everything. */ - s_vpn = nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = nm_connection_get_setting_vpn (connection); g_assert (s_vpn); - existing = nm_setting_vpn_get_user_name (NM_SETTING_VPN (s_vpn)); + existing = nm_setting_vpn_get_user_name (s_vpn); if (username == NULL || existing) return nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL); dup = nm_connection_duplicate (connection); g_assert (dup); - s_vpn = nm_connection_get_setting (dup, NM_TYPE_SETTING_VPN); + s_vpn = nm_connection_get_setting_vpn (dup); g_assert (s_vpn); g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL); hash = nm_connection_to_hash (dup, NM_SETTING_HASH_FLAG_ALL); @@ -737,25 +773,17 @@ nm_vpn_connection_activate (NMVPNConnection *connection) } const char * -nm_vpn_connection_get_active_connection_path (NMVPNConnection *connection) -{ - g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), NULL); - - return nm_vpn_connection_base_get_ac_path (NM_VPN_CONNECTION_BASE (connection)); -} - -const char * nm_vpn_connection_get_name (NMVPNConnection *connection) { NMVPNConnectionPrivate *priv; - NMSettingConnection *setting; + NMSettingConnection *s_con; g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), NULL); priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); - setting = (NMSettingConnection *) nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_CONNECTION); + s_con = nm_connection_get_setting_connection (priv->connection); - return nm_setting_connection_get_id (setting); + return nm_setting_connection_get_id (s_con); } NMConnection * @@ -1152,6 +1180,9 @@ get_property (GObject *object, guint prop_id, case PROP_BANNER: g_value_set_string (value, priv->banner ? priv->banner : ""); break; + case PROP_MASTER: + g_value_set_boxed (value, nm_device_get_path (priv->parent_dev)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1171,6 +1202,8 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class) object_class->dispose = dispose; object_class->finalize = finalize; + g_object_class_override_property (object_class, PROP_MASTER, NM_ACTIVE_CONNECTION_MASTER); + /* properties */ g_object_class_install_property (object_class, PROP_VPN_STATE, g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, @@ -1199,10 +1232,6 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class) G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMVPNConnectionClass, properties_changed)); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (object_class), &dbus_glib_nm_vpn_connection_object_info); } diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h index c0d15f8a..93cc06d1 100644 --- a/src/vpn-manager/nm-vpn-connection.h +++ b/src/vpn-manager/nm-vpn-connection.h @@ -26,7 +26,6 @@ #include <glib-object.h> #include "NetworkManagerVPN.h" #include "nm-device.h" -#include "nm-vpn-connection-base.h" #define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) #define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnection)) @@ -39,18 +38,16 @@ #define NM_VPN_CONNECTION_BANNER "banner" typedef struct { - NMVpnConnectionBase parent; + NMActiveConnection parent; } NMVPNConnection; typedef struct { - NMVpnConnectionBaseClass parent; + NMActiveConnectionClass parent; /* Signals */ void (*vpn_state_changed) (NMVPNConnection *connection, NMVPNConnectionState state, NMVPNConnectionStateReason reason); - - void (*properties_changed) (NMVPNConnection *connection, GHashTable *properties); } NMVPNConnectionClass; GType nm_vpn_connection_get_type (void); @@ -63,8 +60,6 @@ NMVPNConnection * nm_vpn_connection_new (NMConnection *connection, void nm_vpn_connection_activate (NMVPNConnection *connection); NMConnection * nm_vpn_connection_get_connection (NMVPNConnection *connection); -const char * nm_vpn_connection_get_active_connection_path (NMVPNConnection *connection); -const char * nm_vpn_connection_get_specific_object_path (NMVPNConnection *connection); const char * nm_vpn_connection_get_name (NMVPNConnection *connection); NMVPNConnectionState nm_vpn_connection_get_vpn_state (NMVPNConnection *connection); const char * nm_vpn_connection_get_banner (NMVPNConnection *connection); diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c index 41e96c0b..34131964 100644 --- a/src/vpn-manager/nm-vpn-manager.c +++ b/src/vpn-manager/nm-vpn-manager.c @@ -29,6 +29,7 @@ #include "nm-dbus-manager.h" #include "NetworkManagerVPN.h" #include "nm-marshal.h" +#include "nm-enum-types.h" #include "nm-logging.h" G_DEFINE_TYPE (NMVPNManager, nm_vpn_manager, G_TYPE_OBJECT) @@ -61,31 +62,6 @@ nm_vpn_manager_error_quark (void) return quark; } -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -nm_vpn_manager_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* The base device for the VPN connection is not active. */ - ENUM_ENTRY (NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE, "BaseDeviceNotActive"), - /* The requested VPN connection was invalid. */ - ENUM_ENTRY (NM_VPN_MANAGER_ERROR_CONNECTION_INVALID, "ConnectionInvalid"), - /* The VPN service required by this VPN connection did not exist or was invalid. */ - ENUM_ENTRY (NM_VPN_MANAGER_ERROR_SERVICE_INVALID, "ServiceInvalid"), - /* The VPN service required by this VPN connection could not be started. */ - ENUM_ENTRY (NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED, "ServiceStartFailed"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("NMVPNManagerError", values); - } - return etype; -} - static NMVPNService * get_service_by_namefile (NMVPNManager *self, const char *namefile) @@ -158,7 +134,7 @@ connection_vpn_state_changed (NMVPNConnection *connection, } } -NMVPNConnection * +NMActiveConnection * nm_vpn_manager_activate_connection (NMVPNManager *manager, NMConnection *connection, NMDevice *device, @@ -185,7 +161,7 @@ nm_vpn_manager_activate_connection (NMVPNManager *manager, return NULL; } - vpn_setting = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + vpn_setting = nm_connection_get_setting_vpn (connection); if (!vpn_setting) { g_set_error (error, NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_CONNECTION_INVALID, @@ -217,7 +193,7 @@ nm_vpn_manager_activate_connection (NMVPNManager *manager, manager); } - return vpn; + return (NMActiveConnection *) vpn; } gboolean @@ -243,7 +219,7 @@ nm_vpn_manager_deactivate_connection (NMVPNManager *self, NMVPNConnection *vpn = NM_VPN_CONNECTION (aiter->data); const char *vpn_path; - vpn_path = nm_vpn_connection_get_active_connection_path (vpn); + vpn_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn)); if (!strcmp (path, vpn_path)) { nm_vpn_connection_disconnect (vpn, reason); success = TRUE; @@ -279,7 +255,7 @@ nm_vpn_manager_add_active_connections (NMVPNManager *self, const char *path; if (!filter || (nm_vpn_connection_get_connection (vpn) == filter)) { - path = nm_vpn_connection_get_active_connection_path (vpn); + path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn)); g_ptr_array_add (array, g_strdup (path)); } } @@ -326,7 +302,7 @@ nm_vpn_manager_get_vpn_connection_for_active (NMVPNManager *manager, NMVPNConnection *vpn = NM_VPN_CONNECTION (elt->data); const char *ac_path; - ac_path = nm_vpn_connection_get_active_connection_path (vpn); + ac_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn)); if (ac_path && !strcmp (ac_path, active_path)) return vpn; } diff --git a/src/vpn-manager/nm-vpn-manager.h b/src/vpn-manager/nm-vpn-manager.h index 78a5220b..cec370c8 100644 --- a/src/vpn-manager/nm-vpn-manager.h +++ b/src/vpn-manager/nm-vpn-manager.h @@ -35,14 +35,13 @@ typedef enum { - NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE = 0, - NM_VPN_MANAGER_ERROR_CONNECTION_INVALID, - NM_VPN_MANAGER_ERROR_SERVICE_INVALID, - NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED, + NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE = 0, /*< nick=BaseDeviceNotActive >*/ + NM_VPN_MANAGER_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ + NM_VPN_MANAGER_ERROR_SERVICE_INVALID, /*< nick=ServiceInvalid >*/ + NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED, /*< nick=ServiceStartFailed >*/ } NMVPNManagerError; #define NM_VPN_MANAGER_ERROR (nm_vpn_manager_error_quark ()) -#define NM_TYPE_VPN_MANAGER_ERROR (nm_vpn_manager_error_get_type ()) GQuark nm_vpn_manager_error_quark (void); GType nm_vpn_manager_error_get_type (void); @@ -66,13 +65,13 @@ GType nm_vpn_manager_get_type (void); NMVPNManager *nm_vpn_manager_get (void); -NMVPNConnection *nm_vpn_manager_activate_connection (NMVPNManager *manager, - NMConnection *connection, - NMDevice *device, - const char *specific_object, - gboolean user_requested, - gulong user_uid, - GError **error); +NMActiveConnection *nm_vpn_manager_activate_connection (NMVPNManager *manager, + NMConnection *connection, + NMDevice *device, + const char *specific_object, + gboolean user_requested, + gulong user_uid, + GError **error); gboolean nm_vpn_manager_deactivate_connection (NMVPNManager *manager, const char *path, |