[calls/wip/ui-manage-accounts: 17/26] account-manager: Add API to load credentials from a GKeyFile




commit 5f28fc1299cb38854e33d8c5f6cf89a5831e32ff
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Fri Jun 11 09:45:54 2021 +0200

    account-manager: Add API to load credentials from a GKeyFile

 src/calls-account-manager.c | 19 +++++++++++++++++++
 src/calls-account-manager.h |  3 +++
 2 files changed, 22 insertions(+)
---
diff --git a/src/calls-account-manager.c b/src/calls-account-manager.c
index 252058d8..f463c141 100644
--- a/src/calls-account-manager.c
+++ b/src/calls-account-manager.c
@@ -548,3 +548,22 @@ calls_account_manager_remove_credentials (CallsAccountManager *self,
 
   return TRUE;
 }
+
+
+void
+calls_account_manager_load_from_keyfile (CallsAccountManager *self,
+                                         GKeyFile            *key_file)
+{
+  g_auto (GStrv) groups = NULL;
+
+  g_return_if_fail (CALLS_IS_ACCOUNT_MANAGER (self));
+  g_return_if_fail (key_file);
+
+  groups = g_key_file_get_groups (key_file, NULL);
+  for (gsize i = 0; groups[i] != NULL; i++) {
+    g_autoptr (CallsCredentials) credentials =
+      calls_credentials_new_from_keyfile (key_file, groups[i]);
+
+    calls_account_manager_add_credentials (self, credentials);
+  }
+}
diff --git a/src/calls-account-manager.h b/src/calls-account-manager.h
index 1b1ac8a9..4102f41c 100644
--- a/src/calls-account-manager.h
+++ b/src/calls-account-manager.h
@@ -68,5 +68,8 @@ CallsCredentials         *calls_account_manager_get_credentials          (CallsA
 gboolean                  calls_account_manager_update_credentials       (CallsAccountManager  *self,
                                                                           const char           *uuid,
                                                                           CallsCredentials     *new_creds);
+void                      calls_account_manager_load_from_keyfile        (CallsAccountManager  *self,
+                                                                          GKeyFile             *key_file);
+
 
 G_END_DECLS


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