Commit 251ba960 authored by jehan's avatar jehan

add new functions linphone_core_add_listener to enable multiple vtable to be registered

parent 7a68db79
This diff is collapsed.
...@@ -77,9 +77,7 @@ static void linphone_chat_message_file_transfer_on_progress(belle_sip_body_handl ...@@ -77,9 +77,7 @@ static void linphone_chat_message_file_transfer_on_progress(belle_sip_body_handl
LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data; LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data;
LinphoneCore *lc = chatMsg->chat_room->lc; LinphoneCore *lc = chatMsg->chat_room->lc;
/* call back given by application level */ /* call back given by application level */
if (lc->vtable.file_transfer_progress_indication != NULL) { linphone_core_notify_file_transfer_progress_indication(lc, chatMsg, chatMsg->file_transfer_information, (size_t)(((double)offset/(double)total)*100.0));
lc->vtable.file_transfer_progress_indication(lc, chatMsg, chatMsg->file_transfer_information, (size_t)(((double)offset/(double)total)*100.0));
}
return; return;
} }
...@@ -102,7 +100,7 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_ ...@@ -102,7 +100,7 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_
/* if we've not reach the end of file yet, ask for more data*/ /* if we've not reach the end of file yet, ask for more data*/
if (offset<chatMsg->file_transfer_information->size){ if (offset<chatMsg->file_transfer_information->size){
/* get data from call back */ /* get data from call back */
lc->vtable.file_transfer_send(lc, chatMsg, chatMsg->file_transfer_information, buf, size); linphone_core_notify_file_transfer_send(lc, chatMsg, chatMsg->file_transfer_information, buf, size);
} }
return BELLE_SIP_CONTINUE; return BELLE_SIP_CONTINUE;
...@@ -510,12 +508,10 @@ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg) { ...@@ -510,12 +508,10 @@ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg) {
void linphone_chat_room_message_received(LinphoneChatRoom *cr, LinphoneCore *lc, LinphoneChatMessage *msg){ void linphone_chat_room_message_received(LinphoneChatRoom *cr, LinphoneCore *lc, LinphoneChatMessage *msg){
if (msg->message) if (msg->message)
//legacy API //legacy API
if (lc->vtable.text_received!=NULL) lc->vtable.text_received(lc, cr, msg->from, msg->message); linphone_core_notify_text_message_received(lc, cr, msg->from, msg->message);
if (lc->vtable.message_received!=NULL) lc->vtable.message_received(lc, cr,msg); linphone_core_notify_message_received(lc, cr,msg);
if (cr->lc->vtable.is_composing_received != NULL) { cr->remote_is_composing = LinphoneIsComposingIdle;
cr->remote_is_composing = LinphoneIsComposingIdle; linphone_core_notify_is_composing_received(cr->lc, cr);
cr->lc->vtable.is_composing_received(cr->lc, cr);
}
} }
void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg){ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg){
...@@ -629,8 +625,7 @@ static int linphone_chat_room_remote_refresh_composing_expired(void *data, unsig ...@@ -629,8 +625,7 @@ static int linphone_chat_room_remote_refresh_composing_expired(void *data, unsig
belle_sip_object_unref(cr->remote_composing_refresh_timer); belle_sip_object_unref(cr->remote_composing_refresh_timer);
cr->remote_composing_refresh_timer = NULL; cr->remote_composing_refresh_timer = NULL;
cr->remote_is_composing = LinphoneIsComposingIdle; cr->remote_is_composing = LinphoneIsComposingIdle;
if (cr->lc->vtable.is_composing_received != NULL) linphone_core_notify_is_composing_received(cr->lc, cr);
cr->lc->vtable.is_composing_received(cr->lc, cr);
return BELLE_SIP_STOP; return BELLE_SIP_STOP;
} }
...@@ -675,8 +670,7 @@ static void process_im_is_composing_notification(LinphoneChatRoom *cr, xmlparsin ...@@ -675,8 +670,7 @@ static void process_im_is_composing_notification(LinphoneChatRoom *cr, xmlparsin
} }
cr->remote_is_composing = state; cr->remote_is_composing = state;
if (cr->lc->vtable.is_composing_received != NULL) linphone_core_notify_is_composing_received(cr->lc, cr);
cr->lc->vtable.is_composing_received(cr->lc, cr);
} }
} }
...@@ -1034,9 +1028,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t ...@@ -1034,9 +1028,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t
return; return;
} }
/* call back given by application level */ /* call back given by application level */
if (lc->vtable.file_transfer_recv != NULL) { linphone_core_notify_file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, (char *)buffer, size);
lc->vtable.file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, (char *)buffer, size);
}
return; return;
} }
...@@ -1101,9 +1093,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle ...@@ -1101,9 +1093,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data; LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data;
LinphoneCore *lc = chatMsg->chat_room->lc; LinphoneCore *lc = chatMsg->chat_room->lc;
/* file downloaded succesfully, call again the callback with size at zero */ /* file downloaded succesfully, call again the callback with size at zero */
if (lc->vtable.file_transfer_recv != NULL) { linphone_core_notify_file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, NULL, 0);
lc->vtable.file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, NULL, 0);
}
} }
} }
} }
......
...@@ -89,13 +89,10 @@ LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp ...@@ -89,13 +89,10 @@ LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp
} }
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){ void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){
LinphoneCore *lc=lev->lc;
if (lev->subscription_state!=state){ if (lev->subscription_state!=state){
ms_message("LinphoneEvent [%p] moving to subscription state %s",lev,linphone_subscription_state_to_string(state)); ms_message("LinphoneEvent [%p] moving to subscription state %s",lev,linphone_subscription_state_to_string(state));
lev->subscription_state=state; lev->subscription_state=state;
if (lc->vtable.subscription_state_changed){ linphone_core_notify_subscription_state_changed(lev->lc,lev,state);
lc->vtable.subscription_state_changed(lev->lc,lev,state);
}
if (state==LinphoneSubscriptionTerminated){ if (state==LinphoneSubscriptionTerminated){
linphone_event_unref(lev); linphone_event_unref(lev);
} }
...@@ -103,13 +100,10 @@ void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState stat ...@@ -103,13 +100,10 @@ void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState stat
} }
void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state){ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state){
LinphoneCore *lc=lev->lc;
if (lev->publish_state!=state){ if (lev->publish_state!=state){
ms_message("LinphoneEvent [%p] moving to publish state %s",lev,linphone_publish_state_to_string(state)); ms_message("LinphoneEvent [%p] moving to publish state %s",lev,linphone_publish_state_to_string(state));
lev->publish_state=state; lev->publish_state=state;
if (lc->vtable.publish_state_changed){ linphone_core_notify_publish_state_changed(lev->lc,lev,state);
lc->vtable.publish_state_changed(lev->lc,lev,state);
}
switch(state){ switch(state){
case LinphonePublishCleared: case LinphonePublishCleared:
linphone_event_unref(lev); linphone_event_unref(lev);
......
...@@ -253,8 +253,7 @@ static void linphone_friend_invalidate_subscription(LinphoneFriend *lf){ ...@@ -253,8 +253,7 @@ static void linphone_friend_invalidate_subscription(LinphoneFriend *lf){
linphone_presence_model_unref(lf->presence); linphone_presence_model_unref(lf->presence);
} }
lf->presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,"unknown activity"); lf->presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,"unknown activity");
if (lc->vtable.notify_presence_received) linphone_core_notify_notify_presence_received(lc,lf);
lc->vtable.notify_presence_received(lc,lf);
} }
lf->initial_subscribes_sent=FALSE; lf->initial_subscribes_sent=FALSE;
} }
......
...@@ -192,8 +192,7 @@ void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, const SalBody ...@@ -192,8 +192,7 @@ void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, const SalBody
LinphoneInfoMessage *info=ms_new0(LinphoneInfoMessage,1); LinphoneInfoMessage *info=ms_new0(LinphoneInfoMessage,1);
info->headers=sal_custom_header_clone(sal_op_get_recv_custom_header(op)); info->headers=sal_custom_header_clone(sal_op_get_recv_custom_header(op));
if (body) linphone_content_copy_from_sal_body(&info->content,body); if (body) linphone_content_copy_from_sal_body(&info->content,body);
if (lc->vtable.info_received) linphone_core_notify_info_received(lc,call,info);
lc->vtable.info_received(lc,call,info);
linphone_info_message_destroy(info); linphone_info_message_destroy(info);
} }
} }
...@@ -153,17 +153,14 @@ static uint16_t linphone_call_get_avpf_rr_interval(const LinphoneCall *call) { ...@@ -153,17 +153,14 @@ static uint16_t linphone_call_get_avpf_rr_interval(const LinphoneCall *call) {
} }
static void propagate_encryption_changed(LinphoneCall *call){ static void propagate_encryption_changed(LinphoneCall *call){
LinphoneCore *lc=call->core;
if (!linphone_call_all_streams_encrypted(call)) { if (!linphone_call_all_streams_encrypted(call)) {
ms_message("Some streams are not encrypted"); ms_message("Some streams are not encrypted");
call->current_params->media_encryption=LinphoneMediaEncryptionNone; call->current_params->media_encryption=LinphoneMediaEncryptionNone;
if (lc->vtable.call_encryption_changed) linphone_core_notify_call_encryption_changed(call->core, call, FALSE, call->auth_token);
lc->vtable.call_encryption_changed(call->core, call, FALSE, call->auth_token);
} else { } else {
ms_message("All streams are encrypted"); ms_message("All streams are encrypted");
call->current_params->media_encryption=LinphoneMediaEncryptionZRTP; call->current_params->media_encryption=LinphoneMediaEncryptionZRTP;
if (lc->vtable.call_encryption_changed) linphone_core_notify_call_encryption_changed(call->core, call, TRUE, call->auth_token);
lc->vtable.call_encryption_changed(call->core, call, TRUE, call->auth_token);
} }
} }
...@@ -173,9 +170,9 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr ...@@ -173,9 +170,9 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr
call = (LinphoneCall *)data; call = (LinphoneCall *)data;
if (encrypted && call->core->vtable.display_status != NULL) { if (encrypted) {
snprintf(status,sizeof(status)-1,_("Authentication token is %s"),call->auth_token); snprintf(status,sizeof(status)-1,_("Authentication token is %s"),call->auth_token);
call->core->vtable.display_status(call->core, status); linphone_core_notify_display_status(call->core, status);
} }
propagate_encryption_changed(call); propagate_encryption_changed(call);
...@@ -974,8 +971,8 @@ void linphone_call_set_state_base(LinphoneCall *call, LinphoneCallState cstate, ...@@ -974,8 +971,8 @@ void linphone_call_set_state_base(LinphoneCall *call, LinphoneCallState cstate,
call->media_start_time=time(NULL); call->media_start_time=time(NULL);
} }
if (lc->vtable.call_state_changed && !silently) if (!silently)
lc->vtable.call_state_changed(lc,call,cstate,message); linphone_core_notify_call_state_changed(lc,call,cstate,message);
linphone_reporting_call_state_updated(call); linphone_reporting_call_state_updated(call);
...@@ -1640,8 +1637,7 @@ static void linphone_core_dtmf_received(LinphoneCore *lc, int dtmf){ ...@@ -1640,8 +1637,7 @@ static void linphone_core_dtmf_received(LinphoneCore *lc, int dtmf){
ms_warning("Bad dtmf value %i",dtmf); ms_warning("Bad dtmf value %i",dtmf);
return; return;
} }
if (lc->vtable.dtmf_received != NULL) linphone_core_notify_dtmf_received(lc, linphone_core_get_current_call(lc), dtmf_tab[dtmf]);
lc->vtable.dtmf_received(lc, linphone_core_get_current_call(lc), dtmf_tab[dtmf]);
} }
static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){ static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){
...@@ -1728,7 +1724,7 @@ static void post_configure_audio_streams(LinphoneCall*call){ ...@@ -1728,7 +1724,7 @@ static void post_configure_audio_streams(LinphoneCall*call){
AudioStream *st=call->audiostream; AudioStream *st=call->audiostream;
LinphoneCore *lc=call->core; LinphoneCore *lc=call->core;
_post_configure_audio_stream(st,lc,call->audio_muted); _post_configure_audio_stream(st,lc,call->audio_muted);
if (lc->vtable.dtmf_received!=NULL){ if (linphone_core_dtmf_received_has_listener(lc)){
audio_stream_play_received_dtmfs(call->audiostream,FALSE); audio_stream_play_received_dtmfs(call->audiostream,FALSE);
} }
if (call->record_active) if (call->record_active)
...@@ -2713,8 +2709,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){ ...@@ -2713,8 +2709,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
if (from) ms_free(from); if (from) ms_free(from);
ms_message("On call [%p]: %s",call,temp); ms_message("On call [%p]: %s",call,temp);
if (lc->vtable.display_warning!=NULL) linphone_core_notify_display_warning(lc,temp);
lc->vtable.display_warning(lc,temp);
linphone_core_terminate_call(lc,call); linphone_core_terminate_call(lc,call);
linphone_core_play_named_tone(lc,LinphoneToneCallLost); linphone_core_play_named_tone(lc,LinphoneToneCallLost);
} }
...@@ -2836,8 +2831,7 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){ ...@@ -2836,8 +2831,7 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){
LinphoneCore *lc=call->core; LinphoneCore *lc=call->core;
if (stats->updated){ if (stats->updated){
linphone_reporting_on_rtcp_update(call, stream_index); linphone_reporting_on_rtcp_update(call, stream_index);
if (lc->vtable.call_stats_updated) linphone_core_notify_call_stats_updated(lc, call, stats);
lc->vtable.call_stats_updated(lc, call, stats);
stats->updated = 0; stats->updated = 0;
} }
} }
...@@ -2932,8 +2926,7 @@ void linphone_call_log_completed(LinphoneCall *call){ ...@@ -2932,8 +2926,7 @@ void linphone_call_log_completed(LinphoneCall *call){
info=ortp_strdup_printf(ngettext("You have missed %i call.", info=ortp_strdup_printf(ngettext("You have missed %i call.",
"You have missed %i calls.", lc->missed_calls), "You have missed %i calls.", lc->missed_calls),
lc->missed_calls); lc->missed_calls);
if (lc->vtable.display_status!=NULL) linphone_core_notify_display_status(lc,info);
lc->vtable.display_status(lc,info);
ms_free(info); ms_free(info);
} }
lc->call_logs=ms_list_prepend(lc->call_logs,linphone_call_log_ref(call->log)); lc->call_logs=ms_list_prepend(lc->call_logs,linphone_call_log_ref(call->log));
...@@ -2947,9 +2940,7 @@ void linphone_call_log_completed(LinphoneCall *call){ ...@@ -2947,9 +2940,7 @@ void linphone_call_log_completed(LinphoneCall *call){
linphone_call_log_unref((LinphoneCallLog*)elem->data); linphone_call_log_unref((LinphoneCallLog*)elem->data);
lc->call_logs=ms_list_remove_link(lc->call_logs,elem); lc->call_logs=ms_list_remove_link(lc->call_logs,elem);
} }
if (lc->vtable.call_log_updated!=NULL){ linphone_core_notify_call_log_updated(lc,call->log);
lc->vtable.call_log_updated(lc,call->log);
}
call_logs_write_to_config_file(lc); call_logs_write_to_config_file(lc);
} }
...@@ -2968,8 +2959,7 @@ void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState stat ...@@ -2968,8 +2959,7 @@ void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState stat
,linphone_call_state_to_string(call->transfer_state) ,linphone_call_state_to_string(call->transfer_state)
,linphone_call_state_to_string(state)); ,linphone_call_state_to_string(state));
call->transfer_state = state; call->transfer_state = state;
if (lc->vtable.transfer_state_changed) linphone_core_notify_transfer_state_changed(lc, call, state);
lc->vtable.transfer_state_changed(lc, call, state);
} }
} }
......
This diff is collapsed.
...@@ -1611,6 +1611,13 @@ typedef enum _LinphoneConfiguringState { ...@@ -1611,6 +1611,13 @@ typedef enum _LinphoneConfiguringState {
*/ */
typedef void (*LinphoneCoreConfiguringStatusCb)(LinphoneCore *lc, LinphoneConfiguringState status, const char *message); typedef void (*LinphoneCoreConfiguringStatusCb)(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
/**
* 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 (*LinphoneCoreNetworkReachableCb)(LinphoneCore *lc, bool_t reachable);
/** /**
* This structure holds all callbacks that the application should implement. * This structure holds all callbacks that the application should implement.
* None is mandatory. * None is mandatory.
...@@ -1645,8 +1652,21 @@ typedef struct _LinphoneCoreVTable{ ...@@ -1645,8 +1652,21 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreFileTransferRecvCb file_transfer_recv; /** Callback to store file received attached to a #LinphoneChatMessage */ LinphoneCoreFileTransferRecvCb file_transfer_recv; /** Callback to store file received attached to a #LinphoneChatMessage */
LinphoneCoreFileTransferSendCb file_transfer_send; /** Callback to collect file chunk to be sent for a #LinphoneChatMessage */ LinphoneCoreFileTransferSendCb file_transfer_send; /** Callback to collect file chunk to be sent for a #LinphoneChatMessage */
LinphoneCoreFileTransferProgressIndicationCb file_transfer_progress_indication; /**Callback to indicate file transfer progress*/ LinphoneCoreFileTransferProgressIndicationCb file_transfer_progress_indication; /**Callback to indicate file transfer progress*/
LinphoneCoreNetworkReachableCb network_reachable; /** Call back to report IP network status (I.E up/down)*/
} LinphoneCoreVTable; } LinphoneCoreVTable;
/**
* Instantiate a vtable with all argument set to NULL
* @returns newly allocated vtable
*/
LINPHONE_PUBLIC LinphoneCoreVTable *linphone_vtable_new();
/**
* destroy a vtable.
* @param vtable to be destroyed
*/
LINPHONE_PUBLIC void linphone_vtable_destroy(LinphoneCoreVTable* table);
/** /**
* @} * @}
**/ **/
...@@ -1751,24 +1771,26 @@ LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVT ...@@ -1751,24 +1771,26 @@ LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVT
/* function to be periodically called in a main loop */ /* function to be periodically called in a main loop */
/* For ICE to work properly it should be called every 20ms */ /* For ICE to work properly it should be called every 20ms */
LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc);
#if 0 /*not implemented yet*/
/** /**
* @ingroup initializing * @ingroup initializing
* Provide Linphone Core with an unique identifier. This be later used to identified contact address coming from this device. * add a listener to be notified of linphone core events. Once events are received, registered vtable are invoked in order.
* Value is not saved. * @param vtable a LinphoneCoreVTable structure holding your application callbacks. Object is owned by linphone core until linphone_core_remove_listener.
* @param lc object * @param lc object
* @param string identifying the device, can be EMEI or UDID * @param string identifying the device, can be EMEI or UDID
* *
*/ */
void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id); LINPHONE_PUBLIC void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable);
/** /**
* @ingroup initializing * @ingroup initializing
* get Linphone unique identifier * remove a listener registred by linphone_core_add_listener.
* @param vtable a LinphoneCoreVTable structure holding your application callbacks
* @param lc object
* @param string identifying the device, can be EMEI or UDID
* *
*/ */
const char* linphone_core_get_device_identifier(const LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable);
#endif
/*sets the user-agent string in sip messages, ideally called just after linphone_core_new() or linphone_core_init() */ /*sets the user-agent string in sip messages, ideally called just after linphone_core_new() or linphone_core_init() */
LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version); LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version);
......
...@@ -421,8 +421,7 @@ int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){ ...@@ -421,8 +421,7 @@ int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){
ms_error("Could not obtain stun server addrinfo."); ms_error("Could not obtain stun server addrinfo.");
return -1; return -1;
} }
if (lc->vtable.display_status!=NULL) linphone_core_notify_display_status(lc,_("Stun lookup in progress..."));
lc->vtable.display_status(lc,_("Stun lookup in progress..."));
/*create the two audio and video RTP sockets, and send STUN message to our stun server */ /*create the two audio and video RTP sockets, and send STUN message to our stun server */
sock1=create_socket(call->media_ports[0].rtp_port); sock1=create_socket(call->media_ports[0].rtp_port);
...@@ -603,8 +602,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) ...@@ -603,8 +602,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
ms_warning("Fail to resolve STUN server for ICE gathering."); ms_warning("Fail to resolve STUN server for ICE gathering.");
return -1; return -1;
} }
if (lc->vtable.display_status != NULL) linphone_core_notify_display_status(lc, _("ICE local candidates gathering in progress..."));
lc->vtable.display_status(lc, _("ICE local candidates gathering in progress..."));
/* Gather local host candidates. */ /* Gather local host candidates. */
if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) { if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) {
......
...@@ -1443,9 +1443,9 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO ...@@ -1443,9 +1443,9 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO
linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept); linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept);
fl->inc_subscribe_pending=TRUE; fl->inc_subscribe_pending=TRUE;
lc->subscribers=ms_list_append(lc->subscribers,(void *)fl); lc->subscribers=ms_list_append(lc->subscribers,(void *)fl);
if (lc->vtable.new_subscription_requested!=NULL) { {
char *tmp=linphone_address_as_string(fl->uri); char *tmp=linphone_address_as_string(fl->uri);
lc->vtable.new_subscription_requested(lc,fl,tmp); linphone_core_notify_new_subscription_requested(lc,fl,tmp);
ms_free(tmp); ms_free(tmp);
} }
} }
...@@ -1876,8 +1876,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa ...@@ -1876,8 +1876,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
} }
lf->presence = presence; lf->presence = presence;
lf->subscribe_active=TRUE; lf->subscribe_active=TRUE;
if (lc->vtable.notify_presence_received) linphone_core_notify_notify_presence_received(lc,(LinphoneFriend*)lf);
lc->vtable.notify_presence_received(lc,(LinphoneFriend*)lf);
ms_free(tmp); ms_free(tmp);
}else{ }else{
ms_message("But this person is not part of our friend list, so we don't care."); ms_message("But this person is not part of our friend list, so we don't care.");
......
...@@ -677,7 +677,7 @@ typedef struct _LinphoneConference LinphoneConference; ...@@ -677,7 +677,7 @@ typedef struct _LinphoneConference LinphoneConference;
struct _LinphoneCore struct _LinphoneCore
{ {
LinphoneCoreVTable vtable; MSList* vtables;
Sal *sal; Sal *sal;
LinphoneGlobalState state; LinphoneGlobalState state;
struct _LpConfig *config; struct _LpConfig *config;
...@@ -735,6 +735,7 @@ struct _LinphoneCore ...@@ -735,6 +735,7 @@ struct _LinphoneCore
bool_t preview_finished; bool_t preview_finished;
bool_t auto_net_state_mon; bool_t auto_net_state_mon;
bool_t network_reachable; bool_t network_reachable;
bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/
bool_t use_preview_window; bool_t use_preview_window;
time_t network_last_check; time_t network_last_check;
...@@ -978,6 +979,44 @@ BELLE_SIP_TYPE_ID(LinphoneProxyConfig) ...@@ -978,6 +979,44 @@ BELLE_SIP_TYPE_ID(LinphoneProxyConfig)
BELLE_SIP_DECLARE_TYPES_END BELLE_SIP_DECLARE_TYPES_END
void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
void linphone_core_notify_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
void linphone_core_notify_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
void linphone_core_notify_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
void linphone_core_notify_show_interface(LinphoneCore *lc);
void linphone_core_notify_display_status(LinphoneCore *lc, const char *message);
void linphone_core_notify_display_message(LinphoneCore *lc, const char *message);
void linphone_core_notify_display_warning(LinphoneCore *lc, const char *message);
void linphone_core_notify_display_url(LinphoneCore *lc, const char *message, const char *url);
void linphone_core_notify_notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf);
void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
void linphone_core_notify_call_log_updated(LinphoneCore *lc, LinphoneCallLog *newcl);
void linphone_core_notify_text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
void linphone_core_notify_message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
void linphone_core_notify_file_transfer_recv(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size);
void linphone_core_notify_file_transfer_send(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, char* buff, size_t* size);
void linphone_core_notify_file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, size_t progress);
void linphone_core_notify_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room);
void linphone_core_notify_dtmf_received(LinphoneCore* lc, LinphoneCall *call, int dtmf);
/*
* return true if at least a registered vtable has a cb for dtmf received*/
bool_t linphone_core_dtmf_received_has_listener(const LinphoneCore* lc);
void linphone_core_notify_refer_received(LinphoneCore *lc, const char *refer_to);
void linphone_core_notify_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf);
void linphone_core_notify_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
void linphone_core_notify_call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
void linphone_core_notify_info_received(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
void linphone_core_notify_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
void linphone_core_notify_network_reachable(LinphoneCore *lc, bool_t reachable);
void linphone_core_notify_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, const LinphoneContent *body);
void linphone_core_notify_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state);
void linphone_core_notify_publish_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphonePublishState state);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -310,14 +310,14 @@ int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route) ...@@ -310,14 +310,14 @@ int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route)
bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *obj){ bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *obj){
if (obj->reg_proxy==NULL){ if (obj->reg_proxy==NULL){
if (lc && lc->vtable.display_warning) if (lc)
lc->vtable.display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\"" linphone_core_notify_display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\""
" followed by a hostname.")); " followed by a hostname."));
return FALSE; return FALSE;
} }
if (obj->reg_identity==NULL){ if (obj->reg_identity==NULL){
if (lc && lc->vtable.display_warning) if (lc)
lc->vtable.display_warning(lc,_("The sip identity you entered is invalid.\nIt should look like " linphone_core_notify_display_warning(lc,_("The sip identity you entered is invalid.\nIt should look like "
"sip:username@proxydomain, such as sip:alice@example.net")); "sip:username@proxydomain, such as sip:alice@example.net"));
return FALSE; return FALSE;
} }
...@@ -1365,9 +1365,9 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){ ...@@ -1365,9 +1365,9 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){
caps=sip_setup_context_get_capabilities(ssc); caps=sip_setup_context_get_capabilities(ssc);
if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){ if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){
if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL,NULL)!=0){ if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL,NULL)!=0){
if (lc->vtable.display_warning){ {
char *tmp=ms_strdup_printf(_("Could not login as %s"),cfg->reg_identity); char *tmp=ms_strdup_printf(_("Could not login as %s"),cfg->reg_identity);
lc->vtable.display_warning(lc,tmp); linphone_core_notify_display_warning(lc,tmp);
ms_free(tmp); ms_free(tmp);
} }
return; return;
...@@ -1567,9 +1567,8 @@ void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrat ...@@ -1567,9 +1567,8 @@ void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrat
if (update_friends){ if (update_friends){
linphone_core_update_friends_subscriptions(lc,cfg,TRUE); linphone_core_update_friends_subscriptions(lc,cfg,TRUE);
} }
if (lc && lc->vtable.registration_state_changed){ if (lc)
lc->vtable.registration_state_changed(lc,cfg,state,message); linphone_core_notify_registration_state_changed(lc,cfg,state,message);
}
} else { } else {
/*state already reported*/ /*state already reported*/
} }
......
...@@ -2297,10 +2297,10 @@ static void call_transfer_existing_call_outgoing_call(void) { ...@@ -2297,10 +2297,10 @@ static void call_transfer_existing_call_outgoing_call(void) {
MSList* lcs=ms_list_append(NULL,marie->lc); MSList* lcs=ms_list_append(NULL,marie->lc);
const MSList* calls; const MSList* calls;
linphone_core_use_files (pauline->lc,TRUE); linphone_core_use_files (pauline->lc,TRUE);
linphone_core_use_files (laure->lc,TRUE); linphone_core_use_files (laure->lc,TRUE);
lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,pauline->lc);
lcs=ms_list_append(lcs,laure->lc); lcs=ms_list_append(lcs,laure->lc);
...@@ -2315,7 +2315,7 @@ static void call_transfer_existing_call_outgoing_call(void) { ...@@ -2315,7 +2315,7 @@ static void call_transfer_existing_call_outgoing_call(void) {
CU_ASSERT_TRUE(call(marie,laure)); CU_ASSERT_TRUE(call(marie,laure));
marie_call_laure=linphone_core_get_current_call(marie->lc); marie_call_laure=linphone_core_get_current_call(marie->lc);
laure_called_by_marie=linphone_core_get_current_call(laure->lc); laure_called_by_marie=linphone_core_get_current_call(laure->lc);
/*marie pause pauline*/ /*marie pause laure*/
CU_ASSERT_TRUE(pause_call_1(marie,marie_call_laure,laure,laure_called_by_marie)); CU_ASSERT_TRUE(pause_call_1(marie,marie_call_laure,laure,laure_called_by_marie));
reset_counters(&marie->stat); reset_counters(&marie->stat);
...@@ -2570,7 +2570,9 @@ static void call_rejected_because_wrong_credentials_with_params(const char* user ...@@ -2570,7 +2570,9 @@ static void call_rejected_because_wrong_credentials_with_params(const char* user
linphone_core_set_user_agent(marie->lc,user_agent,NULL); linphone_core_set_user_agent(marie->lc,user_agent,NULL);
} }
if (!enable_auth_req_cb) { if (!enable_auth_req_cb) {
marie->lc->vtable.auth_info_requested=NULL;
((LinphoneCoreVTable*)(marie->lc->vtables->data))->auth_info_requested=NULL;
linphone_core_add_auth_info(marie->lc,wrong_auth_info); linphone_core_add_auth_info(marie->lc,wrong_auth_info);
} }
......
...@@ -193,6 +193,8 @@ typedef struct _stats { ...@@ -193,6 +193,8 @@ typedef struct _stats {
int number_of_LinphoneCallEncryptedOn; int number_of_LinphoneCallEncryptedOn;
int number_of_LinphoneCallEncryptedOff; int number_of_LinphoneCallEncryptedOff;
int number_of_NetworkReachableTrue;
int number_of_NetworkReachableFalse;
LinphoneChatMessage* last_received_chat_message; LinphoneChatMessage* last_received_chat_message;
}stats; }stats;
......
...@@ -216,12 +216,9 @@ static void text_message_within_dialog(void) { ...@@ -216,12 +216,9 @@ static void text_message_within_dialog(void) {
static LinphoneAuthInfo* text_message_with_credential_from_auth_cb_auth_info; static LinphoneAuthInfo* text_message_with_credential_from_auth_cb_auth_info;
static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
stats* counters;
ms_message("text_message_with_credential_from_auth_cb:Auth info requested for user id [%s] at realm [%s]\n" ms_message("text_message_with_credential_from_auth_cb:Auth info requested for user id [%s] at realm [%s]\n"
,username ,username
,realm); ,realm);
counters = get_stats(lc);
counters->number_of_auth_info_requested++;
linphone_core_add_auth_info(lc,text_message_with_credential_from_auth_cb_auth_info); /*add stored authentication info to LinphoneCore*/ linphone_core_add_auth_info(lc,text_message_with_credential_from_auth_cb_auth_info); /*add stored authentication info to LinphoneCore*/
} }