[phodav] Adjust to GLib's GUuid
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [phodav] Adjust to GLib's GUuid
- Date: Thu, 16 Feb 2017 16:59:25 +0000 (UTC)
commit 40ffc950165b098b3ea557e7282bb1b2dc67e03a
Author: Pavel Grunt <pgrunt redhat com>
Date: Thu Feb 16 16:16:15 2017 +0100
Adjust to GLib's GUuid
It was introduced it GLib > 2.51
Avoid building our version of GUuid if GLib's is available
https://bugzilla.gnome.org/show_bug.cgi?id=778761
Makefile.am | 9 +++++++--
configure.ac | 6 ++++++
libphodav/guuid.c | 6 +++---
libphodav/guuid.h | 2 +-
libphodav/phodav-method-lock.c | 2 +-
5 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7c3cbf4..b9f781b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,8 +26,6 @@ libphodav_include_HEADERS = \
$(NULL)
libphodav_2_0_la_SOURCES = \
- libphodav/guuid.c \
- libphodav/guuid.h \
libphodav/phodav-priv.h \
libphodav/phodav-path.c \
libphodav/phodav-path.h \
@@ -51,6 +49,13 @@ libphodav_2_0_la_SOURCES = \
libphodav/phodav-utils.h \
$(NULL)
+if BUILD_GUUID
+libphodav_2_0_la_SOURCES += \
+ libphodav/guuid.c \
+ libphodav/guuid.h \
+ $(NULL)
+endif
+
libphodav_2_0_la_CFLAGS = \
$(GIO_CFLAGS) \
$(SOUP_CFLAGS) \
diff --git a/configure.ac b/configure.ac
index d87524e..6c5b364 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,12 @@ AC_CHECK_HEADERS([attr/xattr.h])
PKG_CHECK_MODULES(GIO, [$gio_os])
PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.48.0 libxml-2.0)
+# GLib's GUuid was introduce in GLib 2.51
+# https://bugzilla.gnome.org/show_bug.cgi?id=639078
+# do not build our version of it conditionally
+PKG_CHECK_EXISTS([glib-2.0 > 2.51], [build_guuid=no], [build_guuid=yes])
+AM_CONDITIONAL(BUILD_GUUID, [test "x$build_guuid" = "xyes"])
+
AC_ARG_WITH([avahi],
AS_HELP_STRING([--without-avahi], [Build without avahi/mdns]))
diff --git a/libphodav/guuid.c b/libphodav/guuid.c
index 7be07c3..0e37582 100644
--- a/libphodav/guuid.c
+++ b/libphodav/guuid.c
@@ -45,7 +45,7 @@
*
* There are different mechanisms to generate UUIDs. The UUID
* specification defines 5 versions. If all you want is a unique ID,
- * you should probably call g_uuid_random() or g_uuid_generate4(),
+ * you should probably call g_uuid_string_random() or g_uuid_generate4(),
* which is the version 4.
*
* If you want to generate UUID based on a name within a namespace
@@ -338,7 +338,7 @@ g_uuid_generate4 (GUuid *uuid)
}
/**
- * g_uuid_random:
+ * g_uuid_string_random:
*
* Generates a random UUID (RFC 4122 version 4) as a string.
*
@@ -346,7 +346,7 @@ g_uuid_generate4 (GUuid *uuid)
* Since: 2.40
**/
gchar *
-g_uuid_random (void)
+g_uuid_string_random (void)
{
GUuid uuid;
diff --git a/libphodav/guuid.h b/libphodav/guuid.h
index 1cda776..59e1e84 100644
--- a/libphodav/guuid.h
+++ b/libphodav/guuid.h
@@ -77,7 +77,7 @@ gboolean g_uuid_from_string (const gchar *str,
gssize len,
GUuid *uuid);
-gchar * g_uuid_random (void);
+gchar * g_uuid_string_random (void);
void g_uuid_generate4 (GUuid *uuid);
const GUuid * g_uuid_get_namespace (GUuidNamespace namespace);
diff --git a/libphodav/phodav-method-lock.c b/libphodav/phodav-method-lock.c
index e7e74c0..01ce238 100644
--- a/libphodav/phodav-method-lock.c
+++ b/libphodav/phodav-method-lock.c
@@ -203,7 +203,7 @@ phodav_method_lock (PathHandler *handler, SoupMessage *msg,
g_debug ("lock depth:%d scope:%d type:%d owner:%p, timeout: %u",
depth, scope, type, owner, timeout);
- uuid = g_uuid_random ();
+ uuid = g_uuid_string_random ();
token = g_strdup_printf ("urn:uuid:%s", uuid);
ltoken = g_strdup_printf ("<%s>", token);
soup_message_headers_append (msg->response_headers, "Lock-Token", ltoken);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]