Commit 45f88c6e authored by Julien Wadel's avatar Julien Wadel
Browse files

- Use linphone callback for Magic search

- Multithreading LDAP search in cpp
- Multithreading and queue management on Magic search requests
- LDAP : Tester recfiles
- LDAP : Adapt tests

Clean and rework MagicSearch
- Auto clean cache between async search (optional)
- Variable visibility
- Better data structure
- Documentation
- Shared pointers on cache
- Allow cancellation from search (in addition to providers)
- Pool of generic providers in order to allow other future implementations
- Searches processes done on Iteration main loop to follow simple state transitions
- Keep synchronous mechanism working

- LDAP : Make search before getting results
- Fix adding results from core friends list

- Add Getter for certificate checks options
- Add debug and certificate verification options to LDAP/TLS

Add requested domain when dealing with sal to TLS handshake

- remove libgcc and libmingwex from msvc builds

- Add OpenLDAP for all platforms if enabled
- Add libraries for Windows
- rename linphone_core_get_veri...
parent ebc0bb30
......@@ -195,10 +195,7 @@ if(ENABLE_CXX_WRAPPER OR ENABLE_CSHARP_WRAPPER OR ENABLE_JAVA_WRAPPER OR ENABLE_
endif()
endif()
if(ENABLE_LDAP)
find_package(SASL REQUIRED)
if(NOT WIN32)
find_package(OpenLDAP REQUIRED)
endif()
endif()
if(UNIX AND NOT APPLE)
......@@ -206,11 +203,6 @@ if(UNIX AND NOT APPLE)
check_include_files(libudev.h HAVE_LIBUDEV_H)
endif()
if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
find_library(LIBGCC NAMES gcc)
find_library(LIBMINGWEX NAMES mingwex)
endif()
if(NOT WIN32)
find_package(Iconv QUIET)
endif()
......@@ -259,9 +251,8 @@ if(INTL_FOUND)
set(HAVE_INTL 1)
list(APPEND LINPHONE_INCLUDE_DIRS ${INTL_INCLUDE_DIRS})
endif()
if(OPENLDAP_FOUND AND SASL_FOUND)
if(OPENLDAP_FOUND)
list(APPEND LINPHONE_INCLUDE_DIRS ${OPENLDAP_INCLUDE_DIRS})
list(APPEND LINPHONE_INCLUDE_DIRS ${SASL_INCLUDE_DIRS})
endif()
if(MSVC)
include_directories(${MSVC_INCLUDE_DIR})
......@@ -369,6 +360,10 @@ if(ENABLE_VIDEO)
add_definitions(-DVIDEO_ENABLED)
endif()
if(ENABLE_LDAP)
add_definitions(-DLDAP_ENABLED -DLDAP_LIBS_DYNAMIC)
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
......
......@@ -28,12 +28,25 @@ find_path(OPENLDAP_INCLUDE_DIRS
NAMES ldap.h
PATH_SUFFIXES include/openldap
)
find_library(OPENLDAP_LIBRARIES
NAMES ldap
HINTS "${CMAKE_INSTALL_PREFIX}"
PATH_SUFFIXES lib
)
if(WIN32)
find_library(LDAP_LIB
NAMES ldap
HINTS "${CMAKE_INSTALL_PREFIX}"
PATH_SUFFIXES lib
)
find_library(LBER_LIB
NAMES lber
HINTS "${CMAKE_INSTALL_PREFIX}"
PATH_SUFFIXES lib
)
set(OPENLDAP_LIBRARIES ${LDAP_LIB} ${LBER_LIB})
else()
find_library(OPENLDAP_LIBRARIES
NAMES ldap
HINTS "${CMAKE_INSTALL_PREFIX}"
PATH_SUFFIXES bin lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenLDAP
......
......@@ -60,7 +60,6 @@ set(LINPHONE_SOURCE_FILES_C
friendlist.c
im_notif_policy.c
info.c
ldapprovider.c
lime.c
im_encryption_engine.c
linphonecall.c
......@@ -91,9 +90,6 @@ set(LINPHONE_SOURCE_FILES_C
xmlrpc.c
vtables.c
)
if(ENABLE_LDAP)
add_definitions(-DBUILD_LDAP)
endif()
set(LINPHONE_SOURCE_FILES_CXX
conference.cc
tester_utils.cpp
......
......@@ -5365,6 +5365,10 @@ void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno){
linphone_config_set_int(lc->config,"sip","verify_server_certs",yesno);
}
bool_t linphone_core_is_verify_server_certificates(LinphoneCore *lc){
return !!linphone_config_get_int(lc->config, "sip", "verify_server_certs", TRUE);
}
void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){
lc->sal->verifyServerCn(!!yesno);
if (lc->http_crypto_config){
......@@ -5373,6 +5377,10 @@ void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){
linphone_config_set_int(lc->config,"sip","verify_server_cn",yesno);
}
bool_t linphone_core_get_verify_server_cn(LinphoneCore *lc){
return !!linphone_config_get_int(lc->config, "sip", "verify_server_cn", TRUE);
}
void linphone_core_set_ssl_config(LinphoneCore *lc, void *ssl_config) {
lc->sal->setSslConfig(ssl_config);
if (lc->http_crypto_config) {
......
......@@ -372,6 +372,8 @@ void _linphone_chat_message_notify_ephemeral_message_timer_started(LinphoneChatM
void _linphone_chat_message_notify_ephemeral_message_deleted(LinphoneChatMessage* msg);
void _linphone_chat_message_clear_callbacks (LinphoneChatMessage *msg);
void _linphone_magic_search_notify_search_results_received(LinphoneMagicSearch* magic_search);
const LinphoneParticipantImdnState *_linphone_participant_imdn_state_from_cpp_obj (const LinphonePrivate::ParticipantImdnState &state);
......
......@@ -45,7 +45,6 @@ set(ROOT_HEADER_FILES
im_encryption_engine.h
im_notif_policy.h
info_message.h
ldapprovider.h
logging.h
lpconfig.h
misc.h
......@@ -96,6 +95,7 @@ set(C_API_HEADER_FILES
c-event-log.h
c-factory.h
c-magic-search.h
c-magic-search-cbs.h
c-participant.h
c-participant-device.h
c-participant-device-identity.h
......
......@@ -400,6 +400,9 @@ typedef void (*LinphoneChatRoomCbsShouldChatMessageBeStoredCb) (LinphoneChatRoom
*/
typedef void (*LinphoneChatRoomCbsChatMessageParticipantImdnStateChangedCb) (LinphoneChatRoom *chat_room, LinphoneChatMessage *message, const LinphoneParticipantImdnState *state);
/************ */
/* DEPRECATED */
/* ********** */
......@@ -477,6 +480,22 @@ typedef void (*LinphoneConferenceCbsParticipantDeviceRemovedCb) (LinphoneConfere
* @}
**/
/**
* @addtogroup misc
* @{
*/
/**
* Call back used to notify message delivery status
* @param magic_search #LinphoneChatMessage object @notnil
*/
typedef void (*LinphoneMagicSearchCbsSearchResultsReceivedCb)(LinphoneMagicSearch* magic_search);
/**
* @}
**/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
......
......@@ -259,6 +259,13 @@ LINPHONE_PUBLIC LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(cons
*/
LINPHONE_PUBLIC LinphoneChatMessageCbs * linphone_factory_create_chat_message_cbs(const LinphoneFactory *factory);
/**
* Create a LinphoneMagicSearchCbs object that holds callbacks for events happening on a chat message.
* @param factory #LinphoneFactory singletion object @notnil
* @return A new #LinphoneMagicSearchCbs object @notnil
*/
LINPHONE_PUBLIC LinphoneMagicSearchCbs * linphone_factory_create_magic_search_cbs(const LinphoneFactory *factory);
/**
* Create an empty #LinphoneVcard.
* @param factory #LinphoneFactory singletion object @notnil
......
/*
* Copyright (c) 2010-2019 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/>.
*/
#ifndef _L_C_MAGIC_SEARCH_CBS_H_
#define _L_C_MAGIC_SEARCH_CBS_H_
#include "linphone/api/c-callbacks.h"
#include "linphone/api/c-types.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup misc
* @{
*/
LinphoneMagicSearchCbs *linphone_magic_search_cbs_new (void);
/**
* Acquire a reference to the chat message callbacks object.
* @param cbs The #LinphoneMagicSearchCbs object @notnil
* @return The same chat message callbacks object
**/
LINPHONE_PUBLIC LinphoneMagicSearchCbs * linphone_magic_search_cbs_ref (LinphoneMagicSearchCbs *cbs);
/**
* Release reference to the chat message callbacks object.
* @param cbs The #LinphoneMagicSearchCbs object @notnil
**/
LINPHONE_PUBLIC void linphone_magic_search_cbs_unref (LinphoneMagicSearchCbs *cbs);
/**
* Retrieve the user pointer associated with the chat message callbacks object.
* @param cbs The #LinphoneMagicSearchCbs object @notnil
* @return The user pointer associated with the chat message callbacks object. @maybenil
**/
LINPHONE_PUBLIC void * linphone_magic_search_cbs_get_user_data (const LinphoneMagicSearchCbs *cbs);
/**
* Assign a user pointer to the chat message callbacks object.
* @param cbs The #LinphoneMagicSearchCbs object @notnil
* @param user_data The user pointer to associate with the chat message callbacks object. @maybenil
**/
LINPHONE_PUBLIC void linphone_magic_search_cbs_set_user_data (LinphoneMagicSearchCbs *cbs, void *user_data);
/**
* Get the message state changed callback.
* @param cbs #LinphoneMagicSearchCbs object. @notnil
* @return The current message state changed callback.
*/
LINPHONE_PUBLIC LinphoneMagicSearchCbsSearchResultsReceivedCb linphone_magic_search_cbs_get_search_results_received (const LinphoneMagicSearchCbs *cbs);
/**
* Set the message state changed callback.
* @param cbs #LinphoneMagicSearchCbs object. @notnil
* @param cb The message state changed callback to be used.
*/
LINPHONE_PUBLIC void linphone_magic_search_cbs_set_search_results_received (LinphoneMagicSearchCbs *cbs, LinphoneMagicSearchCbsSearchResultsReceivedCb cb);
/**
* @}
*/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _L_C_CHAT_MESSAGE_CBS_H_
......@@ -20,6 +20,7 @@
#ifndef _L_C_MAGIC_SEARCH_H_
#define _L_C_MAGIC_SEARCH_H_
#include "linphone/api/c-magic-search-cbs.h"
#include "linphone/api/c-types.h"
// =============================================================================
......@@ -53,6 +54,35 @@ LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_ref (LinphoneMagicSea
**/
LINPHONE_PUBLIC void linphone_magic_search_unref (LinphoneMagicSearch *magic_search);
/**
* Add a listener in order to be notified of #LinphoneMagicSearch events.
* @param magic_search #LinphoneMagicSearch object to monitor. @notnil
* @param cbs A #LinphoneMagicSearchCbs object holding the callbacks you need. @notnil
*/
LINPHONE_PUBLIC void linphone_magic_search_add_callbacks(LinphoneMagicSearch *magic_search, LinphoneMagicSearchCbs *cbs);
/**
* Remove a listener from a #LinphoneMagicSearch
* @param magic_search #LinphoneMagicSearch object @notnil
* @param cbs #LinphoneMagicSearchCbs object to remove. @notnil
*/
LINPHONE_PUBLIC void linphone_magic_search_remove_callbacks(LinphoneMagicSearch *magic_search, LinphoneMagicSearchCbs *cbs);
/**
* Gets the list of listeners from a #LinphoneMagicSearch.maybenil
* @param magic_search #LinphoneMagicSearch object. @notnil
* @return The list of #LinphoneMagicSearchCbs object. @maybenil
*/
LINPHONE_PUBLIC const bctbx_list_t *linphone_magic_search_get_callbacks_list(const LinphoneMagicSearch *magic_search);
/**
* Gets the current LinphoneMagicSearchCbs.
* This is meant only to be called from a callback to be able to get the user_data associated with the #LinphoneMagicSearchCbs that is calling the callback.
* @param magic_search #LinphoneMagicSearch object @notnil
* @return The #LinphoneMagicSearchCbs that has called the last callback. @maybenil
*/
LINPHONE_PUBLIC LinphoneMagicSearchCbs *linphone_magic_search_get_current_callbacks(const LinphoneMagicSearch *magic_search);
/**
* Set the minimum value used to calculate the weight in search
* @param magic_search a #LinphoneMagicSearch object @notnil
......@@ -158,11 +188,38 @@ LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache (LinphoneMagicSear
* @return sorted list of \bctbx_list{LinphoneSearchResult} @tobefreed @notnil
**/
LINPHONE_PUBLIC bctbx_list_t *linphone_magic_search_get_contact_list_from_filter (
const LinphoneMagicSearch *magic_search,
LinphoneMagicSearch *magic_search,
const char *filter,
const char *domain
);
/**
* Create a sorted list of SearchResult asynchronous from SipUri, Contact name,
* Contact displayname, Contact phone number, which match with a filter word
* The last item list will be an address formed with "filter" if a proxy config exist
* During the first search, a cache is created and used for the next search
* Use linphone_magic_search_reset_search_cache() to begin a new search
* @param magic_search a #LinphoneMagicSearch object @notnil
* @param filter word we search @maybenil
* @param domain domain which we want to search only @maybenil
** NULL or "" for searching in all contact
** "*" for searching in contact with sip SipUri
** "yourdomain" for searching in contact from "yourdomain" domain
**/
//typedef void (MagicSearchCb)(const void *, void *);
LINPHONE_PUBLIC void linphone_magic_search_get_contact_list_from_filter_async (
LinphoneMagicSearch *magic_search,
const char *filter,
const char *domain
);
/**
*
* @param magic_search a #LinphoneMagicSearch object @notnil
* @return sorted list of \bctbx_list{LinphoneSearchResult} @tobefreed @notnil
*
**/
LINPHONE_PUBLIC bctbx_list_t* linphone_magic_search_get_last_search(const LinphoneMagicSearch *magic_search);
/**
* @}
*/
......
......@@ -424,6 +424,12 @@ typedef struct _LinphonePushNotificationConfig LinphonePushNotificationConfig;
*/
typedef struct _LinphoneMagicSearch LinphoneMagicSearch;
/**
* @brief A #LinphoneMagicSearchCbs is used to do specifics searchs
* @ingroup misc
*/
typedef struct _LinphoneMagicSearchCbs LinphoneMagicSearchCbs;
/**
* @brief The LinphoneSearchResult object represents a result of a search
* @ingroup misc
......
......@@ -2764,6 +2764,14 @@ LINPHONE_PUBLIC bool_t linphone_core_is_native_ringing_enabled(const LinphoneCor
**/
LINPHONE_PUBLIC void linphone_core_verify_server_certificates(LinphoneCore *core, bool_t yesno);
/**
* Get whether the tls server certificate must be verified when connecting to a SIP/TLS server.
* @param core #LinphoneCore object @notnil
* @return True if the tls server certificate must be verified
* @ingroup initializing
**/
LINPHONE_PUBLIC bool_t linphone_core_is_verify_server_certificates(LinphoneCore *core);
/**
* Specify whether the tls server certificate common name must be verified when connecting to a SIP/TLS server.
* @param core #LinphoneCore object @notnil
......@@ -2772,6 +2780,14 @@ LINPHONE_PUBLIC void linphone_core_verify_server_certificates(LinphoneCore *core
**/
LINPHONE_PUBLIC void linphone_core_verify_server_cn(LinphoneCore *core, bool_t yesno);
/**
* Get whether the tls server certificate common name must be verified when connecting to a SIP/TLS server.
* @param core #LinphoneCore object @notnil
* @return True if the tls server certificate common name must be verified
* @ingroup initializing
**/
LINPHONE_PUBLIC bool_t linphone_core_get_verify_server_cn(LinphoneCore *core);
/**
* Gets the path to a file or folder containing the trusted root CAs (PEM format)
* @param core #LinphoneCore object @notnil
......
......@@ -90,9 +90,7 @@ if(ENABLE_TUNNEL)
list(APPEND LINK_LIBS ${TUNNEL_LIBRARIES})
add_definitions(-DTUNNEL_ENABLED)
endif()
if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
list(APPEND LINK_LIBS ${LIBGCC} ${LIBMINGWEX})
endif()
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
list(APPEND LINK_LIBS shlwapi)
endif()
......@@ -104,15 +102,14 @@ if(BELCARD_FOUND)
list(APPEND INTERFACE_LIBS belcard)
list(APPEND LINK_LIBS belcard)
endif()
if(WIN32 AND ENABLE_LDAP)
list(APPEND LINK_LIBS "Wldap32")
endif()
if(OPENLDAP_FOUND AND SASL_FOUND)
if(OPENLDAP_FOUND)
list(APPEND LINK_LIBS ${OPENLDAP_LIBRARIES})
list(APPEND LINK_LIBS ${SASL_LIBRARIES})
endif()
#define log domain for this part of code
add_definitions(-DBCTBX_LOG_DOMAIN="liblinphone")
if(ENABLE_LDAP)
add_definitions(-DBUILD_LDAP)
endif()
set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
account/account.h
......@@ -229,7 +226,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
......@@ -252,6 +249,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
sal/sal_stream_description.h
sal/sal_media_description.h
sal/offeranswer.h
search/search-async-data.h
search/magic-search-p.h
search/magic-search.h
search/search-result.h
......@@ -288,6 +286,14 @@ if(ENABLE_ADVANCED_IM)
)
endif()
if(ENABLE_LDAP)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
ldap/ldap-friend.h
ldap/ldap-contact-provider.h
ldap/ldap-contact-search.h
)
endif()
if(ENABLE_DB_STORAGE)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
db/internal/db-transaction.h
......@@ -326,6 +332,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-event-log.cpp
c-wrapper/api/c-factory.cpp
c-wrapper/api/c-magic-search.cpp
c-wrapper/api/c-magic-search-cbs.cpp
c-wrapper/api/c-participant.cpp
c-wrapper/api/c-participant-device.cpp
c-wrapper/api/c-participant-device-identity.cpp
......@@ -438,6 +445,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
sal/sal_media_description.cpp
sal/offeranswer.cpp
search/magic-search.cpp
search/search-async-data.cpp
search/search-result.cpp
utils/background-task.cpp
utils/fs.cpp
......@@ -448,7 +456,13 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
utils/version.cpp
variant/variant.cpp
)
if(ENABLE_LDAP)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
ldap/ldap-friend.cpp
ldap/ldap-contact-provider.cpp
ldap/ldap-contact-search.cpp
)
endif()
if(ENABLE_VIDEO)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
conference/session/video-mixer.cpp
......
......@@ -193,6 +193,10 @@ LinphoneChatMessageCbs * linphone_factory_create_chat_message_cbs(const Linphone
return Factory::toCpp(factory)->createChatMessageCbs();
}
LinphoneMagicSearchCbs * linphone_factory_create_magic_search_cbs(const LinphoneFactory *factory){
return Factory::toCpp(factory)->createMagicSearchCbs();
}
LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) {
return Factory::toCpp(factory)->createVcard();
}
......
/*
* Copyright (c) 2010-2019 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/api/c-magic-search-cbs.h"
#include "c-wrapper/c-wrapper.h"
// =============================================================================
struct _LinphoneMagicSearchCbs {
belle_sip_object_t base;
void *userData;
LinphoneMagicSearchCbsSearchResultsReceivedCb search_results_received;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneMagicSearchCbs);
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneMagicSearchCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneMagicSearchCbs, belle_sip_object_t,
NULL, // destroy
NULL, // clone
NULL, // marshal
FALSE
);
// =============================================================================
LinphoneMagicSearchCbs * linphone_magic_search_cbs_new (void) {
return belle_sip_object_new(LinphoneMagicSearchCbs);
}
LinphoneMagicSearchCbs * linphone_magic_search_cbs_ref (LinphoneMagicSearchCbs *cbs) {
belle_sip_object_ref(cbs);
return cbs;
}
void linphone_magic_search_cbs_unref (LinphoneMagicSearchCbs *cbs) {
belle_sip_object_unref(cbs);
}
void * linphone_magic_search_cbs_get_user_data (const LinphoneMagicSearchCbs *cbs) {
return cbs->userData;
}
void linphone_magic_search_cbs_set_user_data (LinphoneMagicSearchCbs *cbs, void *ud) {
cbs->userData = ud;
}
LinphoneMagicSearchCbsSearchResultsReceivedCb linphone_magic_search_cbs_get_search_results_received(
const LinphoneMagicSearchCbs *cbs
) {
return cbs->search_results_received;
}
void linphone_magic_search_cbs_set_search_results_received (
LinphoneMagicSearchCbs *cbs,
LinphoneMagicSearchCbsSearchResultsReceivedCb cb
) {
cbs->search_results_received = cb;
}
......@@ -24,7 +24,10 @@
using namespace std;
L_DECLARE_C_OBJECT_IMPL(MagicSearch);
L_DECLARE_C_OBJECT_IMPL(MagicSearch,
bctbx_list_t *callbacks;
LinphoneMagicSearchCbs *currentCbs;
);
LinphoneMagicSearch *linphone_core_create_magic_search(LinphoneCore *lc) {
shared_ptr<LinphonePrivate::MagicSearch> cppPtr = make_shared<LinphonePrivate::MagicSearch>(
......@@ -49,6 +52,51 @@ void linphone_magic_search_unref (LinphoneMagicSearch *magic_search) {
belle_sip_object_unref(magic_search);
}
void _linphone_magic_search_clear_callbacks (LinphoneMagicSearch *magic_search) {
bctbx_list_free_with_data(magic_search->callbacks, (bctbx_list_free_func)linphone_magic_search_cbs_unref);
magic_search->callbacks = nullptr;
}
void linphone_magic_search_add_callbacks(LinphoneMagicSearch *magic_search, LinphoneMagicSearchCbs *cbs) {
magic_search->callbacks = bctbx_list_append(magic_search->callbacks, linphone_magic_search_cbs_ref(cbs));
}
void linphone_magic_search_remove_callbacks(LinphoneMagicSearch *magic_search, LinphoneMagicSearchCbs *cbs) {
magic_search->callbacks = bctbx_list_remove(magic_search->callbacks, cbs);
linphone_magic_search_cbs_unref(cbs);
}
LinphoneMagicSearchCbs *linphone_magic_search_get_current_callbacks(const LinphoneMagicSearch *msg) {
return msg->currentCbs;
}