/* 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 (1)

/**
 * NMA_MINOR_VERSION:
 *
 * Evaluates to the minor version number of NetworkManager which this source
 * is compiled against.
 */
#define NMA_MINOR_VERSION (8)

/**
 * NMA_MICRO_VERSION:
 *
 * Evaluates to the micro version number of NetworkManager which this source
 * compiled against.
 */
#define NMA_MICRO_VERSION (22)

/**
 * 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_1_8_2  (NMA_ENCODE_VERSION (1, 8, 2))
#define NMA_VERSION_1_8_4  (NMA_ENCODE_VERSION (1, 8, 4))
#define NMA_VERSION_1_8_6  (NMA_ENCODE_VERSION (1, 8, 6))
#define NMA_VERSION_1_8_8  (NMA_ENCODE_VERSION (1, 8, 8))
#define NMA_VERSION_1_8_10 (NMA_ENCODE_VERSION (1, 8, 10))
#define NMA_VERSION_1_8_12 (NMA_ENCODE_VERSION (1, 8, 12))
#define NMA_VERSION_1_8_22 (NMA_ENCODE_VERSION (1, 8, 22))

#define NMA_VERSION_CUR_STABLE  NMA_VERSION_1_8_10
#define NMA_VERSION_NEXT_STABLE NMA_VERSION_1_8_22

#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

#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8_22
# define NMA_AVAILABLE_IN_1_8_22            G_UNAVAILABLE(1.8,22)
#else
# define NMA_AVAILABLE_IN_1_8_22
#endif

#endif  /* NMA_VERSION_H */
