From 548a81228f86d8938b866ed754dfac1dac604de5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 30 Mar 2017 15:40:33 +0200 Subject: [PATCH] Add definition of callbacks on the LinphoneCall object. --- coreapi/callbacks.c | 3 +- coreapi/factory.c | 5 +- coreapi/info.c | 2 +- coreapi/linphonecall.c | 152 +++++- coreapi/linphonecore.c | 9 + coreapi/private.h | 26 + coreapi/vtables.c | 5 + include/CMakeLists.txt | 1 + include/linphone/Makefile.am | 1 + include/linphone/call.h | 135 +++++ include/linphone/callbacks.h | 645 ++++++++++++++++++++++++ include/linphone/chat.h | 44 -- include/linphone/core.h | 366 +------------- include/linphone/event.h | 31 -- include/linphone/factory.h | 7 + include/linphone/friendlist.h | 30 -- include/linphone/im_encryption_engine.h | 59 --- include/linphone/types.h | 12 +- include/linphone/xmlrpc.h | 7 - 19 files changed, 1006 insertions(+), 534 deletions(-) create mode 100644 include/linphone/callbacks.h diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 9dbd95dd8..68da7e6f6 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -1114,10 +1114,9 @@ static void vfu_request(SalOp *op){ } static void dtmf_received(SalOp *op, char dtmf){ - LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); if (!call) return; - linphone_core_notify_dtmf_received(lc, call, dtmf); + linphone_call_notify_dtmf_received(call, dtmf); } static void refer_received(Sal *sal, SalOp *op, const char *referto){ diff --git a/coreapi/factory.c b/coreapi/factory.c index b43bd0136..f5983291d 100644 --- a/coreapi/factory.c +++ b/coreapi/factory.c @@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif extern LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata); -extern LinphoneCoreCbs *_linphone_core_cbs_new(void); extern LinphoneAddress *_linphone_address_new(const char *addr); typedef belle_sip_object_t_vptr_t LinphoneFactory_vptr_t; @@ -133,6 +132,10 @@ LinphoneAuthInfo *linphone_factory_create_auth_info(const LinphoneFactory *facto return linphone_auth_info_new(username, userid, passwd, ha1, realm, domain); } +LinphoneCallCbs * linphone_factory_create_call_cbs(const LinphoneFactory *factory) { + return _linphone_call_cbs_new(); +} + LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) { return _linphone_vcard_new(); } diff --git a/coreapi/info.c b/coreapi/info.c index ff1c8d876..6bd80ebc3 100644 --- a/coreapi/info.c +++ b/coreapi/info.c @@ -104,7 +104,7 @@ void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, SalBodyHandle LinphoneInfoMessage *info=linphone_core_create_info_message(lc); info->headers=sal_custom_header_clone(sal_op_get_recv_custom_header(op)); if (body_handler) info->content=linphone_content_from_sal_body_handler(body_handler); - linphone_core_notify_info_received(lc,call,info); + linphone_call_notify_info_message_received(call, info); linphone_info_message_unref(info); } } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d57ee984c..b3d7a4c80 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -51,6 +51,85 @@ static void _linphone_call_set_next_video_frame_decoded_trigger(LinphoneCall *ca void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index); +typedef belle_sip_object_t_vptr_t LinphoneCallCbs_vptr_t; +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCallCbs); +BELLE_SIP_INSTANCIATE_VPTR(LinphoneCallCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // Marshall + FALSE +); + +LinphoneCallCbs *_linphone_call_cbs_new(void) { + LinphoneCallCbs *obj = belle_sip_object_new(LinphoneCallCbs); + return obj; +} + +LinphoneCallCbs *linphone_call_cbs_ref(LinphoneCallCbs *cbs) { + return (LinphoneCallCbs *)belle_sip_object_ref(cbs); +} + +void linphone_call_cbs_unref(LinphoneCallCbs *cbs) { + belle_sip_object_unref(cbs); +} + +void *linphone_call_cbs_get_user_data(const LinphoneCallCbs *cbs) { + return cbs->user_data; +} + +void linphone_call_cbs_set_user_data(LinphoneCallCbs *cbs, void *user_data) { + cbs->user_data = user_data; +} + +LinphoneCallCbsDtmfReceivedCb linphone_call_cbs_get_dtmf_received(LinphoneCallCbs *cbs) { + return cbs->dtmf_received_cb; +} + +void linphone_call_cbs_set_dtmf_received(LinphoneCallCbs *cbs, LinphoneCallCbsDtmfReceivedCb cb) { + cbs->dtmf_received_cb = cb; +} + +LinphoneCallCbsEncryptionChangedCb linphone_call_cbs_get_encryption_changed(LinphoneCallCbs *cbs) { + return cbs->encryption_changed_cb; +} + +void linphone_call_cbs_set_encryption_changed(LinphoneCallCbs *cbs, LinphoneCallCbsEncryptionChangedCb cb) { + cbs->encryption_changed_cb = cb; +} + +LinphoneCallCbsInfoMessageReceivedCb linphone_call_cbs_get_info_message_received(LinphoneCallCbs *cbs) { + return cbs->info_message_received_cb; +} + +void linphone_call_cbs_set_info_message_received(LinphoneCallCbs *cbs, LinphoneCallCbsInfoMessageReceivedCb cb) { + cbs->info_message_received_cb = cb; +} + +LinphoneCallCbsStateChangedCb linphone_call_cbs_get_state_changed(LinphoneCallCbs *cbs) { + return cbs->state_changed_cb; +} + +void linphone_call_cbs_set_state_changed(LinphoneCallCbs *cbs, LinphoneCallCbsStateChangedCb cb) { + cbs->state_changed_cb = cb; +} + +LinphoneCallCbsStatsUpdatedCb linphone_call_cbs_get_stats_updated(LinphoneCallCbs *cbs) { + return cbs->stats_updated_cb; +} + +void linphone_call_cbs_set_stats_updated(LinphoneCallCbs *cbs, LinphoneCallCbsStatsUpdatedCb cb) { + cbs->stats_updated_cb = cb; +} + +LinphoneCallCbsTransferStateChangedCb linphone_call_cbs_get_transfer_state_changed(LinphoneCallCbs *cbs) { + return cbs->transfer_state_changed_cb; +} + +void linphone_call_cbs_set_transfer_state_changed(LinphoneCallCbs *cbs, LinphoneCallCbsTransferStateChangedCb cb) { + cbs->transfer_state_changed_cb = cb; +} + + bool_t linphone_call_state_is_early(LinphoneCallState state){ switch (state){ case LinphoneCallIdle: @@ -207,7 +286,7 @@ static void propagate_encryption_changed(LinphoneCall *call){ if (!linphone_call_all_streams_encrypted(call)) { ms_message("Some streams are not encrypted"); call->current_params->media_encryption=LinphoneMediaEncryptionNone; - linphone_core_notify_call_encryption_changed(call->core, call, FALSE, call->auth_token); + linphone_call_notify_encryption_changed(call, FALSE, call->auth_token); } else { if (call->auth_token) {/* ZRTP only is using auth_token */ call->current_params->media_encryption=LinphoneMediaEncryptionZRTP; @@ -215,7 +294,7 @@ static void propagate_encryption_changed(LinphoneCall *call){ call->current_params->media_encryption=LinphoneMediaEncryptionDTLS; } ms_message("All streams are encrypted key exchanged using %s", call->current_params->media_encryption==LinphoneMediaEncryptionZRTP?"ZRTP":call->current_params->media_encryption==LinphoneMediaEncryptionDTLS?"DTLS":"Unknown mechanism"); - linphone_core_notify_call_encryption_changed(call->core, call, TRUE, call->auth_token); + linphone_call_notify_encryption_changed(call, TRUE, call->auth_token); #ifdef VIDEO_ENABLED if (linphone_call_encryption_mandatory(call) && call->videostream && media_stream_started((MediaStream *)call->videostream)) { video_stream_send_vfu(call->videostream); /*nothing could have been sent yet so generating key frame*/ @@ -1779,7 +1858,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const , linphone_call_state_to_string(call->prevstate) , linphone_call_state_to_string(call->state)); } - linphone_core_notify_call_state_changed(lc,call,cstate,message?message:""); + linphone_call_notify_state_changed(call, cstate, message ? message : ""); linphone_reporting_call_state_updated(call); if (cstate==LinphoneCallReleased) {/*shall be performed after app notification*/ linphone_call_set_released(call); @@ -1789,6 +1868,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const static void linphone_call_destroy(LinphoneCall *obj){ ms_message("Call [%p] freed.",obj); + bctbx_list_free_with_data(obj->callbacks, (bctbx_list_free_func)linphone_call_cbs_unref); if (obj->audiostream || obj->videostream){ linphone_call_free_media_resources(obj); } @@ -2754,7 +2834,7 @@ static void linphone_core_dtmf_received(LinphoneCall *call, int dtmf){ ms_warning("Bad dtmf value %i",dtmf); return; } - linphone_core_notify_dtmf_received(call->core, call, dtmf_tab[dtmf]); + linphone_call_notify_dtmf_received(call, dtmf_tab[dtmf]); } static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){ @@ -4299,7 +4379,7 @@ static void report_bandwidth_for_stream(LinphoneCall *call, MediaStream *ms, Lin if (call->core->send_call_stats_periodical_updates){ if (active) update_local_stats(stats, ms); stats->updated |= LINPHONE_CALL_STATS_PERIODICAL_UPDATE; - linphone_core_notify_call_stats_updated(call->core, call, stats); + linphone_call_notify_stats_updated(call, stats); stats->updated=0; } } @@ -4456,9 +4536,8 @@ void linphone_call_stats_uninit(LinphoneCallStats *stats){ } } -void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){ +void linphone_call_notify_stats_updated_with_stream_index(LinphoneCall *call, int stream_index){ LinphoneCallStats *stats = &call->stats[stream_index]; - LinphoneCore *lc = call->core; if (stats->updated){ switch(stats->updated) { case LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE: @@ -4468,7 +4547,7 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){ default: break; } - linphone_core_notify_call_stats_updated(lc, call, stats); + linphone_call_notify_stats_updated(call, stats); stats->updated = 0; } } @@ -4535,7 +4614,7 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ ms = linphone_call_get_media_stream(call, stream_index); if (ms) linphone_call_stats_fill(&call->stats[stats_index],ms,ev); - linphone_call_notify_stats_updated(call,stats_index); + linphone_call_notify_stats_updated_with_stream_index(call,stats_index); if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ if (stream_index == call->main_audio_stream_index) @@ -4654,12 +4733,11 @@ LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call) { void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state) { if (state != call->transfer_state) { - LinphoneCore* lc = call->core; ms_message("Transfer state for call [%p] changed from [%s] to [%s]",call ,linphone_call_state_to_string(call->transfer_state) ,linphone_call_state_to_string(state)); call->transfer_state = state; - linphone_core_notify_transfer_state_changed(lc, call, state); + linphone_call_notify_transfer_state_changed(call, state); } } @@ -5836,3 +5914,55 @@ void linphone_call_ogl_render(LinphoneCall *call, bool_t is_preview) { if (stream->output2 && ms_filter_get_id(stream->output2) == MS_OGL_ID) ms_filter_call_method(stream->output2, MS_OGL_RENDER, NULL); } + +void linphone_call_add_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs) { + call->callbacks = bctbx_list_append(call->callbacks, linphone_call_cbs_ref(cbs)); +} + +void linphone_call_remove_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs) { + call->callbacks = bctbx_list_remove(call->callbacks, cbs); + linphone_call_cbs_unref(cbs); +} + +LinphoneCallCbs *linphone_call_get_current_callbacks(const LinphoneCall *call) { + return call->current_cbs; +} + +#define NOTIFY_IF_EXIST(function_name, ...) \ + bctbx_list_t* iterator; \ + for (iterator = call->callbacks; iterator != NULL; iterator = bctbx_list_next(iterator)) { \ + call->current_cbs = (LinphoneCallCbs *)bctbx_list_get_data(iterator); \ + if (call->current_cbs->function_name != NULL) { \ + call->current_cbs->function_name(__VA_ARGS__); \ + } \ + } + +void linphone_call_notify_state_changed(LinphoneCall *call, LinphoneCallState cstate, const char *message) { + NOTIFY_IF_EXIST(state_changed_cb, call, cstate, message) + linphone_core_notify_call_state_changed(linphone_call_get_core(call), call, cstate, message); +} + +void linphone_call_notify_dtmf_received(LinphoneCall *call, int dtmf) { + NOTIFY_IF_EXIST(dtmf_received_cb, call, dtmf) + linphone_core_notify_dtmf_received(linphone_call_get_core(call), call, dtmf); +} + +void linphone_call_notify_encryption_changed(LinphoneCall *call, bool_t on, const char *authentication_token) { + NOTIFY_IF_EXIST(encryption_changed_cb, call, on, authentication_token) + linphone_core_notify_call_encryption_changed(linphone_call_get_core(call), call, on, authentication_token); +} + +void linphone_call_notify_transfer_state_changed(LinphoneCall *call, LinphoneCallState cstate) { + NOTIFY_IF_EXIST(transfer_state_changed_cb, call, cstate) + linphone_core_notify_transfer_state_changed(linphone_call_get_core(call), call, cstate); +} + +void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallStats *stats) { + NOTIFY_IF_EXIST(stats_updated_cb, call, stats) + linphone_core_notify_call_stats_updated(linphone_call_get_core(call), call, stats); +} + +void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg) { + NOTIFY_IF_EXIST(info_message_received_cb, call, msg) + linphone_core_notify_info_received(linphone_call_get_core(call), call, msg); +} diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ff8d45b20..236b6e322 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -389,6 +389,14 @@ void linphone_core_cbs_set_friend_list_removed(LinphoneCoreCbs *cbs, LinphoneCor cbs->vtable->friend_list_removed = cb; } +LinphoneCoreCbsCallCreatedCb linphone_core_cbs_get_call_created(LinphoneCoreCbs *cbs) { + return cbs->vtable->call_created; +} + +void linphone_core_cbs_set_call_created(LinphoneCoreCbs *cbs, LinphoneCoreCbsCallCreatedCb cb) { + cbs->vtable->call_created = cb; +} + typedef belle_sip_object_t_vptr_t LinphoneCore_vptr_t; BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCore); BELLE_SIP_INSTANCIATE_VPTR(LinphoneCore, belle_sip_object_t, @@ -5949,6 +5957,7 @@ int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call) { if (linphone_core_can_we_add_call(lc)){ if (lc->calls==NULL) notify_soundcard_usage(lc,TRUE); lc->calls = bctbx_list_append(lc->calls,call); + linphone_core_notify_call_created(lc, call); return 0; } return -1; diff --git a/coreapi/private.h b/coreapi/private.h index d0e7a44db..f4dffdfd0 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -290,6 +290,19 @@ typedef struct _PortConfig{ int rtcp_port; }PortConfig; +struct _LinphoneCallCbs { + belle_sip_object_t base; + void *user_data; + LinphoneCallCbsDtmfReceivedCb dtmf_received_cb; + LinphoneCallCbsEncryptionChangedCb encryption_changed_cb; + LinphoneCallCbsInfoMessageReceivedCb info_message_received_cb; + LinphoneCallCbsStateChangedCb state_changed_cb; + LinphoneCallCbsStatsUpdatedCb stats_updated_cb; + LinphoneCallCbsTransferStateChangedCb transfer_state_changed_cb; +}; + +LinphoneCallCbs * _linphone_call_cbs_new(void); + struct _LinphoneCall{ belle_sip_object_t base; void *user_data; @@ -379,11 +392,21 @@ struct _LinphoneCall{ bool_t reinvite_on_cancel_response_requested; bool_t non_op_error; /*set when the LinphoneErrorInfo was set at higher level than sal*/ + + bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */ + LinphoneCallCbs *current_cbs; /* The current LinphoneCallCbs object used to call a callback */ }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCall); +void linphone_call_notify_state_changed(LinphoneCall *call, LinphoneCallState cstate, const char *message); +void linphone_call_notify_dtmf_received(LinphoneCall *call, int dtmf); +void linphone_call_notify_encryption_changed(LinphoneCall *call, bool_t on, const char *authentication_token); +void linphone_call_notify_transfer_state_changed(LinphoneCall *call, LinphoneCallState cstate); +void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallStats *stats); +void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg); + LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg); LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op); void linphone_call_set_new_params(LinphoneCall *call, const LinphoneCallParams *params); @@ -967,6 +990,7 @@ struct _LinphoneCoreCbs { bool_t autorelease; }; +LinphoneCoreCbs * _linphone_core_cbs_new(void); void _linphone_core_cbs_set_v_table(LinphoneCoreCbs *cbs, LinphoneCoreVTable *vtable, bool_t autorelease); typedef struct _LCCallbackObj { @@ -1620,6 +1644,7 @@ BELLE_SIP_TYPE_ID(LinphoneBuffer), BELLE_SIP_TYPE_ID(LinphoneContactProvider), BELLE_SIP_TYPE_ID(LinphoneContactSearch), BELLE_SIP_TYPE_ID(LinphoneCall), +BELLE_SIP_TYPE_ID(LinphoneCallCbs), BELLE_SIP_TYPE_ID(LinphoneCallLog), BELLE_SIP_TYPE_ID(LinphoneCallParams), BELLE_SIP_TYPE_ID(LinphoneChatMessage), @@ -1701,6 +1726,7 @@ void linphone_core_notify_log_collection_upload_state_changed(LinphoneCore *lc, void linphone_core_notify_log_collection_upload_progress_indication(LinphoneCore *lc, size_t offset, size_t total); void linphone_core_notify_friend_list_created(LinphoneCore *lc, LinphoneFriendList *list); void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendList *list); +void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call); void set_mic_gain_db(AudioStream *st, float gain); void set_playback_gain_db(AudioStream *st, float gain); diff --git a/coreapi/vtables.c b/coreapi/vtables.c index fd392361d..d48342b36 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -311,6 +311,11 @@ void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendLi cleanup_dead_vtable_refs(lc); } +void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call) { + NOTIFY_IF_EXIST(call_created, lc, call); + cleanup_dead_vtable_refs(lc); +} + static VTableReference * v_table_reference_new(LinphoneCoreCbs *cbs, bool_t internal){ VTableReference *ref=ms_new0(VTableReference,1); ref->valid=TRUE; diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 3884222bc..3125601ee 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -27,6 +27,7 @@ set(HEADER_FILES auth_info.h buffer.h call.h + callbacks.h call_log.h call_params.h call_stats.h diff --git a/include/linphone/Makefile.am b/include/linphone/Makefile.am index 7056185cf..d8df9c528 100644 --- a/include/linphone/Makefile.am +++ b/include/linphone/Makefile.am @@ -7,6 +7,7 @@ linphone_include_HEADERS=\ auth_info.h \ buffer.h \ call.h \ + callbacks.h \ call_log.h \ call_params.h \ call_stats.h \ diff --git a/include/linphone/call.h b/include/linphone/call.h index 242fac2eb..1f494e0fb 100644 --- a/include/linphone/call.h +++ b/include/linphone/call.h @@ -524,6 +524,118 @@ LINPHONE_PUBLIC int linphone_call_transfer(LinphoneCall *call, const char *refer **/ LINPHONE_PUBLIC int linphone_call_transfer_to_another(LinphoneCall *call, LinphoneCall *dest); + +/** + * Acquire a reference to the LinphoneCallCbs object. + * @param[in] cbs LinphoneCallCbs object. + * @return The same LinphoneCallCbs object. + */ +LINPHONE_PUBLIC LinphoneCallCbs *linphone_call_cbs_ref(LinphoneCallCbs *cbs); + +/** + * Release reference to the LinphoneCallCbs object. + * @param[in] cbs LinphoneCallCbs object. + */ +LINPHONE_PUBLIC void linphone_call_cbs_unref(LinphoneCallCbs *cbs); + +/** + * Retrieve the user pointer associated with the LinphoneCallCbs object. + * @param[in] cbs LinphoneCallCbs object. + * @return The user pointer associated with the LinphoneCallCbs object. + */ +LINPHONE_PUBLIC void *linphone_call_cbs_get_user_data(const LinphoneCallCbs *cbs); + +/** + * Assign a user pointer to the LinphoneCallCbs object. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] ud The user pointer to associate with the LinphoneCallCbs object. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_user_data(LinphoneCallCbs *cbs, void *user_data); + +/** + * Get the dtmf received callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current dtmf received callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsDtmfReceivedCb linphone_call_cbs_get_dtmf_received(LinphoneCallCbs *cbs); + +/** + * Set the dtmf received callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The dtmf received callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_dtmf_received(LinphoneCallCbs *cbs, LinphoneCallCbsDtmfReceivedCb cb); + +/** + * Get the encryption changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current encryption changed callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsEncryptionChangedCb linphone_call_cbs_get_encryption_changed(LinphoneCallCbs *cbs); + +/** + * Set the encryption changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The encryption changed callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_encryption_changed(LinphoneCallCbs *cbs, LinphoneCallCbsEncryptionChangedCb cb); + +/** + * Get the info message received callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current info message received callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsInfoMessageReceivedCb linphone_call_cbs_get_info_message_received(LinphoneCallCbs *cbs); + +/** + * Set the info message received callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The info message received callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_info_message_received(LinphoneCallCbs *cbs, LinphoneCallCbsInfoMessageReceivedCb cb); + +/** + * Get the state changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current state changed callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsStateChangedCb linphone_call_cbs_get_state_changed(LinphoneCallCbs *cbs); + +/** + * Set the state changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The state changed callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_state_changed(LinphoneCallCbs *cbs, LinphoneCallCbsStateChangedCb cb); + +/** + * Get the stats updated callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current stats updated callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsStatsUpdatedCb linphone_call_cbs_get_stats_updated(LinphoneCallCbs *cbs); + +/** + * Set the stats updated callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The stats updated callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_stats_updated(LinphoneCallCbs *cbs, LinphoneCallCbsStatsUpdatedCb cb); + +/** + * Get the transfer state changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current transfer state changed callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsTransferStateChangedCb linphone_call_cbs_get_transfer_state_changed(LinphoneCallCbs *cbs); + +/** + * Set the transfer state changed callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The transfer state changed callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_transfer_state_changed(LinphoneCallCbs *cbs, LinphoneCallCbsTransferStateChangedCb cb); + /** * @} */ @@ -715,6 +827,29 @@ LINPHONE_PUBLIC const LinphoneCallStats *linphone_call_get_video_stats(LinphoneC LINPHONE_PUBLIC const LinphoneCallStats *linphone_call_get_text_stats(LinphoneCall *call); +/** + * Add a listener in order to be notified of LinphoneCall events. Once an event is received, registred LinphoneCallCbs are + * invoked sequencially. + * @param[in] call LinphoneCall object to monitor. + * @param[in] cbs A LinphoneCallCbs object holding the callbacks you need. A reference is taken by the LinphoneCall until you invoke linphone_call_remove_callbacks(). + */ +LINPHONE_PUBLIC void linphone_call_add_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs); + +/** + * Remove a listener from a LinphoneCall + * @param[in] call LinphoneCall object + * @param[in] cbs LinphoneCallCbs object to remove. + */ +LINPHONE_PUBLIC void linphone_call_remove_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs); + +/** + * Gets the current LinphoneCallCbs. + * This is meant only to be called from a callback to be able to get the user_data associated with the LinphoneCallCbs that is calling the callback. + * @param[in] call LinphoneCall object + * @return The LinphoneCallCbs that has called the last callback + * @donotwrap + */ +LINPHONE_PUBLIC LinphoneCallCbs *linphone_call_get_current_callbacks(const LinphoneCall *call); /** * @} diff --git a/include/linphone/callbacks.h b/include/linphone/callbacks.h new file mode 100644 index 000000000..07bfffc33 --- /dev/null +++ b/include/linphone/callbacks.h @@ -0,0 +1,645 @@ +/* +callbacks.h +Copyright (C) 2010-2017 Belledonne Communications SARL + +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 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef LINPHONE_CALLBACKS_H_ +#define LINPHONE_CALLBACKS_H_ + + +#include "linphone/types.h" + + +/** + * @addtogroup chatroom + * @{ + */ + +/** + * Call back used to notify message delivery status + * @param msg #LinphoneChatMessage object + * @param status LinphoneChatMessageState + * @param ud application user data + * @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead. + * @donotwrap + */ +typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); + +/** + * Call back used to notify message delivery status + * @param msg #LinphoneChatMessage object + * @param status LinphoneChatMessageState + */ +typedef void (*LinphoneChatMessageCbsMsgStateChangedCb)(LinphoneChatMessage* msg, LinphoneChatMessageState state); + +/** + * File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file. + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent incoming content information + * @param buffer #LinphoneBuffer holding the received data. Empty buffer means end of file. + */ +typedef void (*LinphoneChatMessageCbsFileTransferRecvCb)(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer); + +/** + * File transfer send callback prototype. This function is called by the core when an outgoing file transfer is started. This function is called until size is set to 0. + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent outgoing content + * @param offset the offset in the file from where to get the data to be sent + * @param size the number of bytes expected by the framework + * @return A LinphoneBuffer object holding the data written by the application. An empty buffer means end of file. + */ +typedef LinphoneBuffer * (*LinphoneChatMessageCbsFileTransferSendCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size); + +/** + * File transfer progress indication callback prototype. + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent incoming content information + * @param offset The number of bytes sent/received since the beginning of the transfer. + * @param total The total number of bytes to be sent/received. + */ +typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total); + +/** + * @} +**/ + +/** + * @addtogroup call_control + * @{ +**/ + +/** + * Callback for being notified of received DTMFs. + * @param call LinphoneCall object that received the dtmf + * @param dtmf The ascii code of the dtmf + */ +typedef void (*LinphoneCallCbsDtmfReceivedCb)(LinphoneCall *call, int dtmf); + +/** + * Call encryption changed callback. + * @param call LinphoneCall object whose encryption is changed. + * @param on Whether encryption is activated. + * @param authentication_token An authentication_token, currently set for ZRTP kind of encryption only. + */ +typedef void (*LinphoneCallCbsEncryptionChangedCb)(LinphoneCall *call, bool_t on, const char *authentication_token); + +/** + * Callback for receiving info messages. + * @param call LinphoneCall whose info message belongs to. + * @param msg LinphoneInfoMessage object. + */ +typedef void (*LinphoneCallCbsInfoMessageReceivedCb)(LinphoneCall *call, const LinphoneInfoMessage *msg); + +/** + * Call state notification callback. + * @param call LinphoneCall whose state is changed. + * @param cstate The new state of the call + * @param message An informational message about the state. + */ +typedef void (*LinphoneCallCbsStateChangedCb)(LinphoneCall *call, LinphoneCallState cstate, const char *message); + +/** + * Callback for receiving quality statistics for calls. + * @param call LinphoneCall object whose statistics are notified + * @param stats LinphoneCallStats object + */ +typedef void (*LinphoneCallCbsStatsUpdatedCb)(LinphoneCall *call, const LinphoneCallStats *stats); + +/** + * Callback for notifying progresses of transfers. + * @param call LinphoneCall that was transfered + * @param cstate The state of the call to transfer target at the far end. + */ +typedef void (*LinphoneCallCbsTransferStateChangedCb)(LinphoneCall *call, LinphoneCallState cstate); + +/** + * @} +**/ + +/** + * @addtogroup initializing + * @{ +**/ + +/** + * Callback notifying that a new LinphoneCall (either incoming or outgoing) has been created. + * @param[in] lc LinphoneCore object that has created the call + * @param[in] call The newly created LinphoneCall object + */ +typedef void (*LinphoneCoreCbsCallCreatedCb)(LinphoneCore *lc, LinphoneCall *call); + +/** + * Global state notification callback. + * @param lc the #LinphoneCore. + * @param gstate the global state + * @param message informational message. + */ +typedef void (*LinphoneCoreCbsGlobalStateChangedCb)(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message); + +/** + * Old name of #LinphoneCoreCbsGlobalStateChangedCb. + */ +typedef LinphoneCoreCbsGlobalStateChangedCb LinphoneCoreGlobalStateChangedCb; + +/** + * Call state notification callback. + * @param lc the LinphoneCore + * @param call the call object whose state is changed. + * @param cstate the new state of the call + * @param message a non NULL informational message about the state. + */ +typedef void (*LinphoneCoreCbsCallStateChangedCb)(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message); + +/** + * Old name of #LinphoneCoreCbsCallStateChangedCb. + */ +typedef LinphoneCoreCbsCallStateChangedCb LinphoneCoreCallStateChangedCb; + +/** + * Call encryption changed callback. + * @param lc the LinphoneCore + * @param call the call on which encryption is changed. + * @param on whether encryption is activated. + * @param authentication_token an authentication_token, currently set for ZRTP kind of encryption only. + */ +typedef void (*LinphoneCoreCbsCallEncryptionChangedCb)(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token); + +/** + * Old name of #LinphoneCoreCbsCallEncryptionChangedCb. + */ +typedef LinphoneCoreCbsCallEncryptionChangedCb LinphoneCoreCallEncryptionChangedCb; + +/** + * Registration state notification callback prototype + * @ingroup Proxies + */ +typedef void (*LinphoneCoreCbsRegistrationStateChangedCb)(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message); + +/** + * Old name of #LinphoneCoreCbsRegistrationStateChangedCb. + */ +typedef LinphoneCoreCbsRegistrationStateChangedCb LinphoneCoreRegistrationStateChangedCb; + +/** + * Report status change for a friend previously \link linphone_core_add_friend() added \endlink to #LinphoneCore. + * @param lc #LinphoneCore object . + * @param lf Updated #LinphoneFriend . + */ +typedef void (*LinphoneCoreCbsNotifyPresenceReceivedCb)(LinphoneCore *lc, LinphoneFriend * lf); + +/** + * Old name of #LinphoneCoreCbsNotifyPresenceReceivedCb. + */ +typedef LinphoneCoreCbsNotifyPresenceReceivedCb LinphoneCoreNotifyPresenceReceivedCb; + +/** + * Reports presence model change for a specific URI or phone number of a friend + * @param lc #LinphoneCore object + * @param lf #LinphoneFriend object + * @param uri_or_tel The URI or phone number for which teh presence model has changed + * @param presence_model The new presence model + */ +typedef void (*LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *uri_or_tel, const LinphonePresenceModel *presence_model); + +/** + * Old name of #LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb. + */ +typedef LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb LinphoneCoreNotifyPresenceReceivedForUriOrTelCb; + +/** + * Reports that a new subscription request has been received and wait for a decision. + * Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend + * @param lc #LinphoneCore object + * @param lf #LinphoneFriend corresponding to the subscriber + * @param url of the subscriber + */ +typedef void (*LinphoneCoreCbsNewSubscriptionRequestedCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *url); + +/** + * Old name of #LinphoneCoreCbsNewSubscriptionRequestedCb. + */ +typedef LinphoneCoreCbsNewSubscriptionRequestedCb LinphoneCoreNewSubscriptionRequestedCb; + +/** + * Callback for requesting authentication information to application or user. + * @param lc the LinphoneCore + * @param realm the realm (domain) on which authentication is required. + * @param username the username that needs to be authenticated. + * @param domain the domain on which authentication is required. + * Application shall reply to this callback using linphone_core_add_auth_info(). + */ +typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain); + +/** + * Callback for requesting authentication information to application or user. + * @param lc the LinphoneCore + * @param auth_info a LinphoneAuthInfo pre-filled with username, realm and domain values as much as possible + * @param method the type of authentication requested + * Application shall reply to this callback using linphone_core_add_auth_info(). + */ +typedef void (*LinphoneCoreCbsAuthenticationRequestedCb)(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method); + +/** + * Old name of #LinphoneCoreCbsAuthenticationRequestedCb. + */ +typedef LinphoneCoreCbsAuthenticationRequestedCb LinphoneCoreAuthenticationRequestedCb; + +/** + * Callback to notify a new call-log entry has been added. + * This is done typically when a call terminates. + * @param lc the LinphoneCore + * @param newcl the new call log entry added. + */ +typedef void (*LinphoneCoreCbsCallLogUpdatedCb)(LinphoneCore *lc, LinphoneCallLog *newcl); + +/** + * Old name of #LinphoneCoreCbsCallLogUpdatedCb. + */ +typedef LinphoneCoreCbsCallLogUpdatedCb LinphoneCoreCallLogUpdatedCb; + +/** + * Callback prototype + * @param lc #LinphoneCore object + * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. + * @param from #LinphoneAddress from + * @param message incoming message + * @deprecated use #LinphoneCoreMessageReceivedCb instead. + * @donotwrap + */ +typedef void (*LinphoneCoreTextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); + +/** + * Chat message callback prototype + * @param lc #LinphoneCore object + * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. + * @param LinphoneChatMessage incoming message + */ +typedef void (*LinphoneCoreCbsMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); + +/** + * Old name of #LinphoneCoreCbsMessageReceivedCb. + */ +typedef LinphoneCoreCbsMessageReceivedCb LinphoneCoreMessageReceivedCb; + +/** + * Chat message not decrypted callback prototype + * @param lc #LinphoneCore object + * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. + * @param LinphoneChatMessage incoming message + */ +typedef void (*LinphoneCoreCbsMessageReceivedUnableDecryptCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); + +/** + * File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file. + * @param lc #LinphoneCore object + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent incoming content information + * @param buff pointer to the received data + * @param size number of bytes to be read from buff. 0 means end of file. + */ +typedef void (*LinphoneCoreFileTransferRecvCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size); + +/** + * File transfer send callback prototype. This function is called by the core upon an outgoing file transfer is started. This function is called until size is set to 0. + * @param lc #LinphoneCore object + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent outgoing content + * @param buff pointer to the buffer where data chunk shall be written by the app + * @param size as input value, it represents the number of bytes expected by the framework. As output value, it means the number of bytes wrote by the application in the buffer. 0 means end of file. + * + */ +typedef void (*LinphoneCoreFileTransferSendCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, char* buff, size_t* size); + +/** + * File transfer progress indication callback prototype. + * @param lc #LinphoneCore object + * @param message #LinphoneChatMessage message from which the body is received. + * @param content #LinphoneContent incoming content information + * @param offset The number of bytes sent/received since the beginning of the transfer. + * @param total The total number of bytes to be sent/received. + */ +typedef void (*LinphoneCoreFileTransferProgressIndicationCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total); + +/** + * Is composing notification callback prototype. + * @param[in] lc #LinphoneCore object + * @param[in] room #LinphoneChatRoom involved in the conversation. + */ +typedef void (*LinphoneCoreCbsIsComposingReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room); + +/** + * Old name of #LinphoneCoreCbsIsComposingReceivedCb. + */ +typedef LinphoneCoreCbsIsComposingReceivedCb LinphoneCoreIsComposingReceivedCb; + +/** + * Callback for being notified of DTMFs received. + * @param lc the linphone core + * @param call the call that received the dtmf + * @param dtmf the ascii code of the dtmf + */ +typedef void (*LinphoneCoreCbsDtmfReceivedCb)(LinphoneCore* lc, LinphoneCall *call, int dtmf); + +/** + * Old name of #LinphoneCoreCbsDtmfReceivedCb. + */ +typedef LinphoneCoreCbsDtmfReceivedCb LinphoneCoreDtmfReceivedCb; + +/** Callback prototype */ +typedef void (*LinphoneCoreCbsReferReceivedCb)(LinphoneCore *lc, const char *refer_to); + +/** + * Old name of #LinphoneCoreCbsReferReceivedCb. + */ +typedef LinphoneCoreCbsReferReceivedCb LinphoneCoreReferReceivedCb; + +/** Callback prototype */ +typedef void (*LinphoneCoreCbsBuddyInfoUpdatedCb)(LinphoneCore *lc, LinphoneFriend *lf); + +/** + * Old name of #LinphoneCoreCbsBuddyInfoUpdatedCb. + */ +typedef LinphoneCoreCbsBuddyInfoUpdatedCb LinphoneCoreBuddyInfoUpdatedCb; + +/** + * Callback for notifying progresses of transfers. + * @param lc the LinphoneCore + * @param transfered the call that was transfered + * @param new_call_state the state of the call to transfer target at the far end. + */ +typedef void (*LinphoneCoreCbsTransferStateChangedCb)(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state); + +/** + * Old name of LinphoneCoreCbsTransferStateChangedCb. + */ +typedef LinphoneCoreCbsTransferStateChangedCb LinphoneCoreTransferStateChangedCb; + +/** + * Callback for receiving quality statistics for calls. + * @param lc the LinphoneCore + * @param call the call + * @param stats the call statistics. + */ +typedef void (*LinphoneCoreCbsCallStatsUpdatedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); + +/** + * Old name of #LinphoneCoreCbsCallStatsUpdatedCb. + */ +typedef LinphoneCoreCbsCallStatsUpdatedCb LinphoneCoreCallStatsUpdatedCb; + +/** + * Callback prototype for receiving info messages. + * @param lc the LinphoneCore + * @param call the call whose info message belongs to. + * @param msg the info message. + */ +typedef void (*LinphoneCoreCbsInfoReceivedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg); + +/** + * Old name of #LinphoneCoreCbsInfoReceivedCb. + */ +typedef LinphoneCoreCbsInfoReceivedCb LinphoneCoreInfoReceivedCb; + +/** + * Callback prototype for configuring status changes notification + * @param lc the LinphoneCore + * @param message informational message. + */ +typedef void (*LinphoneCoreCbsConfiguringStatusCb)(LinphoneCore *lc, LinphoneConfiguringState status, const char *message); + +/** + * Old name of #LinphoneCoreCbsConfiguringStatusCb. + */ +typedef LinphoneCoreCbsConfiguringStatusCb LinphoneCoreConfiguringStatusCb; + +/** + * Callback prototype for reporting network change either automatically detected or notified by #linphone_core_set_network_reachable. + * @param lc the LinphoneCore + * @param reachable true if network is reachable. + */ +typedef void (*LinphoneCoreCbsNetworkReachableCb)(LinphoneCore *lc, bool_t reachable); + +/** + * Old name of #LinphoneCoreCbsNetworkReachableCb. + */ +typedef LinphoneCoreCbsNetworkReachableCb LinphoneCoreNetworkReachableCb; + +/** + * Callback prototype for reporting log collection upload state change. + * @param[in] lc LinphoneCore object + * @param[in] state The state of the log collection upload + * @param[in] info Additional information: error message in case of error state, URL of uploaded file in case of success. + */ +typedef void (*LinphoneCoreCbsLogCollectionUploadStateChangedCb)(LinphoneCore *lc, LinphoneCoreLogCollectionUploadState state, const char *info); + +/** + * Old name of #LinphoneCoreCbsLogCollectionUploadStateChangedCb. + */ +typedef LinphoneCoreCbsLogCollectionUploadStateChangedCb LinphoneCoreLogCollectionUploadStateChangedCb; + +/** + * Callback prototype for reporting log collection upload progress indication. + * @param[in] lc LinphoneCore object + */ +typedef void (*LinphoneCoreCbsLogCollectionUploadProgressIndicationCb)(LinphoneCore *lc, size_t offset, size_t total); + +/** + * Old name of #LinphoneCoreCbsLogCollectionUploadProgressIndicationCb. + */ +typedef LinphoneCoreCbsLogCollectionUploadProgressIndicationCb LinphoneCoreLogCollectionUploadProgressIndicationCb; + +/** + * Callback prototype for reporting when a friend list has been added to the core friends list. + * @param[in] lc LinphoneCore object + * @param[in] list LinphoneFriendList object + */ +typedef void (*LinphoneCoreCbsFriendListCreatedCb) (LinphoneCore *lc, LinphoneFriendList *list); + +/** + * Old name of #LinphoneCoreCbsFriendListCreatedCb. + */ +typedef LinphoneCoreCbsFriendListCreatedCb LinphoneCoreFriendListCreatedCb; + +/** + * Callback prototype for reporting when a friend list has been removed from the core friends list. + * @param[in] lc LinphoneCore object + * @param[in] list LinphoneFriendList object + */ +typedef void (*LinphoneCoreCbsFriendListRemovedCb) (LinphoneCore *lc, LinphoneFriendList *list); + +/** + * Old name of #LinphoneCoreCbsFriendListRemovedCb. + */ +typedef LinphoneCoreCbsFriendListRemovedCb LinphoneCoreFriendListRemovedCb; + +/** + * @} +**/ + +/** + * @addtogroup event_api + * @{ +**/ + +/** + * Callback prototype for notifying the application about notification received from the network. +**/ +typedef void (*LinphoneCoreCbsNotifyReceivedCb)(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, const LinphoneContent *body); + +/** + * Old name of #LinphoneCoreCbsNotifyReceivedCb. + */ +typedef LinphoneCoreCbsNotifyReceivedCb LinphoneCoreNotifyReceivedCb; + +/** + * Callback prototype for notifying the application about changes of subscription states, including arrival of new subscriptions. +**/ +typedef void (*LinphoneCoreCbsSubscriptionStateChangedCb)(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state); + +/** + * Old name of #LinphoneCoreCbsSubscriptionStateChangedCb. + */ +typedef LinphoneCoreCbsSubscriptionStateChangedCb LinphoneCoreSubscriptionStateChangedCb; + +/** + * Callback prototype for notifying the application about changes of publish states. +**/ +typedef void (*LinphoneCoreCbsPublishStateChangedCb)(LinphoneCore *lc, LinphoneEvent *lev, LinphonePublishState state); + +/** + * Old name of LinphoneCoreCbsPublishStateChangedCb. + */ +typedef LinphoneCoreCbsPublishStateChangedCb LinphoneCorePublishStateChangedCb; + +/** + * @} +**/ + +/** + * @addtogroup buddy_list + * @{ + */ + +/** + * Callback used to notify a new contact has been created on the CardDAV server and downloaded locally + * @param list The LinphoneFriendList object the new contact is added to + * @param lf The LinphoneFriend object that has been created +**/ +typedef void (*LinphoneFriendListCbsContactCreatedCb)(LinphoneFriendList *list, LinphoneFriend *lf); + +/** + * Callback used to notify a contact has been deleted on the CardDAV server + * @param list The LinphoneFriendList object a contact has been removed from + * @param lf The LinphoneFriend object that has been deleted +**/ +typedef void (*LinphoneFriendListCbsContactDeletedCb)(LinphoneFriendList *list, LinphoneFriend *lf); + +/** + * Callback used to notify a contact has been updated on the CardDAV server + * @param list The LinphoneFriendList object in which a contact has been updated + * @param new_friend The new LinphoneFriend object corresponding to the updated contact + * @param old_friend The old LinphoneFriend object before update +**/ +typedef void (*LinphoneFriendListCbsContactUpdatedCb)(LinphoneFriendList *list, LinphoneFriend *new_friend, LinphoneFriend *old_friend); + +/** + * Callback used to notify the status of the synchronization has changed + * @param list The LinphoneFriendList object for which the status has changed + * @param status The new synchronisation status + * @param msg An additional information on the status update +**/ +typedef void (*LinphoneFriendListCbsSyncStateChangedCb)(LinphoneFriendList *list, LinphoneFriendListSyncStatus status, const char *msg); + +/** + * @} +**/ + +/** + * @addtogroup misc + * @{ + */ + +/** + * Callback to decrypt incoming LinphoneChatMessage + * @param engine ImEncryptionEngine object + * @param room LinphoneChatRoom object + * @param msg LinphoneChatMessage object + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ +typedef int (*LinphoneImEncryptionEngineCbsIncomingMessageCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); + +/** + * Callback to encrypt outgoing LinphoneChatMessage + * @param engine LinphoneImEncryptionEngine object + * @param room LinphoneChatRoom object + * @param msg LinphoneChatMessage object + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ +typedef int (*LinphoneImEncryptionEngineCbsOutgoingMessageCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); + +/** + * Callback to know whether or not the engine will encrypt files before uploading them + * @param engine LinphoneImEncryptionEngine object + * @param room LinphoneChatRoom object + * @return TRUE if files will be encrypted, FALSE otherwise +*/ +typedef bool_t (*LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room); + +/** + * Callback to generate the key used to encrypt the files before uploading them + * Key can be stored in the LinphoneContent object inside the LinphoneChatMessage using linphone_content_set_key + * @param engine LinphoneImEncryptionEngine object + * @param room LinphoneChatRoom object + * @param msg LinphoneChatMessage object +*/ +typedef void (*LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); + +/** + * Callback to decrypt downloading file + * @param engine LinphoneImEncryptionEngine object + * @param msg LinphoneChatMessage object + * @param offset The current offset of the upload + * @param[in] buffer Encrypted data buffer + * @param[in] size Size of the encrypted data buffer and maximum size of the decrypted data buffer + * @param[out] decrypted_buffer Buffer in which to write the decrypted data which maximum size is size + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ +typedef int (*LinphoneImEncryptionEngineCbsDownloadingFileCb)(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t size, uint8_t *decrypted_buffer); + +/** + * Callback to encrypt uploading file + * @param engine LinphoneImEncryptionEngine object + * @param msg LinphoneChatMessage object + * @param offset The current offset of the upload + * @param[in] buffer Encrypted data buffer + * @param[in,out] size Size of the plain data buffer and the size of the encrypted data buffer once encryption is done + * @param[out] encrypted_buffer Buffer in which to write the encrypted data which maxmimum size is size + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ +typedef int (*LinphoneImEncryptionEngineCbsUploadingFileCb)(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer); + +/** + * Callback used to notify the response to an XML-RPC request. + * @param[in] request LinphoneXmlRpcRequest object +**/ +typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *request); + +/** + * @} +**/ + +#endif /* LINPHONE_CALLBACKS_H_ */ diff --git a/include/linphone/chat.h b/include/linphone/chat.h index 7d41e3c59..704339753 100644 --- a/include/linphone/chat.h +++ b/include/linphone/chat.h @@ -33,50 +33,6 @@ extern "C" { * @{ */ -/** - * Call back used to notify message delivery status - * @param msg #LinphoneChatMessage object - * @param status LinphoneChatMessageState - * @param ud application user data - * @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead. - * @donotwrap - */ -typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); - -/** - * Call back used to notify message delivery status - * @param msg #LinphoneChatMessage object - * @param status LinphoneChatMessageState - */ -typedef void (*LinphoneChatMessageCbsMsgStateChangedCb)(LinphoneChatMessage* msg, LinphoneChatMessageState state); - -/** - * File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file. - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent incoming content information - * @param buffer #LinphoneBuffer holding the received data. Empty buffer means end of file. - */ -typedef void (*LinphoneChatMessageCbsFileTransferRecvCb)(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer); - -/** - * File transfer send callback prototype. This function is called by the core when an outgoing file transfer is started. This function is called until size is set to 0. - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent outgoing content - * @param offset the offset in the file from where to get the data to be sent - * @param size the number of bytes expected by the framework - * @return A LinphoneBuffer object holding the data written by the application. An empty buffer means end of file. - */ -typedef LinphoneBuffer * (*LinphoneChatMessageCbsFileTransferSendCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size); - -/** - * File transfer progress indication callback prototype. - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent incoming content information - * @param offset The number of bytes sent/received since the beginning of the transfer. - * @param total The total number of bytes to be sent/received. - */ -typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total); - /** * Destroy a LinphoneChatRoom. * @param cr #LinphoneChatRoom object diff --git a/include/linphone/core.h b/include/linphone/core.h index 253b4e501..a4d39ec7e 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/defs.h" #include "linphone/types.h" +#include "linphone/callbacks.h" #include "linphone/sipsetup.h" #include "linphone/account_creator.h" @@ -129,58 +130,6 @@ LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_ad * @{ **/ -/** - * Global state notification callback. - * @param lc the #LinphoneCore. - * @param gstate the global state - * @param message informational message. - */ -typedef void (*LinphoneCoreCbsGlobalStateChangedCb)(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message); - -/** - * Old name of #LinphoneCoreCbsGlobalStateChangedCb. - */ -typedef LinphoneCoreCbsGlobalStateChangedCb LinphoneCoreGlobalStateChangedCb; - -/** - * Call state notification callback. - * @param lc the LinphoneCore - * @param call the call object whose state is changed. - * @param cstate the new state of the call - * @param message a non NULL informational message about the state. - */ -typedef void (*LinphoneCoreCbsCallStateChangedCb)(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message); - -/** - * Old name of #LinphoneCoreCbsCallStateChangedCb. - */ -typedef LinphoneCoreCbsCallStateChangedCb LinphoneCoreCallStateChangedCb; - -/** - * Call encryption changed callback. - * @param lc the LinphoneCore - * @param call the call on which encryption is changed. - * @param on whether encryption is activated. - * @param authentication_token an authentication_token, currently set for ZRTP kind of encryption only. - */ -typedef void (*LinphoneCoreCbsCallEncryptionChangedCb)(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token); - -/** - * Old name of #LinphoneCoreCbsCallEncryptionChangedCb. - */ -typedef LinphoneCoreCbsCallEncryptionChangedCb LinphoneCoreCallEncryptionChangedCb; - -/** - * Registration state notification callback prototype - * @ingroup Proxies - */ -typedef void (*LinphoneCoreCbsRegistrationStateChangedCb)(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message); - -/** - * Old name of #LinphoneCoreCbsRegistrationStateChangedCb. - */ -typedef LinphoneCoreCbsRegistrationStateChangedCb LinphoneCoreRegistrationStateChangedCb; - /** * Callback prototype * @deprecated @@ -214,298 +163,6 @@ typedef void (*DisplayUrlCb)(LinphoneCore *lc, const char *message, const char * */ typedef void (*LinphoneCoreCbFunc)(LinphoneCore *lc,void * user_data); -/** - * Report status change for a friend previously \link linphone_core_add_friend() added \endlink to #LinphoneCore. - * @param lc #LinphoneCore object . - * @param lf Updated #LinphoneFriend . - */ -typedef void (*LinphoneCoreCbsNotifyPresenceReceivedCb)(LinphoneCore *lc, LinphoneFriend * lf); - -/** - * Old name of #LinphoneCoreCbsNotifyPresenceReceivedCb. - */ -typedef LinphoneCoreCbsNotifyPresenceReceivedCb LinphoneCoreNotifyPresenceReceivedCb; - -/** - * Reports presence model change for a specific URI or phone number of a friend - * @param lc #LinphoneCore object - * @param lf #LinphoneFriend object - * @param uri_or_tel The URI or phone number for which teh presence model has changed - * @param presence_model The new presence model - */ -typedef void (*LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *uri_or_tel, const LinphonePresenceModel *presence_model); - -/** - * Old name of #LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb. - */ -typedef LinphoneCoreCbsNotifyPresenceReceivedForUriOrTelCb LinphoneCoreNotifyPresenceReceivedForUriOrTelCb; - -/** - * Reports that a new subscription request has been received and wait for a decision. - * Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend - * @param lc #LinphoneCore object - * @param lf #LinphoneFriend corresponding to the subscriber - * @param url of the subscriber - */ -typedef void (*LinphoneCoreCbsNewSubscriptionRequestedCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *url); - -/** - * Old name of #LinphoneCoreCbsNewSubscriptionRequestedCb. - */ -typedef LinphoneCoreCbsNewSubscriptionRequestedCb LinphoneCoreNewSubscriptionRequestedCb; - -/** - * Callback for requesting authentication information to application or user. - * @param lc the LinphoneCore - * @param realm the realm (domain) on which authentication is required. - * @param username the username that needs to be authenticated. - * @param domain the domain on which authentication is required. - * Application shall reply to this callback using linphone_core_add_auth_info(). - */ -typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain); - -/** - * Callback for requesting authentication information to application or user. - * @param lc the LinphoneCore - * @param auth_info a LinphoneAuthInfo pre-filled with username, realm and domain values as much as possible - * @param method the type of authentication requested - * Application shall reply to this callback using linphone_core_add_auth_info(). - */ -typedef void (*LinphoneCoreCbsAuthenticationRequestedCb)(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method); - -/** - * Old name of #LinphoneCoreCbsAuthenticationRequestedCb. - */ -typedef LinphoneCoreCbsAuthenticationRequestedCb LinphoneCoreAuthenticationRequestedCb; - -/** - * Callback to notify a new call-log entry has been added. - * This is done typically when a call terminates. - * @param lc the LinphoneCore - * @param newcl the new call log entry added. - */ -typedef void (*LinphoneCoreCbsCallLogUpdatedCb)(LinphoneCore *lc, LinphoneCallLog *newcl); - -/** - * Old name of #LinphoneCoreCbsCallLogUpdatedCb. - */ -typedef LinphoneCoreCbsCallLogUpdatedCb LinphoneCoreCallLogUpdatedCb; - -/** - * Callback prototype - * @param lc #LinphoneCore object - * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. - * @param from #LinphoneAddress from - * @param message incoming message - * @deprecated use #LinphoneCoreMessageReceivedCb instead. - * @donotwrap - */ -typedef void (*LinphoneCoreTextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); - -/** - * Chat message callback prototype - * @param lc #LinphoneCore object - * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. - * @param LinphoneChatMessage incoming message - */ -typedef void (*LinphoneCoreCbsMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); - -/** - * Old name of #LinphoneCoreCbsMessageReceivedCb. - */ -typedef LinphoneCoreCbsMessageReceivedCb LinphoneCoreMessageReceivedCb; - -/** - * Chat message not decrypted callback prototype - * @param lc #LinphoneCore object - * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. - * @param LinphoneChatMessage incoming message - */ -typedef void (*LinphoneCoreCbsMessageReceivedUnableDecryptCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); - -/** - * File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file. - * @param lc #LinphoneCore object - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent incoming content information - * @param buff pointer to the received data - * @param size number of bytes to be read from buff. 0 means end of file. - */ -typedef void (*LinphoneCoreFileTransferRecvCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size); - -/** - * File transfer send callback prototype. This function is called by the core upon an outgoing file transfer is started. This function is called until size is set to 0. - * @param lc #LinphoneCore object - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent outgoing content - * @param buff pointer to the buffer where data chunk shall be written by the app - * @param size as input value, it represents the number of bytes expected by the framework. As output value, it means the number of bytes wrote by the application in the buffer. 0 means end of file. - * - */ -typedef void (*LinphoneCoreFileTransferSendCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, char* buff, size_t* size); - -/** - * File transfer progress indication callback prototype. - * @param lc #LinphoneCore object - * @param message #LinphoneChatMessage message from which the body is received. - * @param content #LinphoneContent incoming content information - * @param offset The number of bytes sent/received since the beginning of the transfer. - * @param total The total number of bytes to be sent/received. - */ -typedef void (*LinphoneCoreFileTransferProgressIndicationCb)(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total); - -/** - * Is composing notification callback prototype. - * @param[in] lc #LinphoneCore object - * @param[in] room #LinphoneChatRoom involved in the conversation. - */ -typedef void (*LinphoneCoreCbsIsComposingReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room); - -/** - * Old name of #LinphoneCoreCbsIsComposingReceivedCb. - */ -typedef LinphoneCoreCbsIsComposingReceivedCb LinphoneCoreIsComposingReceivedCb; - -/** - * Callback for being notified of DTMFs received. - * @param lc the linphone core - * @param call the call that received the dtmf - * @param dtmf the ascii code of the dtmf - */ -typedef void (*LinphoneCoreCbsDtmfReceivedCb)(LinphoneCore* lc, LinphoneCall *call, int dtmf); - -/** - * Old name of #LinphoneCoreCbsDtmfReceivedCb. - */ -typedef LinphoneCoreCbsDtmfReceivedCb LinphoneCoreDtmfReceivedCb; - -/** Callback prototype */ -typedef void (*LinphoneCoreCbsReferReceivedCb)(LinphoneCore *lc, const char *refer_to); - -/** - * Old name of #LinphoneCoreCbsReferReceivedCb. - */ -typedef LinphoneCoreCbsReferReceivedCb LinphoneCoreReferReceivedCb; - -/** Callback prototype */ -typedef void (*LinphoneCoreCbsBuddyInfoUpdatedCb)(LinphoneCore *lc, LinphoneFriend *lf); - -/** - * Old name of #LinphoneCoreCbsBuddyInfoUpdatedCb. - */ -typedef LinphoneCoreCbsBuddyInfoUpdatedCb LinphoneCoreBuddyInfoUpdatedCb; - -/** - * Callback for notifying progresses of transfers. - * @param lc the LinphoneCore - * @param transfered the call that was transfered - * @param new_call_state the state of the call to transfer target at the far end. - */ -typedef void (*LinphoneCoreCbsTransferStateChangedCb)(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state); - -/** - * Old name of LinphoneCoreCbsTransferStateChangedCb. - */ -typedef LinphoneCoreCbsTransferStateChangedCb LinphoneCoreTransferStateChangedCb; - -/** - * Callback for receiving quality statistics for calls. - * @param lc the LinphoneCore - * @param call the call - * @param stats the call statistics. - */ -typedef void (*LinphoneCoreCbsCallStatsUpdatedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); - -/** - * Old name of #LinphoneCoreCbsCallStatsUpdatedCb. - */ -typedef LinphoneCoreCbsCallStatsUpdatedCb LinphoneCoreCallStatsUpdatedCb; - -/** - * Callback prototype for receiving info messages. - * @param lc the LinphoneCore - * @param call the call whose info message belongs to. - * @param msg the info message. - */ -typedef void (*LinphoneCoreCbsInfoReceivedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg); - -/** - * Old name of #LinphoneCoreCbsInfoReceivedCb. - */ -typedef LinphoneCoreCbsInfoReceivedCb LinphoneCoreInfoReceivedCb; - -/** - * Callback prototype for configuring status changes notification - * @param lc the LinphoneCore - * @param message informational message. - */ -typedef void (*LinphoneCoreCbsConfiguringStatusCb)(LinphoneCore *lc, LinphoneConfiguringState status, const char *message); - -/** - * Old name of #LinphoneCoreCbsConfiguringStatusCb. - */ -typedef LinphoneCoreCbsConfiguringStatusCb LinphoneCoreConfiguringStatusCb; - -/** - * Callback prototype for reporting network change either automatically detected or notified by #linphone_core_set_network_reachable. - * @param lc the LinphoneCore - * @param reachable true if network is reachable. - */ -typedef void (*LinphoneCoreCbsNetworkReachableCb)(LinphoneCore *lc, bool_t reachable); - -/** - * Old name of #LinphoneCoreCbsNetworkReachableCb. - */ -typedef LinphoneCoreCbsNetworkReachableCb LinphoneCoreNetworkReachableCb; - -/** - * Callback prototype for reporting log collection upload state change. - * @param[in] lc LinphoneCore object - * @param[in] state The state of the log collection upload - * @param[in] info Additional information: error message in case of error state, URL of uploaded file in case of success. - */ -typedef void (*LinphoneCoreCbsLogCollectionUploadStateChangedCb)(LinphoneCore *lc, LinphoneCoreLogCollectionUploadState state, const char *info); - -/** - * Old name of #LinphoneCoreCbsLogCollectionUploadStateChangedCb. - */ -typedef LinphoneCoreCbsLogCollectionUploadStateChangedCb LinphoneCoreLogCollectionUploadStateChangedCb; - -/** - * Callback prototype for reporting log collection upload progress indication. - * @param[in] lc LinphoneCore object - */ -typedef void (*LinphoneCoreCbsLogCollectionUploadProgressIndicationCb)(LinphoneCore *lc, size_t offset, size_t total); - -/** - * Old name of #LinphoneCoreCbsLogCollectionUploadProgressIndicationCb. - */ -typedef LinphoneCoreCbsLogCollectionUploadProgressIndicationCb LinphoneCoreLogCollectionUploadProgressIndicationCb; - -/** - * Callback prototype for reporting when a friend list has been added to the core friends list. - * @param[in] lc LinphoneCore object - * @param[in] list LinphoneFriendList object - */ -typedef void (*LinphoneCoreCbsFriendListCreatedCb) (LinphoneCore *lc, LinphoneFriendList *list); - -/** - * Old name of #LinphoneCoreCbsFriendListCreatedCb. - */ -typedef LinphoneCoreCbsFriendListCreatedCb LinphoneCoreFriendListCreatedCb; - -/** - * Callback prototype for reporting when a friend list has been removed from the core friends list. - * @param[in] lc LinphoneCore object - * @param[in] list LinphoneFriendList object - */ -typedef void (*LinphoneCoreCbsFriendListRemovedCb) (LinphoneCore *lc, LinphoneFriendList *list); - -/** - * Old name of #LinphoneCoreCbsFriendListRemovedCb. - */ -typedef LinphoneCoreCbsFriendListRemovedCb LinphoneCoreFriendListRemovedCb; - /** * This structure holds all callbacks that the application should implement. * None is mandatory. @@ -548,6 +205,7 @@ typedef struct _LinphoneCoreVTable{ LinphoneCoreLogCollectionUploadProgressIndicationCb log_collection_upload_progress_indication; /**< Callback to indicate log collection upload progress */ LinphoneCoreFriendListCreatedCb friend_list_created; LinphoneCoreFriendListRemovedCb friend_list_removed; + LinphoneCoreCbsCallCreatedCb call_created; void *user_data; /** 0 for error -*/ -typedef int (*LinphoneImEncryptionEngineCbsIncomingMessageCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); - -/** - * Callback to encrypt outgoing LinphoneChatMessage - * @param engine LinphoneImEncryptionEngine object - * @param room LinphoneChatRoom object - * @param msg LinphoneChatMessage object - * @return -1 if nothing to be done, 0 on success or an integer > 0 for error -*/ -typedef int (*LinphoneImEncryptionEngineCbsOutgoingMessageCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); - -/** - * Callback to know whether or not the engine will encrypt files before uploading them - * @param engine LinphoneImEncryptionEngine object - * @param room LinphoneChatRoom object - * @return TRUE if files will be encrypted, FALSE otherwise -*/ -typedef bool_t (*LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room); - -/** - * Callback to generate the key used to encrypt the files before uploading them - * Key can be stored in the LinphoneContent object inside the LinphoneChatMessage using linphone_content_set_key - * @param engine LinphoneImEncryptionEngine object - * @param room LinphoneChatRoom object - * @param msg LinphoneChatMessage object -*/ -typedef void (*LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb)(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg); - -/** - * Callback to decrypt downloading file - * @param engine LinphoneImEncryptionEngine object - * @param msg LinphoneChatMessage object - * @param offset The current offset of the upload - * @param[in] buffer Encrypted data buffer - * @param[in] size Size of the encrypted data buffer and maximum size of the decrypted data buffer - * @param[out] decrypted_buffer Buffer in which to write the decrypted data which maximum size is size - * @return -1 if nothing to be done, 0 on success or an integer > 0 for error -*/ -typedef int (*LinphoneImEncryptionEngineCbsDownloadingFileCb)(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t size, uint8_t *decrypted_buffer); - -/** - * Callback to encrypt uploading file - * @param engine LinphoneImEncryptionEngine object - * @param msg LinphoneChatMessage object - * @param offset The current offset of the upload - * @param[in] buffer Encrypted data buffer - * @param[in,out] size Size of the plain data buffer and the size of the encrypted data buffer once encryption is done - * @param[out] encrypted_buffer Buffer in which to write the encrypted data which maxmimum size is size - * @return -1 if nothing to be done, 0 on success or an integer > 0 for error -*/ -typedef int (*LinphoneImEncryptionEngineCbsUploadingFileCb)(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer); - /** * Acquire a reference to the LinphoneImEncryptionEngineCbs. * @param[in] cbs LinphoneImEncryptionEngineCbs object. diff --git a/include/linphone/types.h b/include/linphone/types.h index 18f73c39f..bb9e25ae3 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -242,6 +242,16 @@ typedef struct _LinphoneBuffer LinphoneBuffer; **/ typedef struct _LinphoneCall LinphoneCall; +/** + * That class holds all the callbacks which are called by LinphoneCall objects. + * + * Use linphone_factory_create_call_cbs() to create an instance. Then, call the + * callback setters on the events you need to monitor and pass the object to + * a LinphoneCall instance through linphone_call_add_callbacks(). + * @ingroup call_control + */ +typedef struct _LinphoneCallCbs LinphoneCallCbs; + /** * Enum representing the direction of a call. * @ingroup call_logs @@ -446,7 +456,7 @@ typedef struct _LinphoneCore LinphoneCore; * * Use linphone_factory_create_core_cbs() to create an instance. Then, call the * callback setters on the events you need to monitor and pass the object to - * a #LinphoneCore instance through linphone_core_add_listener(). + * a #LinphoneCore instance through linphone_core_add_callbacks(). * * That class is inherited from belle_sip_object_t. * @ingroup initializing diff --git a/include/linphone/xmlrpc.h b/include/linphone/xmlrpc.h index 706105a3e..f2914cf82 100644 --- a/include/linphone/xmlrpc.h +++ b/include/linphone/xmlrpc.h @@ -34,13 +34,6 @@ extern "C" { * @{ */ -/** - * Callback used to notify the response to an XML-RPC request. - * @param[in] request LinphoneXmlRpcRequest object -**/ -typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *request); - - /** * Create a new LinphoneXmlRpcRequest object. * @param[in] return_type The expected XML-RPC response type.