[network-manager-vpnc] shared: reimport shared files and reorganize



commit 2328b4634717a5a5874a0feab6b3644ff3f1e983
Author: Thomas Haller <thaller redhat com>
Date:   Thu Jun 16 11:10:16 2016 +0200

    shared: reimport shared files and reorganize
    
    The shared files got reorganized and the directory
    "shared/nm-vpn" got merged with "shared/nm-utils".
    Update the VPN plugin to do the same.
    
    Also, reimport and update the shared files with their
    latest version, fix the include paths and reword
    "shared/README".

 po/POTFILES.in                                     |    2 +-
 properties/nm-vpnc-editor-plugin.c                 |    2 +-
 shared/Makefile.am                                 |    7 ++--
 shared/README                                      |   32 +++++--------------
 shared/nm-utils/nm-glib.h                          |    2 +
 shared/nm-utils/nm-macros-internal.h               |   33 ++++++++++++++++++++
 shared/nm-utils/nm-test-utils.h                    |   10 ++++++
 shared/{nm-vpn => nm-utils}/nm-vpn-plugin-macros.h |    0
 shared/{nm-vpn => nm-utils}/nm-vpn-plugin-utils.c  |    0
 shared/{nm-vpn => nm-utils}/nm-vpn-plugin-utils.h  |    2 +
 src/nm-vpnc-service-vpnc-helper.c                  |    2 +-
 src/nm-vpnc-service.c                              |    2 +-
 12 files changed, 63 insertions(+), 31 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 167713d..520809d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,5 +6,5 @@ properties/nm-vpnc-editor-plugin.c
 properties/nm-vpnc-editor.c
 src/nm-vpnc-service.c
 shared/nm-utils/nm-shared-utils.c
-shared/nm-vpn/nm-vpn-plugin-utils.c
+shared/nm-utils/nm-vpn-plugin-utils.c
 [type: gettext/glade]properties/nm-vpnc-dialog.ui
diff --git a/properties/nm-vpnc-editor-plugin.c b/properties/nm-vpnc-editor-plugin.c
index ffa8ee4..55341b0 100644
--- a/properties/nm-vpnc-editor-plugin.c
+++ b/properties/nm-vpnc-editor-plugin.c
@@ -38,7 +38,7 @@
 #ifdef NM_VPN_OLD
 #include "nm-vpnc-editor.h"
 #else
-#include "nm-vpn/nm-vpn-plugin-utils.h"
+#include "nm-utils/nm-vpn-plugin-utils.h"
 #endif
 
 #define VPNC_PLUGIN_NAME    _("Cisco Compatible VPN (vpnc)")
diff --git a/shared/Makefile.am b/shared/Makefile.am
index 237810c..26b57d6 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -42,9 +42,9 @@ libnm_vpn_editor_utils_shared_la_CPPFLAGS = \
     -I$(top_srcdir)/shared
 
 libnm_vpn_editor_utils_shared_la_SOURCES = \
-    nm-vpn/nm-vpn-plugin-utils.c \
-    nm-vpn/nm-vpn-plugin-utils.h \
-    nm-vpn/nm-vpn-plugin-macros.h
+    nm-utils/nm-vpn-plugin-utils.c \
+    nm-utils/nm-vpn-plugin-utils.h \
+    nm-utils/nm-vpn-plugin-macros.h
 
 libnm_vpn_editor_utils_shared_la_LIBADD = \
     $(LIBNM_LIBS) \
@@ -53,6 +53,7 @@ libnm_vpn_editor_utils_shared_la_LIBADD = \
 ###############################################################################
 
 EXTRA_DIST = \
+    README \
     nm-utils/gsystem-local-alloc.h \
     nm-utils/nm-glib.h \
     nm-utils/nm-macros-internal.h \
diff --git a/shared/README b/shared/README
index b57961e..3fe41ef 100644
--- a/shared/README
+++ b/shared/README
@@ -1,25 +1,9 @@
-The files in the "shared/" directory are supposed to be shared
-across NetworkManager related projects (reuse-by-copying).
-
-(1) the files
-    shared/nm-utils/gsystem-local-alloc.h
-    shared/nm-utils/nm-glib.h
-    shared/nm-utils/nm-macros-internal.h
-    shared/nm-utils/nm-shared-utils.c
-    shared/nm-utils/nm-shared-utils.h
-    shared/nm-utils/nm-test-utils.h
-are copied as-is from NetworkManager
-  
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/shared?id=9770024f63b85da604f1134a8bc8dc968278dcd1
-
-2) the files
-    shared/nm-vpn/nm-vpn-plugin-utils.c
-    shared/nm-vpn/nm-vpn-plugin-utils.h
-    shared/nm-vpn/nm-vpn-plugin-macros.h
-are copied as-is from nm-openvpn
-  
https://git.gnome.org/browse/network-manager-openvpn/tree/shared?id=3d0ac3ca94b4bf24f77306cef5a95172ddaf5fc4
-
-
-Do *not* modify these files locally so that they don't diverge.
-Fix/extend them in their respective origin first, and re-import
-the files as a whole.
+The files in the "shared/" directory are used by all components
+inside the VPN plugin repository (src, properties, auth-dialog).
+
+The files in shared/nm-utils are copied from NetworkManager
+repository and used as is:
+Do *not* modify these files locally so that they don't diverge
+from their original. Fix/extend them in their respective origin
+first, and re-import the files as a whole.
 
diff --git a/shared/nm-utils/nm-glib.h b/shared/nm-utils/nm-glib.h
index 5f8ebc7..46a8bb2 100644
--- a/shared/nm-utils/nm-glib.h
+++ b/shared/nm-utils/nm-glib.h
@@ -24,6 +24,8 @@
 #include <gio/gio.h>
 #include <string.h>
 
+#include "gsystem-local-alloc.h"
+
 #ifdef __clang__
 
 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index 7a5c90f..603689a 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -24,12 +24,15 @@
 
 #include <stdlib.h>
 
+#include "nm-glib.h"
+
 /********************************************************/
 
 #define _nm_packed __attribute__ ((packed))
 #define _nm_unused __attribute__ ((unused))
 #define _nm_pure   __attribute__ ((pure))
 #define _nm_const  __attribute__ ((const))
+#define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b)))
 
 #define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
 
@@ -483,6 +486,36 @@ nm_strstrip (char *str)
        return str ? g_strstrip (str) : NULL;
 }
 
+/* g_ptr_array_sort()'s compare function takes pointers to the
+ * value. Thus, you cannot use strcmp directly. You can use
+ * nm_strcmp_p().
+ *
+ * Like strcmp(), this function is not forgiving to accept %NULL. */
+static inline int
+nm_strcmp_p (gconstpointer a, gconstpointer b)
+{
+       const char *s1 = *((const char **) a);
+       const char *s2 = *((const char **) b);
+
+       return strcmp (s1, s2);
+}
+
+/* like nm_strcmp_p(), suitable for g_ptr_array_sort_with_data().
+ * g_ptr_array_sort() just casts nm_strcmp_p() to a function of different
+ * signature. I guess, in glib there are knowledgeable people that ensure
+ * that this additional argument doesn't cause problems due to different ABI
+ * for every architecture that glib supports.
+ * For NetworkManager, we'd rather avoid such stunts.
+ **/
+static inline int
+nm_strcmp_p_with_data (gconstpointer a, gconstpointer b, gpointer user_data)
+{
+       const char *s1 = *((const char **) a);
+       const char *s2 = *((const char **) b);
+
+       return strcmp (s1, s2);
+}
+
 /*****************************************************************************/
 
 static inline guint
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h
index ad3cad6..dba41c4 100644
--- a/shared/nm-utils/nm-test-utils.h
+++ b/shared/nm-utils/nm-test-utils.h
@@ -92,6 +92,11 @@
 
 #include "nm-default.h"
 
+#if defined(NM_ASSERT_NO_MSG) && NM_ASSERT_NO_MSG
+#undef g_return_if_fail_warning
+#undef g_assertion_message_expr
+#endif
+
 #include <arpa/inet.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -103,6 +108,11 @@
 
 /*******************************************************************************/
 
+#define NMTST_G_RETURN_MSG_S(expr) "*: assertion '"NM_ASSERT_G_RETURN_EXPR(expr)"' failed"
+#define NMTST_G_RETURN_MSG(expr)   NMTST_G_RETURN_MSG_S(#expr)
+
+/*******************************************************************************/
+
 /* general purpose functions that have no dependency on other nmtst functions */
 
 #define nmtst_assert_error(error, expect_error_domain, expect_error_code, expect_error_pattern) \
diff --git a/shared/nm-vpn/nm-vpn-plugin-macros.h b/shared/nm-utils/nm-vpn-plugin-macros.h
similarity index 100%
rename from shared/nm-vpn/nm-vpn-plugin-macros.h
rename to shared/nm-utils/nm-vpn-plugin-macros.h
diff --git a/shared/nm-vpn/nm-vpn-plugin-utils.c b/shared/nm-utils/nm-vpn-plugin-utils.c
similarity index 100%
rename from shared/nm-vpn/nm-vpn-plugin-utils.c
rename to shared/nm-utils/nm-vpn-plugin-utils.c
diff --git a/shared/nm-vpn/nm-vpn-plugin-utils.h b/shared/nm-utils/nm-vpn-plugin-utils.h
similarity index 98%
rename from shared/nm-vpn/nm-vpn-plugin-utils.h
rename to shared/nm-utils/nm-vpn-plugin-utils.h
index 3efad44..f3928d1 100644
--- a/shared/nm-vpn/nm-vpn-plugin-utils.h
+++ b/shared/nm-utils/nm-vpn-plugin-utils.h
@@ -22,6 +22,8 @@
 #ifndef __NM_VPN_PLUGIN_UTILS_H__
 #define __NM_VPN_PLUGIN_UTILS_H__
 
+#include <NetworkManager.h>
+
 typedef NMVpnEditor *(NMVpnPluginUtilsEditorFactory) (gpointer factory,
                                                       NMVpnEditorPlugin *editor_plugin,
                                                       NMConnection *connection,
diff --git a/src/nm-vpnc-service-vpnc-helper.c b/src/nm-vpnc-service-vpnc-helper.c
index 9bd07a5..a4cb74c 100644
--- a/src/nm-vpnc-service-vpnc-helper.c
+++ b/src/nm-vpnc-service-vpnc-helper.c
@@ -33,7 +33,7 @@
 
 #include "utils.h"
 #include "nm-utils/nm-shared-utils.h"
-#include "nm-vpn/nm-vpn-plugin-macros.h"
+#include "nm-utils/nm-vpn-plugin-macros.h"
 
 extern char **environ;
 
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 673829f..ffeb411 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -37,7 +37,7 @@
 
 #include "utils.h"
 #include "nm-utils/nm-shared-utils.h"
-#include "nm-vpn/nm-vpn-plugin-macros.h"
+#include "nm-utils/nm-vpn-plugin-macros.h"
 
 #if !defined(DIST_VERSION)
 # define DIST_VERSION VERSION


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