Commit 2499db4e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added multi listener on every single listener object, single listener deprecated

parent 15b44a2d
This diff is collapsed.
......@@ -35,7 +35,7 @@ struct _LinphoneAccountCreatorService {
LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */
LinphoneAccountCreatorRequestFunc delete_account_request_cb; /**< Request to delete account */
LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */
LinphoneAccountCreatorRequestFunc get_confirmation_key_request_cb; /**< Request to get the confirmation key */
LinphoneAccountCreatorRequestFunc confirmation_key_request_cb; /**< Request to get the confirmation key */
LinphoneAccountCreatorRequestFunc activate_account_request_cb; /**< Request to activate account */
LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */
......@@ -61,7 +61,7 @@ struct _LinphoneAccountCreatorCbs {
LinphoneAccountCreatorCbsStatusCb activate_account_response_cb; /**< Response of activate_account request */
LinphoneAccountCreatorCbsStatusCb is_account_activated_response_cb; /**< Response of is_account_activated request */
LinphoneAccountCreatorCbsStatusCb get_confirmation_key_response_cb; /**< Response of get_confirmation_key request */
LinphoneAccountCreatorCbsStatusCb confirmation_key_response_cb; /**< Response of get_confirmation_key request */
LinphoneAccountCreatorCbsStatusCb link_account_response_cb; /**< Response of link_account request */
LinphoneAccountCreatorCbsStatusCb activate_alias_response_cb; /**< Response of activation alias */
......@@ -81,7 +81,9 @@ struct _LinphoneAccountCreator {
/* AccountCreator */
LinphoneAccountCreatorService *service; /**< Account creator service */
LinphoneAccountCreatorCbs *cbs; /**< Account creator cbs */
LinphoneAccountCreatorCbs *cbs; /**< Account creator cbs, deprecated, use a list of Cbs instead */
bctbx_list_t *callbacks;
LinphoneAccountCreatorCbs *currentCbs;
LinphoneXmlRpcSession *xmlrpc_session; /**< XML-RPC session */
LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */
......
......@@ -86,7 +86,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneEventCbs, belle_sip_object_t,
FALSE
);
static LinphoneEventCbs *linphone_event_cbs_new(void) {
LinphoneEventCbs *linphone_event_cbs_new(void) {
return belle_sip_object_new(LinphoneEventCbs);
}
......@@ -497,6 +497,8 @@ static void linphone_event_destroy(LinphoneEvent *lev){
if (lev->from_address) linphone_address_unref(lev->from_address);
if (lev->remote_contact_address) linphone_address_unref(lev->remote_contact_address);
linphone_event_cbs_unref(lev->callbacks);
bctbx_list_free_with_data(lev->callbacks_list, (bctbx_list_free_func)linphone_event_cbs_unref);
lev->callbacks_list = nullptr;
ms_free(lev->name);
}
......@@ -574,16 +576,48 @@ static belle_sip_error_code _linphone_event_marshall(belle_sip_object_t *obj, ch
return err;
}
void _linphone_event_notify_notify_response(const LinphoneEvent *lev) {
void _linphone_event_notify_notify_response(LinphoneEvent *lev) {
LinphoneEventCbsNotifyResponseCb cb = linphone_event_cbs_get_notify_response(lev->callbacks);
if (cb)
cb(lev);
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_event_get_callbacks_list(lev));
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) {
linphone_event_set_current_callbacks(lev, reinterpret_cast<LinphoneEventCbs *>(bctbx_list_get_data(it)));
LinphoneEventCbsNotifyResponseCb callback = linphone_event_cbs_get_notify_response(linphone_event_get_current_callbacks(lev));
if (callback) {
callback(lev);
}
}
linphone_event_set_current_callbacks(lev, nullptr);
bctbx_list_free(callbacksCopy);
}
LinphoneEventCbs *linphone_event_get_callbacks(const LinphoneEvent *ev) {
return ev->callbacks;
}
void linphone_event_add_callbacks(LinphoneEvent *ev, LinphoneEventCbs *cbs) {
ev->callbacks_list = bctbx_list_append(ev->callbacks_list, linphone_event_cbs_ref(cbs));
}
void linphone_event_remove_callbacks(LinphoneEvent *ev, LinphoneEventCbs *cbs) {
ev->callbacks_list = bctbx_list_remove(ev->callbacks_list, cbs);
linphone_event_cbs_unref(cbs);
}
LinphoneEventCbs *linphone_event_get_current_callbacks(const LinphoneEvent *ev) {
return ev->currentCbs;
}
void linphone_event_set_current_callbacks(LinphoneEvent *ev, LinphoneEventCbs *cbs) {
ev->currentCbs = cbs;
}
const bctbx_list_t *linphone_event_get_callbacks_list(const LinphoneEvent *ev) {
return ev->callbacks_list;
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneEvent);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneEvent, belle_sip_object_t,
......
......@@ -258,6 +258,10 @@ LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(const LinphoneFactor
return _linphone_chat_room_cbs_new();
}
LinphoneChatMessageCbs * linphone_factory_create_chat_message_cbs(const LinphoneFactory *factory) {
return linphone_chat_message_cbs_new();
}
LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) {
return _linphone_vcard_new();
}
......@@ -455,3 +459,27 @@ void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLo
LinphoneTunnelConfig *linphone_factory_create_tunnel_config(LinphoneFactory *factory) {
return linphone_tunnel_config_new();
}
LinphoneLoggingServiceCbs *linphone_factory_create_logging_service_cbs(LinphoneFactory *factory) {
return linphone_logging_service_cbs_new();
}
LinphonePlayerCbs *linphone_factory_create_player_cbs(LinphoneFactory *factory) {
return linphone_player_cbs_new();
}
LinphoneEventCbs *linphone_factory_create_event_cbs(LinphoneFactory *factory) {
return linphone_event_cbs_new();
}
LinphoneFriendListCbs *linphone_factory_create_friend_list_cbs(LinphoneFactory *factory) {
return linphone_friend_list_cbs_new();
}
LinphoneAccountCreatorCbs *linphone_factory_create_account_creator_cbs(LinphoneFactory *factory) {
return linphone_account_creator_cbs_new();
}
LinphoneXmlRpcRequestCbs *linphone_factory_create_xml_rpc_request_cbs(LinphoneFactory *factory) {
return linphone_xml_rpc_request_cbs_new();
}
\ No newline at end of file
......@@ -36,14 +36,46 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriendListCbs, belle_sip_object_t,
FALSE
);
static LinphoneFriendListCbs * linphone_friend_list_cbs_new(void) {
LinphoneFriendListCbs * linphone_friend_list_cbs_new(void) {
return belle_sip_object_new(LinphoneFriendListCbs);
}
LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *list) {
return list->cbs;
LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *friend_list) {
return friend_list->cbs;
}
void linphone_friend_list_add_callbacks(LinphoneFriendList *friend_list, LinphoneFriendListCbs *cbs) {
friend_list->callbacks = bctbx_list_append(friend_list->callbacks, linphone_friend_list_cbs_ref(cbs));
}
void linphone_friend_list_remove_callbacks(LinphoneFriendList *friend_list, LinphoneFriendListCbs *cbs) {
friend_list->callbacks = bctbx_list_remove(friend_list->callbacks, cbs);
linphone_friend_list_cbs_unref(cbs);
}
LinphoneFriendListCbs *linphone_friend_list_get_current_callbacks(const LinphoneFriendList *friend_list) {
return friend_list->currentCbs;
}
void linphone_friend_list_set_current_callbacks(LinphoneFriendList *friend_list, LinphoneFriendListCbs *cbs) {
friend_list->currentCbs = cbs;
}
const bctbx_list_t *linphone_friend_list_get_callbacks_list(const LinphoneFriendList *friend_list) {
return friend_list->callbacks;
}
#define NOTIFY_IF_EXIST(cbName, functionName, ...) \
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_friend_list_get_callbacks_list(list)); \
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) { \
linphone_friend_list_set_current_callbacks(list, reinterpret_cast<LinphoneFriendListCbs *>(bctbx_list_get_data(it))); \
LinphoneFriendListCbs ## cbName ## Cb cb = linphone_friend_list_cbs_get_ ## functionName (linphone_friend_list_get_current_callbacks(list)); \
if (cb) \
cb(__VA_ARGS__); \
} \
linphone_friend_list_set_current_callbacks(list, nullptr); \
bctbx_list_free(callbacksCopy);
LinphoneFriendListCbs * linphone_friend_list_cbs_ref(LinphoneFriendListCbs *cbs) {
belle_sip_object_ref(cbs);
return cbs;
......@@ -355,8 +387,12 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
}
}
// Notify list with all friends for which we received presence information
if (bctbx_list_size(list_friends_presence_received) > 0 && list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
if (bctbx_list_size(list_friends_presence_received) > 0) {
if (list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
}
NOTIFY_IF_EXIST(PresenceReceived, presence_received, list, list_friends_presence_received)
}
bctbx_list_free(list_friends_presence_received);
}
......@@ -398,8 +434,12 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
}
}
// Notify list with all friends for which we received presence information
if (bctbx_list_size(list_friends_presence_received) > 0 && list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
if (bctbx_list_size(list_friends_presence_received) > 0) {
if (list_cbs && linphone_friend_list_cbs_get_presence_received(list_cbs)) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received);
}
NOTIFY_IF_EXIST(PresenceReceived, presence_received, list, list_friends_presence_received)
}
bctbx_list_free(list_friends_presence_received);
}
......@@ -449,6 +489,8 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) {
}
if (list->uri != NULL) ms_free(list->uri);
if (list->cbs) linphone_friend_list_cbs_unref(list->cbs);
bctbx_list_free_with_data(list->callbacks, (bctbx_list_free_func)linphone_friend_list_cbs_unref);
list->callbacks = nullptr;
if (list->dirty_friends_to_update) list->dirty_friends_to_update = bctbx_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref);
if (list->friends) list->friends = bctbx_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release);
if (list->friends_map) bctbx_mmap_cchar_delete_with_data(list->friends_map, (void (*)(void *))linphone_friend_unref);
......@@ -665,9 +707,11 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
}
static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) {
LinphoneFriendList *list = cdc->friend_list;
if (cdc && cdc->friend_list->cbs && cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, success ? LinphoneFriendListSyncSuccessful : LinphoneFriendListSyncFailure, msg);
}
NOTIFY_IF_EXIST(SyncStateChanged, sync_status_changed, list, success ? LinphoneFriendListSyncSuccessful : LinphoneFriendListSyncFailure, msg)
linphone_carddav_context_destroy(cdc);
}
......@@ -691,6 +735,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
if (cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL);
}
NOTIFY_IF_EXIST(SyncStateChanged, sync_status_changed, list, LinphoneFriendListSyncStarted, NULL)
linphone_carddav_delete_vcard(cdc, lf);
}
}
......@@ -771,6 +816,7 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
if (cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL);
}
NOTIFY_IF_EXIST(SyncStateChanged, sync_status_changed, list, LinphoneFriendListSyncStarted, NULL)
linphone_carddav_put_vcard(cdc, lf);
}
}
......@@ -781,36 +827,39 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
static void carddav_created(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list;
linphone_friend_list_import_friend(lfl, lf, FALSE);
LinphoneFriendList *list = cdc->friend_list;
linphone_friend_list_import_friend(list, lf, FALSE);
if (cdc->friend_list->cbs->contact_created_cb) {
cdc->friend_list->cbs->contact_created_cb(lfl, lf);
cdc->friend_list->cbs->contact_created_cb(list, lf);
}
NOTIFY_IF_EXIST(ContactCreated, contact_created, list, lf)
}
}
static void carddav_removed(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list;
_linphone_friend_list_remove_friend(lfl, lf, FALSE);
LinphoneFriendList *list = cdc->friend_list;
_linphone_friend_list_remove_friend(list, lf, FALSE);
if (cdc->friend_list->cbs->contact_deleted_cb) {
cdc->friend_list->cbs->contact_deleted_cb(lfl, lf);
cdc->friend_list->cbs->contact_deleted_cb(list, lf);
}
NOTIFY_IF_EXIST(ContactDeleted, contact_deleted, list, lf)
}
}
static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, LinphoneFriend *lf_old) {
if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list;
bctbx_list_t *elem = bctbx_list_find(lfl->friends, lf_old);
LinphoneFriendList *list = cdc->friend_list;
bctbx_list_t *elem = bctbx_list_find(list->friends, lf_old);
if (elem) {
elem->data = linphone_friend_ref(lf_new);
}
linphone_core_store_friend_in_db(lf_new->lc, lf_new);
if (cdc->friend_list->cbs->contact_updated_cb) {
cdc->friend_list->cbs->contact_updated_cb(lfl, lf_new, lf_old);
cdc->friend_list->cbs->contact_updated_cb(list, lf_new, lf_old);
}
NOTIFY_IF_EXIST(ContactUpdated, contact_updated, list, lf_new, lf_old)
linphone_friend_unref(lf_old);
}
}
......@@ -832,6 +881,7 @@ void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *li
if (cdc && cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL);
}
NOTIFY_IF_EXIST(SyncStateChanged, sync_status_changed, list, LinphoneFriendListSyncStarted, NULL)
linphone_carddav_synchronize(cdc);
}
}
......
......@@ -2304,7 +2304,7 @@ static void _linphone_core_init_account_creator_service(LinphoneCore *lc) {
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->get_confirmation_key_request_cb = linphone_account_creator_get_confirmation_key_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;
......
......@@ -54,6 +54,10 @@ unsigned int _linphone_log_mask_to_bctbx_log_mask(unsigned int mask);
*/
void _linphone_logging_service_clean(void);
void _linphone_logging_service_clear_callbacks (LinphoneLoggingService *log_service);
void linphone_logging_service_set_current_callbacks(LinphoneLoggingService *log_service, LinphoneLoggingServiceCbs *cbs);
#ifdef __cplusplus
}
#endif
......
......@@ -32,7 +32,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct _LinphoneLoggingService {
belle_sip_object_t base;
LinphoneLoggingServiceCbs *cbs;
LinphoneLoggingServiceCbs *cbs; // Deprecated, use a list of Cbs instead
bctbx_list_t *callbacks;
LinphoneLoggingServiceCbs *currentCbs;
bctbx_log_handler_t *log_handler;
};
......@@ -123,6 +125,19 @@ static void _log_handler_on_message_written_cb(void *info,const char *domain, Bc
service->cbs->message_event_cb(service, domain, _bctbx_log_level_to_linphone_log_level(lev), message);
bctbx_free(message);
}
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_logging_service_get_callbacks_list(service));
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) {
linphone_logging_service_set_current_callbacks(service, reinterpret_cast<LinphoneLoggingServiceCbs *>(bctbx_list_get_data(it)));
LinphoneLoggingServiceCbsLogMessageWrittenCb cb = linphone_logging_service_cbs_get_log_message_written(linphone_logging_service_get_current_callbacks(service));
if (cb) {
char *message = bctbx_strdup_vprintf(fmt, args);
cb(service, domain, _bctbx_log_level_to_linphone_log_level(lev), message);
bctbx_free(message);
}
}
linphone_logging_service_set_current_callbacks(service, nullptr);
bctbx_list_free(callbacksCopy);
}
static void _log_handler_destroy_cb(bctbx_log_handler_t *handler) {
......@@ -165,6 +180,7 @@ void linphone_logging_service_unref(LinphoneLoggingService *service) {
static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) {
if (log_service->log_handler)
bctbx_remove_log_handler(log_service->log_handler);
_linphone_logging_service_clear_callbacks(log_service);
linphone_logging_service_cbs_unref(log_service->cbs);
}
......@@ -179,6 +195,32 @@ LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const Linphone
return log_service->cbs;
}
void linphone_logging_service_add_callbacks(LinphoneLoggingService *log_service, LinphoneLoggingServiceCbs *cbs) {
log_service->callbacks = bctbx_list_append(log_service->callbacks, linphone_logging_service_cbs_ref(cbs));
}
void linphone_logging_service_remove_callbacks(LinphoneLoggingService *log_service, LinphoneLoggingServiceCbs *cbs) {
log_service->callbacks = bctbx_list_remove(log_service->callbacks, cbs);
linphone_logging_service_cbs_unref(cbs);
}
LinphoneLoggingServiceCbs *linphone_logging_service_get_current_callbacks(const LinphoneLoggingService *log_service) {
return log_service->currentCbs;
}
void linphone_logging_service_set_current_callbacks(LinphoneLoggingService *log_service, LinphoneLoggingServiceCbs *cbs) {
log_service->currentCbs = cbs;
}
const bctbx_list_t *linphone_logging_service_get_callbacks_list(const LinphoneLoggingService *log_service) {
return log_service->callbacks;
}
void _linphone_logging_service_clear_callbacks (LinphoneLoggingService *log_service) {
bctbx_list_free_with_data(log_service->callbacks, (bctbx_list_free_func)linphone_logging_service_cbs_unref);
log_service->callbacks = nullptr;
}
static const char *_linphone_logging_service_log_domains[] = {
"bctbx",
"belle-sip",
......@@ -232,6 +274,10 @@ static LinphoneLoggingServiceCbs *_linphone_logging_service_cbs_new(void) {
return belle_sip_object_new(LinphoneLoggingServiceCbs);
}
LinphoneLoggingServiceCbs *linphone_logging_service_cbs_new(void) {
return _linphone_logging_service_cbs_new();
}
LinphoneLoggingServiceCbs *linphone_logging_service_cbs_ref(LinphoneLoggingServiceCbs *cbs) {
return (LinphoneLoggingServiceCbs *)belle_sip_object_ref(cbs);
}
......@@ -266,4 +312,4 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneLoggingServiceCbs, belle_sip_object_t,
NULL, // clone
NULL, // marshal
FALSE // unown
);
);
\ No newline at end of file
......@@ -60,6 +60,27 @@ LinphonePlayerCbs * linphone_player_get_callbacks(const LinphonePlayer *player)
return player->callbacks;
}
void linphone_player_add_callbacks(LinphonePlayer *player, LinphonePlayerCbs *cbs) {
player->callbacks_list = bctbx_list_append(player->callbacks_list, linphone_player_cbs_ref(cbs));
}
void linphone_player_remove_callbacks(LinphonePlayer *player, LinphonePlayerCbs *cbs) {
player->callbacks_list = bctbx_list_remove(player->callbacks_list, cbs);
linphone_player_cbs_unref(cbs);
}
LinphonePlayerCbs *linphone_player_get_current_callbacks(const LinphonePlayer *player) {
return player->currentCbs;
}
void linphone_player_set_current_callbacks(LinphonePlayer *player, LinphonePlayerCbs *cbs) {
player->currentCbs = cbs;
}
const bctbx_list_t *linphone_player_get_callbacks_list(const LinphonePlayer *player) {
return player->callbacks_list;
}
LinphoneCore *linphone_player_get_core(const LinphonePlayer *player){
return player->core;
}
......@@ -111,6 +132,8 @@ void linphone_player_destroy(LinphonePlayer *obj) {
void _linphone_player_destroy(LinphonePlayer *player) {
if(player->destroy) player->destroy(player);
linphone_player_cbs_unref(player->callbacks);
bctbx_list_free_with_data(player->callbacks_list, (bctbx_list_free_func)linphone_player_cbs_unref);
player->callbacks_list = nullptr;
}
......@@ -144,6 +167,17 @@ static void on_eof(void *user_data, MSFilter *f, unsigned int event_id, void *ar
LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs);
if (cb) cb(player);
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_player_get_callbacks_list(player));
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) {
linphone_player_set_current_callbacks(player, reinterpret_cast<LinphonePlayerCbs *>(bctbx_list_get_data(it)));
LinphonePlayerCbsEofReachedCb callback = linphone_player_cbs_get_eof_reached(linphone_player_get_current_callbacks(player));
if (callback) {
callback(player);
}
}
linphone_player_set_current_callbacks(player, nullptr);
bctbx_list_free(callbacksCopy);
break;
}
}
......
......@@ -188,6 +188,8 @@ void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendL
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list);
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize);
LinphoneFriendListCbs * linphone_friend_list_cbs_new(void);
void linphone_friend_list_set_current_callbacks(LinphoneFriendList *friend_list, LinphoneFriendListCbs *cbs);
int linphone_parse_host_port(const char *input, char *host, size_t hostlen, int *port);
int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen, int default_port);
......@@ -327,6 +329,15 @@ void _linphone_chat_room_notify_participant_registration_subscription_requested(
void _linphone_chat_room_notify_participant_registration_unsubscription_requested(LinphoneChatRoom *cr, const LinphoneAddress *participantAddr);
void _linphone_chat_room_notify_chat_message_should_be_stored(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
void _linphone_chat_room_clear_callbacks (LinphoneChatRoom *cr);
void _linphone_chat_message_notify_msg_state_changed(LinphoneChatMessage* msg, LinphoneChatMessageState state);
void _linphone_chat_message_notify_participant_imdn_state_changed(LinphoneChatMessage* msg, const LinphoneParticipantImdnState *state);
void _linphone_chat_message_notify_file_transfer_recv(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer);
void _linphone_chat_message_notify_file_transfer_send(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t size);
void _linphone_chat_message_notify_file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t total);
void _linphone_chat_message_clear_callbacks (LinphoneChatMessage *msg);
const LinphoneParticipantImdnState *_linphone_participant_imdn_state_from_cpp_obj (const LinphonePrivate::ParticipantImdnState &state);
LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile);
......@@ -345,6 +356,7 @@ void linphone_task_list_free(LinphoneTaskList *t);
LinphoneCoreCbs * _linphone_core_cbs_new(void);
void _linphone_core_cbs_set_v_table(LinphoneCoreCbs *cbs, LinphoneCoreVTable *vtable, bool_t autorelease);
LinphoneLoggingServiceCbs *linphone_logging_service_cbs_new(void);
LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
void linphone_tunnel_configure(LinphoneTunnel *tunnel);
......@@ -415,9 +427,11 @@ SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content, bo
SalReason linphone_reason_to_sal(LinphoneReason reason);
LinphoneReason linphone_reason_from_sal(SalReason reason);
void linphone_error_info_to_sal(const LinphoneErrorInfo* ei, SalErrorInfo* sei);
LinphoneEventCbs *linphone_event_cbs_new(void);
LinphoneEvent *linphone_event_new(LinphoneCore *lc, LinphoneSubscriptionDir dir, const char *name, int expires);
LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, LinphonePrivate::SalEventOp *op, LinphoneSubscriptionDir dir, const char *name);
void linphone_event_unpublish(LinphoneEvent *lev);
void linphone_event_set_current_callbacks(LinphoneEvent *ev, LinphoneEventCbs *cbs);
/**
* Useful for out of dialog notify
* */
......@@ -426,7 +440,7 @@ void linphone_event_set_internal(LinphoneEvent *lev, bool_t internal);
bool_t linphone_event_is_internal(LinphoneEvent *lev);
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state);
void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state);
void _linphone_event_notify_notify_response(const LinphoneEvent *lev);
void _linphone_event_notify_notify_response(LinphoneEvent *lev);
LinphoneSubscriptionState linphone_subscription_state_from_sal(SalSubscribeStatus ss);
LinphoneContent *linphone_content_from_sal_body_handler(const SalBodyHandler *ref, bool parseMultipart = true);
void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc);
......@@ -454,6 +468,7 @@ LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, co
LinphonePlayerCbs *linphone_player_cbs_new(void);
LinphonePlayer * linphone_player_new(LinphoneCore *core);
void _linphone_player_destroy(LinphonePlayer *player);
void linphone_player_set_current_callbacks(LinphonePlayer *player, LinphonePlayerCbs *cbs);
/*****************************************************************************
......@@ -594,6 +609,10 @@ void _linphone_core_set_log_handler(OrtpLogFunc logfunc);
void _linphone_core_set_native_preview_window_id(LinphoneCore *lc, void *id);
void _linphone_core_set_native_video_window_id(LinphoneCore *lc, void *id);
LinphoneAccountCreatorCbs * linphone_account_creator_cbs_new(void);
void linphone_account_creator_set_current_callbacks(LinphoneAccountCreator *creator, LinphoneAccountCreatorCbs *cbs);
LinphoneXmlRpcRequestCbs * linphone_xml_rpc_request_cbs_new(void);
void linphone_xml_rpc_request_set_current_callbacks(LinphoneXmlRpcRequest *request, LinphoneXmlRpcRequestCbs *cbs);
#ifdef __cplusplus
}
......
......@@ -223,7 +223,9 @@ struct _LinphoneFriendList {
char *uri;
MSList *dirty_friends_to_update;
int revision;
LinphoneFriendListCbs *cbs;
LinphoneFriendListCbs *cbs; // Deprecated, use a list of Cbs instead
bctbx_list_t *callbacks;
LinphoneFriendListCbs *currentCbs;
bool_t enable_subscriptions;
bool_t bodyless_subscription;
};
......@@ -410,7 +412,11 @@ struct _LinphoneEvent{
LinphonePublishState publish_state;
void *userdata;
char *name;
LinphoneEventCbs *callbacks;
LinphoneEventCbs *callbacks; // Deprecated, use a list of Cbs instead
bctbx_list_t *callbacks_list;
LinphoneEventCbs *currentCbs;
int expires;
bool_t terminating;
bool_t is_out_of_dialog_op; /*used for out of dialog notify*/
......@@ -532,7 +538,9 @@ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcRequestCbs);
struct _LinphoneXmlRpcRequest {
belle_sip_object_t base;
void *user_data;
LinphoneXmlRpcRequestCbs *callbacks;
LinphoneXmlRpcRequestCbs *callbacks; // Deprecated, use a list of Cbs instead
bctbx_list_t *callbacks_list;
LinphoneXmlRpcRequestCbs *currentCbs;
belle_sip_list_t *arg_list;
char *content; /**< The string representation of the XML-RPC request */
char *method;
......@@ -612,8 +620,10 @@ struct _LinphonePlayer{
void (*close)(LinphonePlayer* player);
void (*destroy)(LinphonePlayer *player);
void *impl;
LinphonePlayerCbs *callbacks;
LinphonePlayerCbs *callbacks; // Deprecated, use a list of Cbs instead
LinphoneCore *core;
bctbx_list_t *callbacks_list;
LinphonePlayerCbs *currentCbs;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphonePlayer);
......
......@@ -189,7 +189,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_g
* @param[in] cb The get confirmation key request to be used.
* @donotwrap Exists for tests purposes only
**/
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_get_confirmation_key(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_confirmation_key(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
/**
* Deletes local LIME X3DH database
......
......@@ -37,7 +37,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneXmlRpcRequestCbs, belle_sip_object_t,
FALSE
);
static LinphoneXmlRpcRequestCbs * linphone_xml_rpc_request_cbs_new(void) {
LinphoneXmlRpcRequestCbs * linphone_xml_rpc_request_cbs_new(void) {
return belle_sip_object_new(LinphoneXmlRpcRequestCbs);
}
......@@ -66,6 +66,16 @@ void linphone_xml_rpc_request_cbs_set_response(LinphoneXmlRpcRequestCbs *cbs, Li
cbs->response = cb;
}
#define NOTIFY_IF_EXIST(cbName, functionName, ...) \
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_xml_rpc_request_get_callbacks_list(request)); \
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) { \
linphone_xml_rpc_request_set_current_callbacks(request, reinterpret_cast<LinphoneXmlRpcRequestCbs *>(bctbx_list_get_data(it))); \
LinphoneXmlRpcRequestCbs ## cbName ## Cb cb = linphone_xml_rpc_request_cbs_get_ ## functionName (linphone_xml_rpc_request_get_current_callbacks(request)); \
if (cb) \
cb(__VA_ARGS__); \
} \
linphone_xml_rpc_request_set_current_callbacks(request, nullptr); \
bctbx_list_free(callbacksCopy);
static void format_request(LinphoneXmlRpcRequest *request) {
char si[64];
......@@ -173,9 +183,10 @@ static void process_io_error_from_post_xml_rpc_request(void *data, const belle_s
ms_error("I/O Error during XML-RPC request sending");
if (!linphone_xml_rpc_request_aborted(request)){
request->status = LinphoneXmlRpcStatusFailed;
if (request->callbacks->response != NULL) {
if (request->callbacks->response != NULL) {
request->callbacks->response(request);
}
NOTIFY_IF_EXIST(Response, response, request)
}
linphone_xml_rpc_request_unref(request);
}
......@@ -202,6 +213,7 @@ static void process_auth_requested_from_post_xml_rpc_request(void *data, belle_s
if (request->callbacks->response != NULL) {
request->callbacks->response(request);
}
NOTIFY_IF_EXIST(Response, response, request)
}
linphone_xml_rpc_request_unref(request);
}
......@@ -242,6 +254,7 @@ end:
if (request->callbacks->response != NULL) {
request->callbacks->response(request);
}
NOTIFY_IF_EXIST(Response, response, request)
}
static void notify_xml_rpc_error(LinphoneXmlRpcRequest *request) {
......@@ -249,6 +262,7 @@ static void notify_xml_rpc_error(LinphoneXmlRpcRequest *request) {
if (request->callbacks->response != NULL) {
request->callbacks->response(request);
}
NOTIFY_IF_EXIST(Response, response, request)
}
static void process_response_from_post_xml_rpc_request(void *data, const belle_http_response_event_t *event) {
......@@ -299,6 +313,8 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
if (request->content) belle_sip_free(request->content);
belle_sip_free(request->method);
linphone_xml_rpc_request_cbs_unref(request->callbacks);
bctbx_list_free_with_data(request->callbacks_list, (bctbx_list_free_func)linphone_xml_rpc_request_cbs_unref);
request->callbacks_list = nullptr;
}
static void _linphone_xml_rpc_session_destroy(LinphoneXmlRpcSession *session) {
......@@ -360,6 +376,27 @@ LinphoneXmlRpcRequestCbs * linphone_xml_rpc_request_get_callbacks(const Linphone
return request->callbacks;
}
void linphone_xml_rpc_request_add_callbacks(LinphoneXmlRpcRequest *request, LinphoneXmlRpcRequestCbs *cbs) {
request->callbacks_list = bctbx_list_append(request->callbacks_list, linphone_xml_rpc_request_cbs_ref(cbs));
}
void linphone_xml_rpc_request_remove_callbacks(LinphoneXmlRpcRequest *request, LinphoneXmlRpcRequestCbs *cbs) {
request->callbacks_list = bctbx_list_remove(request->callbacks_list, cbs);
linphone_xml_rpc_request_cbs_unref(cbs);
}
LinphoneXmlRpcRequestCbs *linphone_xml_rpc_request_get_current_callbacks(const LinphoneXmlRpcRequest *request) {
return request->currentCbs;
}
void linphone_xml_rpc_request_set_current_callbacks(LinphoneXmlRpcRequest *request, LinphoneXmlRpcRequestCbs *cbs) {
request->currentCbs = cbs;
}
const bctbx_list_t *linphone_xml_rpc_request_get_callbacks_list(const LinphoneXmlRpcRequest *request) {
return request->callbacks_list;
}
const char * linphone_xml_rpc_request_get_content(const LinphoneXmlRpcRequest *request) {
return request->content;
}
......
......@@ -337,9 +337,31 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC const char * linphone_account_creator_get_ro
* Get the #LinphoneAccountCreatorCbs object associated with a LinphoneAccountCreator.
* @param[in] creator #LinphoneAccountCreator object
* @return The #LinphoneAccountCreatorCbs object associated with the LinphoneAccountCreator.
* @deprecated use add_callbacks / remove_callbacks instead
**/
LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator);
/**
* Add the #LinphoneAccountCreatorCbs object to a LinphoneAccountCreator.
* @param[in] creator #LinphoneAccountCreator object
* @param[in] cbs The #LinphoneAccountCreatorCbs object to add to the LinphoneAccountCreator.
**/
LINPHONE_PUBLIC void linphone_account_creator_add_callbacks(LinphoneAccountCreator *creator, LinphoneAccountCreatorCbs *cbs);
/**
* Removes the #LinphoneAccountCreatorCbs object from a LinphoneAccountCreator.
* @param[in] creator #LinphoneAccountCreator object
* @param[in] cbs The #LinphoneAccountCreatorCbs object to remove from the LinphoneAccountCreator.
**/
LINPHONE_PUBLIC void linphone_account_creator_remove_callbacks(LinphoneAccountCreator *creator, LinphoneAccountCreatorCbs *cbs);
/**
* Get the current #LinphoneAccountCreatorCbs object associated with a LinphoneAccountCreator.
* @param[in] creator #LinphoneAccountCreator object
* @return The current #LinphoneAccountCreatorCbs object associated with the LinphoneAccountCreator.