[gnome-notes] providers: Simplify generating uuid



commit 758510a1a940dfaba942d800a72f8c2007cf4a6e
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Mon Jan 4 22:20:45 2021 +0530

    providers: Simplify generating uuid
    
    We have g_uuid_string_random() in glib to generate uuid.
    Use that and remove libuuid dependency

 meson.build                                |  1 -
 src/libbiji/provider/biji-local-provider.c |  9 ++-------
 src/libbiji/provider/biji-own-cloud-note.c | 10 ++--------
 3 files changed, 4 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index 70e4b09..3b1b1ba 100644
--- a/meson.build
+++ b/meson.build
@@ -122,7 +122,6 @@ bijiben_deps = [
   dependency('libedataserver-1.2', version: '>= 3.13.90'),
   dependency('libhandy-0.0', version: '>= 0.0.10'),
   dependency('libxml-2.0'),
-  dependency('uuid'),
   dependency('webkit2gtk-4.0', version: '>= 2.26'),
   cc.find_library('m')
 ]
diff --git a/src/libbiji/provider/biji-local-provider.c b/src/libbiji/provider/biji-local-provider.c
index ebc4fa7..e027a17 100644
--- a/src/libbiji/provider/biji-local-provider.c
+++ b/src/libbiji/provider/biji-local-provider.c
@@ -25,8 +25,6 @@
  */
 
 
-#include <uuid/uuid.h>
-
 #include "biji-local-note.h"
 #include "biji-local-provider.h"
 
@@ -382,12 +380,9 @@ biji_local_provider_init (BijiLocalProvider *self)
 static gchar *
 _get_uuid (void)
 {
-  uuid_t unique;
-  char out[40];
+  g_autofree char *uuid = g_uuid_string_random ();
 
-  uuid_generate (unique);
-  uuid_unparse_lower (unique, out);
-  return g_strdup_printf ("%s.note", out);
+  return g_strdup_printf ("%s.note", uuid);
 }
 
 
diff --git a/src/libbiji/provider/biji-own-cloud-note.c b/src/libbiji/provider/biji-own-cloud-note.c
index 4f5336e..6930d07 100644
--- a/src/libbiji/provider/biji-own-cloud-note.c
+++ b/src/libbiji/provider/biji-own-cloud-note.c
@@ -21,8 +21,6 @@
  * Markdown is not implemented.
  */
 
-#include <uuid/uuid.h>
-
 #include "biji-info-set.h"
 #include "biji-item.h"
 #include "biji-own-cloud-note.h"
@@ -414,15 +412,11 @@ BijiNoteObj        *biji_own_cloud_note_new_from_info           (BijiOwnCloudPro
 
   if (info->url == NULL)
   {
-    uuid_t unique;
-    char out[40];
-
-    uuid_generate (unique);
-    uuid_unparse_lower (unique, out);
+    g_autofree char *uuid = g_uuid_string_random ();
 
     info->url = g_strdup_printf ("%s/%s.txt",
                   biji_own_cloud_provider_get_readable_path (prov),
-                  out);
+                  uuid);
   }
 
   /* Now actually create the stuff */


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