diff --git a/test/agent/Makefile.am b/test/agent/Makefile.am index 34aae1f32..28cf9cabe 100644 --- a/test/agent/Makefile.am +++ b/test/agent/Makefile.am @@ -9,6 +9,7 @@ agent_SOURCES = \ src/main.cpp \ src/utils.h \ src/bindings/bindings.cpp \ - src/bindings/bindings.h + src/bindings/bindings.h \ + src/bindings/account.h agent_LDADD = $(top_builddir)/src/libring.la diff --git a/test/agent/src/bindings/account.h b/test/agent/src/bindings/account.h new file mode 100644 index 000000000..a5dd054ea --- /dev/null +++ b/test/agent/src/bindings/account.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2021 Savoir-faire Linux Inc. + * + * Author: Olivier Dion + * + * 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/callmanager_interface.h" +#include "jami/configurationmanager_interface.h" + +/* Agent */ +#include "utils.h" + +static SCM set_details_binding(SCM accountID_str, SCM details_alist) +{ + DRing::setAccountDetails(from_guile(accountID_str), + from_guile(details_alist)); + return SCM_UNDEFINED; +} + +static SCM get_details_binding(SCM accountID_str) +{ + return to_guile(DRing::getAccountDetails(from_guile(accountID_str))); +} + +static SCM send_register_binding(SCM accountID_str, SCM enable_boolean) +{ + DRing::sendRegister(from_guile(accountID_str), + from_guile(enable_boolean)); + + return SCM_UNDEFINED; +} + +static SCM export_to_file_binding(SCM accountID_str, SCM path_str, SCM passwd_str_optional) +{ + if (SCM_UNBNDP(passwd_str_optional)) { + return to_guile(DRing::exportToFile(from_guile(accountID_str), + from_guile(path_str))); + } + + return to_guile(DRing::exportToFile(from_guile(accountID_str), + from_guile(path_str), + from_guile(passwd_str_optional))); +} + +static SCM add_account_binding(SCM details_alist, SCM accountID_str_optional) +{ + if (SCM_UNBNDP(accountID_str_optional)) { + return to_guile(DRing::addAccount(from_guile(details_alist))); + } + + return to_guile(DRing::addAccount(from_guile(details_alist), + from_guile(accountID_str_optional))); +} + +static void +install_account_primitives(void *) +{ + define_primitive("set-details", 2, 0, 0, (void*) set_details_binding); + define_primitive("get-details", 1, 0, 0, (void*) get_details_binding); + 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); +} diff --git a/test/agent/src/bindings/bindings.cpp b/test/agent/src/bindings/bindings.cpp index 3b71dfc66..4eb53f4b9 100644 --- a/test/agent/src/bindings/bindings.cpp +++ b/test/agent/src/bindings/bindings.cpp @@ -22,11 +22,13 @@ #include "bindings/bindings.h" /* Include module's bindings here */ +#include "bindings/account.h" void install_scheme_primitives() { /* Define modules here */ + scm_c_define_module("jami account", install_account_primitives, NULL); } /*