diff --git a/test/agent/Makefile.am b/test/agent/Makefile.am index e5a8d2f9b6a6867927cca753d5f7508a178b05a9..0427168e28b4b261d468e35cae5d4ff9b663b049 100644 --- a/test/agent/Makefile.am +++ b/test/agent/Makefile.am @@ -5,14 +5,15 @@ AM_LDFLAGS += $(GUILE_LIBS) noinst_PROGRAMS = agent.exe -agent_exe_SOURCES = \ - src/main.cpp \ - src/utils.h \ - src/bindings/bindings.cpp \ - src/bindings/bindings.h \ - src/bindings/account.h \ - src/bindings/call.h \ - src/bindings/signal.cpp \ +agent_exe_SOURCES = \ + src/main.cpp \ + src/utils.h \ + src/bindings/bindings.cpp \ + src/bindings/bindings.h \ + src/bindings/account.h \ + src/bindings/call.h \ + src/bindings/conversation.h \ + src/bindings/signal.cpp \ src/bindings/signal.h agent_exe_LDADD = $(top_builddir)/src/libring.la diff --git a/test/agent/src/bindings/bindings.cpp b/test/agent/src/bindings/bindings.cpp index 6876234f53b040ca204dfdf8be6a1844f31bf681..f66f16b295f70cac9567a1fe286df60b8ec2c3e4 100644 --- a/test/agent/src/bindings/bindings.cpp +++ b/test/agent/src/bindings/bindings.cpp @@ -24,6 +24,7 @@ /* Include module's bindings here */ #include "bindings/account.h" #include "bindings/call.h" +#include "bindings/conversation.h" #include "bindings/logger.h" #include "bindings/signal.h" @@ -37,6 +38,7 @@ install_scheme_primitives() load_module("jami account", install_account_primitives); load_module("jami call", install_call_primitives); + load_module("jami conversation", install_conversation_primitives); load_module("jami logger bindings", install_logger_primitives); load_module("jami signal", install_signal_primitives); } diff --git a/test/agent/src/bindings/conversation.h b/test/agent/src/bindings/conversation.h new file mode 100644 index 0000000000000000000000000000000000000000..f94b1b98ff79ab29efaadf3356147dafb9b83de9 --- /dev/null +++ b/test/agent/src/bindings/conversation.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2021 Savoir-faire Linux Inc. + * + * Author: Olivier Dion <olivier.dion@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +/* Jami */ +#include "jami/conversation_interface.h" + +/* Agent */ +#include "utils.h" + +static SCM +get_conversations_binding(SCM accountID_str) +{ + LOG_BINDING(); + + return to_guile(DRing::getConversations(from_guile(accountID_str))); +} + +static SCM +get_conversation_members_binding(SCM accountID_str, SCM conversationID_str) +{ + LOG_BINDING(); + + return to_guile(DRing::getConversationMembers(from_guile(accountID_str), + from_guile(conversationID_str))); +} + +static SCM +accept_conversation_binding(SCM accountID_str, SCM conversationID_str) +{ + LOG_BINDING(); + + DRing::acceptConversationRequest(from_guile(accountID_str), + from_guile(conversationID_str)); + + return SCM_UNDEFINED; +} + +static SCM +send_message_binding(SCM accountID_str, SCM conversationID_str, SCM message_str, + SCM parent_str_optional) +{ + LOG_BINDING(); + + if (SCM_UNBNDP(parent_str_optional)) { + DRing::sendMessage(from_guile(accountID_str), + from_guile(conversationID_str), + from_guile(message_str), + ""); + + } else { + DRing::sendMessage(from_guile(accountID_str), + from_guile(conversationID_str), + from_guile(message_str), + from_guile(parent_str_optional)); + } + + + return SCM_UNDEFINED; +} + +static void +install_conversation_primitives(void *) +{ + define_primitive("get-conversations", 1, 0, 0, + (void*) get_conversations_binding); + + define_primitive("get-conversation-members", 2, 0, 0, + (void*) get_conversation_members_binding); + + define_primitive("accept-conversation", 2, 0, 0, + (void*) accept_conversation_binding); + + define_primitive("send-message", 3, 1, 0, + (void*) send_message_binding); +}