Blob Blame History Raw
From 9bd50802ae027422720b358eaea3c01f2a55ecab Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Thu, 5 Jan 2017 11:25:02 +0100
Subject: [PATCH] fix building with json-glib < 1.2.0

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
---
 CMakeLists.txt                      | 2 +-
 rhsm/rhsm-entitlement-certificate.c | 8 ++++++++
 rhsm/rhsm-utils.c                   | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2eff0df..887cce2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ find_package (PkgConfig REQUIRED)
 pkg_check_modules (GLIB REQUIRED glib-2.0>=2.44)
 pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.44)
 pkg_check_modules (GIO REQUIRED gio-2.0>=2.44)
-pkg_check_modules (JSON_GLIB REQUIRED json-glib-1.0>=1.2)
+pkg_check_modules (JSON_GLIB REQUIRED json-glib-1.0)
 pkg_check_modules (OPENSSL REQUIRED openssl)
 
 add_subdirectory (rhsm)
diff --git a/rhsm/rhsm-entitlement-certificate.c b/rhsm/rhsm-entitlement-certificate.c
index 5d37732..23b3b2c 100644
--- a/rhsm/rhsm-entitlement-certificate.c
+++ b/rhsm/rhsm-entitlement-certificate.c
@@ -20,6 +20,10 @@
 
 #include <string.h>
 
+#if !JSON_CHECK_VERSION (1, 2, 0)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonParser, g_object_unref)
+#endif
+
 /**
  * SECTION:rhsm-entitlement-certificate
  * @short_description: the entitlement certificate
@@ -147,7 +151,11 @@ parse_entitlement_data (const gchar  *data,
   g_autoptr(GInputStream) zstream = g_memory_input_stream_new_from_data (zdata, zlen, g_free);
   g_autoptr(GZlibDecompressor) decompressor = g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB);
   g_autoptr(GInputStream) cstream = g_converter_input_stream_new (zstream, G_CONVERTER (decompressor));
+#if JSON_CHECK_VERSION (1, 2, 0)
   g_autoptr(JsonParser) parser = json_parser_new_immutable ();
+#else
+  g_autoptr(JsonParser) parser = json_parser_new ();
+#endif
   if (!json_parser_load_from_stream (parser, cstream, NULL, error))
     return NULL;
 
diff --git a/rhsm/rhsm-utils.c b/rhsm/rhsm-utils.c
index d9bb4a2..956633d 100644
--- a/rhsm/rhsm-utils.c
+++ b/rhsm/rhsm-utils.c
@@ -27,6 +27,10 @@
 #include <gio/gio.h>
 #include <json-glib/json-glib.h>
 
+#if !JSON_CHECK_VERSION (1, 2, 0)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonNode, json_node_free)
+#endif
+
 /*
  * rhsm_utils_str_replace:
  * @haystack: (inout): pointer to a nul-terminated string.
-- 
2.12.1