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
LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data;
LinphoneCore *lc = chatMsg->chat_room->lc;
/* call back given by application level */
if (lc->vtable.file_transfer_progress_indication != NULL) {
lc->vtable.file_transfer_progress_indication(lc, chatMsg, chatMsg->file_transfer_information, (size_t)(((double)offset/(double)total)*100.0));
}
linphone_core_notify_file_transfer_progress_indication(lc, chatMsg, chatMsg->file_transfer_information, (size_t)(((double)offset/(double)total)*100.0));
return;
}
......@@ -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 (offset<chatMsg->file_transfer_information->size){
/* 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;
......@@ -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){
if (msg->message)
//legacy API
if (lc->vtable.text_received!=NULL) lc->vtable.text_received(lc, cr, msg->from, msg->message);
if (lc->vtable.message_received!=NULL) lc->vtable.message_received(lc, cr,msg);
if (cr->lc->vtable.is_composing_received != NULL) {
cr->remote_is_composing = LinphoneIsComposingIdle;
cr->lc->vtable.is_composing_received(cr->lc, cr);
}
linphone_core_notify_text_message_received(lc, cr, msg->from, msg->message);
linphone_core_notify_message_received(lc, cr,msg);
cr->remote_is_composing = LinphoneIsComposingIdle;
linphone_core_notify_is_composing_received(cr->lc, cr);
}
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
belle_sip_object_unref(cr->remote_composing_refresh_timer);
cr->remote_composing_refresh_timer = NULL;
cr->remote_is_composing = LinphoneIsComposingIdle;
if (cr->lc->vtable.is_composing_received != NULL)
cr->lc->vtable.is_composing_received(cr->lc, cr);
linphone_core_notify_is_composing_received(cr->lc, cr);
return BELLE_SIP_STOP;
}
......@@ -675,8 +670,7 @@ static void process_im_is_composing_notification(LinphoneChatRoom *cr, xmlparsin
}
cr->remote_is_composing = state;
if (cr->lc->vtable.is_composing_received != NULL)
cr->lc->vtable.is_composing_received(cr->lc, cr);
linphone_core_notify_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
return;
}
/* call back given by application level */
if (lc->vtable.file_transfer_recv != NULL) {
lc->vtable.file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, (char *)buffer, size);
}
linphone_core_notify_file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, (char *)buffer, size);
return;
}
......@@ -1101,9 +1093,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data;
LinphoneCore *lc = chatMsg->chat_room->lc;
/* file downloaded succesfully, call again the callback with size at zero */
if (lc->vtable.file_transfer_recv != NULL) {
lc->vtable.file_transfer_recv(lc, chatMsg, chatMsg->file_transfer_information, NULL, 0);
}
linphone_core_notify_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
}
void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state){
LinphoneCore *lc=lev->lc;
if (lev->subscription_state!=state){
ms_message("LinphoneEvent [%p] moving to subscription state %s",lev,linphone_subscription_state_to_string(state));
lev->subscription_state=state;
if (lc->vtable.subscription_state_changed){
lc->vtable.subscription_state_changed(lev->lc,lev,state);
}
linphone_core_notify_subscription_state_changed(lev->lc,lev,state);
if (state==LinphoneSubscriptionTerminated){
linphone_event_unref(lev);
}
......@@ -103,13 +100,10 @@ void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState stat
}
void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state){
LinphoneCore *lc=lev->lc;
if (lev->publish_state!=state){
ms_message("LinphoneEvent [%p] moving to publish state %s",lev,linphone_publish_state_to_string(state));
lev->publish_state=state;
if (lc->vtable.publish_state_changed){
lc->vtable.publish_state_changed(lev->lc,lev,state);
}
linphone_core_notify_publish_state_changed(lev->lc,lev,state);
switch(state){
case LinphonePublishCleared:
linphone_event_unref(lev);
......
......@@ -253,8 +253,7 @@ static void linphone_friend_invalidate_subscription(LinphoneFriend *lf){
linphone_presence_model_unref(lf->presence);
}
lf->presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,"unknown activity");
if (lc->vtable.notify_presence_received)
lc->vtable.notify_presence_received(lc,lf);
linphone_core_notify_notify_presence_received(lc,lf);
}
lf->initial_subscribes_sent=FALSE;
}
......
......@@ -192,8 +192,7 @@ void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, const SalBody
LinphoneInfoMessage *info=ms_new0(LinphoneInfoMessage,1);
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 (lc->vtable.info_received)
lc->vtable.info_received(lc,call,info);
linphone_core_notify_info_received(lc,call,info);
linphone_info_message_destroy(info);
}
}
......@@ -153,17 +153,14 @@ static uint16_t linphone_call_get_avpf_rr_interval(const LinphoneCall *call) {
}
static void propagate_encryption_changed(LinphoneCall *call){
LinphoneCore *lc=call->core;
if (!linphone_call_all_streams_encrypted(call)) {
ms_message("Some streams are not encrypted");
call->current_params->media_encryption=LinphoneMediaEncryptionNone;
if (lc->vtable.call_encryption_changed)
lc->vtable.call_encryption_changed(call->core, call, FALSE, call->auth_token);
linphone_core_notify_call_encryption_changed(call->core, call, FALSE, call->auth_token);
} else {
ms_message("All streams are encrypted");
call->current_params->media_encryption=LinphoneMediaEncryptionZRTP;
if (lc->vtable.call_encryption_changed)
lc->vtable.call_encryption_changed(call->core, call, TRUE, call->auth_token);
linphone_core_notify_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
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);
call->core->vtable.display_status(call->core, status);
linphone_core_notify_display_status(call->core, status);
}
propagate_encryption_changed(call);
......@@ -974,8 +971,8 @@ void linphone_call_set_state_base(LinphoneCall *call, LinphoneCallState cstate,
call->media_start_time=time(NULL);
}
if (lc->vtable.call_state_changed && !silently)
lc->vtable.call_state_changed(lc,call,cstate,message);
if (!silently)
linphone_core_notify_call_state_changed(lc,call,cstate,message);
linphone_reporting_call_state_updated(call);
......@@ -1640,8 +1637,7 @@ static void linphone_core_dtmf_received(LinphoneCore *lc, int dtmf){
ms_warning("Bad dtmf value %i",dtmf);
return;
}
if (lc->vtable.dtmf_received != NULL)
lc->vtable.dtmf_received(lc, linphone_core_get_current_call(lc), dtmf_tab[dtmf]);
linphone_core_notify_dtmf_received(lc, linphone_core_get_current_call(lc), dtmf_tab[dtmf]);
}
static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){
......@@ -1728,7 +1724,7 @@ static void post_configure_audio_streams(LinphoneCall*call){
AudioStream *st=call->audiostream;
LinphoneCore *lc=call->core;
_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);
}
if (call->record_active)
......@@ -2713,8 +2709,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
if (from) ms_free(from);
ms_message("On call [%p]: %s",call,temp);
if (lc->vtable.display_warning!=NULL)
lc->vtable.display_warning(lc,temp);
linphone_core_notify_display_warning(lc,temp);
linphone_core_terminate_call(lc,call);
linphone_core_play_named_tone(lc,LinphoneToneCallLost);
}
......@@ -2836,8 +2831,7 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, int stream_index){
LinphoneCore *lc=call->core;
if (stats->updated){
linphone_reporting_on_rtcp_update(call, stream_index);
if (lc->vtable.call_stats_updated)
lc->vtable.call_stats_updated(lc, call, stats);
linphone_core_notify_call_stats_updated(lc, call, stats);
stats->updated = 0;
}
}
......@@ -2932,8 +2926,7 @@ void linphone_call_log_completed(LinphoneCall *call){
info=ortp_strdup_printf(ngettext("You have missed %i call.",
"You have missed %i calls.", lc->missed_calls),
lc->missed_calls);
if (lc->vtable.display_status!=NULL)
lc->vtable.display_status(lc,info);
linphone_core_notify_display_status(lc,info);
ms_free(info);
}
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){
linphone_call_log_unref((LinphoneCallLog*)elem->data);
lc->call_logs=ms_list_remove_link(lc->call_logs,elem);
}
if (lc->vtable.call_log_updated!=NULL){
lc->vtable.call_log_updated(lc,call->log);
}
linphone_core_notify_call_log_updated(lc,call->log);
call_logs_write_to_config_file(lc);
}
......@@ -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(state));
call->transfer_state = state;
if (lc->vtable.transfer_state_changed)
lc->vtable.transfer_state_changed(lc, call, state);
linphone_core_notify_transfer_state_changed(lc, call, state);
}
}
......
This diff is collapsed.
......@@ -1611,6 +1611,13 @@ typedef enum _LinphoneConfiguringState {
*/
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.
* None is mandatory.
......@@ -1645,8 +1652,21 @@ typedef struct _LinphoneCoreVTable{
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 */
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;
/**
* 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
/* function to be periodically called in a main loop */
/* For ICE to work properly it should be called every 20ms */
LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc);
#if 0 /*not implemented yet*/
/**
* @ingroup initializing
* Provide Linphone Core with an unique identifier. This be later used to identified contact address coming from this device.
* Value is not saved.
* add a listener to be notified of linphone core events. Once events are received, registered vtable are invoked in order.
* @param vtable a LinphoneCoreVTable structure holding your application callbacks. Object is owned by linphone core until linphone_core_remove_listener.
* @param lc object
* @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
* 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() */
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){
ms_error("Could not obtain stun server addrinfo.");
return -1;
}
if (lc->vtable.display_status!=NULL)
lc->vtable.display_status(lc,_("Stun lookup in progress..."));
linphone_core_notify_display_status(lc,_("Stun lookup in progress..."));
/*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);
......@@ -603,8 +602,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
ms_warning("Fail to resolve STUN server for ICE gathering.");
return -1;
}
if (lc->vtable.display_status != NULL)
lc->vtable.display_status(lc, _("ICE local candidates gathering in progress..."));
linphone_core_notify_display_status(lc, _("ICE local candidates gathering in progress..."));
/* Gather local host candidates. */
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
linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept);
fl->inc_subscribe_pending=TRUE;
lc->subscribers=ms_list_append(lc->subscribers,(void *)fl);
if (lc->vtable.new_subscription_requested!=NULL) {
{
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);
}
}
......@@ -1876,8 +1876,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
}
lf->presence = presence;
lf->subscribe_active=TRUE;
if (lc->vtable.notify_presence_received)
lc->vtable.notify_presence_received(lc,(LinphoneFriend*)lf);
linphone_core_notify_notify_presence_received(lc,(LinphoneFriend*)lf);
ms_free(tmp);
}else{
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;
struct _LinphoneCore
{
LinphoneCoreVTable vtable;
MSList* vtables;
Sal *sal;
LinphoneGlobalState state;
struct _LpConfig *config;
......@@ -735,6 +735,7 @@ struct _LinphoneCore
bool_t preview_finished;
bool_t auto_net_state_mon;
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;
time_t network_last_check;
......@@ -978,6 +979,44 @@ BELLE_SIP_TYPE_ID(LinphoneProxyConfig)
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
}
#endif
......
......@@ -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){
if (obj->reg_proxy==NULL){
if (lc && lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\""
if (lc)
linphone_core_notify_display_warning(lc,_("The sip proxy address you entered is invalid, it must start with \"sip:\""
" followed by a hostname."));
return FALSE;
}
if (obj->reg_identity==NULL){
if (lc && lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("The sip identity you entered is invalid.\nIt should look like "
if (lc)
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"));
return FALSE;
}
......@@ -1365,9 +1365,9 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){
caps=sip_setup_context_get_capabilities(ssc);
if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){
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);
lc->vtable.display_warning(lc,tmp);
linphone_core_notify_display_warning(lc,tmp);
ms_free(tmp);
}
return;
......@@ -1567,9 +1567,8 @@ void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrat
if (update_friends){
linphone_core_update_friends_subscriptions(lc,cfg,TRUE);
}
if (lc && lc->vtable.registration_state_changed){
lc->vtable.registration_state_changed(lc,cfg,state,message);
}
if (lc)
linphone_core_notify_registration_state_changed(lc,cfg,state,message);
} else {
/*state already reported*/
}
......
......@@ -2297,10 +2297,10 @@ static void call_transfer_existing_call_outgoing_call(void) {
MSList* lcs=ms_list_append(NULL,marie->lc);
const MSList* calls;
linphone_core_use_files (pauline->lc,TRUE);
linphone_core_use_files (laure->lc,TRUE);
lcs=ms_list_append(lcs,pauline->lc);
lcs=ms_list_append(lcs,laure->lc);
......@@ -2315,7 +2315,7 @@ static void call_transfer_existing_call_outgoing_call(void) {
CU_ASSERT_TRUE(call(marie,laure));
marie_call_laure=linphone_core_get_current_call(marie->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));
reset_counters(&marie->stat);
......@@ -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);
}
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);
}
......
......@@ -193,6 +193,8 @@ typedef struct _stats {
int number_of_LinphoneCallEncryptedOn;
int number_of_LinphoneCallEncryptedOff;
int number_of_NetworkReachableTrue;
int number_of_NetworkReachableFalse;
LinphoneChatMessage* last_received_chat_message;
}stats;
......
......@@ -216,12 +216,9 @@ static void text_message_within_dialog(void) {
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) {
stats* counters;
ms_message("text_message_with_credential_from_auth_cb:Auth info requested for user id [%s] at realm [%s]\n"
,username
,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*/
}
......@@ -229,13 +226,15 @@ static void text_message_with_credential_from_auth_cb_auth_info_requested(Linpho
static void text_message_with_credential_from_auth_cb(void) {
char* to;
LinphoneChatRoom* chat_room;
LinphoneCoreVTable* vtable = linphone_vtable_new();
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
text_message_with_credential_from_auth_cb_auth_info=linphone_auth_info_clone((LinphoneAuthInfo*)(linphone_core_get_auth_info_list(marie->lc)->data));
/*to force cb to be called*/
linphone_core_clear_all_auth_info(marie->lc);
marie->lc->vtable.auth_info_requested=text_message_with_credential_from_auth_cb_auth_info_requested;
vtable->auth_info_requested=text_message_with_credential_from_auth_cb_auth_info_requested;
linphone_core_add_listener(marie->lc, vtable);
to = linphone_address_as_string(marie->identity);
chat_room = linphone_core_create_chat_room(pauline->lc,to);
......
......@@ -22,20 +22,10 @@
#include "private.h"
#include "liblinphone_tester.h"
static void auth_info_requested2(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
stats* counters;
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
,username
,realm);
counters = get_stats(lc);
counters->number_of_auth_info_requested++;
}
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
LinphoneAuthInfo *info;
auth_info_requested2(lc,realm,username,domain);
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain); /*create authentication structure from identity*/
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
}
......@@ -46,7 +36,9 @@ static LinphoneCoreManager* create_lcm_with_auth(unsigned int with_auth) {
LinphoneCoreManager* mgr=linphone_core_manager_new(NULL);
if (with_auth) {
mgr->lc->vtable.auth_info_requested=auth_info_requested;
LinphoneCoreVTable* vtable = linphone_vtable_new();
vtable->auth_info_requested=auth_info_requested;
linphone_core_add_listener(mgr->lc,vtable);
}
/*to allow testing with 127.0.0.1*/
......@@ -322,6 +314,7 @@ static void ha1_authenticated_register(){
static void authenticated_register_with_no_initial_credentials(){
LinphoneCoreManager *mgr;
LinphoneCoreVTable* vtable = linphone_vtable_new();
stats* counters;
char route[256];
......@@ -329,7 +322,8 @@ static void authenticated_register_with_no_initial_credentials(){
mgr = linphone_core_manager_new(NULL);
mgr->lc->vtable.auth_info_requested=auth_info_requested;
vtable->auth_info_requested=auth_info_requested;
linphone_core_add_listener(mgr->lc,vtable);
counters= get_stats(mgr->lc);
counters->number_of_auth_info_requested=0;
......@@ -387,8 +381,6 @@ static void authenticated_register_with_wrong_credentials_with_params_base(const
sprintf(route,"sip:%s",test_route);
mgr->lc->vtable.auth_info_requested=auth_info_requested2;
sal_set_refresher_retry_after(mgr->lc->sal,500);
if (user_agent) {
linphone_core_set_user_agent(mgr->lc,user_agent,NULL);
......@@ -467,9 +459,12 @@ static void network_state_change(){
counters = get_stats(lc);
register_ok=counters->number_of_LinphoneRegistrationOk;
linphone_core_set_network_reachable(lc,FALSE);
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_NetworkReachableFalse,1));
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationNone,register_ok));
linphone_core_set_network_reachable(lc,TRUE);
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_NetworkReachableTrue,1));
wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,2*register_ok);
linphone_core_manager_destroy(mgr);
}
static int get_number_of_udp_proxy(const LinphoneCore* lc) {
......
......@@ -57,7 +57,15 @@ const char *liblinphone_tester_writable_dir_prefix = ".";
#endif
const char *userhostsfile = "tester_hosts";
static void network_reachable(LinphoneCore *lc, bool_t reachable) {
stats* counters;
ms_message("Network reachable [%s]",reachable?"TRUE":"FALSE");
counters = get_stats(lc);
if (reachable)
counters->number_of_NetworkReachableTrue++;
else
counters->number_of_NetworkReachableFalse++;
}
void liblinphone_tester_clock_start(MSTimeSpec *start){
ms_get_cur_time(start);
}
......@@ -216,6 +224,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f
mgr->v_table.publish_state_changed=linphone_publish_state_changed;
mgr->v_table.configuring_status=linphone_configuration_status;
mgr->v_table.call_encryption_changed=linphone_call_encryption_changed;
mgr->v_table.network_reachable=network_reachable;
reset_counters(&mgr->stat);
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment