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 { ...@@ -35,7 +35,7 @@ struct _LinphoneAccountCreatorService {
LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */ LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */
LinphoneAccountCreatorRequestFunc delete_account_request_cb; /**< Request to delete account */ LinphoneAccountCreatorRequestFunc delete_account_request_cb; /**< Request to delete account */
LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */ 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 activate_account_request_cb; /**< Request to activate account */
LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */ LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */
...@@ -61,7 +61,7 @@ struct _LinphoneAccountCreatorCbs { ...@@ -61,7 +61,7 @@ struct _LinphoneAccountCreatorCbs {
LinphoneAccountCreatorCbsStatusCb activate_account_response_cb; /**< Response of activate_account request */ LinphoneAccountCreatorCbsStatusCb activate_account_response_cb; /**< Response of activate_account request */
LinphoneAccountCreatorCbsStatusCb is_account_activated_response_cb; /**< Response of is_account_activated 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 link_account_response_cb; /**< Response of link_account request */
LinphoneAccountCreatorCbsStatusCb activate_alias_response_cb; /**< Response of activation alias */ LinphoneAccountCreatorCbsStatusCb activate_alias_response_cb; /**< Response of activation alias */
...@@ -81,7 +81,9 @@ struct _LinphoneAccountCreator { ...@@ -81,7 +81,9 @@ struct _LinphoneAccountCreator {
/* AccountCreator */ /* AccountCreator */
LinphoneAccountCreatorService *service; /**< Account creator service */ 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 */ LinphoneXmlRpcSession *xmlrpc_session; /**< XML-RPC session */
LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */ LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */
......
...@@ -86,7 +86,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneEventCbs, belle_sip_object_t, ...@@ -86,7 +86,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneEventCbs, belle_sip_object_t,
FALSE FALSE
); );
static LinphoneEventCbs *linphone_event_cbs_new(void) { LinphoneEventCbs *linphone_event_cbs_new(void) {
return belle_sip_object_new(LinphoneEventCbs); return belle_sip_object_new(LinphoneEventCbs);
} }
...@@ -497,6 +497,8 @@ static void linphone_event_destroy(LinphoneEvent *lev){ ...@@ -497,6 +497,8 @@ static void linphone_event_destroy(LinphoneEvent *lev){
if (lev->from_address) linphone_address_unref(lev->from_address); if (lev->from_address) linphone_address_unref(lev->from_address);
if (lev->remote_contact_address) linphone_address_unref(lev->remote_contact_address); if (lev->remote_contact_address) linphone_address_unref(lev->remote_contact_address);
linphone_event_cbs_unref(lev->callbacks); 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); ms_free(lev->name);
} }
...@@ -574,16 +576,48 @@ static belle_sip_error_code _linphone_event_marshall(belle_sip_object_t *obj, ch ...@@ -574,16 +576,48 @@ static belle_sip_error_code _linphone_event_marshall(belle_sip_object_t *obj, ch
return err; 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); LinphoneEventCbsNotifyResponseCb cb = linphone_event_cbs_get_notify_response(lev->callbacks);
if (cb) if (cb)
cb(lev); 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) { LinphoneEventCbs *linphone_event_get_callbacks(const LinphoneEvent *ev) {
return ev->callbacks; 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_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneEvent);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneEvent, belle_sip_object_t, BELLE_SIP_INSTANCIATE_VPTR(LinphoneEvent, belle_sip_object_t,
......
...@@ -258,6 +258,10 @@ LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(const LinphoneFactor ...@@ -258,6 +258,10 @@ LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(const LinphoneFactor
return _linphone_chat_room_cbs_new(); 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) { LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) {
return _linphone_vcard_new(); return _linphone_vcard_new();
} }
...@@ -455,3 +459,27 @@ void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLo ...@@ -455,3 +459,27 @@ void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLo
LinphoneTunnelConfig *linphone_factory_create_tunnel_config(LinphoneFactory *factory) { LinphoneTunnelConfig *linphone_factory_create_tunnel_config(LinphoneFactory *factory) {
return linphone_tunnel_config_new(); 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, ...@@ -36,14 +36,46 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriendListCbs, belle_sip_object_t,
FALSE FALSE
); );
static LinphoneFriendListCbs * linphone_friend_list_cbs_new(void) { LinphoneFriendListCbs * linphone_friend_list_cbs_new(void) {
return belle_sip_object_new(LinphoneFriendListCbs); return belle_sip_object_new(LinphoneFriendListCbs);
} }
LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *list) { LinphoneFriendListCbs * linphone_friend_list_get_callbacks(const LinphoneFriendList *friend_list) {
return list->cbs; 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) { LinphoneFriendListCbs * linphone_friend_list_cbs_ref(LinphoneFriendListCbs *cbs) {
belle_sip_object_ref(cbs); belle_sip_object_ref(cbs);
return cbs; return cbs;
...@@ -355,8 +387,12 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList ...@@ -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 // 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)) { if (bctbx_list_size(list_friends_presence_received) > 0) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received); 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); bctbx_list_free(list_friends_presence_received);
} }
...@@ -398,8 +434,12 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList ...@@ -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 // 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)) { if (bctbx_list_size(list_friends_presence_received) > 0) {
linphone_friend_list_cbs_get_presence_received(list_cbs)(list, list_friends_presence_received); 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); bctbx_list_free(list_friends_presence_received);
} }
...@@ -449,6 +489,8 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) { ...@@ -449,6 +489,8 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) {
} }
if (list->uri != NULL) ms_free(list->uri); if (list->uri != NULL) ms_free(list->uri);
if (list->cbs) linphone_friend_list_cbs_unref(list->cbs); 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->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) 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); 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 * ...@@ -665,9 +707,11 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
} }
static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char *msg) { 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) { 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); 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); linphone_carddav_context_destroy(cdc);
} }
...@@ -691,6 +735,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie ...@@ -691,6 +735,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
if (cdc->friend_list->cbs->sync_state_changed_cb) { if (cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); 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); linphone_carddav_delete_vcard(cdc, lf);
} }
} }
...@@ -771,6 +816,7 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) { ...@@ -771,6 +816,7 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
if (cdc->friend_list->cbs->sync_state_changed_cb) { if (cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); 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); linphone_carddav_put_vcard(cdc, lf);
} }
} }
...@@ -781,36 +827,39 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) { ...@@ -781,36 +827,39 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) {
static void carddav_created(LinphoneCardDavContext *cdc, LinphoneFriend *lf) { static void carddav_created(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc) { if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list; LinphoneFriendList *list = cdc->friend_list;
linphone_friend_list_import_friend(lfl, lf, FALSE); linphone_friend_list_import_friend(list, lf, FALSE);
if (cdc->friend_list->cbs->contact_created_cb) { 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) { static void carddav_removed(LinphoneCardDavContext *cdc, LinphoneFriend *lf) {
if (cdc) { if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list; LinphoneFriendList *list = cdc->friend_list;
_linphone_friend_list_remove_friend(lfl, lf, FALSE); _linphone_friend_list_remove_friend(list, lf, FALSE);
if (cdc->friend_list->cbs->contact_deleted_cb) { 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) { static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, LinphoneFriend *lf_old) {
if (cdc) { if (cdc) {
LinphoneFriendList *lfl = cdc->friend_list; LinphoneFriendList *list = cdc->friend_list;
bctbx_list_t *elem = bctbx_list_find(lfl->friends, lf_old); bctbx_list_t *elem = bctbx_list_find(list->friends, lf_old);
if (elem) { if (elem) {
elem->data = linphone_friend_ref(lf_new); elem->data = linphone_friend_ref(lf_new);
} }
linphone_core_store_friend_in_db(lf_new->lc, lf_new); linphone_core_store_friend_in_db(lf_new->lc, lf_new);
if (cdc->friend_list->cbs->contact_updated_cb) { 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); linphone_friend_unref(lf_old);
} }
} }
...@@ -832,6 +881,7 @@ void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *li ...@@ -832,6 +881,7 @@ void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *li
if (cdc && cdc->friend_list->cbs->sync_state_changed_cb) { if (cdc && cdc->friend_list->cbs->sync_state_changed_cb) {
cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); 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); linphone_carddav_synchronize(cdc);
} }
} }
......
...@@ -2304,7 +2304,7 @@ static void _linphone_core_init_account_creator_service(LinphoneCore *lc) { ...@@ -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->create_account_request_cb = linphone_account_creator_create_account_linphone;
service->delete_account_request_cb = linphone_account_creator_delete_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->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->activate_account_request_cb = linphone_account_creator_activate_account_linphone;
service->is_account_activated_request_cb = linphone_account_creator_is_account_activated_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->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); ...@@ -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_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 #ifdef __cplusplus
} }
#endif #endif
......
...@@ -32,7 +32,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -32,7 +32,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct _LinphoneLoggingService { struct _LinphoneLoggingService {
belle_sip_object_t base; 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; bctbx_log_handler_t *log_handler;
}; };
...@@ -123,6 +125,19 @@ static void _log_handler_on_message_written_cb(void *info,const char *domain, Bc ...@@ -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); service->cbs->message_event_cb(service, domain, _bctbx_log_level_to_linphone_log_level(lev), message);
bctbx_free(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) { static void _log_handler_destroy_cb(bctbx_log_handler_t *handler) {
...@@ -165,6 +180,7 @@ void linphone_logging_service_unref(LinphoneLoggingService *service) { ...@@ -165,6 +180,7 @@ void linphone_logging_service_unref(LinphoneLoggingService *service) {
static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) { static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) {
if (log_service->log_handler) if (log_service->log_handler)
bctbx_remove_log_handler(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); linphone_logging_service_cbs_unref(log_service->cbs);
} }
...@@ -179,6 +195,32 @@ LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const Linphone ...@@ -179,6 +195,32 @@ LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const Linphone
return log_service->cbs; 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[] = { static const char *_linphone_logging_service_log_domains[] = {
"bctbx", "bctbx",
"belle-sip", "belle-sip",
...@@ -232,6 +274,10 @@ static LinphoneLoggingServiceCbs *_linphone_logging_service_cbs_new(void) { ...@@ -232,6 +274,10 @@ static LinphoneLoggingServiceCbs *_linphone_logging_service_cbs_new(void) {
return belle_sip_object_new(LinphoneLoggingServiceCbs); 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) { LinphoneLoggingServiceCbs *linphone_logging_service_cbs_ref(LinphoneLoggingServiceCbs *cbs) {
return (LinphoneLoggingServiceCbs *)belle_sip_object_ref(cbs); return (LinphoneLoggingServiceCbs *)belle_sip_object_ref(cbs);
} }
...@@ -266,4 +312,4 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneLoggingServiceCbs, belle_sip_object_t, ...@@ -266,4 +312,4 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneLoggingServiceCbs, belle_sip_object_t,
NULL, // clone NULL, // clone
NULL, // marshal NULL, // marshal
FALSE // unown FALSE // unown
); );
\ No newline at end of file
...@@ -60,6 +60,27 @@ LinphonePlayerCbs * linphone_player_get_callbacks(const LinphonePlayer *player) ...@@ -60,6 +60,27 @@ LinphonePlayerCbs * linphone_player_get_callbacks(const LinphonePlayer *player)
return player->callbacks; 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){ LinphoneCore *linphone_player_get_core(const LinphonePlayer *player){
return player->core; return player->core;
} }
...@@ -111,6 +132,8 @@ void linphone_player_destroy(LinphonePlayer *obj) { ...@@ -111,6 +132,8 @@ void linphone_player_destroy(LinphonePlayer *obj) {
void _linphone_player_destroy(LinphonePlayer *player) { void _linphone_player_destroy(LinphonePlayer *player) {
if(player->destroy) player->destroy(player); if(player->destroy) player->destroy(player);
linphone_player_cbs_unref(player->callbacks); 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 ...@@ -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); LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs); LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs);
if (cb) cb(player); 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; break;
} }
} }
......
...@@ -188,6 +188,8 @@ void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendL ...@@ -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_from_db(LinphoneCore *lc, LinphoneFriendList *list);
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc); 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); 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 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); 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( ...@@ -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_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_notify_chat_message_should_be_stored(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
void _linphone_chat_room_clear_callbacks (LinphoneChatRoom *cr); 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); 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); LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile);
...@@ -345,6 +356,7 @@ void linphone_task_list_free(LinphoneTaskList *t); ...@@ -345,6 +356,7 @@ void linphone_task_list_free(LinphoneTaskList *t);
LinphoneCoreCbs * _linphone_core_cbs_new(void); LinphoneCoreCbs * _linphone_core_cbs_new(void);
void _linphone_core_cbs_set_v_table(LinphoneCoreCbs *cbs, LinphoneCoreVTable *vtable, bool_t autorelease); 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); LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
void linphone_tunnel_configure(LinphoneTunnel *tunnel); void linphone_tunnel_configure(LinphoneTunnel *tunnel);
...@@ -415,9 +427,11 @@ SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content, bo ...@@ -415,9 +427,11 @@ SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content, bo
SalReason linphone_reason_to_sal(LinphoneReason reason); SalReason linphone_reason_to_sal(LinphoneReason reason);
LinphoneReason linphone_reason_from_sal(SalReason reason); LinphoneReason linphone_reason_from_sal(SalReason reason);
void linphone_error_info_to_sal(const LinphoneErrorInfo* ei, SalErrorInfo* sei); 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(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); 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_unpublish(LinphoneEvent *lev);
void linphone_event_set_current_callbacks(LinphoneEvent *ev, LinphoneEventCbs *cbs);
/** /**
* Useful for out of dialog notify * Useful for out of dialog notify
* */ * */
...@@ -426,7 +440,7 @@ void linphone_event_set_internal(LinphoneEvent *lev, bool_t internal); ...@@ -426,7 +440,7 @@ void linphone_event_set_internal(LinphoneEvent *lev, bool_t internal);
bool_t linphone_event_is_internal(LinphoneEvent *lev); bool_t linphone_event_is_internal(LinphoneEvent *lev);
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state); void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state);
void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState 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); LinphoneSubscriptionState linphone_subscription_state_from_sal(SalSubscribeStatus ss);
LinphoneContent *linphone_content_from_sal_body_handler(const SalBodyHandler *ref, bool parseMultipart = true); LinphoneContent *linphone_content_from_sal_body_handler(const SalBodyHandler *ref, bool parseMultipart = true);
void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc); void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc);
...@@ -454,6 +468,7 @@ LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, co ...@@ -454,6 +468,7 @@ LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, co
LinphonePlayerCbs *linphone_player_cbs_new(void); LinphonePlayerCbs *linphone_player_cbs_new(void);
LinphonePlayer * linphone_player_new(LinphoneCore *core); LinphonePlayer * linphone_player_new(LinphoneCore *core);
void _linphone_player_destroy(LinphonePlayer *player); void _linphone_player_destroy(LinphonePlayer *player);
void linphone_player_set_current_callbacks(LinphonePlayer *player, LinphonePlayerCbs *cbs);