[calls/wip/ui-manage-accounts: 8/26] credentials: generate uuid and add API to query it




commit 13c97dd5cb5ddd47f88db005d529515364144c0d
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Thu Jun 3 01:13:14 2021 +0200

    credentials: generate uuid and add API to query it
    
    This uuid will be used in the account management to refer to credentials.

 src/calls-credentials.c | 20 ++++++++++++++++++++
 src/calls-credentials.h |  1 +
 2 files changed, 21 insertions(+)
---
diff --git a/src/calls-credentials.c b/src/calls-credentials.c
index 853118ba..60ce9f6e 100644
--- a/src/calls-credentials.c
+++ b/src/calls-credentials.c
@@ -72,6 +72,8 @@ struct _CallsCredentials
   char *transport_protocol;
   CallsCredentialsType credentials_type;
 
+  char *uuid;
+
   gboolean auto_connect;
 
   /* The account these credentials are currently used for */
@@ -232,6 +234,7 @@ calls_credentials_finalize (GObject *object)
   g_free (self->user);
   g_free (self->password);
   g_free (self->transport_protocol);
+  g_free (self->uuid);
   g_free (self->account);
 
   G_OBJECT_CLASS (calls_credentials_parent_class)->finalize (object);
@@ -333,6 +336,7 @@ calls_credentials_class_init (CallsCredentialsClass *klass)
 static void
 calls_credentials_init (CallsCredentials *self)
 {
+  self->uuid = g_uuid_string_random ();
 }
 
 
@@ -591,3 +595,19 @@ calls_credentials_is_ready (CallsCredentials *self)
 
   return FALSE;
 }
+
+/**
+ * calls_credentials_get_uuid:
+ * @self: A #CallsCredentials
+ *
+ * Get the autogenerated uuid for @self
+ *
+ * Returns: The uuid for the credentials
+ */
+const char *
+calls_credentials_get_uuid (CallsCredentials *self)
+{
+  g_return_val_if_fail (CALLS_IS_CREDENTIALS (self), FALSE);
+
+  return self->uuid;
+}
diff --git a/src/calls-credentials.h b/src/calls-credentials.h
index 61fbd1f9..4c9e3d76 100644
--- a/src/calls-credentials.h
+++ b/src/calls-credentials.h
@@ -62,6 +62,7 @@ CallsAccount           *calls_credentials_get_account             (CallsCredenti
 gboolean                calls_credentials_update_from_credentials (CallsCredentials *self,
                                                                    CallsCredentials *other);
 gboolean                calls_credentials_is_ready                (CallsCredentials *self);
+const char             *calls_credentials_get_uuid                (CallsCredentials *self);
 
 G_END_DECLS
 


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