fix call log status in case of incoming call canceled by remote

This commit is contained in:
Jehan Monnier 2011-05-23 13:16:35 +02:00
parent 71b77319f9
commit 27ab8107ef
3 changed files with 50 additions and 45 deletions

View file

@ -228,19 +228,12 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
*/
static void linphone_call_set_terminated(LinphoneCall *call){
LinphoneCallStatus status=LinphoneCallAborted;
LinphoneCore *lc=call->core;
linphone_core_update_allocated_audio_bandwidth(lc);
if (call->state==LinphoneCallEnd){
if (call->reason==LinphoneReasonDeclined){
status=LinphoneCallDeclined;
}
else status=LinphoneCallSuccess;
}
call->owns_call_log=FALSE;
linphone_call_log_completed(call->log,call, status);
linphone_call_log_completed(call);
if (call == lc->current_call){
@ -320,8 +313,14 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
call->state=cstate;
}
if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
linphone_call_set_terminated (call);
if (call->reason==LinphoneReasonDeclined){
call->log->status=LinphoneCallDeclined;
}
linphone_call_set_terminated (call);
}
if (cstate == LinphoneCallConnected) {
call->log->status=LinphoneCallSuccess;
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
@ -1179,3 +1178,35 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
linphone_core_disconnected(call->core,call);
}
void linphone_call_log_completed(LinphoneCall *call){
LinphoneCore *lc=call->core;
call->log->duration=time(NULL)-call->start_time;
if (call->log->status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
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);
ms_free(info);
}
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)call->log);
if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL;
/*find the last element*/
for(elem=lc->call_logs;elem!=NULL;elem=elem->next){
prevelem=elem;
}
elem=prevelem;
linphone_call_log_destroy((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);
}
call_logs_write_to_config_file(lc);
}

View file

@ -97,10 +97,11 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *fro
set_call_log_date(cl,&loctime);
cl->from=from;
cl->to=to;
cl->status=LinphoneCallAborted; /*default status*/
return cl;
}
static void call_logs_write_to_config_file(LinphoneCore *lc){
void call_logs_write_to_config_file(LinphoneCore *lc){
MSList *elem;
char logsection[32];
int i;
@ -156,37 +157,6 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){
}
void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status){
LinphoneCore *lc=call->core;
calllog->duration=time(NULL)-call->start_time;
if (status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
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);
ms_free(info);
}else calllog->status=status;
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)calllog);
if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL;
/*find the last element*/
for(elem=lc->call_logs;elem!=NULL;elem=elem->next){
prevelem=elem;
}
elem=prevelem;
linphone_call_log_destroy((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,calllog);
}
call_logs_write_to_config_file(lc);
}
/**
* @addtogroup call_logs
@ -914,6 +884,10 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const
lc->vtable.global_state_changed(lc,gstate,message);
}
}
static void misc_config_read (LinphoneCore *lc) {
LpConfig *config=lc->config;
lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",15);
}
static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path,
const char *factory_config_path, void * userdata)
@ -993,7 +967,7 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
video_config_read(lc);
//autoreplier_config_init(&lc->autoreplier_conf);
lc->presence_mode=LinphoneStatusOnline;
lc->max_call_logs=15;
misc_config_read(lc);
ui_config_read(lc);
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));

View file

@ -108,7 +108,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
/* private: */
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *local, LinphoneAddress * remote);
void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status);
void linphone_call_log_completed(LinphoneCall *call);
void linphone_call_log_destroy(LinphoneCallLog *cl);
void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);
@ -489,5 +489,5 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
#ifndef NB_MAX_CALLS
#define NB_MAX_CALLS (10)
#endif
void call_logs_write_to_config_file(LinphoneCore *lc);
#endif /* _PRIVATE_H */