Commit 6734620e authored by CeRiAl's avatar CeRiAl

Just push everything

parent 85a5abb6
...@@ -6,7 +6,7 @@ Tested on: ...@@ -6,7 +6,7 @@ Tested on:
* ElementaryOS Freya * ElementaryOS Freya
* Linux Mint Rebecca Cinnamon * 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 $ git clone https://git.cryptopath.org/cerial/NetworkManager-l2tp.git
$ cd NetworkManager-l2tp/ $ cd NetworkManager-l2tp/
$ ./autogen.sh $ ./autogen.sh
......
...@@ -9,9 +9,14 @@ endif ...@@ -9,9 +9,14 @@ endif
dbusservicedir = $(sysconfdir)/dbus-1/system.d dbusservicedir = $(sysconfdir)/dbus-1/system.d
dbusservice_DATA = nm-ipsec-l2tp-service.conf dbusservice_DATA = nm-ipsec-l2tp-service.conf
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN nmvpnservicedir = $(NM_VPN_SERVICE_DIR)
nmvpnservice_DATA = nm-ipsec-l2tp-service.name 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 desktopfile = nm-ipsec-l2tp.desktop.in
iconfile = gnome-mime-application-x-ipsec-l2tp-settings.png iconfile = gnome-mime-application-x-ipsec-l2tp-settings.png
......
INCLUDES = -I${top_srcdir}
libexec_PROGRAMS = nm-ipsec-l2tp-auth-dialog libexec_PROGRAMS = nm-ipsec-l2tp-auth-dialog
nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \ nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \
$(NM_CFLAGS) \ $(LIBNM_CFLAGS) \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
$(GTK_CFLAGS) \ $(GTK_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \ $(GNOMEKEYRING_CFLAGS) \
-Wno-error=deprecated-declarations \ -I"${top_srcdir}/shared/" \
-DICONDIR=\""$(datadir)/pixmaps"\" \ -Wno-error=deprecated-declarations \
-DUIDIR=\""$(uidir)"\" \ -DICONDIR=\""$(datadir)/pixmaps"\" \
-DBINDIR=\""$(bindir)"\" \ -DUIDIR=\""$(uidir)"\" \
-DG_DISABLE_DEPRECATED \ -DBINDIR=\""$(bindir)"\" \
-DG_DISABLE_DEPRECATED \
-DVERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
nm_ipsec_l2tp_auth_dialog_SOURCES = \ nm_ipsec_l2tp_auth_dialog_SOURCES = \
main.c \ main.c \
vpn-password-dialog.c \ vpn-password-dialog.c \
vpn-password-dialog.h vpn-password-dialog.h
nm_ipsec_l2tp_auth_dialog_LDADD = \ nm_ipsec_l2tp_auth_dialog_LDADD = \
$(NM_LIBS) \ $(LIBNM_LIBS) \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(GNOMEKEYRING_LIBS) $(GNOMEKEYRING_LIBS)
CLEANFILES = *~ CLEANFILES = *~
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <config.h> #include <config.h>
#endif #endif
#include "nm-default.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
...@@ -33,10 +35,14 @@ ...@@ -33,10 +35,14 @@
#include <gnome-keyring.h> #include <gnome-keyring.h>
#include <gnome-keyring-memory.h> #include <gnome-keyring-memory.h>
#include <nm-setting-vpn.h> //#include <libsecret/secret.h>
#include <nm-vpn-plugin-utils.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" #include "vpn-password-dialog.h"
#define KEYRING_UUID_TAG "connection-uuid" #define KEYRING_UUID_TAG "connection-uuid"
...@@ -218,7 +224,7 @@ wait_for_quit (void) ...@@ -218,7 +224,7 @@ wait_for_quit (void)
g_string_free (str, TRUE); g_string_free (str, TRUE);
} }
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
gboolean retry = FALSE, allow_interaction = FALSE, external_ui_mode = FALSE; gboolean retry = FALSE, allow_interaction = FALSE, external_ui_mode = FALSE;
...@@ -257,13 +263,13 @@ main (int argc, char *argv[]) ...@@ -257,13 +263,13 @@ main (int argc, char *argv[])
return 1; 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", fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n",
vpn_name, vpn_uuid); vpn_name, vpn_uuid);
return 1; 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, if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode,
g_hash_table_lookup (secrets, NM_IPSEC_L2TP_KEY_PASSWORD), g_hash_table_lookup (secrets, NM_IPSEC_L2TP_KEY_PASSWORD),
......
...@@ -54,6 +54,9 @@ dnl ...@@ -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])) 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) 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 GETTEXT_PACKAGE=NetworkManager-ipsec-l2tp
AC_SUBST(GETTEXT_PACKAGE) AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
...@@ -61,23 +64,12 @@ 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]) IT_PROG_INTLTOOL([0.35])
AM_GLIB_GNU_GETTEXT 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_CFLAGS)
AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_LIBS)
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32" 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 if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4) PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4)
AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_CFLAGS)
...@@ -87,6 +79,16 @@ if test x"$with_gnome" != xno; then ...@@ -87,6 +79,16 @@ if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1) PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
AC_SUBST(GNOMEKEYRING_CFLAGS) AC_SUBST(GNOMEKEYRING_CFLAGS)
AC_SUBST(GNOMEKEYRING_LIBS) 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 fi
NM_COMPILER_WARNINGS NM_COMPILER_WARNINGS
...@@ -99,6 +101,15 @@ if ! test x"$ac_distver" = x""; then ...@@ -99,6 +101,15 @@ if ! test x"$ac_distver" = x""; then
AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string]) AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string])
fi 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([ AC_CONFIG_FILES([
Makefile Makefile
src/Makefile src/Makefile
......
...@@ -3,6 +3,9 @@ name=ipsec-l2tp ...@@ -3,6 +3,9 @@ name=ipsec-l2tp
service=org.freedesktop.NetworkManager.ipsec_l2tp service=org.freedesktop.NetworkManager.ipsec_l2tp
program=@LIBEXECDIR@/nm-ipsec-l2tp-service program=@LIBEXECDIR@/nm-ipsec-l2tp-service
[libnm]
plugin=@PLUGINDIR@/libnm-vpn-plugin-ipsec-l2tp.so
[GNOME] [GNOME]
auth-dialog=@LIBEXECDIR@/nm-ipsec-l2tp-auth-dialog auth-dialog=@LIBEXECDIR@/nm-ipsec-l2tp-auth-dialog
properties=@PLUGINDIR@/libnm-ipsec-l2tp-properties properties=@PLUGINDIR@/libnm-ipsec-l2tp-properties
......
# Slovenian translation for network-manager-ipsec-l2tp. # Slovenian translation for network-manager-ipsec-l2tp.
# Copyright (C) 2009 network-manager-ipsec-l2tp's COPYRIGHT HOLDER # 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. # 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 "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: network-manager-ipsec-l2tp master\n" "Project-Id-Version: network-manager-ipsec-l2tp master\n"
......
plugindir = $(libdir)/NetworkManager 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_vpn_plugin_ipsec_l2tp_la_SOURCES = \
libnm_ipsec_l2tp_properties_la_SOURCES = \
nm-ipsec-l2tp.c \ nm-ipsec-l2tp.c \
nm-ipsec-l2tp.h \ nm-ipsec-l2tp.h \
ipsec-dialog.c \ ipsec-dialog.c \
ipsec-dialog.h \ ipsec-dialog.h \
advanced-dialog.c \ advanced-dialog.c \
advanced-dialog.h \ advanced-dialog.h
import-export.c \ # import-export.c \
import-export.h # 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 ui_DATA = nm-ipsec-l2tp-dialog.ui
libnm_ipsec_l2tp_properties_la_CFLAGS = \ common_CFLAGS = \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
$(GTK_CFLAGS) \ $(GTK_CFLAGS) \
$(NM_CFLAGS) \ -DICONDIR=\""$(datadir)/pixmaps"\" \
-DICONDIR=\""$(datadir)/pixmaps"\" \ -DUIDIR=\""$(uidir)"\" \
-DUIDIR=\""$(uidir)"\" \ -DLOCALEDIR=\""$(datadir)/locale"\" \
-DLOCALEDIR=\""$(datadir)/locale"\" \ -DG_DISABLE_DEPRECATED \
-DG_DISABLE_DEPRECATED \ -DVERSION=\"$(VERSION)\"
-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 = \ libnm_ipsec_l2tp_properties_la_LIBADD = \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(NM_LIBS) $(LIBNM_GLIB_LIBS)
libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS = \
-avoid-version
libnm_ipsec_l2tp_properties_la_LDFLAGS = \ libnm_ipsec_l2tp_properties_la_LDFLAGS = \
-avoid-version $(libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS)
CLEANFILES = *.bak *~ CLEANFILES = *.bak *~
......
...@@ -35,12 +35,9 @@ ...@@ -35,12 +35,9 @@
#include <glib.h> #include <glib.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#include "advanced-dialog.h" #include "advanced-dialog.h"
#include "nm-ipsec-l2tp.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_NAME 0
#define COL_VALUE 1 #define COL_VALUE 1
...@@ -66,8 +63,6 @@ static const char *advanced_keys[] = { ...@@ -66,8 +63,6 @@ static const char *advanced_keys[] = {
NM_IPSEC_L2TP_KEY_NOBSDCOMP, NM_IPSEC_L2TP_KEY_NOBSDCOMP,
NM_IPSEC_L2TP_KEY_NODEFLATE, NM_IPSEC_L2TP_KEY_NODEFLATE,
NM_IPSEC_L2TP_KEY_NO_VJ_COMP, 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_FAILURE,
NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL,
NULL NULL
...@@ -91,11 +86,11 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection, ...@@ -91,11 +86,11 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection,
GError **error) GError **error)
{ {
GHashTable *hash; GHashTable *hash;
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); 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); nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash);
return hash; return hash;
} }
...@@ -282,7 +277,7 @@ auth_methods_setup (GtkBuilder *builder, GHashTable *hash) ...@@ -282,7 +277,7 @@ auth_methods_setup (GtkBuilder *builder, GHashTable *hash)
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE); value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE);
if (value && !strcmp (value, "yes")) if (value && !strcmp (value, "yes"))
use_mppe = TRUE; use_mppe = TRUE;
/* Or MPPE-128 */ /* Or MPPE-128 */
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128); value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128);
if (value && !strcmp (value, "yes")) if (value && !strcmp (value, "yes"))
...@@ -468,18 +463,6 @@ advanced_dialog_new (GHashTable *hash) ...@@ -468,18 +463,6 @@ advanced_dialog_new (GHashTable *hash)
if (value && !strcmp (value, "yes")) if (value && !strcmp (value, "yes"))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); 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")); 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); value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL);
if (value && strlen (value)) { if (value && strlen (value)) {
...@@ -554,14 +537,6 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error) ...@@ -554,14 +537,6 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) 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")); 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")); widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { 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)); g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE), g_strdup_printf ("%d", 5));
......
...@@ -19,13 +19,19 @@ ...@@ -19,13 +19,19 @@
* *
**************************************************************************/ **************************************************************************/
#ifndef _AUTH_HELPERS_H_ #ifndef _ADVANCED_DIALOG_H_
#define _AUTH_HELPERS_H_ #define _ADVANCED_DIALOG_H_
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h> #include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_IPSEC_L2TP_OLD */
#include <NetworkManager.h>
#endif
GtkWidget *advanced_dialog_new (GHashTable *hash); GtkWidget *advanced_dialog_new (GHashTable *hash);
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <nm-setting-vpn.h> //#include <nm-setting-vpn.h>
#include <nm-setting-connection.h> //#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h> //#include <nm-setting-ip4-config.h>
#include "import-export.h" #include "import-export.h"
#include "nm-ipsec-l2tp.h" #include "nm-ipsec-l2tp.h"
...@@ -104,8 +104,6 @@ static VpnImportExportProperty vpn_properties[] = { ...@@ -104,8 +104,6 @@ static VpnImportExportProperty vpn_properties[] = {
{ NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NODEFLATE, 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_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_FAILURE, G_TYPE_UINT, FALSE },
{ NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, 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 }, */ /* { NM_IPSEC_L2TP_KEY_PASSWORD"-flags", G_TYPE_UINT, FALSE }, */
...@@ -119,11 +117,11 @@ static VpnImportExportProperty vpn_properties[] = { ...@@ -119,11 +117,11 @@ static VpnImportExportProperty vpn_properties[] = {
}; };
static VpnImportExportProperty ip4_properties[] = { static VpnImportExportProperty ip4_properties[] = {
{ NM_SETTING_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE}, { NM_VPN_PLUGIN_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE},
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE}, { NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE}, { NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE}, { NM_VPN_PLUGIN_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE}, { NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE},
{ NULL, G_TYPE_NONE, FALSE } { NULL, G_TYPE_NONE, FALSE }
/* NM_SETTING_IP4_CONFIG_DNS */ /* NM_SETTING_IP4_CONFIG_DNS */
/* NM_SETTING_IP4_CONFIG_DNS_SEARCH */ /* NM_SETTING_IP4_CONFIG_DNS_SEARCH */
...@@ -134,8 +132,8 @@ static void ...@@ -134,8 +132,8 @@ static void
ip4_import_error (GError **error, const char *message, const char *key, const char *val) ip4_import_error (GError **error, const char *message, const char *key, const char *val)
{ {
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
message, message,
key, key,
val); val);
...@@ -165,8 +163,8 @@ import_ip4 (GKeyFile *keyfile, NMSettingIP4Config *s_ip4, GError **error) ...@@ -165,8 +163,8 @@ import_ip4 (GKeyFile *keyfile, NMSettingIP4Config *s_ip4, GError **error)
continue; continue;
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Required property %s missing"), _("Required property %s missing"),
prop.name); prop.name);
return FALSE; return FALSE;
...@@ -371,7 +369,7 @@ do_import (const char *path, GError **error) ...@@ -371,7 +369,7 @@ do_import (const char *path, GError **error)
{ {
NMConnection *connection = NULL; NMConnection *connection = NULL;
NMSettingConnection *s_con; NMSettingConnection *s_con;
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
NMSettingIP4Config *s_ip4; NMSettingIP4Config *s_ip4;
GKeyFile *keyfile; GKeyFile *keyfile;
...@@ -381,13 +379,13 @@ do_import (const char *path, GError **error) ...@@ -381,13 +379,13 @@ do_import (const char *path, GError **error)
keyfile = g_key_file_new (); keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile, path, 0, error)) { if (!g_key_file_load_from_file (keyfile, path, 0, error)) {
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP,
_("does not look like a IPSEC-L2TP VPN connection (parse failed)")); _("does not look like a IPSEC-L2TP VPN connection (parse failed)"));
return NULL; return NULL;
} }
connection = nm_connection_new (); connection = nm_simple_connection_new ();
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con)); nm_connection_add_setting (connection, NM_SETTING (s_con));
...@@ -416,8 +414,8 @@ do_import (const char *path, GError **error) ...@@ -416,8 +414,8 @@ do_import (const char *path, GError **error)
continue; continue;
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Required property %s missing"), _("Required property %s missing"),
prop.name); prop.name);
g_key_file_free (keyfile); g_key_file_free (keyfile);
...@@ -434,8 +432,8 @@ do_import (const char *path, GError **error) ...@@ -434,8 +432,8 @@ do_import (const char *path, GError **error)
if (int_val == 0 && *error){ if (int_val == 0 && *error){
g_clear_error(error); g_clear_error(error);
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
_("Property %s can't be parsed as integer."), _("Property %s can't be parsed as integer."),
prop.name); prop.name);
g_key_file_free (keyfile); g_key_file_free (keyfile);
...@@ -451,8 +449,8 @@ do_import (const char *path, GError **error) ...@@ -451,8 +449,8 @@ do_import (const char *path, GError **error)
if (!bool_val) { if (!bool_val) {
g_clear_error(error); g_clear_error(error);
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
_("Property %s can't be parsed as boolean. Only 'true' and 'false' allowed."), _("Property %s can't be parsed as boolean. Only 'true' and 'false' allowed."),
prop.name); prop.name);
g_key_file_free (keyfile); g_key_file_free (keyfile);
...@@ -595,7 +593,7 @@ gboolean ...@@ -595,7 +593,7 @@ gboolean
do_export (const char *path, NMConnection *connection, GError **error) do_export (const char *path, NMConnection *connection, GError **error)
{ {
NMSettingConnection *s_con; NMSettingConnection *s_con;
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
NMSettingIP4Config *s_ip4; NMSettingIP4Config *s_ip4;
GKeyFile *export_file; GKeyFile *export_file;
...@@ -607,7 +605,7 @@ do_export (const char *path, NMConnection *connection, GError **error) ...@@ -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_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_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 (); export_file = g_key_file_new ();
...@@ -623,8 +621,8 @@ do_export (const char *path, NMConnection *connection, GError **error) ...@@ -623,8 +621,8 @@ do_export (const char *path, NMConnection *connection, GError **error)
if (!value && prop.required){ if (!value && prop.required){
g_key_file_free(export_file); g_key_file_free(export_file);
g_set_error(error, g_set_error(error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Missing required property '%s'"), _("Missing required property '%s'"),
prop.name); prop.name);
return FALSE; return FALSE;
...@@ -653,8 +651,8 @@ do_export (const char *path, NMConnection *connection, GError **error) ...@@ -653,8 +651,8 @@ do_export (const char *path, NMConnection *connection, GError **error)
if (!(file = fopen (path, "w"))) { if (!(file = fopen (path, "w"))) {
g_set_error(error, g_set_error(error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE,
_("Couldn't open file for writing.")); _("Couldn't open file for writing."));
g_key_file_free (export_file); g_key_file_free (export_file);
return FALSE; return FALSE;
......
...@@ -23,7 +23,14 @@ ...@@ -23,7 +23,14 @@
#define _IMPORT_EXPORT_H_ #define _IMPORT_EXPORT_H_
#include <glib.h> #include <glib.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h> #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); NMConnection *do_import (const char *path, GError **error);
......
...@@ -34,12 +34,9 @@ ...@@ -34,12 +34,9 @@
#include <glib.h> #include <glib.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#include "ipsec-dialog.h" #include "ipsec-dialog.h"
#include "nm-ipsec-l2tp.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[] = { static const char *ipsec_keys[] = {
NM_IPSEC_L2TP_KEY_IPSEC_ENABLE, NM_IPSEC_L2TP_KEY_IPSEC_ENABLE,
...@@ -69,11 +66,11 @@ ipsec_dialog_new_hash_from_connection (NMConnection *connection, ...@@ -69,11 +66,11 @@ ipsec_dialog_new_hash_from_connection (NMConnection *connection,
GError **error) GError **error)
{ {
GHashTable *hash; GHashTable *hash;
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); 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); nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash);
return hash; return hash;
} }
......
...@@ -25,7 +25,13 @@ ...@@ -25,7 +25,13 @@
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h> #include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_IPSEC_L2TP_OLD */
#include <NetworkManager.h>
#endif
GtkWidget *ipsec_dialog_new (GHashTable *hash); GtkWidget *ipsec_dialog_new (GHashTable *hash);
......
...@@ -36,12 +36,30 @@ ...@@ -36,12 +36,30 @@
#define NM_VPN_API_SUBJECT_TO_CHANGE #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-vpn-plugin-ui-interface.h>
#include <nm-setting-vpn.h> #include <nm-setting-vpn.h>
#include <nm-setting-connection.h> #include <nm-setting-connection.h>
#include <nm-setting-ip4-config.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 "nm-ipsec-l2tp.h"
#include "import-export.h" #include "import-export.h"
#include "advanced-dialog.h" #include "advanced-dialog.h"
...@@ -49,7 +67,6 @@ ...@@ -49,7 +67,6 @@
#define IPSEC_L2TP_PLUGIN_NAME _("IPSec-L2TP") #define IPSEC_L2TP_PLUGIN_NAME _("IPSec-L2TP")
#define IPSEC_L2TP_PLUGIN_DESC _("Compatible with IPSec-L2TP VPN servers.") #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_SAVE 0
#define PW_TYPE_ASK 1 #define PW_TYPE_ASK 1
...@@ -59,21 +76,28 @@ typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data); ...@@ -59,21 +76,28 @@ typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data);
/************** plugin class **************/ /************** 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, static void ipsec_l2tp_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class);
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
ipsec_l2tp_plugin_ui_interface_init)) 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 **************/ /************** 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_DEFINE_TYPE_EXTENDED (IPSecL2tpEditor, ipsec_l2tp_editor, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
ipsec_l2tp_plugin_ui_widget_interface_init)) 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 { typedef struct {
GtkBuilder *builder; GtkBuilder *builder;
...@@ -84,48 +108,13 @@ typedef struct { ...@@ -84,48 +108,13 @@ typedef struct {
GHashTable *advanced; GHashTable *advanced;
GHashTable *ipsec; GHashTable *ipsec;
gboolean new_connection; gboolean new_connection;
} IPSecL2tpPluginUiWidgetPrivate; } IPSecL2tpEditorPrivate;
GQuark /************** import/export **************/
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 }
GType typedef enum {
ipsec_l2tp_plugin_ui_error_get_type (void) IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP = 0
{ } NMIpsecL2tpImportError;
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;
}
/** /**
* Return copy of string #s with the leading and trailing spaces removed * Return copy of string #s with the leading and trailing spaces removed
...@@ -158,9 +147,9 @@ strstrip (const char *s) ...@@ -158,9 +147,9 @@ strstrip (const char *s)
} }
static gboolean 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; GtkWidget *widget;
const char *str; const char *str;
char *s=NULL; char *s=NULL;
...@@ -170,8 +159,8 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error) ...@@ -170,8 +159,8 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error)
if (!str || !strlen (s = strstrip (str))) { if (!str || !strlen (s = strstrip (str))) {
g_free(s); g_free(s);
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
NM_IPSEC_L2TP_KEY_GATEWAY); NM_IPSEC_L2TP_KEY_GATEWAY);
return FALSE; return FALSE;
} }
...@@ -182,7 +171,7 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error) ...@@ -182,7 +171,7 @@ check_validity (IPSecL2tpPluginUiWidget *self, GError **error)
static void static void
stuff_changed_cb (GtkWidget *widget, gpointer user_data) 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 static void
...@@ -204,8 +193,8 @@ ipsec_dialog_close_cb (GtkWidget *dialog, gpointer user_data) ...@@ -204,8 +193,8 @@ ipsec_dialog_close_cb (GtkWidget *dialog, gpointer user_data)
static void static void
advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
GError *error = NULL; GError *error = NULL;
if (response != GTK_RESPONSE_OK) { if (response != GTK_RESPONSE_OK) {
...@@ -228,8 +217,8 @@ advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_dat ...@@ -228,8 +217,8 @@ advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_dat
static void static void
ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
GError *error = NULL; GError *error = NULL;
if (response != GTK_RESPONSE_OK) { if (response != GTK_RESPONSE_OK) {
...@@ -252,8 +241,8 @@ ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data) ...@@ -252,8 +241,8 @@ ipsec_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data)
static void static void
advanced_button_clicked_cb (GtkWidget *button, gpointer user_data) advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel; GtkWidget *dialog, *toplevel;
toplevel = gtk_widget_get_toplevel (priv->widget); toplevel = gtk_widget_get_toplevel (priv->widget);
...@@ -281,8 +270,8 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data) ...@@ -281,8 +270,8 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
static void static void
ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data) ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel; GtkWidget *dialog, *toplevel;
toplevel = gtk_widget_get_toplevel (priv->widget); toplevel = gtk_widget_get_toplevel (priv->widget);
...@@ -308,13 +297,13 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data) ...@@ -308,13 +297,13 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data)
} }
static void static void
setup_password_widget (IPSecL2tpPluginUiWidget *self, setup_password_widget (IPSecL2tpEditor *self,
const char *entry_name, const char *entry_name,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
const char *secret_name, const char *secret_name,
gboolean new_connection) 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; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
GtkWidget *widget; GtkWidget *widget;
const char *value; const char *value;
...@@ -339,9 +328,9 @@ setup_password_widget (IPSecL2tpPluginUiWidget *self, ...@@ -339,9 +328,9 @@ setup_password_widget (IPSecL2tpPluginUiWidget *self,
} }
static void 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; GtkWidget *widget;
gboolean visible; gboolean visible;
...@@ -355,8 +344,8 @@ show_toggled_cb (GtkCheckButton *button, IPSecL2tpPluginUiWidget *self) ...@@ -355,8 +344,8 @@ show_toggled_cb (GtkCheckButton *button, IPSecL2tpPluginUiWidget *self)
static void static void
pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (user_data); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (user_data);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
GtkWidget *entry; GtkWidget *entry;
entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_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) ...@@ -380,13 +369,13 @@ pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data)
} }
static void static void
init_one_pw_combo (IPSecL2tpPluginUiWidget *self, init_one_pw_combo (IPSecL2tpEditor *self,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
const char *combo_name, const char *combo_name,
const char *secret_key, const char *secret_key,
const char *entry_name) 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; int active = -1;
GtkWidget *widget; GtkWidget *widget;
GtkListStore *store; GtkListStore *store;
...@@ -437,14 +426,14 @@ init_one_pw_combo (IPSecL2tpPluginUiWidget *self, ...@@ -437,14 +426,14 @@ init_one_pw_combo (IPSecL2tpPluginUiWidget *self,
} }
static gboolean 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); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
GtkWidget *widget; GtkWidget *widget;
const char *value; 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); priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
...@@ -512,10 +501,10 @@ init_plugin_ui (IPSecL2tpPluginUiWidget *self, NMConnection *connection, GError ...@@ -512,10 +501,10 @@ init_plugin_ui (IPSecL2tpPluginUiWidget *self, NMConnection *connection, GError
} }
static GObject * static GObject *
get_widget (NMVpnPluginUiWidgetInterface *iface) get_widget (NMVpnEditor *iface)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (iface); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (iface);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
return G_OBJECT (priv->widget); return G_OBJECT (priv->widget);
} }
...@@ -523,13 +512,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface) ...@@ -523,13 +512,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface)
static void static void
hash_copy_pair (gpointer key, gpointer data, gpointer user_data) 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); nm_setting_vpn_add_data_item (s_vpn, (const char *) key, (const char *) data);
} }
static void static void
save_password_and_flags (NMSettingVPN *s_vpn, save_password_and_flags (NMSettingVpn *s_vpn,
GtkBuilder *builder, GtkBuilder *builder,
const char *entry_name, const char *entry_name,
const char *combo_name, const char *combo_name,
...@@ -566,13 +555,13 @@ save_password_and_flags (NMSettingVPN *s_vpn, ...@@ -566,13 +555,13 @@ save_password_and_flags (NMSettingVPN *s_vpn,
} }
static gboolean static gboolean
update_connection (NMVpnPluginUiWidgetInterface *iface, update_connection (NMVpnEditor *iface,
NMConnection *connection, NMConnection *connection,
GError **error) GError **error)
{ {
IPSecL2tpPluginUiWidget *self = IPSEC_L2TP_PLUGIN_UI_WIDGET (iface); IPSecL2tpEditor *self = IPSEC_L2TP_EDITOR (iface);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (self);
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
GtkWidget *widget; GtkWidget *widget;
const char *str; const char *str;
char *s=NULL; char *s=NULL;
...@@ -632,25 +621,25 @@ is_new_func (const char *key, const char *value, gpointer user_data) ...@@ -632,25 +621,25 @@ is_new_func (const char *key, const char *value, gpointer user_data)
*is_new = FALSE; *is_new = FALSE;
} }
static NMVpnPluginUiWidgetInterface * static NMVpnEditor *
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) nm_vpn_editor_interface_new (NMConnection *connection, GError **error)
{ {
NMVpnPluginUiWidgetInterface *object; NMVpnEditor *object;
IPSecL2tpPluginUiWidgetPrivate *priv; IPSecL2tpEditorPrivate *priv;
char *ui_file; char *ui_file;
gboolean new = TRUE; gboolean new = TRUE;
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
if (error) if (error)
g_return_val_if_fail (*error == NULL, NULL); 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) { 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; 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"); ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-ipsec-l2tp-dialog.ui");
priv->builder = gtk_builder_new (); priv->builder = gtk_builder_new ();
...@@ -661,7 +650,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -661,7 +650,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
g_warning (_("Couldn't load builder file: %s"), g_warning (_("Couldn't load builder file: %s"),
error && *error ? (*error)->message : "(unknown)"); error && *error ? (*error)->message : "(unknown)");
g_clear_error(error); 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"), _("could not load required resources at %s"),
ui_file); ui_file);
g_free(ui_file); g_free(ui_file);
...@@ -672,7 +661,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -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")); priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipsec-l2tp-vbox"));
if (!priv->widget) { 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); g_object_unref (object);
return NULL; return NULL;
} }
...@@ -685,7 +674,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -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); nm_setting_vpn_foreach_data_item (s_vpn, is_new_func, &new);
priv->new_connection = 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); g_object_unref (object);
return NULL; return NULL;
} }
...@@ -707,8 +696,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -707,8 +696,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
static void static void
dispose (GObject *object) dispose (GObject *object)
{ {
IPSecL2tpPluginUiWidget *plugin = IPSEC_L2TP_PLUGIN_UI_WIDGET (object); IPSecL2tpEditor *plugin = IPSEC_L2TP_EDITOR (object);
IPSecL2tpPluginUiWidgetPrivate *priv = IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin); IPSecL2tpEditorPrivate *priv = IPSEC_L2TP_EDITOR_GET_PRIVATE (plugin);
if (priv->group) if (priv->group)
g_object_unref (priv->group); g_object_unref (priv->group);
...@@ -728,26 +717,26 @@ dispose (GObject *object) ...@@ -728,26 +717,26 @@ dispose (GObject *object)
if (priv->ipsec) if (priv->ipsec)
g_hash_table_destroy (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 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); 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; object_class->dispose = dispose;
} }
static void static void
ipsec_l2tp_plugin_ui_widget_init (IPSecL2tpPluginUiWidget *plugin) ipsec_l2tp_editor_init (IPSecL2tpEditor *plugin)
{ {
} }
static void static void
ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class) ipsec_l2tp_editor_interface_init (NMVpnEditorInterface *iface_class)
{ {
/* interface implementation */ /* interface implementation */
iface_class->get_widget = get_widget; iface_class->get_widget = get_widget;
...@@ -755,7 +744,7 @@ ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_ ...@@ -755,7 +744,7 @@ ipsec_l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_
} }
static NMConnection * static NMConnection *
import (NMVpnPluginUiInterface *iface, const char *path, GError **error) import (NMVpnEditorPlugin *iface, const char *path, GError **error)
{ {
NMConnection *connection = NULL; NMConnection *connection = NULL;
char *ext; char *ext;
...@@ -763,24 +752,24 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) ...@@ -763,24 +752,24 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
ext = strrchr (path, '.'); ext = strrchr (path, '.');
if (!ext) { if (!ext) {
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP,
_("unknown IPSec-L2TP file extension")); _("unknown IPSec-L2TP file extension"));
return NULL; return NULL;
} }
if (strcmp (ext, ".conf") && strcmp (ext, ".cnf")) { if (strcmp (ext, ".conf") && strcmp (ext, ".cnf")) {
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP,
_("unknown IPSec-L2TP file extension. Allowed .conf or .cnf")); _("unknown IPSec-L2TP file extension. Allowed .conf or .cnf"));
return NULL; return NULL;
} }
if (!strstr (path, "ipsec-l2tp")) { if (!strstr (path, "ipsec-l2tp")) {
g_set_error (error, g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR, IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP, IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP,
_("Filename doesn't contains 'ipsec-l2tp' substring.")); _("Filename doesn't contains 'ipsec-l2tp' substring."));
return NULL; return NULL;
} }
...@@ -794,7 +783,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) ...@@ -794,7 +783,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
} }
static gboolean static gboolean
export (NMVpnPluginUiInterface *iface, export (NMVpnEditorPlugin *iface,
const char *path, const char *path,
NMConnection *connection, NMConnection *connection,
GError **error) GError **error)
...@@ -802,8 +791,9 @@ export (NMVpnPluginUiInterface *iface, ...@@ -802,8 +791,9 @@ export (NMVpnPluginUiInterface *iface,
return do_export (path, connection, error); return do_export (path, connection, error);
} }
/*
static char * static char *
get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection) get_suggested_name (NMVpnEditorPlugin *iface, NMConnection *connection)
{ {
NMSettingConnection *s_con; NMSettingConnection *s_con;
const char *id; const char *id;
...@@ -818,17 +808,18 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection) ...@@ -818,17 +808,18 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
return g_strdup_printf ("%s (ipsec-l2tp).conf", id); return g_strdup_printf ("%s (ipsec-l2tp).conf", id);
} }
*/
static guint32 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 * static NMVpnEditor *
ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error) 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 static void
...@@ -836,14 +827,14 @@ get_property (GObject *object, guint prop_id, ...@@ -836,14 +827,14 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
switch (prop_id) { switch (prop_id) {
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: case PROP_NAME:
g_value_set_string (value, IPSEC_L2TP_PLUGIN_NAME); g_value_set_string (value, IPSEC_L2TP_PLUGIN_NAME);
break; break;
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: case PROP_DESC:
g_value_set_string (value, IPSEC_L2TP_PLUGIN_DESC); g_value_set_string (value, IPSEC_L2TP_PLUGIN_DESC);
break; break;
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: case PROP_SERVICE:
g_value_set_string (value, IPSEC_L2TP_PLUGIN_SERVICE); g_value_set_string (value, NM_DBUS_SERVICE_IPSEC_L2TP);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -852,44 +843,43 @@ get_property (GObject *object, guint prop_id, ...@@ -852,44 +843,43 @@ get_property (GObject *object, guint prop_id,
} }
static void 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); GObjectClass *object_class = G_OBJECT_CLASS (req_class);
object_class->get_property = get_property; object_class->get_property = get_property;
g_object_class_override_property (object_class, g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME, PROP_NAME,
NM_VPN_PLUGIN_UI_INTERFACE_NAME); NM_VPN_EDITOR_PLUGIN_NAME);
g_object_class_override_property (object_class, g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC, PROP_DESC,
NM_VPN_PLUGIN_UI_INTERFACE_DESC); NM_VPN_EDITOR_PLUGIN_DESCRIPTION);
g_object_class_override_property (object_class, g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE, PROP_SERVICE,
NM_VPN_PLUGIN_UI_INTERFACE_SERVICE); NM_VPN_EDITOR_PLUGIN_SERVICE);
} }
static void static void
ipsec_l2tp_plugin_ui_init (IPSecL2tpPluginUi *plugin) ipsec_l2tp_editor_plugin_init (IPSecL2tpEditorPlugin *plugin)
{ {
} }
static void static void
ipsec_l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) ipsec_l2tp_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class)
{ {
/* interface implementation */ /* interface implementation */
iface_class->ui_factory = ui_factory; iface_class->get_editor = get_editor;
iface_class->get_capabilities = get_capabilities; iface_class->get_capabilities = get_capabilities;
iface_class->import_from_file = import; iface_class->import_from_file = import;
iface_class->export_to_file = export; iface_class->export_to_file = export;
iface_class->get_suggested_name = get_suggested_name;
} }
G_MODULE_EXPORT NMVpnPluginUiInterface * G_MODULE_EXPORT NMVpnEditorPlugin *
nm_vpn_plugin_ui_factory (GError **error) nm_vpn_editor_plugin_factory (GError **error)
{ {
if (error) if (error)
g_return_val_if_fail (*error == NULL, NULL); g_return_val_if_fail (*error == NULL, NULL);
...@@ -897,6 +887,6 @@ nm_vpn_plugin_ui_factory (GError **error) ...@@ -897,6 +887,6 @@ nm_vpn_plugin_ui_factory (GError **error)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 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);
} }
...@@ -25,62 +25,45 @@ ...@@ -25,62 +25,45 @@
#include <glib-object.h> #include <glib-object.h>
typedef enum #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))
IPSEC_L2TP_PLUGIN_UI_ERROR_UNKNOWN = 0, #define IPSEC_L2TP_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass))
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, #define IPSEC_L2TP_IS_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN))
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY, #define IPSEC_L2TP_IS_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN))
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY, #define IPSEC_L2TP_EDITOR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass))
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP
} IPSecL2tpPluginUiError;
#define IPSEC_L2TP_TYPE_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_get_type ()) typedef struct _IPSecL2tpEditorPlugin IPSecL2tpEditorPlugin;
GType ipsec_l2tp_plugin_ui_error_get_type (void); typedef struct _IPSecL2tpEditorPluginClass IPSecL2tpEditorPluginClass;
#define IPSEC_L2TP_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_quark ()) struct _IPSecL2tpEditorPlugin {
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 {
GObject parent; GObject parent;
}; };
struct _IPSecL2tpPluginUiClass { struct _IPSecL2tpEditorPluginClass {
GObjectClass parent; 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_TYPE_EDITOR (ipsec_l2tp_editor_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_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditor))
#define IPSEC_L2TP_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetClass)) #define IPSEC_L2TP_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass))
#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET)) #define IPSEC_L2TP_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR))
#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET)) #define IPSEC_L2TP_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR))
#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_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass))
typedef struct _IPSecL2tpPluginUiWidget IPSecL2tpPluginUiWidget; typedef struct _IPSecL2tpEditor IPSecL2tpEditor;
typedef struct _IPSecL2tpPluginUiWidgetClass IPSecL2tpPluginUiWidgetClass; typedef struct _IPSecL2tpEditorClass IPSecL2tpEditorClass;
struct _IPSecL2tpPluginUiWidget { struct _IPSecL2tpEditor {
GObject parent; GObject parent;
}; };
struct _IPSecL2tpPluginUiWidgetClass { struct _IPSecL2tpEditorClass {
GObjectClass parent; GObjectClass parent;
}; };
GType ipsec_l2tp_plugin_ui_widget_get_type (void); GType ipsec_l2tp_editor_get_type (void);
#endif /* _NM_IPSEC_L2TP_H_ */ #endif /* _NM_IPSEC_L2TP_H_ */
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
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.
/* -*- 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__ */
/* -*- 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__ */
/* -*- 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
/* -*- 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__ */
/* -*- 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__ */
/* -*- 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;
}
/* -*- 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__ */
INCLUDES = -I${top_srcdir} AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
AM_CPPFLAGS = \ $(LIBNM_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \ -DG_DISABLE_DEPRECATED \
$(GLIB_CFLAGS) \ -DBINDIR=\"$(bindir)\" \
$(NM_CFLAGS) \ -DPREFIX=\""$(prefix)"\" \
-DG_DISABLE_DEPRECATED \ -DSYSCONFDIR=\""$(sysconfdir)"\" \
-DBINDIR=\"$(bindir)\" \ -DNM_VERSION="\"$(VERSION)\"" \
-DPREFIX=\""$(prefix)"\" \ -DLIBDIR=\""$(libdir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \ -DLIBEXECDIR=\""$(libexecdir)"\" \
-DNM_VERSION="\"$(VERSION)\"" \ -DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DLIBDIR=\""$(libdir)"\" \ -DDATADIR=\"$(datadir)\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \ -DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \ -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
-DDATADIR=\"$(datadir)\" \
-DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \
-DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
libexec_PROGRAMS = nm-ipsec-l2tp-service libexec_PROGRAMS = nm-ipsec-l2tp-service
nm_ipsec_l2tp_service_SOURCES = \ nm_ipsec_l2tp_service_SOURCES = \
nm-ipsec-l2tp-service.c \ nm-ipsec-l2tp-service.c \
nm-ipsec-l2tp-service.h 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 # D-Bus stuff
dbus-binding-tool --prefix=nm_ipsec_l2tp_pppd_service --mode=glib-server --output=$@ $< noinst_LTLIBRARIES = libnm-ipsec-l2tp-pppd-service-dbus.la
nm_ipsec_l2tp_service_LDADD = \ nodist_libnm_ipsec_l2tp_pppd_service_dbus_la_SOURCES = \
$(DBUS_GLIB_LIBS) \ nm-ipsec-l2tp-pppd-service-dbus.c \
$(GLIB_LIBS) \ nm-ipsec-l2tp-pppd-service-dbus.h
$(NM_LIBS)
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_plugindir = $(PPPD_PLUGIN_DIR)
pppd_plugin_LTLIBRARIES = nm-ipsec-l2tp-pppd-plugin.la pppd_plugin_LTLIBRARIES = nm-ipsec-l2tp-pppd-plugin.la
nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \ nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \
nm-ipsec-l2tp-pppd-plugin.c \ nm-ipsec-l2tp-pppd-plugin.c \
nm-ppp-status.h nm-ppp-status.h
nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \ nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \
$(DBUS_GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
$(GLIB_CFLAGS) \ $(LIBNM_CFLAGS)
$(NM_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 = \ nm_ipsec_l2tp_pppd_plugin_la_LIBADD = \
$(DBUS_GLIB_LIBS) \ $(GLIB_LIBS) \
$(GLIB_LIBS) \ $(LIBNM_LIBS)
$(NM_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) CLEANFILES = $(BUILT_SOURCES)
......
...@@ -28,20 +28,18 @@ ...@@ -28,20 +28,18 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <glib.h> #include <dlfcn.h>
#include <glib-object.h> //#include <glib.h>
#include <dbus/dbus-glib.h> #include <gio/gio.h>
#include "nm-ppp-status.h"
#include <nm-utils.h>
#include "nm-ipsec-l2tp-service.h" #include "nm-ipsec-l2tp-service.h"
#include "nm-ppp-status.h"
int plugin_init (void); int plugin_init (void);
char pppd_version[] = VERSION; char pppd_version[] = VERSION;
static DBusGProxy *proxy = NULL; static GDBusProxy *proxy = NULL;
static void static void
nm_phasechange (void *data, int arg) nm_phasechange (void *data, int arg)
...@@ -49,7 +47,7 @@ nm_phasechange (void *data, int arg) ...@@ -49,7 +47,7 @@ nm_phasechange (void *data, int arg)
NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN; NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
char *ppp_phase; char *ppp_phase;
g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (G_IS_DBUS_PROXY (proxy));
switch (arg) { switch (arg) {
case PHASE_DEAD: case PHASE_DEAD:
...@@ -116,127 +114,104 @@ nm_phasechange (void *data, int arg) ...@@ -116,127 +114,104 @@ nm_phasechange (void *data, int arg)
ppp_phase); ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN) { if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
dbus_g_proxy_call_no_reply (proxy, "SetState", g_dbus_proxy_call (proxy,
G_TYPE_UINT, ppp_status, "SetState",
G_TYPE_INVALID, g_variant_new ("(u)", ppp_status),
G_TYPE_INVALID); 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 static void
nm_ip_up (void *data, int arg) nm_ip_up (void *data, int arg)
{ {
guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit); guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit);
ipcp_options opts = ipcp_gotoptions[0]; ipcp_options opts = ipcp_gotoptions[0];
ipcp_options peer_opts = ipcp_hisoptions[0]; ipcp_options peer_opts = ipcp_hisoptions[0];
GHashTable *hash; GVariantBuilder builder;
GArray *array;
GValue *val;
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__); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): ip-up event", __func__);
if (!opts.ouraddr) { if (!opts.ouraddr) {
g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__); g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__);
nm_phasechange (NULL, PHASE_DEAD);
return; return;
} }
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
NULL, value_destroy);
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, g_variant_builder_add (&builder, "{sv}",
str_to_gvalue (ifname)); 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 /* Prefer the peer options remote address first, _unless_ pppd made the
* address up, at which point prefer the local options remote address, * 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. * 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)) { if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, g_variant_builder_add (&builder, "{sv}",
uint_to_gvalue (peer_opts.hisaddr)); NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.hisaddr));
} else if (opts.hisaddr) { } else if (opts.hisaddr) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, g_variant_builder_add (&builder, "{sv}",
uint_to_gvalue (opts.hisaddr)); NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (opts.hisaddr));
} else if (peer_opts.hisaddr == pppd_made_up_address) { } else if (peer_opts.hisaddr == pppd_made_up_address) {
/* As a last resort, use the made-up address */ /* As a last resort, use the made-up address */
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP, g_variant_builder_add (&builder, "{sv}",
uint_to_gvalue (peer_opts.hisaddr)); NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.ouraddr));
} }
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, g_variant_builder_add (&builder, "{sv}",
uint_to_gvalue (opts.ouraddr)); NM_VPN_PLUGIN_IP4_CONFIG_PREFIX,
g_variant_new_uint32 (32));
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, uint_to_gvalue (32));
if (opts.dnsaddr[0] || opts.dnsaddr[1]) { 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]) if (opts.dnsaddr[0])
g_array_append_val (array, opts.dnsaddr[0]); dns[len++] = opts.dnsaddr[0];
if (opts.dnsaddr[1]) if (opts.dnsaddr[1])
g_array_append_val (array, opts.dnsaddr[1]); dns[len++] = opts.dnsaddr[1];
val = g_slice_new0 (GValue);
g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
g_value_set_boxed (val, array);
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 */ /* 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__); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): sending Ip4Config to NetworkManager-ipsec-l2tp...", __func__);
dbus_g_proxy_call_no_reply (proxy, "SetIp4Config", g_dbus_proxy_call (proxy,
DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID, "SetIp4Config",
G_TYPE_INVALID); g_variant_new ("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1,
g_hash_table_destroy (hash); NULL,
NULL, NULL);
} }
static int static int
get_chap_check(void) get_chap_check (void)
{ {
return 1; return 1;
} }
static int static int
get_pap_check(void) get_pap_check (void)
{ {
return 1; return 1;
} }
...@@ -244,45 +219,47 @@ get_pap_check(void) ...@@ -244,45 +219,47 @@ get_pap_check(void)
static int static int
get_credentials (char *username, char *password) get_credentials (char *username, char *password)
{ {
char *my_username = NULL; const char *my_username = NULL;
char *my_password = NULL; const char *my_password = NULL;
size_t len; size_t len;
GVariant *ret;
GError *err = NULL; GError *err = NULL;
if (username && !password) { if (!password) {
/* pppd is checking pap support; return 1 for supported */ /* pppd is checking pap support; return 1 for supported */
g_return_val_if_fail (username, -1);
return 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__); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__);
dbus_g_proxy_call (proxy, "NeedSecrets", &err, ret = g_dbus_proxy_call_sync (proxy,
G_TYPE_INVALID, "NeedSecrets",
G_TYPE_STRING, &my_username, NULL,
G_TYPE_STRING, &my_password, G_DBUS_CALL_FLAGS_NONE, -1,
G_TYPE_INVALID); NULL, &err);
if (!ret) {
if (err) {
g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): could not get secrets: (%d) %s", g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): could not get secrets: (%d) %s",
__func__, __func__,
err ? err->code : -1, err ? err->code : -1,
err->message ? err->message : "(unknown)"); err->message ? err->message : "(unknown)");
g_error_free (err); g_error_free (err);
return -1; return -1;
} }
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): got credentials from NetworkManager-ipsec-l2tp", __func__); 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) { if (my_username) {
len = strlen (my_username) + 1; len = strlen (my_username) + 1;
len = len < MAXNAMELEN ? len : MAXNAMELEN; len = len < MAXNAMELEN ? len : MAXNAMELEN;
strncpy (username, my_username, len); strncpy (username, my_username, len);
username[len - 1] = '\0'; username[len - 1] = '\0';
g_free (my_username);
} }
if (my_password) { if (my_password) {
...@@ -291,17 +268,17 @@ get_credentials (char *username, char *password) ...@@ -291,17 +268,17 @@ get_credentials (char *username, char *password)
strncpy (password, my_password, len); strncpy (password, my_password, len);
password[len - 1] = '\0'; password[len - 1] = '\0';
g_free (my_password);
} }
g_variant_unref (ret);
return 1; return 1;
} }
static void static void
nm_exit_notify (void *data, int arg) 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__); g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): cleaning up", __func__);
...@@ -312,7 +289,7 @@ nm_exit_notify (void *data, int arg) ...@@ -312,7 +289,7 @@ nm_exit_notify (void *data, int arg)
int int
plugin_init (void) plugin_init (void)
{ {
DBusGConnection *bus; GDBusConnection *bus;
GError *err = NULL; GError *err = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0) #if !GLIB_CHECK_VERSION (2, 35, 0)
...@@ -321,22 +298,22 @@ plugin_init (void) ...@@ -321,22 +298,22 @@ plugin_init (void)
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): initializing", __func__); 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) { if (!bus) {
g_warning ("nm-ipsec-l2tp-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s", g_warning ("nm-ipsec-l2tp-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s",
__func__, __func__,
err ? err->code : -1, err ? err->code : -1,
err && err->message ? err->message : "(unknown)"); err && err->message ? err->message : "(unknown)");
g_error_free (err); g_error_free (err);
return -1; return -1;
} }
proxy = dbus_g_proxy_new_for_name (bus, proxy = g_dbus_proxy_new_sync (bus, G_DBUS_CALL_FLAGS_NONE, NULL,
NM_DBUS_SERVICE_IPSEC_L2TP_PPP, NM_DBUS_SERVICE_IPSEC_L2TP_PPP,
NM_DBUS_PATH_IPSEC_L2TP_PPP, NM_DBUS_PATH_IPSEC_L2TP_PPP,
NM_DBUS_INTERFACE_IPSEC_L2TP_PPP); NM_DBUS_INTERFACE_IPSEC_L2TP_PPP,
NULL, &err);
dbus_g_connection_unref (bus); g_object_unref (bus);
chap_passwd_hook = get_credentials; chap_passwd_hook = get_credentials;
chap_check_hook = get_chap_check; chap_check_hook = get_chap_check;
......
/*
* 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 (&paramv[0], NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP);
g_value_set_object (&paramv[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 (&paramv[n], G_TYPE_VARIANT);
g_value_set_variant (&paramv[n], child);
n++;
}
else
g_dbus_gvariant_to_gvalue (child, &paramv[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 (&paramv[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 (&paramv[n], NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP);
g_value_set_object (&paramv[n++], skeleton);
g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
g_value_set_object (&paramv[n++], invocation);
if (info->pass_fdlist)
{
#ifdef G_OS_UNIX
g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
g_value_set_object (&paramv[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 (&paramv[n], G_TYPE_VARIANT);
g_value_set_variant (&paramv[n], child);
n++;
}
else
g_dbus_gvariant_to_gvalue (child, &paramv[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 (&paramv[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));
}
/*
* 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__ */
/* -*- 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 */
...@@ -51,14 +51,14 @@ ...@@ -51,14 +51,14 @@
#include <netdb.h> #include <netdb.h>
#include <glib/gi18n.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-utils.h>
#include "nm-ipsec-l2tp-service.h" #include "nm-ipsec-l2tp-service.h"
#include "nm-ppp-status.h" #include "nm-ppp-status.h"
#include "nm-ipsec-l2tp-pppd-service-dbus.h"
#if !defined(DIST_VERSION) #if !defined(DIST_VERSION)
# define DIST_VERSION VERSION # define DIST_VERSION VERSION
...@@ -72,8 +72,9 @@ static gboolean debug = FALSE; ...@@ -72,8 +72,9 @@ static gboolean debug = FALSE;
/* ppp plugin <-> ipsec-l2tp-service object */ /* ppp plugin <-> ipsec-l2tp-service object */
/********************************************************/ /********************************************************/
/* Have to have a separate objec to handle ppp plugin requests since /* We have a separate object to handle ppp plugin requests from
* dbus-glib doesn't allow multiple interfaces registed on one GObject. * 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 ()) #define NM_TYPE_IPSEC_L2TP_PPP_SERVICE (nm_ipsec_l2tp_ppp_service_get_type ())
...@@ -93,28 +94,31 @@ typedef struct { ...@@ -93,28 +94,31 @@ typedef struct {
/* Signals */ /* Signals */
void (*plugin_alive) (NMIPsecL2tpPppService *self); void (*plugin_alive) (NMIPsecL2tpPppService *self);
void (*ppp_state) (NMIPsecL2tpPppService *self, guint32 state); void (*ppp_state) (NMIPsecL2tpPppService *self, guint32 state);
void (*ip4_config) (NMIPsecL2tpPppService *self, GHashTable *config_hash); void (*ip4_config) (NMIPsecL2tpPppService *self, GVariant *config);
} NMIPsecL2tpPppServiceClass; } NMIPsecL2tpPppServiceClass;
GType nm_ipsec_l2tp_ppp_service_get_type (void); GType nm_ipsec_l2tp_ppp_service_get_type (void);
G_DEFINE_TYPE (NMIPsecL2tpPppService, nm_ipsec_l2tp_ppp_service, G_TYPE_OBJECT); G_DEFINE_TYPE (NMIPsecL2tpPppService, nm_ipsec_l2tp_ppp_service, G_TYPE_OBJECT);
static gboolean impl_ipsec_l2tp_service_need_secrets (NMIPsecL2tpPppService *self, static gboolean
char **out_username, handle_set_state (NMDBusNetworkManagerIpsec_l2tpPpp *object,
char **out_password, GDBusMethodInvocation *invocation,
GError **err); guint arg_state,
gpointer user_data);
static gboolean impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self,
guint32 state,
GError **err);
static gboolean impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, static gboolean
GHashTable *config, handle_need_secrets (NMDBusNetworkManagerIpsec_l2tpPpp *object,
GError **err); 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)) #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 { ...@@ -122,6 +126,9 @@ typedef struct {
char *username; char *username;
char *domain; char *domain;
char *password; char *password;
/* D-Bus stuff */
NMDBusNetworkManagerIpsec_l2tpPpp *dbus_skeleton;
} NMIPsecL2tpPppServicePrivate; } NMIPsecL2tpPppServicePrivate;
enum { enum {
...@@ -154,13 +161,13 @@ _service_cache_credentials (NMIPsecL2tpPppService *self, ...@@ -154,13 +161,13 @@ _service_cache_credentials (NMIPsecL2tpPppService *self,
GError **error) GError **error)
{ {
NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self); NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self);
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
const char *username, *password, *domain; const char *username, *password, *domain;
g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (connection != 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) { if (!s_vpn) {
return nm_ipsec_l2tp_error(error, "Could not load NetworkManager connection settings."); return nm_ipsec_l2tp_error(error, "Could not load NetworkManager connection settings.");
} }
...@@ -192,21 +199,67 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection, ...@@ -192,21 +199,67 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection,
GError **error) GError **error)
{ {
NMIPsecL2tpPppService *self = NULL; NMIPsecL2tpPppService *self = NULL;
DBusGConnection *bus; NMIPsecL2tpPppServicePrivate *priv;
DBusGProxy *proxy; GDBusConnection *bus;
gboolean success = FALSE; GDBusProxy *proxy;
guint result; GVariant *ret;
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
if (!bus) if (!bus)
return NULL; return NULL;
dbus_connection_set_change_sigpipe (TRUE); proxy = g_dbus_proxy_new_sync (bus,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
proxy = dbus_g_proxy_new_for_name (bus, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
"org.freedesktop.DBus", NULL,
"/org/freedesktop/DBus", "org.freedesktop.DBus",
"org.freedesktop.DBus"); "/org/freedesktop/DBus",
"org.freedesktop.DBus",
NULL, error);
g_assert(proxy); 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, if (dbus_g_proxy_call (proxy, "RequestName", error,
G_TYPE_STRING, NM_DBUS_SERVICE_IPSEC_L2TP_PPP, G_TYPE_STRING, NM_DBUS_SERVICE_IPSEC_L2TP_PPP,
G_TYPE_UINT, 0, G_TYPE_UINT, 0,
...@@ -222,6 +275,7 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection, ...@@ -222,6 +275,7 @@ nm_ipsec_l2tp_ppp_service_new (NMConnection *connection,
} }
g_object_unref (proxy); g_object_unref (proxy);
dbus_g_connection_unref (bus); dbus_g_connection_unref (bus);
*/
return self; return self;
} }
...@@ -230,6 +284,18 @@ nm_ipsec_l2tp_ppp_service_init (NMIPsecL2tpPppService *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 static void
finalize (GObject *object) finalize (GObject *object)
{ {
...@@ -242,6 +308,8 @@ finalize (GObject *object) ...@@ -242,6 +308,8 @@ finalize (GObject *object)
g_free (priv->password); g_free (priv->password);
} }
g_free (priv->domain); g_free (priv->domain);
G_OBJECT_CLASS (nm_ipsec_l2tp_ppp_service_parent_class)->finalize (object);
} }
static void static void
...@@ -252,6 +320,7 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class) ...@@ -252,6 +320,7 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class)
g_type_class_add_private (service_class, sizeof (NMIPsecL2tpPppServicePrivate)); g_type_class_add_private (service_class, sizeof (NMIPsecL2tpPppServicePrivate));
/* virtual methods */ /* virtual methods */
object_class->dispose = nm_ipsec_l2tp_ppp_service_dispose;
object_class->finalize = finalize; object_class->finalize = finalize;
/* Signals */ /* Signals */
...@@ -279,37 +348,47 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class) ...@@ -279,37 +348,47 @@ nm_ipsec_l2tp_ppp_service_class_init (NMIPsecL2tpPppServiceClass *service_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMIPsecL2tpPppServiceClass, ip4_config), G_STRUCT_OFFSET (NMIPsecL2tpPppServiceClass, ip4_config),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__POINTER, NULL,
G_TYPE_NONE, 1, G_TYPE_POINTER); G_TYPE_NONE, 1, G_TYPE_VARIANT);
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (service_class),
&dbus_glib_nm_ipsec_l2tp_pppd_service_object_info);
} }
static gboolean static gboolean
impl_ipsec_l2tp_service_need_secrets (NMIPsecL2tpPppService *self, handle_need_secrets (NMDBusNetworkManagerIpsec_l2tpPpp *object,
char **out_username, GDBusMethodInvocation *invocation,
char **out_password, gpointer user_data)
GError **error)
{ {
NMIPsecL2tpPppService *self = NM_IPSEC_L2TP_PPP_SERVICE (user_data);
NMIPsecL2tpPppServicePrivate *priv = NM_IPSEC_L2TP_PPP_SERVICE_GET_PRIVATE (self); 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); g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0);
if (!*priv->username || !*priv->password) { 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 */ /* Success */
if (priv->domain && *priv->domain) { if (priv->domain && *priv->domain)
*out_username = g_strdup_printf ("%s\\%s", priv->domain, priv->username); username = g_strdup_printf ("%s\\%s", priv->domain, priv->username);
} else { else
*out_username = g_strdup (priv->username); username = g_strdup (priv->username);
} password = g_strdup (priv->password);
*out_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; return TRUE;
} }
/*
static gboolean static gboolean
impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self, impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self,
guint32 pppd_state, guint32 pppd_state,
...@@ -319,17 +398,21 @@ impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self, ...@@ -319,17 +398,21 @@ impl_ipsec_l2tp_service_set_state (NMIPsecL2tpPppService *self,
g_signal_emit (G_OBJECT (self), signals[PPP_STATE], 0, pppd_state); g_signal_emit (G_OBJECT (self), signals[PPP_STATE], 0, pppd_state);
return TRUE; return TRUE;
} }
*/
static gboolean static gboolean
impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, handle_set_ip4_config (NMDBusNetworkManagerIpsec_l2tpPpp *object,
GHashTable *config_hash, GDBusMethodInvocation *invocation,
GError **err) 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_message (_("IPSec-L2TP service (IP Config Get) reply received."));
g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0); 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 */ /* 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; return TRUE;
} }
...@@ -339,7 +422,7 @@ impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self, ...@@ -339,7 +422,7 @@ impl_ipsec_l2tp_service_set_ip4_config (NMIPsecL2tpPppService *self,
/* The VPN plugin service */ /* 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 { typedef struct {
GPid pid_l2tpd; GPid pid_l2tpd;
...@@ -379,8 +462,6 @@ static ValidProperty valid_properties[] = { ...@@ -379,8 +462,6 @@ static ValidProperty valid_properties[] = {
{ NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE }, { NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NODEFLATE, 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_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_FAILURE, G_TYPE_UINT, FALSE },
{ NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, 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 }, { 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) ...@@ -561,7 +642,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data)
} }
static gboolean static gboolean
nm_ipsec_l2tp_properties_validate (NMSettingVPN *s_vpn, nm_ipsec_l2tp_properties_validate (NMSettingVpn *s_vpn,
GError **error) GError **error)
{ {
ValidateInfo info = { &valid_properties[0], error, FALSE }; ValidateInfo info = { &valid_properties[0], error, FALSE };
...@@ -596,7 +677,7 @@ nm_ipsec_l2tp_properties_validate (NMSettingVPN *s_vpn, ...@@ -596,7 +677,7 @@ nm_ipsec_l2tp_properties_validate (NMSettingVPN *s_vpn,
} }
static gboolean 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 }; ValidateInfo info = { &valid_secrets[0], error, FALSE };
...@@ -670,21 +751,19 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data) ...@@ -670,21 +751,19 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data)
case 16: case 16:
/* hangup */ /* hangup */
// FIXME: better failure reason // 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; break;
case 2: case 2:
/* Couldn't log in due to bad user/pass */ /* 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; break;
case 1: case 1:
/* Other error (couldn't bind to address, etc) */ /* 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; break;
default: default:
break; break;
} }
nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
} }
static inline const char * static inline const char *
...@@ -737,14 +816,14 @@ pppd_timed_out (gpointer user_data) ...@@ -737,14 +816,14 @@ pppd_timed_out (gpointer user_data)
NMIPSecL2tpPlugin *plugin = NM_IPSEC_L2TP_PLUGIN (user_data); NMIPSecL2tpPlugin *plugin = NM_IPSEC_L2TP_PLUGIN (user_data);
g_warning (_("pppd timeout. Looks like pppd didn't initialize our dbus module")); 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; return FALSE;
} }
static gboolean static gboolean
nm_ipsec_l2tp_resolve_gateway (NMIPSecL2tpPlugin *plugin, nm_ipsec_l2tp_resolve_gateway (NMIPSecL2tpPlugin *plugin,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
GError **error) GError **error)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
...@@ -885,7 +964,7 @@ nm_ipsec_l2tp_stop_ipsec(void) ...@@ -885,7 +964,7 @@ nm_ipsec_l2tp_stop_ipsec(void)
static gboolean static gboolean
nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin, nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
GError **error) GError **error)
{ {
// NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); // NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
...@@ -995,7 +1074,7 @@ nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin, ...@@ -995,7 +1074,7 @@ nm_ipsec_l2tp_start_ipsec(NMIPSecL2tpPlugin *plugin,
static gboolean static gboolean
nm_ipsec_l2tp_start_l2tpd_binary (NMIPSecL2tpPlugin *plugin, nm_ipsec_l2tp_start_l2tpd_binary (NMIPSecL2tpPlugin *plugin,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
GError **error) GError **error)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
...@@ -1071,8 +1150,6 @@ static PPPOpt ppp_options[] = { ...@@ -1071,8 +1150,6 @@ static PPPOpt ppp_options[] = {
{NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, "nobsdcomp\n"}, {NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, "nobsdcomp\n"},
{NM_IPSEC_L2TP_KEY_NODEFLATE, G_TYPE_BOOLEAN, "nodeflate\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_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} {NULL, G_TYPE_NONE, NULL}
}; };
...@@ -1123,7 +1200,7 @@ get_free_l2tp_port(void) ...@@ -1123,7 +1200,7 @@ get_free_l2tp_port(void)
static gboolean static gboolean
nm_ipsec_l2tp_config_write (NMIPSecL2tpPlugin *plugin, nm_ipsec_l2tp_config_write (NMIPSecL2tpPlugin *plugin,
NMSettingVPN *s_vpn, NMSettingVpn *s_vpn,
GError **error) GError **error)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
...@@ -1316,6 +1393,20 @@ remove_timeout_handler (NMIPSecL2tpPlugin *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 static void
service_plugin_alive_cb (NMIPsecL2tpPppService *service, service_plugin_alive_cb (NMIPsecL2tpPppService *service,
NMIPSecL2tpPlugin *plugin) NMIPSecL2tpPlugin *plugin)
...@@ -1328,28 +1419,26 @@ service_ppp_state_cb (NMIPsecL2tpPppService *service, ...@@ -1328,28 +1419,26 @@ service_ppp_state_cb (NMIPsecL2tpPppService *service,
guint32 ppp_state, guint32 ppp_state,
NMIPSecL2tpPlugin *plugin) NMIPSecL2tpPlugin *plugin)
{ {
NMVPNServiceState plugin_state = nm_vpn_plugin_get_state (NM_VPN_PLUGIN (plugin));
switch (ppp_state) { switch (ppp_state) {
case NM_PPP_STATUS_DEAD: case NM_PPP_STATUS_DEAD:
case NM_PPP_STATUS_DISCONNECT: case NM_PPP_STATUS_DISCONNECT:
if (plugin_state == NM_VPN_SERVICE_STATE_STARTED) nm_vpn_service_plugin_disconnect (NM_VPN_SERVICE_PLUGIN (plugin), NULL);
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);
break; break;
default: default:
break; break;
} }
} }
/*
static void static void
nm_gvalue_destroy (gpointer data) nm_gvalue_destroy (gpointer data)
{ {
g_value_unset ((GValue *) data); g_value_unset ((GValue *) data);
g_slice_free (GValue, data); g_slice_free (GValue, data);
} }
*/
/*
static GValue * static GValue *
nm_gvalue_dup (const GValue *value) nm_gvalue_dup (const GValue *value)
{ {
...@@ -1361,45 +1450,56 @@ nm_gvalue_dup (const GValue *value) ...@@ -1361,45 +1450,56 @@ nm_gvalue_dup (const GValue *value)
return value_dup; return value_dup;
} }
*/
/*
static void static void
copy_hash (gpointer key, gpointer value, gpointer user_data) copy_hash (gpointer key, gpointer value, gpointer user_data)
{ {
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), nm_gvalue_dup ((GValue *) value)); g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), nm_gvalue_dup ((GValue *) value));
} }
*/
static void static void
service_ip4_config_cb (NMIPsecL2tpPppService *service, service_ip4_config_cb (NMIPsecL2tpPppService *service,
GHashTable *config_hash, GVariant *config,
NMVPNPlugin *plugin) NMVpnServicePlugin *plugin)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (service);
GHashTable *hash; GVariantIter iter;
GValue *value; 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_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_hash_table_foreach (config_hash, copy_hash, hash); 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 /* Insert the external VPN gateway into the table, which the pppd plugin
* simply doesn't know about. * simply doesn't know about.
*/ */
value = g_slice_new0 (GValue); g_variant_builder_add (&builder, "{sv}", NM_IPSEC_L2TP_KEY_GATEWAY, g_variant_new_uint32 (priv->naddr));
g_value_init (value, G_TYPE_UINT); new_config = g_variant_builder_end (&builder);
g_value_set_uint (value, priv->naddr); g_variant_ref_sink (new_config);
g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_GATEWAY), value);
nm_vpn_plugin_set_ip4_config (plugin, hash);
g_hash_table_destroy (hash); nm_vpn_service_plugin_set_ip4_config (plugin, new_config);
g_variant_unref (new_config);
} }
static gboolean static gboolean
real_connect (NMVPNPlugin *plugin, real_connect (NMVpnServicePlugin *plugin,
NMConnection *connection, NMConnection *connection,
GError **error) GError **error)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
NMSettingVPN *s_vpn; NMSettingVpn *s_vpn;
const char *value; const char *value;
if (getenv ("NM_PPP_DUMP_CONNECTION") || debug) if (getenv ("NM_PPP_DUMP_CONNECTION") || debug)
...@@ -1461,18 +1561,18 @@ real_connect (NMVPNPlugin *plugin, ...@@ -1461,18 +1561,18 @@ real_connect (NMVPNPlugin *plugin,
} }
static gboolean static gboolean
real_need_secrets (NMVPNPlugin *plugin, real_need_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection, NMConnection *connection,
char **setting_name, const char **setting_name,
GError **error) GError **error)
{ {
NMSetting *s_vpn; NMSettingVpn *s_vpn;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; 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); 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); 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, ...@@ -1481,7 +1581,7 @@ real_need_secrets (NMVPNPlugin *plugin,
return FALSE; return FALSE;
/* Don't need the password if we already have one */ /* 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; return FALSE;
/* Otherwise we need a password */ /* Otherwise we need a password */
...@@ -1503,7 +1603,7 @@ ensure_killed (gpointer data) ...@@ -1503,7 +1603,7 @@ ensure_killed (gpointer data)
} }
static gboolean static gboolean
real_disconnect (NMVPNPlugin *plugin, real_disconnect (NMVpnServicePlugin *plugin,
GError **err) GError **err)
{ {
NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (plugin);
...@@ -1536,8 +1636,9 @@ real_disconnect (NMVPNPlugin *plugin, ...@@ -1536,8 +1636,9 @@ real_disconnect (NMVPNPlugin *plugin,
return TRUE; return TRUE;
} }
/*
static void 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); NMIPSecL2tpPluginPrivate *priv = NM_IPSEC_L2TP_PLUGIN_GET_PRIVATE (object);
...@@ -1564,6 +1665,7 @@ state_changed_cb (GObject *object, NMVPNServiceState state, gpointer user_data) ...@@ -1564,6 +1665,7 @@ state_changed_cb (GObject *object, NMVPNServiceState state, gpointer user_data)
break; break;
} }
} }
*/
static void static void
dispose (GObject *object) dispose (GObject *object)
...@@ -1591,7 +1693,7 @@ static void ...@@ -1591,7 +1693,7 @@ static void
nm_ipsec_l2tp_plugin_class_init (NMIPSecL2tpPluginClass *l2tp_class) nm_ipsec_l2tp_plugin_class_init (NMIPSecL2tpPluginClass *l2tp_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); g_type_class_add_private (object_class, sizeof (NMIPSecL2tpPluginPrivate));
...@@ -1606,13 +1708,16 @@ NMIPSecL2tpPlugin * ...@@ -1606,13 +1708,16 @@ NMIPSecL2tpPlugin *
nm_ipsec_l2tp_plugin_new (void) nm_ipsec_l2tp_plugin_new (void)
{ {
NMIPSecL2tpPlugin *plugin; 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; return plugin;
} }
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#define NM_IPSEC_L2TP_PLUGIN_H #define NM_IPSEC_L2TP_PLUGIN_H
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <NetworkManager.h>
#include <nm-vpn-plugin.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_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)) #define NM_IPSEC_L2TP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IPSEC_L2TP_PLUGIN, NMIPSecL2tpPlugin))
...@@ -34,66 +36,12 @@ ...@@ -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_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)) #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 { typedef struct {
NMVPNPlugin parent; NMVpnServicePlugin parent;
} NMIPSecL2tpPlugin; } NMIPSecL2tpPlugin;
typedef struct { typedef struct {
NMVPNPluginClass parent; NMVpnServicePluginClass parent;
} NMIPSecL2tpPluginClass; } NMIPSecL2tpPluginClass;
GType nm_ipsec_l2tp_plugin_get_type (void); GType nm_ipsec_l2tp_plugin_get_type (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment