From 05e04e20594d5ace744cb8aee3cc386376cefb72 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 3 Apr 2012 15:34:03 +0200 Subject: [PATCH] Add transfer_state property to LinphoneCall --- coreapi/callbacks.c | 4 ++-- coreapi/linphonecall.c | 13 +++++++++++++ coreapi/linphonecore.c | 5 ++++- coreapi/linphonecore.h | 1 + coreapi/private.h | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 34fd552af..c58b42e73 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -420,6 +420,7 @@ static void call_resumed(LinphoneCore *lc, LinphoneCall *call){ if(lc->vtable.display_status) lc->vtable.display_status(lc,_("We have been resumed.")); linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)"); + linphone_call_set_transfer_state(call, LinphoneCallIdle); } static void call_paused_by_remote(LinphoneCore *lc, LinphoneCall *call){ @@ -821,8 +822,7 @@ static void notify_refer(SalOp *op, SalReferStatus status){ default: cstate=LinphoneCallError; } - if (lc->vtable.transfer_state_changed) - lc->vtable.transfer_state_changed(lc,call,cstate); + linphone_call_set_transfer_state(call, cstate); if (cstate==LinphoneCallConnected){ /*automatically terminate the call as the transfer is complete.*/ linphone_core_terminate_call(lc,call); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9c3ecfd11..d41c6cdad 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -295,6 +295,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, call->magic=linphone_call_magic; call->refcnt=1; call->state=LinphoneCallIdle; + call->transfer_state = LinphoneCallIdle; call->start_time=time(NULL); call->media_start_time=0; call->log=linphone_call_log_new(call, from, to); @@ -1675,4 +1676,16 @@ void linphone_call_log_completed(LinphoneCall *call){ call_logs_write_to_config_file(lc); } +LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call) { + return call->transfer_state; +} + +void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state) { + if (state != call->transfer_state) { + LinphoneCore* lc = call->core; + call->transfer_state = state; + if (lc->vtable.transfer_state_changed) + lc->vtable.transfer_state_changed(lc, call, state); + } +} diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index f99cb9c29..3a081d23d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2262,6 +2262,7 @@ int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char sal_call_refer(call->op,real_url); ms_free(real_url); linphone_address_destroy(real_parsed_url); + linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit); return 0; } @@ -2278,7 +2279,9 @@ int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char * close the call with us (the 'dest' call). **/ int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest){ - return sal_call_refer_with_replaces (call->op,dest->op); + int result = sal_call_refer_with_replaces (call->op,dest->op); + linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit); + return result; } bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 9ed629710..d2860c3a2 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -291,6 +291,7 @@ void linphone_call_send_vfu_request(LinphoneCall *call); void *linphone_call_get_user_pointer(LinphoneCall *call); void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer); void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data); +LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call); /** * Enables or disable echo cancellation for this call diff --git a/coreapi/private.h b/coreapi/private.h index 425b51008..ec57eaf9c 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -100,6 +100,7 @@ struct _LinphoneCall time_t start_time; /*time at which the call was initiated*/ time_t media_start_time; /*time at which it was accepted, media streams established*/ LinphoneCallState state; + LinphoneCallState transfer_state; /*idle if no transfer*/ LinphoneReason reason; int refcnt; void * user_pointer; @@ -142,6 +143,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *local, LinphoneAddress * remote); void linphone_call_log_completed(LinphoneCall *call); void linphone_call_log_destroy(LinphoneCallLog *cl); +void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state); void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);