[network-manager-openconnect/th/vpn-editor-split-bgo767690: 12/14] properties: split GTK dependent editor plugin



commit 48963154d353d376e328f58ed2b5e250df6f7049
Author: Thomas Haller <thaller redhat com>
Date:   Tue Jun 14 23:56:53 2016 +0200

    properties: split GTK dependent editor plugin

 Makefile.am                                        |    4 +-
 properties/Makefile.am                             |   35 ++++++++++++++++---
 properties/libnm-vpn-plugin-openconnect-editor.ver |    6 +++
 properties/nm-openconnect-editor-plugin.c          |   37 ++++++++++++++++++--
 properties/nm-openconnect-editor-plugin.h          |    9 ++++-
 properties/nm-openconnect-editor.c                 |   19 +++++++++-
 properties/nm-openconnect-editor.h                 |    2 +-
 7 files changed, 99 insertions(+), 13 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ca4a6c4..ec05941 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = shared src
+SUBDIRS = shared properties src
 
 if WITH_GNOME
-SUBDIRS += properties po
+SUBDIRS += po
 
 if WITH_AUTHDLG
 SUBDIRS += auth-dialog
diff --git a/properties/Makefile.am b/properties/Makefile.am
index a5407b0..85d1b9b 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,8 +1,11 @@
 plugindir = $(libdir)/NetworkManager
 plugin_LTLIBRARIES = libnm-vpn-plugin-openconnect.la
+if WITH_GNOME
+plugin_LTLIBRARIES += libnm-vpn-plugin-openconnect-editor.la
 if WITH_LIBNM_GLIB
 plugin_LTLIBRARIES += libnm-openconnect-properties.la
 endif
+endif
 
 plugin_sources = \
        nm-openconnect-editor-plugin.c \
@@ -17,11 +20,12 @@ editor_sources = \
        $(NULL)
 
 uidir = $(datadir)/gnome-vpn-properties/openconnect
+if WITH_GNOME
 ui_DATA = nm-openconnect-dialog.ui
+endif
 
 common_CFLAGS = \
        $(GLIB_CFLAGS) \
-       $(GTK_CFLAGS) \
        $(OPENCONNECT_CFLAGS) \
        -I$(top_srcdir)/shared \
        -DICONDIR=\""$(datadir)/pixmaps"\" \
@@ -31,16 +35,15 @@ common_CFLAGS = \
 ###############################################################################
 
 libnm_vpn_plugin_openconnect_la_SOURCES = \
-       $(plugin_sources) \
-       $(editor_sources)
+       $(plugin_sources)
 
 libnm_vpn_plugin_openconnect_la_CFLAGS = \
-       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE \
+       -DNM_PLUGIN_DIR=\"$(NM_PLUGIN_DIR)\" \
        $(common_CFLAGS) \
        $(LIBNM_CFLAGS)
 
 libnm_vpn_plugin_openconnect_la_LIBADD = \
-       $(GTK_LIBS) \
        $(LIBNM_LIBS) \
        $(OPENCONNECT_LIBS)
 
@@ -50,6 +53,26 @@ libnm_vpn_plugin_openconnect_la_LDFLAGS = \
 
 ###############################################################################
 
+libnm_vpn_plugin_openconnect_editor_la_SOURCES = \
+       $(editor_sources)
+
+libnm_vpn_plugin_openconnect_editor_la_CFLAGS = \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR \
+       $(common_CFLAGS) \
+       $(GTK_CFLAGS) \
+       $(LIBNM_CFLAGS)
+
+libnm_vpn_plugin_openconnect_editor_la_LIBADD = \
+       $(GTK_LIBS) \
+       $(LIBNM_LIBS) \
+       $(OPENCONNECT_LIBS)
+
+libnm_vpn_plugin_openconnect_editor_la_LDFLAGS = \
+       -avoid-version \
+       -Wl,--version-script="$(srcdir)/libnm-vpn-plugin-openconnect-editor.ver"
+
+###############################################################################
+
 libnm_openconnect_properties_la_SOURCES = \
        $(plugin_sources) \
        $(editor_sources)
@@ -58,6 +81,7 @@ libnm_openconnect_properties_la_CFLAGS = \
        -DNM_VPN_OLD \
        -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
        $(common_CFLAGS) \
+       $(GTK_CFLAGS) \
        $(LIBNM_GLIB_CFLAGS)
 
 libnm_openconnect_properties_la_LIBADD = \
@@ -76,5 +100,6 @@ CLEANFILES = *.bak *~
 EXTRA_DIST = \
        libnm-openconnect-properties.ver \
        libnm-vpn-plugin-openconnect.ver \
+       libnm-vpn-plugin-openconnect-editor.ver \
        nm-openconnect-dialog.ui \
        $(NULL)
diff --git a/properties/libnm-vpn-plugin-openconnect-editor.ver 
b/properties/libnm-vpn-plugin-openconnect-editor.ver
new file mode 100644
index 0000000..5fd4181
--- /dev/null
+++ b/properties/libnm-vpn-plugin-openconnect-editor.ver
@@ -0,0 +1,6 @@
+{
+global:
+       nm_vpn_editor_factory_openconnect;
+local:
+       *;
+};
diff --git a/properties/nm-openconnect-editor-plugin.c b/properties/nm-openconnect-editor-plugin.c
index 8486b59..63fcc9b 100644
--- a/properties/nm-openconnect-editor-plugin.c
+++ b/properties/nm-openconnect-editor-plugin.c
@@ -44,10 +44,11 @@
 #define openconnect_has_oath_support() 0
 #endif
 
+#ifdef NM_VPN_OLD
 #include "nm-openconnect-editor.h"
-
-#ifndef NM_VPN_OLD
+#else
 #include "nm-utils/nm-vpn-editor-plugin-call.h"
+#include "nm-vpn/nm-vpn-plugin-utils.h"
 #endif
 
 #define OPENCONNECT_PLUGIN_NAME    _("Cisco AnyConnect Compatible VPN (openconnect)")
@@ -412,10 +413,40 @@ NM_VPN_EDITOR_PLUGIN_VT_DEFINE (vt, _get_vt,
 
 #endif
 
+#ifndef NM_VPN_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 *iface, NMConnection *connection, GError **error)
 {
-       return nm_vpn_editor_interface_new (connection, error);
+       g_return_val_if_fail (OPENCONNECT_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_VPN_OLD
+               return nm_vpn_editor_new (connection, error);
+#else
+               return nm_vpn_plugin_utils_load_editor 
(NM_PLUGIN_DIR"/libnm-vpn-plugin-openconnect-editor.so",
+                                                       "nm_vpn_editor_factory_openconnect",
+                                                       _call_editor_factory,
+                                                       iface,
+                                                       connection,
+                                                       NULL,
+                                                       error);
+#endif
+       }
 }
 
 static void
diff --git a/properties/nm-openconnect-editor-plugin.h b/properties/nm-openconnect-editor-plugin.h
index 4625528..1b91550 100644
--- a/properties/nm-openconnect-editor-plugin.h
+++ b/properties/nm-openconnect-editor-plugin.h
@@ -41,6 +41,13 @@ struct _OpenconnectEditorPluginClass {
 
 GType openconnect_editor_plugin_get_type (void);
 
+typedef NMVpnEditor *(*NMVpnEditorFactory) (NMVpnEditorPlugin *editor_plugin,
+                                            NMConnection *connection,
+                                            GError **error);
 
-#endif /* __NM_OPENCONNECT_EDITOR_PLUGIN_H__ */
+NMVpnEditor *
+nm_vpn_editor_factory_openconnect (NMVpnEditorPlugin *editor_plugin,
+                                  NMConnection *connection,
+                                  GError **error);
 
+#endif /* __NM_OPENCONNECT_EDITOR_PLUGIN_H__ */
diff --git a/properties/nm-openconnect-editor.c b/properties/nm-openconnect-editor.c
index 7021642..1a9e17e 100644
--- a/properties/nm-openconnect-editor.c
+++ b/properties/nm-openconnect-editor.c
@@ -407,7 +407,7 @@ update_connection (NMVpnEditor *iface,
 }
 
 NMVpnEditor *
-nm_vpn_editor_interface_new (NMConnection *connection, GError **error)
+nm_vpn_editor_new (NMConnection *connection, GError **error)
 {
        NMVpnEditor *object;
        OpenconnectEditorPrivate *priv;
@@ -503,3 +503,20 @@ openconnect_editor_interface_init (NMVpnEditorInterface *iface_class)
        iface_class->update_connection = update_connection;
 }
 
+/*****************************************************************************/
+
+#ifndef NM_VPN_OLD
+
+#include "nm-openconnect-editor-plugin.h"
+
+G_MODULE_EXPORT NMVpnEditor *
+nm_vpn_editor_factory_openconnect (NMVpnEditorPlugin *editor_plugin,
+                                   NMConnection *connection,
+                                   GError **error)
+{
+       g_return_val_if_fail (!error || !*error, NULL);
+
+       return nm_vpn_editor_new (connection, error);
+}
+#endif
+
diff --git a/properties/nm-openconnect-editor.h b/properties/nm-openconnect-editor.h
index 7bca40b..5e3ca58 100644
--- a/properties/nm-openconnect-editor.h
+++ b/properties/nm-openconnect-editor.h
@@ -41,7 +41,7 @@ struct _OpenconnectEditorClass {
 
 GType openconnect_editor_get_type (void);
 
-NMVpnEditor *nm_vpn_editor_interface_new (NMConnection *connection, GError **error);
+NMVpnEditor *nm_vpn_editor_new (NMConnection *connection, GError **error);
 
 #endif /* __NM_OPENCONNECT_EDITOR_H__ */
 


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