[network-manager-applet/lr/pkcs11: 5/18] libnma: add and use version macros



commit c6dc09b8c6bf12c39cd3538e1e5dcc391dcaf3c3
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Fri Mar 3 15:09:06 2017 +0100

    libnma: add and use version macros

 .gitignore                   |    1 +
 Makefile.am                  |    5 ++-
 configure.ac                 |   19 ++++++-
 src/libnma/nma-version.h.in  |  120 ++++++++++++++++++++++++++++++++++++++++++
 src/libnma/nma-wifi-dialog.h |   10 ++--
 5 files changed, 149 insertions(+), 6 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 611dc9e..41597bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ src/libnma/NMA-1.0.gir
 src/libnma/NMA-1.0.typelib
 src/libnma/nma-resources.c
 src/libnma/nma-resources.h
+src/libnma/nma-version.h
 src/libnm-gtk/libnm-gtk.pc
 src/libnm-gtk/NMGtk-1.0.gir
 src/libnm-gtk/NMGtk-1.0.typelib
diff --git a/Makefile.am b/Makefile.am
index 8834c0a..ed407ac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -474,6 +474,7 @@ libnma_c_gen = \
        src/libnma/nma-resources.c
 
 libnma_h_pub = \
+       src/libnma/nma-version.h \
        src/libnma/nma-wifi-dialog.h \
        src/libnma/nma-mobile-wizard.h \
        src/libnma/nma-mobile-providers.h \
@@ -549,6 +550,7 @@ INTROSPECTION_GIRS += src/libnma/NMA-1.0.gir
 endif
 
 EXTRA_DIST += \
+       src/libnma/nma-version.h.in \
        src/libnma/libnma.pc.in \
        src/libnma/libnma.ver \
        src/libnma/wifi.ui \
@@ -847,7 +849,8 @@ HFILE_GLOB = $(top_srcdir)/src/libnma/*.h
 CFILE_GLOB = $(top_srcdir)/src/libnma/*.c
 
 IGNORE_HFILES = \
-       nma-resources.h
+       nma-resources.h \
+       nma-version.h
 
 mkdb_ignore_c_files = \
        nma-resources.c
diff --git a/configure.ac b/configure.ac
index 17878cc..d1c8067 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,13 @@
 AC_PREREQ([2.63])
+
+m4_define([nma_major_version], [1])
+m4_define([nma_minor_version], [7])
+m4_define([nma_micro_version], [0])
+m4_define([nma_version],
+          [nma_major_version.nma_minor_version.nma_micro_version])
+
 AC_INIT([nm-applet],
-        [1.7.0],
+        [nma_version],
         [https://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager],
         [network-manager-applet])
 
@@ -11,6 +18,15 @@ AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wno-portability])
 AM_MAINTAINER_MODE([enable])
 AM_SILENT_RULES([yes])
 
+NMA_MAJOR_VERSION=nma_major_version
+NMA_MINOR_VERSION=nma_minor_version
+NMA_MICRO_VERSION=nma_micro_version
+NMA_VERSION=nma_version
+AC_SUBST(NMA_MAJOR_VERSION)
+AC_SUBST(NMA_MINOR_VERSION)
+AC_SUBST(NMA_MICRO_VERSION)
+AC_SUBST(NMA_VERSION)
+
 dnl
 dnl Require programs
 dnl
@@ -183,6 +199,7 @@ po/Makefile.in
 man/nm-applet.1
 man/nm-connection-editor.1
 org.gnome.nm-applet.gschema.xml
+src/libnma/nma-version.h
 ])
 AC_OUTPUT
 
diff --git a/src/libnma/nma-version.h.in b/src/libnma/nma-version.h.in
new file mode 100644
index 0000000..bcdb5bd
--- /dev/null
+++ b/src/libnma/nma-version.h.in
@@ -0,0 +1,120 @@
+/* NetworkManager Applet -- allow user control over networking
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2011-2017 Red Hat, Inc.
+ */
+
+#ifndef NMA_VERSION_H
+#define NMA_VERSION_H
+
+#include <glib.h>
+
+/**
+ * NMA_MAJOR_VERSION:
+ *
+ * Evaluates to the major version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NMA_MAJOR_VERSION (@NMA_MAJOR_VERSION@)
+
+/**
+ * NMA_MINOR_VERSION:
+ *
+ * Evaluates to the minor version number of NetworkManager which this source
+ * is compiled against.
+ */
+#define NMA_MINOR_VERSION (@NMA_MINOR_VERSION@)
+
+/**
+ * NMA_MICRO_VERSION:
+ *
+ * Evaluates to the micro version number of NetworkManager which this source
+ * compiled against.
+ */
+#define NMA_MICRO_VERSION (@NMA_MICRO_VERSION@)
+
+/**
+ * NMA_CHECK_VERSION:
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns: %TRUE if the version of the NetworkManager header files
+ * is the same as or newer than the passed-in version.
+ */
+#define NMA_CHECK_VERSION(major,minor,micro)                         \
+    (NMA_MAJOR_VERSION > (major) ||                                  \
+     (NMA_MAJOR_VERSION == (major) && NMA_MINOR_VERSION > (minor)) || \
+     (NMA_MAJOR_VERSION == (major) && NMA_MINOR_VERSION == (minor) && NMA_MICRO_VERSION >= (micro)))
+
+#define NMA_ENCODE_VERSION(major,minor,micro) ((major) << 16 | (minor) << 8 | (micro))
+
+#define NMA_VERSION_1_2    (NMA_ENCODE_VERSION (1, 2, 0))
+#define NMA_VERSION_1_4    (NMA_ENCODE_VERSION (1, 4, 0))
+#define NMA_VERSION_1_8    (NMA_ENCODE_VERSION (1, 8, 0))
+
+#define NMA_VERSION_CUR_STABLE  NMA_VERSION_1_4
+#define NMA_VERSION_NEXT_STABLE NMA_VERSION_1_8
+
+#define NMA_VERSION NMA_ENCODE_VERSION (NMA_MAJOR_VERSION, NMA_MINOR_VERSION, NMA_MICRO_VERSION)
+
+/* Deprecation / Availability macros */
+
+#if !defined (NMA_VERSION_MIN_REQUIRED) || (NMA_VERSION_MIN_REQUIRED == 0)
+# undef NMA_VERSION_MIN_REQUIRED
+# define NMA_VERSION_MIN_REQUIRED (NMA_VERSION_CUR_STABLE)
+#endif
+
+#if !defined (NMA_VERSION_MAX_ALLOWED) || (NMA_VERSION_MAX_ALLOWED == 0)
+# undef NMA_VERSION_MAX_ALLOWED
+# define NMA_VERSION_MAX_ALLOWED (NMA_VERSION_NEXT_STABLE)
+#endif
+
+/* sanity checks */
+#if NMA_VERSION_MIN_REQUIRED > NMA_VERSION_NEXT_STABLE
+#error "NMA_VERSION_MIN_REQUIRED must be <= NMA_VERSION_NEXT_STABLE"
+#endif
+#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_MIN_REQUIRED
+#error "NMA_VERSION_MAX_ALLOWED must be >= NMA_VERSION_MIN_REQUIRED"
+#endif
+#if NMA_VERSION_MIN_REQUIRED < NMA_VERSION_1_2
+#error "NMA_VERSION_MIN_REQUIRED must be >= NMA_VERSION_1_2"
+#endif
+
+#if NMA_VERSION_MIN_REQUIRED >= NMA_VERSION_1_2
+# define NMA_DEPRECATED_IN_1_2           G_DEPRECATED
+# define NMA_DEPRECATED_IN_1_2_FOR(f)    G_DEPRECATED_FOR(f)
+#else
+# define NMA_DEPRECATED_IN_1_2
+# define NMA_DEPRECATED_IN_1_2_FOR(f)
+#endif
+
+#if NMA_VERSION_MIN_REQUIRED >= NMA_VERSION_1_8
+# define NMA_DEPRECATED_IN_1_8           G_DEPRECATED
+# define NMA_DEPRECATED_IN_1_8_FOR(f)    G_DEPRECATED_FOR(f)
+#else
+# define NMA_DEPRECATED_IN_1_8
+# define NMA_DEPRECATED_IN_1_8_FOR(f)
+#endif
+
+#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8
+# define NMA_AVAILABLE_IN_1_8            G_UNAVAILABLE(1,8)
+#else
+# define NMA_AVAILABLE_IN_1_8
+#endif
+
+#endif  /* NMA_VERSION_H */
diff --git a/src/libnma/nma-wifi-dialog.h b/src/libnma/nma-wifi-dialog.h
index 4c6addd..bb7a8c1 100644
--- a/src/libnma/nma-wifi-dialog.h
+++ b/src/libnma/nma-wifi-dialog.h
@@ -28,6 +28,8 @@
 
 #include <NetworkManager.h>
 
+#include "nma-version.h"
+
 #define NMA_TYPE_WIFI_DIALOG            (nma_wifi_dialog_get_type ())
 #define NMA_WIFI_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WIFI_DIALOG, 
NMAWifiDialog))
 #define NMA_WIFI_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WIFI_DIALOG, 
NMAWifiDialogClass))
@@ -59,16 +61,16 @@ NMConnection * nma_wifi_dialog_get_connection (NMAWifiDialog *self,
                                                NMDevice **device,
                                                NMAccessPoint **ap);
 
-GLIB_DEPRECATED
+NMA_DEPRECATED_IN_1_2
 GtkWidget * nma_wifi_dialog_nag_user (NMAWifiDialog *self);
 
-GLIB_DEPRECATED
+NMA_DEPRECATED_IN_1_2
 void nma_wifi_dialog_set_nag_ignored (NMAWifiDialog *self, gboolean ignored);
 
-GLIB_DEPRECATED
+NMA_DEPRECATED_IN_1_2
 gboolean nma_wifi_dialog_get_nag_ignored (NMAWifiDialog *self);
 
-GLIB_DEPRECATED_FOR(nma_wifi_dialog_new_for_hidden)
+NMA_DEPRECATED_IN_1_2_FOR(nma_wifi_dialog_new_for_hidden)
 GtkWidget *nma_wifi_dialog_new_for_other (NMClient *client);
 
 #endif /* NMA_WIFI_DIALOG_H */


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