Commit 0666fba9 authored by Timothée Jaussoin's avatar Timothée Jaussoin
Browse files

Implement FlexiAPI REST API

Split some common code between the XMLRPC and REST API in utils files
Do not create local variable named mRequestCallbacks in AccountCreatorFlexiAPI constructor
Do create objects with new and delete them using free
Complete endpoints integration
Add a new flexiapi_url config variable in the LinphoneCore configuration
Split account creator tests in two, local and xmlrpc ones
Cleanup and remove unused code
Echap some URL parameters in FlexiAPIClient
Rename XMLRPC specific methods
Implement more FlexiSIP endpoints in the account manager
Create a new Account Creator FlexiAPI test suit
Put in common some functions of the Account Creator test suits
Complete FlexiAPIClient and the related account creator connectors
Load libjsoncpp properly
Fix response parameter in FlexiAPIClient responses
Use the new callback event system in the XMLRPC tests
Rename a few methods
Add comments to make some code more explicit
Pass jsoncpp to object
Add XCODE static/object for jsoncpp
Move the account_cre...
parent e5cc51d6
......@@ -45,6 +45,7 @@ option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES)
option(ENABLE_CSHARP_WRAPPER "Build the C# wrapper for Liblinphone." OFF)
option(ENABLE_CXX_WRAPPER "Build the C++ wrapper for Liblinphone." YES)
option(ENABLE_DB_STORAGE "Enable database storage." YES)
option(ENABLE_FLEXIAPI "Enable the FlexiAPI support for Liblinphone." YES)
option(ENABLE_SWIFT_WRAPPER "Build the swift wrapper sources for Liblinphone." OFF)
option(ENABLE_SWIFT_WRAPPER_COMPILATION "Compile and package the swift wrapper framework from the built sources." OFF)
option(ENABLE_JAZZY_DOC "Build the jazzy doc for swift module of Liblinphone." OFF)
......@@ -198,6 +199,11 @@ if(ENABLE_LDAP)
find_package(OpenLDAP REQUIRED)
endif()
if (ENABLE_FLEXIAPI)
find_package(jsoncpp REQUIRED)
set(HAVE_FLEXIAPI TRUE)
endif()
if(UNIX AND NOT APPLE)
include(CheckIncludeFiles)
check_include_files(libudev.h HAVE_LIBUDEV_H)
......
......@@ -45,10 +45,10 @@
#cmakedefine HAVE_CU_GET_SUITE 1
#cmakedefine HAVE_CU_CURSES 1
#cmakedefine HAVE_LIBUDEV_H 0
#cmakedefine HAVE_FLEXIAPI
#cmakedefine HAVE_LIME
#cmakedefine HAVE_LIME_X3DH
#cmakedefine HAVE_ADVANCED_IM
#cmakedefine HAVE_DB_STORAGE
#cmakedefine ENABLE_UPDATE_CHECK 1
#cmakedefine HAVE_GETIFADDRS
......@@ -37,8 +37,6 @@ list(APPEND LINPHONE_PRIVATE_HEADER_FILES
)
set(LINPHONE_SOURCE_FILES_C
account_creator.c
account_creator_service.c
authentication.c
bellesip_sal/sal_address_impl.c
bellesip_sal/sal_impl.c
......
......@@ -82,7 +82,7 @@ static bool_t realm_match(const char *realm1, const char *realm2){
/* Check if the LinphoneAuthInfo candidate is compatible with the requested algorithm. */
static bool_t check_algorithm_compatibility(const LinphoneAuthInfo *ai, const char *algorithm){
const char *ai_algorithm = linphone_auth_info_get_algorithm(ai);
if (algorithm == NULL) return TRUE;
if (linphone_auth_info_get_password(ai) != NULL){
/* We have the clear text password, so if the user didn't requested a specific algorithm, we can satisfy all algorithms.*/
......@@ -104,9 +104,9 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
for (elem=lc->auth_info;elem!=NULL;elem=elem->next) {
LinphoneAuthInfo *pinfo = (LinphoneAuthInfo*)elem->data;
if (username && linphone_auth_info_get_username(pinfo) && strcmp(username, linphone_auth_info_get_username(pinfo))==0)
if (username && linphone_auth_info_get_username(pinfo) && strcmp(username, linphone_auth_info_get_username(pinfo))==0)
{
if (!check_algorithm_compatibility(pinfo, algorithm)) {
continue;
}
......@@ -176,7 +176,7 @@ const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const ch
if (ai==NULL){
ai=find_auth_info(lc,username,NULL,NULL, algorithm, ignore_realm);
}
if (ai) ms_message("linphone_core_find_auth_info(): returning auth info username=%s, realm=%s", linphone_auth_info_get_username(ai) ? linphone_auth_info_get_username(ai) : "", linphone_auth_info_get_realm(ai) ? linphone_auth_info_get_realm(ai) : "");
return ai;
}
......@@ -213,7 +213,7 @@ static void write_auth_infos(LinphoneCore *lc){
}
LinphoneAuthInfo *linphone_core_create_auth_info(LinphoneCore *lc, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain) {
return linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
return linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
}
void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){
......@@ -246,7 +246,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
sai.username = (char *) linphone_auth_info_get_username(ai);
sai.userid = (char *)linphone_auth_info_get_userid(ai);
sai.realm = (char *) linphone_auth_info_get_realm(ai);
sai.password = (char *) linphone_auth_info_get_passwd(ai);
sai.password = (char *) linphone_auth_info_get_password(ai);
sai.ha1 = (char *)linphone_auth_info_get_ha1(ai);
sai.algorithm = (char *)linphone_auth_info_get_algorithm(ai);
if (linphone_auth_info_get_tls_cert(ai) && linphone_auth_info_get_tls_key(ai)) {
......
......@@ -113,7 +113,7 @@ static void call_received(SalCallOp *h) {
if (chatRoom) {
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->confirmJoining(h);
} else if (_linphone_core_is_conference_creation(lc, toAddr)) {
#ifdef HAVE_ADVANCED_IM
#ifdef HAVE_ADVANCED_IM
linphone_address_unref(toAddr);
linphone_address_unref(fromAddr);
if (sal_address_has_param(h->getRemoteContactAddress(), "text")) {
......@@ -163,7 +163,7 @@ static void call_received(SalCallOp *h) {
if (participantList.size() == 1) {
IdentityAddress participant = participantList.front();
shared_ptr<AbstractChatRoom> chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->findExhumableOneToOneChatRoom(
IdentityAddress(h->getTo()),
IdentityAddress(h->getTo()),
participant,
endToEndEncrypted == "true");
if (chatRoom) {
......@@ -210,9 +210,9 @@ static void call_received(SalCallOp *h) {
} else {
// TODO: handle media conference joining if the "text" feature tag is not present
}
/* First check if we can answer successfully to this invite */
LinphonePresenceActivity *activity = nullptr;
if ((linphone_presence_model_get_basic_status(lc->presence_model) == LinphonePresenceBasicStatusClosed)
......@@ -611,7 +611,7 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) {
if (ai) {
if (sai->mode == SalAuthModeHttpDigest) {
sai->userid = ms_strdup(linphone_auth_info_get_userid(ai) ? linphone_auth_info_get_userid(ai) : linphone_auth_info_get_username(ai));
sai->password = linphone_auth_info_get_passwd(ai)?ms_strdup(linphone_auth_info_get_passwd(ai)) : NULL;
sai->password = linphone_auth_info_get_password(ai)?ms_strdup(linphone_auth_info_get_password(ai)) : NULL;
sai->ha1 = linphone_auth_info_get_ha1(ai) ? ms_strdup(linphone_auth_info_get_ha1(ai)) : NULL;
......
......@@ -2655,21 +2655,47 @@ static void linphone_core_internal_publish_state_changed(LinphoneCore *lc, Linph
static void _linphone_core_init_account_creator_service(LinphoneCore *lc) {
LinphoneAccountCreatorService *service = linphone_account_creator_service_new();
service->account_creator_service_constructor_cb = linphone_account_creator_constructor_linphone;
service->account_creator_service_destructor_cb = NULL;
service->create_account_request_cb = linphone_account_creator_create_account_linphone;
service->delete_account_request_cb = linphone_account_creator_delete_account_linphone;
service->is_account_exist_request_cb = linphone_account_creator_is_account_exist_linphone;
service->confirmation_key_request_cb = linphone_account_creator_get_confirmation_key_linphone;
service->activate_account_request_cb = linphone_account_creator_activate_account_linphone;
service->is_account_activated_request_cb = linphone_account_creator_is_account_activated_linphone;
service->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_linphone;
service->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_linphone;
service->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_linphone;
service->is_account_linked_request_cb = linphone_account_creator_is_account_linked_linphone;
service->recover_account_request_cb = linphone_account_creator_recover_phone_account_linphone;
service->update_account_request_cb = linphone_account_creator_update_password_linphone;
service->login_linphone_account_request_cb = linphone_account_creator_login_linphone_account_linphone;
#ifdef HAVE_FLEXIAPI
const char* uri = linphone_config_get_string(lc->config, "sip", "flexiapi_url", NULL);
if (uri == NULL) {
#endif
linphone_account_creator_service_set_constructor_cb(service, linphone_account_creator_constructor_linphone_xmlrpc);
linphone_account_creator_service_set_destructor_cb(service, NULL);
linphone_account_creator_service_set_is_account_exist_cb(service, linphone_account_creator_is_account_exist_linphone_xmlrpc);
linphone_account_creator_service_set_activate_account_cb(service, linphone_account_creator_activate_phone_account_linphone_xmlrpc);
linphone_account_creator_service_set_is_account_activated_cb(service, linphone_account_creator_is_account_activated_linphone_xmlrpc);
linphone_account_creator_service_set_link_account_cb(service, linphone_account_creator_link_phone_number_with_account_linphone_xmlrpc);
linphone_account_creator_service_set_activate_alias_cb(service, linphone_account_creator_activate_phone_number_link_linphone_xmlrpc);
linphone_account_creator_service_set_is_account_linked_cb(service, linphone_account_creator_is_account_linked_linphone_xmlrpc);
linphone_account_creator_service_set_update_account_cb(service, linphone_account_creator_update_password_linphone_xmlrpc);
linphone_account_creator_service_set_confirmation_key_cb(service, linphone_account_creator_get_confirmation_key_linphone_xmlrpc);
// XMLRPC specific endpoints
linphone_account_creator_service_set_create_account_cb(service, linphone_account_creator_create_account_linphone_xmlrpc);
linphone_account_creator_service_set_recover_account_cb(service, linphone_account_creator_recover_phone_account_linphone_xmlrpc);
linphone_account_creator_service_set_is_alias_used_cb(service, linphone_account_creator_is_phone_number_used_linphone_xmlrpc);
linphone_account_creator_service_set_login_linphone_account_cb(service, linphone_account_creator_login_linphone_account_linphone_xmlrpc);
#ifdef HAVE_FLEXIAPI
} else {
linphone_account_creator_service_set_constructor_cb(service, NULL);
linphone_account_creator_service_set_destructor_cb(service, NULL);
linphone_account_creator_service_set_is_account_exist_cb(service, linphone_account_creator_is_account_exist_flexiapi);
linphone_account_creator_service_set_activate_account_cb(service, linphone_account_creator_activate_phone_account_flexiapi);
linphone_account_creator_service_set_is_account_activated_cb(service, linphone_account_creator_is_account_activated_flexiapi);
linphone_account_creator_service_set_link_account_cb(service, linphone_account_creator_link_phone_number_with_account_flexiapi);
linphone_account_creator_service_set_activate_alias_cb(service, linphone_account_creator_activate_phone_number_link_flexiapi);
linphone_account_creator_service_set_is_account_linked_cb(service, linphone_account_creator_is_account_linked_flexiapi);
linphone_account_creator_service_set_update_account_cb(service, linphone_account_creator_update_password_flexiapi);
// FlexiAPI specific endpoints
linphone_account_creator_service_set_login_linphone_account_cb(service, linphone_account_creator_send_token_flexiapi);
linphone_account_creator_service_set_create_account_with_token_cb(service, linphone_account_creator_create_account_with_token);
}
#endif
linphone_core_set_account_creator_service(lc, service);
}
......@@ -4656,14 +4682,14 @@ int linphone_core_preempt_sound_resources(LinphoneCore *lc){
linphone_core_leave_conference(lc);
return 0;
}
current_call=linphone_core_get_current_call(lc);
// If current call is not answered, do not try to pause it as user may take another one in the list of ringing calls
if((current_call != NULL) && (!linphone_core_is_incoming_invite_pending(lc))){
if (L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls().size() == 1){
/*
* The current call is the unique one and is the call that requires the sound ressources.
/*
* The current call is the unique one and is the call that requires the sound ressources.
* This is the case of receiving an incoming call when there is no other one. It is then set as current_call.
*/
return 0;
......@@ -8263,13 +8289,13 @@ bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const Linp
const bctbx_list_t * elem;
LinphoneAddress *testedAddr = linphone_address_clone(addr);
bool_t result = FALSE;
if (!testedAddr) return FALSE;
linphone_address_set_port(testedAddr, 0);
for (elem = linphone_core_get_proxy_config_list(lc); elem != NULL; elem = elem->next){
LinphoneProxyConfig *proxy = (LinphoneProxyConfig*) elem->data;
const char *uri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (!uri) continue;
......@@ -8279,7 +8305,7 @@ bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const Linp
linphone_address_set_port(factoryAddr, 0);
result = linphone_address_weak_equal(factoryAddr, testedAddr);
linphone_address_unref(factoryAddr);
if (result) break; /* if they match*/
}
linphone_address_unref(testedAddr);
......
......@@ -76,7 +76,6 @@
#include "vcard_private.h"
#include "carddav.h"
#include "linphone/player.h"
#include "account_creator_private.h"
#include "tester_utils.h"
#include "bctoolbox/port.h"
......
......@@ -22,7 +22,7 @@
#include <sqlite3.h>
#include "account_creator_private.h"
#include "account_creator/private.h"
#include "linphone/core.h"
#include "linphone/tunnel.h"
#include "c-wrapper/internal/c-sal.h"
......@@ -152,22 +152,6 @@ LINPHONE_PUBLIC LinphoneCoreToneManagerStats *linphone_core_get_tone_manager_sta
LINPHONE_PUBLIC void linphone_core_reset_tone_manager_stats(LinphoneCore *lc);
LINPHONE_PUBLIC const char *linphone_core_get_tone_file(LinphoneCore *lc, LinphoneToneID id);
/**
* Send an XML-RPC request to delete a Linphone account.
* @param[in] creator LinphoneAccountCreator object
* @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
* @donotwrap Exists for tests purposes only
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_delete_account_linphone(LinphoneAccountCreator *creator);
/**
* Send an XML-RPC request to get the confirmation key of a Linphone account.
* @param[in] creator LinphoneAccountCreator object
* @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
* @donotwrap Exists for tests purposes only
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_get_confirmation_key_linphone(LinphoneAccountCreator *creator);
/**
* Send a request to delete an account on server.
* @param[in] creator LinphoneAccountCreator object
......
......@@ -347,7 +347,7 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
bctbx_mmap_cchar_delete_with_data(request->response.data.m, bctbx_free);
request->response.data.m = NULL;
}*/
if (request->response.data.l) {
bctbx_list_free_with_data(request->response.data.l, bctbx_free);
request->response.data.l = NULL;
......@@ -363,7 +363,7 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
request->callbacks_list = nullptr;
if (request->raw_response)
bctbx_free(request->raw_response);
}
static void _linphone_xml_rpc_session_destroy(LinphoneXmlRpcSession *session) {
......@@ -513,10 +513,10 @@ void linphone_xml_rpc_session_send_request(LinphoneXmlRpcSession *session, Linph
belle_sip_memory_body_handler_t *bh;
const char *data;
linphone_xml_rpc_request_ref(request);
if (request->core == NULL)
request->core = session->core;
uri = belle_generic_uri_parse(session->url);
if (!uri) {
ms_error("Could not send request, URL %s is invalid", session->url);
......
......@@ -26,6 +26,16 @@
extern "C" {
#endif
/**
* Utils
*/
const char *_get_domain(LinphoneAccountCreator *creator);
char* _get_identity(const LinphoneAccountCreator *creator);
unsigned int validate_uri(const char* username, const char* domain, const char* display_name);
const char* ha1_for_passwd(const char* username, const char* realm, const char* passwd, const char* algo);
void reset_field (char **field);
void fill_domain_and_algorithm_if_needed(LinphoneAccountCreator *creator);
/**
* @addtogroup account_creator
* @{
......@@ -182,6 +192,38 @@ LINPHONE_PUBLIC LinphoneAccountCreatorUsernameStatus linphone_account_creator_se
**/
LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator);
/**
* Set the pn_provider.
* @param creator #LinphoneAccountCreator object @notnil
* @param pn_provider The pn_provider to set @notnil
* @return void
**/
LINPHONE_PUBLIC void linphone_account_creator_set_pn_provider(LinphoneAccountCreator *creator, const char* pn_provider);
/**
* Set the pn_param.
* @param creator #LinphoneAccountCreator object @notnil
* @param pn_param The pn_param to set @notnil
* @return void
**/
LINPHONE_PUBLIC void linphone_account_creator_set_pn_param(LinphoneAccountCreator *creator, const char* pn_param);
/**
* Set the pn_prid.
* @param creator #LinphoneAccountCreator object @notnil
* @param pn_prid The pn_prid to set @notnil
* @return void
**/
LINPHONE_PUBLIC void linphone_account_creator_set_pn_prid(LinphoneAccountCreator *creator, const char* pn_prid);
/**
* Set the token.
* @param creator #LinphoneAccountCreator object @notnil
* @param token The pn_prid to set @notnil
* @return void
**/
LINPHONE_PUBLIC void linphone_account_creator_set_token(LinphoneAccountCreator *creator, const char* token);
/**
* Set the phone number normalized.
* @param creator #LinphoneAccountCreator object @notnil
......@@ -450,6 +492,20 @@ LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_g
**/
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_activate_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
/**
* Get the activate account request.
* @param cbs #LinphoneAccountCreatorCbs object. @notnil
* @return The current activate account request.
**/
LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_send_token(const LinphoneAccountCreatorCbs *cbs);
/**
* Assign a user pointer to a #LinphoneAccountCreatorCbs object.
* @param cbs #LinphoneAccountCreatorCbs object. @notnil
* @param cb The send token request used.
**/
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_send_token(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
/**
* Get the is account activated request.
* @param cbs #LinphoneAccountCreatorCbs object. @notnil
......
......@@ -269,6 +269,22 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_servi
**/
LINPHONE_PUBLIC void linphone_account_creator_service_set_update_account_cb(LinphoneAccountCreatorService *service, LinphoneAccountCreatorRequestFunc cb);
/**
* Get the confirmation key request.
* @param service #LinphoneAccountCreatorService object.
* @return The current confirmation key request.
* @donotwrap
**/
LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_service_get_confirmation_key_cb(const LinphoneAccountCreatorService *service);
/**
* Assign a user pointer to a #LinphoneAccountCreatorService object.
* @param service #LinphoneAccountCreatorService object.
* @param cb The confirmation key request to be used.
* @donotwrap
**/
LINPHONE_PUBLIC void linphone_account_creator_service_set_confirmation_key_cb(LinphoneAccountCreatorService *service, LinphoneAccountCreatorRequestFunc cb);
/**
* Get the login linphone account request.
* @param service #LinphoneAccountCreatorService object.
......@@ -285,6 +301,38 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_servi
**/
LINPHONE_PUBLIC void linphone_account_creator_service_set_login_linphone_account_cb(LinphoneAccountCreatorService *service, LinphoneAccountCreatorRequestFunc cb);
/**
* Get the send token request.
* @param service #LinphoneAccountCreatorService object.
* @return The current login linphone account request.
* @donotwrap
**/
LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_service_get_send_token_cb(const LinphoneAccountCreatorService *service);
/**
* Assign a user pointer to a #LinphoneAccountCreatorService object.
* @param service #LinphoneAccountCreatorService object.
* @param cb The send token request to be used.
* @donotwrap
**/
LINPHONE_PUBLIC void linphone_account_creator_service_set_send_token_cb(LinphoneAccountCreatorService *service, LinphoneAccountCreatorRequestFunc cb);
/**
* Get the create account with token request.
* @param service #LinphoneAccountCreatorService object.
* @return The current create account with token request.
* @donotwrap
**/
LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_service_get_create_account_with_token_cb(const LinphoneAccountCreatorService *service);
/**
* Assign a user pointer to a #LinphoneAccountCreatorService object.
* @param service #LinphoneAccountCreatorService object.
* @param cb The create account with token request to be used.
* @donotwrap
**/
LINPHONE_PUBLIC void linphone_account_creator_service_set_create_account_with_token_cb(LinphoneAccountCreatorService *service, LinphoneAccountCreatorRequestFunc cb);
/************************** End Account Creator Requests **************************/
#ifdef __cplusplus
......
......@@ -262,7 +262,7 @@ LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_cert_path(const LinphoneA
* @return The TLS key path. @maybenil
*/
LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_key_path(const LinphoneAuthInfo *auth_info);
/*
* Gets the TLS key password.
* @param auth_info The #LinphoneAuthInfo object. @notnil
......
......@@ -28,6 +28,14 @@ set(LINK_LIBS
ortp
)
if (ENABLE_FLEXIAPI)
if (XCODE)
list(APPEND LINK_LIBS jsoncpp_static)
else()
list(APPEND LINK_LIBS jsoncpp_object)
endif()
endif()
#APPLE_LIBS is mandatory for apple compilation
if(APPLE)
list(APPEND APPLE_LIBS "-framework CFNetwork -framework Foundation -framework AVFoundation -framework SystemConfiguration -framework CoreLocation")
......@@ -226,7 +234,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
event-log/event-log.h
event-log/events.h
factory/factory.h
hacks/hacks.h
hacks/hacks.h
logger/logger.h
nat/ice-service.h
nat/stun-client.h
......@@ -344,6 +352,12 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-search-result.cpp
c-wrapper/internal/c-sal.cpp
c-wrapper/internal/c-tools.cpp
account_creator/utils.cpp
account_creator/service.cpp
account_creator/main.cpp
account_creator/connector_xmlrpc.cpp
call/call.cpp
chat/chat-message/chat-message.cpp
chat/chat-message/imdn-message.cpp
......@@ -457,6 +471,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
utils/version.cpp
variant/variant.cpp
)
if(ENABLE_LDAP)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
ldap/ldap-config-keys.cpp
......@@ -465,6 +480,14 @@ if(ENABLE_LDAP)
ldap/ldap-contact-search.cpp
)
endif()
if (ENABLE_FLEXIAPI)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
account_creator/connector_flexiapi.cpp
FlexiAPIClient.cc
)
endif()
if(ENABLE_VIDEO)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
conference/session/video-mixer.cpp
......@@ -557,6 +580,15 @@ if(ENABLE_STATIC)
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
$<TARGET_OBJECTS:linphone-coreapi-static>
)
if (ENABLE_FLEXIAPI)
if (XCODE)
target_link_libraries(linphone PRIVATE jsoncpp_static)
else()
target_link_libraries(linphone PRIVATE jsoncpp_object)
endif()
endif()
if (APPLE)
set_target_properties(linphone-static PROPERTIES OUTPUT_NAME linphone)
else()
......@@ -599,6 +631,15 @@ if(ENABLE_SHARED)
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
$<TARGET_OBJECTS:linphone-coreapi>
)
if (ENABLE_FLEXIAPI)
if (XCODE)
target_link_libraries(linphone PRIVATE jsoncpp_static)
else()
target_link_libraries(linphone PRIVATE jsoncpp_object)
endif()
endif()
if(APPLE)
set_target_properties(linphone PROPERTIES OUTPUT_NAME linphone)
else()
......
/*
* Copyright (c) 2010-2021 Belledonne Communications SARL.
*
* This file is part of Liblinphone.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "linphone/account_creator.h"
#include "linphone/core.h"
#include "linphone/lpconfig.h"
#include "FlexiAPIClient.hh"
#include "c-wrapper/c-wrapper.h"
#include "dial-plan/dial-plan.h"
#include "bctoolbox/crypto.h"
#include "bctoolbox/regex.h"
#include "private.h"
#include <functional>
#include <json/json.h>
using namespace LinphonePrivate;
using namespace std;
FlexiAPIClient::FlexiAPIClient(LinphoneCore *lc) {
mCore = lc;
mApiKey = nullptr;
// Assign the core there as well to keep it in the callback contexts
mRequestCallbacks.core = lc;
}
/**
* Public endpoints
*/
FlexiAPIClient *FlexiAPIClient::ping() {
prepareRequest("ping");
return this;
}
FlexiAPIClient *FlexiAPIClient::sendToken(string pnProvider, string pnParam, string pnPrid) {
JsonParams params;
params.push("pn_provider", pnProvider);
params.push("pn_param", pnParam);
params.push("pn_prid", pnPrid);