Commit 4f8d373c authored by Lubomir Rintel's avatar Lubomir Rintel

merge: port to libnm, libnma & gdbus

https://bugzilla.gnome.org/show_bug.cgi?id=749686
parents fc9c1458 9b5e8f4f
......@@ -9,9 +9,14 @@ endif
dbusservicedir = $(sysconfdir)/dbus-1/system.d
dbusservice_DATA = nm-pptp-service.conf
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN
nmvpnservicedir = $(NM_VPN_SERVICE_DIR)
nmvpnservice_DATA = nm-pptp-service.name
if WITH_LIBNM_GLIB
nmvpnoldservicedir = $(sysconfdir)/NetworkManager/VPN
nmvpnoldservice_DATA = nm-pptp-service.name
endif
nm-pptp-service.name: $(srcdir)/nm-pptp-service.name.in
sed -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' \
-e 's|[@]PLUGINDIR[@]|$(libdir)/NetworkManager|g' \
......
INCLUDES = -I${top_srcdir}
libexec_PROGRAMS = nm-pptp-auth-dialog
nm_pptp_auth_dialog_CPPFLAGS = \
$(NM_CFLAGS) \
$(LIBNM_CFLAGS) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(NMGTK_CFLAGS) \
$(LIBNMA_CFLAGS) \
$(LIBSECRET_CFLAGS) \
-I${top_srcdir} \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DBINDIR=\""$(bindir)"\" \
......@@ -18,9 +17,9 @@ nm_pptp_auth_dialog_SOURCES = \
main.c
nm_pptp_auth_dialog_LDADD = \
$(NM_LIBS) \
$(LIBNM_LIBS) \
$(GTK_LIBS) \
$(NMGTK_LIBS) \
$(LIBNMA_LIBS) \
$(LIBSECRET_LIBS)
CLEANFILES = *~
......@@ -34,9 +34,8 @@
#define SECRET_API_SUBJECT_TO_CHANGE
#include <libsecret/secret.h>
#include <nm-setting-vpn.h>
#include <nm-vpn-plugin-utils.h>
#include <nm-vpn-password-dialog.h>
#include <NetworkManager.h>
#include <nma-vpn-password-dialog.h>
#include "src/nm-pptp-service.h"
......@@ -271,13 +270,13 @@ main (int argc, char *argv[])
return 1;
}
if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) {
if (!nm_vpn_service_plugin_read_vpn_details (0, &data, &secrets)) {
fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n",
vpn_name, vpn_uuid);
return 1;
}
nm_vpn_plugin_utils_get_secret_flags (secrets, NM_PPTP_KEY_PASSWORD, &pw_flags);
nm_vpn_service_plugin_get_secret_flags (secrets, NM_PPTP_KEY_PASSWORD, &pw_flags);
if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode,
g_hash_table_lookup (secrets, NM_PPTP_KEY_PASSWORD),
......
......@@ -53,6 +53,8 @@ dnl GNOME support
dnl
AC_ARG_WITH(gnome, AS_HELP_STRING([--without-gnome], [Build NetworkManager-pptp without GNOME support, e.g. vpn service only]))
AM_CONDITIONAL(WITH_GNOME, test x"$with_gnome" != xno)
AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--without-libnm-glib], [Build NetworkManager-pptp without libnm-glib comatibility]))
AM_CONDITIONAL(WITH_LIBNM_GLIB, test x"$with_libnm_glib" != xno)
GETTEXT_PACKAGE=NetworkManager-pptp
AC_SUBST(GETTEXT_PACKAGE)
......@@ -61,26 +63,33 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
IT_PROG_INTLTOOL([0.35])
AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32)
# gio-unix will require glib and gio
PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32)
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74)
PKG_CHECK_MODULES(NM,
NetworkManager >= 0.9.10
libnm-util >= 0.9.10
libnm-glib >= 0.9.10
libnm-glib-vpn >= 0.9.10)
if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4)
GTK_CFLAGS="$GTK_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4"
PKG_CHECK_MODULES(NMGTK, libnm-gtk >= 0.9.10)
PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0)
PKG_CHECK_MODULES(LIBSECRET, libsecret-unstable)
if test x"$with_libnm_glib" != xno; then
PKG_CHECK_MODULES(LIBNM_GTK, libnm-gtk >= 0.9.10)
PKG_CHECK_MODULES(LIBNM_GLIB,
NetworkManager >= 1.1.0
libnm-glib >= 1.1.0
libnm-glib-vpn >= 1.1.0)
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
dnl
......
......@@ -3,6 +3,9 @@ name=pptp
service=org.freedesktop.NetworkManager.pptp
program=@LIBEXECDIR@/nm-pptp-service
[libnm]
plugin=@PLUGINDIR@/libnm-vpn-plugin-pptp.so
[GNOME]
auth-dialog=@LIBEXECDIR@/nm-pptp-auth-dialog
properties=@PLUGINDIR@/libnm-pptp-properties
......
plugindir = $(libdir)/NetworkManager
plugin_LTLIBRARIES = libnm-pptp-properties.la
plugin_LTLIBRARIES = libnm-vpn-plugin-pptp.la
if WITH_LIBNM_GLIB
plugin_LTLIBRARIES += libnm-pptp-properties.la
endif
INCLUDES = -I${top_srcdir}
AM_CPPFLAGS = -I${top_srcdir}
libnm_pptp_properties_la_SOURCES = \
libnm_vpn_plugin_pptp_la_SOURCES = \
nm-pptp.c \
nm-pptp.h \
advanced-dialog.c \
......@@ -11,29 +14,49 @@ libnm_pptp_properties_la_SOURCES = \
import-export.c \
import-export.h
libnm_pptp_properties_la_SOURCES = \
$(libnm_vpn_plugin_pptp_la_SOURCES)
uidir = $(datadir)/gnome-vpn-properties/pptp
ui_DATA = nm-pptp-dialog.ui
libnm_pptp_properties_la_CFLAGS = \
common_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(NM_CFLAGS) \
$(NMGTK_CFLAGS) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DLOCALEDIR=\""$(datadir)/locale"\" \
-DG_DISABLE_DEPRECATED \
-DVERSION=\"$(VERSION)\"
libnm_pptp_properties_la_LIBADD = \
$(GTK_LIBS) \
$(NM_LIBS) \
libnm_vpn_plugin_pptp_la_CFLAGS = \
$(common_CFLAGS) \
$(LIBNMA_CFLAGS) \
$(LIBNM_CFLAGS)
libnm_pptp_properties_la_CFLAGS = \
-DNM_PPTP_OLD \
$(common_CFLAGS) \
$(LIBNM_GLIB_CFLAGS) \
$(LIBNM_GTK_CFLAGS)
libnm_vpn_plugin_pptp_la_LIBADD = \
$(GTK_LIBS) \
$(LIBNMA_LIBS) \
$(LIBNM_LIBS)
libnm_pptp_properties_la_LIBADD = \
$(GTK_LIBS) \
$(NM_LIBS) \
$(NMGTK_LIBS)
libnm_pptp_properties_la_LDFLAGS = \
libnm_vpn_plugin_pptp_la_LDFLAGS = \
-avoid-version
libnm_pptp_properties_la_LDFLAGS = \
$(libnm_vpn_plugin_pptp_la_LDFLAGS)
CLEANFILES = *.bak *~
EXTRA_DIST = \
......
......@@ -35,12 +35,18 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#ifdef NM_PPTP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_PPTP_OLD */
#include <NetworkManager.h>
#endif
#include "advanced-dialog.h"
#include "nm-pptp.h"
#include "../src/nm-pptp-service.h"
#include "../src/nm-pptp-service-defines.h"
#define COL_NAME 0
#define COL_VALUE 1
......@@ -90,7 +96,7 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection,
GError **error)
{
GHashTable *hash;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
......
......@@ -34,13 +34,11 @@
#include <glib/gi18n-lib.h>
#include <nm-setting-vpn.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <NetworkManager.h>
#include "import-export.h"
#include "nm-pptp.h"
#include "../src/nm-pptp-service.h"
#include "../src/nm-pptp-service-defines.h"
NMConnection *
do_import (const char *path, char **lines, GError **error)
......
......@@ -34,12 +34,20 @@
#include <string.h>
#include <gtk/gtk.h>
#ifdef NM_PPTP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-vpn-plugin-ui-interface.h>
#include <nm-setting-vpn.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-ui-utils.h>
#else /* !NM_PPTP_OLD */
#include <NetworkManager.h>
#include <nma-ui-utils.h>
#endif
#include "nm-pptp-service-defines.h"
#include "nm-pptp.h"
#include "import-export.h"
......@@ -47,24 +55,23 @@
#define PPTP_PLUGIN_NAME _("Point-to-Point Tunneling Protocol (PPTP)")
#define PPTP_PLUGIN_DESC _("Compatible with Microsoft and other PPTP VPN servers.")
#define PPTP_PLUGIN_SERVICE NM_DBUS_SERVICE_PPTP
typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data);
/************** plugin class **************/
static void pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
static void pptp_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (PptpPluginUi, pptp_plugin_ui, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
pptp_plugin_ui_interface_init))
/************** UI widget class **************/
static void pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
static void pptp_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (PptpPluginUiWidget, pptp_plugin_ui_widget, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
pptp_plugin_ui_widget_interface_init))
#define PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PPTP_TYPE_PLUGIN_UI_WIDGET, PptpPluginUiWidgetPrivate))
......@@ -79,6 +86,14 @@ typedef struct {
gboolean new_connection;
} PptpPluginUiWidgetPrivate;
enum {
PROP_0,
PROP_NAME,
PROP_DESC,
PROP_SERVICE,
LAST_PROP
};
GQuark
pptp_plugin_ui_error_quark (void)
......@@ -210,7 +225,7 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
static void
setup_password_widget (PptpPluginUiWidget *self,
const char *entry_name,
NMSettingVPN *s_vpn,
NMSettingVpn *s_vpn,
const char *secret_name,
gboolean new_connection)
{
......@@ -256,7 +271,7 @@ password_storage_changed_cb (GObject *entry,
static void
init_password_icon (PptpPluginUiWidget *self,
NMSettingVPN *s_vpn,
NMSettingVpn *s_vpn,
const char *secret_key,
const char *entry_name)
{
......@@ -292,7 +307,7 @@ static gboolean
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
{
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
GtkWidget *widget;
const char *value;
......@@ -360,7 +375,7 @@ init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **err
}
static GObject *
get_widget (NMVpnPluginUiWidgetInterface *iface)
get_widget (NMVpnEditor *iface)
{
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
......@@ -371,13 +386,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface)
static void
hash_copy_advanced (gpointer key, gpointer data, gpointer user_data)
{
NMSettingVPN *s_vpn = NM_SETTING_VPN (user_data);
NMSettingVpn *s_vpn = NM_SETTING_VPN (user_data);
nm_setting_vpn_add_data_item (s_vpn, (const char *) key, (const char *) data);
}
static void
save_password_and_flags (NMSettingVPN *s_vpn,
save_password_and_flags (NMSettingVpn *s_vpn,
GtkBuilder *builder,
const char *entry_name,
const char *secret_key)
......@@ -407,13 +422,13 @@ save_password_and_flags (NMSettingVPN *s_vpn,
}
static gboolean
update_connection (NMVpnPluginUiWidgetInterface *iface,
update_connection (NMVpnEditor *iface,
NMConnection *connection,
GError **error)
{
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
GtkWidget *widget;
const char *str;
gboolean valid = FALSE;
......@@ -466,19 +481,19 @@ is_new_func (const char *key, const char *value, gpointer user_data)
*is_new = FALSE;
}
static NMVpnPluginUiWidgetInterface *
static NMVpnEditor *
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{
NMVpnPluginUiWidgetInterface *object;
NMVpnEditor *object;
PptpPluginUiWidgetPrivate *priv;
char *ui_file;
gboolean new = TRUE;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
if (error)
g_return_val_if_fail (*error == NULL, NULL);
object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI_WIDGET, NULL));
object = NM_VPN_EDITOR (g_object_new (PPTP_TYPE_PLUGIN_UI_WIDGET, NULL));
if (!object) {
g_set_error (error, PPTP_PLUGIN_UI_ERROR, 0, "could not create pptp object");
return NULL;
......@@ -578,7 +593,7 @@ pptp_plugin_ui_widget_init (PptpPluginUiWidget *plugin)
}
static void
pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
pptp_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class)
{
/* interface implementation */
iface_class->get_widget = get_widget;
......@@ -586,7 +601,7 @@ pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
}
static NMConnection *
import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
import (NMVpnEditorPlugin *iface, const char *path, GError **error)
{
NMConnection *connection = NULL;
char *contents = NULL;
......@@ -632,7 +647,7 @@ out:
}
static gboolean
export (NMVpnPluginUiInterface *iface,
export (NMVpnEditorPlugin *iface,
const char *path,
NMConnection *connection,
GError **error)
......@@ -641,7 +656,7 @@ export (NMVpnPluginUiInterface *iface,
}
static char *
get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
get_suggested_filename (NMVpnEditorPlugin *iface, NMConnection *connection)
{
NMSettingConnection *s_con;
const char *id;
......@@ -657,14 +672,14 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
return g_strdup_printf ("%s (pptp).conf", id);
}
static guint32
get_capabilities (NMVpnPluginUiInterface *iface)
static NMVpnEditorPluginCapability
get_capabilities (NMVpnEditorPlugin *iface)
{
return (NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT | NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT);
return (NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT | NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT);
}
static NMVpnPluginUiWidgetInterface *
ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error)
static NMVpnEditor *
get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error)
{
return nm_vpn_plugin_ui_widget_interface_new (connection, error);
}
......@@ -674,14 +689,14 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME:
case PROP_NAME:
g_value_set_string (value, PPTP_PLUGIN_NAME);
break;
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
case PROP_DESC:
g_value_set_string (value, PPTP_PLUGIN_DESC);
break;
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
g_value_set_string (value, PPTP_PLUGIN_SERVICE);
case PROP_SERVICE:
g_value_set_string (value, NM_DBUS_SERVICE_PPTP);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -697,16 +712,16 @@ pptp_plugin_ui_class_init (PptpPluginUiClass *req_class)
object_class->get_property = get_property;
g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME,
NM_VPN_PLUGIN_UI_INTERFACE_NAME);
PROP_NAME,
NM_VPN_EDITOR_PLUGIN_NAME);
g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
NM_VPN_PLUGIN_UI_INTERFACE_DESC);
PROP_DESC,
NM_VPN_EDITOR_PLUGIN_DESCRIPTION);
g_object_class_override_property (object_class,
NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE,
NM_VPN_PLUGIN_UI_INTERFACE_SERVICE);
PROP_SERVICE,
NM_VPN_EDITOR_PLUGIN_SERVICE);
}
static void
......@@ -715,19 +730,18 @@ pptp_plugin_ui_init (PptpPluginUi *plugin)
}
static void
pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
pptp_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class)
{
/* interface implementation */
iface_class->ui_factory = ui_factory;
iface_class->get_editor = get_editor;
iface_class->get_capabilities = get_capabilities;
iface_class->import_from_file = import;
iface_class->export_to_file = export;
iface_class->get_suggested_name = get_suggested_name;
iface_class->get_suggested_filename = get_suggested_filename;
}
G_MODULE_EXPORT NMVpnPluginUiInterface *
nm_vpn_plugin_ui_factory (GError **error)
G_MODULE_EXPORT NMVpnEditorPlugin *
nm_vpn_editor_plugin_factory (GError **error)
{
if (error)
g_return_val_if_fail (*error == NULL, NULL);
......@@ -735,6 +749,6 @@ nm_vpn_plugin_ui_factory (GError **error)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI, NULL));
return NM_VPN_EDITOR_PLUGIN (g_object_new (PPTP_TYPE_PLUGIN_UI, NULL));
}
INCLUDES = -I${top_srcdir}
AM_CPPFLAGS = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(NM_CFLAGS) \
$(LIBNM_CFLAGS) \
-I${top_srcdir} \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
......@@ -11,7 +9,7 @@ AM_CPPFLAGS = \
-DNM_VERSION="\"$(VERSION)\"" \
-DLIBDIR=\""$(libdir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DDATADIR=\"$(datadir)\" \
-DNM_PPTP_LOCALEDIR=\"$(datadir)/locale\" \
-DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
......@@ -23,13 +21,30 @@ nm_pptp_service_SOURCES = \
nm-pptp-service.c \
nm-pptp-service.h
nm-pptp-pppd-service-glue.h: $(top_srcdir)/src/nm-pptp-pppd-service.xml
dbus-binding-tool --prefix=nm_pptp_pppd_service --mode=glib-server --output=$@ $<
# D-Bus stuff
noinst_LTLIBRARIES = libnm-pptp-pppd-service-dbus.la
nodist_libnm_pptp_pppd_service_dbus_la_SOURCES = \
nm-pptp-pppd-service-dbus.c \
nm-pptp-pppd-service-dbus.h
libnm_pptp_pppd_service_dbus_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS))
nm-pptp-pppd-service-dbus.h: $(top_srcdir)/src/nm-pptp-pppd-service.xml
$(AM_V_GEN) gdbus-codegen \
--generate-c-code $(basename $@) \
--c-namespace NMDBus \
--interface-prefix org.freedesktop \
$<
nm-pptp-pppd-service-dbus.c:
@true
nm_pptp_service_LDADD = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(NM_LIBS)
$(LIBNM_LIBS) \
libnm-pptp-pppd-service-dbus.la
pppd_plugindir = $(PPPD_PLUGIN_DIR)
pppd_plugin_LTLIBRARIES = nm-pptp-pppd-plugin.la
......@@ -39,18 +54,16 @@ nm_pptp_pppd_plugin_la_SOURCES = \
nm-ppp-status.h
nm_pptp_pppd_plugin_la_CPPFLAGS = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(NM_CFLAGS)
$(LIBNM_CFLAGS)
nm_pptp_pppd_plugin_la_LDFLAGS = -module -avoid-version
nm_pptp_pppd_plugin_la_LIBADD = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(NM_LIBS)
$(LIBNM_LIBS)
BUILT_SOURCES = nm-pptp-pppd-service-glue.h
BUILT_SOURCES = nm-pptp-pppd-service-dbus.h nm-pptp-pppd-service-dbus.c
CLEANFILES = $(BUILT_SOURCES)
......
......@@ -27,20 +27,20 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dlfcn.h>
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <gio/gio.h>
#include "nm-pptp-service.h"
#include "nm-ppp-status.h"
#include <nm-utils.h>
#include <NetworkManager.h>
int plugin_init (void);
char pppd_version[] = VERSION;
static DBusGProxy *proxy = NULL;
static GDBusProxy *proxy = NULL;
static void
nm_phasechange (void *data, int arg)
......@@ -48,7 +48,7 @@ nm_phasechange (void *data, int arg)
NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
char *ppp_phase;
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
switch (arg) {
case PHASE_DEAD:
......@@ -115,126 +115,104 @@ nm_phasechange (void *data, int arg)
ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
dbus_g_proxy_call_no_reply (proxy, "SetState",
G_TYPE_UINT, ppp_status,
G_TYPE_INVALID,
G_TYPE_INVALID);
g_dbus_proxy_call (proxy,
"SetState",
g_variant_new ("(u)", ppp_status),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL,
NULL, NULL);
}
}
static GValue *
str_to_gvalue (const char *str)
{
GValue *val;
val = g_slice_new0 (GValue);
g_value_init (val, G_TYPE_STRING);
g_value_set_string (val, str);
return val;
}
static GValue *
uint_to_gvalue (guint32 i)
{
GValue *val;
val = g_slice_new0 (GValue);
g_value_init (val, G_TYPE_UINT);
g_value_set_uint (val, i);
return val;
}
static void
value_destroy (gpointer data)
{
GValue *val = (GValue *) data;
g_value_unset (val);
g_slice_free (GValue, val);
}
static void
nm_ip_up (void *data, int arg)
{
guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit);
ipcp_options opts = ipcp_gotoptions[0];
ipcp_options peer_opts = ipcp_hisoptions[0];
GHashTable *hash;
GArray *array;
GValue *val;
GVariantBuilder builder;
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
g_message ("nm-pptp-ppp-plugin: (%s): ip-up event", __func__);
if (!opts.ouraddr) {
g_warning ("nm-pptp-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__);
nm_phasechange (NULL, PHASE_DEAD);
return;
}
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, value_destroy);
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
g_variant_new_string (ifname));
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
str_to_gvalue (ifname));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS,
g_variant_new_uint32 (opts.ouraddr));
/* Prefer the peer options remote address first, _unless_ pppd made the
* address up, at which point prefer the local options remote address,
* and if that's not right, use the made-up address as a last resort.
*/
if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (peer_opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.hisaddr));
} else if (opts.hisaddr) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (opts.hisaddr));
} else if (peer_opts.hisaddr == pppd_made_up_address) {
/* As a last resort, use the made-up address */
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (peer_opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.ouraddr));
}
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS,
uint_to_gvalue (opts.ouraddr));
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, uint_to_gvalue (32));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PREFIX,