[network-manager-vpnc/th/vpn-editor-split-bgo766170: 16/19] properties: split GTK dependent editor plugin



commit 7ea0f057d9706dae793a4968e2d6ffe35c408402
Author: Thomas Haller <thaller redhat com>
Date:   Mon May 9 13:06:28 2016 +0200

    properties: split GTK dependent editor plugin

 Makefile.am                                 |    4 +-
 properties/Makefile.am                      |   59 +++++++++++++++++++++------
 properties/libnm-vpn-plugin-vpnc-editor.ver |    6 +++
 properties/nm-vpnc-editor-plugin.c          |   49 ++++++++++++++++++-----
 properties/nm-vpnc-editor-plugin.h          |    8 ++++
 properties/nm-vpnc-editor.c                 |   17 ++++++++
 6 files changed, 118 insertions(+), 25 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6ae251b..6285613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = shared src
+SUBDIRS = shared src properties
 
 if WITH_GNOME
-SUBDIRS += auth-dialog properties po
+SUBDIRS += auth-dialog po
 endif
 
 dbusservicedir = $(sysconfdir)/dbus-1/system.d
diff --git a/properties/Makefile.am b/properties/Makefile.am
index 07e4f41..ace0feb 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -2,54 +2,86 @@ SUBDIRS=. tests
 
 plugindir = $(libdir)/NetworkManager
 plugin_LTLIBRARIES = libnm-vpn-plugin-vpnc.la
+if WITH_GNOME
+plugin_LTLIBRARIES += libnm-vpn-plugin-vpnc-editor.la
 if WITH_LIBNM_GLIB
 plugin_LTLIBRARIES += libnm-vpnc-properties.la
 endif
+endif
+
+plugin_sources = \
+    nm-vpnc-helper.c \
+    nm-vpnc-helper.h \
+    nm-vpnc-editor-plugin.c \
+    nm-vpnc-editor-plugin.h
+
+editor_sources = \
+    nm-vpnc-editor.c \
+    nm-vpnc-editor.h
 
 uidir = $(datadir)/gnome-vpn-properties/vpnc
+if WITH_GNOME
 ui_DATA = nm-vpnc-dialog.ui
+endif
 
 common_CFLAGS = \
     $(GLIB_CFLAGS) \
-    $(GTK_CFLAGS) \
     -I"$(top_srcdir)/shared/" \
     -DICONDIR=\""$(datadir)/pixmaps"\" \
     -DUIDIR=\""$(uidir)"\" \
-    -DLOCALEDIR=\"$(datadir)/locale\" \
-    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB
+    -DLOCALEDIR=\"$(datadir)/locale\"
 
 ###############################################################################
 
 libnm_vpn_plugin_vpnc_la_SOURCES = \
-    nm-vpnc-editor-plugin.c \
-    nm-vpnc-editor-plugin.h \
-    nm-vpnc-editor.c \
-    nm-vpnc-editor.h \
-    nm-vpnc-helper.c \
-    nm-vpnc-helper.h
+    $(plugin_sources)
 
 libnm_vpn_plugin_vpnc_la_CFLAGS = \
+    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE \
+    -DNM_PLUGIN_DIR=\"$(NM_PLUGIN_DIR)\" \
+    $(common_CFLAGS) \
+    $(LIBNM_CFLAGS)
+
+libnm_vpn_plugin_vpnc_la_LIBADD = \
+    $(LIBNM_LIBS) \
+    $(top_builddir)/shared/libnm-vpn-editor-utils-shared.la
+
+libnm_vpn_plugin_vpnc_la_LDFLAGS = \
+    -avoid-version \
+    -Wl,--version-script=$(srcdir)/libnm-vpn-plugin-vpnc.ver
+
+###############################################################################
+
+libnm_vpn_plugin_vpnc_editor_la_SOURCES = \
+    $(editor_sources)
+
+libnm_vpn_plugin_vpnc_editor_la_CFLAGS = \
+    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR \
     $(common_CFLAGS) \
+    $(GTK_CFLAGS) \
     $(LIBNM_CFLAGS) \
     $(LIBNMA_CFLAGS)
 
-libnm_vpn_plugin_vpnc_la_LIBADD = \
+libnm_vpn_plugin_vpnc_editor_la_LIBADD = \
     $(GTK_LIBS) \
     $(LIBNM_LIBS) \
     $(LIBNMA_LIBS)
 
-libnm_vpn_plugin_vpnc_la_LDFLAGS = \
+libnm_vpn_plugin_vpnc_editor_la_LDFLAGS = \
     -avoid-version \
-    -Wl,--version-script=$(srcdir)/libnm-vpn-plugin-vpnc.ver
+    -Wl,--version-script=$(srcdir)/libnm-vpn-plugin-vpnc-editor.ver
 
 ###############################################################################
 
 libnm_vpnc_properties_la_SOURCES = \
-    $(libnm_vpn_plugin_vpnc_la_SOURCES)
+    $(plugin_sources) \
+    $(editor_sources)
 
 libnm_vpnc_properties_la_CFLAGS = \
     -DNM_VPNC_OLD \
+    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
     $(common_CFLAGS) \
+    $(GTK_CFLAGS) \
     $(LIBNM_GLIB_CFLAGS) \
     $(LIBNM_GTK_CFLAGS)
 
@@ -88,5 +120,6 @@ CLEANFILES = *.bak *~
 
 EXTRA_DIST = \
     libnm-vpn-plugin-vpnc.ver \
+    libnm-vpn-plugin-vpnc-editor.ver \
     libnm-vpnc-properties.ver \
     $(ui_DATA)
diff --git a/properties/libnm-vpn-plugin-vpnc-editor.ver b/properties/libnm-vpn-plugin-vpnc-editor.ver
new file mode 100644
index 0000000..0abaac8
--- /dev/null
+++ b/properties/libnm-vpn-plugin-vpnc-editor.ver
@@ -0,0 +1,6 @@
+{
+global:
+       nm_vpn_editor_factory_vpnc;
+local:
+       *;
+};
diff --git a/properties/nm-vpnc-editor-plugin.c b/properties/nm-vpnc-editor-plugin.c
index 166c06c..e535996 100644
--- a/properties/nm-vpnc-editor-plugin.c
+++ b/properties/nm-vpnc-editor-plugin.c
@@ -29,11 +29,17 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
 #include "nm-vpnc-helper.h"
+
+#ifdef NM_VPNC_OLD
 #include "nm-vpnc-editor.h"
+#else
+#include "nm-vpn-plugin-utils.h"
+#endif
 
 #define VPNC_PLUGIN_NAME    _("Cisco Compatible VPN (vpnc)")
 #define VPNC_PLUGIN_DESC    _("Compatible with various Cisco, Juniper, Netscreen, and Sonicwall IPsec-based 
VPN gateways.")
@@ -496,18 +502,11 @@ import (NMVpnEditorPlugin *plugin, const char *path, GError **error)
        if (key_file_get_integer_helper (keyfile, "main", "TunnelingMode", &val)) {
                /* If applicable, put up warning that TCP tunneling will be disabled */
                if (val == 1) {
-                       GtkWidget *dialog;
                        char *basename;
 
                        basename = g_path_get_basename (path);
-                       dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                        GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
-                                                        _("TCP tunneling not supported"));
-                       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                                       _("The VPN settings file '%s' 
specifies that VPN traffic should be tunneled through TCP which is currently not supported in the vpnc 
software.\n\nThe connection can still be created, with TCP tunneling disabled, however it may not work as 
expected."), basename);
+                       g_warning (_("The VPN settings file '%s' specifies that VPN traffic should be 
tunneled through TCP which is currently not supported in the vpnc software.\n\nThe connection can still be 
created, with TCP tunneling disabled, however it may not work as expected."), basename);
                        g_free (basename);
-                       gtk_dialog_run (GTK_DIALOG (dialog));
-                       gtk_widget_destroy (dialog);
                }
        }
 
@@ -801,10 +800,40 @@ get_capabilities (NMVpnEditorPlugin *plugin)
        return (NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT | NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT);
 }
 
+#ifndef NM_VPNC_OLD
+static NMVpnEditor *
+_call_editor_factory (gpointer factory,
+                      NMVpnEditorPlugin *editor_plugin,
+                      NMConnection *connection,
+                      gpointer user_data,
+                      GError **error)
+{
+       return ((NMVpnEditorFactory) factory) (editor_plugin,
+                                              connection,
+                                              error);
+}
+#endif
+
 static NMVpnEditor *
-get_editor (NMVpnEditorPlugin *plugin, NMConnection *connection, GError **error)
+get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error)
 {
-       return nm_vpnc_editor_new (connection, error);
+       g_return_val_if_fail (VPNC_IS_EDITOR_PLUGIN (iface), NULL);
+       g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+       g_return_val_if_fail (!error || !*error, NULL);
+
+       {
+#ifdef NM_VPNC_OLD
+               return nm_vpnc_editor_new (connection, error);
+#else
+               return nm_vpn_plugin_utils_load_editor (NM_PLUGIN_DIR"/libnm-vpn-plugin-vpnc-editor.so",
+                                                       "nm_vpn_editor_factory_vpnc",
+                                                       _call_editor_factory,
+                                                       iface,
+                                                       connection,
+                                                       NULL,
+                                                       error);
+#endif
+       }
 }
 
 static void
diff --git a/properties/nm-vpnc-editor-plugin.h b/properties/nm-vpnc-editor-plugin.h
index d2a357e..8c98d87 100644
--- a/properties/nm-vpnc-editor-plugin.h
+++ b/properties/nm-vpnc-editor-plugin.h
@@ -41,6 +41,14 @@ struct _VpncEditorPluginClass {
 
 GType vpnc_editor_plugin_get_type (void);
 
+typedef NMVpnEditor *(*NMVpnEditorFactory) (NMVpnEditorPlugin *editor_plugin,
+                                            NMConnection *connection,
+                                            GError **error);
+
+NMVpnEditor *
+nm_vpn_editor_factory_vpnc (NMVpnEditorPlugin *editor_plugin,
+                            NMConnection *connection,
+                            GError **error);
 
 #endif /* __NM_VPNC_EDITOR_PLUGIN_H__ */
 
diff --git a/properties/nm-vpnc-editor.c b/properties/nm-vpnc-editor.c
index b273a96..f379520 100644
--- a/properties/nm-vpnc-editor.c
+++ b/properties/nm-vpnc-editor.c
@@ -1035,3 +1035,20 @@ vpnc_editor_interface_init (NMVpnEditorInterface *iface)
        iface->update_connection = update_connection;
 }
 
+/*****************************************************************************/
+
+#ifndef NM_OPENVPN_OLD
+
+#include "nm-vpnc-editor-plugin.h"
+
+G_MODULE_EXPORT NMVpnEditor *
+nm_vpn_editor_factory_vpnc (NMVpnEditorPlugin *editor_plugin,
+                            NMConnection *connection,
+                            GError **error)
+{
+       g_return_val_if_fail (!error || !*error, NULL);
+
+       return nm_vpnc_editor_new (connection, error);
+}
+#endif
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]