[network-manager-pptp/th/vpn-editor-split-bgo766623: 20/21] properties: split GTK dependent editor plugin



commit 511c0a73bf02e899117ef97859c34c2577b99a9d
Author: Thomas Haller <thaller redhat com>
Date:   Wed May 18 20:25:47 2016 +0200

    properties: split GTK dependent editor plugin

 Makefile.am                                 |    4 +-
 properties/Makefile.am                      |   39 ++++++++++++++++++++++-----
 properties/libnm-vpn-plugin-pptp-editor.ver |    6 ++++
 properties/nm-pptp-editor-plugin.c          |   36 ++++++++++++++++++++++++-
 properties/nm-pptp-editor-plugin.h          |    9 ++++++
 properties/nm-pptp-editor.c                 |   17 +++++++++++
 6 files changed, 101 insertions(+), 10 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index cac70ff..239a2b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = shared src
+SUBDIRS = shared properties src po
 
 if WITH_GNOME
-SUBDIRS += auth-dialog properties po
+SUBDIRS += auth-dialog
 endif
 
 dbusservicedir = $(sysconfdir)/dbus-1/system.d
diff --git a/properties/Makefile.am b/properties/Makefile.am
index 157502c..c4c5322 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,8 +1,11 @@
 plugindir = $(libdir)/NetworkManager
 plugin_LTLIBRARIES = libnm-vpn-plugin-pptp.la
+if WITH_GNOME
+plugin_LTLIBRARIES += libnm-vpn-plugin-pptp-editor.la
 if WITH_LIBNM_GLIB
 plugin_LTLIBRARIES += libnm-pptp-properties.la
 endif
+endif
 
 AM_CPPFLAGS = -I${top_srcdir}
 
@@ -17,11 +20,12 @@ editor_sources = \
     nm-pptp-editor.h
 
 uidir = $(datadir)/gnome-vpn-properties/pptp
+if WITH_GNOME
 ui_DATA = nm-pptp-dialog.ui
+endif
 
 common_CFLAGS = \
     $(GLIB_CFLAGS) \
-    $(GTK_CFLAGS) \
     -I"$(top_srcdir)/shared" \
     -DICONDIR=\""$(datadir)/pixmaps"\" \
     -DUIDIR=\""$(uidir)"\" \
@@ -30,23 +34,42 @@ common_CFLAGS = \
 ###############################################################################
 
 libnm_vpn_plugin_pptp_la_SOURCES = \
-    $(plugin_sources) \
-    $(editor_sources)
+    $(plugin_sources)
 
 libnm_vpn_plugin_pptp_la_CFLAGS = \
-    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE \
+    -DNM_PLUGIN_DIR=\"$(NM_PLUGIN_DIR)\" \
     $(common_CFLAGS) \
-    $(LIBNMA_CFLAGS) \
     $(LIBNM_CFLAGS)
 
 libnm_vpn_plugin_pptp_la_LIBADD = \
+    $(LIBNM_LIBS) \
+    $(top_builddir)/shared/libnm-vpn-editor-utils-shared.la
+
+libnm_vpn_plugin_pptp_la_LDFLAGS = \
+    -avoid-version \
+    -Wl,--version-script="$(srcdir)/libnm-vpn-plugin-pptp.ver"
+
+###############################################################################
+
+libnm_vpn_plugin_pptp_editor_la_SOURCES = \
+    $(editor_sources)
+
+libnm_vpn_plugin_pptp_editor_la_CFLAGS = \
+    -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR \
+    $(common_CFLAGS) \
+    $(GTK_CFLAGS) \
+    $(LIBNMA_CFLAGS) \
+    $(LIBNM_CFLAGS)
+
+libnm_vpn_plugin_pptp_editor_la_LIBADD = \
     $(GTK_LIBS) \
     $(LIBNMA_LIBS) \
     $(LIBNM_LIBS)
 
-libnm_vpn_plugin_pptp_la_LDFLAGS = \
+libnm_vpn_plugin_pptp_editor_la_LDFLAGS = \
     -avoid-version \
-    -Wl,--version-script="$(srcdir)/libnm-vpn-plugin-pptp.ver"
+    -Wl,--version-script="$(srcdir)/libnm-vpn-plugin-pptp-editor.ver"
 
 ###############################################################################
 
@@ -58,6 +81,7 @@ libnm_pptp_properties_la_CFLAGS = \
     -DNM_VPN_OLD \
     -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
     $(common_CFLAGS) \
+    $(GTK_CFLAGS) \
     $(LIBNM_GLIB_CFLAGS) \
     $(LIBNM_GTK_CFLAGS)
 
@@ -77,4 +101,5 @@ CLEANFILES = *.bak *~
 EXTRA_DIST = \
     libnm-pptp-properties.ver \
     libnm-vpn-plugin-pptp.ver \
+    libnm-vpn-plugin-pptp-editor.ver \
     nm-pptp-dialog.ui
diff --git a/properties/libnm-vpn-plugin-pptp-editor.ver b/properties/libnm-vpn-plugin-pptp-editor.ver
new file mode 100644
index 0000000..57e65d4
--- /dev/null
+++ b/properties/libnm-vpn-plugin-pptp-editor.ver
@@ -0,0 +1,6 @@
+{
+global:
+       nm_vpn_editor_factory_pptp;
+local:
+       *;
+};
diff --git a/properties/nm-pptp-editor-plugin.c b/properties/nm-pptp-editor-plugin.c
index 90d6a9f..7a5d63d 100644
--- a/properties/nm-pptp-editor-plugin.c
+++ b/properties/nm-pptp-editor-plugin.c
@@ -25,7 +25,11 @@
 
 #include "nm-pptp-editor-plugin.h"
 
+#ifdef NM_VPN_OLD
 #include "nm-pptp-editor.h"
+#else
+#include "nm-vpn/nm-vpn-plugin-utils.h"
+#endif
 
 #define PPTP_PLUGIN_NAME    _("Point-to-Point Tunneling Protocol (PPTP)")
 #define PPTP_PLUGIN_DESC    _("Compatible with Microsoft and other PPTP VPN servers.")
@@ -128,10 +132,40 @@ get_capabilities (NMVpnEditorPlugin *iface)
        return NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE;
 }
 
+#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_plugin_ui_widget_interface_new (connection, error);
+       g_return_val_if_fail (PPTP_IS_PLUGIN_UI (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_plugin_ui_widget_interface_new (connection, error);
+#else
+               return nm_vpn_plugin_utils_load_editor (NM_PLUGIN_DIR"/libnm-vpn-plugin-pptp-editor.so",
+                                                       "nm_vpn_editor_factory_pptp",
+                                                       _call_editor_factory,
+                                                       iface,
+                                                       connection,
+                                                       NULL,
+                                                       error);
+#endif
+       }
 }
 
 static void
diff --git a/properties/nm-pptp-editor-plugin.h b/properties/nm-pptp-editor-plugin.h
index 6587c03..31b9875 100644
--- a/properties/nm-pptp-editor-plugin.h
+++ b/properties/nm-pptp-editor-plugin.h
@@ -41,5 +41,14 @@ struct _PptpPluginUiClass {
 
 GType pptp_plugin_ui_get_type (void);
 
+typedef NMVpnEditor *(*NMVpnEditorFactory) (NMVpnEditorPlugin *editor_plugin,
+                                            NMConnection *connection,
+                                            GError **error);
+
+NMVpnEditor *
+nm_vpn_editor_factory_pptp (NMVpnEditorPlugin *editor_plugin,
+                            NMConnection *connection,
+                            GError **error);
+
 #endif /* __NM_PPTP_EDITOR_PLUGIN_H__ */
 
diff --git a/properties/nm-pptp-editor.c b/properties/nm-pptp-editor.c
index a47a4af..0ab1735 100644
--- a/properties/nm-pptp-editor.c
+++ b/properties/nm-pptp-editor.c
@@ -516,3 +516,20 @@ pptp_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class)
        iface_class->update_connection = update_connection;
 }
 
+/*****************************************************************************/
+
+#ifndef NM_VPN_OLD
+
+#include "nm-pptp-editor-plugin.h"
+
+G_MODULE_EXPORT NMVpnEditor *
+nm_vpn_editor_factory_pptp (NMVpnEditorPlugin *editor_plugin,
+                            NMConnection *connection,
+                            GError **error)
+{
+       g_return_val_if_fail (!error || !*error, NULL);
+
+       return nm_vpn_plugin_ui_widget_interface_new (connection, error);
+}
+#endif
+


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