diff --git a/coreapi/conference.h b/coreapi/conference.h index c4cc8e6cfaa7ef4f6831b1932210cdf6be7c25a8..f17ebfbfc368b1f710f2c061e4f4d680cd247f19 100644 --- a/coreapi/conference.h +++ b/coreapi/conference.h @@ -214,6 +214,12 @@ protected: void fillParticipantAttributes(std::shared_ptr<Participant> &p); }; +class ConferenceLogContextualizer : CoreLogContextualizer { +public: + ConferenceLogContextualizer(const LinphoneConference *conf) : CoreLogContextualizer(*Conference::toCpp(conf)) { + } +}; + } // end of namespace MediaConference LINPHONE_END_NAMESPACE diff --git a/coreapi/linphoneconference.c b/coreapi/linphoneconference.c index a62c037bc7088dfcbaa6420b5409c822b93e1e25..e5035b04ad848c4dcd9e6fee0548c92db37ab641 100644 --- a/coreapi/linphoneconference.c +++ b/coreapi/linphoneconference.c @@ -39,9 +39,9 @@ #include "core/core.h" #include "linphone/api/c-conference.h" #include "linphone/conference.h" +#include "linphone/utils/utils.h" #include "local_conference.h" #include "remote_conference.h" -#include "linphone/utils/utils.h" using namespace std; @@ -67,6 +67,7 @@ LinphoneConference *linphone_conference_ref(LinphoneConference *conference) { } void linphone_conference_unref(LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); MediaConference::Conference::toCpp(conference)->unref(); } @@ -125,6 +126,7 @@ LinphoneConferenceState linphone_conference_get_state(const LinphoneConference * LinphoneParticipantDevice * linphone_conference_get_active_speaker_participant_device(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); shared_ptr<LinphonePrivate::ParticipantDevice> p = MediaConference::Conference::toCpp(conference)->getActiveSpeakerParticipantDevice(); if (p) { @@ -134,15 +136,18 @@ linphone_conference_get_active_speaker_participant_device(const LinphoneConferen } const LinphoneConferenceParams *linphone_conference_get_current_params(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getCurrentParams().toC(); } LinphoneStatus linphone_conference_add_participant(LinphoneConference *conference, LinphoneCall *call) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->addParticipant(Call::toCpp(call)->getSharedFromThis()) ? 0 : -1; } LinphoneStatus linphone_conference_add_participant_2(LinphoneConference *conference, const LinphoneAddress *uri) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->addParticipant( LinphonePrivate::Address::toCpp(const_cast<LinphoneAddress *>(uri))->getSharedFromThis()) @@ -151,6 +156,7 @@ LinphoneStatus linphone_conference_add_participant_2(LinphoneConference *confere } LinphoneStatus linphone_conference_remove_participant(LinphoneConference *conference, const LinphoneAddress *uri) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); LinphoneParticipant *participant = linphone_conference_find_participant(conference, const_cast<LinphoneAddress *>(uri)); return linphone_conference_remove_participant_2(conference, participant); @@ -158,15 +164,18 @@ LinphoneStatus linphone_conference_remove_participant(LinphoneConference *confer LinphoneStatus linphone_conference_remove_participant_2(LinphoneConference *conference, LinphoneParticipant *participant) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->removeParticipant(Participant::toCpp(participant)->getSharedFromThis()); } LinphoneStatus linphone_conference_remove_participant_3(LinphoneConference *conference, LinphoneCall *call) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->removeParticipant(Call::toCpp(call)->getSharedFromThis()); } LinphoneParticipant *linphone_conference_find_participant(LinphoneConference *conference, const LinphoneAddress *uri) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); shared_ptr<LinphonePrivate::Participant> p = MediaConference::Conference::toCpp(conference) ->findParticipant(LinphonePrivate::Address::toCpp(const_cast<LinphoneAddress *>(uri))->getSharedFromThis()); @@ -177,32 +186,39 @@ LinphoneParticipant *linphone_conference_find_participant(LinphoneConference *co } int linphone_conference_update_params(LinphoneConference *conference, const LinphoneConferenceParams *params) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->update(*ConferenceParams::toCpp(params)); } int linphone_conference_terminate(LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->terminate(); } int linphone_conference_enter(LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->enter(); } int linphone_conference_leave(LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); MediaConference::Conference::toCpp(conference)->leave(); return 0; } bool_t linphone_conference_is_me(const LinphoneConference *conference, const LinphoneAddress *uri) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->isMe(LinphonePrivate::Address::toCpp(const_cast<LinphoneAddress *>(uri))->getSharedFromThis()); } bool_t linphone_conference_is_in(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->isIn(); } void linphone_conference_set_input_audio_device(LinphoneConference *conference, LinphoneAudioDevice *audio_device) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); if (audio_device) { MediaConference::Conference::toCpp(conference) ->setInputAudioDevice(LinphonePrivate::AudioDevice::getSharedFromThis(audio_device)); @@ -210,6 +226,7 @@ void linphone_conference_set_input_audio_device(LinphoneConference *conference, } void linphone_conference_set_output_audio_device(LinphoneConference *conference, LinphoneAudioDevice *audio_device) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); if (audio_device) { MediaConference::Conference::toCpp(conference) ->setOutputAudioDevice(LinphonePrivate::AudioDevice::getSharedFromThis(audio_device)); @@ -217,6 +234,7 @@ void linphone_conference_set_output_audio_device(LinphoneConference *conference, } const LinphoneAudioDevice *linphone_conference_get_input_audio_device(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); auto audioDevice = MediaConference::Conference::toCpp(conference)->getInputAudioDevice(); if (audioDevice) { return audioDevice->toC(); @@ -224,6 +242,7 @@ const LinphoneAudioDevice *linphone_conference_get_input_audio_device(const Linp return NULL; } const LinphoneAudioDevice *linphone_conference_get_output_audio_device(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); auto audioDevice = MediaConference::Conference::toCpp(conference)->getOutputAudioDevice(); if (audioDevice) { return audioDevice->toC(); @@ -233,11 +252,13 @@ const LinphoneAudioDevice *linphone_conference_get_output_audio_device(const Lin int linphone_conference_get_participant_device_volume(LinphoneConference *conference, LinphoneParticipantDevice *device) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->getParticipantDeviceVolume(ParticipantDevice::toCpp(device)->getSharedFromThis()); } int linphone_conference_mute_microphone(LinphoneConference *conference, bool_t val) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); MediaConference::Conference::toCpp(conference)->notifyLocalMutedDevices(val); AudioControlInterface *aci = MediaConference::Conference::toCpp(conference)->getAudioControlInterface(); if (!aci) return -1; @@ -246,22 +267,26 @@ int linphone_conference_mute_microphone(LinphoneConference *conference, bool_t v } bool_t linphone_conference_microphone_is_muted(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); AudioControlInterface *aci = MediaConference::Conference::toCpp(conference)->getAudioControlInterface(); if (!aci) return FALSE; return aci->micEnabled() ? FALSE : TRUE; } float linphone_conference_get_input_volume(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); AudioControlInterface *aci = MediaConference::Conference::toCpp(conference)->getAudioControlInterface(); if (!aci) return 0.0; return aci->getRecordVolume(); } int linphone_conference_get_participant_count(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getParticipantCount(); } bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); bctbx_list_t *participants = linphone_conference_get_participant_list(conference); bctbx_list_t *participant_addresses = NULL; for (bctbx_list_t *iterator = participants; iterator; iterator = bctbx_list_next(iterator)) { @@ -275,6 +300,7 @@ bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *con } bctbx_list_t *linphone_conference_get_participant_list(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); const list<std::shared_ptr<LinphonePrivate::Participant>> &participants = MediaConference::Conference::toCpp(conference)->getParticipants(); bctbx_list_t *participants_list = nullptr; @@ -288,6 +314,7 @@ bctbx_list_t *linphone_conference_get_participant_list(const LinphoneConference } bctbx_list_t *linphone_conference_get_participant_device_list(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); const list<std::shared_ptr<LinphonePrivate::ParticipantDevice>> devices = MediaConference::Conference::toCpp(conference)->getParticipantDevices(); bctbx_list_t *devices_list = nullptr; @@ -301,18 +328,22 @@ bctbx_list_t *linphone_conference_get_participant_device_list(const LinphoneConf } int linphone_conference_start_recording(LinphoneConference *conference, const char *path) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->startRecording(path); } int linphone_conference_stop_recording(LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->stopRecording(); } bool_t linphone_conference_is_recording(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->isRecording(); } bool_t linphone_conference_check_class(LinphoneConference *conference, LinphoneConferenceClass _class) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); const auto &cpp_conference = *LinphonePrivate::MediaConference::Conference::toCpp(conference); switch (_class) { case LinphoneConferenceClassLocal: @@ -329,6 +360,7 @@ bool_t linphone_conference_check_class(LinphoneConference *conference, LinphoneC LinphoneStatus linphone_conference_invite_participants(LinphoneConference *conference, const bctbx_list_t *addresses, const LinphoneCallParams *params) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->inviteAddresses( LinphonePrivate::Utils::bctbxListToCppSharedPtrList<LinphoneAddress, LinphonePrivate::Address>(addresses), @@ -336,42 +368,51 @@ LinphoneStatus linphone_conference_invite_participants(LinphoneConference *confe } LinphoneStatus linphone_conference_add_participants(LinphoneConference *conference, const bctbx_list_t *calls) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->addParticipants( LinphonePrivate::Utils::bctbxListToCppSharedPtrList<LinphoneCall, LinphonePrivate::Call>(calls)); } LinphoneStatus linphone_conference_add_participants_2(LinphoneConference *conference, const bctbx_list_t *addresses) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference) ->addParticipants( LinphonePrivate::Utils::bctbxListToCppSharedPtrList<LinphoneAddress, LinphonePrivate::Address>(addresses)); } LinphoneParticipant *linphone_conference_get_me(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getMe()->toC(); } const char *linphone_conference_get_subject(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return L_STRING_TO_C(MediaConference::Conference::toCpp(conference)->getSubject()); } void linphone_conference_set_subject(LinphoneConference *conference, const char *subject) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); MediaConference::Conference::toCpp(conference)->setSubject(L_C_TO_STRING(subject)); } const char *linphone_conference_get_username(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getUsername().c_str(); } void linphone_conference_set_username(LinphoneConference *conference, const char *subject) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); MediaConference::Conference::toCpp(conference)->setUsername(L_C_TO_STRING(subject)); } int linphone_conference_get_duration(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getDuration(); } time_t linphone_conference_get_start_time(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); return MediaConference::Conference::toCpp(conference)->getStartTime(); } @@ -380,6 +421,7 @@ AudioStream *linphone_conference_get_audio_stream(LinphoneConference *conference } LinphoneCall *linphone_conference_get_call(const LinphoneConference *conference) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); const std::shared_ptr<Call> call = MediaConference::Conference::toCpp(conference)->getCall(); if (call) { return call->toC(); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d3992af13272c4bceff62b8f1bb3311b48edc40b..579ff2857624291399fd59857552a911ffc53959 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -725,11 +725,11 @@ void linphone_core_cbs_set_account_registration_state_changed(LinphoneCoreCbs *c LinphoneCoreCbsAccountRegistrationStateChangedCb cb) { cbs->vtable->account_registration_state_changed = cb; } -void linphone_core_cbs_set_on_alert(LinphoneCoreCbs *cbs, LinphoneCoreCbsOnAlertCb alert_cb) { - cbs->vtable->on_alert = alert_cb; +void linphone_core_cbs_set_new_alert_triggered(LinphoneCoreCbs *cbs, LinphoneCoreCbsNewAlertTriggeredCb alert_cb) { + cbs->vtable->new_alert_triggered = alert_cb; } -LinphoneCoreCbsOnAlertCb linphone_core_cbs_get_on_alert(LinphoneCoreCbs *cbs) { - return cbs->vtable->on_alert; +LinphoneCoreCbsNewAlertTriggeredCb linphone_core_cbs_get_new_alert_triggered(LinphoneCoreCbs *cbs) { + return cbs->vtable->new_alert_triggered; } void lc_callback_obj_init(LCCallbackObj *obj, LinphoneCoreCbFunc func, void *ud) { obj->_func = func; @@ -3319,6 +3319,7 @@ static void linphone_core_init(LinphoneCore *lc, } LinphoneStatus linphone_core_start(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); try { if (lc->state == LinphoneGlobalShutdown) { // Force change of status to LinphoneGlobalOff, otherwise restarting it will fail @@ -3551,6 +3552,7 @@ const bctbx_list_t *linphone_core_get_text_codecs(const LinphoneCore *lc) { } LinphoneStatus linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact) { + CoreLogContextualizer logContextualizer(lc); LinphoneAddress *ctt; if (lc->sip_conf.contact != NULL && strcmp(lc->sip_conf.contact, contact) == 0) { @@ -3607,6 +3609,7 @@ it won't work. But we prefer to return something in all cases. It at least shows } const char *linphone_core_get_primary_contact(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); char *identity; if (lc->sip_conf.guess_hostname) { @@ -3637,6 +3640,7 @@ LinphoneAddress *linphone_core_create_primary_contact_parsed(LinphoneCore *lc) { } LinphoneStatus linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *codecs) { + CoreLogContextualizer logContextualizer(lc); if (lc->codecs_conf.audio_codecs != NULL) bctbx_list_free(lc->codecs_conf.audio_codecs); lc->codecs_conf.audio_codecs = codecs; _linphone_core_codec_config_write(lc); @@ -3645,6 +3649,7 @@ LinphoneStatus linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *co } LinphoneStatus linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_t *codecs) { + CoreLogContextualizer logContextualizer(lc); if (lc->codecs_conf.video_codecs != NULL) bctbx_list_free(lc->codecs_conf.video_codecs); lc->codecs_conf.video_codecs = codecs; _linphone_core_codec_config_write(lc); @@ -3652,6 +3657,7 @@ LinphoneStatus linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_t *co } LinphoneStatus linphone_core_set_text_codecs(LinphoneCore *lc, bctbx_list_t *codecs) { + CoreLogContextualizer logContextualizer(lc); if (lc->codecs_conf.text_codecs != NULL) bctbx_list_free(lc->codecs_conf.text_codecs); lc->codecs_conf.text_codecs = codecs; @@ -3718,6 +3724,7 @@ void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list } void linphone_core_clear_bodyless_friend_lists(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); bctbx_list_t *copy = bctbx_list_copy(linphone_core_get_friends_lists((const LinphoneCore *)lc)); for (auto it = copy; it; it = bctbx_list_next(it)) { LinphoneFriendList *friends = (LinphoneFriendList *)bctbx_list_get_data(it); @@ -3728,6 +3735,7 @@ void linphone_core_clear_bodyless_friend_lists(LinphoneCore *lc) { } void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { + CoreLogContextualizer logContextualizer(lc); if (!list->lc) { list->lc = lc; } @@ -3737,6 +3745,7 @@ void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { } const bctbx_list_t *linphone_core_find_contacts_by_char(LinphoneCore *core, const char *filter, bool_t sip_only) { + CoreLogContextualizer logContextualizer(core); // Get sipuri from filter if possible bctbx_list_t *list = NULL, *_list = NULL; LinphoneAddress *addr = linphone_core_interpret_url(core, (sip_only) ? filter : ""); @@ -3941,6 +3950,7 @@ static char _ua_name[64] = "Linphone"; static char _ua_version[64] = LIBLINPHONE_VERSION; void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver) { + CoreLogContextualizer logContextualizer(lc); ostringstream ua_string; ua_string << (name ? name : ""); if (ver) ua_string << "/" << ver; @@ -4183,6 +4193,7 @@ bool_t linphone_core_ipv6_enabled(LinphoneCore *lc) { } void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val) { + CoreLogContextualizer logContextualizer(lc); if (lc->sip_conf.ipv6_enabled != val) { lc->sip_conf.ipv6_enabled = val; if (lc->sal) { @@ -4332,6 +4343,7 @@ static void linphone_core_do_plugin_tasks(LinphoneCore *lc) { } void linphone_core_iterate(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); uint64_t curtime_ms = ms_get_cur_time_ms(); /*monotonic time*/ time_t current_real_time = ms_time(NULL); int64_t diff_time; @@ -4434,10 +4446,12 @@ void linphone_core_iterate(LinphoneCore *lc) { } LinphoneAddress *linphone_core_interpret_url(LinphoneCore *lc, const char *url) { + CoreLogContextualizer logContextualizer(lc); return linphone_core_interpret_url_2(lc, url, TRUE); } LinphoneAddress *linphone_core_interpret_url_2(LinphoneCore *lc, const char *url, bool_t apply_international_prefix) { + CoreLogContextualizer logContextualizer(lc); if (!url) return NULL; LinphoneAccount *account = linphone_core_get_default_account(lc); LinphoneAddress *result = NULL; @@ -4458,6 +4472,7 @@ LinphoneAddress *linphone_core_interpret_url_2(LinphoneCore *lc, const char *url } const char *linphone_core_get_identity(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(lc); const char *from; if (proxy != NULL) { @@ -4467,6 +4482,7 @@ const char *linphone_core_get_identity(LinphoneCore *lc) { } const char *linphone_core_get_route(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(lc); const char *route = NULL; if (proxy != NULL) { @@ -4580,6 +4596,7 @@ LinphoneProxyConfig *linphone_core_lookup_proxy_by_identity_strict(LinphoneCore * returns default proxy config if none is found */ LinphoneProxyConfig *linphone_core_lookup_proxy_by_identity(LinphoneCore *lc, const LinphoneAddress *uri) { + CoreLogContextualizer logContextualizer(lc); LinphoneProxyConfig *found_cfg = linphone_core_lookup_proxy_by_identity_strict(lc, uri); if (!found_cfg) found_cfg = lc->default_proxy; return found_cfg; @@ -4660,12 +4677,14 @@ LinphoneAccount *linphone_core_lookup_account_by_identity_strict(LinphoneCore *l * returns default account if none is found */ LinphoneAccount *linphone_core_lookup_account_by_identity(LinphoneCore *lc, const LinphoneAddress *uri) { + CoreLogContextualizer logContextualizer(lc); LinphoneAccount *found_acc = linphone_core_lookup_account_by_identity_strict(lc, uri); if (!found_acc) found_acc = lc->default_account; return found_acc; } LinphoneProxyConfig *linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri) { + CoreLogContextualizer logContextualizer(lc); LinphoneAccount *account = linphone_core_lookup_known_account(lc, uri); return account ? Account::toCpp(account)->getConfig() : nullptr; } @@ -4677,6 +4696,7 @@ linphone_core_lookup_known_proxy_2(LinphoneCore *lc, const LinphoneAddress *uri, } LinphoneAccount *linphone_core_lookup_known_account(LinphoneCore *lc, const LinphoneAddress *uri) { + CoreLogContextualizer logContextualizer(lc); return linphone_core_lookup_known_account_2(lc, uri, TRUE); } @@ -4734,6 +4754,7 @@ end: } const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to) { + CoreLogContextualizer logContextualizer(lc); LinphoneProxyConfig *cfg = linphone_core_lookup_known_proxy(lc, to); if (cfg != NULL) { return linphone_proxy_config_get_identity(cfg); @@ -4742,6 +4763,7 @@ const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAdd } LinphoneCall *linphone_core_invite(LinphoneCore *lc, const char *url) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call; LinphoneCallParams *p = linphone_core_create_call_params(lc, NULL); linphone_call_params_enable_video(p, linphone_call_params_video_enabled(p) && @@ -4752,6 +4774,7 @@ LinphoneCall *linphone_core_invite(LinphoneCore *lc, const char *url) { } LinphoneCall *linphone_core_invite_with_params(LinphoneCore *lc, const char *url, const LinphoneCallParams *p) { + CoreLogContextualizer logContextualizer(lc); bool_t apply_prefix = TRUE; LinphoneAccount *account = linphone_core_get_default_account(lc); if (account) { @@ -4768,6 +4791,7 @@ LinphoneCall *linphone_core_invite_with_params(LinphoneCore *lc, const char *url } LinphoneCall *linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call; LinphoneCallParams *p = linphone_core_create_call_params(lc, NULL); linphone_call_params_enable_video(p, linphone_call_params_video_enabled(p) && @@ -4904,6 +4928,7 @@ bool_t linphone_core_sound_resources_need_locking(LinphoneCore *lc, const Linpho LinphoneCall *linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params) { + CoreLogContextualizer logContextualizer(lc); return linphone_core_invite_address_with_params_2(lc, addr, params, NULL, NULL); } @@ -4912,6 +4937,7 @@ LinphoneCall *linphone_core_invite_address_with_params_2(LinphoneCore *lc, const LinphoneCallParams *params, const char *subject, const LinphoneContent *content) { + CoreLogContextualizer logContextualizer(lc); const char *from = NULL; LinphoneProxyConfig *proxy = NULL; LinphoneAddress *parsed_url2 = NULL; @@ -5094,6 +5120,7 @@ LinphoneStatus linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call } LinphoneStatus linphone_core_terminate_all_calls(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->terminateAllCalls(); } @@ -5102,6 +5129,7 @@ LinphoneStatus linphone_core_decline_call(BCTBX_UNUSED(LinphoneCore *lc), Linpho } const bctbx_list_t *linphone_core_get_calls(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); if (lc->callsCache) { bctbx_list_free(lc->callsCache); lc->callsCache = NULL; @@ -5120,6 +5148,7 @@ bool_t linphone_core_in_call(const LinphoneCore *lc) { } LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCurrentCall(); return call ? call->toC() : NULL; } @@ -5129,6 +5158,7 @@ LinphoneStatus linphone_core_pause_call(BCTBX_UNUSED(LinphoneCore *lc), Linphone } LinphoneStatus linphone_core_pause_all_calls(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->pauseAllCalls(); } @@ -5173,6 +5203,7 @@ LinphoneStatus linphone_core_resume_call(BCTBX_UNUSED(LinphoneCore *lc), Linphon } LinphoneCall *linphone_core_get_call_by_remote_address(const LinphoneCore *lc, const char *remote_address) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call = NULL; LinphoneAddress *raddr = linphone_address_new(remote_address); if (raddr) { @@ -5183,16 +5214,19 @@ LinphoneCall *linphone_core_get_call_by_remote_address(const LinphoneCore *lc, c } LinphoneCall *linphone_core_find_call_from_uri(const LinphoneCore *lc, const char *remote_address) { + CoreLogContextualizer logContextualizer(lc); return linphone_core_get_call_by_remote_address(lc, remote_address); } LinphoneCall *linphone_core_get_call_by_remote_address2(const LinphoneCore *lc, const LinphoneAddress *raddr) { + CoreLogContextualizer logContextualizer(lc); const auto remote_addr = LinphonePrivate::Address::toCpp(const_cast<LinphoneAddress *>(raddr))->getSharedFromThis(); shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCallByRemoteAddress(remote_addr); return call ? call->toC() : NULL; } int linphone_core_send_publish(LinphoneCore *lc, LinphonePresenceModel *presence) { + CoreLogContextualizer logContextualizer(lc); const bctbx_list_t *elem; for (elem = linphone_core_get_account_list(lc); elem != NULL; elem = bctbx_list_next(elem)) { LinphoneAccount *acc = (LinphoneAccount *)elem->data; @@ -5331,6 +5365,7 @@ void linphone_core_enable_auto_send_ringing(LinphoneCore *lc, bool_t enable) { } void linphone_core_set_presence_info(LinphoneCore *lc, int minutes_away, const char *contact, LinphoneOnlineStatus os) { + CoreLogContextualizer logContextualizer(lc); LinphonePresenceModel *presence = NULL; LinphonePresenceActivity *activity = NULL; const char *description = NULL; @@ -5395,11 +5430,13 @@ end: } void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence) { + CoreLogContextualizer logContextualizer(lc); linphone_core_notify_all_friends(lc, presence); linphone_core_send_publish(lc, presence); } void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence) { + CoreLogContextualizer logContextualizer(lc); linphone_core_send_presence(lc, presence); if (lc->presence_model != NULL) { linphone_presence_model_unref(lc->presence_model); @@ -5553,6 +5590,7 @@ void linphone_core_set_ring_level(LinphoneCore *lc, int level) { } void linphone_core_set_mic_gain_db(LinphoneCore *lc, float gaindb) { + CoreLogContextualizer logContextualizer(lc); float gain = gaindb; LinphoneCall *call = linphone_core_get_current_call(lc); AudioStream *st; @@ -5587,6 +5625,7 @@ float linphone_core_get_mic_gain_db(LinphoneCore *lc) { } void linphone_core_set_playback_gain_db(LinphoneCore *lc, float gaindb) { + CoreLogContextualizer logContextualizer(lc); float gain = gaindb; LinphoneCall *call = linphone_core_get_current_call(lc); AudioStream *st; @@ -5779,6 +5818,7 @@ void linphone_core_set_default_sound_devices(LinphoneCore *lc) { } void linphone_core_reload_sound_devices(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); const char *ringer; const char *playback; const char *capture; @@ -5841,6 +5881,7 @@ void linphone_core_reload_sound_devices(LinphoneCore *lc) { } void linphone_core_reload_video_devices(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); char *devid_copy = NULL; const char *devid = linphone_core_get_video_device(lc); if (devid != NULL) { @@ -5873,6 +5914,7 @@ void linphone_core_set_sound_source(LinphoneCore *lc, char source) { } LinphoneRecorderParams *linphone_core_create_recorder_params(const LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); LinphoneRecorderParams *params = linphone_recorder_params_new(); const LinphoneAudioDevice *device = linphone_core_get_default_input_audio_device(lc); linphone_recorder_params_set_audio_device(params, device); @@ -5880,6 +5922,7 @@ LinphoneRecorderParams *linphone_core_create_recorder_params(const LinphoneCore } LinphoneRecorder *linphone_core_create_recorder(LinphoneCore *lc, LinphoneRecorderParams *params) { + CoreLogContextualizer logContextualizer(lc); return linphone_recorder_new(lc, params); } @@ -5902,6 +5945,7 @@ void linphone_core_set_native_ringing_enabled(LinphoneCore *core, bool_t enable) } void linphone_core_enable_native_ringing(LinphoneCore *core, bool_t enable) { + CoreLogContextualizer logContextualizer(core); core->native_ringing_enabled = enable; linphone_config_set_int(core->config, "sound", "use_native_ringing", enable); if (enable == FALSE && linphone_core_get_ring(core) == NULL) { @@ -6045,6 +6089,7 @@ bool_t linphone_core_is_mic_muted(LinphoneCore *lc) { } void linphone_core_enable_mic(LinphoneCore *lc, bool_t enable) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call; const bctbx_list_t *list; const bctbx_list_t *elem; @@ -6070,6 +6115,7 @@ bool_t linphone_core_mic_enabled(LinphoneCore *lc) { } bool_t linphone_core_is_rtp_muted(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call = linphone_core_get_current_call(lc); if (call == NULL) { ms_warning("linphone_core_is_rtp_muted(): No current call !"); @@ -6201,6 +6247,7 @@ LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) } void linphone_core_set_nat_policy(LinphoneCore *lc, LinphoneNatPolicy *policy) { + CoreLogContextualizer logContextualizer(lc); if (policy != NULL) policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ else { @@ -6234,6 +6281,7 @@ LinphoneNatPolicy *linphone_core_get_nat_policy(const LinphoneCore *lc) { ******************************************************************************/ void linphone_core_set_call_logs_database_path(LinphoneCore *lc, const char *path) { + CoreLogContextualizer logContextualizer(lc); if (!linphone_core_conference_server_enabled(lc)) { auto &mainDb = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb; if (mainDb) { @@ -6252,10 +6300,12 @@ const char *linphone_core_get_call_logs_database_path(BCTBX_UNUSED(LinphoneCore } const bctbx_list_t *linphone_core_get_call_logs(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); return linphone_core_get_call_history(lc); } void linphone_core_clear_call_logs(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); #ifdef HAVE_DB_STORAGE linphone_core_delete_call_history(lc); #else @@ -6274,6 +6324,7 @@ void linphone_core_reset_missed_calls_count(LinphoneCore *lc) { } void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) { + CoreLogContextualizer logContextualizer(lc); #ifdef HAVE_DB_STORAGE linphone_core_delete_call_log(lc, cl); #else @@ -6407,6 +6458,7 @@ static void video_filter_callback(void *userdata, BCTBX_UNUSED(MSFilter *f), uns #endif LinphoneStatus linphone_core_take_preview_snapshot(LinphoneCore *lc, const char *file) { + CoreLogContextualizer logContextualizer(lc); LinphoneCall *call = linphone_core_get_current_call(lc); if (!file) return -1; @@ -6525,6 +6577,7 @@ static void reapply_network_bandwidth_settings(LinphoneCore *lc) { } void linphone_core_enable_video_capture(LinphoneCore *lc, bool_t enable) { + CoreLogContextualizer logContextualizer(lc); #ifndef VIDEO_ENABLED if (enable == TRUE) { ms_warning("Cannot enable video capture, this version of linphone was built without video support."); @@ -6539,6 +6592,7 @@ void linphone_core_enable_video_capture(LinphoneCore *lc, bool_t enable) { } void linphone_core_enable_video_display(LinphoneCore *lc, bool_t enable) { + CoreLogContextualizer logContextualizer(lc); #ifndef VIDEO_ENABLED if (enable == TRUE) { ms_warning("Cannot enable video display, this version of linphone was built without video support."); @@ -6553,6 +6607,7 @@ void linphone_core_enable_video_display(LinphoneCore *lc, bool_t enable) { } void linphone_core_enable_video_source_reuse(LinphoneCore *lc, bool_t enable) { + CoreLogContextualizer logContextualizer(lc); #ifndef VIDEO_ENABLED if (enable == TRUE) { ms_warning("Cannot enable video display, this version of linphone was built without video support."); @@ -6857,6 +6912,7 @@ float linphone_core_get_static_picture_fps(LinphoneCore *lc) { #pragma GCC diagnostic ignored "-Wunused-parameter" #endif // _MSC_VER void *linphone_core_create_native_video_window_id(const LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); #ifdef VIDEO_ENABLED LinphoneCall *call = linphone_core_get_current_call(lc); if (call) { @@ -6871,6 +6927,7 @@ void *linphone_core_create_native_video_window_id(const LinphoneCore *lc) { #endif // _MSC_VER void *linphone_core_get_native_video_window_id(const LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); if (lc->video_window_id) { /* case where the video id was previously set by the app*/ return lc->video_window_id; @@ -6907,6 +6964,7 @@ void linphone_core_set_native_video_window_id(LinphoneCore *lc, void *id) { #pragma GCC diagnostic ignored "-Wunused-parameter" #endif // _MSC_VER void *linphone_core_create_native_preview_window_id(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); #ifdef VIDEO_ENABLED LinphoneCall *call = linphone_core_get_current_call(lc); if (call) { @@ -6925,6 +6983,7 @@ void *linphone_core_create_native_preview_window_id(LinphoneCore *lc) { #endif // _MSC_VER void *linphone_core_get_native_preview_window_id(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); if (lc->preview_window_id) { /*case where the id was set by the app previously*/ return lc->preview_window_id; @@ -6998,6 +7057,7 @@ int linphone_core_get_device_rotation(LinphoneCore *lc) { } void linphone_core_set_device_rotation(LinphoneCore *lc, int rotation) { + CoreLogContextualizer logContextualizer(lc); if (rotation == lc->device_rotation) return; ms_message("%s : rotation=%d\n", __FUNCTION__, rotation); @@ -7028,6 +7088,7 @@ void linphone_core_set_device_rotation(LinphoneCore *lc, int rotation) { #pragma GCC diagnostic ignored "-Wunused-parameter" #endif // _MSC_VER int linphone_core_get_camera_sensor_rotation(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); #ifdef VIDEO_ENABLED LinphoneCall *call = linphone_core_get_current_call(lc); if (call) { @@ -7104,6 +7165,7 @@ static bool_t video_definition_supported(const LinphoneVideoDefinition *vdef) { } void linphone_core_set_preferred_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef) { + CoreLogContextualizer logContextualizer(lc); if (!linphone_video_definition_is_undefined(vdef) && video_definition_supported(vdef)) { LinphoneVideoDefinition *oldvdef = lc->video_conf.vdef; lc->video_conf.vdef = linphone_video_definition_ref(vdef); @@ -7131,6 +7193,7 @@ void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize) } void linphone_core_set_preview_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef) { + CoreLogContextualizer logContextualizer(lc); if (!vdef || linphone_video_definition_is_undefined(vdef)) { /* Reset the forced preview video definition mode */ if (lc->video_conf.preview_vdef != NULL) linphone_video_definition_unref(lc->video_conf.preview_vdef); @@ -7583,10 +7646,12 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file) { } void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms) { + CoreLogContextualizer logContextualizer(lc); L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().playDtmf(dtmf, duration_ms); } LinphoneStatus linphone_core_play_local(LinphoneCore *lc, const char *audiofile) { + CoreLogContextualizer logContextualizer(lc); return L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().playLocal(audiofile); } @@ -7607,6 +7672,7 @@ int linphone_core_get_mtu(const LinphoneCore *lc) { } void linphone_core_set_mtu(LinphoneCore *lc, int mtu) { + CoreLogContextualizer logContextualizer(lc); lc->net_conf.mtu = mtu; if (mtu > 0) { if (mtu < 500) { @@ -7917,10 +7983,12 @@ static void _linphone_core_stop(LinphoneCore *lc) { } void linphone_core_stop(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); _linphone_core_stop(lc); } void linphone_core_stop_async(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); _linphone_core_stop_async_start(lc); } @@ -8017,6 +8085,7 @@ static void set_media_network_reachable(LinphoneCore *lc, bool_t is_media_reacha } void linphone_core_refresh_registers(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); const bctbx_list_t *elem; if (!lc->sip_network_state.global_state) { ms_warning("Refresh register operation not available (network unreachable)"); @@ -8040,6 +8109,7 @@ void linphone_core_set_network_reachable_internal(LinphoneCore *lc, bool_t is_re } void linphone_core_set_network_reachable(LinphoneCore *lc, bool_t is_reachable) { + CoreLogContextualizer logContextualizer(lc); bool_t reachable = is_reachable; lc->sip_network_state.user_state = is_reachable; @@ -8053,6 +8123,7 @@ void linphone_core_set_network_reachable(LinphoneCore *lc, bool_t is_reachable) } void linphone_core_set_media_network_reachable(LinphoneCore *lc, bool_t is_reachable) { + CoreLogContextualizer logContextualizer(lc); bool_t reachable = is_reachable; lc->media_network_state.user_state = is_reachable; @@ -8064,6 +8135,7 @@ void linphone_core_set_media_network_reachable(LinphoneCore *lc, bool_t is_reach } void linphone_core_set_sip_network_reachable(LinphoneCore *lc, bool_t is_reachable) { + CoreLogContextualizer logContextualizer(lc); bool_t reachable = is_reachable; lc->sip_network_state.user_state = is_reachable; @@ -8084,6 +8156,7 @@ ortp_socket_t linphone_core_get_sip_socket(BCTBX_UNUSED(LinphoneCore *lc)) { } void linphone_core_destroy(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); linphone_core_unref(lc); } @@ -8115,6 +8188,7 @@ bool_t linphone_core_callkit_enabled(const LinphoneCore *core) { } bool_t linphone_core_local_permission_enabled(const LinphoneCore *core) { + CoreLogContextualizer logContextualizer(core); if (getPlatformHelpers(core)->getNetworkType() != PlatformHelpers::NetworkType::Wifi) { lInfo() << "IceService::hasLocalNetworkPermission() assuming true when network is not wifi"; return TRUE; @@ -8166,6 +8240,7 @@ OrtpPayloadType *linphone_core_find_payload_type(LinphoneCore *lc, const char *t } LinphonePayloadType *linphone_core_get_payload_type(LinphoneCore *lc, const char *type, int rate, int channels) { + CoreLogContextualizer logContextualizer(lc); OrtpPayloadType *pt = _linphone_core_find_payload_type(lc, type, rate, channels); return pt ? linphone_payload_type_new(lc, pt) : NULL; } @@ -8206,6 +8281,7 @@ LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc) { } LinphoneCallParams *linphone_core_create_call_params(LinphoneCore *lc, LinphoneCall *call) { + CoreLogContextualizer logContextualizer(lc); if (!call) return linphone_call_params_new(lc); if (linphone_call_get_params(call)) { return _linphone_call_params_copy(linphone_call_get_params(call)); @@ -8221,6 +8297,7 @@ const char *linphone_error_to_string(LinphoneReason err) { } void linphone_core_enable_keep_alive(LinphoneCore *lc, bool_t enable) { + CoreLogContextualizer logContextualizer(lc); if (enable > 0) { lc->sal->useTcpTlsKeepAlive(!!lc->sip_conf.tcp_tls_keepalive); lc->sal->setKeepAlivePeriod(lc->sip_conf.keepalive_period); @@ -8234,19 +8311,23 @@ bool_t linphone_core_keep_alive_enabled(LinphoneCore *lc) { } void linphone_core_start_dtmf_stream(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); if (linphone_core_get_global_state(lc) != LinphoneGlobalShutdown) L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().startDtmfStream(); } void linphone_core_stop_ringing(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().freeAudioResources(); } void linphone_core_stop_dtmf_stream(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().stopDtmfStream(); } void linphone_core_stop_tone_manager(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager().freeAudioResources(); } @@ -8517,6 +8598,7 @@ bool_t linphone_core_media_encryption_supported(LinphoneCore *lc, LinphoneMediaE } LinphoneStatus linphone_core_set_media_encryption(LinphoneCore *lc, LinphoneMediaEncryption menc) { + CoreLogContextualizer logContextualizer(lc); const char *type = "none"; int ret = -1; @@ -8761,6 +8843,7 @@ int linphone_core_get_video_dscp(const LinphoneCore *lc) { } void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path) { + CoreLogContextualizer logContextualizer(lc); if (!linphone_core_conference_server_enabled(lc)) { auto &mainDb = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb; if (mainDb) { @@ -8907,6 +8990,7 @@ void linphone_core_set_avpf_rr_interval(LinphoneCore *lc, int interval) { } LinphoneStatus linphone_core_set_audio_multicast_addr(LinphoneCore *lc, const char *ip) { + CoreLogContextualizer logContextualizer(lc); char *new_value; if (ip && !ms_is_multicast(ip)) { ms_error("Cannot set multicast audio addr to core [%p] because [%s] is not multicast", lc, ip); @@ -8920,6 +9004,7 @@ LinphoneStatus linphone_core_set_audio_multicast_addr(LinphoneCore *lc, const ch } LinphoneStatus linphone_core_set_video_multicast_addr(LinphoneCore *lc, const char *ip) { + CoreLogContextualizer logContextualizer(lc); char *new_value; if (ip && !ms_is_multicast(ip)) { ms_error("Cannot set multicast video addr to core [%p] because [%s] is not multicast", lc, ip); @@ -9038,6 +9123,7 @@ void linphone_core_realtime_text_set_keepalive_interval(LinphoneCore *lc, unsign } void linphone_core_set_http_proxy_host(LinphoneCore *lc, const char *host) { + CoreLogContextualizer logContextualizer(lc); linphone_config_set_string(lc->config, "sip", "http_proxy_host", host); if (lc->sal) { lc->sal->setHttpProxyHost(host); @@ -9049,6 +9135,7 @@ void linphone_core_set_http_proxy_host(LinphoneCore *lc, const char *host) { } void linphone_core_set_http_proxy_port(LinphoneCore *lc, int port) { + CoreLogContextualizer logContextualizer(lc); linphone_config_set_int(lc->config, "sip", "http_proxy_port", port); if (lc->sal) lc->sal->setHttpProxyPort(port); if (lc->tunnel) { @@ -9123,6 +9210,7 @@ static void linphone_core_set_conference(LinphoneCore *lc, LinphoneConference *c LinphoneConference *linphone_core_create_conference_with_params(LinphoneCore *lc, const LinphoneConferenceParams *params) { + CoreLogContextualizer logContextualizer(lc); const char *conf_method_name; LinphoneConference *conf = nullptr; bool serverMode = params && !linphone_conference_params_local_participant_enabled(params); @@ -9214,6 +9302,7 @@ LinphoneConference *linphone_core_create_conference_with_params(LinphoneCore *lc } LinphoneConferenceScheduler *linphone_core_create_conference_scheduler(LinphoneCore *core) { + CoreLogContextualizer logContextualizer(core); return LinphonePrivate::ConferenceScheduler::createCObject(L_GET_CPP_PTR_FROM_C_OBJECT(core)); } @@ -9222,6 +9311,7 @@ LinphoneConference *linphone_core_search_conference(const LinphoneCore *lc, const LinphoneAddress *localAddr, const LinphoneAddress *remoteAddr, const bctbx_list_t *participants) { + CoreLogContextualizer logContextualizer(lc); shared_ptr<LinphonePrivate::ConferenceParams> conferenceParams = params ? LinphonePrivate::ConferenceParams::toCpp(params)->clone()->toSharedPtr() : nullptr; list<std::shared_ptr<LinphonePrivate::Address>> participantsList; @@ -9246,6 +9336,7 @@ LinphoneConference *linphone_core_search_conference(const LinphoneCore *lc, } LinphoneConference *linphone_core_search_conference_2(const LinphoneCore *lc, const LinphoneAddress *conferenceAddr) { + CoreLogContextualizer logContextualizer(lc); const auto conferenceAddress = conferenceAddr ? LinphonePrivate::Address::toCpp(const_cast<LinphoneAddress *>(conferenceAddr))->getSharedFromThis() @@ -9260,6 +9351,7 @@ LinphoneConference *linphone_core_search_conference_2(const LinphoneCore *lc, co } LinphoneConferenceParams *linphone_core_create_conference_params_2(LinphoneCore *lc, LinphoneConference *conference) { + CoreLogContextualizer logContextualizer(lc); if (!conference) return linphone_conference_params_new(lc); if (linphone_conference_get_current_params(conference)) { return linphone_conference_params_clone(linphone_conference_get_current_params(conference)); @@ -9275,6 +9367,7 @@ LinphoneConferenceParams *linphone_core_create_conference_params(LinphoneCore *l } LinphoneStatus linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call) { + CoreLogContextualizer logContextualizer(lc); LinphoneConference *conference = linphone_core_get_conference(lc); if (conference == NULL) { LinphoneConferenceParams *params = linphone_conference_params_new(lc); @@ -9301,6 +9394,7 @@ LinphoneStatus linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *c } LinphoneStatus linphone_core_add_all_to_conference(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); for (const auto &call : L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls()) { if (!linphone_call_get_conference( call->toC())) // Prevent the call to the conference server from being added to the conference @@ -9321,6 +9415,7 @@ LinphoneStatus linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCa } int linphone_core_terminate_conference(LinphoneCore *lc) { + CoreLogContextualizer logContextualizer(lc); if (lc->conf_ctx == NULL) { ms_error("Could not terminate conference: no conference context"); return -1; @@ -9533,6 +9628,7 @@ const char *linphone_core_get_srtp_crypto_suites(LinphoneCore *core) { #pragma GCC diagnostic ignored "-Wunused-parameter" #endif // _MSC_VER LinphoneConferenceInfo *linphone_core_find_conference_information_from_uri(LinphoneCore *core, LinphoneAddress *uri) { + CoreLogContextualizer logContextualizer(core); #ifdef HAVE_DB_STORAGE auto &mainDb = L_GET_PRIVATE_FROM_C_OBJECT(core)->mainDb; const auto uri_addr = uri ? LinphonePrivate::Address::toCpp(uri)->getSharedFromThis() : nullptr; @@ -9589,6 +9685,7 @@ bctbx_list_t *linphone_core_get_conference_information_list_after_time(LinphoneC } void linphone_core_delete_conference_information(LinphoneCore *core, LinphoneConferenceInfo *conference_info) { + CoreLogContextualizer logContextualizer(core); #ifdef HAVE_DB_STORAGE auto &mainDb = L_GET_PRIVATE_FROM_C_OBJECT(core)->mainDb; mainDb->deleteConferenceInfo(LinphonePrivate::ConferenceInfo::toCpp(conference_info)->getSharedFromThis()); @@ -9604,6 +9701,7 @@ bool_t linphone_core_ldap_available(BCTBX_UNUSED(LinphoneCore *core)) { } LinphoneStatus linphone_core_config_sync(LinphoneCore *core) { + CoreLogContextualizer logContextualizer(core); #if TARGET_OS_IPHONE auto helper = getPlatformHelpers(core)->getSharedCoreHelpers(); SharedCoreState state = helper->getSharedCoreState(); @@ -9626,6 +9724,7 @@ void linphone_core_enable_empty_chatrooms_deletion(LinphoneCore *core, bool_t en LinphoneAccount *linphone_core_find_account_by_identity_address(const LinphoneCore *core, const LinphoneAddress *identity_address) { + CoreLogContextualizer logContextualizer(core); LinphoneAccount *found = NULL; if (identity_address == NULL) return found; @@ -9667,3 +9766,11 @@ void linphone_core_set_register_only_when_network_is_up(LinphoneCore *core, bool bool_t linphone_core_get_register_only_when_network_is_up(const LinphoneCore *core) { return core->sip_conf.register_only_when_network_is_up; } + +void linphone_core_set_label(LinphoneCore *core, const char *label) { + L_GET_CPP_PTR_FROM_C_OBJECT(core)->setLabel(L_C_TO_STRING(label)); +} + +const char *linphone_core_get_label(const LinphoneCore *core) { + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(core)->getLabel()); +} diff --git a/coreapi/tester_utils.h b/coreapi/tester_utils.h index 7a73faf8dca3e7a2422d9796ed28e5983fb79e76..505aafa174fea04e30e9b1e47741db91bdb27218 100644 --- a/coreapi/tester_utils.h +++ b/coreapi/tester_utils.h @@ -322,6 +322,7 @@ LINPHONE_PUBLIC void sal_uninit(Sal *sal); LINPHONE_PUBLIC int sal_create_uuid(Sal *ctx, char *uuid, size_t len); LINPHONE_PUBLIC char *sal_get_random_token(int size); LINPHONE_PUBLIC void sal_set_uuid(Sal *ctx, const char *uuid); +LINPHONE_PUBLIC const char *sal_get_uuid(const Sal *ctx); LINPHONE_PUBLIC void sal_default_set_sdp_handling(Sal *h, SalOpSDPHandling handling_method); LINPHONE_PUBLIC void sal_set_send_error(Sal *sal, int value); diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 41fa7b8dce66722a70d513b81c64534e8cef849f..6247f3466c60201188a936993dfba532376bd894 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -589,6 +589,6 @@ void linphone_core_remove_callbacks(LinphoneCore *lc, const LinphoneCoreCbs *cbs } void linphone_core_notify_alert(LinphoneCore *lc, LinphoneAlert *alert) { - NOTIFY_IF_EXIST(on_alert, lc, alert); + NOTIFY_IF_EXIST(new_alert_triggered, lc, alert); cleanup_dead_vtable_refs(lc); } diff --git a/include/linphone/api/c-alert-cbs.h b/include/linphone/api/c-alert-cbs.h index 332fd6a3b8e3cba6a71dbab172683e1b9a04be56..1158d204f909f8fc881e66e4e8805a2bbd7395b4 100644 --- a/include/linphone/api/c-alert-cbs.h +++ b/include/linphone/api/c-alert-cbs.h @@ -66,14 +66,13 @@ LINPHONE_PUBLIC void linphone_alert_cbs_set_user_data(LinphoneAlertCbs *cbs, voi * @param cbs The #LinphoneAlertCbs object. @notnil * @param on_terminated The #LinphoneAlertCbsOnTerminatedCb callback to execute. @notnil */ -LINPHONE_PUBLIC void linphone_alert_cbs_set_on_terminated(LinphoneAlertCbs *cbs, - LinphoneAlertCbsOnTerminatedCb on_terminated); +LINPHONE_PUBLIC void linphone_alert_cbs_set_terminated(LinphoneAlertCbs *cbs, LinphoneAlertCbsTerminatedCb terminated); /** * Get the callback for when the alert is terminated * @param cbs The #LinphoneAlertCbs object. @notnil * @return The #LinphoneAlertCbsOnTerminatedCb callback to execute. @maybenil */ -LINPHONE_PUBLIC LinphoneAlertCbsOnTerminatedCb linphone_alert_cbs_get_on_terminated(LinphoneAlertCbs *cbs); +LINPHONE_PUBLIC LinphoneAlertCbsTerminatedCb linphone_alert_cbs_get_terminated(LinphoneAlertCbs *cbs); /** * @} @@ -82,4 +81,4 @@ LINPHONE_PUBLIC LinphoneAlertCbsOnTerminatedCb linphone_alert_cbs_get_on_termina } #endif // ifdef __cplusplus -#endif // ifndef _L_C_ALERT_CBS_H_ \ No newline at end of file +#endif // ifndef _L_C_ALERT_CBS_H_ diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index f6b51fe812eaa1cda6d6c02e382bac5204d52d6e..ff0e359793646b9e26e680c1c27c13fb47c0e4c7 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -58,12 +58,12 @@ typedef void (*LinphoneAccountCbsRegistrationStateChangedCb)(LinphoneAccount *ac * @param core #LinphoneCore object @notnil * @param alert #LinphoneAlert to notify @notnil */ -typedef void (*LinphoneCoreCbsOnAlertCb)(LinphoneCore *core, LinphoneAlert *alert); +typedef void (*LinphoneCoreCbsNewAlertTriggeredCb)(LinphoneCore *core, LinphoneAlert *alert); /** * Callback to know if an alert stops * @param alert the alert that stops @notnil */ -typedef void (*LinphoneAlertCbsOnTerminatedCb)(LinphoneAlert *alert); +typedef void (*LinphoneAlertCbsTerminatedCb)(LinphoneAlert *alert); /** * @} */ diff --git a/include/linphone/core.h b/include/linphone/core.h index f659edbc44307025fd4ed5c710209acee0c81ae4..9928cf66414c549256a7f964e240b953a5dc67f1 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -299,7 +299,7 @@ typedef struct _LinphoneCoreVTable { LinphoneCoreCbsAccountRegistrationStateChangedCb account_registration_state_changed; LinphoneCoreCbsConferenceInfoReceivedCb conference_info_received; LinphoneCoreCbsPushNotificationReceivedCb push_notification_received; - LinphoneCoreCbsOnAlertCb on_alert; + LinphoneCoreCbsNewAlertTriggeredCb new_alert_triggered; LinphoneCoreCbsPreviewDisplayErrorOccurredCb preview_display_error_occurred; LinphoneCoreCbsNewMessageReactionCb new_message_reaction; LinphoneCoreCbsReactionRemovedCb reaction_removed; @@ -1439,6 +1439,22 @@ LINPHONE_PUBLIC void linphone_core_enable_conference_ics_in_message_body(Linphon */ LINPHONE_PUBLIC bool_t linphone_core_conference_ics_in_message_body_enabled(const LinphoneCore *core); +/** + * Set a label - for logging/troubleshooting purpose - to the core object. + * This label is used by the logger to give context. When running an application with several LinphoneCore objects, + * (such as a test), it is useful to enhance the log's readability'. + * @param core the #LinphoneCore + * @param label a developper-friendly label. + **/ +LINPHONE_PUBLIC void linphone_core_set_label(LinphoneCore *core, const char *label); + +/** + * Get the label assigned to the LinphoneCore. The default value is NULL (no label). + * @param core the #LinphoneCore + * @return the assigned label. + **/ +LINPHONE_PUBLIC const char *linphone_core_get_label(const LinphoneCore *core); + /** * @} **/ @@ -4805,13 +4821,14 @@ linphone_core_get_conference_participant_list_type(const LinphoneCore *lc); * @param cbs #LinphoneCoreCbs object. @notnil * @param alert_cb The #LinphoneCoreCbsOnAlertCb callback to call. @notnil */ -LINPHONE_PUBLIC void linphone_core_cbs_set_on_alert(LinphoneCoreCbs *cbs, LinphoneCoreCbsOnAlertCb alert_cb); +LINPHONE_PUBLIC void linphone_core_cbs_set_new_alert_triggered(LinphoneCoreCbs *cbs, + LinphoneCoreCbsNewAlertTriggeredCb alert_cb); /** * Get the on alert callback. * @param cbs #LinphoneCoreCbs object. @notnil * @return The #LinphoneCoreCbsOnAlertCb callback called. */ -LINPHONE_PUBLIC LinphoneCoreCbsOnAlertCb linphone_core_cbs_get_on_alert(LinphoneCoreCbs *cbs); +LINPHONE_PUBLIC LinphoneCoreCbsNewAlertTriggeredCb linphone_core_cbs_get_new_alert_triggered(LinphoneCoreCbs *cbs); /** * Enable alerts. See #LinphoneAlert for more details. diff --git a/src/account/account.cpp b/src/account/account.cpp index e750c0bc41d9ae8925e33787436960f47f5d58cd..362bb80c147c37b310961e312dc26243d906ce27 100644 --- a/src/account/account.cpp +++ b/src/account/account.cpp @@ -44,8 +44,8 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -Account::Account(LinphoneCore *lc, std::shared_ptr<AccountParams> params) { - mCore = lc; +Account::Account(LinphoneCore *lc, std::shared_ptr<AccountParams> params) + : CoreAccessor(lc ? L_GET_CPP_PTR_FROM_C_OBJECT(lc) : nullptr) { mParams = params; applyParamsChanges(); bctbx_message("LinphoneAccount[%p] created with params", toC()); @@ -57,10 +57,6 @@ Account::Account(LinphoneCore *lc, std::shared_ptr<AccountParams> params, Linpho bctbx_message("LinphoneAccount[%p] created with proxy config", toC()); } -Account::Account(const Account &other) : HybridObject(other) { - bctbx_message("LinphoneAccount[%p] created from copy constructor", toC()); -} - Account::~Account() { bctbx_message("LinphoneAccount[%p] destroyed", toC()); if (mSentHeaders) sal_custom_header_free(mSentHeaders); @@ -72,7 +68,7 @@ Account::~Account() { } Account *Account::clone() const { - return new Account(*this); + return nullptr; } // ----------------------------------------------------------------------------- @@ -262,10 +258,6 @@ void Account::setSipEtag(const std::string &sipEtag) { mSipEtag = sipEtag; } -void Account::setCore(LinphoneCore *lc) { - mCore = lc; -} - void Account::setErrorInfo(LinphoneErrorInfo *errorInfo) { mErrorInfo = errorInfo; } @@ -305,8 +297,10 @@ void Account::setServiceRouteAddress(std::shared_ptr<Address> serviceRoute) { // Enable register on account dependent on the given one (if any). // Also force contact address of dependent account to the given one void Account::updateDependentAccount(LinphoneRegistrationState state, const std::string &message) { - if (!mCore) return; - bctbx_list_t *it = mCore->sip_conf.accounts; + auto core = getCCore(); + + if (!core) return; + bctbx_list_t *it = core->sip_conf.accounts; for (; it; it = it->next) { LinphoneAccount *tmp = static_cast<LinphoneAccount *>(it->data); @@ -344,13 +338,14 @@ void Account::updateDependentAccount(LinphoneRegistrationState state, const std: } void Account::setState(LinphoneRegistrationState state, const std::string &message) { + auto core = getCCore(); if (mState != state || state == LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/ const auto identity = (mParams) ? mParams->getIdentity().c_str() : std::string(); if (!mParams) lWarning() << "AccountParams not set for Account [" << this->toC() << "]"; lInfo() << "Account [" << this << "] for identity [" << identity << "] moving from state [" << linphone_registration_state_to_string(mState) << "] to [" - << linphone_registration_state_to_string(state) << "] on core [" << mCore << "]"; + << linphone_registration_state_to_string(state) << "] on core [" << core << "]"; if (state == LinphoneRegistrationOk) { @@ -371,15 +366,15 @@ void Account::setState(LinphoneRegistrationState state, const std::string &messa } _linphone_account_notify_registration_state_changed(this->toC(), state, message.c_str()); - if (mCore) linphone_core_notify_account_registration_state_changed(mCore, this->toC(), state, message.c_str()); - if (mConfig && mCore) { + if (core) linphone_core_notify_account_registration_state_changed(core, this->toC(), state, message.c_str()); + if (mConfig && core) { // Compatibility with proxy config - linphone_core_notify_registration_state_changed(mCore, mConfig, state, message.c_str()); + linphone_core_notify_registration_state_changed(core, mConfig, state, message.c_str()); } - if (linphone_core_should_subscribe_friends_only_when_registered(mCore) && state == LinphoneRegistrationOk && + if (linphone_core_should_subscribe_friends_only_when_registered(core) && state == LinphoneRegistrationOk && previousState != state) { - linphone_core_update_friends_subscriptions(mCore); + linphone_core_update_friends_subscriptions(core); } } else { /*state already reported*/ @@ -432,10 +427,6 @@ const std::string &Account::getSipEtag() const { return mSipEtag; } -LinphoneCore *Account::getCore() const { - return mCore; -} - const LinphoneErrorInfo *Account::getErrorInfo() { if (!mErrorInfo) mErrorInfo = linphone_error_info_new(); linphone_error_info_from_sal_op(mErrorInfo, mOp); @@ -498,6 +489,7 @@ std::shared_ptr<Account> Account::getDependency() { std::shared_ptr<Address> Account::guessContactForRegister() { std::shared_ptr<Address> result = nullptr; + auto core = getCCore(); if (mDependency) { // In case of dependent account, force contact of 'master' account, but only after a successful register @@ -516,13 +508,13 @@ std::shared_ptr<Address> Account::guessContactForRegister() { bool successfullyPreparedPushParameters = false; auto newParams = mParams->clone()->toSharedPtr(); - if (mCore && mCore->push_notification_enabled) { + if (core && core->push_notification_enabled) { if (!newParams->isPushNotificationAvailable()) { lError() << "Couldn't compute automatic push notifications parameters on account [" << this->toC() << "] because account params do not have available push notifications"; } else if (newParams->mPushNotificationAllowed || newParams->mRemotePushNotificationAllowed) { if (newParams->mPushNotificationConfig->getProvider().empty()) { - bool tester_env = !!linphone_config_get_int(mCore->config, "tester", "test_env", FALSE); + bool tester_env = !!linphone_config_get_int(core->config, "tester", "test_env", FALSE); if (tester_env) newParams->mPushNotificationConfig->setProvider("liblinphone_tester"); #if TARGET_OS_IPHONE if (tester_env) newParams->mPushNotificationConfig->setProvider("apns.dev"); @@ -630,9 +622,9 @@ void Account::registerAccount() { auto proxy_string = proxy->asStringUriOnly(); if (mOp) mOp->release(); - mOp = new SalRegisterOp(mCore->sal.get()); + mOp = new SalRegisterOp(getCCore()->sal.get()); - linphone_configure_op(mCore, mOp, mParams->mIdentityAddress->toC(), mSentHeaders, FALSE); + linphone_configure_op(getCCore(), mOp, mParams->mIdentityAddress->toC(), mSentHeaders, FALSE); std::shared_ptr<Address> contactAddress = guessContactForRegister(); if (contactAddress) { @@ -733,7 +725,7 @@ void Account::stopRefreshing() { /*with udp, there is a risk of port reuse, so I prefer to not do anything for now*/ if (contact_addr) { if (contact_addr->getTransport() != LinphonePrivate::Transport::Udp && - linphone_config_get_int(mCore->config, "sip", "unregister_previous_contact", 0)) { + linphone_config_get_int(getCCore()->config, "sip", "unregister_previous_contact", 0)) { mPendingContactAddress = contact_addr; } } @@ -797,9 +789,10 @@ bool Account::isAvpfEnabled() const { lWarning() << "isAvpfEnabled is called but no AccountParams is set on Account [" << this->toC() << "]"; return false; } + auto core = getCCore(); - if (mParams->mAvpfMode == LinphoneAVPFDefault && mCore) { - return linphone_core_get_avpf_mode(mCore) == LinphoneAVPFEnabled; + if (mParams->mAvpfMode == LinphoneAVPFDefault && core) { + return linphone_core_get_avpf_mode(core) == LinphoneAVPFEnabled; } return mParams->mAvpfMode == LinphoneAVPFEnabled; @@ -813,7 +806,7 @@ const LinphoneAuthInfo *Account::findAuthInfo() const { const std::string username = mParams->mIdentityAddress ? mParams->mIdentityAddress->getUsername() : std::string(); const std::string domain = mParams->mIdentityAddress ? mParams->mIdentityAddress->getDomain() : std::string(); - return linphone_core_find_auth_info(mCore, mParams->mRealm.c_str(), username.c_str(), domain.c_str()); + return linphone_core_find_auth_info(getCCore(), mParams->mRealm.c_str(), username.c_str(), domain.c_str()); } int Account::getUnreadChatMessageCount() const { @@ -822,7 +815,7 @@ int Account::getUnreadChatMessageCount() const { return -1; } - return L_GET_CPP_PTR_FROM_C_OBJECT(mCore)->getUnreadChatMessageCount(mParams->mIdentityAddress); + return getCore()->getUnreadChatMessageCount(mParams->mIdentityAddress); } void Account::writeToConfigFile(int index) { @@ -831,7 +824,7 @@ void Account::writeToConfigFile(int index) { return; } - mParams->writeToConfigFile(mCore->config, index); + mParams->writeToConfigFile(getCCore()->config, index); } void Account::addCustomParam(const std::string &key, const std::string &value) { @@ -843,7 +836,8 @@ const std::string &Account::getCustomParam(const std::string &key) const { } bool Account::canRegister() { - if (mCore->sip_conf.register_only_when_network_is_up && !mCore->sip_network_state.global_state) { + LinphoneCore *core = getCCore(); + if (core->sip_conf.register_only_when_network_is_up && !core->sip_network_state.global_state) { return false; } if (mDependency) { @@ -895,13 +889,21 @@ int Account::done() { lInfo() << "Publish params have not changed on account [" << this->toC() << "]"; } - if (mCore) { - linphone_proxy_config_write_all_to_config_file(mCore); // TODO: change it when removing all proxy_config + if (getCCore()) { + linphone_proxy_config_write_all_to_config_file(getCCore()); // TODO: change it when removing all proxy_config } return 0; } +LinphoneCore *Account::getCCore() const { + try { + return L_GET_C_BACK_PTR(getCore()); + } catch (...) { + } + return nullptr; +} + void Account::update() { if (mNeedToRegister) { if (canRegister()) { @@ -911,7 +913,7 @@ void Account::update() { } if (mSendPublish && (mState == LinphoneRegistrationOk || mState == LinphoneRegistrationCleared)) { if (mPresenceModel == nullptr) { - setPresenceModel(mCore->presence_model); + setPresenceModel(getCCore()->presence_model); } sendPublish(); mSendPublish = false; @@ -921,7 +923,7 @@ void Account::update() { void Account::apply(LinphoneCore *lc) { mOldParams = nullptr; // remove old params to make sure we will register since we only call apply when adding // accounts to core - mCore = lc; + setCore(L_GET_CPP_PTR_FROM_C_OBJECT(lc)); if (mDependency != nullptr) { // disable register if master account is not yet registered @@ -939,13 +941,12 @@ void Account::apply(LinphoneCore *lc) { } shared_ptr<EventPublish> Account::createPublish(const std::string event, int expires) { - if (!mCore) { + if (!getCore()) { lError() << "Cannot create publish from account [" << this->toC() << "] not attached to any core"; return nullptr; } return dynamic_pointer_cast<EventPublish>( - (new EventPublish(L_GET_CPP_PTR_FROM_C_OBJECT(mCore), getSharedFromThis(), NULL, event, expires)) - ->getSharedFromThis()); + (new EventPublish(getCore(), getSharedFromThis(), NULL, event, expires))->getSharedFromThis()); } void Account::setPresenceModel(LinphonePresenceModel *presence) { @@ -989,7 +990,7 @@ int Account::sendPublish() { const auto &identityAddress = mParams->getIdentityAddress(); mPresencePublishEvent->setUserData(identityAddress->toC()); - LinphoneConfig *config = linphone_core_get_config(mCore); + LinphoneConfig *config = linphone_core_get_config(getCCore()); if (linphone_config_get_bool(config, "sip", "update_presence_model_timestamp_before_publish_expires_refresh", FALSE)) { unsigned int nbServices = linphone_presence_model_get_nb_services(mPresenceModel); @@ -1082,16 +1083,17 @@ void Account::releaseOps() { } void Account::resolveDependencies() { - if (!mCore) return; + auto core = getCCore(); + if (!core) return; const bctbx_list_t *elem; - for (elem = mCore->sip_conf.accounts; elem != NULL; elem = elem->next) { + for (elem = core->sip_conf.accounts; elem != NULL; elem = elem->next) { LinphoneAccount *account = (LinphoneAccount *)elem->data; LinphoneAccount *dependency = linphone_account_get_dependency(account); string dependsOn = Account::toCpp(account)->mParams->mDependsOn; if (dependency != NULL && !dependsOn.empty()) { - LinphoneAccount *master_account = linphone_core_get_account_by_idkey(mCore, dependsOn.c_str()); + LinphoneAccount *master_account = linphone_core_get_account_by_idkey(core, dependsOn.c_str()); if (master_account != NULL && master_account != dependency) { lError() << "LinphoneAccount has a dependency but idkeys do not match: [" << dependsOn << "] != [" << linphone_account_params_get_idkey(linphone_account_get_params(dependency)) @@ -1105,7 +1107,7 @@ void Account::resolveDependencies() { } } if (!dependsOn.empty() && dependency == NULL) { - LinphoneAccount *dependency_acc = linphone_core_get_account_by_idkey(mCore, dependsOn.c_str()); + LinphoneAccount *dependency_acc = linphone_core_get_account_by_idkey(core, dependsOn.c_str()); if (dependency_acc == NULL) { lWarning() << "LinphoneAccount marked as dependent but no account found for idkey [" << dependsOn @@ -1123,15 +1125,20 @@ void Account::resolveDependencies() { // ----------------------------------------------------------------------------- void Account::onInternationalPrefixChanged() { + auto core = getCCore(); + if (!core) return; /* Ensure there is a default account otherwise after invalidating friends maps we won't be able to recompute phone * numbers */ /* Also it is useless to do it if the account being edited isn't the default one */ - if (mCore && this->toC() == linphone_core_get_default_account(mCore)) { - linphone_core_invalidate_friends_maps(mCore); + if (core && this->toC() == linphone_core_get_default_account(core)) { + linphone_core_invalidate_friends_maps(core); } } void Account::onConferenceFactoryUriChanged(const std::string &conferenceFactoryUri) { + auto core = getCCore(); + if (!core) return; + std::string conferenceSpec("conference/"); conferenceSpec.append(Core::conferenceVersionAsString()); std::string groupchatSpec("groupchat/"); @@ -1140,16 +1147,14 @@ void Account::onConferenceFactoryUriChanged(const std::string &conferenceFactory ephemeralSpec.append(Core::ephemeralVersionAsString()); if (!conferenceFactoryUri.empty()) { - if (mCore) { - linphone_core_add_linphone_spec(mCore, L_STRING_TO_C(conferenceSpec)); - linphone_core_add_linphone_spec(mCore, L_STRING_TO_C(groupchatSpec)); - linphone_core_add_linphone_spec(mCore, L_STRING_TO_C(ephemeralSpec)); - } - } else if (mCore) { + linphone_core_add_linphone_spec(core, L_STRING_TO_C(conferenceSpec)); + linphone_core_add_linphone_spec(core, L_STRING_TO_C(groupchatSpec)); + linphone_core_add_linphone_spec(core, L_STRING_TO_C(ephemeralSpec)); + } else { bool remove = true; bool removeAudioVideoConfAddress = true; // Check that no other account needs the specs before removing it - for (bctbx_list_t *it = mCore->sip_conf.accounts; it; it = it->next) { + for (bctbx_list_t *it = core->sip_conf.accounts; it; it = it->next) { if (it->data != this->toC()) { const char *confUri = linphone_account_params_get_conference_factory_uri( linphone_account_get_params((LinphoneAccount *)it->data)); @@ -1167,28 +1172,29 @@ void Account::onConferenceFactoryUriChanged(const std::string &conferenceFactory } } if (removeAudioVideoConfAddress) { - linphone_core_remove_linphone_spec(mCore, L_STRING_TO_C(conferenceSpec)); + linphone_core_remove_linphone_spec(core, L_STRING_TO_C(conferenceSpec)); } if (remove) { - linphone_core_remove_linphone_spec(mCore, L_STRING_TO_C(groupchatSpec)); - linphone_core_remove_linphone_spec(mCore, L_STRING_TO_C(ephemeralSpec)); + linphone_core_remove_linphone_spec(core, L_STRING_TO_C(groupchatSpec)); + linphone_core_remove_linphone_spec(core, L_STRING_TO_C(ephemeralSpec)); } } } void Account::onAudioVideoConferenceFactoryAddressChanged( const std::shared_ptr<Address> &audioVideoConferenceFactoryAddress) { + auto core = getCCore(); + if (!core) return; + std::string conferenceSpec("conference/"); conferenceSpec.append(Core::conferenceVersionAsString()); if (audioVideoConferenceFactoryAddress) { - if (mCore) { - linphone_core_add_linphone_spec(mCore, L_STRING_TO_C(conferenceSpec)); - } - } else if (mCore) { + linphone_core_add_linphone_spec(core, L_STRING_TO_C(conferenceSpec)); + } else { bool remove = true; // Check that no other account needs the specs before removing it - for (bctbx_list_t *it = mCore->sip_conf.accounts; it; it = it->next) { + for (bctbx_list_t *it = core->sip_conf.accounts; it; it = it->next) { if (it->data != this->toC()) { const char *confUri = linphone_account_params_get_conference_factory_uri( linphone_account_get_params((LinphoneAccount *)it->data)); @@ -1201,7 +1207,7 @@ void Account::onAudioVideoConferenceFactoryAddressChanged( } } if (remove) { - linphone_core_remove_linphone_spec(mCore, L_STRING_TO_C(conferenceSpec)); + linphone_core_remove_linphone_spec(core, L_STRING_TO_C(conferenceSpec)); } } } @@ -1235,20 +1241,20 @@ void AccountCbs::setRegistrationStateChanged(LinphoneAccountCbsRegistrationState #endif // _MSC_VER void Account::onLimeServerUrlChanged(const std::string &limeServerUrl) { #ifdef HAVE_LIME_X3DH + auto core = getCCore(); + if (!core) return; if (!limeServerUrl.empty()) { - if (mCore) { - linphone_core_add_linphone_spec(mCore, "lime"); - } - } else if (mCore) { + linphone_core_add_linphone_spec(core, "lime"); + } else { // If LIME server URL is still set in the Core, do not remove the spec - const char *core_lime_server_url = linphone_core_get_lime_x3dh_server_url(mCore); + const char *core_lime_server_url = linphone_core_get_lime_x3dh_server_url(core); if (core_lime_server_url && strlen(core_lime_server_url)) { return; } bool remove = true; // Check that no other account needs the spec before removing it - for (bctbx_list_t *it = mCore->sip_conf.accounts; it; it = it->next) { + for (bctbx_list_t *it = core->sip_conf.accounts; it; it = it->next) { if (it->data != this->toC()) { const char *lime_server_url = linphone_account_params_get_lime_server_url( linphone_account_get_params((LinphoneAccount *)it->data)); @@ -1259,16 +1265,14 @@ void Account::onLimeServerUrlChanged(const std::string &limeServerUrl) { } } if (remove) { - linphone_core_remove_linphone_spec(mCore, "lime"); + linphone_core_remove_linphone_spec(core, "lime"); } } - if (mCore) { - // If the lime server URL has changed, then propagate the change to the encryption engine - auto encryptionEngine = L_GET_CPP_PTR_FROM_C_OBJECT(mCore)->getEncryptionEngine(); - if (encryptionEngine && (encryptionEngine->getEngineType() == EncryptionEngine::EngineType::LimeX3dh)) { - encryptionEngine->onServerUrlChanged(getSharedFromThis(), limeServerUrl); - } + // If the lime server URL has changed, then propagate the change to the encryption engine + auto encryptionEngine = getCore()->getEncryptionEngine(); + if (encryptionEngine && (encryptionEngine->getEngineType() == EncryptionEngine::EngineType::LimeX3dh)) { + encryptionEngine->onServerUrlChanged(getSharedFromThis(), limeServerUrl); } #else diff --git a/src/account/account.h b/src/account/account.h index 93fec9cbc272b6d153818bec826e87162511cf7a..53e49d0aa16a8a9783355a939f9f0ab359c29cbb 100644 --- a/src/account/account.h +++ b/src/account/account.h @@ -45,11 +45,12 @@ class EventPublish; class Account : public bellesip::HybridObject<LinphoneAccount, Account>, public UserDataAccessor, - public CallbacksHolder<AccountCbs> { + public CallbacksHolder<AccountCbs>, + public CoreAccessor { public: Account(LinphoneCore *lc, std::shared_ptr<AccountParams> params); Account(LinphoneCore *lc, std::shared_ptr<AccountParams> params, LinphoneProxyConfig *config); - Account(const Account &other); + Account(const Account &other) = delete; virtual ~Account(); Account *clone() const override; @@ -65,7 +66,6 @@ public: void setNeedToRegister(bool needToRegister); void setDeletionDate(time_t deletionDate); void setSipEtag(const std::string &sipEtag); - void setCore(LinphoneCore *lc); void setErrorInfo(LinphoneErrorInfo *errorInfo); void setContactAddress(const std::shared_ptr<const Address> &contact); void setContactAddressWithoutParams(const std::shared_ptr<const Address> &contact); @@ -82,7 +82,6 @@ public: bool getRegisterChanged() const; time_t getDeletionDate() const; const std::string &getSipEtag() const; - LinphoneCore *getCore() const; const LinphoneErrorInfo *getErrorInfo(); const std::shared_ptr<Address> &getContactAddress() const; const std::shared_ptr<Address> &getContactAddressWithoutParams() const; @@ -131,6 +130,7 @@ public: LinphoneAccountAddressComparisonResult isServerConfigChanged(); private: + LinphoneCore *getCCore() const; bool canRegister(); bool computePublishParamsHash(); int done(); @@ -162,8 +162,6 @@ private: std::string mSipEtag; - LinphoneCore *mCore = nullptr; - LinphoneErrorInfo *mErrorInfo = nullptr; std::shared_ptr<Address> mContactAddress = nullptr; @@ -200,6 +198,13 @@ private: LinphoneAccountCbsRegistrationStateChangedCb mRegistrationStateChangedCb = nullptr; }; +class AccountLogScope : public CoreLogContextualizer { +public: + AccountLogScope(const LinphoneAccount *account) + : CoreLogContextualizer(account ? Account::toCpp(account) : nullptr) { + } +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_ACCOUNT_H_ diff --git a/src/alert/alert.h b/src/alert/alert.h index 85907646ac00f09e3d43b5926b0b7a00cb1e70c6..a634161b433f9fde12759a94046fcd03c3bfa2b1 100644 --- a/src/alert/alert.h +++ b/src/alert/alert.h @@ -136,7 +136,9 @@ public: void reset() override; float computeNackIndicator(uint64_t lostBeforeNack, uint64_t cumPacketLoss); void checkSignalQuality(); - bool mNackSent; + void confirmNackSent() { + mNackSent = true; + } private: uint64_t mLastNackLoss = 0; @@ -147,19 +149,20 @@ private: float mNackPerformanceThreshold = 0.0f; float mSignalThreshold = 0.0f; bool mFirstMeasureNonZero = false; + bool mNackSent = false; }; class AlertCbs : public bellesip::HybridObject<LinphoneAlertCbs, AlertCbs>, public Callbacks { public: - LinphoneAlertCbsOnTerminatedCb getOnTerminated() const { + LinphoneAlertCbsTerminatedCb getOnTerminated() const { return mOnTerminated; }; - void setOnTerminated(LinphoneAlertCbsOnTerminatedCb onTerminated) { + void setOnTerminated(LinphoneAlertCbsTerminatedCb onTerminated) { mOnTerminated = onTerminated; }; private: - LinphoneAlertCbsOnTerminatedCb mOnTerminated = nullptr; + LinphoneAlertCbsTerminatedCb mOnTerminated = nullptr; }; LINPHONE_END_NAMESPACE diff --git a/src/c-wrapper/api/c-account.cpp b/src/c-wrapper/api/c-account.cpp index 5f2712dd5eaf73f97e49a370da49b12d44b20b14..1d0cb46158b23869d22fd822e3e5a38621a5e6ed 100644 --- a/src/c-wrapper/api/c-account.cpp +++ b/src/c-wrapper/api/c-account.cpp @@ -55,22 +55,27 @@ LinphoneAccount *linphone_account_ref(LinphoneAccount *account) { } void linphone_account_unref(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->unref(); } int linphone_account_set_params(LinphoneAccount *account, LinphoneAccountParams *params) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->setAccountParams(AccountParams::toCpp(params)->getSharedFromThis()); } const LinphoneAccountParams *linphone_account_get_params(const LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getAccountParams()->toC(); } void linphone_account_add_custom_param(LinphoneAccount *account, const char *key, const char *value) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->addCustomParam(L_C_TO_STRING(key), L_C_TO_STRING(value)); } const char *linphone_account_get_custom_param(const LinphoneAccount *account, const char *key) { + AccountLogScope logContextualizer(account); return L_STRING_TO_C(Account::toCpp(account)->getCustomParam(L_C_TO_STRING(key))); } @@ -83,14 +88,17 @@ void *linphone_account_get_user_data(LinphoneAccount *account) { } void linphone_account_set_custom_header(LinphoneAccount *account, const char *header_name, const char *header_value) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->setCustomheader(std::string(header_name), std::string(header_value)); } const char *linphone_account_get_custom_header(LinphoneAccount *account, const char *header_name) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getCustomHeader(std::string(header_name)); } void linphone_account_set_dependency(LinphoneAccount *account, LinphoneAccount *depends_on) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->setDependency(depends_on ? Account::toCpp(depends_on)->getSharedFromThis() : nullptr); } @@ -103,30 +111,36 @@ LinphoneAccount *linphone_account_get_dependency(LinphoneAccount *account) { } LinphoneCore *linphone_account_get_core(LinphoneAccount *account) { - return Account::toCpp(account)->getCore(); + return L_GET_C_BACK_PTR(Account::toCpp(account)->getCore()); } const LinphoneErrorInfo *linphone_account_get_error_info(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getErrorInfo(); } LinphoneAddress *linphone_account_get_contact_address(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return (Account::toCpp(account)->getContactAddress()) ? Account::toCpp(account)->getContactAddress()->toC() : NULL; } void linphone_account_set_contact_address(LinphoneAccount *account, const LinphoneAddress *addr) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->setContactAddress(Address::toCpp(addr)->getSharedFromThis()); } LinphoneRegistrationState linphone_account_get_state(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getState(); } void linphone_account_refresh_register(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->refreshRegister(); } void linphone_account_pause_register(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); Account::toCpp(account)->pauseRegister(); } @@ -135,6 +149,7 @@ LinphoneReason linphone_account_get_error(LinphoneAccount *account) { } LinphoneTransportType linphone_account_get_transport(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getTransport(); } @@ -147,10 +162,12 @@ bool_t linphone_account_avpf_enabled(LinphoneAccount *account) { } const LinphoneAuthInfo *linphone_account_find_auth_info(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->findAuthInfo(); } int linphone_account_get_unread_chat_message_count(LinphoneAccount *account) { + AccountLogScope logContextualizer(account); return Account::toCpp(account)->getUnreadChatMessageCount(); } @@ -181,7 +198,8 @@ void _linphone_account_notify_registration_state_changed(LinphoneAccount *accoun linphone_account_cbs_get_registration_state_changed, state, message); } -bool_t linphone_account_is_phone_number(BCTBX_UNUSED(const LinphoneAccount *account), const char *username) { +bool_t linphone_account_is_phone_number(const LinphoneAccount *account, const char *username) { + AccountLogScope logContextualizer(account); if (!username) return FALSE; const char *p; @@ -224,6 +242,7 @@ static char *replace_icp_with_plus(char *phone, const char *icp) { } char *linphone_account_normalize_phone_number(const LinphoneAccount *account, const char *username) { + AccountLogScope logContextualizer(account); char *result = NULL; std::shared_ptr<DialPlan> dialplan; char *nationnal_significant_number = NULL; @@ -332,6 +351,7 @@ static LinphoneAddress *_destroy_addr_if_not_sip(LinphoneAddress *addr) { } LinphoneAddress *linphone_account_normalize_sip_uri(LinphoneAccount *account, const char *username) { + AccountLogScope logContextualizer(account); enum_lookup_res_t *enumres = NULL; char *enum_domain = NULL; char *tmpurl; diff --git a/src/c-wrapper/api/c-alert-cbs.cpp b/src/c-wrapper/api/c-alert-cbs.cpp index 78accded3e39fd0760083d562e1f6a26afa2174d..66921c8b3d91aed73bc5ba5f462afcd78a9b06db 100644 --- a/src/c-wrapper/api/c-alert-cbs.cpp +++ b/src/c-wrapper/api/c-alert-cbs.cpp @@ -41,9 +41,9 @@ void linphone_alert_cbs_set_user_data(LinphoneAlertCbs *cbs, void *ud) { AlertCbs::toCpp(cbs)->setUserData(ud); } -void linphone_alert_cbs_set_on_terminated(LinphoneAlertCbs *cbs, LinphoneAlertCbsOnTerminatedCb on_terminated) { +void linphone_alert_cbs_set_terminated(LinphoneAlertCbs *cbs, LinphoneAlertCbsTerminatedCb on_terminated) { AlertCbs::toCpp(cbs)->setOnTerminated(on_terminated); } -LinphoneAlertCbsOnTerminatedCb linphone_alert_cbs_get_on_terminated(LinphoneAlertCbs *cbs) { +LinphoneAlertCbsTerminatedCb linphone_alert_cbs_get_terminated(LinphoneAlertCbs *cbs) { return AlertCbs::toCpp(cbs)->getOnTerminated(); } \ No newline at end of file diff --git a/src/c-wrapper/api/c-alert.cpp b/src/c-wrapper/api/c-alert.cpp index 3452b925cc7d12957b18068362ca0f066bec2dc4..7839562d60bc2d008aaf224bd85fd1bfe345bc5e 100644 --- a/src/c-wrapper/api/c-alert.cpp +++ b/src/c-wrapper/api/c-alert.cpp @@ -66,5 +66,5 @@ void linphone_alert_remove_callbacks(LinphoneAlert *alert, LinphoneAlertCbs *cbs Alert::toCpp(alert)->removeCallbacks(AlertCbs::toCpp(cbs)->getSharedFromThis()); } void linphone_alert_notify_on_terminated(LinphoneAlert *alert) { - LINPHONE_HYBRID_OBJECT_INVOKE_CBS_NO_ARG(Alert, Alert::toCpp(alert), linphone_alert_cbs_get_on_terminated); + LINPHONE_HYBRID_OBJECT_INVOKE_CBS_NO_ARG(Alert, Alert::toCpp(alert), linphone_alert_cbs_get_terminated); } \ No newline at end of file diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index cd2161e6285d9123b7f4208b756ac0285338b6cd..762b55e236970ca4e9237c6b65b47cba14decb3f 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -78,6 +78,7 @@ bool_t linphone_call_get_all_muted(const LinphoneCall *call) { } void linphone_call_set_ekt(const LinphoneCall *call, const MSEKTParametersSet *ekt_params) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setEkt(ekt_params); } @@ -173,6 +174,7 @@ LinphoneCore *linphone_call_get_core(const LinphoneCall *call) { } LinphoneCallState linphone_call_get_state(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return static_cast<LinphoneCallState>(Call::toCpp(call)->getState()); } @@ -252,91 +254,108 @@ int linphone_call_get_duration(const LinphoneCall *call) { } const LinphoneCallParams *linphone_call_get_current_params(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return L_GET_C_BACK_PTR(Call::toCpp(call)->getCurrentParams()); } const LinphoneCallParams *linphone_call_get_remote_params(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); const LinphonePrivate::MediaSessionParams *remoteParams = Call::toCpp(call)->getRemoteParams(); return remoteParams ? L_GET_C_BACK_PTR(remoteParams) : nullptr; } void linphone_call_enable_camera(LinphoneCall *call, bool_t enable) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->enableCamera(!!enable); } bool_t linphone_call_camera_enabled(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->cameraEnabled(); } LinphoneStatus linphone_call_take_video_snapshot(LinphoneCall *call, const char *file) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->takeVideoSnapshot(L_C_TO_STRING(file)); } LinphoneStatus linphone_call_take_preview_snapshot(LinphoneCall *call, const char *file) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->takePreviewSnapshot(L_C_TO_STRING(file)); } LinphoneReason linphone_call_get_reason(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getReason(); } const LinphoneErrorInfo *linphone_call_get_error_info(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getErrorInfo(); } const char *linphone_call_get_remote_user_agent(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return L_STRING_TO_C(Call::toCpp(call)->getRemoteUserAgent()); } const char *linphone_call_get_remote_contact(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return L_STRING_TO_C(Call::toCpp(call)->getRemoteContact()); } const char *linphone_call_get_authentication_token(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return L_STRING_TO_C(Call::toCpp(call)->getAuthenticationToken()); } bool_t linphone_call_get_authentication_token_verified(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getAuthenticationTokenVerified(); } void linphone_call_set_authentication_token_verified(LinphoneCall *call, bool_t verified) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setAuthenticationTokenVerified(!!verified); } void linphone_call_send_vfu_request(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->sendVfuRequest(); } void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void *ud) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setNextVideoFrameDecodedCallback(cb, ud); } void linphone_call_request_notify_next_video_frame_decoded(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->requestNotifyNextVideoFrameDecoded(); } LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return static_cast<LinphoneCallState>(Call::toCpp(call)->getTransferState()); } void linphone_call_zoom_video(LinphoneCall *call, float zoom_factor, float *cx, float *cy) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->zoomVideo(zoom_factor, cx, cy); } void linphone_call_zoom(LinphoneCall *call, float zoom_factor, float cx, float cy) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->zoomVideo(zoom_factor, cx, cy); } LinphoneStatus linphone_call_send_dtmf(LinphoneCall *call, char dtmf) { - if (!call) { - ms_warning("linphone_call_send_dtmf(): invalid call, canceling DTMF"); - return -1; - } + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->sendDtmf(dtmf); } LinphoneStatus linphone_call_send_dtmfs(LinphoneCall *call, const char *dtmfs) { + CallLogContextualizer logContextualizer(call); if (!call) { ms_warning("linphone_call_send_dtmfs(): invalid call, canceling DTMF sequence"); return -1; @@ -345,11 +364,13 @@ LinphoneStatus linphone_call_send_dtmfs(LinphoneCall *call, const char *dtmfs) { } void linphone_call_cancel_dtmfs(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); if (!call) return; Call::toCpp(call)->cancelDtmfs(); } bool_t linphone_call_is_in_conference(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return !!Call::toCpp(call)->isInConference(); } @@ -375,94 +396,117 @@ RtpTransport *linphone_call_get_meta_rtcp_transport(const LinphoneCall *call, in } LinphoneStatus linphone_call_pause(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->pause(); } LinphoneStatus linphone_call_resume(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->resume(); } LinphoneStatus linphone_call_terminate(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->terminate(); } LinphoneStatus linphone_call_terminate_with_error_info(LinphoneCall *call, const LinphoneErrorInfo *ei) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->terminate(ei); } LinphoneStatus linphone_call_redirect(LinphoneCall *call, const char *redirect_uri) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->redirect(redirect_uri); } LinphoneStatus linphone_call_redirect_to(LinphoneCall *call, LinphoneAddress *redirect_address) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->redirect(Address::toCpp(redirect_address)->getSharedFromThis()); } LinphoneStatus linphone_call_decline(LinphoneCall *call, LinphoneReason reason) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->decline(reason); } LinphoneStatus linphone_call_decline_with_error_info(LinphoneCall *call, const LinphoneErrorInfo *ei) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->decline(ei); } LinphoneStatus linphone_call_accept(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->accept(nullptr); } LinphoneStatus linphone_call_accept_with_params(LinphoneCall *call, const LinphoneCallParams *params) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->accept(params ? L_GET_CPP_PTR_FROM_C_OBJECT(params) : nullptr); } LinphoneStatus linphone_call_accept_early_media(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->acceptEarlyMedia(); } LinphoneStatus linphone_call_accept_early_media_with_params(LinphoneCall *call, const LinphoneCallParams *params) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->acceptEarlyMedia(params ? L_GET_CPP_PTR_FROM_C_OBJECT(params) : nullptr); } LinphoneStatus linphone_call_update(LinphoneCall *call, const LinphoneCallParams *params) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->update(params ? L_GET_CPP_PTR_FROM_C_OBJECT(params) : nullptr); } LinphoneStatus linphone_call_defer_update(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->deferUpdate(); } LinphoneStatus linphone_call_accept_update(LinphoneCall *call, const LinphoneCallParams *params) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->acceptUpdate(params ? L_GET_CPP_PTR_FROM_C_OBJECT(params) : nullptr); } LinphoneStatus linphone_call_transfer(LinphoneCall *call, const char *referTo) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->transfer(referTo); } LinphoneStatus linphone_call_transfer_to(LinphoneCall *call, LinphoneAddress *referTo) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->transfer(Address::toCpp(referTo)->getSharedFromThis()); } LinphoneStatus linphone_call_transfer_to_another(LinphoneCall *call, LinphoneCall *dest) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->transfer(Call::toCpp(dest)->getSharedFromThis()); } void *linphone_call_get_native_video_window_id(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getNativeVideoWindowId(); } void *linphone_call_create_native_video_window_id(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->createNativeVideoWindowId(); } void linphone_call_set_native_video_window_id(LinphoneCall *call, void *id) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setNativeVideoWindowId(id); } void linphone_call_enable_echo_cancellation(LinphoneCall *call, bool_t enable) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->enableEchoCancellation(!!enable); } bool_t linphone_call_echo_cancellation_enabled(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->echoCancellationEnabled(); } @@ -475,64 +519,79 @@ bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call) { } LinphoneChatRoom *linphone_call_get_chat_room(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); shared_ptr<LinphonePrivate::AbstractChatRoom> acr = Call::toCpp(call)->getChatRoom(); if (acr) return L_GET_C_BACK_PTR(acr); return nullptr; } float linphone_call_get_play_volume(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getPlayVolume(); } float linphone_call_get_record_volume(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getRecordVolume(); } float linphone_call_get_speaker_volume_gain(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getSpeakerVolumeGain(); } void linphone_call_set_speaker_volume_gain(LinphoneCall *call, float volume) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setSpeakerVolumeGain(volume); } float linphone_call_get_microphone_volume_gain(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getMicrophoneVolumeGain(); } void linphone_call_set_microphone_volume_gain(LinphoneCall *call, float volume) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setMicrophoneVolumeGain(volume); } bool_t linphone_call_get_speaker_muted(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getSpeakerMuted(); } void linphone_call_set_speaker_muted(LinphoneCall *call, bool_t muted) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setSpeakerMuted(!!muted); } bool_t linphone_call_get_microphone_muted(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getMicrophoneMuted(); } void linphone_call_set_microphone_muted(LinphoneCall *call, bool_t muted) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setMicrophoneMuted(!!muted); } float linphone_call_get_current_quality(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getCurrentQuality(); } float linphone_call_get_average_quality(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getAverageQuality(); } void linphone_call_start_recording(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->startRecording(); } void linphone_call_stop_recording(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->stopRecording(); } @@ -545,14 +604,17 @@ LinphonePlayer *linphone_call_get_player(LinphoneCall *call) { } bool_t linphone_call_media_in_progress(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->mediaInProgress(); } void linphone_call_ogl_render(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->oglRender(); } LinphoneStatus linphone_call_send_info_message(LinphoneCall *call, const LinphoneInfoMessage *info) { + CallLogContextualizer logContextualizer(call); SalBodyHandler *body_handler = sal_body_handler_from_content(linphone_info_message_get_content(info)); linphone_call_get_op(call)->setSentCustomHeaders(linphone_info_message_get_headers(info)); return linphone_call_get_op(call)->sendInfo(body_handler); @@ -575,10 +637,12 @@ LinphoneCallStats *linphone_call_get_text_stats(LinphoneCall *call) { } void linphone_call_add_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->addCallbacks(CallCbs::toCpp(cbs)->getSharedFromThis()); } void linphone_call_remove_callbacks(LinphoneCall *call, LinphoneCallCbs *cbs) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->removeCallbacks(CallCbs::toCpp(cbs)->getSharedFromThis()); } @@ -587,14 +651,17 @@ LinphoneCallCbs *linphone_call_get_current_callbacks(const LinphoneCall *call) { } const bctbx_list_t *linphone_call_get_callbacks_list(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return Call::toCpp(call)->getCCallbacksList(); } void linphone_call_set_params(LinphoneCall *call, const LinphoneCallParams *params) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setParams(L_GET_CPP_PTR_FROM_C_OBJECT(params)); } const LinphoneCallParams *linphone_call_get_params(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); return L_GET_C_BACK_PTR(Call::toCpp(call)->getParams()); } @@ -608,6 +675,7 @@ LinphoneCall *linphone_call_ref(LinphoneCall *call) { } void linphone_call_unref(LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->unref(); } @@ -669,18 +737,21 @@ bool_t linphone_call_is_op_configured(const LinphoneCall *call) { } void linphone_call_set_input_audio_device(LinphoneCall *call, LinphoneAudioDevice *audio_device) { + CallLogContextualizer logContextualizer(call); if (audio_device) { Call::toCpp(call)->setInputAudioDevice(LinphonePrivate::AudioDevice::getSharedFromThis(audio_device)); } } void linphone_call_set_output_audio_device(LinphoneCall *call, LinphoneAudioDevice *audio_device) { + CallLogContextualizer logContextualizer(call); if (audio_device) { Call::toCpp(call)->setOutputAudioDevice(LinphonePrivate::AudioDevice::getSharedFromThis(audio_device)); } } const LinphoneAudioDevice *linphone_call_get_input_audio_device(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); auto audioDevice = Call::toCpp(call)->getInputAudioDevice(); if (audioDevice) { return audioDevice->toC(); @@ -688,6 +759,7 @@ const LinphoneAudioDevice *linphone_call_get_input_audio_device(const LinphoneCa return NULL; } const LinphoneAudioDevice *linphone_call_get_output_audio_device(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); auto audioDevice = Call::toCpp(call)->getOutputAudioDevice(); if (audioDevice) { return audioDevice->toC(); @@ -696,15 +768,18 @@ const LinphoneAudioDevice *linphone_call_get_output_audio_device(const LinphoneC } void linphone_call_set_video_source(LinphoneCall *call, const LinphoneVideoSourceDescriptor *descriptor) { + CallLogContextualizer logContextualizer(call); Call::toCpp(call)->setVideoSource(VideoSourceDescriptor::toCpp(descriptor)->getSharedFromThis()); } const LinphoneVideoSourceDescriptor *linphone_call_get_video_source(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); auto descriptor = Call::toCpp(call)->getVideoSource(); return descriptor == nullptr ? NULL : descriptor->toC(); } void linphone_call_confirm_go_clear(const LinphoneCall *call) { + CallLogContextualizer logContextualizer(call); #ifdef HAVE_GOCLEAR Call::toCpp(call)->confirmGoClear(); #else // HAVE_GOCLEAR diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index 6e2700d4a270a12a9c4db23492893094a1b080c8..bd755b6b3be1dfc6a60ec7f88f2d7ff35dc0914e 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -88,6 +88,7 @@ LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg) { } void linphone_chat_message_unref(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); belle_sip_object_unref(msg); } @@ -269,6 +270,7 @@ bool_t linphone_chat_message_is_forward(LinphoneChatMessage *msg) { } const char *linphone_chat_message_get_forward_info(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getForwardInfo()); } @@ -281,6 +283,7 @@ const char *linphone_chat_message_get_reply_message_id(LinphoneChatMessage *msg) } const LinphoneAddress *linphone_chat_message_get_reply_message_sender_address(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); if (L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isReply()) { const auto &address = L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getReplyToSenderAddress(); if (address && address->isValid()) { @@ -291,6 +294,7 @@ const LinphoneAddress *linphone_chat_message_get_reply_message_sender_address(Li } LinphoneChatMessage *linphone_chat_message_get_reply_message(LinphoneChatMessage *message) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(message); if (linphone_chat_message_is_reply(message)) { shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(message)->getReplyToMessage(); if (!cppPtr) return NULL; @@ -300,42 +304,51 @@ LinphoneChatMessage *linphone_chat_message_get_reply_message(LinphoneChatMessage } bool_t linphone_chat_message_is_ephemeral(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isEphemeral(); } long linphone_chat_message_get_ephemeral_lifetime(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getEphemeralLifetime(); } time_t linphone_chat_message_get_ephemeral_expire_time(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getEphemeralExpireTime(); } void linphone_chat_message_add_custom_header(LinphoneChatMessage *msg, const char *header_name, const char *header_value) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_PRIVATE_FROM_C_OBJECT(msg)->addSalCustomHeader(L_C_TO_STRING(header_name), L_C_TO_STRING(header_value)); } void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_PRIVATE_FROM_C_OBJECT(msg)->removeSalCustomHeader(L_C_TO_STRING(header_name)); } const char *linphone_chat_message_get_custom_header(const LinphoneChatMessage *msg, const char *header_name) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); msg->cache.customHeaderValue = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getSalCustomHeaderValue(L_C_TO_STRING(header_name)); return L_STRING_TO_C(msg->cache.customHeaderValue); } const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getErrorInfo(); } bool_t linphone_chat_message_get_to_be_stored(const LinphoneChatMessage *message) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(message); return L_GET_CPP_PTR_FROM_C_OBJECT(message)->getToBeStored(); } void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *message, bool_t to_be_stored) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(message); L_GET_CPP_PTR_FROM_C_OBJECT(message)->setToBeStored(!!to_be_stored); } @@ -344,26 +357,32 @@ void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *message, bool_t // ============================================================================= void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_CPP_PTR_FROM_C_OBJECT(msg)->cancelFileTransfer(); } void linphone_chat_message_send(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send(); } void linphone_chat_message_resend(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send(); } void linphone_chat_message_resend_2(LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send(); } LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t character) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return ((LinphoneStatus)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->putCharacter(character)); } void linphone_chat_message_add_file_content(LinphoneChatMessage *msg, LinphoneContent *c_content) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); LinphonePrivate::FileContent *fileContent = new LinphonePrivate::FileContent(); LinphonePrivate::Content *content = L_GET_CPP_PTR_FROM_C_OBJECT(c_content); @@ -395,6 +414,7 @@ void linphone_chat_message_add_file_content(LinphoneChatMessage *msg, LinphoneCo } void linphone_chat_message_add_text_content(LinphoneChatMessage *msg, const char *text) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); LinphonePrivate::Content *content = new LinphonePrivate::Content(); LinphonePrivate::ContentType contentType = LinphonePrivate::ContentType::PlainText; content->setContentType(contentType); @@ -403,6 +423,7 @@ void linphone_chat_message_add_text_content(LinphoneChatMessage *msg, const char } void linphone_chat_message_add_utf8_text_content(LinphoneChatMessage *msg, const char *text) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); LinphonePrivate::Content *content = new LinphonePrivate::Content(); LinphonePrivate::ContentType contentType = LinphonePrivate::ContentType::PlainText; content->setContentType(contentType); @@ -411,6 +432,7 @@ void linphone_chat_message_add_utf8_text_content(LinphoneChatMessage *msg, const } void linphone_chat_message_add_content(LinphoneChatMessage *msg, LinphoneContent *c_content) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); if (linphone_content_is_voice_recording(c_content)) { linphone_content_ref(c_content); LinphonePrivate::Content *content = @@ -427,20 +449,24 @@ void linphone_chat_message_add_content(LinphoneChatMessage *msg, LinphoneContent } void linphone_chat_message_remove_content(LinphoneChatMessage *msg, LinphoneContent *content) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); L_GET_CPP_PTR_FROM_C_OBJECT(msg)->removeContent(L_GET_CPP_PTR_FROM_C_OBJECT(content)); } const bctbx_list_t *linphone_chat_message_get_contents(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); if (msg->cache.contents) bctbx_free(msg->cache.contents); msg->cache.contents = L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getContents()); return msg->cache.contents; } bool_t linphone_chat_message_has_text_content(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_PRIVATE_FROM_C_OBJECT(msg)->hasTextContent(); } const char *linphone_chat_message_get_text_content(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); const LinphonePrivate::Content *content = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getTextContent(); if (content->isEmpty()) return nullptr; msg->cache.textContentBody = content->getBodyAsString(); @@ -448,20 +474,24 @@ const char *linphone_chat_message_get_text_content(const LinphoneChatMessage *ms } bool_t linphone_chat_message_has_conference_invitation_content(const LinphoneChatMessage *message) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(message); return L_GET_PRIVATE_FROM_C_OBJECT(message)->hasConferenceInvitationContent(); } bool_t linphone_chat_message_is_file_transfer_in_progress(const LinphoneChatMessage *msg) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isFileTransferInProgress(); } bctbx_list_t *linphone_chat_message_get_participants_by_imdn_state(const LinphoneChatMessage *msg, LinphoneChatMessageState state) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST( L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getParticipantsByImdnState(LinphonePrivate::ChatMessage::State(state))); } bool_t linphone_chat_message_download_content(LinphoneChatMessage *msg, LinphoneContent *c_content) { + LinphonePrivate::ChatMessageLogContextualizer logContextualizer(msg); LinphonePrivate::Content *content = L_GET_CPP_PTR_FROM_C_OBJECT(c_content); if (!content->isFileTransfer()) { if (content->isFile()) { @@ -615,4 +645,4 @@ LinphoneChatMessageReaction *linphone_chat_message_create_reaction(LinphoneChatM LinphonePrivate::ChatMessageReaction::toCpp(reaction)->setChatRoom(chatRoom); return reaction; -} \ No newline at end of file +} diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index dd32f2ce91f0ac83bc58127b1fc7417151cbf152..fab2217ea749370c85fabb2994e0cc87b934e13f 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -83,10 +83,12 @@ const LinphoneChatRoomParams *linphone_chat_room_get_current_params(const Linpho // Deprecated void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(msg)->send(); } bool_t linphone_chat_room_is_remote_composing(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->isRemoteComposing(); } @@ -117,6 +119,7 @@ const LinphoneAddress *linphone_chat_room_get_local_address(LinphoneChatRoom *cr } LinphoneChatMessage *linphone_chat_room_create_empty_message(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(); LinphoneChatMessage *object = L_INIT(ChatMessage); L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr); @@ -124,6 +127,7 @@ LinphoneChatMessage *linphone_chat_room_create_empty_message(LinphoneChatRoom *c } LinphoneChatMessage *linphone_chat_room_create_message_from_utf8(LinphoneChatRoom *cr, const char *message) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessageFromUtf8(L_C_TO_STRING(message)); LinphoneChatMessage *object = L_INIT(ChatMessage); @@ -133,6 +137,7 @@ LinphoneChatMessage *linphone_chat_room_create_message_from_utf8(LinphoneChatRoo // Deprecated LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(L_C_TO_STRING(message)); LinphoneChatMessage *object = L_INIT(ChatMessage); @@ -142,6 +147,7 @@ LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, con LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, LinphoneContent *initial_content) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); LinphoneChatMessage *msg = linphone_chat_room_create_empty_message(cr); linphone_chat_message_add_file_content(msg, initial_content); return msg; @@ -155,6 +161,7 @@ LinphoneChatMessage *linphone_chat_room_create_message_2(LinphoneChatRoom *cr, time_t time, BCTBX_UNUSED(bool_t is_read), BCTBX_UNUSED(bool_t is_incoming)) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); LinphoneChatMessage *msg = linphone_chat_room_create_message(cr, message); linphone_chat_message_set_external_body_url(msg, external_body_url ? ms_strdup(external_body_url) : NULL); @@ -167,6 +174,7 @@ LinphoneChatMessage *linphone_chat_room_create_message_2(LinphoneChatRoom *cr, } LinphoneChatMessage *linphone_chat_room_create_forward_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createForwardMessage(L_GET_CPP_PTR_FROM_C_OBJECT(msg)); LinphoneChatMessage *object = L_INIT(ChatMessage); @@ -175,6 +183,7 @@ LinphoneChatMessage *linphone_chat_room_create_forward_message(LinphoneChatRoom } LinphoneChatMessage *linphone_chat_room_create_reply_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createReplyMessage(L_GET_CPP_PTR_FROM_C_OBJECT(msg)); LinphoneChatMessage *object = L_INIT(ChatMessage); @@ -184,6 +193,7 @@ LinphoneChatMessage *linphone_chat_room_create_reply_message(LinphoneChatRoom *c LinphoneChatMessage *linphone_chat_room_create_voice_recording_message(LinphoneChatRoom *cr, LinphoneRecorder *recorder) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); LinphoneChatMessage *chat_message = linphone_chat_room_create_empty_message(cr); LinphoneContent *c_content = linphone_recorder_create_content(recorder); @@ -209,14 +219,17 @@ void linphone_chat_room_receive_chat_message(BCTBX_UNUSED(LinphoneChatRoom *cr), } uint32_t linphone_chat_room_get_char(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChar(); } void linphone_chat_room_compose(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->compose(); } LinphoneCall *linphone_chat_room_get_call(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCall(); if (call) return call->toC(); return nullptr; @@ -227,59 +240,73 @@ void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call) { } void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->markAsRead(); } void linphone_chat_room_set_ephemeral_mode(LinphoneChatRoom *cr, LinphoneChatRoomEphemeralMode mode) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->setEphemeralMode( static_cast<LinphonePrivate::AbstractChatRoom::EphemeralMode>(mode), true); } LinphoneChatRoomEphemeralMode linphone_chat_room_get_ephemeral_mode(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return static_cast<LinphoneChatRoomEphemeralMode>(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getEphemeralMode()); } void linphone_chat_room_enable_ephemeral(LinphoneChatRoom *cr, bool_t ephem) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->enableEphemeral(!!ephem, true); } bool_t linphone_chat_room_ephemeral_enabled(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->ephemeralEnabled(); } void linphone_chat_room_set_ephemeral_lifetime(LinphoneChatRoom *cr, long time) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->setEphemeralLifetime(time, true); } long linphone_chat_room_get_ephemeral_lifetime(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getEphemeralLifetime(); } bool_t linphone_chat_room_ephemeral_supported_by_all_participants(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->ephemeralSupportedByAllParticipants(); } int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getUnreadChatMessageCount(); } int linphone_chat_room_get_history_size(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChatMessageCount(); } bool_t linphone_chat_room_is_empty(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->isEmpty(); } void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->deleteMessageFromHistory(L_GET_CPP_PTR_FROM_C_OBJECT(msg)); } void linphone_chat_room_delete_history(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->deleteHistory(); } bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); list<shared_ptr<LinphonePrivate::ChatMessage>> chatMessages; for (auto &event : L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistoryRange(startm, endm)) chatMessages.push_back( @@ -289,34 +316,42 @@ bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int sta } bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr, int nb_message) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return linphone_chat_room_get_history_range(cr, 0, nb_message); } bctbx_list_t *linphone_chat_room_get_unread_history(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getUnreadChatMessages()); } bctbx_list_t *linphone_chat_room_get_history_range_message_events(LinphoneChatRoom *cr, int startm, int endm) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistoryRange(startm, endm)); } bctbx_list_t *linphone_chat_room_get_history_message_events(LinphoneChatRoom *cr, int nb_events) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistory(nb_events)); } bctbx_list_t *linphone_chat_room_get_history_events(LinphoneChatRoom *cr, int nb_events) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistory(nb_events)); } bctbx_list_t *linphone_chat_room_get_history_range_events(LinphoneChatRoom *cr, int begin, int end) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistoryRange(begin, end)); } int linphone_chat_room_get_history_events_size(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistorySize(); } LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastChatMessageInHistory(); if (!cppPtr) return nullptr; @@ -324,6 +359,7 @@ LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChat } LinphoneChatMessage *linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findChatMessage(message_id); if (!cppPtr) return nullptr; @@ -331,36 +367,44 @@ LinphoneChatMessage *linphone_chat_room_find_message(LinphoneChatRoom *cr, const } LinphoneChatRoomState linphone_chat_room_get_state(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return linphone_conference_state_to_chat_room_state( static_cast<LinphoneConferenceState>(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getState())); } bool_t linphone_chat_room_has_been_left(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->hasBeenLeft(); } bool_t linphone_chat_room_is_read_only(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->isReadOnly(); } time_t linphone_chat_room_get_creation_time(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCreationTime(); } time_t linphone_chat_room_get_last_update_time(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastUpdateTime(); } void linphone_chat_room_add_participant(LinphoneChatRoom *cr, LinphoneAddress *addr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant(LinphonePrivate::Address::toCpp(addr)->getSharedFromThis()); } bool_t linphone_chat_room_add_participants(LinphoneChatRoom *cr, const bctbx_list_t *addresses) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipants( LinphonePrivate::Utils::bctbxListToCppSharedPtrList<LinphoneAddress, LinphonePrivate::Address>(addresses)); } LinphoneParticipant *linphone_chat_room_find_participant(const LinphoneChatRoom *cr, LinphoneAddress *addr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); std::shared_ptr<LinphonePrivate::Participant> participant = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findParticipant(LinphonePrivate::Address::toCpp(addr)->getSharedFromThis()); if (participant) { @@ -370,18 +414,22 @@ LinphoneParticipant *linphone_chat_room_find_participant(const LinphoneChatRoom } bool_t linphone_chat_room_can_handle_participants(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->canHandleParticipants(); } LinphoneChatRoomCapabilitiesMask linphone_chat_room_get_capabilities(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities(); } bool_t linphone_chat_room_has_capability(const LinphoneChatRoom *cr, int mask) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return static_cast<bool_t>(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & mask); } const LinphoneAddress *linphone_chat_room_get_conference_address(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); const auto &confAddress = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress(); if (confAddress && confAddress->isValid()) { return confAddress->toC(); @@ -391,6 +439,7 @@ const LinphoneAddress *linphone_chat_room_get_conference_address(const LinphoneC } LinphoneParticipant *linphone_chat_room_get_me(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); std::shared_ptr<LinphonePrivate::Participant> me = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMe(); if (me) { return me->toC(); @@ -399,31 +448,38 @@ LinphoneParticipant *linphone_chat_room_get_me(const LinphoneChatRoom *cr) { } int linphone_chat_room_get_nb_participants(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getParticipantCount(); } bctbx_list_t *linphone_chat_room_get_participants(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return LinphonePrivate::Participant::getCListFromCppList(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getParticipants()); } const char *linphone_chat_room_get_subject(const LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getSubject()); } LinphoneChatRoomSecurityLevel linphone_chat_room_get_security_level(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); return (LinphoneChatRoomSecurityLevel)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getSecurityLevel(); } void linphone_chat_room_leave(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->leave(); } void linphone_chat_room_remove_participant(LinphoneChatRoom *cr, LinphoneParticipant *participant) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->removeParticipant( LinphonePrivate::Participant::toCpp(participant)->getSharedFromThis()); } void linphone_chat_room_remove_participants(LinphoneChatRoom *cr, const bctbx_list_t *participants) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->removeParticipants( LinphonePrivate::Participant::getCppListFromCList(participants)); } @@ -431,15 +487,18 @@ void linphone_chat_room_remove_participants(LinphoneChatRoom *cr, const bctbx_li void linphone_chat_room_set_participant_admin_status(LinphoneChatRoom *cr, LinphoneParticipant *participant, bool_t isAdmin) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); shared_ptr<LinphonePrivate::Participant> p = LinphonePrivate::Participant::toCpp(participant)->getSharedFromThis(); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->setParticipantAdminStatus(p, !!isAdmin); } void linphone_chat_room_set_subject(LinphoneChatRoom *cr, const char *subject) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->setSubject(L_C_TO_STRING(subject)); } const bctbx_list_t *linphone_chat_room_get_composing_addresses(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); list<shared_ptr<LinphonePrivate::Address>> addresses = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getComposingAddresses(); cr->composingAddresses = LinphonePrivate::Utils::listToCBctbxList<LinphoneAddress, LinphonePrivate::Address>(addresses); @@ -722,6 +781,7 @@ LinphoneChatRoom *linphone_chat_room_ref(LinphoneChatRoom *cr) { } void linphone_chat_room_unref(LinphoneChatRoom *cr) { + LinphonePrivate::ChatRoomLogScope logContextualizer(cr); belle_sip_object_unref(cr); } diff --git a/src/c-wrapper/api/c-conference-scheduler.cpp b/src/c-wrapper/api/c-conference-scheduler.cpp index 09d148152cdae7f28fb828f7efbe23e02464e4a6..6d8c383cca90a54ff4d7944539da60bb6dd5fa8a 100644 --- a/src/c-wrapper/api/c-conference-scheduler.cpp +++ b/src/c-wrapper/api/c-conference-scheduler.cpp @@ -36,6 +36,7 @@ LinphoneConferenceScheduler *linphone_conference_scheduler_ref(LinphoneConferenc } void linphone_conference_scheduler_unref(LinphoneConferenceScheduler *conference_scheduler) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); ConferenceScheduler::toCpp(conference_scheduler)->unref(); } @@ -45,6 +46,7 @@ LinphoneCore *linphone_conference_scheduler_get_core(const LinphoneConferenceSch void linphone_conference_scheduler_set_account(LinphoneConferenceScheduler *conference_scheduler, LinphoneAccount *account) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); ConferenceScheduler::toCpp(conference_scheduler) ->setAccount(LinphonePrivate::Account::toCpp(account)->getSharedFromThis()); } @@ -56,23 +58,27 @@ LinphoneAccount *linphone_conference_scheduler_get_account(const LinphoneConfere const LinphoneConferenceInfo * linphone_conference_scheduler_get_info(const LinphoneConferenceScheduler *conference_scheduler) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); return ConferenceScheduler::toCpp(conference_scheduler)->getInfo()->toC(); } void linphone_conference_scheduler_set_info(LinphoneConferenceScheduler *conference_scheduler, LinphoneConferenceInfo *conference_info) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); ConferenceScheduler::toCpp(conference_scheduler) ->setInfo(ConferenceInfo::toCpp(conference_info)->getSharedFromThis()); } void linphone_conference_scheduler_cancel_conference(LinphoneConferenceScheduler *conference_scheduler, LinphoneConferenceInfo *conference_info) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); ConferenceScheduler::toCpp(conference_scheduler) ->cancelConference(ConferenceInfo::toCpp(conference_info)->getSharedFromThis()); } void linphone_conference_scheduler_send_invitations(LinphoneConferenceScheduler *conference_scheduler, LinphoneChatRoomParams *chat_room_params) { + ConferenceSchedulerLogContextualizer logContextualizer(conference_scheduler); ConferenceScheduler::toCpp(conference_scheduler) ->sendInvitations(ChatRoomParams::toCpp(chat_room_params)->getSharedFromThis()); } diff --git a/src/c-wrapper/api/c-conference.cpp b/src/c-wrapper/api/c-conference.cpp index 9a24d7995d9f1211d5aae67be5855b92a29dd89b..551cc2c0ae0b4a9eca8c7fa6ca12a0ae5e287024 100644 --- a/src/c-wrapper/api/c-conference.cpp +++ b/src/c-wrapper/api/c-conference.cpp @@ -150,6 +150,7 @@ LinphoneCore *linphone_conference_get_core(const LinphoneConference *conference) } void linphone_conference_set_conference_address(LinphoneConference *conference, LinphoneAddress *address) { + LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); std::shared_ptr<LinphonePrivate::MediaConference::RemoteConference> remoteConference = dynamic_pointer_cast<LinphonePrivate::MediaConference::RemoteConference>( MediaConference::Conference::toCpp(conference)->getSharedFromThis()); @@ -160,6 +161,7 @@ void linphone_conference_set_conference_address(LinphoneConference *conference, } const LinphoneAddress *linphone_conference_get_conference_address(const LinphoneConference *conference) { + // LinphonePrivate::MediaConference::ConferenceLogContextualizer logContextualizer(conference); const auto &address = MediaConference::Conference::toCpp(conference)->getConferenceAddress(); return address && address->isValid() ? address->toC() : nullptr; } diff --git a/src/c-wrapper/api/c-event.cpp b/src/c-wrapper/api/c-event.cpp index 068054289f339aa8e40a74d91a5b7013b4b38100..4f7c15a2b978d4664ca226b733cd8e014fd97f52 100644 --- a/src/c-wrapper/api/c-event.cpp +++ b/src/c-wrapper/api/c-event.cpp @@ -67,6 +67,7 @@ LinphoneEvent *_linphone_core_create_publish( LinphoneEvent * linphone_core_create_publish(LinphoneCore *lc, LinphoneAddress *resource, const char *event, int expires) { + CoreLogContextualizer logContextualizer(lc); return (new EventPublish(L_GET_CPP_PTR_FROM_C_OBJECT(lc), NULL, Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event), expires)) ->toC(); @@ -74,6 +75,7 @@ linphone_core_create_publish(LinphoneCore *lc, LinphoneAddress *resource, const LinphoneEvent *linphone_core_publish( LinphoneCore *lc, LinphoneAddress *resource, const char *event, int expires, const LinphoneContent *body) { + CoreLogContextualizer logContextualizer(lc); int err; auto ev = (new EventPublish(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event), expires)); @@ -87,12 +89,14 @@ LinphoneEvent *linphone_core_publish( } LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, LinphoneAddress *resource, const char *event) { + CoreLogContextualizer logContextualizer(lc); return (new EventPublish(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event))) ->toC(); } LinphoneEvent *linphone_core_create_notify(LinphoneCore *lc, LinphoneAddress *resource, const char *event) { + CoreLogContextualizer logContextualizer(lc); return (new EventSubscribe(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event))) ->toC(); @@ -100,6 +104,7 @@ LinphoneEvent *linphone_core_create_notify(LinphoneCore *lc, LinphoneAddress *re LinphoneEvent * linphone_core_create_subscribe(LinphoneCore *lc, LinphoneAddress *resource, const char *event, int expires) { + CoreLogContextualizer logContextualizer(lc); return (new EventSubscribe(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event), expires)) ->toC(); @@ -107,6 +112,7 @@ linphone_core_create_subscribe(LinphoneCore *lc, LinphoneAddress *resource, cons LinphoneEvent *linphone_core_subscribe( LinphoneCore *lc, LinphoneAddress *resource, const char *event, int expires, const LinphoneContent *body) { + CoreLogContextualizer logContextualizer(lc); auto ev = new EventSubscribe(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), L_C_TO_STRING(event), expires); ev->setUnrefWhenTerminated(true); @@ -116,6 +122,7 @@ LinphoneEvent *linphone_core_subscribe( LinphoneEvent *linphone_core_create_subscribe_2( LinphoneCore *lc, LinphoneAddress *resource, LinphoneProxyConfig *cfg, const char *event, int expires) { + CoreLogContextualizer logContextualizer(lc); return (new EventSubscribe(L_GET_CPP_PTR_FROM_C_OBJECT(lc), Address::toCpp(resource)->getSharedFromThis(), cfg, L_C_TO_STRING(event), expires)) ->toC(); @@ -231,6 +238,7 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s } void linphone_event_unpublish(LinphoneEvent *lev) { + EventLogScope logContextualizer(lev); Event::toCpp(lev)->unpublish(); } @@ -247,6 +255,7 @@ const bctbx_list_t *linphone_event_get_callbacks_list(const LinphoneEvent *ev) { // ============================================================================= LinphoneStatus linphone_event_send_subscribe(LinphoneEvent *linphone_event, const LinphoneContent *body) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_send_subscribe"); @@ -256,6 +265,7 @@ LinphoneStatus linphone_event_send_subscribe(LinphoneEvent *linphone_event, cons } LinphoneStatus linphone_event_update_subscribe(LinphoneEvent *linphone_event, const LinphoneContent *body) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_update_subscribe"); @@ -265,6 +275,7 @@ LinphoneStatus linphone_event_update_subscribe(LinphoneEvent *linphone_event, co } LinphoneStatus linphone_event_refresh_subscribe(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_refresh_subscribe"); @@ -274,6 +285,7 @@ LinphoneStatus linphone_event_refresh_subscribe(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_accept_subscription(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_accept_subscription"); @@ -283,6 +295,7 @@ LinphoneStatus linphone_event_accept_subscription(LinphoneEvent *linphone_event) } LinphoneStatus linphone_event_deny_subscription(LinphoneEvent *linphone_event, LinphoneReason reason) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_deny_subscription"); @@ -292,6 +305,7 @@ LinphoneStatus linphone_event_deny_subscription(LinphoneEvent *linphone_event, L } LinphoneStatus linphone_event_notify(LinphoneEvent *linphone_event, const LinphoneContent *body) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_notify"); @@ -301,6 +315,7 @@ LinphoneStatus linphone_event_notify(LinphoneEvent *linphone_event, const Linpho } LinphoneStatus linphone_event_send_publish(LinphoneEvent *linphone_event, const LinphoneContent *body) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_send_publish"); @@ -310,6 +325,7 @@ LinphoneStatus linphone_event_send_publish(LinphoneEvent *linphone_event, const } LinphoneStatus linphone_event_update_publish(LinphoneEvent *linphone_event, const LinphoneContent *body) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_update_publish"); @@ -319,6 +335,7 @@ LinphoneStatus linphone_event_update_publish(LinphoneEvent *linphone_event, cons } LinphoneStatus linphone_event_refresh_publish(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_refresh_publish"); @@ -328,6 +345,7 @@ LinphoneStatus linphone_event_refresh_publish(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_accept_publish(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_accept_publish"); @@ -337,6 +355,7 @@ LinphoneStatus linphone_event_accept_publish(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_deny_publish(LinphoneEvent *linphone_event, LinphoneReason reason) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_deny_publish"); @@ -346,6 +365,7 @@ LinphoneStatus linphone_event_deny_publish(LinphoneEvent *linphone_event, Linpho } void linphone_event_pause_publish(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_pause_publish"); @@ -355,14 +375,17 @@ void linphone_event_pause_publish(LinphoneEvent *linphone_event) { } LinphoneReason linphone_event_get_reason(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getReason(); } const LinphoneErrorInfo *linphone_event_get_error_info(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getErrorInfo(); } LinphoneSubscriptionState linphone_event_get_subscription_state(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<const EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_get_subscription_state"); @@ -372,6 +395,7 @@ LinphoneSubscriptionState linphone_event_get_subscription_state(const LinphoneEv } LinphonePublishState linphone_event_get_publish_state(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_publish = dynamic_cast<const EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_get_publish_state"); @@ -381,6 +405,7 @@ LinphonePublishState linphone_event_get_publish_state(const LinphoneEvent *linph } LinphoneSubscriptionDir linphone_event_get_subscription_dir(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_get_subscription_dir"); @@ -399,38 +424,47 @@ bool_t linphone_event_is_out_of_dialog_op(const LinphoneEvent *linphone_event) { } void linphone_event_add_custom_header(LinphoneEvent *linphone_event, const char *name, const char *value) { + EventLogScope logContextualizer(linphone_event); Event::toCpp(linphone_event)->addCustomHeader(L_C_TO_STRING(name), L_C_TO_STRING(value)); } void linphone_event_remove_custom_header(LinphoneEvent *linphone_event, const char *name) { + EventLogScope logContextualizer(linphone_event); Event::toCpp(linphone_event)->removeCustomHeader(L_C_TO_STRING(name)); } const char *linphone_event_get_custom_header(LinphoneEvent *linphone_event, const char *name) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getCustomHeaderCstr(L_C_TO_STRING(name)); } void linphone_event_terminate(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); Event::toCpp(linphone_event)->terminate(); } const char *linphone_event_get_name(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return L_STRING_TO_C(Event::toCpp(linphone_event)->getName()); } const LinphoneAddress *linphone_event_get_from(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getFrom()->toC(); } const LinphoneAddress *linphone_event_get_to(const LinphoneEvent *lev) { + EventLogScope logContextualizer(lev); return Event::toCpp(lev)->getTo()->toC(); } const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getResource()->toC(); } const LinphoneAddress *linphone_event_get_remote_contact(const LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getRemoteContact()->toC(); } @@ -460,6 +494,7 @@ LinphoneEvent *linphone_event_ref(LinphoneEvent *linphone_event) { } void linphone_event_unref(LinphoneEvent *linphone_event) { + EventLogScope logContextualizer(linphone_event); Event::toCpp(linphone_event)->unref(); } diff --git a/src/call/call.h b/src/call/call.h index 43b697b7fd98d44eeef316bd7d19172b9124fa3a..21627614e3a5140013ace15a1cc1c7f040e5ccae 100644 --- a/src/call/call.h +++ b/src/call/call.h @@ -343,6 +343,14 @@ private: void configureSoundCardsFromCore(const MediaSessionParams *msp); }; +class CallLogContextualizer : protected CoreLogContextualizer { +public: + CallLogContextualizer(const Call &call) : CoreLogContextualizer(call) { + } + CallLogContextualizer(const LinphoneCall *call) : CoreLogContextualizer(*Call::toCpp(call)) { + } +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_CALL_CALL_H_ diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 0f6450d93a6814ffda10e8e14a9f81bd2bfceadd..528c051a36c2da9a68d3a6514c13c4bda1571251 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -1855,4 +1855,8 @@ std::ostream &operator<<(std::ostream &lhs, ChatMessage::State e) { return lhs; } +ChatMessageLogContextualizer::ChatMessageLogContextualizer(const LinphoneChatMessage *msg) + : CoreLogContextualizer(*L_GET_CPP_PTR_FROM_C_OBJECT(msg)) { +} + LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/chat-message.h b/src/chat/chat-message/chat-message.h index 6f33a2946e61888aa5118cb62292549bb5d3f79e..22813192d20598e56232285aef4af76c173f21f2 100644 --- a/src/chat/chat-message/chat-message.h +++ b/src/chat/chat-message/chat-message.h @@ -178,6 +178,11 @@ private: std::ostream &operator<<(std::ostream &lhs, ChatMessage::State e); +class ChatMessageLogContextualizer : CoreLogContextualizer { +public: + ChatMessageLogContextualizer(const LinphoneChatMessage *msg); +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_CHAT_MESSAGE_H_ diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 238443a2b64d8359e083744ce174af04ba034f70..563e5670372fa5d8ba08fbca5e7a9fc984ca530a 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -887,4 +887,8 @@ const string &ChatRoom::getUtf8Subject() const { return getConference()->getUtf8Subject(); } +ChatRoomLogScope::ChatRoomLogScope(const LinphoneChatRoom *cr) + : CoreLogContextualizer(*L_GET_CPP_PTR_FROM_C_OBJECT(cr)) { +} + LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index 7b60175bd83a9427766dbd703fce9b3e895e4667..ad06d6483a9c25512b762aa5969779748709fc4d 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -131,6 +131,11 @@ private: L_DISABLE_COPY(ChatRoom); }; +class ChatRoomLogScope : CoreLogContextualizer { +public: + ChatRoomLogScope(const LinphoneChatRoom *cr); +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_CHAT_ROOM_H_ diff --git a/src/chat/encryption/lime-x3dh-encryption-engine.cpp b/src/chat/encryption/lime-x3dh-encryption-engine.cpp index 4b043002f12d2cdcf48dee92c3cd4dbbada569f2..4a6ebb602cab597c1a9e2e0bd5f32699e1a0e189 100644 --- a/src/chat/encryption/lime-x3dh-encryption-engine.cpp +++ b/src/chat/encryption/lime-x3dh-encryption-engine.cpp @@ -1036,7 +1036,7 @@ void LimeX3dhEncryptionEngine::onAccountRegistrationStateChanged(std::shared_ptr const std::shared_ptr<Address> &identityAddress = account->getContactAddress(); string localDeviceId = identityAddress->asStringUriOnly(); - LinphoneCore *lc = account->getCore(); + LinphoneCore *lc = L_GET_C_BACK_PTR(account->getCore()); lInfo() << "[LIME] Load lime user for device " << localDeviceId << " with server URL [" << accountLimeServerUrl << "]"; @@ -1076,7 +1076,7 @@ void LimeX3dhEncryptionEngine::onServerUrlChanged(const std::shared_ptr<Account> } string localDeviceId = contactAddress->asStringUriOnly(); - LinphoneCore *lc = account->getCore(); + LinphoneCore *lc = L_GET_C_BACK_PTR(account->getCore()); lInfo() << "[LIME] Trying to update lime user for device " << localDeviceId << " with server URL [" << accountLimeServerUrl << "]"; diff --git a/src/conference/conference-params.cpp b/src/conference/conference-params.cpp index af873c1468c691bfb9e75211b5ef8b74c8c9e081..ee93e4668367f38564830d04b3caec7b3c6b0dc3 100644 --- a/src/conference/conference-params.cpp +++ b/src/conference/conference-params.cpp @@ -63,7 +63,8 @@ void ConferenceParams::updateFromAccount( if (m_useDefaultFactoryAddress) { auto core = account->getCore(); m_factoryAddress = accountParams->getAudioVideoConferenceFactoryAddress(); - if (m_factoryAddress && (linphone_core_get_global_state(core) != LinphoneGlobalStartup)) { + if (m_factoryAddress && + (linphone_core_get_global_state(L_GET_C_BACK_PTR(core)) != LinphoneGlobalStartup)) { lInfo() << "Update conference parameters from account, factory: " << *m_factoryAddress; } } diff --git a/src/conference/conference-scheduler.h b/src/conference/conference-scheduler.h index 7a5290070e56df8e1ef5ea706c227a3303608abd..f694c1faf8cf09d58b4a400071c2a6988be0f1a5 100644 --- a/src/conference/conference-scheduler.h +++ b/src/conference/conference-scheduler.h @@ -113,6 +113,13 @@ private: std::ostream &operator<<(std::ostream &lhs, ConferenceScheduler::State s); +class ConferenceSchedulerLogContextualizer : public CoreLogContextualizer { +public: + ConferenceSchedulerLogContextualizer(const LinphoneConferenceScheduler *cs) + : CoreLogContextualizer(*ConferenceScheduler::toCpp(cs)) { + } +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_CONFERENCE_SCHEDULER_H_ diff --git a/src/conference/session/video-stream.cpp b/src/conference/session/video-stream.cpp index 8263e33efd49cd2456c2713c1673b3d7f0fc16f2..6203ef69cd92ac9ac48ce13fd04865a7265d984b 100644 --- a/src/conference/session/video-stream.cpp +++ b/src/conference/session/video-stream.cpp @@ -616,7 +616,7 @@ void MS2VideoStream::handleEvent(const OrtpEvent *ev) { linphone_call_stats_set_estimated_download_bandwidth(mStats, (float)(evd->info.video_bandwidth_available * 1e-3)); } else if (evt == ORTP_EVENT_JITTER_UPDATE_FOR_NACK) { - mNetworkMonitor.mNackSent = true; + mNetworkMonitor.confirmNackSent(); } VideoStats sendStats, recvStats; diff --git a/src/core/core-accessor.cpp b/src/core/core-accessor.cpp index 24035f6073d97a4010a9111df63f11f15ed7a60d..4af0b3a4d4a8442b61a8010eae967a0e3464c16d 100644 --- a/src/core/core-accessor.cpp +++ b/src/core/core-accessor.cpp @@ -19,6 +19,7 @@ */ #include "core-accessor.h" +#include "core.h" #include "logger/logger.h" @@ -28,37 +29,46 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -class CoreAccessorPrivate { -public: - weak_ptr<Core> core; -}; - // ----------------------------------------------------------------------------- -CoreAccessor::CoreAccessor(const shared_ptr<Core> &core) { - mPrivate = new CoreAccessorPrivate(); - if (core) mPrivate->core = core; -} - -CoreAccessor::~CoreAccessor() { - delete mPrivate; +CoreAccessor::CoreAccessor(const shared_ptr<Core> &core) : mCore(core) { } shared_ptr<Core> CoreAccessor::getCore() const { - L_D(); - - shared_ptr<Core> core = d->core.lock(); + shared_ptr<Core> core = mCore.lock(); if (!core) { lWarning() << "Unable to get valid core instance."; throw bad_weak_ptr(); } - return core; } -void CoreAccessor::setCore(std::shared_ptr<Core> core) { - L_D(); - d->core = core; +void CoreAccessor::setCore(const std::shared_ptr<Core> &core) { + mCore = core; +} + +CoreLogContextualizer::CoreLogContextualizer(const LinphoneCore *core) { + pushTag(core ? L_GET_CPP_PTR_FROM_C_OBJECT(core)->getLabel() : ""); +} + +CoreLogContextualizer::CoreLogContextualizer(const CoreAccessor *coreAccessor) { + if (!coreAccessor) return; + try { + auto core = coreAccessor->getCore(); + if (core) pushTag(core->getLabel()); + } catch (...) { + } +} + +void CoreLogContextualizer::pushTag(const std::string &tag) { + if (!tag.empty()) { + mPushed = true; + bctbx_push_log_tag(sTagIdentifier, tag.c_str()); + } +} + +CoreLogContextualizer::~CoreLogContextualizer() { + if (mPushed) bctbx_pop_log_tag(sTagIdentifier); } LINPHONE_END_NAMESPACE diff --git a/src/core/core-accessor.h b/src/core/core-accessor.h index 3caa74e1f33d600e08f44adcb591b80515e722c9..c152aff5a706afc403c4ceded2c64cf43e93f35f 100644 --- a/src/core/core-accessor.h +++ b/src/core/core-accessor.h @@ -21,6 +21,7 @@ #ifndef _L_CORE_ACCESSOR_H_ #define _L_CORE_ACCESSOR_H_ +#include "linphone/api/c-types.h" #include "linphone/utils/general.h" // ============================================================================= @@ -34,17 +35,28 @@ class CoreAccessorPrivate; class LINPHONE_PUBLIC CoreAccessor { public: CoreAccessor(const std::shared_ptr<Core> &core); - virtual ~CoreAccessor() = 0; + virtual ~CoreAccessor() = default; // Returns a valid core instance. Or throw one std::bad_weak_ptr exception if core is destroyed. std::shared_ptr<Core> getCore() const; - void setCore(std::shared_ptr<Core> core); + void setCore(const std::shared_ptr<Core> &core); private: - CoreAccessorPrivate *mPrivate = nullptr; + std::weak_ptr<Core> mCore; +}; + +class CoreLogContextualizer { +public: + CoreLogContextualizer(const LinphoneCore *core); + CoreLogContextualizer(const CoreAccessor &coreAccessor) : CoreLogContextualizer(&coreAccessor) { + } + CoreLogContextualizer(const CoreAccessor *coreAccessor); + ~CoreLogContextualizer(); - L_DISABLE_COPY(CoreAccessor); - L_DECLARE_PRIVATE(CoreAccessor); +private: + void pushTag(const std::string &tag); + bool mPushed = false; + static constexpr char sTagIdentifier[] = "linphone-core"; }; LINPHONE_END_NAMESPACE diff --git a/src/core/core-p.h b/src/core/core-p.h index a01e30c24865cd3b3c32e9f624cc472646b26457..e125beb2064475b228e0ee42681c22b4df0d6bfb 100644 --- a/src/core/core-p.h +++ b/src/core/core-p.h @@ -227,6 +227,7 @@ private: ExtraBackgroundTask bgTask{"Stop core async end"}; std::list<std::shared_ptr<Ldap>> mLdapServers; // Persistent list of LDAP servers + std::string logLabel; L_DECLARE_PUBLIC(Core); }; diff --git a/src/core/core.cpp b/src/core/core.cpp index 06869c149be0dd08d510c3942ebbdcc2aa8cc3e2..7ed711c9e745a9dc6ff7fa44bab6b77df634081e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -2133,4 +2133,14 @@ Core::ETagStatus Core::eTagHandler(SalPublishOp *op, const SalBodyHandler *body) return Core::ETagStatus::None; } +void Core::setLabel(const std::string &label) { + L_D(); + d->logLabel = label; +} + +const std::string &Core::getLabel() const { + L_D(); + return d->logLabel; +} + LINPHONE_END_NAMESPACE diff --git a/src/core/core.h b/src/core/core.h index c6e707a54a5921841112221f50b09da4bc236f84..de10048af1d19994b5d38cd939d8ab1e66da9ec6 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -377,6 +377,9 @@ public: void addOrUpdatePublishByEtag(SalPublishOp *op, std::shared_ptr<LinphonePrivate::EventPublish>); Core::ETagStatus eTagHandler(SalPublishOp *op, const SalBodyHandler *body); + void setLabel(const std::string &label); + const std::string &getLabel() const; + private: Core(); diff --git a/src/event/event.h b/src/event/event.h index e59f3657407319d5b2aeb2ac560fe74a6244960f..f2833f4bd8318a74fe72309d7241263b27b1d5d8 100644 --- a/src/event/event.h +++ b/src/event/event.h @@ -114,6 +114,12 @@ private: mutable LinphoneErrorInfo *mEi = nullptr; }; +class EventLogScope : public CoreLogContextualizer { +public: + EventLogScope(const LinphoneEvent *ev) : CoreLogContextualizer(*Event::toCpp(ev)) { + } +}; + LINPHONE_END_NAMESPACE #endif // ifndef _L_EVENT_H_ diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index 76a4ab8c7cfcdac1eb2ec745a492cb25b05136ae..47a971e5e5e87cfdc002ca053bee0b64c93a6a86 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -976,6 +976,10 @@ LINPHONE_PUBLIC void sal_set_uuid(Sal *ctx, const char *uuid) { ctx->setUuid(L_C_TO_STRING(uuid)); } +LINPHONE_PUBLIC const char *sal_get_uuid(const Sal *ctx) { + return ctx->getUuid().c_str(); +} + LINPHONE_PUBLIC void sal_default_set_sdp_handling(Sal *h, SalOpSDPHandling sdpHandlingMethod) { h->setDefaultSdpHandling(sdpHandlingMethod); } diff --git a/src/sal/sal.h b/src/sal/sal.h index 25caeb71d06d74fae3e9f972e644200aa5ef785e..d6be06f103494609ac15c3795695fbec665f9905 100644 --- a/src/sal/sal.h +++ b/src/sal/sal.h @@ -194,6 +194,9 @@ public: void setUuid(const std::string &value) { mUuid = value; } + const std::string &getUuid() const { + return mUuid; + } std::string createUuid(); static std::string generateUuid(); diff --git a/tester/accountmanager.c b/tester/accountmanager.c index a7a39aad92978da15bc0af8c73c2e291ac13b9d5..f43fda3f2188d79230dcfd19e3dd7bc724489641 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -340,6 +340,7 @@ account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg, Linph create_account = TRUE; m->accounts = bctbx_list_append(m->accounts, account); } + // modify the username of the identity of the proxy config linphone_address_set_username(id_addr, linphone_address_get_username(account->modified_identity)); linphone_proxy_config_edit(cfg); @@ -365,6 +366,11 @@ account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg, Linph sal_set_uuid(linphone_core_get_sal(cm->lc), account->uuid); } + if (cfg == linphone_core_get_default_proxy_config(cm->lc)) { + /* uuid is computed at later time, during linphone_core_start(). */ + linphone_core_set_label(cm->lc, linphone_address_get_username(account->identity)); + } + // remove previous auth info to avoid mismatching if (original_ai) linphone_core_remove_auth_info(lc, original_ai); diff --git a/tester/alerts_tester.cpp b/tester/alerts_tester.cpp index 9751900cd6297cc928a62634ba0a03c72ff0f7e7..0b540d6458ebafeaf87ee3e7c8e814979d267059 100644 --- a/tester/alerts_tester.cpp +++ b/tester/alerts_tester.cpp @@ -74,7 +74,7 @@ static void alert_catch(LinphoneCore *core, LinphoneAlert *alert) { if (type == data->expectedType) { data->triggerCount++; } - linphone_alert_cbs_set_on_terminated(alert_cbs, alert_on_terminated); + linphone_alert_cbs_set_terminated(alert_cbs, alert_on_terminated); linphone_alert_add_callbacks(alert, alert_cbs); linphone_alert_cbs_set_user_data(alert_cbs, data); linphone_alert_cbs_unref(alert_cbs); @@ -88,7 +88,7 @@ static void alert_call_base(OrtpNetworkSimulatorParams &networkParams, AlertCall pauline = linphone_core_manager_new("pauline_rc"); LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get()); - linphone_core_cbs_set_on_alert(cbs, alert_catch); + linphone_core_cbs_set_new_alert_triggered(cbs, alert_catch); linphone_core_add_callbacks(marie->lc, cbs); linphone_core_cbs_set_user_data(cbs, &data); linphone_core_cbs_unref(cbs); diff --git a/tester/dtmf_tester.c b/tester/dtmf_tester.c index 17eea74fe8c389be944b19c8cbb44bf80713f3ca..48d7f769f2ee71efef547911e04486dc3de8bb32 100644 --- a/tester/dtmf_tester.c +++ b/tester/dtmf_tester.c @@ -186,13 +186,6 @@ void linphone_call_send_dtmf__sequence__rfc2833_and_sip_info_enabled(void) { send_dtmf_cleanup(marie, pauline); } -static void send_dtmfs_sequence_not_ready(void) { - LinphoneCoreManager *marie; - marie = linphone_core_manager_new("marie_rc"); - BC_ASSERT_EQUAL(linphone_call_send_dtmfs(linphone_core_get_current_call(marie->lc), "123"), -1, int, "%d"); - linphone_core_manager_destroy(marie); -} - static void send_dtmfs_sequence_call_state_changed(void) { LinphoneCoreManager *marie, *pauline; LinphoneCall *marie_call = NULL; @@ -231,6 +224,5 @@ test_t dtmf_tests[10] = { send_dtmfs_sequence_rfc2833_with_hardcoded_payload_type), TEST_NO_TAG("Send DTMF sequence using SIP INFO", send_dtmfs_sequence_sip_info), TEST_NO_TAG_AUTO_NAMED(linphone_call_send_dtmf__sequence__rfc2833_and_sip_info_enabled), - TEST_NO_TAG("DTMF sequence not sent if invalid call", send_dtmfs_sequence_not_ready), TEST_NO_TAG("DTMF sequence canceled if call state changed", send_dtmfs_sequence_call_state_changed), TEST_NO_TAG("Send DTMF using RFC2833 using Opus", send_dtmf_rfc2833_opus)}; diff --git a/tester/setup_tester.c b/tester/setup_tester.c index c937dc36fb0083b091eb17934736120bf2e3304a..712581e5a522759cc4a19b6b806946a751f1bf49 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -1740,10 +1740,11 @@ static void search_friend_in_call_log(void) { linphone_magic_search_unref(magicSearch); // Ensure tester call log & zrtp secrets db are correctly removed - const char *zrtp_secrets_db_path = linphone_core_get_zrtp_secrets_file(manager->lc); + char *zrtp_secrets_db_path = bctbx_strdup(linphone_core_get_zrtp_secrets_file(manager->lc)); BC_ASSERT_EQUAL(0, bctbx_file_exist(zrtp_secrets_db_path), int, "%d"); linphone_core_manager_destroy(manager); BC_ASSERT_NOT_EQUAL(0, bctbx_file_exist(zrtp_secrets_db_path), int, "%d"); + bctbx_free(zrtp_secrets_db_path); } static void search_friend_in_call_log_already_exist(void) { diff --git a/tester/tester.c b/tester/tester.c index e6d166d9db417c7f77db339857b33d211692d541..482e275833c3fc7c006891121a22ed4cdce6ef1c 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -2557,6 +2557,13 @@ void linphone_core_manager_init_shared(LinphoneCoreManager *mgr, #pragma GCC diagnostic pop #endif +static const char *end_of_uuid(const char *uuid) { + size_t size = strlen(uuid); + if (size > 4) size -= 4; + else size = 0; + return uuid + size; +} + void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_proxies) { LinphoneProxyConfig *proxy; int proxy_count; @@ -2564,6 +2571,18 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_prox if (linphone_core_start(mgr->lc) == -1) { ms_error("Core [%p] failed to start", mgr->lc); } + proxy = linphone_core_get_default_proxy_config(mgr->lc); + if (proxy) { + const char *label = linphone_core_get_label(mgr->lc); + if (label && strchr(label, ';') == NULL) { + /* suffix the uuid, that is known from linphone_core_start() was done.*/ + char *full_label = bctbx_strdup_printf( + "%s;%s", label, + end_of_uuid(linphone_config_get_string(linphone_core_get_config(mgr->lc), "misc", "uuid", "unknown"))); + linphone_core_set_label(mgr->lc, full_label); + bctbx_free(full_label); + } + } /*BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/ int old_registration_ok = mgr->stat.number_of_LinphoneRegistrationOk; @@ -2587,7 +2606,6 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_prox BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk, old_registration_ok + proxy_count, int, "%d"); enable_codec(mgr->lc, "PCMU", 8000); - proxy = linphone_core_get_default_proxy_config(mgr->lc); if (proxy) { if (mgr->identity) { linphone_address_unref(mgr->identity); diff --git a/tester/video_quality_tester.c b/tester/video_quality_tester.c index 92864cd30f398eb97dfbe7e70b960cd23ac0558a..f17ef2e0962db50ba3ba0ec1bff2b9aa459c9d28 100644 --- a/tester/video_quality_tester.c +++ b/tester/video_quality_tester.c @@ -609,7 +609,7 @@ static void call_with_retransmissions_on_nack(void) { linphone_core_enable_alerts(pauline->lc, TRUE); linphone_config_set_float(linphone_core_get_config(pauline->lc), "alerts", "alerts::nack_threshold", 1.0f); LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get()); - linphone_core_cbs_set_on_alert(cbs, on_nack_alert); + linphone_core_cbs_set_new_alert_triggered(cbs, on_nack_alert); linphone_core_add_callbacks(pauline->lc, cbs); linphone_core_cbs_set_user_data(cbs, &nack_alert_count); linphone_core_cbs_unref(cbs);