[network-manager-openswan/lr/libnm: 2/6] properties: port the new plugin to libnm
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openswan/lr/libnm: 2/6] properties: port the new plugin to libnm
- Date: Thu, 16 Jul 2015 15:34:41 +0000 (UTC)
commit ccda96293f7149931c8eeb2fc7ab0f61843aabd0
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Wed Jul 15 18:45:39 2015 +0200
properties: port the new plugin to libnm
configure.ac | 2 +
properties/Makefile.am | 3 +-
properties/nm-openswan.c | 106 ++++++++++++++++++++++++++++++----------------
3 files changed, 74 insertions(+), 37 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5bb2c04..9fc96e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,8 @@ if ! test x"$ac_distver" = x""; then
AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string])
fi
+PKG_CHECK_MODULES(LIBNM, libnm >= 0.9.11)
+
NM_COMPILER_WARNINGS
AC_CONFIG_FILES([
diff --git a/properties/Makefile.am b/properties/Makefile.am
index db6226b..c2e5550 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -5,7 +5,7 @@ libnm_openswan_properties_new_la_CPPFLAGS = \
-DNM_OPENSWAN_NEW \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
- $(NM_CFLAGS) \
+ $(LIBNM_CFLAGS) \
-I$(top_srcdir)/src \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
@@ -19,6 +19,7 @@ libnm_openswan_properties_old_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(NM_CFLAGS) \
+ -I$(top_srcdir)/src \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DG_DISABLE_DEPRECATED \
diff --git a/properties/nm-openswan.c b/properties/nm-openswan.c
index caa512e..4ef49a2 100644
--- a/properties/nm-openswan.c
+++ b/properties/nm-openswan.c
@@ -34,11 +34,36 @@
#include <string.h>
#include <gtk/gtk.h>
+#ifdef NM_OPENSWAN_OLD
#include <nm-vpn-plugin-ui-interface.h>
#include <nm-setting-vpn.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
+// FIXME: Check what danw's NM_VPN_LIBNM_COMPAT does
+#define NMVpnEditorPluginInterface NMVpnPluginUiInterface
+#define NM_TYPE_VPN_EDITOR_PLUGIN NM_TYPE_VPN_PLUGIN_UI_INTERFACE
+#define NMVpnEditorInterface NMVpnPluginUiWidgetInterface
+#define NM_TYPE_VPN_EDITOR NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE
+#define NMSettingVpn NMSettingVPN
+#define NMVpnEditor NMVpnPluginUiWidgetInterface
+#define NMVpnEditorPlugin NMVpnPluginUiInterface
+#define NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE NM_VPN_PLUGIN_UI_CAPABILITY_NONE
+#define PROP_DESC NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC
+#define PROP_NAME NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME
+#define PROP_SERVICE NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE
+#define NM_VPN_EDITOR_PLUGIN_NAME NM_VPN_PLUGIN_UI_INTERFACE_NAME
+#define NM_VPN_EDITOR_PLUGIN_DESCRIPTION NM_VPN_PLUGIN_UI_INTERFACE_DESC
+#define NM_VPN_EDITOR_PLUGIN_SERVICE NM_VPN_PLUGIN_UI_INTERFACE_SERVICE
+#define get_editor ui_factory
+#define get_suggested_filename get_suggested_name
+#define nm_vpn_editor_plugin_factory nm_vpn_plugin_ui_factory
+#endif
+
+#ifdef NM_OPENSWAN_NEW
+#include <NetworkManager.h>
+#endif
+
#include "nm-openswan-service.h"
#include "nm-openswan.h"
@@ -56,18 +81,27 @@
/************** plugin class **************/
-static void openswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
+#ifdef NM_OPENSWAN_NEW
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_DESC,
+ PROP_SERVICE
+};
+#endif
+
+static void openswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (OpenswanPluginUi, openswan_plugin_ui, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
openswan_plugin_ui_interface_init))
/************** UI widget class **************/
-static void openswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
+static void openswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (OpenswanPluginUiWidget, openswan_plugin_ui_widget, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
openswan_plugin_ui_widget_interface_init))
#define OPENSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
OPENSWAN_TYPE_PLUGIN_UI_WIDGET, OpenswanPluginUiWidgetPrivate))
@@ -157,7 +191,7 @@ stuff_changed_cb (GtkWidget *widget, gpointer user_data)
static void
setup_password_widget (OpenswanPluginUiWidget *self,
const char *entry_name,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *secret_name,
gboolean new_connection)
{
@@ -248,7 +282,7 @@ pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data)
}
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;
@@ -264,7 +298,7 @@ secret_flags_to_pw_type (NMSettingVPN *s_vpn, const char *key)
static void
init_one_pw_combo (OpenswanPluginUiWidget *self,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *combo_name,
const char *secret_key,
const char *type_key,
@@ -336,7 +370,7 @@ init_plugin_ui (OpenswanPluginUiWidget *self,
GError **error)
{
OpenswanPluginUiWidgetPrivate *priv = OPENSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
- NMSettingVPN *s_vpn = NULL;
+ NMSettingVpn *s_vpn = NULL;
GtkWidget *widget;
const char *value = NULL;
@@ -443,7 +477,7 @@ init_plugin_ui (OpenswanPluginUiWidget *self,
}
static GObject *
-get_widget (NMVpnPluginUiWidgetInterface *iface)
+get_widget (NMVpnEditor *iface)
{
OpenswanPluginUiWidget *self = OPENSWAN_PLUGIN_UI_WIDGET (iface);
OpenswanPluginUiWidgetPrivate *priv = OPENSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
@@ -452,7 +486,7 @@ get_widget (NMVpnPluginUiWidgetInterface *iface)
}
static void
-save_one_password (NMSettingVPN *s_vpn,
+save_one_password (NMSettingVpn *s_vpn,
GtkBuilder *builder,
const char *entry_name,
const char *combo_name,
@@ -491,13 +525,13 @@ save_one_password (NMSettingVPN *s_vpn,
}
static gboolean
-update_connection (NMVpnPluginUiWidgetInterface *iface,
+update_connection (NMVpnEditor *iface,
NMConnection *connection,
GError **error)
{
OpenswanPluginUiWidget *self = OPENSWAN_PLUGIN_UI_WIDGET (iface);
OpenswanPluginUiWidgetPrivate *priv = OPENSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
GtkWidget *widget;
char *str;
@@ -569,19 +603,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;
OpenswanPluginUiWidgetPrivate *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 (OPENSWAN_TYPE_PLUGIN_UI_WIDGET, NULL));
+ object = g_object_new (OPENSWAN_TYPE_PLUGIN_UI_WIDGET, NULL);
if (!object) {
g_set_error (error, OPENSWAN_PLUGIN_UI_ERROR, 0, "could not create openswan object");
return NULL;
@@ -661,7 +695,7 @@ openswan_plugin_ui_widget_init (OpenswanPluginUiWidget *plugin)
}
static void
-openswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
+openswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class)
{
/* interface implementation */
iface_class->get_widget = get_widget;
@@ -669,13 +703,13 @@ openswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_cl
}
static guint32
-get_capabilities (NMVpnPluginUiInterface *iface)
+get_capabilities (NMVpnEditorPlugin *iface)
{
- return NM_VPN_PLUGIN_UI_CAPABILITY_NONE;
+ return NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE;
}
-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);
}
@@ -685,13 +719,13 @@ 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, OPENSWAN_PLUGIN_NAME);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
+ case PROP_DESC:
g_value_set_string (value, OPENSWAN_PLUGIN_DESC);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
+ case PROP_SERVICE:
g_value_set_string (value, OPENSWAN_PLUGIN_SERVICE);
break;
default:
@@ -708,16 +742,16 @@ openswan_plugin_ui_class_init (OpenswanPluginUiClass *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
@@ -726,19 +760,19 @@ openswan_plugin_ui_init (OpenswanPluginUi *plugin)
}
static void
-openswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
+openswan_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 = NULL;
iface_class->export_to_file = NULL;
- iface_class->get_suggested_name = NULL;
+ iface_class->get_suggested_filename = NULL;
}
-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);
@@ -746,6 +780,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 (OPENSWAN_TYPE_PLUGIN_UI, NULL));
+ return g_object_new (OPENSWAN_TYPE_PLUGIN_UI, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]