summaryrefslogtreecommitdiff
path: root/src/vpn-manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn-manager')
-rw-r--r--src/vpn-manager/Makefile.am3
-rw-r--r--src/vpn-manager/Makefile.in79
-rw-r--r--src/vpn-manager/nm-vpn-connection.c144
-rw-r--r--src/vpn-manager/nm-vpn-connection.h1
-rw-r--r--src/vpn-manager/nm-vpn-manager.c176
-rw-r--r--src/vpn-manager/nm-vpn-manager.h24
-rw-r--r--src/vpn-manager/nm-vpn-service.c6
-rw-r--r--src/vpn-manager/nm-vpn-service.h2
8 files changed, 139 insertions, 296 deletions
diff --git a/src/vpn-manager/Makefile.am b/src/vpn-manager/Makefile.am
index 06e04734c..a525ce205 100644
--- a/src/vpn-manager/Makefile.am
+++ b/src/vpn-manager/Makefile.am
@@ -26,8 +26,7 @@ libvpn_manager_la_SOURCES = \
libvpn_manager_la_CPPFLAGS = \
$(LIBNL_CFLAGS) \
$(DBUS_CFLAGS) \
- $(GLIB_CFLAGS) \
- -DG_DISABLE_DEPRECATED
+ $(GLIB_CFLAGS)
libvpn_manager_la_LIBADD = \
$(top_builddir)/src/generated/libnm-generated.la \
diff --git a/src/vpn-manager/Makefile.in b/src/vpn-manager/Makefile.in
index 5eb769c5e..bb8efd17c 100644
--- a/src/vpn-manager/Makefile.in
+++ b/src/vpn-manager/Makefile.in
@@ -55,16 +55,18 @@ subdir = src/vpn-manager
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
- $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
- $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
- $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/gnome-code-coverage.m4 \
+ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \
+ $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libnl-check.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/vapigen.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -134,6 +136,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CKDB_PATH = @CKDB_PATH@
+CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@
+CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@
+CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
@@ -148,9 +154,7 @@ DBUS_SYS_DIR = @DBUS_SYS_DIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DHCLIENT_PATH = @DHCLIENT_PATH@
-DHCLIENT_VERSION = @DHCLIENT_VERSION@
DHCPCD_PATH = @DHCPCD_PATH@
-DISABLE_DEPRECATED = @DISABLE_DEPRECATED@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
@@ -160,17 +164,14 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+GENHTML = @GENHTML@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
-GIO_CFLAGS = @GIO_CFLAGS@
-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@
GMSGFMT_015 = @GMSGFMT_015@
GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
@@ -211,6 +212,7 @@ IPTABLES_PATH = @IPTABLES_PATH@
IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@
IWMX_SDK_LIBS = @IWMX_SDK_LIBS@
KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
+LCOV = @LCOV@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBDL = @LIBDL@
@@ -227,11 +229,7 @@ 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@
@@ -246,6 +244,8 @@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
+MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@
+MM_GLIB_LIBS = @MM_GLIB_LIBS@
MOC = @MOC@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
@@ -255,6 +255,7 @@ NMEDIT = @NMEDIT@
NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
NM_MICRO_VERSION = @NM_MICRO_VERSION@
NM_MINOR_VERSION = @NM_MINOR_VERSION@
+NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@
NM_VERSION = @NM_VERSION@
NSS_CFLAGS = @NSS_CFLAGS@
NSS_LIBS = @NSS_LIBS@
@@ -281,13 +282,14 @@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
QT_CFLAGS = @QT_CFLAGS@
QT_LIBS = @QT_LIBS@
RANLIB = @RANLIB@
-RESOLVCONF_PATH = @RESOLVCONF_PATH@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
-SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@
-SYSTEMD_LIBS = @SYSTEMD_LIBS@
+SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@
+SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@
+SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@
+SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@
SYSTEM_CA_PATH = @SYSTEM_CA_PATH@
UDEV_BASE_DIR = @UDEV_BASE_DIR@
USE_NLS = @USE_NLS@
@@ -342,6 +344,11 @@ localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
+nmbinary = @nmbinary@
+nmconfdir = @nmconfdir@
+nmdatadir = @nmdatadir@
+nmrundir = @nmrundir@
+nmstatedir = @nmstatedir@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
@@ -356,6 +363,10 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+with_dhclient = @with_dhclient@
+with_dhcpcd = @with_dhcpcd@
+with_netconfig = @with_netconfig@
+with_resolvconf = @with_resolvconf@
INCLUDES = \
-I${top_srcdir} \
-I${top_builddir}/include \
@@ -382,8 +393,7 @@ libvpn_manager_la_SOURCES = \
libvpn_manager_la_CPPFLAGS = \
$(LIBNL_CFLAGS) \
$(DBUS_CFLAGS) \
- $(GLIB_CFLAGS) \
- -DG_DISABLE_DEPRECATED
+ $(GLIB_CFLAGS)
libvpn_manager_la_LIBADD = \
$(top_builddir)/src/generated/libnm-generated.la \
@@ -457,25 +467,22 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvpn_manager_la-nm-vpn-service.Plo@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
-@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
-@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 1820ede3f..639d66d05 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -47,6 +47,7 @@
#include "nm-netlink-utils.h"
#include "nm-glib-compat.h"
#include "settings/nm-settings-connection.h"
+#include "nm-dispatcher.h"
#include "nm-vpn-connection-glue.h"
@@ -68,8 +69,6 @@ typedef struct {
NMConnection *connection;
- gboolean user_requested;
- gulong user_uid;
guint32 secrets_id;
SecretsReq secrets_idx;
char *username;
@@ -134,6 +133,9 @@ ac_state_from_vpn_state (NMVPNConnectionState vpn_state)
return NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
return NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
+ case NM_VPN_CONNECTION_STATE_FAILED:
+ case NM_VPN_CONNECTION_STATE_DISCONNECTED:
+ return NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
default:
break;
}
@@ -242,23 +244,27 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection,
nm_connection_clear_secrets (priv->connection);
/* Let dispatcher scripts know we're up and running */
- nm_utils_call_dispatcher ("vpn-up",
- priv->connection,
- priv->parent_dev,
- priv->ip_iface,
- priv->ip4_config,
- priv->ip6_config);
+ nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_UP,
+ priv->connection,
+ priv->parent_dev,
+ priv->ip_iface,
+ priv->ip4_config,
+ priv->ip6_config,
+ NULL,
+ NULL);
break;
case NM_VPN_CONNECTION_STATE_FAILED:
case NM_VPN_CONNECTION_STATE_DISCONNECTED:
if (old_vpn_state == NM_VPN_CONNECTION_STATE_ACTIVATED) {
/* Let dispatcher scripts know we're about to go down */
- nm_utils_call_dispatcher ("vpn-down",
- priv->connection,
- priv->parent_dev,
- priv->ip_iface,
- NULL,
- NULL);
+ nm_dispatcher_call_vpn (DISPATCHER_ACTION_VPN_DOWN,
+ priv->connection,
+ priv->parent_dev,
+ priv->ip_iface,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
}
/* Tear down and clean up the connection */
@@ -342,42 +348,20 @@ nm_vpn_connection_new (NMConnection *connection,
gulong user_uid)
{
NMVPNConnection *self;
- NMVPNConnectionPrivate *priv;
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,
+ NM_ACTIVE_CONNECTION_INT_CONNECTION, connection,
+ NM_ACTIVE_CONNECTION_INT_DEVICE, parent_device,
NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
+ NM_ACTIVE_CONNECTION_INT_USER_REQUESTED, user_requested,
+ NM_ACTIVE_CONNECTION_INT_USER_UID, user_uid,
NM_ACTIVE_CONNECTION_VPN, TRUE,
NULL);
- if (!self)
- return NULL;
-
- priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
-
- priv->user_requested = user_requested;
- priv->user_uid = user_uid;
- priv->connection = g_object_ref (connection);
- priv->parent_dev = g_object_ref (parent_device);
-
- priv->device_monitor = g_signal_connect (parent_device, "state-changed",
- G_CALLBACK (device_state_changed),
- self);
-
- priv->device_ip4 = g_signal_connect (parent_device, "notify::" NM_DEVICE_IP4_CONFIG,
- G_CALLBACK (device_ip4_config_changed),
- self);
- priv->device_ip6 = g_signal_connect (parent_device, "notify::" NM_DEVICE_IP6_CONFIG,
- G_CALLBACK (device_ip6_config_changed),
- self);
-
- if (!nm_active_connection_export (NM_ACTIVE_CONNECTION (self),
- connection,
- nm_device_get_path (parent_device))) {
- g_object_unref (self);
- self = NULL;
- }
+ if (self)
+ nm_active_connection_export (NM_ACTIVE_CONNECTION (self));
return self;
}
@@ -642,7 +626,7 @@ nm_vpn_connection_apply_config (NMVPNConnection *connection)
}
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) complete.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_ACTIVATED,
NM_VPN_CONNECTION_STATE_REASON_NONE);
@@ -684,7 +668,7 @@ nm_vpn_connection_config_maybe_complete (NMVPNConnection *connection,
g_clear_object (&priv->ip6_config);
nm_log_warn (LOGD_VPN, "VPN connection '%s' did not receive valid IP config information.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID);
@@ -708,7 +692,7 @@ process_generic_config (NMVPNConnection *connection,
/* Grab the interface index for address/routing operations */
priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface);
- if (priv->ip_ifindex < 0) {
+ if (priv->ip_ifindex <= 0) {
nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface);
nm_vpn_connection_config_maybe_complete (connection, FALSE);
return FALSE;
@@ -762,7 +746,7 @@ nm_vpn_connection_config_get (DBusGProxy *proxy,
GValue *val;
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) reply received.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
if (!process_generic_config (connection, config_hash))
return;
@@ -792,7 +776,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
if (priv->has_ip4) {
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP4 Config Get) reply received.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
if (g_hash_table_size (config_hash) == 0) {
priv->has_ip4 = FALSE;
@@ -801,7 +785,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
}
} else {
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP4 Config Get) reply received from old-style plugin.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
/* In the old API, the generic and IPv4 configuration items
* were mixed together.
@@ -937,7 +921,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
int i;
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP6 Config Get) reply received.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
if (g_hash_table_size (config_hash) == 0) {
priv->has_ip6 = FALSE;
@@ -1073,7 +1057,7 @@ nm_vpn_connection_ip_config_timeout (gpointer user_data)
*/
if (nm_vpn_connection_get_vpn_state (connection) == NM_VPN_CONNECTION_STATE_IP_CONFIG_GET) {
nm_log_warn (LOGD_VPN, "VPN connection '%s' (IP Config Get) timeout exceeded.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT);
@@ -1089,11 +1073,11 @@ nm_vpn_connection_connect_cb (DBusGProxy *proxy, GError *err, gpointer user_data
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
nm_log_info (LOGD_VPN, "VPN connection '%s' (Connect) reply received.",
- nm_vpn_connection_get_name (connection));
+ nm_connection_get_id (priv->connection));
if (err) {
nm_log_warn (LOGD_VPN, "VPN connection '%s' failed to connect: '%s'.",
- nm_vpn_connection_get_name (connection), err->message);
+ nm_connection_get_id (priv->connection), err->message);
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED);
@@ -1219,20 +1203,6 @@ nm_vpn_connection_activate (NMVPNConnection *connection)
NM_VPN_CONNECTION_STATE_REASON_NONE);
}
-const char *
-nm_vpn_connection_get_name (NMVPNConnection *connection)
-{
- NMVPNConnectionPrivate *priv;
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), NULL);
-
- priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
- s_con = nm_connection_get_setting_connection (priv->connection);
-
- return nm_setting_connection_get_id (s_con);
-}
-
NMConnection *
nm_vpn_connection_get_connection (NMVPNConnection *connection)
{
@@ -1431,11 +1401,13 @@ get_secrets (NMVPNConnection *self, SecretsReq secrets_idx)
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
NMSettingsGetSecretsFlags flags = NM_SETTINGS_GET_SECRETS_FLAG_NONE;
GError *error = NULL;
- gboolean filter_by_uid = priv->user_requested;
+ gboolean filter_by_uid;
g_return_if_fail (secrets_idx < SECRETS_REQ_LAST);
priv->secrets_idx = secrets_idx;
+ filter_by_uid = nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self));
+
nm_log_dbg (LOGD_VPN, "(%s/%s) requesting VPN secrets pass #%d",
nm_connection_get_uuid (priv->connection),
nm_connection_get_id (priv->connection),
@@ -1456,12 +1428,12 @@ get_secrets (NMVPNConnection *self, SecretsReq secrets_idx)
g_assert_not_reached ();
}
- if (priv->user_requested)
+ if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self)))
flags |= NM_SETTINGS_GET_SECRETS_FLAG_USER_REQUESTED;
priv->secrets_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection),
filter_by_uid,
- priv->user_uid,
+ nm_active_connection_get_user_uid (NM_ACTIVE_CONNECTION (self)),
NM_SETTING_VPN_SETTING_NAME,
flags,
NULL,
@@ -1487,6 +1459,35 @@ nm_vpn_connection_init (NMVPNConnection *self)
}
static void
+constructed (GObject *object)
+{
+ NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
+ NMConnection *connection;
+ NMDevice *device;
+
+ G_OBJECT_CLASS (nm_vpn_connection_parent_class)->constructed (object);
+
+ connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (object));
+ priv->connection = g_object_ref (connection);
+
+ device = (NMDevice *) nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
+ g_assert (device);
+
+ priv->parent_dev = g_object_ref (device);
+
+ priv->device_monitor = g_signal_connect (device, "state-changed",
+ G_CALLBACK (device_state_changed),
+ object);
+
+ priv->device_ip4 = g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONFIG,
+ G_CALLBACK (device_ip4_config_changed),
+ object);
+ priv->device_ip6 = g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONFIG,
+ G_CALLBACK (device_ip6_config_changed),
+ object);
+}
+
+static void
dispose (GObject *object)
{
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
@@ -1512,7 +1513,7 @@ dispose (GObject *object)
if (priv->device_monitor)
g_signal_handler_disconnect (priv->parent_dev, priv->device_monitor);
- g_object_unref (priv->parent_dev);
+ g_clear_object (&priv->parent_dev);
if (priv->ip4_config)
g_object_unref (priv->ip4_config);
@@ -1530,7 +1531,7 @@ dispose (GObject *object)
priv->secrets_id);
}
- g_object_unref (priv->connection);
+ g_clear_object (&priv->connection);
g_free (priv->username);
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object);
@@ -1578,6 +1579,7 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
/* virtual methods */
object_class->get_property = get_property;
+ object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->finalize = finalize;
diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h
index 98bf14f1d..bf5433456 100644
--- a/src/vpn-manager/nm-vpn-connection.h
+++ b/src/vpn-manager/nm-vpn-connection.h
@@ -72,7 +72,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_name (NMVPNConnection *connection);
NMVPNConnectionState nm_vpn_connection_get_vpn_state (NMVPNConnection *connection);
const char * nm_vpn_connection_get_banner (NMVPNConnection *connection);
void nm_vpn_connection_fail (NMVPNConnection *connection,
diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c
index 8bfa82aed..7743fddd7 100644
--- a/src/vpn-manager/nm-vpn-manager.c
+++ b/src/vpn-manager/nm-vpn-manager.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.
*/
@@ -44,15 +44,6 @@ typedef struct {
guint monitor_id;
} NMVPNManagerPrivate;
-enum {
- CONNECTION_ACTIVATED,
- CONNECTION_DEACTIVATED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
GQuark
nm_vpn_manager_error_quark (void)
{
@@ -91,7 +82,7 @@ find_active_vpn_connection_by_connection (NMVPNManager *self, NMConnection *conn
NMVPNManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self);
GHashTableIter iter;
gpointer data;
- GSList *active, *aiter;
+ const GSList *active, *aiter;
NMVPNConnection *found = NULL;
g_return_val_if_fail (connection, NULL);
@@ -108,33 +99,10 @@ find_active_vpn_connection_by_connection (NMVPNManager *self, NMConnection *conn
break;
}
}
- g_slist_free (active);
}
return found;
}
-static void
-connection_vpn_state_changed (NMVPNConnection *connection,
- NMVPNConnectionState new_state,
- NMVPNConnectionState old_state,
- NMVPNConnectionStateReason reason,
- gpointer user_data)
-{
- NMVPNManager *manager = NM_VPN_MANAGER (user_data);
-
- switch (new_state) {
- case NM_VPN_CONNECTION_STATE_ACTIVATED:
- g_signal_emit (manager, signals[CONNECTION_ACTIVATED], 0, connection);
- break;
- case NM_VPN_CONNECTION_STATE_FAILED:
- case NM_VPN_CONNECTION_STATE_DISCONNECTED:
- g_signal_emit (manager, signals[CONNECTION_DEACTIVATED], 0, connection, new_state, old_state, reason);
- break;
- default:
- break;
- }
-}
-
NMActiveConnection *
nm_vpn_manager_activate_connection (NMVPNManager *manager,
NMConnection *connection,
@@ -155,7 +123,8 @@ nm_vpn_manager_activate_connection (NMVPNManager *manager,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (*error == NULL, NULL);
- if (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED) {
+ if ( nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED
+ && nm_device_get_state (device) != NM_DEVICE_STATE_SECONDARIES) {
g_set_error (error,
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE,
"%s", "The base device for the VPN connection was not active.");
@@ -187,142 +156,48 @@ nm_vpn_manager_activate_connection (NMVPNManager *manager,
return NULL;
}
- vpn = nm_vpn_service_activate (service, connection, device, specific_object, user_requested, user_uid, error);
- if (vpn) {
- g_signal_connect (vpn, NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED,
- G_CALLBACK (connection_vpn_state_changed),
- manager);
- }
-
- return (NMActiveConnection *) vpn;
+ return (NMActiveConnection *) nm_vpn_service_activate (service,
+ connection,
+ device,
+ specific_object,
+ user_requested,
+ user_uid,
+ error);
}
gboolean
nm_vpn_manager_deactivate_connection (NMVPNManager *self,
- const char *path,
+ NMVPNConnection *connection,
NMVPNConnectionStateReason reason)
{
NMVPNManagerPrivate *priv;
GHashTableIter iter;
gpointer data;
- GSList *active, *aiter;
+ const GSList *active, *aiter;
gboolean success = FALSE;
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (NM_IS_VPN_MANAGER (self), FALSE);
- g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
priv = NM_VPN_MANAGER_GET_PRIVATE (self);
g_hash_table_iter_init (&iter, priv->services);
while (g_hash_table_iter_next (&iter, NULL, &data) && (success == FALSE)) {
active = nm_vpn_service_get_active_connections (NM_VPN_SERVICE (data));
for (aiter = active; aiter; aiter = g_slist_next (aiter)) {
- NMVPNConnection *vpn = NM_VPN_CONNECTION (aiter->data);
- const char *vpn_path;
+ NMVPNConnection *candidate = aiter->data;
- vpn_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn));
- if (!strcmp (path, vpn_path)) {
- nm_vpn_connection_disconnect (vpn, reason);
+ if (connection == candidate) {
+ nm_vpn_connection_disconnect (connection, reason);
success = TRUE;
break;
}
}
- g_slist_free (active);
}
return success;
}
-void
-nm_vpn_manager_add_active_connections (NMVPNManager *self,
- NMConnection *filter,
- GPtrArray *array)
-{
- NMVPNManagerPrivate *priv;
- GHashTableIter iter;
- gpointer data;
- GSList *active, *aiter;
-
- g_return_if_fail (self);
- g_return_if_fail (NM_IS_VPN_MANAGER (self));
- g_return_if_fail (array != NULL);
-
- priv = NM_VPN_MANAGER_GET_PRIVATE (self);
- g_hash_table_iter_init (&iter, priv->services);
- while (g_hash_table_iter_next (&iter, NULL, &data)) {
- active = nm_vpn_service_get_active_connections (NM_VPN_SERVICE (data));
- for (aiter = active; aiter; aiter = g_slist_next (aiter)) {
- NMVPNConnection *vpn = NM_VPN_CONNECTION (aiter->data);
- const char *path;
-
- if (!filter || (nm_vpn_connection_get_connection (vpn) == filter)) {
- path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn));
- g_ptr_array_add (array, g_strdup (path));
- }
- }
- g_slist_free (active);
- }
-}
-
-GSList *
-nm_vpn_manager_get_active_connections (NMVPNManager *self)
-{
- NMVPNManagerPrivate *priv;
- GHashTableIter iter;
- gpointer data;
- GSList *list = NULL, *active;
-
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (NM_IS_VPN_MANAGER (self), NULL);
-
- priv = NM_VPN_MANAGER_GET_PRIVATE (self);
- g_hash_table_iter_init (&iter, priv->services);
- while (g_hash_table_iter_next (&iter, NULL, &data)) {
- active = nm_vpn_service_get_active_connections (NM_VPN_SERVICE (data));
- list = g_slist_concat (list, active);
- }
- return list;
-}
-
-NMVPNConnection *
-nm_vpn_manager_get_vpn_connection_for_active (NMVPNManager *manager,
- const char *active_path)
-{
- NMVPNManagerPrivate *priv;
- GHashTableIter iter;
- gpointer data;
- GSList *active, *elt;
-
- g_return_val_if_fail (NM_IS_VPN_MANAGER (manager), NULL);
-
- priv = NM_VPN_MANAGER_GET_PRIVATE (manager);
- g_hash_table_iter_init (&iter, priv->services);
- while (g_hash_table_iter_next (&iter, NULL, &data)) {
- active = nm_vpn_service_get_active_connections (NM_VPN_SERVICE (data));
- for (elt = active; elt; elt = g_slist_next (elt)) {
- NMVPNConnection *vpn = NM_VPN_CONNECTION (elt->data);
- const char *ac_path;
-
- ac_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (vpn));
- if (ac_path && !strcmp (ac_path, active_path))
- return vpn;
- }
- }
-
- return NULL;
-}
-
-NMConnection *
-nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
- const char *active_path)
-{
- NMVPNConnection *vpn_con;
-
- vpn_con = nm_vpn_manager_get_vpn_connection_for_active (manager, active_path);
-
- return vpn_con ? nm_vpn_connection_get_connection (vpn_con) : NULL;
-}
-
static char *
service_name_from_file (const char *path)
{
@@ -506,23 +381,6 @@ nm_vpn_manager_class_init (NMVPNManagerClass *manager_class)
/* virtual methods */
object_class->dispose = dispose;
- /* signals */
- signals[CONNECTION_ACTIVATED] =
- g_signal_new ("connection-activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[CONNECTION_DEACTIVATED] =
- g_signal_new ("connection-deactivated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- _nm_marshal_VOID__OBJECT_UINT_UINT_UINT,
- G_TYPE_NONE, 4, G_TYPE_OBJECT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
-
dbus_g_error_domain_register (NM_VPN_MANAGER_ERROR, NULL, NM_TYPE_VPN_MANAGER_ERROR);
}
diff --git a/src/vpn-manager/nm-vpn-manager.h b/src/vpn-manager/nm-vpn-manager.h
index efae161ed..1d398ea2c 100644
--- a/src/vpn-manager/nm-vpn-manager.h
+++ b/src/vpn-manager/nm-vpn-manager.h
@@ -53,16 +53,6 @@ typedef struct {
typedef struct {
GObjectClass parent;
-
- /* Signals */
- void (*connection_activated) (NMVPNManager *manager,
- NMVPNConnection *connection);
-
- void (*connection_deactivated) (NMVPNManager *manager,
- NMVPNConnection *connection,
- NMVPNConnectionState new_state,
- NMVPNConnectionState old_state,
- NMVPNConnectionStateReason reason);
} NMVPNManagerClass;
GType nm_vpn_manager_get_type (void);
@@ -78,19 +68,7 @@ NMActiveConnection *nm_vpn_manager_activate_connection (NMVPNManager *manager,
GError **error);
gboolean nm_vpn_manager_deactivate_connection (NMVPNManager *manager,
- const char *path,
+ NMVPNConnection *connection,
NMVPNConnectionStateReason reason);
-void nm_vpn_manager_add_active_connections (NMVPNManager *manager,
- NMConnection *filter,
- GPtrArray *list);
-
-GSList *nm_vpn_manager_get_active_connections (NMVPNManager *manager);
-
-NMVPNConnection *nm_vpn_manager_get_vpn_connection_for_active (NMVPNManager *manager,
- const char *active_path);
-
-NMConnection *nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
- const char *active_path);
-
#endif /* NM_VPN_MANAGER_H */
diff --git a/src/vpn-manager/nm-vpn-service.c b/src/vpn-manager/nm-vpn-service.c
index 8fdf6c161..668cbf2e3 100644
--- a/src/vpn-manager/nm-vpn-service.c
+++ b/src/vpn-manager/nm-vpn-service.c
@@ -355,7 +355,7 @@ nm_vpn_service_activate (NMVPNService *service,
G_CALLBACK (connection_vpn_state_changed),
service);
- priv->connections = g_slist_prepend (priv->connections, vpn);
+ priv->connections = g_slist_prepend (priv->connections, g_object_ref (vpn));
if (nm_dbus_manager_name_has_owner (priv->dbus_mgr, priv->dbus_service)) {
// FIXME: fill in error when errors happen
@@ -369,12 +369,12 @@ nm_vpn_service_activate (NMVPNService *service,
return vpn;
}
-GSList *
+const GSList *
nm_vpn_service_get_active_connections (NMVPNService *service)
{
g_return_val_if_fail (NM_IS_VPN_SERVICE (service), NULL);
- return g_slist_copy (NM_VPN_SERVICE_GET_PRIVATE (service)->connections);
+ return NM_VPN_SERVICE_GET_PRIVATE (service)->connections;
}
static void
diff --git a/src/vpn-manager/nm-vpn-service.h b/src/vpn-manager/nm-vpn-service.h
index 6ccdcc473..e883d55f8 100644
--- a/src/vpn-manager/nm-vpn-service.h
+++ b/src/vpn-manager/nm-vpn-service.h
@@ -62,7 +62,7 @@ NMVPNConnection * nm_vpn_service_activate (NMVPNService *service,
gulong user_uid,
GError **error);
-GSList * nm_vpn_service_get_active_connections (NMVPNService *service);
+const GSList *nm_vpn_service_get_active_connections (NMVPNService *service);
void nm_vpn_service_connections_stop (NMVPNService *service,
gboolean fail,