summarylogtreecommitdiffstats
path: root/0006-nm-port-to-libnm.patch
blob: 75608bac501c7ef79e03e2850b07f14136a5d7db (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
From 0195709af106f66bd74a6f379580ffbc8076d514 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Wed, 21 Oct 2015 11:23:57 +0200
Subject: [PATCH 06/10] nm: port to libnm

---
 auth-dialog/Makefile.am       |  4 +--
 auth-dialog/main.c            |  9 +++---
 configure.ac                  |  2 +-
 nm-strongswan-service.name.in |  3 ++
 properties/Makefile.am        |  4 +--
 properties/nm-strongswan.c    | 73 +++++++++++++++++++++++++------------------
 6 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am
index 34f9d6b..1ebef22 100644
--- a/auth-dialog/Makefile.am
+++ b/auth-dialog/Makefile.am
@@ -4,7 +4,7 @@ nm_strongswan_auth_dialog_CPPFLAGS = \
 	$(GTK_CFLAGS) \
 	$(LIBGNOMEUI_CFLAGS) \
 	$(GNOMEKEYRING_CFLAGS) \
-	$(LIBNM_GLIB_CFLAGS) \
+	$(LIBNM_CFLAGS) \
 	-DG_DISABLE_DEPRECATED \
 	-DGNOME_DISABLE_DEPRECATED \
 	-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
@@ -17,5 +17,5 @@ nm_strongswan_auth_dialog_LDADD = \
 	$(GTK_LIBS) \
 	$(LIBGNOMEUI_LIBS) \
 	$(GNOMEKEYRING_LIBS) \
-	$(LIBNM_GLIB_LIBS)
+	$(LIBNM_LIBS)
 
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index b9fd886..f579fc5 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -24,10 +24,9 @@
 #include <gtk/gtk.h>
 #include <gnome-keyring.h>
 #include <libgnomeui/libgnomeui.h>
-#include <nm-vpn-plugin.h>
-#include <nm-setting-vpn.h>
-#include <nm-setting-connection.h>
-#include <nm-vpn-plugin-utils.h>
+
+#include <NetworkManager.h>
+#include <nm-vpn-service-plugin.h>
 
 #define NM_DBUS_SERVICE_STRONGSWAN	"org.freedesktop.NetworkManager.strongswan"
 
@@ -95,7 +94,7 @@ static char* get_connection_type(char *uuid)
 	GHashTable *data = NULL, *secrets = NULL;
 	char *method;
 
-	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 data and secrets from stdin.\n");
 		return NULL;
 	}
diff --git a/configure.ac b/configure.ac
index 70fb42e..4a16c5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,7 @@ AM_GLIB_GNU_GETTEXT
 PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6)
 PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
 PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
-PKG_CHECK_MODULES(LIBNM_GLIB, NetworkManager >= 0.9.0 libnm-util libnm-glib libnm-glib-vpn)
+PKG_CHECK_MODULES(LIBNM_GLIB, NetworkManager >= 1.1.0 libnm-util libnm-glib libnm-glib-vpn)
 
 PKG_CHECK_MODULES(LIBNM, libnm >= 1.1.0)
 LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2"
diff --git a/nm-strongswan-service.name.in b/nm-strongswan-service.name.in
index ca45ff2..a2f71a9 100644
--- a/nm-strongswan-service.name.in
+++ b/nm-strongswan-service.name.in
@@ -3,6 +3,9 @@ name=strongswan
 service=org.freedesktop.NetworkManager.strongswan
 program=@CHARON@
 
+[libnm]
+plugin=@PLUGINDIR@/libnm-vpn-plugin-strongswan.so
+
 [GNOME]
 auth-dialog=@LIBEXECDIR@/nm-strongswan-auth-dialog
 properties=@PLUGINDIR@/libnm-strongswan-properties
diff --git a/properties/Makefile.am b/properties/Makefile.am
index 2a113c7..116e722 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -19,7 +19,7 @@ common_CFLAGS = \
 	-DGDK_DISABLE_DEPRECATED
 
 libnm_vpn_plugin_strongswan_la_CFLAGS = \
-	$(LIBNM_GLIB_CFLAGS) \
+	$(LIBNM_CFLAGS) \
 	$(common_CFLAGS)
 
 libnm_strongswan_properties_la_CFLAGS = \
@@ -29,7 +29,7 @@ libnm_strongswan_properties_la_CFLAGS = \
 
 libnm_vpn_plugin_strongswan_la_LIBADD = \
 	$(GTK_LIBS) \
-	$(LIBNM_GLIB_LIBS)
+	$(LIBNM_LIBS)
 
 libnm_strongswan_properties_la_LIBADD = \
 	$(GTK_LIBS) \
diff --git a/properties/nm-strongswan.c b/properties/nm-strongswan.c
index 4cf6864..6c59fa7 100644
--- a/properties/nm-strongswan.c
+++ b/properties/nm-strongswan.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2015 Lubomir Rintel
  * Copyright (C) 2013 Tobias Brunner
  * Copyright (C) 2008 Martin Willi
  * Hochschule fuer Technik Rapperswil
@@ -26,11 +27,14 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
-#define NM_VPN_API_SUBJECT_TO_CHANGE
-
+#ifdef NM_STRONGSWAN_OLD
+#define NM_VPN_LIBNM_COMPAT
 #include <nm-vpn-plugin-ui-interface.h>
 #include <nm-setting-vpn.h>
 #include <nm-setting-connection.h>
+#else
+#include <NetworkManager.h>
+#endif
 
 #include "nm-strongswan.h"
 
@@ -41,18 +45,25 @@
 
 /************** plugin class **************/
 
-static void strongswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
+enum {
+	PROP_0,
+	PROP_NAME,
+	PROP_DESC,
+	PROP_SERVICE
+};
+
+static void strongswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class);
 
 G_DEFINE_TYPE_EXTENDED (StrongswanPluginUi, strongswan_plugin_ui, G_TYPE_OBJECT, 0,
-						G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
+						G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
 											   strongswan_plugin_ui_interface_init))
 
 /************** UI widget class **************/
 
-static void strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
+static void strongswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class);
 
 G_DEFINE_TYPE_EXTENDED (StrongswanPluginUiWidget, strongswan_plugin_ui_widget, G_TYPE_OBJECT, 0,
-						G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
+						G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
 											   strongswan_plugin_ui_widget_interface_init))
 
 #define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetPrivate))
@@ -178,7 +189,7 @@ static gboolean
 init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError **error)
 {
 	StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
-	NMSettingVPN *settings;
+	NMSettingVpn *settings;
 	GtkWidget *widget;
 	const char *value;
 
@@ -281,7 +292,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
 }
 
 static GObject *
-get_widget (NMVpnPluginUiWidgetInterface *iface)
+get_widget (NMVpnEditor *iface)
 {
 	StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (iface);
 	StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
@@ -290,13 +301,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface)
 }
 
 static gboolean
-update_connection (NMVpnPluginUiWidgetInterface *iface,
+update_connection (NMVpnEditor *iface,
 				   NMConnection *connection,
 				   GError **error)
 {
 	StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (iface);
 	StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
-	NMSettingVPN *settings;
+	NMSettingVpn *settings;
 	GtkWidget *widget;
 	gboolean active;
 	char *str;
@@ -386,17 +397,17 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 	return TRUE;
 }
 
-static NMVpnPluginUiWidgetInterface *
+static NMVpnEditor *
 nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
 {
-	NMVpnPluginUiWidgetInterface *object;
+	NMVpnEditor *object;
 	StrongswanPluginUiWidgetPrivate *priv;
 	char *ui_file;
 
 	if (error)
 		g_return_val_if_fail (*error == NULL, NULL);
 
-	object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, NULL));
+	object = g_object_new (STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, NULL);
 	if (!object) {
 		g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, "could not create strongswan object");
 		return NULL;
@@ -467,7 +478,7 @@ strongswan_plugin_ui_widget_init (StrongswanPluginUiWidget *plugin)
 }
 
 static void
-strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
+strongswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class)
 {
 	/* interface implementation */
 	iface_class->get_widget = get_widget;
@@ -475,13 +486,13 @@ strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_
 }
 
 static guint32
-get_capabilities (NMVpnPluginUiInterface *iface)
+get_capabilities (NMVpnEditorPlugin *iface)
 {
 	return 0;
 }
 
-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);
 }
@@ -491,13 +502,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, STRONGSWAN_PLUGIN_NAME);
 		break;
-	case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
+	case PROP_DESC:
 		g_value_set_string (value, STRONGSWAN_PLUGIN_DESC);
 		break;
-	case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
+	case PROP_SERVICE:
 		g_value_set_string (value, STRONGSWAN_PLUGIN_SERVICE);
 		break;
 	default:
@@ -514,16 +525,16 @@ strongswan_plugin_ui_class_init (StrongswanPluginUiClass *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
@@ -532,20 +543,20 @@ strongswan_plugin_ui_init (StrongswanPluginUi *plugin)
 }
 
 static void
-strongswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
+strongswan_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;
 	/* TODO: implement delete_connection to purge associated secrets */
 }
 
 
-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);
 
-	return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (STRONGSWAN_TYPE_PLUGIN_UI, NULL));
+	return g_object_new (STRONGSWAN_TYPE_PLUGIN_UI, NULL);
 }
-- 
2.4.3