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



commit 4a51341cf975c00323038ea597b3740be4f6ac4a
Author: Thomas Haller <thaller redhat com>
Date:   Thu Jun 16 10:56:33 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 nm-openvpn 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-openvpn-editor-plugin.c              |    2 +-
 shared/Makefile.am                                 |    6 ++--
 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-openvpn-service-openvpn-helper.c            |    2 +-
 src/nm-openvpn-service.c                           |    2 +-
 12 files changed, 62 insertions(+), 31 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 945a1f5..d15f424 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,7 +7,7 @@ properties/import-export.c
 properties/nm-openvpn-editor-plugin.c
 properties/nm-openvpn-editor.c
 shared/nm-utils/nm-shared-utils.c
-shared/nm-vpn/nm-vpn-plugin-utils.c
+shared/nm-utils/nm-vpn-plugin-utils.c
 src/nm-openvpn-service.c
 src/nm-openvpn-service-openvpn-helper.c
 [type: gettext/glade]properties/nm-openvpn-dialog.ui
diff --git a/properties/nm-openvpn-editor-plugin.c b/properties/nm-openvpn-editor-plugin.c
index 7c1e59c..3fcf898 100644
--- a/properties/nm-openvpn-editor-plugin.c
+++ b/properties/nm-openvpn-editor-plugin.c
@@ -36,7 +36,7 @@
 #ifdef NM_VPN_OLD
 #include "nm-openvpn-editor.h"
 #else
-#include "nm-vpn/nm-vpn-plugin-utils.h"
+#include "nm-utils/nm-vpn-plugin-utils.h"
 #endif
 
 #include "import-export.h"
diff --git a/shared/Makefile.am b/shared/Makefile.am
index 06dbb70..b8cf611 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -44,9 +44,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) \
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-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index cb5ad3c..0550cd7 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -41,7 +41,7 @@
 #include <syslog.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-openvpn-service.c b/src/nm-openvpn-service.c
index f6c6c12..e5a1aa9 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -48,7 +48,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]