[network-manager-vpnc/lr/libnm: 1/10] properties: build separate libnm-based and libnm-glib-based plugins
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc/lr/libnm: 1/10] properties: build separate libnm-based and libnm-glib-based plugins
- Date: Mon, 17 Aug 2015 15:23:45 +0000 (UTC)
commit 71f54d24fd20c121d268ad6520a0d922b9c026bb
Author: Dan Winship <danw gnome org>
Date: Sun Nov 9 11:51:27 2014 -0500
properties: build separate libnm-based and libnm-glib-based plugins
Build two copies of the properties plugin, one against libnm-glib and
one against libnm, so we can support both libnm-based and
libnm-glib-based editors.
auth-dialog/Makefile.am | 8 +-
auth-dialog/main.c | 2 +-
configure.ac | 9 +-
nm-vpnc-service.name.in | 5 +-
properties/Makefile.am | 36 +++-
properties/nm-vpnc.c | 327 +++++++++++++++++----------------
properties/nm-vpnc.h | 55 +++----
properties/tests/Makefile.am | 10 +-
properties/tests/test-import-export.c | 2 +-
src/Makefile.am | 6 +-
10 files changed, 242 insertions(+), 218 deletions(-)
---
diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am
index 665fc26..cb5a5c8 100644
--- a/auth-dialog/Makefile.am
+++ b/auth-dialog/Makefile.am
@@ -1,10 +1,10 @@
libexec_PROGRAMS = nm-vpnc-auth-dialog
nm_vpnc_auth_dialog_CPPFLAGS = \
- $(NM_CFLAGS) \
+ $(LIBNM_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
- $(NMGTK_CFLAGS) \
+ $(LIBNM_GTK_CFLAGS) \
$(LIBSECRET_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DBINDIR=\""$(bindir)"\" \
@@ -18,8 +18,8 @@ nm_vpnc_auth_dialog_SOURCES = \
nm_vpnc_auth_dialog_LDADD = \
$(GTK_LIBS) \
- $(NM_LIBS) \
- $(NMGTK_LIBS) \
+ $(LIBNM_GLIB_LIBS) \
+ $(LIBNM_GTK_LIBS) \
$(LIBSECRET_LIBS)
@INTLTOOL_DESKTOP_RULE@
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index cbd6338..578e53b 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -38,7 +38,7 @@
#include <nm-vpn-plugin-utils.h>
#include <nm-vpn-password-dialog.h>
-#include "../src/nm-vpnc-service.h"
+#include "../src/nm-vpnc-service-defines.h"
#define KEYRING_UUID_TAG "connection-uuid"
#define KEYRING_SN_TAG "setting-name"
diff --git a/configure.ac b/configure.ac
index 219ab13..3098119 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,16 +66,21 @@ 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.9.0)
+ PKG_CHECK_MODULES(LIBNM_GTK, libnm-gtk >= 0.9.9.0)
+ PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0)
PKG_CHECK_MODULES(LIBSECRET, libsecret-unstable)
fi
-PKG_CHECK_MODULES(NM,
+PKG_CHECK_MODULES(LIBNM_GLIB,
NetworkManager >= 0.9.6
libnm-util >= 0.9.6
libnm-glib >= 0.9.6
libnm-glib-vpn >= 0.9.6)
+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_COMPILER_WARNINGS
dnl
diff --git a/nm-vpnc-service.name.in b/nm-vpnc-service.name.in
index ec15b94..4f72642 100644
--- a/nm-vpnc-service.name.in
+++ b/nm-vpnc-service.name.in
@@ -3,8 +3,11 @@ name=vpnc
service=org.freedesktop.NetworkManager.vpnc
program= LIBEXECDIR@/nm-vpnc-service
+[libnm]
+plugin= PLUGINDIR@/libnm-vpnc-properties
+
[GNOME]
auth-dialog= LIBEXECDIR@/nm-vpnc-auth-dialog
-properties= PLUGINDIR@/libnm-vpnc-properties
+properties= PLUGINDIR@/libnm-vpnc-properties-old
supports-external-ui-mode=true
supports-hints=true
diff --git a/properties/Makefile.am b/properties/Makefile.am
index c4de949..d5b24b2 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS=. tests
plugindir = $(libdir)/NetworkManager
-plugin_LTLIBRARIES = libnm-vpnc-properties.la
+plugin_LTLIBRARIES = libnm-vpnc-properties.la libnm-vpnc-properties-old.la
libnm_vpnc_properties_la_SOURCES = \
nm-vpnc.c \
@@ -9,28 +9,42 @@ libnm_vpnc_properties_la_SOURCES = \
nm-vpnc-helper.c \
nm-vpnc-helper.h
+libnm_vpnc_properties_old_la_SOURCES = \
+ $(libnm_vpnc_properties_la_SOURCES)
+
uidir = $(datadir)/gnome-vpn-properties/vpnc
ui_DATA = nm-vpnc-dialog.ui
-libnm_vpnc_properties_la_CPPFLAGS = \
+common_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
- $(NM_CFLAGS) \
- $(NMGTK_CFLAGS) \
- -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/ \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
- -DG_DISABLE_DEPRECATED \
-DLOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\"
-libnm_vpnc_properties_la_LIBADD = \
+libnm_vpnc_properties_la_CFLAGS = \
+ $(common_CFLAGS) \
+ $(LIBNM_CFLAGS) \
+ $(LIBNMA_CFLAGS)
+
+libnm_vpnc_properties_old_la_CFLAGS = \
+ -DNM_VPNC_OLD \
+ $(common_CFLAGS) \
+ $(LIBNM_GLIB_CFLAGS) \
+ $(LIBNM_GTK_CFLAGS)
+
+libnm_vpnc_properties_old_la_LIBADD = \
$(GTK_LIBS) \
- $(NM_LIBS) \
- $(NMGTK_LIBS)
+ $(LIBNM_GLIB_LIBS) \
+ $(LIBNM_GTK_LIBS)
+
+libnm_vpnc_properties_new_la_LDFLAGS = \
+ -avoid-version
-libnm_vpnc_properties_la_LDFLAGS = \
- -avoid-version
+libnm_vpnc_properties_old_la_LDFLAGS = \
+ $(libnm_vpnc_properties_new_la_LDFLAGS)
CLEANFILES = *.bak *~
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 38b63ea..2c6dc67 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -39,19 +39,48 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <nm-vpn-plugin-ui-interface.h>
+#ifdef NM_VPNC_OLD
#include <nm-setting-vpn.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-ui-utils.h>
-#include "nm-vpnc-service-defines.h"
-#include "nm-vpnc-helper.h"
-#include "nm-vpnc.h"
+#define NM_VPN_LIBNM_COMPAT
+#include <nm-vpn-plugin-ui-interface.h>
+
+#define NMSettingVpn NMSettingVPN
+#define nm_simple_connection_new() nm_connection_new ()
+
+#define NMSettingIPConfig NMSettingIP4Config
+#define NM_SETTING_IP_CONFIG(obj) NM_SETTING_IP4_CONFIG (obj)
+#define nm_setting_ip_config_get_num_routes nm_setting_ip4_config_get_num_routes
+#define nm_setting_ip_config_get_route nm_setting_ip4_config_get_route
+#define nm_setting_ip_config_add_route nm_setting_ip4_config_add_route
+#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
#define VPNC_PLUGIN_NAME _("Cisco Compatible VPN (vpnc)")
#define VPNC_PLUGIN_DESC _("Compatible with various Cisco, Juniper, Netscreen, and Sonicwall IPsec-based
VPN gateways.")
-#define VPNC_PLUGIN_SERVICE NM_DBUS_SERVICE_VPNC
+
+#define VPNC_PLUGIN_UI_ERROR NM_SETTING_VPN_ERROR
+#define VPNC_PLUGIN_UI_ERROR_FAILED NM_SETTING_VPN_ERROR_UNKNOWN
+#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
+
+#else /* !NM_VPNC_OLD */
+
+#include <NetworkManager.h>
+#include <nma-ui-utils.h>
+
+#define VPNC_PLUGIN_NAME _("vpnc")
+#define VPNC_PLUGIN_DESC _("Cisco Compatible VPN (vpnc)")
+
+#define VPNC_PLUGIN_UI_ERROR NM_CONNECTION_ERROR
+#define VPNC_PLUGIN_UI_ERROR_FAILED NM_CONNECTION_ERROR_FAILED
+#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
+#endif
+
+#include "nm-vpnc-service-defines.h"
+#include "nm-vpnc-helper.h"
+#include "nm-vpnc.h"
#define ENC_TYPE_SECURE 0
#define ENC_TYPE_WEAK 1
@@ -61,21 +90,28 @@
/************** plugin class **************/
-static void vpnc_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
+static void vpnc_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (VpncEditorPlugin, vpnc_editor_plugin, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
+ vpnc_editor_plugin_interface_init))
-G_DEFINE_TYPE_EXTENDED (VpncPluginUi, vpnc_plugin_ui, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
- vpnc_plugin_ui_interface_init))
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_DESC,
+ PROP_SERVICE
+};
-/************** UI widget class **************/
+/************** editor class **************/
-static void vpnc_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
+static void vpnc_editor_interface_init (NMVpnEditorInterface *iface);
-G_DEFINE_TYPE_EXTENDED (VpncPluginUiWidget, vpnc_plugin_ui_widget, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
- vpnc_plugin_ui_widget_interface_init))
+G_DEFINE_TYPE_EXTENDED (VpncEditor, vpnc_editor, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
+ vpnc_editor_interface_init))
-#define VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VPNC_TYPE_PLUGIN_UI_WIDGET,
VpncPluginUiWidgetPrivate))
+#define VPNC_EDITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VPNC_TYPE_EDITOR, VpncEditorPrivate))
typedef struct {
GtkBuilder *builder;
@@ -83,52 +119,13 @@ typedef struct {
GtkSizeGroup *group;
gint orig_dpd_timeout;
GtkWidget *advanced_dialog;
-} VpncPluginUiWidgetPrivate;
-
-
-#define VPNC_PLUGIN_UI_ERROR vpnc_plugin_ui_error_quark ()
-
-static GQuark
-vpnc_plugin_ui_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("vpnc-plugin-ui-error-quark");
-
- return error_quark;
-}
-
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-GType
-vpnc_plugin_ui_error_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] = {
- /* Unknown error. */
- ENUM_ENTRY (VPNC_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"),
- /* The specified property was invalid. */
- ENUM_ENTRY (VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"),
- /* The specified property was missing and is required. */
- ENUM_ENTRY (VPNC_PLUGIN_UI_ERROR_MISSING_PROPERTY, "MissingProperty"),
- /* The connection was missing invalid. */
- ENUM_ENTRY (VPNC_PLUGIN_UI_ERROR_INVALID_CONNECTION, "InvalidConnection"),
- { 0, 0, 0 }
- };
- etype = g_enum_register_static ("VpncPluginUiError", values);
- }
- return etype;
-}
+} VpncEditorPrivate;
static gboolean
-check_validity (VpncPluginUiWidget *self, GError **error)
+check_validity (VpncEditor *self, GError **error)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
GtkWidget *widget;
char *str;
@@ -158,13 +155,13 @@ check_validity (VpncPluginUiWidget *self, GError **error)
static void
stuff_changed_cb (GtkWidget *widget, gpointer user_data)
{
- g_signal_emit_by_name (VPNC_PLUGIN_UI_WIDGET (user_data), "changed");
+ g_signal_emit_by_name (VPNC_EDITOR (user_data), "changed");
}
static void
hybrid_toggled_cb (GtkWidget *widget, gpointer user_data)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (user_data);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (user_data);
gboolean enabled = FALSE;
GtkWidget *cafile_label, *ca_file_chooser;
@@ -190,13 +187,13 @@ spinbutton_changed_cb (GtkWidget *widget, gpointer user_data)
}
static void
-setup_password_widget (VpncPluginUiWidget *self,
+setup_password_widget (VpncEditor *self,
const char *entry_name,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *secret_name,
gboolean new_connection)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
GtkWidget *widget;
const char *value;
@@ -213,9 +210,9 @@ setup_password_widget (VpncPluginUiWidget *self,
}
static void
-show_toggled_cb (GtkCheckButton *button, VpncPluginUiWidget *self)
+show_toggled_cb (GtkCheckButton *button, VpncEditor *self)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
GtkWidget *widget;
gboolean visible;
@@ -235,13 +232,13 @@ password_storage_changed_cb (GObject *entry,
GParamSpec *pspec,
gpointer user_data)
{
- VpncPluginUiWidget *self = VPNC_PLUGIN_UI_WIDGET (user_data);
+ VpncEditor *self = VPNC_EDITOR (user_data);
stuff_changed_cb (NULL, self);
}
static const char *
-secret_flags_to_pw_type (NMSettingVPN *s_vpn, const char *key)
+secret_flags_to_pw_type (NMSettingVpn *s_vpn, const char *key)
{
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
@@ -256,13 +253,13 @@ secret_flags_to_pw_type (NMSettingVPN *s_vpn, const char *key)
}
static void
-init_password_icon (VpncPluginUiWidget *self,
- NMSettingVPN *s_vpn,
+init_password_icon (VpncEditor *self,
+ NMSettingVpn *s_vpn,
const char *secret_key,
const char *type_key,
const char *entry_name)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
GtkWidget *entry;
const char *value;
const char *flags = NULL;
@@ -293,7 +290,7 @@ init_password_icon (VpncPluginUiWidget *self,
static void
toggle_advanced_dialog_cb (GtkWidget *button, gpointer user_data)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (user_data);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (user_data);
GtkWidget *toplevel;
if (gtk_widget_get_visible (priv->advanced_dialog))
@@ -372,14 +369,14 @@ out:
}
static gboolean
-init_plugin_ui (VpncPluginUiWidget *self,
+init_plugin_ui (VpncEditor *self,
NMConnection *connection,
gboolean new_connection,
GError **error)
{
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
NMSettingConnection *s_con = NULL;
- NMSettingVPN *s_vpn = NULL;
+ NMSettingVpn *s_vpn = NULL;
GtkWidget *widget;
GtkListStore *store;
GtkTreeIter iter;
@@ -771,16 +768,16 @@ init_plugin_ui (VpncPluginUiWidget *self,
}
static GObject *
-get_widget (NMVpnPluginUiWidgetInterface *iface)
+get_widget (NMVpnEditor *editor)
{
- VpncPluginUiWidget *self = VPNC_PLUGIN_UI_WIDGET (iface);
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditor *self = VPNC_EDITOR (editor);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
return G_OBJECT (priv->widget);
}
static void
-save_one_password (NMSettingVPN *s_vpn,
+save_one_password (NMSettingVpn *s_vpn,
GtkBuilder *builder,
const char *entry_name,
const char *secret_key,
@@ -818,14 +815,14 @@ save_one_password (NMSettingVPN *s_vpn,
}
static gboolean
-update_connection (NMVpnPluginUiWidgetInterface *iface,
+update_connection (NMVpnEditor *editor,
NMConnection *connection,
GError **error)
{
- VpncPluginUiWidget *self = VPNC_PLUGIN_UI_WIDGET (iface);
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+ VpncEditor *self = VPNC_EDITOR (editor);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (self);
NMSettingConnection *s_con;
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
GtkWidget *widget;
char *str;
guint32 port;
@@ -984,25 +981,26 @@ is_new_func (const char *key, const char *value, gpointer user_data)
*is_new = FALSE;
}
-static NMVpnPluginUiWidgetInterface *
-nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
+static NMVpnEditor *
+nm_vpnc_editor_new (NMConnection *connection, GError **error)
{
- NMVpnPluginUiWidgetInterface *object;
- VpncPluginUiWidgetPrivate *priv;
+ NMVpnEditor *object;
+ VpncEditorPrivate *priv;
char *ui_file;
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
gboolean is_new = TRUE;
if (error)
g_return_val_if_fail (*error == NULL, NULL);
- object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (VPNC_TYPE_PLUGIN_UI_WIDGET, NULL));
+ object = g_object_new (VPNC_TYPE_EDITOR, NULL);
if (!object) {
- g_set_error (error, VPNC_PLUGIN_UI_ERROR, 0, "could not create vpnc object");
+ g_set_error (error, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
+ "could not create vpnc object");
return NULL;
}
- priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (object);
+ priv = VPNC_EDITOR_GET_PRIVATE (object);
ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-vpnc-dialog.ui");
priv->builder = gtk_builder_new ();
@@ -1013,7 +1011,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
g_warning ("Couldn't load builder file: %s",
error && *error ? (*error)->message : "(unknown)");
g_clear_error (error);
- g_set_error (error, VPNC_PLUGIN_UI_ERROR, 0,
+ g_set_error (error, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
"could not load required resources at %s", ui_file);
g_free (ui_file);
g_object_unref (object);
@@ -1023,7 +1021,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "vpnc-vbox"));
if (!priv->widget) {
- g_set_error (error, VPNC_PLUGIN_UI_ERROR, 0, "could not load UI widget");
+ g_set_error (error, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
+ "could not load UI widget");
g_object_unref (object);
return NULL;
}
@@ -1033,7 +1032,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
if (s_vpn)
nm_setting_vpn_foreach_data_item (s_vpn, is_new_func, &is_new);
- if (!init_plugin_ui (VPNC_PLUGIN_UI_WIDGET (object), connection, is_new, error)) {
+ if (!init_plugin_ui (VPNC_EDITOR (object), connection, is_new, error)) {
g_object_unref (object);
return NULL;
}
@@ -1044,18 +1043,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
static void
dispose (GObject *object)
{
- VpncPluginUiWidget *plugin = VPNC_PLUGIN_UI_WIDGET (object);
- VpncPluginUiWidgetPrivate *priv = VPNC_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin);
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry"));
- g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
- (GCallback) password_storage_changed_cb,
- plugin);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "group_password_entry"));
- g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
- (GCallback) password_storage_changed_cb,
- plugin);
+ VpncEditor *plugin = VPNC_EDITOR (object);
+ VpncEditorPrivate *priv = VPNC_EDITOR_GET_PRIVATE (plugin);
if (priv->group)
g_object_unref (priv->group);
@@ -1069,43 +1058,48 @@ dispose (GObject *object)
if (priv->builder)
g_object_unref (priv->builder);
- G_OBJECT_CLASS (vpnc_plugin_ui_widget_parent_class)->dispose (object);
+ G_OBJECT_CLASS (vpnc_editor_parent_class)->dispose (object);
}
static void
-vpnc_plugin_ui_widget_class_init (VpncPluginUiWidgetClass *req_class)
+vpnc_editor_class_init (VpncEditorClass *req_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
- g_type_class_add_private (req_class, sizeof (VpncPluginUiWidgetPrivate));
+ g_type_class_add_private (req_class, sizeof (VpncEditorPrivate));
object_class->dispose = dispose;
}
static void
-vpnc_plugin_ui_widget_init (VpncPluginUiWidget *plugin)
+vpnc_editor_init (VpncEditor *plugin)
{
}
static void
-vpnc_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
+vpnc_editor_interface_init (NMVpnEditorInterface *iface)
{
/* interface implementation */
- iface_class->get_widget = get_widget;
- iface_class->update_connection = update_connection;
+ iface->get_widget = get_widget;
+ iface->update_connection = update_connection;
}
static void
-add_routes (NMSettingIP4Config *s_ip4, const char *routelist)
+add_routes (NMSettingIPConfig *s_ip4, const char *routelist)
{
char **substrs;
unsigned int i;
substrs = g_strsplit (routelist, " ", 0);
for (i = 0; substrs[i] != NULL; i++) {
- struct in_addr tmp;
char *p, *str_route;
long int prefix = 32;
+#ifdef NM_VPNC_OLD
+ struct in_addr tmp;
+#else
+ NMIPRoute *route;
+ GError *error = NULL;
+#endif
str_route = g_strdup (substrs[i]);
p = strchr (str_route, '/');
@@ -1120,18 +1114,28 @@ add_routes (NMSettingIP4Config *s_ip4, const char *routelist)
g_warning ("Ignoring invalid route '%s'", str_route);
goto next;
}
-
- /* don't pass the prefix to inet_pton() */
*p = '\0';
+
+#ifdef NM_VPNC_OLD
if (inet_pton (AF_INET, str_route, &tmp) > 0) {
NMIP4Route *route = nm_ip4_route_new ();
nm_ip4_route_set_dest (route, tmp.s_addr);
nm_ip4_route_set_prefix (route, (guint32) prefix);
- nm_setting_ip4_config_add_route (s_ip4, route);
+ nm_setting_ip_config_add_route (s_ip4, route);
} else
g_warning ("Ignoring invalid route '%s'", str_route);
+#else
+ route = nm_ip_route_new (AF_INET, str_route, prefix, NULL, -1, &error);
+ if (route) {
+ nm_setting_ip_config_add_route (s_ip4, route);
+ nm_ip_route_unref (route);
+ } else {
+ g_warning ("Ignoring invalid route '%s': %s", str_route, error->message);
+ g_clear_error (&error);
+ }
+#endif
next:
g_free (str_route);
@@ -1264,16 +1268,16 @@ nm_vpnc_import_export_error_quark (void)
}
static NMConnection *
-import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
+import (NMVpnEditorPlugin *plugin, const char *path, GError **error)
{
NMConnection *connection = NULL;
NMSettingConnection *s_con;
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
GKeyFile *keyfile;
char *buf;
gboolean bool_value;
- NMSettingIP4Config *s_ip4;
+ NMSettingIPConfig *s_ip4;
gint val;
gboolean found;
@@ -1281,7 +1285,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
if (!g_key_file_load_from_file (keyfile, path, 0, error))
goto error;
- connection = nm_connection_new ();
+ connection = nm_simple_connection_new ();
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con));
@@ -1289,7 +1293,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, NM_DBUS_SERVICE_VPNC, NULL);
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
- s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
+ s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new ());
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
/* Interface Name */
@@ -1467,7 +1471,7 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
bool_value = key_file_get_boolean_helper (keyfile, "main", "EnableLocalLAN", NULL);
if (bool_value)
- g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, TRUE, NULL);
+ g_object_set (s_ip4, NM_SETTING_IP_CONFIG_NEVER_DEFAULT, TRUE, NULL);
buf = key_file_get_string_helper (keyfile, "main", "DHGroup", NULL);
if (buf) {
@@ -1527,14 +1531,14 @@ error:
}
static gboolean
-export (NMVpnPluginUiInterface *iface,
+export (NMVpnEditorPlugin *plugin,
const char *path,
NMConnection *connection,
GError **error)
{
NMSettingConnection *s_con;
- NMSettingIP4Config *s_ip4;
- NMSettingVPN *s_vpn;
+ NMSettingIPConfig *s_ip4;
+ NMSettingVpn *s_vpn;
FILE *f;
const char *value;
const char *gateway = NULL;
@@ -1659,20 +1663,29 @@ export (NMVpnPluginUiInterface *iface,
group_pw = nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_SECRET);
routes = g_string_new ("X-NM-Routes=");
- if (s_ip4 && nm_setting_ip4_config_get_num_routes (s_ip4)) {
+ if (s_ip4 && nm_setting_ip_config_get_num_routes (s_ip4)) {
int i;
- for (i = 0; i < nm_setting_ip4_config_get_num_routes (s_ip4); i++) {
- NMIP4Route *route = nm_setting_ip4_config_get_route (s_ip4, i);
+ for (i = 0; i < nm_setting_ip_config_get_num_routes (s_ip4); i++) {
+#ifdef NM_VPNC_OLD
+ NMIP4Route *route = nm_setting_ip_config_get_route (s_ip4, i);
char str_addr[INET_ADDRSTRLEN + 1];
struct in_addr num_addr;
+#else
+ NMIPRoute *route = nm_setting_ip_config_get_route (s_ip4, i);
+#endif
if (routes_count)
g_string_append_c (routes, ' ');
-
+#ifdef NM_VPNC_OLD
num_addr.s_addr = nm_ip4_route_get_dest (route);
if (inet_ntop (AF_INET, &num_addr, &str_addr[0], INET_ADDRSTRLEN + 1))
g_string_append_printf (routes, "%s/%d", str_addr, nm_ip4_route_get_prefix
(route));
+#else
+ g_string_append_printf (routes, "%s/%d",
+ nm_ip_route_get_dest (route),
+ nm_ip_route_get_prefix (route));
+#endif
routes_count++;
}
@@ -1763,7 +1776,7 @@ done:
}
static char *
-get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
+get_suggested_filename (NMVpnEditorPlugin *plugin, NMConnection *connection)
{
NMSettingConnection *s_con;
const char *id;
@@ -1780,15 +1793,15 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
}
static guint32
-get_capabilities (NMVpnPluginUiInterface *iface)
+get_capabilities (NMVpnEditorPlugin *plugin)
{
- 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 *plugin, NMConnection *connection, GError **error)
{
- return nm_vpn_plugin_ui_widget_interface_new (connection, error);
+ return nm_vpnc_editor_new (connection, error);
}
static void
@@ -1796,14 +1809,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, VPNC_PLUGIN_NAME);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
+ case PROP_DESC:
g_value_set_string (value, VPNC_PLUGIN_DESC);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
- g_value_set_string (value, VPNC_PLUGIN_SERVICE);
+ case PROP_SERVICE:
+ g_value_set_string (value, NM_DBUS_SERVICE_VPNC);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1812,44 +1825,44 @@ get_property (GObject *object, guint prop_id,
}
static void
-vpnc_plugin_ui_class_init (VpncPluginUiClass *req_class)
+vpnc_editor_plugin_class_init (VpncEditorPluginClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (req_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
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
-vpnc_plugin_ui_init (VpncPluginUi *plugin)
+vpnc_editor_plugin_init (VpncEditorPlugin *plugin)
{
}
static void
-vpnc_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
+vpnc_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface)
{
/* interface implementation */
- iface_class->ui_factory = ui_factory;
- 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->get_editor = get_editor;
+ iface->get_capabilities = get_capabilities;
+ iface->import_from_file = import;
+ iface->export_to_file = export;
+ iface->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);
@@ -1857,6 +1870,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 (VPNC_TYPE_PLUGIN_UI, NULL));
+ return g_object_new (VPNC_TYPE_EDITOR_PLUGIN, NULL);
}
diff --git a/properties/nm-vpnc.h b/properties/nm-vpnc.h
index 39b75c4..6ffd148 100644
--- a/properties/nm-vpnc.h
+++ b/properties/nm-vpnc.h
@@ -25,57 +25,46 @@
#include <glib-object.h>
-typedef enum
-{
- VPNC_PLUGIN_UI_ERROR_UNKNOWN = 0,
- VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY,
- VPNC_PLUGIN_UI_ERROR_MISSING_PROPERTY,
- VPNC_PLUGIN_UI_ERROR_INVALID_CONNECTION
-} VpncPluginUiError;
+#define VPNC_TYPE_EDITOR_PLUGIN (vpnc_editor_plugin_get_type ())
+#define VPNC_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VPNC_TYPE_EDITOR_PLUGIN,
VpncEditorPlugin))
+#define VPNC_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VPNC_TYPE_EDITOR_PLUGIN,
VpncEditorPluginClass))
+#define VPNC_IS_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VPNC_TYPE_EDITOR_PLUGIN))
+#define VPNC_IS_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VPNC_TYPE_EDITOR_PLUGIN))
+#define VPNC_EDITOR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VPNC_TYPE_EDITOR_PLUGIN,
VpncEditorPluginClass))
-#define VPNC_TYPE_PLUGIN_UI_ERROR (vpnc_plugin_ui_error_get_type ())
-GType vpnc_plugin_ui_error_get_type (void);
+typedef struct _VpncEditorPlugin VpncEditorPlugin;
+typedef struct _VpncEditorPluginClass VpncEditorPluginClass;
-#define VPNC_TYPE_PLUGIN_UI (vpnc_plugin_ui_get_type ())
-#define VPNC_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VPNC_TYPE_PLUGIN_UI,
VpncPluginUi))
-#define VPNC_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VPNC_TYPE_PLUGIN_UI,
VpncPluginUiClass))
-#define VPNC_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VPNC_TYPE_PLUGIN_UI))
-#define VPNC_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VPNC_TYPE_PLUGIN_UI))
-#define VPNC_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VPNC_TYPE_PLUGIN_UI,
VpncPluginUiClass))
-
-typedef struct _VpncPluginUi VpncPluginUi;
-typedef struct _VpncPluginUiClass VpncPluginUiClass;
-
-struct _VpncPluginUi {
+struct _VpncEditorPlugin {
GObject parent;
};
-struct _VpncPluginUiClass {
+struct _VpncEditorPluginClass {
GObjectClass parent;
};
-GType vpnc_plugin_ui_get_type (void);
+GType vpnc_editor_plugin_get_type (void);
-#define VPNC_TYPE_PLUGIN_UI_WIDGET (vpnc_plugin_ui_widget_get_type ())
-#define VPNC_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
VPNC_TYPE_PLUGIN_UI_WIDGET, VpncPluginUiWidget))
-#define VPNC_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VPNC_TYPE_PLUGIN_UI_WIDGET,
VpncPluginUiWidgetClass))
-#define VPNC_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
VPNC_TYPE_PLUGIN_UI_WIDGET))
-#define VPNC_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VPNC_TYPE_PLUGIN_UI_WIDGET))
-#define VPNC_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VPNC_TYPE_PLUGIN_UI_WIDGET,
VpncPluginUiWidgetClass))
+#define VPNC_TYPE_EDITOR (vpnc_editor_get_type ())
+#define VPNC_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VPNC_TYPE_EDITOR, VpncEditor))
+#define VPNC_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VPNC_TYPE_EDITOR, VpncEditorClass))
+#define VPNC_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VPNC_TYPE_EDITOR))
+#define VPNC_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VPNC_TYPE_EDITOR))
+#define VPNC_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VPNC_TYPE_EDITOR, VpncEditorClass))
-typedef struct _VpncPluginUiWidget VpncPluginUiWidget;
-typedef struct _VpncPluginUiWidgetClass VpncPluginUiWidgetClass;
+typedef struct _VpncEditor VpncEditor;
+typedef struct _VpncEditorClass VpncEditorClass;
-struct _VpncPluginUiWidget {
+struct _VpncEditor {
GObject parent;
};
-struct _VpncPluginUiWidgetClass {
+struct _VpncEditorClass {
GObjectClass parent;
};
-GType vpnc_plugin_ui_widget_get_type (void);
+GType vpnc_editor_get_type (void);
#endif /* _NM_VPNC_H_ */
diff --git a/properties/tests/Makefile.am b/properties/tests/Makefile.am
index d2d43f6..d2a7930 100644
--- a/properties/tests/Makefile.am
+++ b/properties/tests/Makefile.am
@@ -8,17 +8,17 @@ test_import_export_SOURCES = \
test_import_export_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
- $(NM_CFLAGS) \
- $(NMGTK_CFLAGS) \
+ $(LIBNM_GLIB_CFLAGS) \
+ $(LIBNM_GTK_CFLAGS) \
$(DBUS_CFLAGS)
test_import_export_LDADD = \
$(GTHREAD_LIBS) \
$(GTK_LIBS) \
$(DBUS_LIBS) \
- $(NM_LIBS) \
- $(NMGTK_LIBS) \
- $(top_builddir)/properties/libnm-vpnc-properties.la
+ $(LIBNM_GLIB_LIBS) \
+ $(LIBNM_GTK_LIBS) \
+ $(top_builddir)/properties/libnm-vpnc-properties-old.la
if WITH_TESTS
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 82fcb73..1c0bd84 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -35,7 +35,7 @@
#include "../../nm-test-helpers.h"
#include "../../properties/nm-vpnc.h"
-#include "../../src/nm-vpnc-service.h"
+#include "../../src/nm-vpnc-service-defines.h"
#include "../../properties/nm-vpnc-helper.h"
typedef struct {
diff --git a/src/Makefile.am b/src/Makefile.am
index 4e2976e..267c21c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
- $(NM_CFLAGS) \
+ $(LIBNM_GLIB_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
@@ -25,7 +25,7 @@ nm_vpnc_service_SOURCES = \
nm_vpnc_service_LDADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
- $(NM_LIBS)
+ $(LIBNM_GLIB_LIBS)
nm_vpnc_service_vpnc_helper_SOURCES = \
@@ -34,7 +34,7 @@ nm_vpnc_service_vpnc_helper_SOURCES = \
nm_vpnc_service_vpnc_helper_LDADD = \
$(DBUS_LIBS) \
$(GTHREAD_LIBS) \
- $(NM_LIBS)
+ $(LIBNM_GLIB_LIBS)
noinst_PROGRAMS = test-vpnc-output
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]