From f6a48f89e945896cc4b40189627db5fa0cd2cf90 Mon Sep 17 00:00:00 2001
From: Olivier Dion <olivier.dion@savoirfairelinux.com>
Date: Fri, 29 Oct 2021 14:28:56 -0400
Subject: [PATCH] agent/bindings/account: Add bindings

Change-Id: Ifc363fee36bd10fba9211cddaa03d6fbd8e99d49
---
 test/agent/src/bindings/account.h | 52 ++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/test/agent/src/bindings/account.h b/test/agent/src/bindings/account.h
index f057dc256b..b9a26004a1 100644
--- a/test/agent/src/bindings/account.h
+++ b/test/agent/src/bindings/account.h
@@ -23,6 +23,7 @@
 /* Jami */
 #include "jami/callmanager_interface.h"
 #include "jami/configurationmanager_interface.h"
+#include "jami/presencemanager_interface.h"
 
 /* Agent */
 #include "utils.h"
@@ -67,7 +68,8 @@ static SCM export_to_file_binding(SCM accountID_str, SCM path_str, SCM passwd_st
                                         from_guile(passwd_str_optional)));
 }
 
-static SCM add_account_binding(SCM details_alist, SCM accountID_str_optional)
+static SCM
+add_account_binding(SCM details_alist, SCM accountID_str_optional)
 {
     LOG_BINDING();
 
@@ -79,6 +81,50 @@ static SCM add_account_binding(SCM details_alist, SCM accountID_str_optional)
                                       from_guile(accountID_str_optional)));
 }
 
+static SCM
+accept_trust_request_binding(SCM accountID_str, SCM from_uri_str)
+{
+    LOG_BINDING();
+
+    return to_guile(DRing::acceptTrustRequest(from_guile(accountID_str),
+                                              from_guile(from_uri_str)));
+}
+
+static SCM
+send_trust_request_binding(SCM accountID_str, SCM to_uri_str, SCM payload_vector_uint8_optional)
+{
+    LOG_BINDING();
+
+    if (SCM_UNBNDP(payload_vector_uint8_optional)) {
+        payload_vector_uint8_optional = scm_c_make_vector(0, SCM_UNDEFINED);
+    }
+
+    DRing::sendTrustRequest(from_guile(accountID_str),
+                            from_guile(to_uri_str),
+                            from_guile(payload_vector_uint8_optional));
+    return SCM_UNDEFINED;
+}
+
+static SCM
+get_contacts_binding(SCM accountID_str)
+{
+    LOG_BINDING();
+
+    return to_guile(DRing::getContacts(from_guile(accountID_str)));
+}
+
+static SCM
+subscribe_buddy_binding(SCM accountID_str, SCM peer_uri_str, SCM flag_bool)
+{
+    LOG_BINDING();
+
+    DRing::subscribeBuddy(from_guile(accountID_str),
+                          from_guile(peer_uri_str),
+                          from_guile(flag_bool));
+
+    return SCM_UNDEFINED;
+}
+
 static void
 install_account_primitives(void *)
 {
@@ -87,4 +133,8 @@ install_account_primitives(void *)
     define_primitive("send-register", 2, 0, 0, (void*) send_register_binding);
     define_primitive("account->archive", 2, 1, 0, (void*) export_to_file_binding);
     define_primitive("add", 1, 1, 0, (void*) add_account_binding);
+    define_primitive("accept-trust-request", 2, 0, 0, (void*) accept_trust_request_binding);
+    define_primitive("send-trust-request", 2, 1, 0, (void*) send_trust_request_binding);
+    define_primitive("get-contacts", 1, 0, 0, (void*) get_contacts_binding);
+    define_primitive("subscribe-buddy", 3, 0, 0, (void*) subscribe_buddy_binding);
 }
-- 
GitLab