[network-manager-openconnect: 12/15] properties: split GTK dependent editor plugin



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

    properties: split GTK dependent editor plugin

 Makefile.am                                        |    4 +-
 configure.ac                                       |    2 +-
 properties/Makefile.am                             |   39 +++++++++++++++++---
 properties/libnm-vpn-plugin-openconnect-editor.ver |    6 +++
 properties/nm-openconnect-editor-plugin.c          |   34 ++++++++++++++++--
 properties/nm-openconnect-editor-plugin.h          |    9 ++++-
 properties/nm-openconnect-editor.c                 |   19 +++++++++-
 properties/nm-openconnect-editor.h                 |    2 +-
 8 files changed, 100 insertions(+), 15 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/configure.ac b/configure.ac
index 2f55537..d375c3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_INIT(NetworkManager-openconnect,
         1.3.0,
         https://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager,
         NetworkManager-openconnect)
-AM_INIT_AUTOMAKE([subdir-objects no-dist-gzip dist-xz])
+AM_INIT_AUTOMAKE([no-dist-gzip dist-xz])
 AM_MAINTAINER_MODE
 
 AC_CONFIG_MACRO_DIR([m4])
diff --git a/properties/Makefile.am b/properties/Makefile.am
index f8bb09f..c206ac2 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,11 +1,13 @@
 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 = \
-       $(top_srcdir)/shared/nm-utils/nm-vpn-editor-plugin-call.h \
        nm-openconnect-editor-plugin.c \
        nm-openconnect-editor-plugin.h \
        $(NULL)
@@ -18,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"\" \
@@ -32,16 +35,18 @@ common_CFLAGS = \
 ###############################################################################
 
 libnm_vpn_plugin_openconnect_la_SOURCES = \
-       $(plugin_sources) \
-       $(editor_sources)
+       $(top_srcdir)/shared/nm-utils/nm-vpn-editor-plugin-call.h \
+       $(top_srcdir)/shared/nm-utils/nm-vpn-plugin-utils.c \
+       $(top_srcdir)/shared/nm-utils/nm-vpn-plugin-utils.h \
+       $(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)
 
@@ -51,6 +56,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)
@@ -59,6 +84,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 = \
@@ -77,5 +103,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..5df3c4f 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-utils/nm-vpn-plugin-utils.h"
 #endif
 
 #define OPENCONNECT_PLUGIN_NAME    _("Cisco AnyConnect Compatible VPN (openconnect)")
@@ -410,12 +411,39 @@ NM_VPN_EDITOR_PLUGIN_VT_DEFINE (vt, _get_vt,
        .fcn_get_service_add_detail  = _vt_impl_get_service_add_detail,
 )
 
+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]