diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 56e8075df..695050ea4 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -425,9 +425,12 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, call->media_start_time=0; call->log=linphone_call_log_new(call, from, to); call->owns_call_log=TRUE; - model = linphone_presence_model_new_with_activity(LinphonePresenceActivityOnThePhone, NULL); - linphone_core_notify_all_friends(call->core,model); - linphone_presence_model_unref(model); + if (call->core->calls==NULL){ + /*there were no call, and now there is a call, send an on-the-phone presence notification automatically*/ + model = linphone_presence_model_new_with_activity(LinphonePresenceActivityOnThePhone, NULL); + linphone_core_send_presence(call->core,model); + linphone_presence_model_unref(model); + } linphone_core_get_audio_port_range(call->core, &min_port, &max_port); if (min_port == max_port) { /* Used fixed RTP audio port. */ @@ -635,7 +638,7 @@ static void linphone_call_set_terminated(LinphoneCall *call){ } if (ms_list_size(lc->calls)==0) - linphone_core_notify_all_friends(lc,lc->presence_model); + linphone_core_send_presence(lc,lc->presence_model); linphone_core_conference_check_uninit(lc); if (call->ringing_beep){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 94a242a6e..9ac7e8220 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3747,15 +3747,13 @@ void linphone_core_set_presence_info(LinphoneCore *lc, int minutes_away, const c linphone_core_set_presence_model(lc, presence); } -void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence) { - // TODO: Check that the presence timestamp is newer than the last sent presence. +void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence){ linphone_core_notify_all_friends(lc,presence); - /* - Improve the use of all LINPHONE_STATUS available. - !TODO Do not mix "presence status" with "answer status code".. - Use correct parameter to follow sip_if_match/sip_etag. - */ linphone_core_send_publish(lc,presence); +} + +void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence) { + linphone_core_send_presence(lc,presence); if ((lc->presence_model != NULL) && (lc->presence_model != presence)) { linphone_presence_model_unref(lc->presence_model); diff --git a/coreapi/private.h b/coreapi/private.h index 1c670ce93..bcdc2a565 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -296,6 +296,7 @@ static inline void set_string(char **dest, const char *src){ void linphone_process_authentication(LinphoneCore* lc, SalOp *op); void linphone_authentication_ok(LinphoneCore *lc, SalOp *op); void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from); +void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence); void linphone_notify_parse_presence(SalOp *op, const char *content_type, const char *content_subtype, const char *body, SalPresenceModel **result); void linphone_notify_convert_presence_to_xml(SalOp *op, SalPresenceModel *presence, const char *contact, char **content); void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model);