From 6734620e79a0918ce1d51b9a7832a0113b56b9ef Mon Sep 17 00:00:00 2001 From: CeRiAl <ikhatib@gmail.com> Date: Sun, 28 Aug 2016 04:07:06 +0200 Subject: [PATCH] Just push everything --- INSTALL | 2 +- Makefile.am | 7 +- auth-dialog/Makefile.am | 35 +- auth-dialog/main.c | 18 +- configure.ac | 37 +- nm-ipsec-l2tp-service.name.in | 3 + po/sl.po | 8 +- properties/Makefile.am | 59 +- properties/advanced-dialog.c | 33 +- properties/advanced-dialog.h | 10 +- properties/import-export.c | 58 +- properties/import-export.h | 7 + properties/ipsec-dialog.c | 9 +- properties/ipsec-dialog.h | 6 + properties/nm-ipsec-l2tp.c | 264 +++-- properties/nm-ipsec-l2tp.h | 61 +- shared/Makefile.am | 9 + shared/README | 9 + shared/nm-default.h | 112 ++ shared/nm-service-defines.h | 56 + shared/nm-utils/gsystem-local-alloc.h | 208 ++++ shared/nm-utils/nm-glib.h | 397 +++++++ shared/nm-utils/nm-macros-internal.h | 606 +++++++++++ shared/nm-utils/nm-vpn-plugin-utils.c | 130 +++ shared/nm-utils/nm-vpn-plugin-utils.h | 42 + src/Makefile.am | 87 +- src/nm-ipsec-l2tp-pppd-plugin.c | 195 ++-- src/nm-ipsec-l2tp-pppd-service-dbus.c | 1444 +++++++++++++++++++++++++ src/nm-ipsec-l2tp-pppd-service-dbus.h | 235 ++++ src/nm-ipsec-l2tp-service-defines.h | 63 ++ src/nm-ipsec-l2tp-service.c | 315 ++++-- src/nm-ipsec-l2tp-service.h | 64 +- 32 files changed, 3974 insertions(+), 615 deletions(-) create mode 100644 shared/Makefile.am create mode 100644 shared/README create mode 100644 shared/nm-default.h create mode 100644 shared/nm-service-defines.h create mode 100644 shared/nm-utils/gsystem-local-alloc.h create mode 100644 shared/nm-utils/nm-glib.h create mode 100644 shared/nm-utils/nm-macros-internal.h create mode 100644 shared/nm-utils/nm-vpn-plugin-utils.c create mode 100644 shared/nm-utils/nm-vpn-plugin-utils.h create mode 100644 src/nm-ipsec-l2tp-pppd-service-dbus.c create mode 100644 src/nm-ipsec-l2tp-pppd-service-dbus.h create mode 100644 src/nm-ipsec-l2tp-service-defines.h diff --git a/INSTALL b/INSTALL index f76d7a5..25b1e0e 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ Tested on: * ElementaryOS Freya * Linux Mint Rebecca Cinnamon -$ sudo apt-get install build-essential autoconf libtool intltool ppp-dev git xl2tpd strongswan libglib2.0-dev libdbus-glib-1-dev libnm-util-dev libnm-glib-vpn-dev libgnome-keyring-dev libgtk-3-dev +$ sudo apt-get install build-essential autoconf libtool intltool ppp-dev git xl2tpd strongswan ipsec-tools libglib2.0-dev libdbus-glib-1-dev libnm-dev libnm-util-dev libnm-glib-vpn-dev libgnome-keyring-dev libgtk-3-dev $ git clone https://git.cryptopath.org/cerial/NetworkManager-l2tp.git $ cd NetworkManager-l2tp/ $ ./autogen.sh diff --git a/Makefile.am b/Makefile.am index d90175a..45aea8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,9 +9,14 @@ endif dbusservicedir = $(sysconfdir)/dbus-1/system.d dbusservice_DATA = nm-ipsec-l2tp-service.conf -nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN +nmvpnservicedir = $(NM_VPN_SERVICE_DIR) nmvpnservice_DATA = nm-ipsec-l2tp-service.name +if WITH_LIBNM_GLIB +nmvpnoldservicedir = $(sysconfdir)/NetworkManager/VPN +nmvpnoldservice_DATA = nm-ipsec-l2tp-service.name +endif + desktopfile = nm-ipsec-l2tp.desktop.in iconfile = gnome-mime-application-x-ipsec-l2tp-settings.png diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am index bb79de9..a6dbdb5 100644 --- a/auth-dialog/Makefile.am +++ b/auth-dialog/Makefile.am @@ -1,27 +1,26 @@ -INCLUDES = -I${top_srcdir} - libexec_PROGRAMS = nm-ipsec-l2tp-auth-dialog -nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \ - $(NM_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) \ - $(GNOMEKEYRING_CFLAGS) \ - -Wno-error=deprecated-declarations \ - -DICONDIR=\""$(datadir)/pixmaps"\" \ - -DUIDIR=\""$(uidir)"\" \ - -DBINDIR=\""$(bindir)"\" \ - -DG_DISABLE_DEPRECATED \ +nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \ + $(LIBNM_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GNOMEKEYRING_CFLAGS) \ + -I"${top_srcdir}/shared/" \ + -Wno-error=deprecated-declarations \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DUIDIR=\""$(uidir)"\" \ + -DBINDIR=\""$(bindir)"\" \ + -DG_DISABLE_DEPRECATED \ -DVERSION=\"$(VERSION)\" -nm_ipsec_l2tp_auth_dialog_SOURCES = \ - main.c \ - vpn-password-dialog.c \ +nm_ipsec_l2tp_auth_dialog_SOURCES = \ + main.c \ + vpn-password-dialog.c \ vpn-password-dialog.h -nm_ipsec_l2tp_auth_dialog_LDADD = \ - $(NM_LIBS) \ - $(GTK_LIBS) \ +nm_ipsec_l2tp_auth_dialog_LDADD = \ + $(LIBNM_LIBS) \ + $(GTK_LIBS) \ $(GNOMEKEYRING_LIBS) CLEANFILES = *~ diff --git a/auth-dialog/main.c b/auth-dialog/main.c index 9f929cd..b52f526 100644 --- a/auth-dialog/main.c +++ b/auth-dialog/main.c @@ -24,6 +24,8 @@ #include <config.h> #endif +#include "nm-default.h" + #include <string.h> #include <stdlib.h> #include <errno.h> @@ -33,10 +35,14 @@ #include <gnome-keyring.h> #include <gnome-keyring-memory.h> -#include <nm-setting-vpn.h> -#include <nm-vpn-plugin-utils.h> +//#include <libsecret/secret.h> + +//#include <nm-setting-vpn.h> +//#include <NetworkManager.h> +//#include <nm-vpn-service-plugin.h> + +#include "../src/nm-ipsec-l2tp-service-defines.h" -#include <src/nm-ipsec-l2tp-service.h> #include "vpn-password-dialog.h" #define KEYRING_UUID_TAG "connection-uuid" @@ -218,7 +224,7 @@ wait_for_quit (void) g_string_free (str, TRUE); } -int +int main (int argc, char *argv[]) { gboolean retry = FALSE, allow_interaction = FALSE, external_ui_mode = FALSE; @@ -257,13 +263,13 @@ main (int argc, char *argv[]) return 1; } - if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) { + if (!nm_vpn_service_plugin_read_vpn_details (0, &data, &secrets)) { fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n", vpn_name, vpn_uuid); return 1; } - nm_vpn_plugin_utils_get_secret_flags (secrets, NM_IPSEC_L2TP_KEY_PASSWORD, &pw_flags); + nm_vpn_service_plugin_get_secret_flags (secrets, NM_IPSEC_L2TP_KEY_PASSWORD, &pw_flags); if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode, g_hash_table_lookup (secrets, NM_IPSEC_L2TP_KEY_PASSWORD), diff --git a/configure.ac b/configure.ac index 1c1dd16..c941e86 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,9 @@ dnl AC_ARG_WITH(gnome, AS_HELP_STRING([--without-gnome], [Build NetworkManager-ipsec-l2tp without GNOME support, e.g. vpn service only])) AM_CONDITIONAL(WITH_GNOME, test x"$with_gnome" != xno) +AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--without-libnm-glib], [Build NetworkManager-ipsec-l2tp without libnm-glib comatibility])) +AM_CONDITIONAL(WITH_LIBNM_GLIB, test x"$with_libnm_glib" != xno) + GETTEXT_PACKAGE=NetworkManager-ipsec-l2tp AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) @@ -61,23 +64,12 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) IT_PROG_INTLTOOL([0.35]) AM_GLIB_GNU_GETTEXT -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32) +# gio-unix will require glib and gio +PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32" -PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74) -AC_SUBST(DBUS_GLIB_CFLAGS) -AC_SUBST(DBUS_GLIB_LIBS) - -PKG_CHECK_MODULES(NM, - NetworkManager >= 0.9.8 - libnm-util >= 0.9.8 - libnm-glib >= 0.9.8 - libnm-glib-vpn >= 0.9.8) -AC_SUBST(NM_CFLAGS) -AC_SUBST(NM_LIBS) - if test x"$with_gnome" != xno; then PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4) AC_SUBST(GTK_CFLAGS) @@ -87,6 +79,16 @@ if test x"$with_gnome" != xno; then PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1) AC_SUBST(GNOMEKEYRING_CFLAGS) AC_SUBST(GNOMEKEYRING_LIBS) + + if test x"$with_libnm_glib" != xno; then + PKG_CHECK_MODULES(LIBNM_GLIB, + NetworkManager >= 1.1.0 + libnm-util >= 1.1.0 + libnm-glib >= 1.1.0 + libnm-glib-vpn >= 1.1.0) + AC_SUBST(LIBNM_GLIB_CFLAGS) + AC_SUBST(LIBNM_GLIB_LIBS) + fi fi NM_COMPILER_WARNINGS @@ -99,6 +101,15 @@ if ! test x"$ac_distver" = x""; then AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string]) fi +PKG_CHECK_MODULES(LIBNM, libnm >= 1.1.0) +LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2" +LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_2" + +NM_VPN_SERVICE_DIR=`$PKG_CONFIG --define-variable prefix='\${prefix}' --variable vpnservicedir libnm` +AC_SUBST(NM_VPN_SERVICE_DIR) + +NM_COMPILER_WARNINGS + AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/nm-ipsec-l2tp-service.name.in b/nm-ipsec-l2tp-service.name.in index b0742a0..79e9ed4 100644 --- a/nm-ipsec-l2tp-service.name.in +++ b/nm-ipsec-l2tp-service.name.in @@ -3,6 +3,9 @@ name=ipsec-l2tp service=org.freedesktop.NetworkManager.ipsec_l2tp program=@LIBEXECDIR@/nm-ipsec-l2tp-service +[libnm] +plugin=@PLUGINDIR@/libnm-vpn-plugin-ipsec-l2tp.so + [GNOME] auth-dialog=@LIBEXECDIR@/nm-ipsec-l2tp-auth-dialog properties=@PLUGINDIR@/libnm-ipsec-l2tp-properties diff --git a/po/sl.po b/po/sl.po index 8dfee4b..4aa0165 100644 --- a/po/sl.po +++ b/po/sl.po @@ -1,9 +1,9 @@ # Slovenian translation for network-manager-ipsec-l2tp. -# Copyright (C) 2009 network-manager-ipsec-l2tp's COPYRIGHT HOLDER -# This file is distributed under the same license as the network-manager-ipsec-l2tp package. +# Copyright (C) 2009 network-manager-ipsec-l2tp's COPYRIGHT HOLDER +# This file is distributed under the same license as the network-manager-ipsec-l2tp package. # -# Matej UrbanÄiÄ <mateju@svn.gnome.org>, 2009 - 2010. -# +# Matej UrbanÄiÄ <mateju@svn.gnome.org>, 2009 - 2010. +# msgid "" msgstr "" "Project-Id-Version: network-manager-ipsec-l2tp master\n" diff --git a/properties/Makefile.am b/properties/Makefile.am index b67c3fb..ac88e9a 100644 --- a/properties/Makefile.am +++ b/properties/Makefile.am @@ -1,37 +1,56 @@ plugindir = $(libdir)/NetworkManager -plugin_LTLIBRARIES = libnm-ipsec-l2tp-properties.la +plugin_LTLIBRARIES = libnm-vpn-plugin-ipsec-l2tp.la +if WITH_LIBNM_GLIB +plugin_LTLIBRARIES += libnm-ipsec-l2tp-properties.la +endif -INCLUDES = -I${top_srcdir} - -libnm_ipsec_l2tp_properties_la_SOURCES = \ +libnm_vpn_plugin_ipsec_l2tp_la_SOURCES = \ nm-ipsec-l2tp.c \ nm-ipsec-l2tp.h \ ipsec-dialog.c \ ipsec-dialog.h \ advanced-dialog.c \ - advanced-dialog.h \ - import-export.c \ - import-export.h + advanced-dialog.h +# import-export.c \ +# import-export.h + +libnm_ipsec_l2tp_properties_la_SOURCES = \ + $(libnm_vpn_plugin_ipsec_l2tp_la_SOURCES) -uidir = $(datadir)/gnome-vpn-properties/l2tp +uidir = $(datadir)/gnome-vpn-properties/ipsec-l2tp ui_DATA = nm-ipsec-l2tp-dialog.ui -libnm_ipsec_l2tp_properties_la_CFLAGS = \ - $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) \ - $(NM_CFLAGS) \ - -DICONDIR=\""$(datadir)/pixmaps"\" \ - -DUIDIR=\""$(uidir)"\" \ - -DLOCALEDIR=\""$(datadir)/locale"\" \ - -DG_DISABLE_DEPRECATED \ - -DVERSION=\"$(VERSION)\" +common_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DUIDIR=\""$(uidir)"\" \ + -DLOCALEDIR=\""$(datadir)/locale"\" \ + -DG_DISABLE_DEPRECATED \ + -DVERSION=\"$(VERSION)\" + +libnm_vpn_plugin_ipsec_l2tp_la_CFLAGS = \ + $(common_CFLAGS) \ + $(LIBNM_CFLAGS) + +libnm_ipsec_l2tp_properties_la_CFLAGS = \ + -DNM_IPSEC_L2TP_OLD \ + $(common_CFLAGS) \ + $(LIBNM_GLIB_CFLAGS) + +libnm_vpn_plugin_ipsec_l2tp_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNM_LIBS) libnm_ipsec_l2tp_properties_la_LIBADD = \ - $(GTK_LIBS) \ - $(NM_LIBS) + $(GTK_LIBS) \ + $(LIBNM_GLIB_LIBS) + +libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS = \ + -avoid-version libnm_ipsec_l2tp_properties_la_LDFLAGS = \ - -avoid-version + $(libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS) CLEANFILES = *.bak *~ diff --git a/properties/advanced-dialog.c b/properties/advanced-dialog.c index 1cab4e0..8bd8c7b 100644 --- a/properties/advanced-dialog.c +++ b/properties/advanced-dialog.c @@ -35,12 +35,9 @@ #include <glib.h> #include <glib/gi18n-lib.h> -#include <nm-connection.h> -#include <nm-setting-vpn.h> - #include "advanced-dialog.h" #include "nm-ipsec-l2tp.h" -#include "../src/nm-ipsec-l2tp-service.h" +#include "../src/nm-ipsec-l2tp-service-defines.h" #define COL_NAME 0 #define COL_VALUE 1 @@ -66,8 +63,6 @@ static const char *advanced_keys[] = { NM_IPSEC_L2TP_KEY_NOBSDCOMP, NM_IPSEC_L2TP_KEY_NODEFLATE, NM_IPSEC_L2TP_KEY_NO_VJ_COMP, - NM_IPSEC_L2TP_KEY_NO_PCOMP, - NM_IPSEC_L2TP_KEY_NO_ACCOMP, NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE, NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, NULL @@ -91,11 +86,11 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection, GError **error) { GHashTable *hash; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash); return hash; } @@ -282,7 +277,7 @@ auth_methods_setup (GtkBuilder *builder, GHashTable *hash) value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE); if (value && !strcmp (value, "yes")) use_mppe = TRUE; - + /* Or MPPE-128 */ value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128); if (value && !strcmp (value, "yes")) @@ -468,18 +463,6 @@ advanced_dialog_new (GHashTable *hash) if (value && !strcmp (value, "yes")) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); - widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); - value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_NO_PCOMP); - if (value && !strcmp (value, "yes")) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); - - widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); - value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_NO_ACCOMP); - if (value && !strcmp (value, "yes")) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); - widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets")); value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL); if (value && strlen (value)) { @@ -554,14 +537,6 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error) if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_VJ_COMP), g_strdup ("yes")); - widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp")); - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) - g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_PCOMP), g_strdup ("yes")); - - widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp")); - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) - g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_ACCOMP), g_strdup ("yes")); - widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets")); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE), g_strdup_printf ("%d", 5)); diff --git a/properties/advanced-dialog.h b/properties/advanced-dialog.h index d907ef3..13dc00a 100644 --- a/properties/advanced-dialog.h +++ b/properties/advanced-dialog.h @@ -19,13 +19,19 @@ * **************************************************************************/ -#ifndef _AUTH_HELPERS_H_ -#define _AUTH_HELPERS_H_ +#ifndef _ADVANCED_DIALOG_H_ +#define _ADVANCED_DIALOG_H_ #include <glib.h> #include <gtk/gtk.h> +#ifdef NM_IPSEC_L2TP_OLD +#define NM_VPN_LIBNM_COMPAT #include <nm-connection.h> +#include <nm-setting-vpn.h> +#else /* !NM_IPSEC_L2TP_OLD */ +#include <NetworkManager.h> +#endif GtkWidget *advanced_dialog_new (GHashTable *hash); diff --git a/properties/import-export.c b/properties/import-export.c index 932dfb0..e6b4e1d 100644 --- a/properties/import-export.c +++ b/properties/import-export.c @@ -37,9 +37,9 @@ #include <glib/gi18n-lib.h> -#include <nm-setting-vpn.h> -#include <nm-setting-connection.h> -#include <nm-setting-ip4-config.h> +//#include <nm-setting-vpn.h> +//#include <nm-setting-connection.h> +//#include <nm-setting-ip4-config.h> #include "import-export.h" #include "nm-ipsec-l2tp.h" @@ -104,8 +104,6 @@ static VpnImportExportProperty vpn_properties[] = { { NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NODEFLATE, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NO_VJ_COMP, G_TYPE_BOOLEAN, FALSE }, - { NM_IPSEC_L2TP_KEY_NO_PCOMP, G_TYPE_BOOLEAN, FALSE }, - { NM_IPSEC_L2TP_KEY_NO_ACCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE, G_TYPE_UINT, FALSE }, { NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, G_TYPE_UINT, FALSE }, /* { NM_IPSEC_L2TP_KEY_PASSWORD"-flags", G_TYPE_UINT, FALSE }, */ @@ -119,11 +117,11 @@ static VpnImportExportProperty vpn_properties[] = { }; static VpnImportExportProperty ip4_properties[] = { - { NM_SETTING_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE}, - { NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE}, - { NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE}, - { NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE}, - { NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE}, + { NM_VPN_PLUGIN_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE}, + { NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE}, + { NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE}, + { NM_VPN_PLUGIN_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE}, + { NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE}, { NULL, G_TYPE_NONE, FALSE } /* NM_SETTING_IP4_CONFIG_DNS */ /* NM_SETTING_IP4_CONFIG_DNS_SEARCH */ @@ -134,8 +132,8 @@ static void ip4_import_error (GError **error, const char *message, const char *key, const char *val) { g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, message, key, val); @@ -165,8 +163,8 @@ import_ip4 (GKeyFile *keyfile, NMSettingIP4Config *s_ip4, GError **error) continue; g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY, _("Required property %s missing"), prop.name); return FALSE; @@ -371,7 +369,7 @@ do_import (const char *path, GError **error) { NMConnection *connection = NULL; NMSettingConnection *s_con; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; NMSettingIP4Config *s_ip4; GKeyFile *keyfile; @@ -381,13 +379,13 @@ do_import (const char *path, GError **error) keyfile = g_key_file_new (); if (!g_key_file_load_from_file (keyfile, path, 0, error)) { g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP, _("does not look like a IPSEC-L2TP VPN connection (parse failed)")); return NULL; } - connection = nm_connection_new (); + connection = nm_simple_connection_new (); s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); @@ -416,8 +414,8 @@ do_import (const char *path, GError **error) continue; g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY, _("Required property %s missing"), prop.name); g_key_file_free (keyfile); @@ -434,8 +432,8 @@ do_import (const char *path, GError **error) if (int_val == 0 && *error){ g_clear_error(error); g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, _("Property %s can't be parsed as integer."), prop.name); g_key_file_free (keyfile); @@ -451,8 +449,8 @@ do_import (const char *path, GError **error) if (!bool_val) { g_clear_error(error); g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, _("Property %s can't be parsed as boolean. Only 'true' and 'false' allowed."), prop.name); g_key_file_free (keyfile); @@ -595,7 +593,7 @@ gboolean do_export (const char *path, NMConnection *connection, GError **error) { NMSettingConnection *s_con; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; NMSettingIP4Config *s_ip4; GKeyFile *export_file; @@ -607,7 +605,7 @@ do_export (const char *path, NMConnection *connection, GError **error) s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG); - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); export_file = g_key_file_new (); @@ -623,8 +621,8 @@ do_export (const char *path, NMConnection *connection, GError **error) if (!value && prop.required){ g_key_file_free(export_file); g_set_error(error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY, _("Missing required property '%s'"), prop.name); return FALSE; @@ -653,8 +651,8 @@ do_export (const char *path, NMConnection *connection, GError **error) if (!(file = fopen (path, "w"))) { g_set_error(error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE, _("Couldn't open file for writing.")); g_key_file_free (export_file); return FALSE; diff --git a/properties/import-export.h b/properties/import-export.h index d8bae42..3be1326 100644 --- a/properties/import-export.h +++ b/properties/import-export.h @@ -23,7 +23,14 @@ #define _IMPORT_EXPORT_H_ #include <glib.h> + +#ifdef NM_IPSEC_L2TP_OLD +#define NM_VPN_LIBNM_COMPAT #include <nm-connection.h> +#include <nm-setting-vpn.h> +#else /* !NM_IPSEC_L2TP_OLD */ +#include <NetworkManager.h> +#endif NMConnection *do_import (const char *path, GError **error); diff --git a/properties/ipsec-dialog.c b/properties/ipsec-dialog.c index 869e148..60903fd 100644 --- a/properties/ipsec-dialog.c +++ b/properties/ipsec-dialog.c @@ -34,12 +34,9 @@ #include <glib.h> #include <glib/gi18n-lib.h> -#include <nm-connection.h> -#include <nm-setting-vpn.h> - #include "ipsec-dialog.h" #include "nm-ipsec-l2tp.h" -#include "../src/nm-ipsec-l2tp-service.h" +#include "../src/nm-ipsec-l2tp-service-defines.h" static const char *ipsec_keys[] = { NM_IPSEC_L2TP_KEY_IPSEC_ENABLE, @@ -69,11 +66,11 @@ ipsec_dialog_new_hash_from_connection (NMConnection *connection, GError **error) { GHashTable *hash; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash); return hash; } diff --git a/properties/ipsec-dialog.h b/properties/ipsec-dialog.h index cc45c3b..1f8e4e8 100644 --- a/properties/ipsec-dialog.h +++ b/properties/ipsec-dialog.h @@ -25,7 +25,13 @@ #include <glib.h> #include <gtk/gtk.h> +#ifdef NM_IPSEC_L2TP_OLD +#define NM_VPN_LIBNM_COMPAT #include <nm-connection.h> +#include <nm-setting-vpn.h> +#else /* !NM_IPSEC_L2TP_OLD */ +#include <NetworkManager.h> +#endif GtkWidget *ipsec_dialog_new (GHashTable *hash); diff --git a/properties/nm-ipsec-l2tp.c b/properties/nm-ipsec-l2tp.c index 6107164..ea7a884 100644 --- a/properties/nm-ipsec-l2tp.c +++ b/properties/nm-ipsec-l2tp.c @@ -36,12 +36,30 @@ #define NM_VPN_API_SUBJECT_TO_CHANGE +#ifdef NM_IPSEC_L2TP_OLD +#define NM_VPN_LIBNM_COMPAT #include <nm-vpn-plugin-ui-interface.h> #include <nm-setting-vpn.h> #include <nm-setting-connection.h> #include <nm-setting-ip4-config.h> -#include "../src/nm-ipsec-l2tp-service.h" +#define nm_simple_connection_new nm_connection_new + +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY + +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY + +#else /* !NM_IPSEC_L2TP_OLD */ + +#include <NetworkManager.h> + +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR NM_CONNECTION_ERROR +#define IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY +#endif + +#include "../src/nm-ipsec-l2tp-service-defines.h" #include "nm-ipsec-l2tp.h" #include "import-export.h" #include "advanced-dialog.h" @@ -49,7 +67,6 @@ #define IPSEC_L2TP_PLUGIN_NAME _("IPSec-L2TP") #define IPSEC_L2TP_PLUGIN_DESC _("Compatible with IPSec-L2TP VPN servers.") -#define IPSEC_L2TP_PLUGIN_SERVICE NM_DBUS_SERVICE_IPSEC_L2TP #define PW_TYPE_SAVE 0 #define PW_TYPE_ASK 1 @@ -59,21 +76,28 @@ typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data); /************** plugin class **************/ -static void ipsec_l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class); +enum { + PROP_0, + PROP_NAME, + PROP_DESC, + PROP_SERVICE +}; -G_DEFINE_TYPE_EXTENDED (IPSecL2tpPluginUi, ipsec_l2tp_plugin_ui, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE, - ipsec_l2tp_plugin_ui_interface_init)) +static void ipsec_l2tp_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class); + +G_DEFINE_TYPE_EXTENDED (IPSecL2tpEditorPlugin, ipsec_l2tp_editor_plugin, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN, + ipsec_l2tp_editor_plugin_interface_init)) /************** UI widget class **************/ -static void ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class); +static void ipsec_l2tp_editor_interface_init (NMVpnEditorInterface *iface_class); -G_DEFINE_TYPE_EXTENDED (IPSecL2tpPluginUiWidget, ipsec_l2tp_plugin_ui_widget, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, - ipsec_l2tp_plugin_ui_widget_interface_init)) +G_DEFINE_TYPE_EXTENDED (IPSecL2tpEditor, ipsec_l2tp_editor, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR, + ipsec_l2tp_editor_interface_init)) -#define IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetPrivate)) +#define IPSEC_L2TP_EDITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorPrivate)) typedef struct { GtkBuilder *builder; @@ -84,48 +108,13 @@ typedef struct { GHashTable *advanced; GHashTable *ipsec; gboolean new_connection; -} IPSecL2tpPluginUiWidgetPrivate; - +} IPSecL2tpEditorPrivate; -GQuark -ipsec_l2tp_plugin_ui_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("ipsec-l2tp-plugin-ui-error-quark"); - - return error_quark; -} - -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } +/************** import/export **************/ -GType -ipsec_l2tp_plugin_ui_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"), - /* The connection was missing invalid. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, "InvalidConnection"), - /* The specified property was invalid. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, "MissingProperty"), - /* The file to import could not be read. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE, "FileNotReadable"), - /* The file to import could was not an IPSec-L2TP client file. */ - ENUM_ENTRY (IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, "FileNotIPSecL2TP"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("IPSecL2tpPluginUiError", values); - } - return etype; -} +typedef enum { + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP = 0 +} NMIpsecL2tpImportError; /** * Return copy of string #s with the leading and trailing spaces removed @@ -158,9 +147,9 @@ strstrip (const char *s) } static gboolean -check_validity (IPSecL2tpPluginUiWidget *self, GError **error) +check_validity (IPSecL2tpEditor *self, GError **error) { - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GtkWidget *widget; const char *str; char *s=NULL; @@ -170,8 +159,8 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error) if (!str || !strlen (s = strstrip (str))) { g_free(s); g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, NM_IPSEC_L2TP_KEY_GATEWAY); return FALSE; } @@ -182,7 +171,7 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error) static void stuff_changed_cb (GtkWidget *widget, gpointer user_data) { - g_signal_emit_by_name (IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data), "changed"); + g_signal_emit_by_name (IPSEC_L2TP_EDITOR (user_data), "changed"); } static void @@ -204,8 +193,8 @@ ipsec_dialog_close_cb (GtkWidget *dialog, gpointer user_data) static void advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GError *error = NULL; if (response != GTK_RESPONSE_OK) { @@ -228,8 +217,8 @@ advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_dat static void ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GError *error = NULL; if (response != GTK_RESPONSE_OK) { @@ -252,8 +241,8 @@ ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) static void advanced_button_clicked_cb (GtkWidget *button, gpointer user_data) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GtkWidget *dialog, *toplevel; toplevel = gtk_widget_get_toplevel (priv->widget); @@ -281,8 +270,8 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data) static void ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GtkWidget *dialog, *toplevel; toplevel = gtk_widget_get_toplevel (priv->widget); @@ -308,13 +297,13 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data) } static void -setup_password_widget (IPSecL2tpPluginUiWidget *self, +setup_password_widget (IPSecL2tpEditor *self, const char *entry_name, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, const char *secret_name, gboolean new_connection) { - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; GtkWidget *widget; const char *value; @@ -339,9 +328,9 @@ setup_password_widget (IPSecL2tpPluginUiWidget *self, } static void -show_toggled_cb (GtkCheckButton *button, IPSecL2tpPluginUiWidget *self) +show_toggled_cb (GtkCheckButton *button, IPSecL2tpEditor *self) { - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GtkWidget *widget; gboolean visible; @@ -355,8 +344,8 @@ show_toggled_cb (GtkCheckButton *button, IPSecL2tpPluginUiWidget *self) static void pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); GtkWidget *entry; entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry")); @@ -380,13 +369,13 @@ pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) } static void -init_one_pw_combo (IPSecL2tpPluginUiWidget *self, - NMSettingVPN *s_vpn, +init_one_pw_combo (IPSecL2tpEditor *self, + NMSettingVpn *s_vpn, const char *combo_name, const char *secret_key, const char *entry_name) { - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); int active = -1; GtkWidget *widget; GtkListStore *store; @@ -437,14 +426,14 @@ init_one_pw_combo (IPSecL2tpPluginUiWidget *self, } static gboolean -init_plugin_ui (IPSecL2tpPluginUiWidget *self, NMConnection *connection, GError **error) +init_editor_plugin (IPSecL2tpEditor *self, NMConnection *connection, GError **error) { - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); - NMSettingVPN *s_vpn; + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); + NMSettingVpn *s_vpn; GtkWidget *widget; const char *value; - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); @@ -512,10 +501,10 @@ init_plugin_ui (IPSecL2tpPluginUiWidget *self, NMConnection *connection, GError } static GObject * -get_widget (NMVpnPluginUiWidgetInterface *iface) +get_widget (NMVpnEditor *iface) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (iface); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (iface); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); return G_OBJECT (priv->widget); } @@ -523,13 +512,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface) static void hash_copy_pair (gpointer key, gpointer data, gpointer user_data) { - NMSettingVPN *s_vpn = NM_SETTING_VPN (user_data); + NMSettingVpn *s_vpn = NM_SETTING_VPN (user_data); nm_setting_vpn_add_data_item (s_vpn, (const char *) key, (const char *) data); } static void -save_password_and_flags (NMSettingVPN *s_vpn, +save_password_and_flags (NMSettingVpn *s_vpn, GtkBuilder *builder, const char *entry_name, const char *combo_name, @@ -566,13 +555,13 @@ save_password_and_flags (NMSettingVPN *s_vpn, } static gboolean -update_connection (NMVpnPluginUiWidgetInterface *iface, +update_connection (NMVpnEditor *iface, NMConnection *connection, GError **error) { - IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (iface); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); - NMSettingVPN *s_vpn; + IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (iface); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self); + NMSettingVpn *s_vpn; GtkWidget *widget; const char *str; char *s=NULL; @@ -632,25 +621,25 @@ is_new_func (const char *key, const char *value, gpointer user_data) *is_new = FALSE; } -static NMVpnPluginUiWidgetInterface * -nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) +static NMVpnEditor * +nm_vpn_editor_interface_new (NMConnection *connection, GError **error) { - NMVpnPluginUiWidgetInterface *object; - IPSecL2tpPluginUiWidgetPrivate *priv; + NMVpnEditor *object; + IPSecL2tpEditorPrivate *priv; char *ui_file; gboolean new = TRUE; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; if (error) g_return_val_if_fail (*error == NULL, NULL); - object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, NULL)); + object = g_object_new (IPSEC_L2TP_TYPE_EDITOR, NULL); if (!object) { - g_set_error (error, IPSEC_L2TP_PLUGIN_UI_ERROR, 0, _("could not create ipsec-l2tp object")); + g_set_error (error, IPSEC_L2TP_EDITOR_PLUGIN_ERROR, 0, _("could not create ipsec-l2tp object")); return NULL; } - priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (object); + priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (object); ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-ipsec-l2tp-dialog.ui"); priv->builder = gtk_builder_new (); @@ -661,7 +650,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) g_warning (_("Couldn't load builder file: %s"), error && *error ? (*error)->message : "(unknown)"); g_clear_error(error); - g_set_error(error, IPSEC_L2TP_PLUGIN_UI_ERROR, 0, + g_set_error(error, IPSEC_L2TP_EDITOR_PLUGIN_ERROR, 0, _("could not load required resources at %s"), ui_file); g_free(ui_file); @@ -672,7 +661,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipsec-l2tp-vbox")); if (!priv->widget) { - g_set_error (error, IPSEC_L2TP_PLUGIN_UI_ERROR, 0, _("could not load UI widget")); + g_set_error (error, IPSEC_L2TP_EDITOR_PLUGIN_ERROR, 0, _("could not load UI widget")); g_object_unref (object); return NULL; } @@ -685,7 +674,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) nm_setting_vpn_foreach_data_item (s_vpn, is_new_func, &new); priv->new_connection = new; - if (!init_plugin_ui (IPSEC_L2TP_PLUGIN_UI_WIDGET (object), connection, error)) { + if (!init_editor_plugin (IPSEC_L2TP_EDITOR (object), connection, error)) { g_object_unref (object); return NULL; } @@ -707,8 +696,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) static void dispose (GObject *object) { - IPSecL2tpPluginUiWidget *plugin = IPSEC_L2TP_PLUGIN_UI_WIDGET (object); - IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin); + IPSecL2tpEditor *plugin = IPSEC_L2TP_EDITOR (object); + IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (plugin); if (priv->group) g_object_unref (priv->group); @@ -728,26 +717,26 @@ dispose (GObject *object) if (priv->ipsec) g_hash_table_destroy (priv->ipsec); - G_OBJECT_CLASS (ipsec_l2tp_plugin_ui_widget_parent_class)->dispose (object); + G_OBJECT_CLASS (ipsec_l2tp_editor_parent_class)->dispose (object); } static void -ipsec_l2tp_plugin_ui_widget_class_init (IPSecL2tpPluginUiWidgetClass *req_class) +ipsec_l2tp_editor_class_init (IPSecL2tpEditorClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (IPSecL2tpPluginUiWidgetPrivate)); + g_type_class_add_private (req_class, sizeof (IPSecL2tpEditorPrivate)); object_class->dispose = dispose; } static void -ipsec_l2tp_plugin_ui_widget_init (IPSecL2tpPluginUiWidget *plugin) +ipsec_l2tp_editor_init (IPSecL2tpEditor *plugin) { } static void -ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class) +ipsec_l2tp_editor_interface_init (NMVpnEditorInterface *iface_class) { /* interface implementation */ iface_class->get_widget = get_widget; @@ -755,7 +744,7 @@ ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_ } static NMConnection * -import (NMVpnPluginUiInterface *iface, const char *path, GError **error) +import (NMVpnEditorPlugin *iface, const char *path, GError **error) { NMConnection *connection = NULL; char *ext; @@ -763,24 +752,24 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) ext = strrchr (path, '.'); if (!ext) { g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP, _("unknown IPSec-L2TP file extension")); return NULL; } if (strcmp (ext, ".conf") && strcmp (ext, ".cnf")) { g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP, _("unknown IPSec-L2TP file extension. Allowed .conf or .cnf")); return NULL; } if (!strstr (path, "ipsec-l2tp")) { g_set_error (error, - IPSEC_L2TP_PLUGIN_UI_ERROR, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR, + IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP, _("Filename doesn't contains 'ipsec-l2tp' substring.")); return NULL; } @@ -794,7 +783,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) } static gboolean -export (NMVpnPluginUiInterface *iface, +export (NMVpnEditorPlugin *iface, const char *path, NMConnection *connection, GError **error) @@ -802,8 +791,9 @@ export (NMVpnPluginUiInterface *iface, return do_export (path, connection, error); } +/* static char * -get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection) +get_suggested_name (NMVpnEditorPlugin *iface, NMConnection *connection) { NMSettingConnection *s_con; const char *id; @@ -818,17 +808,18 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection) return g_strdup_printf ("%s (ipsec-l2tp).conf", id); } +*/ static guint32 -get_capabilities (NMVpnPluginUiInterface *iface) +get_capabilities (NMVpnEditorPlugin *iface) { - return (NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT | NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT); + return (NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT | NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT); } -static NMVpnPluginUiWidgetInterface * -ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error) +static NMVpnEditor * +get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error) { - return nm_vpn_plugin_ui_widget_interface_new (connection, error); + return nm_vpn_editor_interface_new (connection, error); } static void @@ -836,14 +827,14 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: + case PROP_NAME: g_value_set_string (value, IPSEC_L2TP_PLUGIN_NAME); break; - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: + case PROP_DESC: g_value_set_string (value, IPSEC_L2TP_PLUGIN_DESC); break; - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: - g_value_set_string (value, IPSEC_L2TP_PLUGIN_SERVICE); + case PROP_SERVICE: + g_value_set_string (value, NM_DBUS_SERVICE_IPSEC_L2TP); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -852,44 +843,43 @@ get_property (GObject *object, guint prop_id, } static void -ipsec_l2tp_plugin_ui_class_init (IPSecL2tpPluginUiClass *req_class) +ipsec_l2tp_editor_plugin_class_init (IPSecL2tpEditorPluginClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); object_class->get_property = get_property; g_object_class_override_property (object_class, - NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME, - NM_VPN_PLUGIN_UI_INTERFACE_NAME); + PROP_NAME, + NM_VPN_EDITOR_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC, - NM_VPN_PLUGIN_UI_INTERFACE_DESC); + PROP_DESC, + NM_VPN_EDITOR_PLUGIN_DESCRIPTION); g_object_class_override_property (object_class, - NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE, - NM_VPN_PLUGIN_UI_INTERFACE_SERVICE); + PROP_SERVICE, + NM_VPN_EDITOR_PLUGIN_SERVICE); } static void -ipsec_l2tp_plugin_ui_init (IPSecL2tpPluginUi *plugin) +ipsec_l2tp_editor_plugin_init (IPSecL2tpEditorPlugin *plugin) { } static void -ipsec_l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) +ipsec_l2tp_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class) { /* interface implementation */ - iface_class->ui_factory = ui_factory; + iface_class->get_editor = get_editor; iface_class->get_capabilities = get_capabilities; iface_class->import_from_file = import; iface_class->export_to_file = export; - iface_class->get_suggested_name = get_suggested_name; } -G_MODULE_EXPORT NMVpnPluginUiInterface * -nm_vpn_plugin_ui_factory (GError **error) +G_MODULE_EXPORT NMVpnEditorPlugin * +nm_vpn_editor_plugin_factory (GError **error) { if (error) g_return_val_if_fail (*error == NULL, NULL); @@ -897,6 +887,6 @@ nm_vpn_plugin_ui_factory (GError **error) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (IPSEC_L2TP_TYPE_PLUGIN_UI, NULL)); + return g_object_new (IPSEC_L2TP_TYPE_EDITOR_PLUGIN, NULL); } diff --git a/properties/nm-ipsec-l2tp.h b/properties/nm-ipsec-l2tp.h index 7bb6ab9..7fc4531 100644 --- a/properties/nm-ipsec-l2tp.h +++ b/properties/nm-ipsec-l2tp.h @@ -25,62 +25,45 @@ #include <glib-object.h> -typedef enum -{ - IPSEC_L2TP_PLUGIN_UI_ERROR_UNKNOWN = 0, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, - IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, - IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE, - IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP -} IPSecL2tpPluginUiError; +#define IPSEC_L2TP_TYPE_EDITOR_PLUGIN (ipsec_l2tp_editor_plugin_get_type ()) +#define IPSEC_L2TP_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPlugin)) +#define IPSEC_L2TP_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass)) +#define IPSEC_L2TP_IS_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN)) +#define IPSEC_L2TP_IS_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN)) +#define IPSEC_L2TP_EDITOR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass)) -#define IPSEC_L2TP_TYPE_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_get_type ()) -GType ipsec_l2tp_plugin_ui_error_get_type (void); +typedef struct _IPSecL2tpEditorPlugin IPSecL2tpEditorPlugin; +typedef struct _IPSecL2tpEditorPluginClass IPSecL2tpEditorPluginClass; -#define IPSEC_L2TP_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_quark ()) -GQuark ipsec_l2tp_plugin_ui_error_quark (void); - - -#define IPSEC_L2TP_TYPE_PLUGIN_UI (ipsec_l2tp_plugin_ui_get_type ()) -#define IPSEC_L2TP_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUi)) -#define IPSEC_L2TP_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUiClass)) -#define IPSEC_L2TP_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI)) -#define IPSEC_L2TP_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI)) -#define IPSEC_L2TP_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUiClass)) - -typedef struct _IPSecL2tpPluginUi IPSecL2tpPluginUi; -typedef struct _IPSecL2tpPluginUiClass IPSecL2tpPluginUiClass; - -struct _IPSecL2tpPluginUi { +struct _IPSecL2tpEditorPlugin { GObject parent; }; -struct _IPSecL2tpPluginUiClass { +struct _IPSecL2tpEditorPluginClass { GObjectClass parent; }; -GType ipsec_l2tp_plugin_ui_get_type (void); +GType ipsec_l2tp_editor_plugin_get_type (void); -#define IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET (ipsec_l2tp_plugin_ui_widget_get_type ()) -#define IPSEC_L2TP_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidget)) -#define IPSEC_L2TP_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetClass)) -#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET)) -#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET)) -#define IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetClass)) +#define IPSEC_L2TP_TYPE_EDITOR (ipsec_l2tp_editor_get_type ()) +#define IPSEC_L2TP_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditor)) +#define IPSEC_L2TP_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass)) +#define IPSEC_L2TP_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR)) +#define IPSEC_L2TP_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR)) +#define IPSEC_L2TP_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass)) -typedef struct _IPSecL2tpPluginUiWidget IPSecL2tpPluginUiWidget; -typedef struct _IPSecL2tpPluginUiWidgetClass IPSecL2tpPluginUiWidgetClass; +typedef struct _IPSecL2tpEditor IPSecL2tpEditor; +typedef struct _IPSecL2tpEditorClass IPSecL2tpEditorClass; -struct _IPSecL2tpPluginUiWidget { +struct _IPSecL2tpEditor { GObject parent; }; -struct _IPSecL2tpPluginUiWidgetClass { +struct _IPSecL2tpEditorClass { GObjectClass parent; }; -GType ipsec_l2tp_plugin_ui_widget_get_type (void); +GType ipsec_l2tp_editor_get_type (void); #endif /* _NM_IPSEC_L2TP_H_ */ diff --git a/shared/Makefile.am b/shared/Makefile.am new file mode 100644 index 0000000..a72f8ce --- /dev/null +++ b/shared/Makefile.am @@ -0,0 +1,9 @@ +EXTRA_DIST = \ + README \ + nm-utils/gsystem-local-alloc.h \ + nm-utils/nm-glib.h \ + nm-utils/nm-macros-internal.h \ + nm-utils/nm-vpn-plugin-utils.c \ + nm-utils/nm-vpn-plugin-utils.h \ + nm-service-defines.h \ + nm-default.h diff --git a/shared/README b/shared/README new file mode 100644 index 0000000..3fe41ef --- /dev/null +++ b/shared/README @@ -0,0 +1,9 @@ +The files in the "shared/" directory are used by all components +inside the VPN plugin repository (src, properties, auth-dialog). + +The files in shared/nm-utils are copied from NetworkManager +repository and used as is: +Do *not* modify these files locally so that they don't diverge +from their original. Fix/extend them in their respective origin +first, and re-import the files as a whole. + diff --git a/shared/nm-default.h b/shared/nm-default.h new file mode 100644 index 0000000..ae548fb --- /dev/null +++ b/shared/nm-default.h @@ -0,0 +1,112 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2015 Red Hat, Inc. + */ + +#ifndef __NM_DEFAULT_H__ +#define __NM_DEFAULT_H__ + +/* makefiles define NETWORKMANAGER_COMPILATION for compiling NetworkManager. + * Depending on which parts are compiled, different values are set. */ +#define NM_NETWORKMANAGER_COMPILATION_DEFAULT 0x0001 +#define NM_NETWORKMANAGER_COMPILATION_LIB_BASE 0x0002 +#define NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR 0x0004 +#define NM_NETWORKMANAGER_COMPILATION_LIB (0x0002 | 0x0004) + +#ifndef NETWORKMANAGER_COMPILATION +/* For convenience, we don't require our Makefile.am to define + * -DNETWORKMANAGER_COMPILATION. As we now include this internal header, + * we know we do a NETWORKMANAGER_COMPILATION. */ +#define NETWORKMANAGER_COMPILATION NM_NETWORKMANAGER_COMPILATION_DEFAULT +#endif + +/*****************************************************************************/ + +#ifndef ___CONFIG_H__ +#define ___CONFIG_H__ +#include <config.h> +#endif + +/* always include these headers for our internal source files. */ + +#include "nm-utils/nm-glib.h" +#include "nm-utils/gsystem-local-alloc.h" +#include "nm-utils/nm-macros-internal.h" + +#include "nm-version.h" +#include "nm-service-defines.h" + +/*****************************************************************************/ + +#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB) + +#include <glib/gi18n-lib.h> + +#else + +#include <glib/gi18n.h> + +#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */ + +/*****************************************************************************/ + +#ifdef NM_VPN_OLD + +#define NM_VPN_LIBNM_COMPAT +#include <nm-connection.h> +#include <nm-setting-connection.h> +#include <nm-setting-8021x.h> +#include <nm-setting-ip4-config.h> +#include <nm-setting-vpn.h> +#include <nm-utils.h> +#include <nm-vpn-plugin-ui-interface.h> + +#define NMV_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR +#define NMV_EDITOR_PLUGIN_ERROR_FAILED NM_SETTING_VPN_ERROR_UNKNOWN +#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY +#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN NM_SETTING_VPN_ERROR_UNKNOWN +#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE NM_SETTING_VPN_ERROR_UNKNOWN + +#else /* !NM_VPN_OLD */ + +#include <NetworkManager.h> + +#define NMV_EDITOR_PLUGIN_ERROR NM_CONNECTION_ERROR +#define NMV_EDITOR_PLUGIN_ERROR_FAILED NM_CONNECTION_ERROR_FAILED +#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY +#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN NM_CONNECTION_ERROR_FAILED +#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE NM_CONNECTION_ERROR_FAILED + +#endif /* NM_VPN_OLD */ + +/*****************************************************************************/ + +#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR + +#ifdef NM_VPN_OLD +#include <nm-ui-utils.h> +#else /* NM_VPN_OLD */ +#include <nma-ui-utils.h> +#endif /* NM_VPN_OLD */ + +#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR */ + +/*****************************************************************************/ + +#endif /* __NM_DEFAULT_H__ */ diff --git a/shared/nm-service-defines.h b/shared/nm-service-defines.h new file mode 100644 index 0000000..8550d83 --- /dev/null +++ b/shared/nm-service-defines.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-pptp-service - PPTP VPN integration with NetworkManager + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2008, 2014 Red Hat, Inc. + */ + +#ifndef __NM_SERVICE_DEFINES_H__ +#define __NM_SERVICE_DEFINES_H__ + +#define NM_DBUS_SERVICE_PPTP "org.freedesktop.NetworkManager.pptp" + +/* For the NM <-> VPN plugin service */ +#define NM_DBUS_INTERFACE_PPTP "org.freedesktop.NetworkManager.pptp" +#define NM_DBUS_PATH_PPTP "/org/freedesktop/NetworkManager/pptp" + +/* For the VPN plugin service <-> PPP plugin */ +#define NM_DBUS_INTERFACE_PPTP_PPP "org.freedesktop.NetworkManager.pptp.ppp" +#define NM_DBUS_PATH_PPTP_PPP "/org/freedesktop/NetworkManager/pptp/ppp" + +#define NM_PPTP_KEY_GATEWAY "gateway" +#define NM_PPTP_KEY_USER "user" +#define NM_PPTP_KEY_PASSWORD "password" +#define NM_PPTP_KEY_DOMAIN "domain" +#define NM_PPTP_KEY_REFUSE_EAP "refuse-eap" +#define NM_PPTP_KEY_REFUSE_PAP "refuse-pap" +#define NM_PPTP_KEY_REFUSE_CHAP "refuse-chap" +#define NM_PPTP_KEY_REFUSE_MSCHAP "refuse-mschap" +#define NM_PPTP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2" +#define NM_PPTP_KEY_REQUIRE_MPPE "require-mppe" +#define NM_PPTP_KEY_REQUIRE_MPPE_40 "require-mppe-40" +#define NM_PPTP_KEY_REQUIRE_MPPE_128 "require-mppe-128" +#define NM_PPTP_KEY_MPPE_STATEFUL "mppe-stateful" +#define NM_PPTP_KEY_NOBSDCOMP "nobsdcomp" +#define NM_PPTP_KEY_NODEFLATE "nodeflate" +#define NM_PPTP_KEY_NO_VJ_COMP "no-vj-comp" +#define NM_PPTP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure" +#define NM_PPTP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval" +#define NM_PPTP_KEY_UNIT_NUM "unit" + +#endif /* __NM_SERVICE_DEFINES_H__ */ diff --git a/shared/nm-utils/gsystem-local-alloc.h b/shared/nm-utils/gsystem-local-alloc.h new file mode 100644 index 0000000..9fa53ad --- /dev/null +++ b/shared/nm-utils/gsystem-local-alloc.h @@ -0,0 +1,208 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2012 Colin Walters <walters@verbum.org>. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GSYSTEM_LOCAL_ALLOC_H__ +#define __GSYSTEM_LOCAL_ALLOC_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \ + static inline void name (void *v) \ + { \ + func (*(Type*)v); \ + } + +#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \ + static inline void name (void *v) \ + { \ + if (*(Type*)v) \ + func (*(Type*)v); \ + } + +/* These functions shouldn't be invoked directly; + * they are stubs that: + * 1) Take a pointer to the location (typically itself a pointer). + * 2) Provide %NULL-safety where it doesn't exist already (e.g. g_object_unref) + */ + +/** + * gs_free: + * + * Call g_free() on a variable location when it goes out of scope. + */ +#define gs_free __attribute__ ((cleanup(gs_local_free))) +GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free) + +/** + * gs_unref_object: + * + * Call g_object_unref() on a variable location when it goes out of + * scope. Note that unlike g_object_unref(), the variable may be + * %NULL. + */ +#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref) + +/** + * gs_unref_variant: + * + * Call g_variant_unref() on a variable location when it goes out of + * scope. Note that unlike g_variant_unref(), the variable may be + * %NULL. + */ +#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref) + +/** + * gs_free_variant_iter: + * + * Call g_variant_iter_free() on a variable location when it goes out of + * scope. + */ +#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free))) +GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free) + +/** + * gs_free_variant_builder: + * + * Call g_variant_builder_unref() on a variable location when it goes out of + * scope. + */ +#define gs_unref_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref) + +/** + * gs_unref_array: + * + * Call g_array_unref() on a variable location when it goes out of + * scope. Note that unlike g_array_unref(), the variable may be + * %NULL. + + */ +#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref) + +/** + * gs_unref_ptrarray: + * + * Call g_ptr_array_unref() on a variable location when it goes out of + * scope. Note that unlike g_ptr_array_unref(), the variable may be + * %NULL. + + */ +#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref) + +/** + * gs_unref_hashtable: + * + * Call g_hash_table_unref() on a variable location when it goes out + * of scope. Note that unlike g_hash_table_unref(), the variable may + * be %NULL. + */ +#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref) + +/** + * gs_free_list: + * + * Call g_list_free() on a variable location when it goes out + * of scope. + */ +#define gs_free_list __attribute__ ((cleanup(gs_local_free_list))) +GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free) + +/** + * gs_free_slist: + * + * Call g_slist_free() on a variable location when it goes out + * of scope. + */ +#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist))) +GS_DEFINE_CLEANUP_FUNCTION(GSList*, gs_local_free_slist, g_slist_free) + +/** + * gs_free_checksum: + * + * Call g_checksum_free() on a variable location when it goes out + * of scope. Note that unlike g_checksum_free(), the variable may + * be %NULL. + */ +#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free))) +GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free) + +/** + * gs_unref_bytes: + * + * Call g_bytes_unref() on a variable location when it goes out + * of scope. Note that unlike g_bytes_unref(), the variable may + * be %NULL. + */ +#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref) + +/** + * gs_strfreev: + * + * Call g_strfreev() on a variable location when it goes out of scope. + */ +#define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev))) +GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev) + +/** + * gs_free_error: + * + * Call g_error_free() on a variable location when it goes out of scope. + */ +#define gs_free_error __attribute__ ((cleanup(gs_local_free_error))) +GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free) + +/** + * gs_unref_keyfile: + * + * Call g_key_file_unref() on a variable location when it goes out of scope. + */ +#define gs_unref_keyfile __attribute__ ((cleanup(gs_local_keyfile_unref))) +GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref) + +static inline void +gs_cleanup_close_fdp (int *fdp) +{ + int fd; + + g_assert (fdp); + + fd = *fdp; + if (fd != -1) + (void) close (fd); +} + +/** + * gs_fd_close: + * + * Call close() on a variable location when it goes out of scope. + */ +#define gs_fd_close __attribute__((cleanup(gs_cleanup_close_fdp))) + +G_END_DECLS + +#endif diff --git a/shared/nm-utils/nm-glib.h b/shared/nm-utils/nm-glib.h new file mode 100644 index 0000000..46a8bb2 --- /dev/null +++ b/shared/nm-utils/nm-glib.h @@ -0,0 +1,397 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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 2008 - 2011 Red Hat, Inc. + */ + +#ifndef __NM_GLIB_H__ +#define __NM_GLIB_H__ + + +#include <gio/gio.h> +#include <string.h> + +#include "gsystem-local-alloc.h" + +#ifdef __clang__ + +#undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#undef G_GNUC_END_IGNORE_DEPRECATIONS + +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") + +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") + +#endif + +static inline void +__g_type_ensure (GType type) +{ +#if !GLIB_CHECK_VERSION(2,34,0) + if (G_UNLIKELY (type == (GType)-1)) + g_error ("can't happen"); +#else + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + g_type_ensure (type); + G_GNUC_END_IGNORE_DEPRECATIONS; +#endif +} +#define g_type_ensure __g_type_ensure + +#if !GLIB_CHECK_VERSION(2,34,0) + +#define g_clear_pointer(pp, destroy) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + /* Only one access, please */ \ + gpointer *_pp = (gpointer *) (pp); \ + gpointer _p; \ + /* This assignment is needed to avoid a gcc warning */ \ + GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ + \ + _p = *_pp; \ + if (_p) \ + { \ + *_pp = NULL; \ + _destroy (_p); \ + } \ + } G_STMT_END + +/* These are used to clean up the output of test programs; we can just let + * them no-op in older glib. + */ +#define g_test_expect_message(log_domain, log_level, pattern) +#define g_test_assert_expected_messages() + +#else + +/* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't + * accidentally use new API that we shouldn't. But we don't want warnings for + * the APIs that we emulate above. + */ + +#define g_test_expect_message(domain, level, format...) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_expect_message (domain, level, format); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END + +#define g_test_assert_expected_messages_internal(domain, file, line, func) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_assert_expected_messages_internal (domain, file, line, func); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END + +#endif + + +#if GLIB_CHECK_VERSION (2, 35, 0) +/* For glib >= 2.36, g_type_init() is deprecated. + * But since 2.35.1 (7c42ab23b55c43ab96d0ac2124b550bf1f49c1ec) this function + * does nothing. Replace the call with empty statement. */ +#define nm_g_type_init() G_STMT_START { (void) 0; } G_STMT_END +#else +#define nm_g_type_init() G_STMT_START { g_type_init (); } G_STMT_END +#endif + + +/* g_test_initialized() is only available since glib 2.36. */ +#if !GLIB_CHECK_VERSION (2, 36, 0) +#define g_test_initialized() (g_test_config_vars->test_initialized) +#endif + +/* g_assert_cmpmem() is only available since glib 2.46. */ +#if !GLIB_CHECK_VERSION (2, 45, 7) +#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\ + gconstpointer __m1 = m1, __m2 = m2; \ + int __l1 = l1, __l2 = l2; \ + if (__l1 != __l2) \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", __l2, 'i'); \ + else if (memcmp (__m1, __m2, __l1) != 0) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #m1 " == " #m2 ")"); \ + } G_STMT_END +#endif + +/* Rumtime check for glib version. First do a compile time check which + * (if satisfied) shortcuts the runtime check. */ +#define nm_glib_check_version(major, minor, micro) \ + ( GLIB_CHECK_VERSION ((major), (minor), (micro)) \ + || ( ( glib_major_version > (major)) \ + || ( glib_major_version == (major) \ + && glib_minor_version > (minor)) \ + || ( glib_major_version == (major) \ + && glib_minor_version == (minor) \ + && glib_micro_version >= (micro)))) + +/* g_test_skip() is only available since glib 2.38. Add a compatibility wrapper. */ +inline static void +__nmtst_g_test_skip (const gchar *msg) +{ +#if GLIB_CHECK_VERSION (2, 38, 0) + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_test_skip (msg); + G_GNUC_END_IGNORE_DEPRECATIONS +#else + g_debug ("%s", msg); +#endif +} +#define g_test_skip __nmtst_g_test_skip + + +/* g_test_add_data_func_full() is only available since glib 2.34. Add a compatibility wrapper. */ +inline static void +__g_test_add_data_func_full (const char *testpath, + gpointer test_data, + GTestDataFunc test_func, + GDestroyNotify data_free_func) +{ +#if GLIB_CHECK_VERSION (2, 34, 0) + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_test_add_data_func_full (testpath, test_data, test_func, data_free_func); + G_GNUC_END_IGNORE_DEPRECATIONS +#else + g_return_if_fail (testpath != NULL); + g_return_if_fail (testpath[0] == '/'); + g_return_if_fail (test_func != NULL); + + g_test_add_vtable (testpath, 0, test_data, NULL, + (GTestFixtureFunc) test_func, + (GTestFixtureFunc) data_free_func); +#endif +} +#define g_test_add_data_func_full __g_test_add_data_func_full + + +#if !GLIB_CHECK_VERSION (2, 34, 0) +#define G_DEFINE_QUARK(QN, q_n) \ +GQuark \ +q_n##_quark (void) \ +{ \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ +} +#endif + + +static inline gboolean +nm_g_hash_table_replace (GHashTable *hash, gpointer key, gpointer value) +{ + /* glib 2.40 added a return value indicating whether the key already existed + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ +#if GLIB_CHECK_VERSION(2, 40, 0) + return g_hash_table_replace (hash, key, value); +#else + gboolean contained = g_hash_table_contains (hash, key); + + g_hash_table_replace (hash, key, value); + return !contained; +#endif +} + +static inline gboolean +nm_g_hash_table_insert (GHashTable *hash, gpointer key, gpointer value) +{ + /* glib 2.40 added a return value indicating whether the key already existed + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ +#if GLIB_CHECK_VERSION(2, 40, 0) + return g_hash_table_insert (hash, key, value); +#else + gboolean contained = g_hash_table_contains (hash, key); + + g_hash_table_insert (hash, key, value); + return !contained; +#endif +} + +static inline gboolean +nm_g_hash_table_add (GHashTable *hash, gpointer key) +{ + /* glib 2.40 added a return value indicating whether the key already existed + * (910191597a6c2e5d5d460e9ce9efb4f47d9cc63c). */ +#if GLIB_CHECK_VERSION(2, 40, 0) + return g_hash_table_add (hash, key); +#else + gboolean contained = g_hash_table_contains (hash, key); + + g_hash_table_add (hash, key); + return !contained; +#endif +} + +#if !GLIB_CHECK_VERSION(2, 40, 0) || defined (NM_GLIB_COMPAT_H_TEST) +static inline void +_nm_g_ptr_array_insert (GPtrArray *array, + gint index_, + gpointer data) +{ + g_return_if_fail (array); + g_return_if_fail (index_ >= -1); + g_return_if_fail (index_ <= (gint) array->len); + + g_ptr_array_add (array, data); + + if (index_ != -1 && index_ != (gint) (array->len - 1)) { + memmove (&(array->pdata[index_ + 1]), + &(array->pdata[index_]), + (array->len - index_ - 1) * sizeof (gpointer)); + array->pdata[index_] = data; + } +} +#endif +#if !GLIB_CHECK_VERSION(2, 40, 0) +#define g_ptr_array_insert(array, index, data) G_STMT_START { _nm_g_ptr_array_insert (array, index, data); } G_STMT_END +#else +#define g_ptr_array_insert(array, index, data) \ + G_STMT_START { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_ptr_array_insert (array, index, data); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } G_STMT_END +#endif + + +#if !GLIB_CHECK_VERSION (2, 40, 0) +inline static gboolean +_g_key_file_save_to_file (GKeyFile *key_file, + const gchar *filename, + GError **error) +{ + gchar *contents; + gboolean success; + gsize length; + + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + contents = g_key_file_to_data (key_file, &length, NULL); + g_assert (contents != NULL); + + success = g_file_set_contents (filename, contents, length, error); + g_free (contents); + + return success; +} +#define g_key_file_save_to_file(key_file, filename, error) \ + _g_key_file_save_to_file (key_file, filename, error) +#else +#define g_key_file_save_to_file(key_file, filename, error) \ + ({ \ + gboolean _success; \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _success = g_key_file_save_to_file (key_file, filename, error); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + _success; \ + }) +#endif + + +#if GLIB_CHECK_VERSION (2, 36, 0) +#define g_credentials_get_unix_pid(creds, error) \ + G_GNUC_EXTENSION ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + (g_credentials_get_unix_pid) ((creds), (error)); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) +#else +#define g_credentials_get_unix_pid(creds, error) \ + G_GNUC_EXTENSION ({ \ + struct ucred *native_creds; \ + \ + native_creds = g_credentials_get_native ((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \ + g_assert (native_creds); \ + native_creds->pid; \ + }) +#endif + + +#if !GLIB_CHECK_VERSION(2, 40, 0) || defined (NM_GLIB_COMPAT_H_TEST) +static inline gpointer * +_nm_g_hash_table_get_keys_as_array (GHashTable *hash_table, + guint *length) +{ + GHashTableIter iter; + gpointer key, *ret; + guint i = 0; + + g_return_val_if_fail (hash_table, NULL); + + ret = g_new0 (gpointer, g_hash_table_size (hash_table) + 1); + g_hash_table_iter_init (&iter, hash_table); + + while (g_hash_table_iter_next (&iter, &key, NULL)) + ret[i++] = key; + + ret[i] = NULL; + + if (length) + *length = i; + + return ret; +} +#endif +#if !GLIB_CHECK_VERSION(2, 40, 0) +#define g_hash_table_get_keys_as_array(hash_table, length) \ + G_GNUC_EXTENSION ({ \ + _nm_g_hash_table_get_keys_as_array (hash_table, length); \ + }) +#else +#define g_hash_table_get_keys_as_array(hash_table, length) \ + G_GNUC_EXTENSION ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + (g_hash_table_get_keys_as_array) ((hash_table), (length)); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) +#endif + +#ifndef g_info +/* g_info was only added with 2.39.2 */ +#define g_info(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_INFO, \ + __VA_ARGS__) +#endif + +#if !GLIB_CHECK_VERSION(2, 44, 0) +static inline gpointer +g_steal_pointer (gpointer pp) +{ + gpointer *ptr = (gpointer *) pp; + gpointer ref; + + ref = *ptr; + *ptr = NULL; + + return ref; +} + +/* type safety */ +#define g_steal_pointer(pp) \ + (0 ? (*(pp)) : (g_steal_pointer) (pp)) +#endif + +#endif /* __NM_GLIB_H__ */ diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h new file mode 100644 index 0000000..603689a --- /dev/null +++ b/shared/nm-utils/nm-macros-internal.h @@ -0,0 +1,606 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NM_MACROS_INTERNAL_H__ +#define __NM_MACROS_INTERNAL_H__ + +#include <stdlib.h> + +#include "nm-glib.h" + +/********************************************************/ + +#define _nm_packed __attribute__ ((packed)) +#define _nm_unused __attribute__ ((unused)) +#define _nm_pure __attribute__ ((pure)) +#define _nm_const __attribute__ ((const)) +#define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b))) + +#define nm_auto(fcn) __attribute__ ((cleanup(fcn))) + +/** + * nm_auto_free: + * + * Call free() on a variable location when it goes out of scope. + */ +#define nm_auto_free nm_auto(_nm_auto_free_impl) +GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free) + +static inline void +_nm_auto_unset_gvalue_impl (GValue *v) +{ + g_value_unset (v); +} +#define nm_auto_unset_gvalue nm_auto(_nm_auto_unset_gvalue_impl) + +/********************************************************/ + +/* http://stackoverflow.com/a/11172679 */ +#define _NM_UTILS_MACRO_FIRST(...) __NM_UTILS_MACRO_FIRST_HELPER(__VA_ARGS__, throwaway) +#define __NM_UTILS_MACRO_FIRST_HELPER(first, ...) first + +#define _NM_UTILS_MACRO_REST(...) __NM_UTILS_MACRO_REST_HELPER(__NM_UTILS_MACRO_REST_NUM(__VA_ARGS__), __VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER(qty, ...) __NM_UTILS_MACRO_REST_HELPER2(qty, __VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER2(qty, ...) __NM_UTILS_MACRO_REST_HELPER_##qty(__VA_ARGS__) +#define __NM_UTILS_MACRO_REST_HELPER_ONE(first) +#define __NM_UTILS_MACRO_REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__ +#define __NM_UTILS_MACRO_REST_NUM(...) \ + __NM_UTILS_MACRO_REST_SELECT_20TH(__VA_ARGS__, \ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway) +#define __NM_UTILS_MACRO_REST_SELECT_20TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, ...) a20 + +/********************************************************/ + +/* http://stackoverflow.com/a/2124385/354393 */ + +#define NM_NARG(...) \ + _NM_NARG(__VA_ARGS__,_NM_NARG_RSEQ_N()) +#define _NM_NARG(...) \ + _NM_NARG_ARG_N(__VA_ARGS__) +#define _NM_NARG_ARG_N( \ + _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ + _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ + _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ + _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ + _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ + _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ + _61,_62,_63,N,...) N +#define _NM_NARG_RSEQ_N() \ + 63,62,61,60, \ + 59,58,57,56,55,54,53,52,51,50, \ + 49,48,47,46,45,44,43,42,41,40, \ + 39,38,37,36,35,34,33,32,31,30, \ + 29,28,27,26,25,24,23,22,21,20, \ + 19,18,17,16,15,14,13,12,11,10, \ + 9,8,7,6,5,4,3,2,1,0 + +/********************************************************/ + +#if defined (__GNUC__) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) +#elif defined (__clang__) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(clang diagnostic ignored warning) +#endif + +/* you can only suppress a specific warning that the compiler + * understands. Otherwise you will get another compiler warning + * about invalid pragma option. + * It's not that bad however, because gcc and clang often have the + * same name for the same warning. */ + +#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("GCC diagnostic push") \ + _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#elif defined (__clang__) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("clang diagnostic push") \ + _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#else +#define NM_PRAGMA_WARNING_DISABLE(warning) +#endif + +#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define NM_PRAGMA_WARNING_REENABLE \ + _Pragma("GCC diagnostic pop") +#elif defined (__clang__) +#define NM_PRAGMA_WARNING_REENABLE \ + _Pragma("clang diagnostic pop") +#else +#define NM_PRAGMA_WARNING_REENABLE +#endif + +/********************************************************/ + +/** + * NM_G_ERROR_MSG: + * @error: (allow none): the #GError instance + * + * All functions must follow the convention that when they + * return a failure, they must also set the GError to a valid + * message. For external API however, we want to be extra + * careful before accessing the error instance. Use NM_G_ERROR_MSG() + * which is safe to use on NULL. + * + * Returns: the error message. + **/ +static inline const char * +NM_G_ERROR_MSG (GError *error) +{ + return error ? (error->message ? : "(null)") : "(no-error)"; \ +} + +/********************************************************/ + +/* macro to return strlen() of a compile time string. */ +#define NM_STRLEN(str) ( sizeof ("" str) - 1 ) + +#define NM_SET_OUT(out_val, value) \ + G_STMT_START { \ + typeof(*(out_val)) *_out_val = (out_val); \ + \ + if (_out_val) { \ + *_out_val = (value); \ + } \ + } G_STMT_END + +/********************************************************/ + +#define _NM_IN_SET_EVAL_1(op, _x, y1) \ + (_x == (y1)) + +#define _NM_IN_SET_EVAL_2(op, _x, y1, y2) \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + ) + +#define _NM_IN_SET_EVAL_3(op, _x, y1, y2, y3) \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + ) + +#define _NM_IN_SET_EVAL_4(op, _x, y1, y2, y3, y4) \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + op (_x == (y4)) \ + ) + +#define _NM_IN_SET_EVAL_5(op, _x, y1, y2, y3, y4, y5) \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + op (_x == (y4)) \ + op (_x == (y5)) \ + ) + +#define _NM_IN_SET_EVAL_6(op, _x, y1, y2, y3, y4, y5, y6) \ + ( (_x == (y1)) \ + op (_x == (y2)) \ + op (_x == (y3)) \ + op (_x == (y4)) \ + op (_x == (y5)) \ + op (_x == (y6)) \ + ) + +#define _NM_IN_SET_EVAL_N2(op, _x, n, ...) _NM_IN_SET_EVAL_##n(op, _x, __VA_ARGS__) +#define _NM_IN_SET_EVAL_N(op, x, n, ...) \ + ({ \ + typeof(x) _x = (x); \ + !!_NM_IN_SET_EVAL_N2(op, _x, n, __VA_ARGS__); \ + }) + +/* Beware that this does short-circuit evaluation (use "||" instead of "|") + * which has a possibly unexpected non-function-like behavior. + * Use NM_IN_SET_SE if you need all arguments to be evaluted. */ +#define NM_IN_SET(x, ...) _NM_IN_SET_EVAL_N(||, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/* "SE" stands for "side-effect". Contrary to NM_IN_SET(), this does not do + * short-circuit evaluation, which can make a difference if the arguments have + * side-effects. */ +#define NM_IN_SET_SE(x, ...) _NM_IN_SET_EVAL_N(|, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/********************************************************/ + +static inline gboolean +_NM_IN_STRSET_streq (const char *x, const char *s) +{ + return s && strcmp (x, s) == 0; +} + +#define _NM_IN_STRSET_EVAL_1(op, _x, y1) \ + _NM_IN_STRSET_streq (_x, y1) + +#define _NM_IN_STRSET_EVAL_2(op, _x, y1, y2) \ + ( _NM_IN_STRSET_streq (_x, y1) \ + op _NM_IN_STRSET_streq (_x, y2) \ + ) + +#define _NM_IN_STRSET_EVAL_3(op, _x, y1, y2, y3) \ + ( _NM_IN_STRSET_streq (_x, y1) \ + op _NM_IN_STRSET_streq (_x, y2) \ + op _NM_IN_STRSET_streq (_x, y3) \ + ) + +#define _NM_IN_STRSET_EVAL_4(op, _x, y1, y2, y3, y4) \ + ( _NM_IN_STRSET_streq (_x, y1) \ + op _NM_IN_STRSET_streq (_x, y2) \ + op _NM_IN_STRSET_streq (_x, y3) \ + op _NM_IN_STRSET_streq (_x, y4) \ + ) + +#define _NM_IN_STRSET_EVAL_5(op, _x, y1, y2, y3, y4, y5) \ + ( _NM_IN_STRSET_streq (_x, y1) \ + op _NM_IN_STRSET_streq (_x, y2) \ + op _NM_IN_STRSET_streq (_x, y3) \ + op _NM_IN_STRSET_streq (_x, y4) \ + op _NM_IN_STRSET_streq (_x, y5) \ + ) + +#define _NM_IN_STRSET_EVAL_6(op, _x, y1, y2, y3, y4, y5, y6) \ + ( _NM_IN_STRSET_streq (_x, y1) \ + op _NM_IN_STRSET_streq (_x, y2) \ + op _NM_IN_STRSET_streq (_x, y3) \ + op _NM_IN_STRSET_streq (_x, y4) \ + op _NM_IN_STRSET_streq (_x, y5) \ + op _NM_IN_STRSET_streq (_x, y6) \ + ) + +#define _NM_IN_STRSET_EVAL_N2(op, _x, n, ...) _NM_IN_STRSET_EVAL_##n(op, _x, __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_N(op, x, n, ...) \ + ({ \ + const char *_x = (x); \ + ( ((_x == NULL) && _NM_IN_SET_EVAL_N2 (op, (const char *) NULL, n, __VA_ARGS__)) \ + || ((_x != NULL) && _NM_IN_STRSET_EVAL_N2 (op, _x, n, __VA_ARGS__)) \ + ); \ + }) + +/* Beware that this does short-circuit evaluation (use "||" instead of "|") + * which has a possibly unexpected non-function-like behavior. + * Use NM_IN_STRSET_SE if you need all arguments to be evaluted. */ +#define NM_IN_STRSET(x, ...) _NM_IN_STRSET_EVAL_N(||, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/* "SE" stands for "side-effect". Contrary to NM_IN_STRSET(), this does not do + * short-circuit evaluation, which can make a difference if the arguments have + * side-effects. */ +#define NM_IN_STRSET_SE(x, ...) _NM_IN_STRSET_EVAL_N(|, x, NM_NARG (__VA_ARGS__), __VA_ARGS__) + +/*****************************************************************************/ + +#define nm_streq(s1, s2) (strcmp (s1, s2) == 0) +#define nm_streq0(s1, s2) (g_strcmp0 (s1, s2) == 0) + +/*****************************************************************************/ + +#define NM_PRINT_FMT_QUOTED(cond, prefix, str, suffix, str_else) \ + (cond) ? (prefix) : "", \ + (cond) ? (str) : (str_else), \ + (cond) ? (suffix) : "" +#define NM_PRINT_FMT_QUOTE_STRING(arg) NM_PRINT_FMT_QUOTED((arg), "\"", (arg), "\"", "(null)") + +/*****************************************************************************/ + +/* glib/C provides the following kind of assertions: + * - assert() -- disable with NDEBUG + * - g_return_if_fail() -- disable with G_DISABLE_CHECKS + * - g_assert() -- disable with G_DISABLE_ASSERT + * but they are all enabled by default and usually even production builds have + * these kind of assertions enabled. It also means, that disabling assertions + * is an untested configuration, and might have bugs. + * + * Add our own assertion macro nm_assert(), which is disabled by default and must + * be explicitly enabled. They are useful for more expensive checks or checks that + * depend less on runtime conditions (that is, are generally expected to be true). */ + +#ifndef NM_MORE_ASSERTS +#define NM_MORE_ASSERTS 0 +#endif + +#if NM_MORE_ASSERTS +#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END +#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END +#else +#define nm_assert(cond) G_STMT_START { if (FALSE) { if (cond) { } } } G_STMT_END +#define nm_assert_not_reached() G_STMT_START { ; } G_STMT_END +#endif + +/*****************************************************************************/ + +#define NM_GOBJECT_PROPERTIES_DEFINE_BASE(...) \ +typedef enum { \ + _PROPERTY_ENUMS_0, \ + __VA_ARGS__ \ + _PROPERTY_ENUMS_LAST, \ +} _PropertyEnums; \ +static GParamSpec *obj_properties[_PROPERTY_ENUMS_LAST] = { NULL, } + +#define NM_GOBJECT_PROPERTIES_DEFINE(obj_type, ...) \ +NM_GOBJECT_PROPERTIES_DEFINE_BASE (__VA_ARGS__); \ +static inline void \ +_notify (obj_type *obj, _PropertyEnums prop) \ +{ \ + nm_assert (G_IS_OBJECT (obj)); \ + nm_assert ((gsize) prop < G_N_ELEMENTS (obj_properties)); \ + g_object_notify_by_pspec ((GObject *) obj, obj_properties[prop]); \ +} + +/*****************************************************************************/ + +static inline gpointer +nm_g_object_ref (gpointer obj) +{ + /* g_object_ref() doesn't accept NULL. */ + if (obj) + g_object_ref (obj); + return obj; +} + +static inline void +nm_g_object_unref (gpointer obj) +{ + /* g_object_unref() doesn't accept NULL. Usully, we workaround that + * by using g_clear_object(), but sometimes that is not convinient + * (for example as as destroy function for a hash table that can contain + * NULL values). */ + if (obj) + g_object_unref (obj); +} + +static inline gboolean +nm_clear_g_source (guint *id) +{ + if (id && *id) { + g_source_remove (*id); + *id = 0; + return TRUE; + } + return FALSE; +} + +static inline gboolean +nm_clear_g_signal_handler (gpointer self, gulong *id) +{ + if (id && *id) { + g_signal_handler_disconnect (self, *id); + *id = 0; + return TRUE; + } + return FALSE; +} + +static inline gboolean +nm_clear_g_variant (GVariant **variant) +{ + if (variant && *variant) { + g_variant_unref (*variant); + *variant = NULL; + return TRUE; + } + return FALSE; +} + +static inline gboolean +nm_clear_g_cancellable (GCancellable **cancellable) +{ + if (cancellable && *cancellable) { + g_cancellable_cancel (*cancellable); + g_object_unref (*cancellable); + *cancellable = NULL; + return TRUE; + } + return FALSE; +} + +/*****************************************************************************/ + +/* Determine whether @x is a power of two (@x being an integer type). + * For the special cases @x equals zero or one, it also returns true. + * For negative @x, always returns FALSE. That only applies, if the data + * type of @x is signed. */ +#define nm_utils_is_power_of_two(x) ({ \ + typeof(x) __x = (x); \ + \ + /* Check if the value is negative. In that case, return FALSE. + * The first expression is a compile time constant, depending on whether + * the type is signed. The second expression is a clumsy way for (__x >= 0), + * which causes a compiler warning for unsigned types. */ \ + ( ( ((typeof(__x)) -1) > ((typeof(__x)) 0) ) || (__x > 0) || (__x == 0) ) \ + && ((__x & (__x - 1)) == 0); \ + }) + +/*****************************************************************************/ + +/* check if @flags has exactly one flag (@check) set. You should call this + * only with @check being a compile time constant and a power of two. */ +#define NM_FLAGS_HAS(flags, check) \ + ( (G_STATIC_ASSERT_EXPR ( ((check) != 0) && ((check) & ((check)-1)) == 0 )), (NM_FLAGS_ANY ((flags), (check))) ) + +#define NM_FLAGS_ANY(flags, check) ( ( ((flags) & (check)) != 0 ) ? TRUE : FALSE ) +#define NM_FLAGS_ALL(flags, check) ( ( ((flags) & (check)) == (check) ) ? TRUE : FALSE ) + +#define NM_FLAGS_SET(flags, val) ({ \ + const typeof(flags) _flags = (flags); \ + const typeof(flags) _val = (val); \ + \ + _flags | _val; \ + }) + +#define NM_FLAGS_UNSET(flags, val) ({ \ + const typeof(flags) _flags = (flags); \ + const typeof(flags) _val = (val); \ + \ + _flags & (~_val); \ + }) + +#define NM_FLAGS_ASSIGN(flags, val, assign) ({ \ + const typeof(flags) _flags = (flags); \ + const typeof(flags) _val = (val); \ + \ + (assign) \ + ? _flags | (_val) \ + : _flags & (~_val); \ + }) + +/*****************************************************************************/ + +#define _NM_BACKPORT_SYMBOL_IMPL(VERSION, RETURN_TYPE, ORIG_FUNC, VERSIONED_FUNC, ARGS_TYPED, ARGS) \ +RETURN_TYPE VERSIONED_FUNC ARGS_TYPED; \ +RETURN_TYPE VERSIONED_FUNC ARGS_TYPED \ +{ \ + return ORIG_FUNC ARGS; \ +} \ +RETURN_TYPE ORIG_FUNC ARGS_TYPED; \ +__asm__(".symver "G_STRINGIFY(VERSIONED_FUNC)", "G_STRINGIFY(ORIG_FUNC)"@"G_STRINGIFY(VERSION)) + +#define NM_BACKPORT_SYMBOL(VERSION, RETURN_TYPE, FUNC, ARGS_TYPED, ARGS) \ +_NM_BACKPORT_SYMBOL_IMPL(VERSION, RETURN_TYPE, FUNC, _##FUNC##_##VERSION, ARGS_TYPED, ARGS) + +/*****************************************************************************/ + +static inline char * +nm_strstrip (char *str) +{ + /* g_strstrip doesn't like NULL. */ + return str ? g_strstrip (str) : NULL; +} + +/* g_ptr_array_sort()'s compare function takes pointers to the + * value. Thus, you cannot use strcmp directly. You can use + * nm_strcmp_p(). + * + * Like strcmp(), this function is not forgiving to accept %NULL. */ +static inline int +nm_strcmp_p (gconstpointer a, gconstpointer b) +{ + const char *s1 = *((const char **) a); + const char *s2 = *((const char **) b); + + return strcmp (s1, s2); +} + +/* like nm_strcmp_p(), suitable for g_ptr_array_sort_with_data(). + * g_ptr_array_sort() just casts nm_strcmp_p() to a function of different + * signature. I guess, in glib there are knowledgeable people that ensure + * that this additional argument doesn't cause problems due to different ABI + * for every architecture that glib supports. + * For NetworkManager, we'd rather avoid such stunts. + **/ +static inline int +nm_strcmp_p_with_data (gconstpointer a, gconstpointer b, gpointer user_data) +{ + const char *s1 = *((const char **) a); + const char *s2 = *((const char **) b); + + return strcmp (s1, s2); +} + +/*****************************************************************************/ + +static inline guint +nm_encode_version (guint major, guint minor, guint micro) { + /* analog to the preprocessor macro NM_ENCODE_VERSION(). */ + return (major << 16) | (minor << 8) | micro; +} + +static inline void +nm_decode_version (guint version, guint *major, guint *minor, guint *micro) { + *major = (version & 0xFFFF0000u) >> 16; + *minor = (version & 0x0000FF00u) >> 8; + *micro = (version & 0x000000FFu); +} +/*****************************************************************************/ + +#define nm_sprintf_buf(buf, format, ...) ({ \ + char * _buf = (buf); \ + \ + /* some static assert trying to ensure that the buffer is statically allocated. + * It disallows a buffer size of sizeof(gpointer) to catch that. */ \ + G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *)); \ + g_snprintf (_buf, sizeof (buf), \ + ""format"", ##__VA_ARGS__); \ + _buf; \ + }) + +#define nm_sprintf_bufa(n_elements, format, ...) \ + ({ \ + char *_buf; \ + \ + G_STATIC_ASSERT (sizeof (char[MAX ((n_elements), 1)]) == (n_elements)); \ + _buf = g_alloca (n_elements); \ + g_snprintf (_buf, n_elements, \ + ""format"", ##__VA_ARGS__); \ + _buf; \ + }) + +/*****************************************************************************/ + +/** + * The boolean type _Bool is C99 while we mostly stick to C89. However, _Bool is too + * convinient to miss and is effectively available in gcc and clang. So, just use it. + * + * Usually, one would include "stdbool.h" to get the "bool" define which aliases + * _Bool. We provide this define here, because we want to make use of it anywhere. + * (also, stdbool.h is again C99). + * + * Using _Bool has advantages over gboolean: + * + * - commonly _Bool is one byte large, instead of gboolean's 4 bytes (because gboolean + * is a typedef for gint). Especially when having boolean fields in a struct, we can + * thereby easily save some space. + * + * - _Bool type guarantees that two "true" expressions compare equal. E.g. the follwing + * will not work: + * gboolean v1 = 1; + * gboolean v2 = 2; + * g_assert_cmpint (v1, ==, v2); // will fail + * For that, we often to use !! to coerce gboolean values to 0 or 1: + * g_assert_cmpint (!!v2, ==, TRUE); + * With _Bool type, this will be handled properly by the compiler. + * + * - For structs, we might want to safe even more space and use bitfields: + * struct s1 { + * gboolean v1:1; + * }; + * But the problem here is that gboolean is signed, so that + * v1 will be either 0 or -1 (not 1, TRUE). Thus, the following + * fails: + * struct s1 s = { .v1 = TRUE, }; + * g_assert_cmpint (s1.v1, ==, TRUE); + * It will however work just fine with bool/_Bool while retaining the + * notion of having a boolean value. + * + * Also, add the defines for "true" and "false". Those are nicely highlighted by the editor + * as special types, contrary to glib's "TRUE"/"FALSE". + */ + +#ifndef bool +#define bool _Bool +#define true 1 +#define false 0 +#endif + +/*****************************************************************************/ + +#endif /* __NM_MACROS_INTERNAL_H__ */ diff --git a/shared/nm-utils/nm-vpn-plugin-utils.c b/shared/nm-utils/nm-vpn-plugin-utils.c new file mode 100644 index 0000000..772aa39 --- /dev/null +++ b/shared/nm-utils/nm-vpn-plugin-utils.c @@ -0,0 +1,130 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-vpn-plugin-utils.h" + +#include <dlfcn.h> + +/*****************************************************************************/ + +NMVpnEditor * +nm_vpn_plugin_utils_load_editor (const char *module_name, + const char *factory_name, + NMVpnPluginUtilsEditorFactory editor_factory, + NMVpnEditorPlugin *editor_plugin, + NMConnection *connection, + gpointer user_data, + GError **error) + +{ + static struct { + gpointer factory; + void *dl_module; + char *module_name; + char *factory_name; + } cached = { 0 }; + NMVpnEditor *editor; + + g_return_val_if_fail (module_name && g_path_is_absolute (module_name), NULL); + g_return_val_if_fail (factory_name && factory_name[0], NULL); + g_return_val_if_fail (editor_factory, NULL); + g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (editor_plugin), NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (!error || !*error, NULL); + + /* we really expect this function to be called with unchanging @module_name + * and @factory_name. And we only want to load the module once, hence it would + * be more complicated to accept changing @module_name/@factory_name arguments. + * + * The reason for only loading once is that due to glib types, we cannot create a + * certain type-name more then once, so loading the same module or another version + * of the same module will fail horribly as both try to create a GType with the same + * name. + * + * Only support loading once, any future calls will reuse the handle. To simplify + * that, we enforce that the @factory_name and @module_name is the same. */ + if (cached.factory) { + g_return_val_if_fail (cached.dl_module, NULL); + g_return_val_if_fail (cached.factory_name && nm_streq0 (cached.factory_name, factory_name), NULL); + g_return_val_if_fail (cached.module_name && nm_streq0 (cached.module_name, module_name), NULL); + } else { + gpointer factory; + void *dl_module; + + dl_module = dlopen (module_name, RTLD_LAZY | RTLD_LOCAL); + if (!dl_module) { + if (!g_file_test (module_name, G_FILE_TEST_EXISTS)) { + g_set_error (error, + G_FILE_ERROR, + G_FILE_ERROR_NOENT, + _("missing plugin file \"%s\""), module_name); + return NULL; + } + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("cannot load editor plugin: %s"), dlerror ()); + return NULL; + } + + factory = dlsym (dl_module, factory_name); + if (!factory) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("cannot load factory %s from plugin: %s"), + factory_name, dlerror ()); + dlclose (dl_module); + return NULL; + } + + /* we cannot ever unload the module because it creates glib types, which + * cannot be unregistered. + * + * Thus we just leak the dl_module handle indefinitely. */ + cached.factory = factory; + cached.dl_module = dl_module; + cached.module_name = g_strdup (module_name); + cached.factory_name = g_strdup (factory_name); + } + + editor = editor_factory (cached.factory, + editor_plugin, + connection, + user_data, + error); + if (!editor) { + if (error && !*error ) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("unknown error creating editor instance")); + g_return_val_if_reached (NULL); + } + return NULL; + } + + g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), NULL); + return editor; +} + diff --git a/shared/nm-utils/nm-vpn-plugin-utils.h b/shared/nm-utils/nm-vpn-plugin-utils.h new file mode 100644 index 0000000..f3928d1 --- /dev/null +++ b/shared/nm-utils/nm-vpn-plugin-utils.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#ifndef __NM_VPN_PLUGIN_UTILS_H__ +#define __NM_VPN_PLUGIN_UTILS_H__ + +#include <NetworkManager.h> + +typedef NMVpnEditor *(NMVpnPluginUtilsEditorFactory) (gpointer factory, + NMVpnEditorPlugin *editor_plugin, + NMConnection *connection, + gpointer user_data, + GError **error); + +NMVpnEditor *nm_vpn_plugin_utils_load_editor (const char *module_name, + const char *factory_name, + NMVpnPluginUtilsEditorFactory editor_factory, + NMVpnEditorPlugin *editor_plugin, + NMConnection *connection, + gpointer user_data, + GError **error); + +#endif /* __NM_VPN_PLUGIN_UTILS_H__ */ + diff --git a/src/Makefile.am b/src/Makefile.am index d8b97de..2d65e7e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,55 +1,68 @@ -INCLUDES = -I${top_srcdir} - -AM_CPPFLAGS = \ - $(DBUS_GLIB_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(NM_CFLAGS) \ - -DG_DISABLE_DEPRECATED \ - -DBINDIR=\"$(bindir)\" \ - -DPREFIX=\""$(prefix)"\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DNM_VERSION="\"$(VERSION)\"" \ - -DLIBDIR=\""$(libdir)"\" \ - -DLIBEXECDIR=\""$(libexecdir)"\" \ - -DLOCALSTATEDIR=\""$(localstatedir)"\" \ - -DDATADIR=\"$(datadir)\" \ - -DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \ - -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\" +AM_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(LIBNM_CFLAGS) \ + -DG_DISABLE_DEPRECATED \ + -DBINDIR=\"$(bindir)\" \ + -DPREFIX=\""$(prefix)"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DNM_VERSION="\"$(VERSION)\"" \ + -DLIBDIR=\""$(libdir)"\" \ + -DLIBEXECDIR=\""$(libexecdir)"\" \ + -DLOCALSTATEDIR=\""$(localstatedir)"\" \ + -DDATADIR=\"$(datadir)\" \ + -DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \ + -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\" libexec_PROGRAMS = nm-ipsec-l2tp-service nm_ipsec_l2tp_service_SOURCES = \ - nm-ipsec-l2tp-service.c \ - nm-ipsec-l2tp-service.h + nm-ipsec-l2tp-service.c \ + nm-ipsec-l2tp-service.h \ + nm-ipsec-l2tp-service-defines.h -nm-ipsec-l2tp-pppd-service-glue.h: $(top_srcdir)/src/nm-ipsec-l2tp-pppd-service.xml - dbus-binding-tool --prefix=nm_ipsec_l2tp_pppd_service --mode=glib-server --output=$@ $< +# D-Bus stuff +noinst_LTLIBRARIES = libnm-ipsec-l2tp-pppd-service-dbus.la -nm_ipsec_l2tp_service_LDADD = \ - $(DBUS_GLIB_LIBS) \ - $(GLIB_LIBS) \ - $(NM_LIBS) +nodist_libnm_ipsec_l2tp_pppd_service_dbus_la_SOURCES = \ + nm-ipsec-l2tp-pppd-service-dbus.c \ + nm-ipsec-l2tp-pppd-service-dbus.h + +libnm_ipsec_l2tp_pppd_service_dbus_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) + +nm-ipsec-l2tp-pppd-service-dbus.h: $(top_srcdir)/src/nm-ipsec-l2tp-pppd-service.xml + $(AM_V_GEN) gdbus-codegen \ + --generate-c-code $(basename $@) \ + --c-namespace NMDBus \ + --interface-prefix org.freedesktop \ + $< + +nm-ipsec-l2tp-pppd-service-dbus.c: + @true + +nm_ipsec_l2tp_service_LDADD = \ + $(GLIB_LIBS) \ + $(LIBNM_LIBS) \ + libnm-ipsec-l2tp-pppd-service-dbus.la pppd_plugindir = $(PPPD_PLUGIN_DIR) pppd_plugin_LTLIBRARIES = nm-ipsec-l2tp-pppd-plugin.la -nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \ - nm-ipsec-l2tp-pppd-plugin.c \ +nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \ + nm-ipsec-l2tp-pppd-plugin.c \ nm-ppp-status.h -nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \ - $(DBUS_GLIB_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(NM_CFLAGS) +nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \ + $(GLIB_CFLAGS) \ + $(LIBNM_CFLAGS) -nm_ipsec_l2tp_pppd_plugin_la_LDFLAGS = -module -avoid-version +nm_ipsec_l2tp_pppd_plugin_la_LDFLAGS = \ + -module -avoid-version -nm_ipsec_l2tp_pppd_plugin_la_LIBADD = \ - $(DBUS_GLIB_LIBS) \ - $(GLIB_LIBS) \ - $(NM_LIBS) +nm_ipsec_l2tp_pppd_plugin_la_LIBADD = \ + $(GLIB_LIBS) \ + $(LIBNM_LIBS) -BUILT_SOURCES = nm-ipsec-l2tp-pppd-service-glue.h +BUILT_SOURCES = nm-ipsec-l2tp-pppd-service-dbus.h nm-ipsec-l2tp-pppd-service-dbus.c CLEANFILES = $(BUILT_SOURCES) diff --git a/src/nm-ipsec-l2tp-pppd-plugin.c b/src/nm-ipsec-l2tp-pppd-plugin.c index a59877f..3806c02 100644 --- a/src/nm-ipsec-l2tp-pppd-plugin.c +++ b/src/nm-ipsec-l2tp-pppd-plugin.c @@ -28,20 +28,18 @@ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> -#include <glib.h> -#include <glib-object.h> -#include <dbus/dbus-glib.h> +#include <dlfcn.h> +//#include <glib.h> +#include <gio/gio.h> -#include "nm-ppp-status.h" - -#include <nm-utils.h> #include "nm-ipsec-l2tp-service.h" +#include "nm-ppp-status.h" int plugin_init (void); char pppd_version[] = VERSION; -static DBusGProxy *proxy = NULL; +static GDBusProxy *proxy = NULL; static void nm_phasechange (void *data, int arg) @@ -49,7 +47,7 @@ nm_phasechange (void *data, int arg) NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN; char *ppp_phase; - g_return_if_fail (DBUS_IS_G_PROXY (proxy)); + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); switch (arg) { case PHASE_DEAD: @@ -116,127 +114,104 @@ nm_phasechange (void *data, int arg) ppp_phase); if (ppp_status != NM_PPP_STATUS_UNKNOWN) { - dbus_g_proxy_call_no_reply (proxy, "SetState", - G_TYPE_UINT, ppp_status, - G_TYPE_INVALID, - G_TYPE_INVALID); + g_dbus_proxy_call (proxy, + "SetState", + g_variant_new ("(u)", ppp_status), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + NULL, NULL); } } -static GValue * -str_to_gvalue (const char *str) -{ - GValue *val; - - val = g_slice_new0 (GValue); - g_value_init (val, G_TYPE_STRING); - g_value_set_string (val, str); - - return val; -} - -static GValue * -uint_to_gvalue (guint32 i) -{ - GValue *val; - - val = g_slice_new0 (GValue); - g_value_init (val, G_TYPE_UINT); - g_value_set_uint (val, i); - - return val; -} - -static void -value_destroy (gpointer data) -{ - GValue *val = (GValue *) data; - - g_value_unset (val); - g_slice_free (GValue, val); -} - static void nm_ip_up (void *data, int arg) { guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit); ipcp_options opts = ipcp_gotoptions[0]; ipcp_options peer_opts = ipcp_hisoptions[0]; - GHashTable *hash; - GArray *array; - GValue *val; + GVariantBuilder builder; - g_return_if_fail (DBUS_IS_G_PROXY (proxy)); + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): ip-up event", __func__); if (!opts.ouraddr) { g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__); + nm_phasechange (NULL, PHASE_DEAD); return; } - hash = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, value_destroy); + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, - str_to_gvalue (ifname)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, + g_variant_new_string (ifname)); + + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, + g_variant_new_uint32 (opts.ouraddr)); /* Prefer the peer options remote address first, _unless_ pppd made the * address up, at which point prefer the local options remote address, * and if that's not right, use the made-up address as a last resort. */ if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) { - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, - uint_to_gvalue (peer_opts.hisaddr)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PTP, + g_variant_new_uint32 (peer_opts.hisaddr)); } else if (opts.hisaddr) { - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, - uint_to_gvalue (opts.hisaddr)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PTP, + g_variant_new_uint32 (opts.hisaddr)); } else if (peer_opts.hisaddr == pppd_made_up_address) { /* As a last resort, use the made-up address */ - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, - uint_to_gvalue (peer_opts.hisaddr)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PTP, + g_variant_new_uint32 (peer_opts.ouraddr)); } - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, - uint_to_gvalue (opts.ouraddr)); - - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, uint_to_gvalue (32)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, + g_variant_new_uint32 (32)); if (opts.dnsaddr[0] || opts.dnsaddr[1]) { - array = g_array_new (FALSE, FALSE, sizeof (guint32)); + guint32 dns[2]; + int len = 0; if (opts.dnsaddr[0]) - g_array_append_val (array, opts.dnsaddr[0]); + dns[len++] = opts.dnsaddr[0]; if (opts.dnsaddr[1]) - g_array_append_val (array, opts.dnsaddr[1]); - - val = g_slice_new0 (GValue); - g_value_init (val, DBUS_TYPE_G_UINT_ARRAY); - g_value_set_boxed (val, array); + dns[len++] = opts.dnsaddr[1]; - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_DNS, val); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_DNS, + g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, + dns, len, sizeof (guint32))); } /* Default MTU to 1400, which is also what Windows XP/Vista use */ - g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_MTU, uint_to_gvalue (1400)); + g_variant_builder_add (&builder, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_MTU, + g_variant_new_uint32 (1400)); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): sending Ip4Config to NetworkManager-ipsec-l2tp...", __func__); - dbus_g_proxy_call_no_reply (proxy, "SetIp4Config", - DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID, - G_TYPE_INVALID); - - g_hash_table_destroy (hash); + g_dbus_proxy_call (proxy, + "SetIp4Config", + g_variant_new ("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + NULL, NULL); } static int -get_chap_check(void) +get_chap_check (void) { return 1; } static int -get_pap_check(void) +get_pap_check (void) { return 1; } @@ -244,45 +219,47 @@ get_pap_check(void) static int get_credentials (char *username, char *password) { - char *my_username = NULL; - char *my_password = NULL; + const char *my_username = NULL; + const char *my_password = NULL; size_t len; + GVariant *ret; GError *err = NULL; - if (username && !password) { + if (!password) { /* pppd is checking pap support; return 1 for supported */ + g_return_val_if_fail (username, -1); return 1; } - g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1); + g_return_val_if_fail (username, -1); + g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), -1); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__); - dbus_g_proxy_call (proxy, "NeedSecrets", &err, - G_TYPE_INVALID, - G_TYPE_STRING, &my_username, - G_TYPE_STRING, &my_password, - G_TYPE_INVALID); - - if (err) { + ret = g_dbus_proxy_call_sync (proxy, + "NeedSecrets", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &err); + if (!ret) { g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): could not get secrets: (%d) %s", - __func__, - err ? err->code : -1, - err->message ? err->message : "(unknown)"); + __func__, + err ? err->code : -1, + err->message ? err->message : "(unknown)"); g_error_free (err); return -1; } g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): got credentials from NetworkManager-ipsec-l2tp", __func__); + g_variant_get (ret, "(&s&s)", &my_username, &my_password); + if (my_username) { len = strlen (my_username) + 1; len = len < MAXNAMELEN ? len : MAXNAMELEN; strncpy (username, my_username, len); username[len - 1] = '\0'; - - g_free (my_username); } if (my_password) { @@ -291,17 +268,17 @@ get_credentials (char *username, char *password) strncpy (password, my_password, len); password[len - 1] = '\0'; - - g_free (my_password); } + g_variant_unref (ret); + return 1; } static void nm_exit_notify (void *data, int arg) { - g_return_if_fail (DBUS_IS_G_PROXY (proxy)); + g_return_if_fail (G_IS_DBUS_PROXY (proxy)); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): cleaning up", __func__); @@ -312,7 +289,7 @@ nm_exit_notify (void *data, int arg) int plugin_init (void) { - DBusGConnection *bus; + GDBusConnection *bus; GError *err = NULL; #if !GLIB_CHECK_VERSION (2, 35, 0) @@ -321,22 +298,22 @@ plugin_init (void) g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): initializing", __func__); - bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err); + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err); if (!bus) { g_warning ("nm-ipsec-l2tp-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s", - __func__, - err ? err->code : -1, - err && err->message ? err->message : "(unknown)"); + __func__, + err ? err->code : -1, + err && err->message ? err->message : "(unknown)"); g_error_free (err); return -1; } - proxy = dbus_g_proxy_new_for_name (bus, - NM_DBUS_SERVICE_IPSEC_L2TP_PPP, - NM_DBUS_PATH_IPSEC_L2TP_PPP, - NM_DBUS_INTERFACE_IPSEC_L2TP_PPP); - - dbus_g_connection_unref (bus); + proxy = g_dbus_proxy_new_sync (bus, G_DBUS_CALL_FLAGS_NONE, NULL, + NM_DBUS_SERVICE_IPSEC_L2TP_PPP, + NM_DBUS_PATH_IPSEC_L2TP_PPP, + NM_DBUS_INTERFACE_IPSEC_L2TP_PPP, + NULL, &err); + g_object_unref (bus); chap_passwd_hook = get_credentials; chap_check_hook = get_chap_check; diff --git a/src/nm-ipsec-l2tp-pppd-service-dbus.c b/src/nm-ipsec-l2tp-pppd-service-dbus.c new file mode 100644 index 0000000..7542171 --- /dev/null +++ b/src/nm-ipsec-l2tp-pppd-service-dbus.c @@ -0,0 +1,1444 @@ +/* + * Generated by gdbus-codegen 2.48.1. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nm-ipsec-l2tp-pppd-service-dbus.h" + +#include <string.h> +#ifdef G_OS_UNIX +# include <gio/gunixfdlist.h> +#endif + +typedef struct +{ + GDBusArgInfo parent_struct; + gboolean use_gvariant; +} _ExtendedGDBusArgInfo; + +typedef struct +{ + GDBusMethodInfo parent_struct; + const gchar *signal_name; + gboolean pass_fdlist; +} _ExtendedGDBusMethodInfo; + +typedef struct +{ + GDBusSignalInfo parent_struct; + const gchar *signal_name; +} _ExtendedGDBusSignalInfo; + +typedef struct +{ + GDBusPropertyInfo parent_struct; + const gchar *hyphen_name; + gboolean use_gvariant; +} _ExtendedGDBusPropertyInfo; + +typedef struct +{ + GDBusInterfaceInfo parent_struct; + const gchar *hyphen_name; +} _ExtendedGDBusInterfaceInfo; + +typedef struct +{ + const _ExtendedGDBusPropertyInfo *info; + guint prop_id; + GValue orig_value; /* the value before the change */ +} ChangedProperty; + +static void +_changed_property_free (ChangedProperty *data) +{ + g_value_unset (&data->orig_value); + g_free (data); +} + +static gboolean +_g_strv_equal0 (gchar **a, gchar **b) +{ + gboolean ret = FALSE; + guint n; + if (a == NULL && b == NULL) + { + ret = TRUE; + goto out; + } + if (a == NULL || b == NULL) + goto out; + if (g_strv_length (a) != g_strv_length (b)) + goto out; + for (n = 0; a[n] != NULL; n++) + if (g_strcmp0 (a[n], b[n]) != 0) + goto out; + ret = TRUE; +out: + return ret; +} + +static gboolean +_g_variant_equal0 (GVariant *a, GVariant *b) +{ + gboolean ret = FALSE; + if (a == NULL && b == NULL) + { + ret = TRUE; + goto out; + } + if (a == NULL || b == NULL) + goto out; + ret = g_variant_equal (a, b); +out: + return ret; +} + +G_GNUC_UNUSED static gboolean +_g_value_equal (const GValue *a, const GValue *b) +{ + gboolean ret = FALSE; + g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b)); + switch (G_VALUE_TYPE (a)) + { + case G_TYPE_BOOLEAN: + ret = (g_value_get_boolean (a) == g_value_get_boolean (b)); + break; + case G_TYPE_UCHAR: + ret = (g_value_get_uchar (a) == g_value_get_uchar (b)); + break; + case G_TYPE_INT: + ret = (g_value_get_int (a) == g_value_get_int (b)); + break; + case G_TYPE_UINT: + ret = (g_value_get_uint (a) == g_value_get_uint (b)); + break; + case G_TYPE_INT64: + ret = (g_value_get_int64 (a) == g_value_get_int64 (b)); + break; + case G_TYPE_UINT64: + ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b)); + break; + case G_TYPE_DOUBLE: + { + /* Avoid -Wfloat-equal warnings by doing a direct bit compare */ + gdouble da = g_value_get_double (a); + gdouble db = g_value_get_double (b); + ret = memcmp (&da, &db, sizeof (gdouble)) == 0; + } + break; + case G_TYPE_STRING: + ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0); + break; + case G_TYPE_VARIANT: + ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b)); + break; + default: + if (G_VALUE_TYPE (a) == G_TYPE_STRV) + ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b)); + else + g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a))); + break; + } + return ret; +} + +/* ------------------------------------------------------------------------ + * Code for interface org.freedesktop.NetworkManager.ipsec_l2tp.ppp + * ------------------------------------------------------------------------ + */ + +/** + * SECTION:NMDBusNetworkManagerIpsec_l2tpPpp + * @title: NMDBusNetworkManagerIpsec_l2tpPpp + * @short_description: Generated C code for the org.freedesktop.NetworkManager.ipsec_l2tp.ppp D-Bus interface + * + * This section contains code for working with the <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link> D-Bus interface in C. + */ + +/* ---- Introspection data for org.freedesktop.NetworkManager.ipsec_l2tp.ppp ---- */ + +static const _ExtendedGDBusArgInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_username = +{ + { + -1, + (gchar *) "username", + (gchar *) "s", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_password = +{ + { + -1, + (gchar *) "password", + (gchar *) "s", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_username, + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_password, + NULL +}; + +static const GDBusAnnotationInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_need_secrets_annotation_info_0 = +{ + -1, + (gchar *) "org.freedesktop.DBus.GLib.CSymbol", + (gchar *) "impl_ipsec_l2tp_service_need_secrets", + NULL +}; + +static const GDBusAnnotationInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_need_secrets_annotation_info_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_need_secrets_annotation_info_0, + NULL +}; + +static const _ExtendedGDBusMethodInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets = +{ + { + -1, + (gchar *) "NeedSecrets", + NULL, + (GDBusArgInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets_OUT_ARG_pointers, + (GDBusAnnotationInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_need_secrets_annotation_info_pointers + }, + "handle-need-secrets", + FALSE +}; + +static const _ExtendedGDBusArgInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config_IN_ARG_config = +{ + { + -1, + (gchar *) "config", + (gchar *) "a{sv}", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config_IN_ARG_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config_IN_ARG_config, + NULL +}; + +static const GDBusAnnotationInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_set_ip4_config_annotation_info_0 = +{ + -1, + (gchar *) "org.freedesktop.DBus.GLib.CSymbol", + (gchar *) "impl_ipsec_l2tp_service_set_ip4_config", + NULL +}; + +static const GDBusAnnotationInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_set_ip4_config_annotation_info_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_set_ip4_config_annotation_info_0, + NULL +}; + +static const _ExtendedGDBusMethodInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config = +{ + { + -1, + (gchar *) "SetIp4Config", + (GDBusArgInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config_IN_ARG_pointers, + NULL, + (GDBusAnnotationInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_set_ip4_config_annotation_info_pointers + }, + "handle-set-ip4-config", + FALSE +}; + +static const _ExtendedGDBusArgInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state_IN_ARG_state = +{ + { + -1, + (gchar *) "state", + (gchar *) "u", + NULL + }, + FALSE +}; + +static const _ExtendedGDBusArgInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state_IN_ARG_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state_IN_ARG_state, + NULL +}; + +static const GDBusAnnotationInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_set_state_annotation_info_0 = +{ + -1, + (gchar *) "org.freedesktop.DBus.GLib.CSymbol", + (gchar *) "impl_ipsec_l2tp_service_set_state", + NULL +}; + +static const GDBusAnnotationInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_set_state_annotation_info_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_set_state_annotation_info_0, + NULL +}; + +static const _ExtendedGDBusMethodInfo _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state = +{ + { + -1, + (gchar *) "SetState", + (GDBusArgInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state_IN_ARG_pointers, + NULL, + (GDBusAnnotationInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_set_state_annotation_info_pointers + }, + "handle-set-state", + FALSE +}; + +static const _ExtendedGDBusMethodInfo * const _nmdbus_network_manager_ipsec_l2tp_ppp_method_info_pointers[] = +{ + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_need_secrets, + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_ip4_config, + &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_set_state, + NULL +}; + +static const _ExtendedGDBusInterfaceInfo _nmdbus_network_manager_ipsec_l2tp_ppp_interface_info = +{ + { + -1, + (gchar *) "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", + (GDBusMethodInfo **) &_nmdbus_network_manager_ipsec_l2tp_ppp_method_info_pointers, + NULL, + NULL, + NULL + }, + "network-manager-ipsec-l2tp-ppp", +}; + + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_interface_info: + * + * Gets a machine-readable description of the <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link> D-Bus interface. + * + * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. + */ +GDBusInterfaceInfo * +nmdbus_network_manager_ipsec_l2tp_ppp_interface_info (void) +{ + return (GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_override_properties: + * @klass: The class structure for a #GObject<!-- -->-derived class. + * @property_id_begin: The property id to assign to the first overridden property. + * + * Overrides all #GObject properties in the #NMDBusNetworkManagerIpsec_l2tpPpp interface for a concrete class. + * The properties are overridden in the order they are defined. + * + * Returns: The last property id. + */ +guint +nmdbus_network_manager_ipsec_l2tp_ppp_override_properties (GObjectClass *klass, guint property_id_begin) +{ + return property_id_begin - 1; +} + + + +/** + * NMDBusNetworkManagerIpsec_l2tpPpp: + * + * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link>. + */ + +/** + * NMDBusNetworkManagerIpsec_l2tpPppIface: + * @parent_iface: The parent interface. + * @handle_need_secrets: Handler for the #NMDBusNetworkManagerIpsec_l2tpPpp::handle-need-secrets signal. + * @handle_set_ip4_config: Handler for the #NMDBusNetworkManagerIpsec_l2tpPpp::handle-set-ip4-config signal. + * @handle_set_state: Handler for the #NMDBusNetworkManagerIpsec_l2tpPpp::handle-set-state signal. + * + * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link>. + */ + +typedef NMDBusNetworkManagerIpsec_l2tpPppIface NMDBusNetworkManagerIpsec_l2tpPppInterface; +G_DEFINE_INTERFACE (NMDBusNetworkManagerIpsec_l2tpPpp, nmdbus_network_manager_ipsec_l2tp_ppp, G_TYPE_OBJECT); + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_default_init (NMDBusNetworkManagerIpsec_l2tpPppIface *iface) +{ + /* GObject signals for incoming D-Bus method calls: */ + /** + * NMDBusNetworkManagerIpsec_l2tpPpp::handle-need-secrets: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: A #GDBusMethodInvocation. + * + * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.NeedSecrets">NeedSecrets()</link> D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call nmdbus_network_manager_ipsec_l2tp_ppp_complete_need_secrets() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-need-secrets", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NMDBusNetworkManagerIpsec_l2tpPppIface, handle_need_secrets), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 1, + G_TYPE_DBUS_METHOD_INVOCATION); + + /** + * NMDBusNetworkManagerIpsec_l2tpPpp::handle-set-ip4-config: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: A #GDBusMethodInvocation. + * @arg_config: Argument passed by remote caller. + * + * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetIp4Config">SetIp4Config()</link> D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_ip4_config() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-set-ip4-config", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NMDBusNetworkManagerIpsec_l2tpPppIface, handle_set_ip4_config), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 2, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT); + + /** + * NMDBusNetworkManagerIpsec_l2tpPpp::handle-set-state: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: A #GDBusMethodInvocation. + * @arg_state: Argument passed by remote caller. + * + * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetState">SetState()</link> D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-set-state", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NMDBusNetworkManagerIpsec_l2tpPppIface, handle_set_state), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 2, + G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_UINT); + +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.NeedSecrets">NeedSecrets()</link> D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_finish() to get the result of the operation. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_sync() for the synchronous, blocking version of this method. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "NeedSecrets", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_finish: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @out_username: (out): Return location for return parameter or %NULL to ignore. + * @out_password: (out): Return location for return parameter or %NULL to ignore. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + gchar **out_username, + gchar **out_password, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "(ss)", + out_username, + out_password); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_sync: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @out_username: (out): Return location for return parameter or %NULL to ignore. + * @out_password: (out): Return location for return parameter or %NULL to ignore. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.NeedSecrets">NeedSecrets()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + gchar **out_username, + gchar **out_password, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "NeedSecrets", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "(ss)", + out_username, + out_password); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @arg_config: Argument to pass with the method invocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetIp4Config">SetIp4Config()</link> D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_finish() to get the result of the operation. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_sync() for the synchronous, blocking version of this method. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GVariant *arg_config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "SetIp4Config", + g_variant_new ("(@a{sv})", + arg_config), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_finish: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_sync: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @arg_config: Argument to pass with the method invocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetIp4Config">SetIp4Config()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GVariant *arg_config, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "SetIp4Config", + g_variant_new ("(@a{sv})", + arg_config), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @arg_state: Argument to pass with the method invocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetState">SetState()</link> D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_finish() to get the result of the operation. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_sync() for the synchronous, blocking version of this method. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + guint arg_state, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "SetState", + g_variant_new ("(u)", + arg_state), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_finish: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_sync: + * @proxy: A #NMDBusNetworkManagerIpsec_l2tpPppProxy. + * @arg_state: Argument to pass with the method invocation. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetState">SetState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + guint arg_state, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "SetState", + g_variant_new ("(u)", + arg_state), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_complete_need_secrets: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * @username: Parameter to return. + * @password: Parameter to return. + * + * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.NeedSecrets">NeedSecrets()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_complete_need_secrets ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + const gchar *username, + const gchar *password) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("(ss)", + username, + password)); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_ip4_config: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * + * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetIp4Config">SetIp4Config()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_ip4_config ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("()")); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_state: + * @object: A #NMDBusNetworkManagerIpsec_l2tpPpp. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * + * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.SetState">SetState()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_state ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("()")); +} + +/* ------------------------------------------------------------------------ */ + +/** + * NMDBusNetworkManagerIpsec_l2tpPppProxy: + * + * The #NMDBusNetworkManagerIpsec_l2tpPppProxy structure contains only private data and should only be accessed using the provided API. + */ + +/** + * NMDBusNetworkManagerIpsec_l2tpPppProxyClass: + * @parent_class: The parent class. + * + * Class structure for #NMDBusNetworkManagerIpsec_l2tpPppProxy. + */ + +struct _NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate +{ + GData *qdata; +}; + +static void nmdbus_network_manager_ipsec_l2tp_ppp_proxy_iface_init (NMDBusNetworkManagerIpsec_l2tpPppIface *iface); + +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +G_DEFINE_TYPE_WITH_CODE (NMDBusNetworkManagerIpsec_l2tpPppProxy, nmdbus_network_manager_ipsec_l2tp_ppp_proxy, G_TYPE_DBUS_PROXY, + G_ADD_PRIVATE (NMDBusNetworkManagerIpsec_l2tpPppProxy) + G_IMPLEMENT_INTERFACE (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, nmdbus_network_manager_ipsec_l2tp_ppp_proxy_iface_init)); + +#else +G_DEFINE_TYPE_WITH_CODE (NMDBusNetworkManagerIpsec_l2tpPppProxy, nmdbus_network_manager_ipsec_l2tp_ppp_proxy, G_TYPE_DBUS_PROXY, + G_IMPLEMENT_INTERFACE (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, nmdbus_network_manager_ipsec_l2tp_ppp_proxy_iface_init)); + +#endif +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_finalize (GObject *object) +{ + NMDBusNetworkManagerIpsec_l2tpPppProxy *proxy = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY (object); + g_datalist_clear (&proxy->priv->qdata); + G_OBJECT_CLASS (nmdbus_network_manager_ipsec_l2tp_ppp_proxy_parent_class)->finalize (object); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec G_GNUC_UNUSED) +{ +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec G_GNUC_UNUSED) +{ +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_g_signal (GDBusProxy *proxy, + const gchar *sender_name G_GNUC_UNUSED, + const gchar *signal_name, + GVariant *parameters) +{ + _ExtendedGDBusSignalInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint n; + guint signal_id; + info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct, signal_name); + if (info == NULL) + return; + num_params = g_variant_n_children (parameters); + paramv = g_new0 (GValue, num_params + 1); + g_value_init (¶mv[0], NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP); + g_value_set_object (¶mv[0], proxy); + g_variant_iter_init (&iter, parameters); + n = 1; + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP); + g_signal_emitv (paramv, signal_id, 0, NULL); + for (n = 0; n < num_params + 1; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_g_properties_changed (GDBusProxy *_proxy, + GVariant *changed_properties, + const gchar *const *invalidated_properties) +{ + NMDBusNetworkManagerIpsec_l2tpPppProxy *proxy = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY (_proxy); + guint n; + const gchar *key; + GVariantIter *iter; + _ExtendedGDBusPropertyInfo *info; + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct, key); + g_datalist_remove_data (&proxy->priv->qdata, key); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } + g_variant_iter_free (iter); + for (n = 0; invalidated_properties[n] != NULL; n++) + { + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct, invalidated_properties[n]); + g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); + if (info != NULL) + g_object_notify (G_OBJECT (proxy), info->hyphen_name); + } +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_init (NMDBusNetworkManagerIpsec_l2tpPppProxy *proxy) +{ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + proxy->priv = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_instance_private (proxy); +#else + proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate); +#endif + + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), nmdbus_network_manager_ipsec_l2tp_ppp_interface_info ()); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_class_init (NMDBusNetworkManagerIpsec_l2tpPppProxyClass *klass) +{ + GObjectClass *gobject_class; + GDBusProxyClass *proxy_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_finalize; + gobject_class->get_property = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_property; + gobject_class->set_property = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_set_property; + + proxy_class = G_DBUS_PROXY_CLASS (klass); + proxy_class->g_signal = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_g_signal; + proxy_class->g_properties_changed = nmdbus_network_manager_ipsec_l2tp_ppp_proxy_g_properties_changed; + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate)); +#endif +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_iface_init (NMDBusNetworkManagerIpsec_l2tpPppIface *iface) +{ +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link>. See g_dbus_proxy_new() for more details. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_finish() to get the result of the operation. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync() for the synchronous, blocking version of this constructor. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", NULL); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new(). + * + * Returns: (transfer full) (type NMDBusNetworkManagerIpsec_l2tpPppProxy): The constructed proxy object or %NULL if @error is set. + */ +NMDBusNetworkManagerIpsec_l2tpPpp * +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP (ret); + else + return NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync: + * @connection: A #GDBusConnection. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link>. See g_dbus_proxy_new_sync() for more details. + * + * The calling thread is blocked until a reply is received. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type NMDBusNetworkManagerIpsec_l2tpPppProxy): The constructed proxy object or %NULL if @error is set. + */ +NMDBusNetworkManagerIpsec_l2tpPpp * +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", NULL); + if (ret != NULL) + return NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP (ret); + else + return NULL; +} + + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied. + * @user_data: User data to pass to @callback. + * + * Like nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new() but takes a #GBusType instead of a #GDBusConnection. + * + * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. + * You can then call nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_finish() to get the result of the operation. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor. + */ +void +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", NULL); +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_finish: + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus(). + * @error: Return location for error or %NULL + * + * Finishes an operation started with nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus(). + * + * Returns: (transfer full) (type NMDBusNetworkManagerIpsec_l2tpPppProxy): The constructed proxy object or %NULL if @error is set. + */ +NMDBusNetworkManagerIpsec_l2tpPpp * +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error) +{ + GObject *ret; + GObject *source_object; + source_object = g_async_result_get_source_object (res); + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); + g_object_unref (source_object); + if (ret != NULL) + return NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP (ret); + else + return NULL; +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_sync: + * @bus_type: A #GBusType. + * @flags: Flags from the #GDBusProxyFlags enumeration. + * @name: A bus name (well-known or unique). + * @object_path: An object path. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL + * + * Like nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. + * + * The calling thread is blocked until a reply is received. + * + * See nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus() for the asynchronous version of this constructor. + * + * Returns: (transfer full) (type NMDBusNetworkManagerIpsec_l2tpPppProxy): The constructed proxy object or %NULL if @error is set. + */ +NMDBusNetworkManagerIpsec_l2tpPpp * +nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + GInitable *ret; + ret = g_initable_new (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", NULL); + if (ret != NULL) + return NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP (ret); + else + return NULL; +} + + +/* ------------------------------------------------------------------------ */ + +/** + * NMDBusNetworkManagerIpsec_l2tpPppSkeleton: + * + * The #NMDBusNetworkManagerIpsec_l2tpPppSkeleton structure contains only private data and should only be accessed using the provided API. + */ + +/** + * NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass: + * @parent_class: The parent class. + * + * Class structure for #NMDBusNetworkManagerIpsec_l2tpPppSkeleton. + */ + +struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate +{ + GValue *properties; + GList *changed_properties; + GSource *changed_properties_idle_source; + GMainContext *context; + GMutex lock; +}; + +static void +_nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_method_call ( + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (user_data); + _ExtendedGDBusMethodInfo *info; + GVariantIter iter; + GVariant *child; + GValue *paramv; + guint num_params; + guint num_extra; + guint n; + guint signal_id; + GValue return_value = G_VALUE_INIT; + info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation); + g_assert (info != NULL); + num_params = g_variant_n_children (parameters); + num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra); + n = 0; + g_value_init (¶mv[n], NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP); + g_value_set_object (¶mv[n++], skeleton); + g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION); + g_value_set_object (¶mv[n++], invocation); + if (info->pass_fdlist) + { +#ifdef G_OS_UNIX + g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST); + g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation))); +#else + g_assert_not_reached (); +#endif + } + g_variant_iter_init (&iter, parameters); + while ((child = g_variant_iter_next_value (&iter)) != NULL) + { + _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra]; + if (arg_info->use_gvariant) + { + g_value_init (¶mv[n], G_TYPE_VARIANT); + g_value_set_variant (¶mv[n], child); + n++; + } + else + g_dbus_gvariant_to_gvalue (child, ¶mv[n++]); + g_variant_unref (child); + } + signal_id = g_signal_lookup (info->signal_name, NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP); + g_value_init (&return_value, G_TYPE_BOOLEAN); + g_signal_emitv (paramv, signal_id, 0, &return_value); + if (!g_value_get_boolean (&return_value)) + g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name); + g_value_unset (&return_value); + for (n = 0; n < num_params + num_extra; n++) + g_value_unset (¶mv[n]); + g_free (paramv); +} + +static GVariant * +_nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_get_property ( + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, + const gchar *property_name, + GError **error, + gpointer user_data) +{ + NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + GVariant *ret; + ret = NULL; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + g_value_init (&value, pspec->value_type); + g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value); + ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)); + g_value_unset (&value); + } + return ret; +} + +static gboolean +_nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_set_property ( + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, + const gchar *property_name, + GVariant *variant, + GError **error, + gpointer user_data) +{ + NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (user_data); + GValue value = G_VALUE_INIT; + GParamSpec *pspec; + _ExtendedGDBusPropertyInfo *info; + gboolean ret; + ret = FALSE; + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct, property_name); + g_assert (info != NULL); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); + if (pspec == NULL) + { + g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name); + } + else + { + if (info->use_gvariant) + g_value_set_variant (&value, variant); + else + g_dbus_gvariant_to_gvalue (variant, &value); + g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value); + g_value_unset (&value); + ret = TRUE; + } + return ret; +} + +static const GDBusInterfaceVTable _nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_vtable = +{ + _nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_method_call, + _nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_get_property, + _nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_set_property, + {NULL} +}; + +static GDBusInterfaceInfo * +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) +{ + return nmdbus_network_manager_ipsec_l2tp_ppp_interface_info (); +} + +static GDBusInterfaceVTable * +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) +{ + return (GDBusInterfaceVTable *) &_nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_vtable; +} + +static GVariant * +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton) +{ + NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (_skeleton); + + GVariantBuilder builder; + guint n; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + if (_nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct.properties == NULL) + goto out; + for (n = 0; _nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct.properties[n] != NULL; n++) + { + GDBusPropertyInfo *info = _nmdbus_network_manager_ipsec_l2tp_ppp_interface_info.parent_struct.properties[n]; + if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) + { + GVariant *value; + value = _nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.freedesktop.NetworkManager.ipsec_l2tp.ppp", info->name, NULL, skeleton); + if (value != NULL) + { + g_variant_take_ref (value); + g_variant_builder_add (&builder, "{sv}", info->name, value); + g_variant_unref (value); + } + } + } +out: + return g_variant_builder_end (&builder); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) +{ +} + +static void nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_iface_init (NMDBusNetworkManagerIpsec_l2tpPppIface *iface); +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +G_DEFINE_TYPE_WITH_CODE (NMDBusNetworkManagerIpsec_l2tpPppSkeleton, nmdbus_network_manager_ipsec_l2tp_ppp_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_ADD_PRIVATE (NMDBusNetworkManagerIpsec_l2tpPppSkeleton) + G_IMPLEMENT_INTERFACE (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_iface_init)); + +#else +G_DEFINE_TYPE_WITH_CODE (NMDBusNetworkManagerIpsec_l2tpPppSkeleton, nmdbus_network_manager_ipsec_l2tp_ppp_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_IMPLEMENT_INTERFACE (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_iface_init)); + +#endif +static void +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_finalize (GObject *object) +{ + NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton = NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (object); + g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free); + if (skeleton->priv->changed_properties_idle_source != NULL) + g_source_destroy (skeleton->priv->changed_properties_idle_source); + g_main_context_unref (skeleton->priv->context); + g_mutex_clear (&skeleton->priv->lock); + G_OBJECT_CLASS (nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_parent_class)->finalize (object); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_init (NMDBusNetworkManagerIpsec_l2tpPppSkeleton *skeleton) +{ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + skeleton->priv = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_get_instance_private (skeleton); +#else + skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate); +#endif + + g_mutex_init (&skeleton->priv->lock); + skeleton->priv->context = g_main_context_ref_thread_default (); +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_class_init (NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass *klass) +{ + GObjectClass *gobject_class; + GDBusInterfaceSkeletonClass *skeleton_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_finalize; + + skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass); + skeleton_class->get_info = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_info; + skeleton_class->get_properties = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_properties; + skeleton_class->flush = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_flush; + skeleton_class->get_vtable = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_dbus_interface_get_vtable; + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate)); +#endif +} + +static void +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_iface_init (NMDBusNetworkManagerIpsec_l2tpPppIface *iface) +{ +} + +/** + * nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_new: + * + * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-NetworkManager-ipsec_l2tp-ppp.top_of_page">org.freedesktop.NetworkManager.ipsec_l2tp.ppp</link>. + * + * Returns: (transfer full) (type NMDBusNetworkManagerIpsec_l2tpPppSkeleton): The skeleton object. + */ +NMDBusNetworkManagerIpsec_l2tpPpp * +nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_new (void) +{ + return NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP (g_object_new (NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NULL)); +} + diff --git a/src/nm-ipsec-l2tp-pppd-service-dbus.h b/src/nm-ipsec-l2tp-pppd-service-dbus.h new file mode 100644 index 0000000..f2bb941 --- /dev/null +++ b/src/nm-ipsec-l2tp-pppd-service-dbus.h @@ -0,0 +1,235 @@ +/* + * Generated by gdbus-codegen 2.48.1. DO NOT EDIT. + * + * The license of this code is the same as for the source it was derived from. + */ + +#ifndef __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__ +#define __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__ + +#include <gio/gio.h> + +G_BEGIN_DECLS + + +/* ------------------------------------------------------------------------ */ +/* Declarations for org.freedesktop.NetworkManager.ipsec_l2tp.ppp */ + +#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP (nmdbus_network_manager_ipsec_l2tp_ppp_get_type ()) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, NMDBusNetworkManagerIpsec_l2tpPpp)) +#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP)) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, NMDBusNetworkManagerIpsec_l2tpPppIface)) + +struct _NMDBusNetworkManagerIpsec_l2tpPpp; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPpp NMDBusNetworkManagerIpsec_l2tpPpp; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppIface NMDBusNetworkManagerIpsec_l2tpPppIface; + +struct _NMDBusNetworkManagerIpsec_l2tpPppIface +{ + GTypeInterface parent_iface; + + gboolean (*handle_need_secrets) ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation); + + gboolean (*handle_set_ip4_config) ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + GVariant *arg_config); + + gboolean (*handle_set_state) ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + guint arg_state); + +}; + +GType nmdbus_network_manager_ipsec_l2tp_ppp_get_type (void) G_GNUC_CONST; + +GDBusInterfaceInfo *nmdbus_network_manager_ipsec_l2tp_ppp_interface_info (void); +guint nmdbus_network_manager_ipsec_l2tp_ppp_override_properties (GObjectClass *klass, guint property_id_begin); + + +/* D-Bus method call completion functions: */ +void nmdbus_network_manager_ipsec_l2tp_ppp_complete_need_secrets ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + const gchar *username, + const gchar *password); + +void nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_ip4_config ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation); + +void nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_state ( + NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation); + + + +/* D-Bus method calls: */ +void nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + gchar **out_username, + gchar **out_password, + GAsyncResult *res, + GError **error); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + gchar **out_username, + gchar **out_password, + GCancellable *cancellable, + GError **error); + +void nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GVariant *arg_config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GAsyncResult *res, + GError **error); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GVariant *arg_config, + GCancellable *cancellable, + GError **error); + +void nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + guint arg_state, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_finish ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + GAsyncResult *res, + GError **error); + +gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_sync ( + NMDBusNetworkManagerIpsec_l2tpPpp *proxy, + guint arg_state, + GCancellable *cancellable, + GError **error); + + + +/* ---- */ + +#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY (nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_type ()) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxy)) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxyClass)) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxyClass)) +#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY)) +#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY)) + +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxy NMDBusNetworkManagerIpsec_l2tpPppProxy; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxyClass NMDBusNetworkManagerIpsec_l2tpPppProxyClass; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate; + +struct _NMDBusNetworkManagerIpsec_l2tpPppProxy +{ + /*< private >*/ + GDBusProxy parent_instance; + NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate *priv; +}; + +struct _NMDBusNetworkManagerIpsec_l2tpPppProxyClass +{ + GDBusProxyClass parent_class; +}; + +GType nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_type (void) G_GNUC_CONST; + +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMDBusNetworkManagerIpsec_l2tpPppProxy, g_object_unref) +#endif + +void nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_finish ( + GAsyncResult *res, + GError **error); +NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync ( + GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +void nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_finish ( + GAsyncResult *res, + GError **error); +NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_sync ( + GBusType bus_type, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +/* ---- */ + +#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_get_type ()) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeleton)) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass)) +#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass)) +#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON)) +#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON)) + +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeleton NMDBusNetworkManagerIpsec_l2tpPppSkeleton; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass; +typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate; + +struct _NMDBusNetworkManagerIpsec_l2tpPppSkeleton +{ + /*< private >*/ + GDBusInterfaceSkeleton parent_instance; + NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate *priv; +}; + +struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass +{ + GDBusInterfaceSkeletonClass parent_class; +}; + +GType nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_get_type (void) G_GNUC_CONST; + +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMDBusNetworkManagerIpsec_l2tpPppSkeleton, g_object_unref) +#endif + +NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_new (void); + + +G_END_DECLS + +#endif /* __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__ */ diff --git a/src/nm-ipsec-l2tp-service-defines.h b/src/nm-ipsec-l2tp-service-defines.h new file mode 100644 index 0000000..b325e3d --- /dev/null +++ b/src/nm-ipsec-l2tp-service-defines.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* nm-ipsec-l2tp-service - IPSec-L2TP VPN integration with NetworkManager + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2008, 2014 Red Hat, Inc. + */ + +#ifndef NM_IPSEC_L2TP_SERVICE_DEFINES_H +#define NM_IPSEC_L2TP_SERVICE_DEFINES_H + +#define NM_DBUS_SERVICE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp-ppp" +#define NM_DBUS_INTERFACE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp.ppp" +#define NM_DBUS_PATH_IPSEC_L2TP_PPP "/org/freedesktop/NetworkManager/ipsec_l2tp/ppp" + +/* For the NM <-> VPN plugin service */ +#define NM_DBUS_SERVICE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp" +#define NM_DBUS_INTERFACE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp" +#define NM_DBUS_PATH_IPSEC_L2TP "/org/freedesktop/NetworkManager/ipsec_l2tp" + + +#define NM_IPSEC_L2TP_KEY_GATEWAY "gateway" +#define NM_IPSEC_L2TP_KEY_USER "user" +#define NM_IPSEC_L2TP_KEY_PASSWORD "password" +#define NM_IPSEC_L2TP_KEY_DOMAIN "domain" +#define NM_IPSEC_L2TP_KEY_REFUSE_EAP "refuse-eap" +#define NM_IPSEC_L2TP_KEY_REFUSE_PAP "refuse-pap" +#define NM_IPSEC_L2TP_KEY_REFUSE_CHAP "refuse-chap" +#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAP "refuse-mschap" +#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2" +#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE "require-mppe" +#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_40 "require-mppe-40" +#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128 "require-mppe-128" +#define NM_IPSEC_L2TP_KEY_MPPE_STATEFUL "mppe-stateful" +#define NM_IPSEC_L2TP_KEY_NOBSDCOMP "nobsdcomp" +#define NM_IPSEC_L2TP_KEY_NODEFLATE "nodeflate" +#define NM_IPSEC_L2TP_KEY_NO_VJ_COMP "no-vj-comp" +#define NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure" +#define NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval" +#define NM_IPSEC_L2TP_KEY_UNIT_NUM "unit" + +#define NM_IPSEC_L2TP_KEY_IPSEC_ENABLE "ipsec-enabled" +#define NM_IPSEC_L2TP_KEY_IPSEC_GATEWAY_ID "ipsec-gateway-id" +#define NM_IPSEC_L2TP_KEY_IPSEC_GROUP_NAME "ipsec-group-name" +#define NM_IPSEC_L2TP_KEY_IPSEC_PSK "ipsec-psk" +#define NM_IPSEC_L2TP_KEY_IPSEC_RSA "ipsec-rsa" +#define NM_IPSEC_L2TP_KEY_IPSEC_RSA_PW "ipsec-rsa-pw" + +#endif /* NM_IPSEC_L2TP_SERVICE_DEFINES_H */ diff --git a/src/nm-ipsec-l2tp-service.c b/src/nm-ipsec-l2tp-service.c index 0b8b045..5c519f3 100644 --- a/src/nm-ipsec-l2tp-service.c +++ b/src/nm-ipsec-l2tp-service.c @@ -51,14 +51,14 @@ #include <netdb.h> #include <glib/gi18n.h> -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <nm-setting-vpn.h> +#include <NetworkManager.h> + #include <nm-utils.h> #include "nm-ipsec-l2tp-service.h" #include "nm-ppp-status.h" +#include "nm-ipsec-l2tp-pppd-service-dbus.h" #if !defined(DIST_VERSION) # define DIST_VERSION VERSION @@ -72,8 +72,9 @@ static gboolean debug = FALSE; /* ppp plugin <-> ipsec-l2tp-service object */ /********************************************************/ -/* Have to have a separate objec to handle ppp plugin requests since - * dbus-glib doesn't allow multiple interfaces registed on one GObject. +/* We have a separate object to handle ppp plugin requests from + * historical reason, because dbus-glib didn't allow multiple + * interfaces registed on one GObject. */ #define NM_TYPE_IPSEC_L2TP_PPP_SERVICE (nm_ipsec_l2tp_ppp_service_get_type ()) @@ -93,28 +94,31 @@ typedef struct { /* Signals */ void (*plugin_alive) (NMIPsecL2tpPppService *self); void (*ppp_state) (NMIPsecL2tpPppService *self, guint32 state); - void (*ip4_config) (NMIPsecL2tpPppService *self, GHashTable *config_hash); + void (*ip4_config) (NMIPsecL2tpPppService *self, GVariant *config); } NMIPsecL2tpPppServiceClass; GType nm_ipsec_l2tp_ppp_service_get_type (void); G_DEFINE_TYPE (NMIPsecL2tpPppService, nm_ipsec_l2tp_ppp_service, G_TYPE_OBJECT); -static gboolean impl_ipsec_l2tp_service_need_secrets (NMIPsecL2tpPppService *self, - char **out_username, - char **out_password, - GError **err); - -static gboolean impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self, - guint32 state, - GError **err); +static gboolean +handle_set_state (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + guint arg_state, + gpointer user_data); -static gboolean impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, - GHashTable *config, - GError **err); +static gboolean +handle_need_secrets (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + gpointer user_data); -#include "nm-ipsec-l2tp-pppd-service-glue.h" +static gboolean +handle_set_ip4_config (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + GVariant *arg_config, + gpointer user_data); +#include "nm-ipsec-l2tp-pppd-service-dbus.h" #define NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IPSEC_L2TP_PPP_SERVICE, NMIPsecL2tpPppServicePrivate)) @@ -122,6 +126,9 @@ typedef struct { char *username; char *domain; char *password; + + /* D-Bus stuff */ + NMDBusNetworkManagerIpsec_l2tpPpp *dbus_skeleton; } NMIPsecL2tpPppServicePrivate; enum { @@ -154,13 +161,13 @@ _service_cache_credentials (NMIPsecL2tpPppService *self, GError **error) { NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self); - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; const char *username, *password, *domain; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (connection != NULL, FALSE); - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); if (!s_vpn) { return nm_ipsec_l2tp_error(error, "Could not load NetworkManager connection settings."); } @@ -192,21 +199,67 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection, GError **error) { NMIPsecL2tpPppService *self = NULL; - DBusGConnection *bus; - DBusGProxy *proxy; - gboolean success = FALSE; - guint result; + NMIPsecL2tpPppServicePrivate *priv; + GDBusConnection *bus; + GDBusProxy *proxy; + GVariant *ret; - bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error); + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); if (!bus) return NULL; - dbus_connection_set_change_sigpipe (TRUE); - - proxy = dbus_g_proxy_new_for_name (bus, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus"); + proxy = g_dbus_proxy_new_sync (bus, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, + NULL, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + NULL, error); g_assert(proxy); + ret = g_dbus_proxy_call_sync (proxy, + "RequestName", + g_variant_new ("(su)", NM_DBUS_SERVICE_IPSEC_L2TP_PPP, 0), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, error); + g_object_unref (proxy); + if (!ret) { + if (error && *error) + g_dbus_error_strip_remote_error (*error); + goto out; + } + g_variant_unref (ret); + + self = (NMIPsecL2tpPppService *) g_object_new (NM_TYPE_IPSEC_L2TP_PPP_SERVICE, NULL); + g_assert(self); + priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self); + + /* Cache the username and password so we can relay the secrets to the pppd + * plugin when it asks for them. + */ + if (!_service_cache_credentials (self, connection, error)) { + g_object_unref (self); + self = NULL; + goto out; + } + + priv->dbus_skeleton = nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_new (); + if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->dbus_skeleton), + bus, + NM_DBUS_PATH_IPSEC_L2TP_PPP, + error)) + goto out; + + g_dbus_connection_register_object (bus, NM_DBUS_PATH_IPSEC_L2TP_PPP, + nmdbus_network_manager_ipsec_l2tp_ppp_interface_info (), + NULL, NULL, NULL, NULL); + + g_signal_connect (priv->dbus_skeleton, "handle-need-secrets", G_CALLBACK (handle_need_secrets), self); + g_signal_connect (priv->dbus_skeleton, "handle-set-state", G_CALLBACK (handle_set_state), self); + g_signal_connect (priv->dbus_skeleton, "handle-set-ip4-config", G_CALLBACK (handle_set_ip4_config), self); + +out: + g_clear_object (&bus); +/* if (dbus_g_proxy_call (proxy, "RequestName", error, G_TYPE_STRING, NM_DBUS_SERVICE_IPSEC_L2TP_PPP, G_TYPE_UINT, 0, @@ -222,6 +275,7 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection, } g_object_unref (proxy); dbus_g_connection_unref (bus); +*/ return self; } @@ -230,6 +284,18 @@ nm_ipsec_l2tp_ppp_service_init (NMIPsecL2tpPppService *self) { } +static void +nm_ipsec_l2tp_ppp_service_dispose (GObject *object) +{ + NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (object); + + g_signal_handlers_disconnect_by_func (priv->dbus_skeleton, handle_need_secrets, object); + g_signal_handlers_disconnect_by_func (priv->dbus_skeleton, handle_set_state, object); + g_signal_handlers_disconnect_by_func (priv->dbus_skeleton, handle_set_ip4_config, object); + + G_OBJECT_CLASS (nm_ipsec_l2tp_ppp_service_parent_class)->dispose (object); +} + static void finalize (GObject *object) { @@ -242,6 +308,8 @@ finalize (GObject *object) g_free (priv->password); } g_free (priv->domain); + + G_OBJECT_CLASS (nm_ipsec_l2tp_ppp_service_parent_class)->finalize (object); } static void @@ -252,6 +320,7 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class) g_type_class_add_private (service_class, sizeof (NMIPsecL2tpPppServicePrivate)); /* virtual methods */ + object_class->dispose = nm_ipsec_l2tp_ppp_service_dispose; object_class->finalize = finalize; /* Signals */ @@ -279,37 +348,47 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMIPsecL2tpPppServiceClass, ip4_config), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (service_class), - &dbus_glib_nm_ipsec_l2tp_pppd_service_object_info); + NULL, + G_TYPE_NONE, 1, G_TYPE_VARIANT); } static gboolean -impl_ipsec_l2tp_service_need_secrets (NMIPsecL2tpPppService *self, - char **out_username, - char **out_password, - GError **error) +handle_need_secrets (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + gpointer user_data) { + NMIPsecL2tpPppService *self = NM_IPSEC_L2TP_PPP_SERVICE (user_data); NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self); + char *username = NULL, *password = NULL; + GError *error = NULL; g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0); if (!*priv->username || !*priv->password) { - return nm_ipsec_l2tp_error(error, "No cached credentials."); + g_set_error (&error, + NM_VPN_PLUGIN_ERROR, + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, + "%s", + _("No cached credentials.")); + g_dbus_method_invocation_take_error (invocation, error); + return FALSE; } /* Success */ - if (priv->domain && *priv->domain) { - *out_username = g_strdup_printf ("%s\\%s", priv->domain, priv->username); - } else { - *out_username = g_strdup (priv->username); - } - *out_password = g_strdup (priv->password); + if (priv->domain && *priv->domain) + username = g_strdup_printf ("%s\\%s", priv->domain, priv->username); + else + username = g_strdup (priv->username); + password = g_strdup (priv->password); + + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("(ss)", username, password)); + g_free (username); + g_free (password); return TRUE; } +/* static gboolean impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self, guint32 pppd_state, @@ -319,17 +398,21 @@ impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self, g_signal_emit (G_OBJECT (self), signals[PPP_STATE], 0, pppd_state); return TRUE; } +*/ static gboolean -impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, - GHashTable *config_hash, - GError **err) +handle_set_ip4_config (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + GVariant *arg_config, + gpointer user_data) { + NMIPsecL2tpPppService *self = NM_IPSEC_L2TP_PPP_SERVICE (user_data); + g_message (_("IPSec-L2TP service (IP Config Get) reply received.")); g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0); /* Just forward the pppd plugin config up to our superclass; no need to modify it */ - g_signal_emit (G_OBJECT (self), signals[IP4_CONFIG], 0, config_hash); + g_signal_emit (G_OBJECT (self), signals[IP4_CONFIG], 0, arg_config); return TRUE; } @@ -339,7 +422,7 @@ impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, /* The VPN plugin service */ /********************************************************/ -G_DEFINE_TYPE (NMIPSecL2tpPlugin, nm_ipsec_l2tp_plugin, NM_TYPE_VPN_PLUGIN); +G_DEFINE_TYPE (NMIPSecL2tpPlugin, nm_ipsec_l2tp_plugin, NM_TYPE_VPN_SERVICE_PLUGIN); typedef struct { GPid pid_l2tpd; @@ -379,8 +462,6 @@ static ValidProperty valid_properties[] = { { NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NODEFLATE, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NO_VJ_COMP, G_TYPE_BOOLEAN, FALSE }, - { NM_IPSEC_L2TP_KEY_NO_PCOMP, G_TYPE_BOOLEAN, FALSE }, - { NM_IPSEC_L2TP_KEY_NO_ACCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE, G_TYPE_UINT, FALSE }, { NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, G_TYPE_UINT, FALSE }, { NM_IPSEC_L2TP_KEY_PASSWORD"-flags", G_TYPE_UINT, FALSE }, @@ -561,7 +642,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data) } static gboolean -nm_ipsec_l2tp_properties_validate (NMSettingVPN *s_vpn, +nm_ipsec_l2tp_properties_validate (NMSettingVpn *s_vpn, GError **error) { ValidateInfo info = { &valid_properties[0], error, FALSE }; @@ -596,7 +677,7 @@ nm_ipsec_l2tp_properties_validate (NMSettingVPN *s_vpn, } static gboolean -nm_ipsec_l2tp_secrets_validate (NMSettingVPN *s_vpn, GError **error) +nm_ipsec_l2tp_secrets_validate (NMSettingVpn *s_vpn, GError **error) { ValidateInfo info = { &valid_secrets[0], error, FALSE }; @@ -670,21 +751,19 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data) case 16: /* hangup */ // FIXME: better failure reason - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); break; case 2: /* Couldn't log in due to bad user/pass */ - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED); break; case 1: /* Other error (couldn't bind to address, etc) */ - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); break; default: break; } - - nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED); } static inline const char * @@ -737,14 +816,14 @@ pppd_timed_out (gpointer user_data) NMIPSecL2tpPlugin *plugin = NM_IPSEC_L2TP_PLUGIN (user_data); g_warning (_("pppd timeout. Looks like pppd didn't initialize our dbus module")); - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT); return FALSE; } static gboolean nm_ipsec_l2tp_resolve_gateway (NMIPSecL2tpPlugin *plugin, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, GError **error) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); @@ -885,7 +964,7 @@ nm_ipsec_l2tp_stop_ipsec(void) static gboolean nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, GError **error) { // NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); @@ -995,7 +1074,7 @@ nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin, static gboolean nm_ipsec_l2tp_start_l2tpd_binary (NMIPSecL2tpPlugin *plugin, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, GError **error) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); @@ -1071,8 +1150,6 @@ static PPPOpt ppp_options[] = { {NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, "nobsdcomp\n"}, {NM_IPSEC_L2TP_KEY_NODEFLATE, G_TYPE_BOOLEAN, "nodeflate\n"}, {NM_IPSEC_L2TP_KEY_NO_VJ_COMP, G_TYPE_BOOLEAN, "novj\n"}, - {NM_IPSEC_L2TP_KEY_NO_PCOMP, G_TYPE_BOOLEAN, "nopcomp\n"}, - {NM_IPSEC_L2TP_KEY_NO_ACCOMP, G_TYPE_BOOLEAN, "noaccomp\n"}, {NULL, G_TYPE_NONE, NULL} }; @@ -1123,7 +1200,7 @@ get_free_l2tp_port(void) static gboolean nm_ipsec_l2tp_config_write (NMIPSecL2tpPlugin *plugin, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, GError **error) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); @@ -1316,6 +1393,20 @@ remove_timeout_handler (NMIPSecL2tpPlugin *plugin) } } +static gboolean +handle_set_state (NMDBusNetworkManagerIpsec_l2tpPpp *object, + GDBusMethodInvocation *invocation, + guint arg_state, + gpointer user_data) +{ + remove_timeout_handler (NM_IPSEC_L2TP_PLUGIN (user_data)); + if (arg_state == NM_PPP_STATUS_DEAD || arg_state == NM_PPP_STATUS_DISCONNECT) + nm_vpn_service_plugin_disconnect (NM_VPN_SERVICE_PLUGIN (user_data), NULL); + + g_dbus_method_invocation_return_value (invocation, NULL); + return TRUE; +} + static void service_plugin_alive_cb (NMIPsecL2tpPppService *service, NMIPSecL2tpPlugin *plugin) @@ -1328,28 +1419,26 @@ service_ppp_state_cb (NMIPsecL2tpPppService *service, guint32 ppp_state, NMIPSecL2tpPlugin *plugin) { - NMVPNServiceState plugin_state = nm_vpn_plugin_get_state (NM_VPN_PLUGIN (plugin)); - switch (ppp_state) { case NM_PPP_STATUS_DEAD: case NM_PPP_STATUS_DISCONNECT: - if (plugin_state == NM_VPN_SERVICE_STATE_STARTED) - nm_vpn_plugin_disconnect (NM_VPN_PLUGIN (plugin), NULL); - else if (plugin_state == NM_VPN_SERVICE_STATE_STARTING) - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); + nm_vpn_service_plugin_disconnect (NM_VPN_SERVICE_PLUGIN (plugin), NULL); break; default: break; } } +/* static void nm_gvalue_destroy (gpointer data) { g_value_unset ((GValue *) data); g_slice_free (GValue, data); } +*/ +/* static GValue * nm_gvalue_dup (const GValue *value) { @@ -1361,45 +1450,56 @@ nm_gvalue_dup (const GValue *value) return value_dup; } +*/ +/* static void copy_hash (gpointer key, gpointer value, gpointer user_data) { g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), nm_gvalue_dup ((GValue *) value)); } +*/ static void service_ip4_config_cb (NMIPsecL2tpPppService *service, - GHashTable *config_hash, - NMVPNPlugin *plugin) + GVariant *config, + NMVpnServicePlugin *plugin) { - NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); - GHashTable *hash; - GValue *value; + NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (service); + GVariantIter iter; + const char *key; + GVariant *value; + GVariantBuilder builder; + GVariant *new_config; + + if (!config) + return; - hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy); - g_hash_table_foreach (config_hash, copy_hash, hash); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); + g_variant_iter_init (&iter, config); + while (g_variant_iter_next (&iter, "{&sv}", &key, &value)) { + g_variant_builder_add (&builder, "{sv}", key, value); + g_variant_unref (value); + } /* Insert the external VPN gateway into the table, which the pppd plugin * simply doesn't know about. */ - value = g_slice_new0 (GValue); - g_value_init (value, G_TYPE_UINT); - g_value_set_uint (value, priv->naddr); - g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_GATEWAY), value); - - nm_vpn_plugin_set_ip4_config (plugin, hash); + g_variant_builder_add (&builder, "{sv}", NM_IPSEC_L2TP_KEY_GATEWAY, g_variant_new_uint32 (priv->naddr)); + new_config = g_variant_builder_end (&builder); + g_variant_ref_sink (new_config); - g_hash_table_destroy (hash); + nm_vpn_service_plugin_set_ip4_config (plugin, new_config); + g_variant_unref (new_config); } static gboolean -real_connect (NMVPNPlugin *plugin, +real_connect (NMVpnServicePlugin *plugin, NMConnection *connection, GError **error) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; const char *value; if (getenv ("NM_PPP_DUMP_CONNECTION") || debug) @@ -1461,18 +1561,18 @@ real_connect (NMVPNPlugin *plugin, } static gboolean -real_need_secrets (NMVPNPlugin *plugin, +real_need_secrets (NMVpnServicePlugin *plugin, NMConnection *connection, - char **setting_name, + const char **setting_name, GError **error) { - NMSetting *s_vpn; + NMSettingVpn *s_vpn; NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE); + g_return_val_if_fail (NM_IS_VPN_SERVICE_PLUGIN (plugin), FALSE); g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); - s_vpn = nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); + s_vpn = nm_connection_get_setting_vpn (connection); nm_setting_get_secret_flags (NM_SETTING (s_vpn), NM_IPSEC_L2TP_KEY_PASSWORD, &flags, NULL); @@ -1481,7 +1581,7 @@ real_need_secrets (NMVPNPlugin *plugin, return FALSE; /* Don't need the password if we already have one */ - if (nm_setting_vpn_get_secret (NM_SETTING_VPN (s_vpn), NM_IPSEC_L2TP_KEY_PASSWORD)) + if (nm_setting_vpn_get_secret (s_vpn, NM_IPSEC_L2TP_KEY_PASSWORD)) return FALSE; /* Otherwise we need a password */ @@ -1503,7 +1603,7 @@ ensure_killed (gpointer data) } static gboolean -real_disconnect (NMVPNPlugin *plugin, +real_disconnect (NMVpnServicePlugin *plugin, GError **err) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); @@ -1536,8 +1636,9 @@ real_disconnect (NMVPNPlugin *plugin, return TRUE; } +/* static void -state_changed_cb (GObject *object, NMVPNServiceState state, gpointer user_data) +state_changed_cb (GObject *object, NMVpnServiceState state, gpointer user_data) { NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (object); @@ -1564,6 +1665,7 @@ state_changed_cb (GObject *object, NMVPNServiceState state, gpointer user_data) break; } } +*/ static void dispose (GObject *object) @@ -1591,7 +1693,7 @@ static void nm_ipsec_l2tp_plugin_class_init (NMIPSecL2tpPluginClass *l2tp_class) { GObjectClass *object_class = G_OBJECT_CLASS (l2tp_class); - NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS (l2tp_class); + NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS (l2tp_class); g_type_class_add_private (object_class, sizeof (NMIPSecL2tpPluginPrivate)); @@ -1606,13 +1708,16 @@ NMIPSecL2tpPlugin * nm_ipsec_l2tp_plugin_new (void) { NMIPSecL2tpPlugin *plugin; + GError *error = NULL; + + plugin = (NMIPSecL2tpPlugin *) g_initable_new (NM_TYPE_IPSEC_L2TP_PLUGIN, NULL, &error, + NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, NM_DBUS_SERVICE_IPSEC_L2TP, + NULL); + if (!plugin) { + g_warning ("Failed to initialize a plugin instance: %s", error->message); + g_error_free (error); + } - plugin = g_object_new (NM_TYPE_IPSEC_L2TP_PLUGIN, - NM_VPN_PLUGIN_DBUS_SERVICE_NAME, - NM_DBUS_SERVICE_IPSEC_L2TP, - NULL); - if (plugin) - g_signal_connect (G_OBJECT (plugin), "state-changed", G_CALLBACK (state_changed_cb), NULL); return plugin; } diff --git a/src/nm-ipsec-l2tp-service.h b/src/nm-ipsec-l2tp-service.h index d6391c4..d700797 100644 --- a/src/nm-ipsec-l2tp-service.h +++ b/src/nm-ipsec-l2tp-service.h @@ -24,8 +24,10 @@ #define NM_IPSEC_L2TP_PLUGIN_H #include <glib.h> -#include <glib-object.h> -#include <nm-vpn-plugin.h> +#include <NetworkManager.h> +#include <nm-vpn-service-plugin.h> + +#include "nm-ipsec-l2tp-service-defines.h" #define NM_TYPE_IPSEC_L2TP_PLUGIN (nm_ipsec_l2tp_plugin_get_type ()) #define NM_IPSEC_L2TP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IPSEC_L2TP_PLUGIN, NMIPSecL2tpPlugin)) @@ -34,66 +36,12 @@ #define NM_IS_IPSEC_L2TP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IPSEC_L2TP_PLUGIN)) #define NM_IPSEC_L2TP_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IPSEC_L2TP_PLUGIN, NMIPSecL2tpPluginClass)) -/* For the pppd plugin <-> VPN plugin service */ -#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) - -#define NM_DBUS_SERVICE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp-ppp" -#define NM_DBUS_PATH_IPSEC_L2TP_PPP "/org/freedesktop/NetworkManager/ipsec_l2tp/ppp" -#define NM_DBUS_INTERFACE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp.ppp" - - -/* For the NM <-> VPN plugin service */ -#define NM_DBUS_SERVICE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp" -#define NM_DBUS_INTERFACE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp" -#define NM_DBUS_PATH_IPSEC_L2TP "/org/freedesktop/NetworkManager/ipsec_l2tp" - - -/* -#define NM_DBUS_SERVICE_L2TP_PPP "org.freedesktop.NetworkManager.l2tp-ppp" -#define NM_DBUS_PATH_L2TP_PPP "/org/freedesktop/NetworkManager/l2tp/ppp" -#define NM_DBUS_INTERFACE_L2TP_PPP "org.freedesktop.NetworkManager.l2tp.ppp" -// For the NM <-> VPN plugin service -#define NM_DBUS_SERVICE_L2TP "org.freedesktop.NetworkManager.l2tp" -#define NM_DBUS_INTERFACE_L2TP "org.freedesktop.NetworkManager.l2tp" -#define NM_DBUS_PATH_L2TP "/org/freedesktop/NetworkManager/l2tp" -*/ - - -#define NM_IPSEC_L2TP_KEY_GATEWAY "gateway" -#define NM_IPSEC_L2TP_KEY_USER "user" -#define NM_IPSEC_L2TP_KEY_PASSWORD "password" -#define NM_IPSEC_L2TP_KEY_DOMAIN "domain" -#define NM_IPSEC_L2TP_KEY_REFUSE_EAP "refuse-eap" -#define NM_IPSEC_L2TP_KEY_REFUSE_PAP "refuse-pap" -#define NM_IPSEC_L2TP_KEY_REFUSE_CHAP "refuse-chap" -#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAP "refuse-mschap" -#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2" -#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE "require-mppe" -#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_40 "require-mppe-40" -#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128 "require-mppe-128" -#define NM_IPSEC_L2TP_KEY_MPPE_STATEFUL "mppe-stateful" -#define NM_IPSEC_L2TP_KEY_NOBSDCOMP "nobsdcomp" -#define NM_IPSEC_L2TP_KEY_NODEFLATE "nodeflate" -#define NM_IPSEC_L2TP_KEY_NO_VJ_COMP "no-vj-comp" -#define NM_IPSEC_L2TP_KEY_NO_PCOMP "nopcomp" -#define NM_IPSEC_L2TP_KEY_NO_ACCOMP "noaccomp" -#define NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure" -#define NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval" - -#define NM_IPSEC_L2TP_KEY_IPSEC_ENABLE "ipsec-enabled" -#define NM_IPSEC_L2TP_KEY_IPSEC_GATEWAY_ID "ipsec-gateway-id" -#define NM_IPSEC_L2TP_KEY_IPSEC_GROUP_NAME "ipsec-group-name" -#define NM_IPSEC_L2TP_KEY_IPSEC_PSK "ipsec-psk" -#define NM_IPSEC_L2TP_KEY_IPSEC_RSA "ipsec-rsa" -#define NM_IPSEC_L2TP_KEY_IPSEC_RSA_PW "ipsec-rsa-pw" - - typedef struct { - NMVPNPlugin parent; + NMVpnServicePlugin parent; } NMIPSecL2tpPlugin; typedef struct { - NMVPNPluginClass parent; + NMVpnServicePluginClass parent; } NMIPSecL2tpPluginClass; GType nm_ipsec_l2tp_plugin_get_type (void); -- 2.18.1