[network-manager-vpnc/lr/libnm: 2/2] fixup! properties: build separate libnm-based and libnm-glib-based plugins



commit 77933cdd7353206aac1fbe1cc17261cdbe779d6e
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Jul 16 18:06:29 2015 +0200

    fixup! properties: build separate libnm-based and libnm-glib-based plugins

 nm-vpnc-service.name.in |    2 +-
 properties/Makefile.am  |   43 ++++++++++++++--------------------
 properties/nm-vpnc.c    |   58 +++++++++++++++++++++++-----------------------
 3 files changed, 48 insertions(+), 55 deletions(-)
---
diff --git a/nm-vpnc-service.name.in b/nm-vpnc-service.name.in
index 3c5bf0e..16200fd 100644
--- a/nm-vpnc-service.name.in
+++ b/nm-vpnc-service.name.in
@@ -4,7 +4,7 @@ service=org.freedesktop.NetworkManager.vpnc
 program= LIBEXECDIR@/nm-vpnc-service
 
 [libnm]
-properties= PLUGINDIR@/libnm-vpnc-properties-new
+properties= PLUGINDIR@/libnm-vpnc-properties
 
 [GNOME]
 auth-dialog= LIBEXECDIR@/nm-vpnc-auth-dialog
diff --git a/properties/Makefile.am b/properties/Makefile.am
index e68b9ef..51672da 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,58 +1,51 @@
 SUBDIRS=. tests
 
 plugindir = $(libdir)/NetworkManager
-plugin_LTLIBRARIES = libnm-vpnc-properties-new.la libnm-vpnc-properties-old.la
+plugin_LTLIBRARIES = libnm-vpnc-properties.la libnm-vpnc-properties-old.la
 
-libnm_vpnc_properties_new_la_SOURCES = \
+libnm_vpnc_properties_la_SOURCES = \
        nm-vpnc.c \
        nm-vpnc.h \
        nm-vpnc-helper.c \
        nm-vpnc-helper.h
 
 libnm_vpnc_properties_old_la_SOURCES = \
-       nm-vpnc.c \
-       nm-vpnc.h \
-       nm-vpnc-helper.c \
-       nm-vpnc-helper.h
+       $(libnm_vpnc_properties_la_SOURCES)
 
 uidir = $(datadir)/gnome-vpn-properties/vpnc
 ui_DATA = nm-vpnc-dialog.ui
 
-libnm_vpnc_properties_new_la_CPPFLAGS = \
-       -DNM_VPNC_NEW \
+common_CFLAGS = \
        $(GLIB_CFLAGS) \
        $(GTK_CFLAGS) \
-       $(LIBNM_CFLAGS) \
        -I$(top_srcdir)/src/ \
        -DICONDIR=\""$(datadir)/pixmaps"\" \
        -DUIDIR=\""$(uidir)"\" \
        -DLOCALEDIR=\"$(datadir)/locale\" \
        -DVERSION=\"$(VERSION)\"
 
-libnm_vpnc_properties_new_la_LIBADD = \
-       $(GTK_LIBS) \
-       $(LIBNM_LIBS)
-
-libnm_vpnc_properties_new_la_LDFLAGS = \
-        -avoid-version
+libnm_vpnc_properties_la_CFLAGS = \
+       $(common_CFLAGS) \
+       $(LIBNM_CFLAGS)
 
-libnm_vpnc_properties_old_la_CPPFLAGS = \
+libnm_vpnc_properties_old_la_CFLAGS = \
        -DNM_VPNC_OLD \
-       $(GLIB_CFLAGS) \
-       $(GTK_CFLAGS) \
-       $(NM_CFLAGS) \
-       -I$(top_srcdir)/src \
-       -DICONDIR=\""$(datadir)/pixmaps"\" \
-       -DUIDIR=\""$(uidir)"\" \
-       -DLOCALEDIR=\"$(datadir)/locale\" \
-       -DVERSION=\"$(VERSION)\"
+       $(common_CFLAGS) \
+       $(NM_CFLAGS)
+
+libnm_vpnc_properties_la_LIBADD = \
+       $(GTK_LIBS) \
+       $(LIBNM_LIBS)
 
 libnm_vpnc_properties_old_la_LIBADD = \
        $(GTK_LIBS) \
        $(NM_LIBS)
 
+libnm_vpnc_properties_new_la_LDFLAGS = \
+       -avoid-version
+
 libnm_vpnc_properties_old_la_LDFLAGS = \
-        -avoid-version
+       $(libnm_vpnc_properties_new_la_LDFLAGS)
 
 CLEANFILES = *.bak *~
 
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 4ad72e8..8a94417 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -39,14 +39,6 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
-#ifdef NM_VPNC_NEW
-#include <NetworkManager.h>
-
-#define VPNC_PLUGIN_UI_ERROR                  NM_CONNECTION_ERROR
-#define VPNC_PLUGIN_UI_ERROR_FAILED           NM_CONNECTION_ERROR_FAILED
-#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
-#endif
-
 #ifdef NM_VPNC_OLD
 #include <nm-setting-vpn.h>
 #include <nm-setting-connection.h>
@@ -68,6 +60,14 @@
 #define VPNC_PLUGIN_UI_ERROR                  NM_SETTING_VPN_ERROR
 #define VPNC_PLUGIN_UI_ERROR_FAILED           NM_SETTING_VPN_ERROR_UNKNOWN
 #define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
+
+#else /* !NM_VPNC_OLD */
+
+#include <NetworkManager.h>
+
+#define VPNC_PLUGIN_UI_ERROR                  NM_CONNECTION_ERROR
+#define VPNC_PLUGIN_UI_ERROR_FAILED           NM_CONNECTION_ERROR_FAILED
+#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
 #endif
 
 #include "nm-vpnc-service-defines.h"
@@ -1172,11 +1172,11 @@ add_routes (NMSettingIPConfig *s_ip4, const char *routelist)
        for (i = 0; substrs[i] != NULL; i++) {
                char *p, *str_route;
                long int prefix = 32;
-#ifdef NM_VPNC_NEW
+#ifdef NM_VPNC_OLD
+               struct in_addr tmp;
+#else
                NMIPRoute *route;
                GError *error = NULL;
-#else
-               struct in_addr tmp;
 #endif
 
                str_route = g_strdup (substrs[i]);
@@ -1194,16 +1194,7 @@ add_routes (NMSettingIPConfig *s_ip4, const char *routelist)
                }
                *p = '\0';
 
-#ifdef NM_VPNC_NEW
-               route = nm_ip_route_new (AF_INET, str_route, prefix, NULL, -1, &error);
-               if (route) {
-                       nm_setting_ip_config_add_route (s_ip4, route);
-                       nm_ip_route_unref (route);
-               } else {
-                       g_warning ("Ignoring invalid route '%s': %s", str_route, error->message);
-                       g_clear_error (&error);
-               }
-#else
+#ifdef NM_VPNC_OLD
                if (inet_pton (AF_INET, str_route, &tmp) > 0) {
                        NMIP4Route *route = nm_ip4_route_new ();
 
@@ -1213,6 +1204,15 @@ add_routes (NMSettingIPConfig *s_ip4, const char *routelist)
                        nm_setting_ip_config_add_route (s_ip4, route);
                } else
                        g_warning ("Ignoring invalid route '%s'", str_route);
+#else
+               route = nm_ip_route_new (AF_INET, str_route, prefix, NULL, -1, &error);
+               if (route) {
+                       nm_setting_ip_config_add_route (s_ip4, route);
+                       nm_ip_route_unref (route);
+               } else {
+                       g_warning ("Ignoring invalid route '%s': %s", str_route, error->message);
+                       g_clear_error (&error);
+               }
 #endif
 
 next:
@@ -1745,24 +1745,24 @@ export (NMVpnEditorPlugin *plugin,
                int i;
 
                for (i = 0; i < nm_setting_ip_config_get_num_routes (s_ip4); i++) {
-#ifdef NM_VPNC_NEW
-                       NMIPRoute *route = nm_setting_ip_config_get_route (s_ip4, i);
-#else
+#ifdef NM_VPNC_OLD
                        NMIP4Route *route = nm_setting_ip_config_get_route (s_ip4, i);
                        char str_addr[INET_ADDRSTRLEN + 1];
                        struct in_addr num_addr;
+#else
+                       NMIPRoute *route = nm_setting_ip_config_get_route (s_ip4, i);
 #endif
 
                        if (routes_count)
                                g_string_append_c (routes, ' ');
-#ifdef NM_VPNC_NEW
-                       g_string_append_printf (routes, "%s/%d",
-                                               nm_ip_route_get_dest (route),
-                                               nm_ip_route_get_prefix (route));
-#else
+#ifdef NM_VPNC_OLD
                        num_addr.s_addr = nm_ip4_route_get_dest (route);
                        if (inet_ntop (AF_INET, &num_addr, &str_addr[0], INET_ADDRSTRLEN + 1))
                                g_string_append_printf (routes, "%s/%d", str_addr, nm_ip4_route_get_prefix 
(route));
+#else
+                       g_string_append_printf (routes, "%s/%d",
+                                               nm_ip_route_get_dest (route),
+                                               nm_ip_route_get_prefix (route));
 #endif
 
                        routes_count++;


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