diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index 526f32954ad5cc8d02ac0cd092a5ac11fb955fc1..053b3fba204a6ba10fb103b4e53ac9e3592256af 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -237,14 +237,18 @@ const char *sal_address_get_param(const SalAddress *addr, const char *name) { return belle_sip_parameters_get_parameter(parameters, name); } +static void copy_parameters_to_map(const belle_sip_parameters_t *parameters, + std::map<std::string, std::string> ¶ms) { + const belle_sip_list_t *pairs = belle_sip_parameters_get_parameters(parameters); + for (const belle_sip_list_t *it = pairs; it != NULL; it = it->next) { + const belle_sip_param_pair_t *pair = (const belle_sip_param_pair_t *)it->data; + params[pair->name] = pair->value ? pair->value : ""; + } +} + void sal_address_get_params(const SalAddress *addr, std::map<std::string, std::string> ¶ms) { belle_sip_parameters_t *parameters = BELLE_SIP_PARAMETERS(addr); - const belle_sip_list_t *param_names = belle_sip_parameters_get_parameter_names(parameters); - for (belle_sip_list_t *it = (belle_sip_list_t *)param_names; it != NULL; it = it->next) { - const char *name = (const char *)it->data; - const char *value = belle_sip_parameters_get_parameter(parameters, name); - params[name] = value ? value : ""; - } + copy_parameters_to_map(parameters, params); } void sal_address_set_params(SalAddress *addr, const char *params) { @@ -252,45 +256,44 @@ void sal_address_set_params(SalAddress *addr, const char *params) { belle_sip_parameters_set(parameters, params); } +static belle_sip_parameters_t *sal_address_get_uri_parameters(const SalAddress *addr) { + belle_sip_uri_t *uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr)); + if (uri) return BELLE_SIP_PARAMETERS(uri); + belle_generic_uri_t *generic_uri = belle_sip_header_address_get_absolute_uri(BELLE_SIP_HEADER_ADDRESS(addr)); + if (generic_uri) return BELLE_SIP_PARAMETERS(generic_uri); + return NULL; +} + void sal_address_set_uri_param(SalAddress *addr, const char *name, const char *value) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); - belle_sip_parameters_set_parameter(parameters, name, value); + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + if (parameters) belle_sip_parameters_set_parameter(parameters, name, value); } -void sal_address_set_uri_params(SalAddress *addr, const char *params) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); - belle_sip_parameters_set(parameters, params); +void sal_address_get_uri_params(const SalAddress *addr, std::map<std::string, std::string> ¶ms) { + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + if (!parameters) return; + copy_parameters_to_map(parameters, params); } -bool_t sal_address_has_uri_param(const SalAddress *addr, const char *name) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); - return !!belle_sip_parameters_has_parameter(parameters, name); +void sal_address_set_uri_params(SalAddress *addr, const char *params) { + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + if (parameters) belle_sip_parameters_set(parameters, params); } -void sal_address_get_uri_params(const SalAddress *addr, std::map<std::string, std::string> ¶ms) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); - const belle_sip_list_t *param_names = belle_sip_parameters_get_parameter_names(parameters); - for (belle_sip_list_t *it = (belle_sip_list_t *)param_names; it != NULL; it = it->next) { - const char *name = (const char *)it->data; - const char *value = belle_sip_parameters_get_parameter(parameters, name); - params[name] = value ? value : ""; - } +bool_t sal_address_has_uri_param(const SalAddress *addr, const char *name) { + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + return parameters && !!belle_sip_parameters_has_parameter(parameters, name); } const char *sal_address_get_uri_param(const SalAddress *addr, const char *name) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + if (!parameters) return NULL; return belle_sip_parameters_get_parameter(parameters, name); } void sal_address_remove_uri_param(const SalAddress *addr, const char *name) { - belle_sip_parameters_t *parameters = - BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); - belle_sip_parameters_remove_parameter(parameters, name); + belle_sip_parameters_t *parameters = sal_address_get_uri_parameters(addr); + if (parameters) belle_sip_parameters_remove_parameter(parameters, name); } void sal_address_set_header(SalAddress *addr, const char *header_name, const char *header_value) { @@ -344,14 +347,27 @@ int sal_address_weak_equals(const SalAddress *addr_a, const SalAddress *addr_b) belle_sip_uri_t *uri_a = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr_a)); belle_sip_uri_t *uri_b = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr_b)); - const char *user_a = belle_sip_uri_get_user(uri_a); - const char *user_b = belle_sip_uri_get_user(uri_b); + if (uri_a && uri_b) { + const char *user_a = belle_sip_uri_get_user(uri_a); + const char *user_b = belle_sip_uri_get_user(uri_b); - if (c_string_equal(user_a, user_b)) { - const char *host_a = belle_sip_uri_get_host(uri_a); - const char *host_b = belle_sip_uri_get_host(uri_b); - if (c_string_equal(host_a, host_b)) { - return belle_sip_uri_get_port(uri_a) == belle_sip_uri_get_port(uri_b); + if (c_string_equal(user_a, user_b)) { + const char *host_a = belle_sip_uri_get_host(uri_a); + const char *host_b = belle_sip_uri_get_host(uri_b); + if (c_string_equal(host_a, host_b)) { + return belle_sip_uri_get_port(uri_a) == belle_sip_uri_get_port(uri_b); + } + } + } else { + belle_generic_uri_t *guri_a = belle_sip_header_address_get_absolute_uri(BELLE_SIP_HEADER_ADDRESS(addr_a)); + belle_generic_uri_t *guri_b = belle_sip_header_address_get_absolute_uri(BELLE_SIP_HEADER_ADDRESS(addr_b)); + if (guri_a && guri_b) { + char *a_str = belle_generic_uri_to_string(guri_a); + char *b_str = belle_generic_uri_to_string(guri_b); + int result = strcasecmp(a_str, b_str) == 0; + belle_sip_free(a_str); + belle_sip_free(b_str); + return result; } } return FALSE; diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index c2518aa389c1e7dfdee45a4689fb1ee6dc9d57ca..01cd7fd79f2ee94bcfe3e2caf19666301d5c8bc9 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -84,7 +84,7 @@ static void call_received(SalCallOp *h) { /* Look if this INVITE is for a call that has already been notified but broken because of network failure */ if (L_GET_PRIVATE_FROM_C_OBJECT(lc)->inviteReplacesABrokenCall(h)) return; - LinphoneAddress *fromAddr = nullptr; + std::shared_ptr<Address> from; const char *pAssertedId = sal_custom_header_find(h->getRecvCustomHeaders(), "P-Asserted-Identity"); /* In some situation, better to trust the network rather than the UAC */ if (linphone_config_get_int(linphone_core_get_config(lc), "sip", "call_logs_use_asserted_id_instead_of_from", 0)) { @@ -93,7 +93,7 @@ static void call_received(SalCallOp *h) { if (pAssertedIdAddr) { ms_message("Using P-Asserted-Identity [%s] instead of from [%s] for op [%p]", pAssertedId, h->getFrom().c_str(), h); - fromAddr = pAssertedIdAddr; + from = Address::toCpp(pAssertedIdAddr)->toSharedPtr(); } else { ms_warning("Unsupported P-Asserted-Identity header for op [%p] ", h); } @@ -103,10 +103,8 @@ static void call_received(SalCallOp *h) { } } - if (!fromAddr) fromAddr = linphone_address_new(h->getFrom().c_str()); - LinphoneAddress *toAddr = linphone_address_new(h->getTo().c_str()); - std::shared_ptr<Address> to = Address::toCpp(toAddr)->toSharedPtr(); - std::shared_ptr<Address> from = Address::toCpp(fromAddr)->toSharedPtr(); + if (!from) from = (new Address(h->getFrom()))->toSharedPtr(); + std::shared_ptr<Address> to = (new Address(h->getTo()))->toSharedPtr(); if (sal_address_has_param(h->getRemoteContactAddress(), "text")) { #ifdef HAVE_ADVANCED_IM diff --git a/src/account/account.h b/src/account/account.h index 664439403ebefe6bc28403668227d6229a2fda32..d359c9dcee83913e7ae96a3d2b70ec22528cfbd7 100644 --- a/src/account/account.h +++ b/src/account/account.h @@ -211,9 +211,9 @@ private: LinphoneAccountCbsRegistrationStateChangedCb mRegistrationStateChangedCb = nullptr; }; -class AccountLogScope : public CoreLogContextualizer { +class AccountLogContextualizer : public CoreLogContextualizer { public: - AccountLogScope(const LinphoneAccount *account) + AccountLogContextualizer(const LinphoneAccount *account) : CoreLogContextualizer(account ? Account::toCpp(account) : nullptr) { } }; diff --git a/src/address/address.cpp b/src/address/address.cpp index c10a23a83e6825507c45d3d134f24645ddb710a9..c5b5ecc602e7586d0572957a6872e6fb4972324e 100644 --- a/src/address/address.cpp +++ b/src/address/address.cpp @@ -72,10 +72,6 @@ Address::Address(const Address &other) : HybridObject(other) { else mImpl = sal_address_new_empty(); } -Address::Address(SalAddress *addr) { - mImpl = addr; -} - Address::Address() { mImpl = sal_address_new_empty(); } @@ -85,6 +81,18 @@ Address::Address(Address &&other) : bellesip::HybridObject<LinphoneAddress, Addr other.mImpl = nullptr; } +Address::Address(SalAddress *addr, bool acquire) { + if (acquire) { + mImpl = addr; + } else { + mImpl = sal_address_clone(addr); + } +} + +Address::Address(const SalAddress *addr) { + mImpl = sal_address_clone(addr); +} + Address::~Address() { if (mImpl) sal_address_unref(mImpl); } @@ -121,7 +129,7 @@ bool Address::operator<(const Address &other) const { Address Address::getUri() const { if (mImpl) { - return sal_address_new_uri_only(mImpl); + return Address(sal_address_new_uri_only(mImpl), true); } return Address(); } diff --git a/src/address/address.h b/src/address/address.h index fca37ac57153dd30ba38cd98010172afcbaca62c..846008140e743d68e68c8f4c10ec37a90102af3c 100644 --- a/src/address/address.h +++ b/src/address/address.h @@ -43,7 +43,11 @@ public: Address(); Address(Address &&other); Address(const Address &other); - Address(SalAddress *addr); + // Instanciate an address by copying from a SalAddress. + Address(const SalAddress *addr); + // Instanciate an address by acquiring a SalAddress if acquire is true. If acquire is false, does the same as + // Address(const Address &other); + Address(SalAddress *addr, bool acquire); virtual ~Address(); virtual Address *clone() const override; virtual std::string toString() const override; diff --git a/src/c-wrapper/api/c-account.cpp b/src/c-wrapper/api/c-account.cpp index 8bc04aaa15081074c5d97f48b8a97f1187c375de..e81000209fff7265c3a6a520448c2fa151749711 100644 --- a/src/c-wrapper/api/c-account.cpp +++ b/src/c-wrapper/api/c-account.cpp @@ -55,27 +55,27 @@ LinphoneAccount *linphone_account_ref(LinphoneAccount *account) { } void linphone_account_unref(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); Account::toCpp(account)->unref(); } int linphone_account_set_params(LinphoneAccount *account, LinphoneAccountParams *params) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->setAccountParams(AccountParams::toCpp(params)->getSharedFromThis()); } const LinphoneAccountParams *linphone_account_get_params(const LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer 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); + AccountLogContextualizer 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); + AccountLogContextualizer logContextualizer(account); return L_STRING_TO_C(Account::toCpp(account)->getCustomParam(L_C_TO_STRING(key))); } @@ -88,17 +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); + AccountLogContextualizer 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); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getCustomHeader(std::string(header_name)); } void linphone_account_set_dependency(LinphoneAccount *account, LinphoneAccount *depends_on) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); Account::toCpp(account)->setDependency(depends_on ? Account::toCpp(depends_on)->getSharedFromThis() : nullptr); } @@ -115,32 +115,32 @@ LinphoneCore *linphone_account_get_core(LinphoneAccount *account) { } const LinphoneErrorInfo *linphone_account_get_error_info(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getErrorInfo(); } LinphoneAddress *linphone_account_get_contact_address(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer 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); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->setContactAddress(Address::toCpp(addr)->getSharedFromThis()); } LinphoneRegistrationState linphone_account_get_state(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getState(); } void linphone_account_refresh_register(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); Account::toCpp(account)->refreshRegister(); } void linphone_account_pause_register(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); Account::toCpp(account)->pauseRegister(); } @@ -149,7 +149,7 @@ LinphoneReason linphone_account_get_error(LinphoneAccount *account) { } LinphoneTransportType linphone_account_get_transport(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getTransport(); } @@ -162,32 +162,32 @@ bool_t linphone_account_avpf_enabled(LinphoneAccount *account) { } const LinphoneAuthInfo *linphone_account_find_auth_info(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->findAuthInfo(); } int linphone_account_get_unread_chat_message_count(const LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getUnreadChatMessageCount(); } bctbx_list_t *linphone_account_get_chat_rooms(const LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(Account::toCpp(account)->getChatRooms()); } int linphone_account_get_missed_calls_count(const LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); return Account::toCpp(account)->getMissedCallsCount(); } void linphone_account_reset_missed_calls_count(LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); Account::toCpp(account)->resetMissedCallsCount(); } bctbx_list_t *linphone_account_get_call_logs(const LinphoneAccount *account) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); bctbx_list_t *results = NULL; std::list list = Account::toCpp(account)->getCallLogs(); @@ -202,7 +202,7 @@ bctbx_list_t *linphone_account_get_call_logs(const LinphoneAccount *account) { bctbx_list_t *linphone_account_get_call_logs_for_address(const LinphoneAccount *account, const LinphoneAddress *remote_address) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); bctbx_list_t *results = NULL; const auto remote = Address::toCpp(const_cast<LinphoneAddress *>(remote_address))->getSharedFromThis(); @@ -248,7 +248,7 @@ void _linphone_account_notify_registration_state_changed(LinphoneAccount *accoun } bool_t linphone_account_is_phone_number(const LinphoneAccount *account, const char *username) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); if (!username) return FALSE; const char *p; @@ -291,7 +291,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); + AccountLogContextualizer logContextualizer(account); char *result = NULL; std::shared_ptr<DialPlan> dialplan; char *nationnal_significant_number = NULL; @@ -400,7 +400,7 @@ static LinphoneAddress *_destroy_addr_if_not_sip(LinphoneAddress *addr) { } LinphoneAddress *linphone_account_normalize_sip_uri(LinphoneAccount *account, const char *username) { - AccountLogScope logContextualizer(account); + AccountLogContextualizer logContextualizer(account); enum_lookup_res_t *enumres = NULL; char *enum_domain = NULL; char *tmpurl; diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index ac252245e17b555506bfbf49aa15c3dc0f04c9cc..92b706f94f051fdaeed74c73f81dcd1e1061f205 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -83,12 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->isRemoteComposing(); } @@ -119,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -127,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -137,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -147,7 +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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); LinphoneChatMessage *msg = linphone_chat_room_create_empty_message(cr); linphone_chat_message_add_file_content(msg, initial_content); return msg; @@ -161,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -174,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -183,7 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -193,7 +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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); LinphoneChatMessage *chat_message = linphone_chat_room_create_empty_message(cr); LinphoneContent *c_content = linphone_recorder_create_content(recorder); @@ -219,17 +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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getChar(); } void linphone_chat_room_compose(LinphoneChatRoom *cr) { - LinphonePrivate::ChatRoomLogScope logContextualizer(cr); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->compose(); } LinphoneCall *linphone_chat_room_get_call(const LinphoneChatRoom *cr) { - LinphonePrivate::ChatRoomLogScope logContextualizer(cr); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCall(); if (call) return call->toC(); return nullptr; @@ -240,73 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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( @@ -316,42 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastChatMessageInHistory(); if (!cppPtr) return nullptr; @@ -359,7 +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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findChatMessage(message_id); if (!cppPtr) return nullptr; @@ -367,44 +367,44 @@ LinphoneChatMessage *linphone_chat_room_find_message(LinphoneChatRoom *cr, const } LinphoneChatRoomState linphone_chat_room_get_state(const LinphoneChatRoom *cr) { - LinphonePrivate::ChatRoomLogScope logContextualizer(cr); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); std::shared_ptr<LinphonePrivate::Participant> participant = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findParticipant(LinphonePrivate::Address::toCpp(addr)->getSharedFromThis()); if (participant) { @@ -414,22 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); const auto &confAddress = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress(); if (confAddress && confAddress->isValid()) { return confAddress->toC(); @@ -439,7 +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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); std::shared_ptr<LinphonePrivate::Participant> me = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMe(); if (me) { return me->toC(); @@ -448,38 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); return (LinphoneChatRoomSecurityLevel)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getSecurityLevel(); } void linphone_chat_room_leave(LinphoneChatRoom *cr) { - LinphonePrivate::ChatRoomLogScope logContextualizer(cr); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->removeParticipants( LinphonePrivate::Participant::getCppListFromCList(participants)); } @@ -487,18 +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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); + LinphonePrivate::ChatRoomLogContextualizer 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); @@ -506,12 +506,12 @@ const bctbx_list_t *linphone_chat_room_get_composing_addresses(LinphoneChatRoom } bool_t linphone_chat_room_get_muted(const LinphoneChatRoom *chat_room) { - LinphonePrivate::ChatRoomLogScope logContextualizer(chat_room); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(chat_room); return L_GET_CPP_PTR_FROM_C_OBJECT(chat_room)->getIsMuted(); } void linphone_chat_room_set_muted(LinphoneChatRoom *chat_room, bool_t muted) { - LinphonePrivate::ChatRoomLogScope logContextualizer(chat_room); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(chat_room); L_GET_CPP_PTR_FROM_C_OBJECT(chat_room)->setIsMuted(!!muted); } @@ -791,7 +791,7 @@ LinphoneChatRoom *linphone_chat_room_ref(LinphoneChatRoom *cr) { } void linphone_chat_room_unref(LinphoneChatRoom *cr) { - LinphonePrivate::ChatRoomLogScope logContextualizer(cr); + LinphonePrivate::ChatRoomLogContextualizer logContextualizer(cr); belle_sip_object_unref(cr); } diff --git a/src/c-wrapper/api/c-event.cpp b/src/c-wrapper/api/c-event.cpp index 4f7c15a2b978d4664ca226b733cd8e014fd97f52..f6fe47d6fad4947222816d55863634bc4e49def1 100644 --- a/src/c-wrapper/api/c-event.cpp +++ b/src/c-wrapper/api/c-event.cpp @@ -238,7 +238,7 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s } void linphone_event_unpublish(LinphoneEvent *lev) { - EventLogScope logContextualizer(lev); + EventLogContextualizer logContextualizer(lev); Event::toCpp(lev)->unpublish(); } @@ -255,7 +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); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_send_subscribe"); @@ -265,7 +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); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_update_subscribe"); @@ -275,7 +275,7 @@ LinphoneStatus linphone_event_update_subscribe(LinphoneEvent *linphone_event, co } LinphoneStatus linphone_event_refresh_subscribe(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_refresh_subscribe"); @@ -285,7 +285,7 @@ LinphoneStatus linphone_event_refresh_subscribe(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_accept_subscription(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_accept_subscription"); @@ -295,7 +295,7 @@ LinphoneStatus linphone_event_accept_subscription(LinphoneEvent *linphone_event) } LinphoneStatus linphone_event_deny_subscription(LinphoneEvent *linphone_event, LinphoneReason reason) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_deny_subscription"); @@ -305,7 +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); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_notify"); @@ -315,7 +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); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_send_publish"); @@ -325,7 +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); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_update_publish"); @@ -335,7 +335,7 @@ LinphoneStatus linphone_event_update_publish(LinphoneEvent *linphone_event, cons } LinphoneStatus linphone_event_refresh_publish(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_refresh_publish"); @@ -345,7 +345,7 @@ LinphoneStatus linphone_event_refresh_publish(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_accept_publish(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_accept_publish"); @@ -355,7 +355,7 @@ LinphoneStatus linphone_event_accept_publish(LinphoneEvent *linphone_event) { } LinphoneStatus linphone_event_deny_publish(LinphoneEvent *linphone_event, LinphoneReason reason) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_deny_publish"); @@ -365,7 +365,7 @@ LinphoneStatus linphone_event_deny_publish(LinphoneEvent *linphone_event, Linpho } void linphone_event_pause_publish(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_publish = dynamic_cast<EventPublish *>(Event::toCpp(linphone_event)); if (!event_publish) { log_bad_cast("linphone_event_pause_publish"); @@ -375,17 +375,17 @@ void linphone_event_pause_publish(LinphoneEvent *linphone_event) { } LinphoneReason linphone_event_get_reason(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getReason(); } const LinphoneErrorInfo *linphone_event_get_error_info(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getErrorInfo(); } LinphoneSubscriptionState linphone_event_get_subscription_state(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer 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"); @@ -395,7 +395,7 @@ LinphoneSubscriptionState linphone_event_get_subscription_state(const LinphoneEv } LinphonePublishState linphone_event_get_publish_state(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer 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"); @@ -405,7 +405,7 @@ LinphonePublishState linphone_event_get_publish_state(const LinphoneEvent *linph } LinphoneSubscriptionDir linphone_event_get_subscription_dir(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); auto event_subscribe = dynamic_cast<EventSubscribe *>(Event::toCpp(linphone_event)); if (!event_subscribe) { log_bad_cast("linphone_event_get_subscription_dir"); @@ -424,47 +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); + EventLogContextualizer 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); + EventLogContextualizer 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); + EventLogContextualizer 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); + EventLogContextualizer logContextualizer(linphone_event); Event::toCpp(linphone_event)->terminate(); } const char *linphone_event_get_name(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer 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); + EventLogContextualizer logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getFrom()->toC(); } const LinphoneAddress *linphone_event_get_to(const LinphoneEvent *lev) { - EventLogScope logContextualizer(lev); + EventLogContextualizer logContextualizer(lev); return Event::toCpp(lev)->getTo()->toC(); } const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer 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); + EventLogContextualizer logContextualizer(linphone_event); return Event::toCpp(linphone_event)->getRemoteContact()->toC(); } @@ -494,7 +494,7 @@ LinphoneEvent *linphone_event_ref(LinphoneEvent *linphone_event) { } void linphone_event_unref(LinphoneEvent *linphone_event) { - EventLogScope logContextualizer(linphone_event); + EventLogContextualizer logContextualizer(linphone_event); Event::toCpp(linphone_event)->unref(); } diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 6f62ccfeb23606478cddf3268c5010f76b08defb..955cb19ad16f0005a42db7ad68401909dadea6a0 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -905,7 +905,7 @@ void ChatRoom::setIsMuted(const bool muted) { } } -ChatRoomLogScope::ChatRoomLogScope(const LinphoneChatRoom *cr) +ChatRoomLogContextualizer::ChatRoomLogContextualizer(const LinphoneChatRoom *cr) : CoreLogContextualizer(*L_GET_CPP_PTR_FROM_C_OBJECT(cr)) { } diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index 5998d902db51d8176e99f240a90114fe4b465132..c78b1a599a99617f000d18fea5d5a47f8369f2ee 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -134,9 +134,9 @@ private: L_DISABLE_COPY(ChatRoom); }; -class ChatRoomLogScope : CoreLogContextualizer { +class ChatRoomLogContextualizer : CoreLogContextualizer { public: - ChatRoomLogScope(const LinphoneChatRoom *cr); + ChatRoomLogContextualizer(const LinphoneChatRoom *cr); }; LINPHONE_END_NAMESPACE diff --git a/src/event/event.h b/src/event/event.h index f2833f4bd8318a74fe72309d7241263b27b1d5d8..ea8a767230c333da440a36c3074450ab529f7ba4 100644 --- a/src/event/event.h +++ b/src/event/event.h @@ -114,9 +114,9 @@ private: mutable LinphoneErrorInfo *mEi = nullptr; }; -class EventLogScope : public CoreLogContextualizer { +class EventLogContextualizer : public CoreLogContextualizer { public: - EventLogScope(const LinphoneEvent *ev) : CoreLogContextualizer(*Event::toCpp(ev)) { + EventLogContextualizer(const LinphoneEvent *ev) : CoreLogContextualizer(*Event::toCpp(ev)) { } }; diff --git a/src/sal/call-op.cpp b/src/sal/call-op.cpp index 1018de46032e7aa4d75de86715e0b1227ed6c49c..11f7a606dd8a9e93ff025ecf13e374b53f3a20f2 100644 --- a/src/sal/call-op.cpp +++ b/src/sal/call-op.cpp @@ -1649,7 +1649,8 @@ int SalCallOp::setReferrer(SalCallOp *referredCall) { SalCallOp *SalCallOp::getReplaces() const { if (!mReplaces) return nullptr; - + const char *from_tag = belle_sip_header_replaces_get_from_tag(mReplaces); + const char *to_tag = belle_sip_header_replaces_get_to_tag(mReplaces); // rfc3891 // 3. User Agent Server Behavior: Receiving a Replaces Header // @@ -1662,10 +1663,9 @@ SalCallOp *SalCallOp::getReplaces() const { // is compared to the local tag, and the from-tag parameter is compared // to the remote tag. auto dialog = belle_sip_provider_find_dialog(mRoot->mProvider, belle_sip_header_replaces_get_call_id(mReplaces), - belle_sip_header_replaces_get_to_tag(mReplaces), - belle_sip_header_replaces_get_from_tag(mReplaces)); + to_tag, from_tag); - if (!dialog && strcmp(belle_sip_header_replaces_get_to_tag(mReplaces), "0") == 0) { + if (!dialog && (to_tag == NULL || strcmp(belle_sip_header_replaces_get_to_tag(mReplaces), "0") == 0)) { // even if not described in rfc3891, in case of very early network switch at caller side, we might receive a // replace header without to-tag. Give a chance to find the early dialog dialog = belle_sip_provider_find_dialog_with_remote_tag(mRoot->mProvider, diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 39f4b23d2b1d668c1bbd1c02aeb98c796d153800..5fe9986df6cde8a03dfbece413b77ec8e7784f05 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -7305,6 +7305,58 @@ static void simple_call_with_display_name(void) { linphone_core_manager_destroy(pauline); } +static void call_received_with_tel_uri(void) { + const char *invite = "INVITE sip:49.14.153.62:34247;transport=udp SIP/2.0\r\n" + "Via: SIP/2.0/UDP 127.0.0.1:80;branch=z9hG4bKd1615h3de26kgeh6k1202gzb4T12045\r\n" + "Call-ID: asbc16ja7z3sau4j2u2jzdx063zj6zj6336n@10.191.176.18\r\n" + "From: <tel:+123456789>;tag=sbc0502naux6xjz\r\n" + "To: <tel:+1234567890>\r\n" + "CSeq: 1 INVITE\r\n" + "Allow: UPDATE,INFO,PRACK,NOTIFY,OPTIONS,INVITE,ACK,BYE,CANCEL\r\n" + "Contact: <sip:127.0.0.1:80;Dpt=eb7a-200>\r\n" + "Max-Forwards: 66\r\n" + "Supported: timer,100rel,histinfo,early-session\r\n" + "Session-Expires: 1800\r\n" + "Min-SE: 600\r\n" + "P-Asserted-Identity: <tel:+919599936258>\r\n" + "P-Called-Party-ID: <tel:+919403993402>\r\n" + "P-Notification: caller-control\r\n" + "Content-Length: 229\r\n" + "Content-Type: application/sdp\r\n" + "Content-Disposition: session\r\n" + "\r\n" + "v=0\r\n" + "o=- 213464062 213464062 IN IP4 127.0.0.1\r\n" + "s=SBC call\r\n" + "c=IN IP4 127.0.0.1\r\n" + "t=0 0\r\n" + "m=audio 1023 RTP/AVP 8 96 0\r\n" + "b=AS:80\r\n" + "a=rtpmap:8 PCMA/8000\r\n" + "a=rtpmap:96 telephone-event/8000\r\n" + "a=ptime:20\r\n" + "a=maxptime:20\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "\r\n"; + + LinphoneCoreManager *laure = linphone_core_manager_new("laure_rc_udp"); + + LinphoneTransports *tp = linphone_core_get_transports_used(laure->lc); + + BC_ASSERT_TRUE(liblinphone_tester_send_data(invite, strlen(invite), "127.0.0.1", + linphone_transports_get_udp_port(tp), SOCK_DGRAM) > 0); + linphone_transports_unref(tp); + + BC_ASSERT_TRUE(wait_for(laure->lc, NULL, &laure->stat.number_of_LinphoneCallIncomingReceived, 1)); + linphone_call_accept(linphone_core_get_current_call(laure->lc)); + BC_ASSERT_TRUE(wait_for(laure->lc, NULL, &laure->stat.number_of_LinphoneCallStreamsRunning, 1)); + linphone_call_terminate(linphone_core_get_current_call(laure->lc)); + + BC_ASSERT_TRUE(wait_for(laure->lc, NULL, &laure->stat.number_of_LinphoneCallEnd, 1)); + BC_ASSERT_TRUE(wait_for_until(laure->lc, NULL, &laure->stat.number_of_LinphoneCallReleased, 1, 36000)); + linphone_core_manager_destroy(laure); +} + static test_t call_tests[] = { TEST_NO_TAG("Simple double call", simple_double_call), TEST_NO_TAG("Simple call with no SIP transport", simple_call_with_no_sip_transport), @@ -7450,8 +7502,7 @@ static test_t call_not_established_tests[] = { TEST_NO_TAG("Call declined, other ringing device receive CANCEL with reason", cancel_other_device_after_decline), TEST_NO_TAG("Call with malformed from", call_with_maformed_from), TEST_NO_TAG("Call rejected with 403", call_rejected_with_403), - -}; + TEST_NO_TAG("Call with tel uri", call_received_with_tel_uri)}; test_suite_t call_test_suite = {"Single Call", NULL, @@ -7479,4 +7530,4 @@ test_suite_t call_not_established_test_suite = {"Single Call (Not established)", sizeof(call_not_established_tests) / sizeof(call_not_established_tests[0]), call_not_established_tests, - 0}; + 304}; diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 65a51cd6a956ef3e47152903f6f3c64abf45e47b..014d9d2d0b2c8f7ee8b31efd7b1ed8241dac22e1 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -519,7 +519,7 @@ void liblinphone_tester_add_suites(void) { liblinphone_tester_add_suite_with_default_time(&offeranswer_test_suite, 185); liblinphone_tester_add_suite_with_default_time(&call_test_suite, 409); liblinphone_tester_add_suite_with_default_time(&call2_test_suite, 244); - liblinphone_tester_add_suite_with_default_time(&call_not_established_test_suite, 214); + bc_tester_add_suite(&call_not_established_test_suite); liblinphone_tester_add_suite_with_default_time(&push_incoming_call_test_suite, 40); liblinphone_tester_add_suite_with_default_time(&call_recovery_test_suite, 246); liblinphone_tester_add_suite_with_default_time(&call_with_ice_test_suite, 324); diff --git a/tester/setup_tester.c b/tester/setup_tester.c index 089f451ee946707d735ca1044a7ef13419eb5154..d08e364f36b628131bea757687f2499f896c5d03 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -1970,9 +1970,12 @@ static void search_friend_with_aggregation(void) { it = bctbx_list_next(phone_numbers); const LinphoneFriendPhoneNumber *phone_number2 = (const LinphoneFriendPhoneNumber *)it->data; const char *number2 = linphone_friend_phone_number_get_phone_number(phone_number2); - const char *label2 = linphone_friend_phone_number_get_label(phone_number2); + BC_ASSERT_STRING_EQUAL(number2, "+33901020304"); - BC_ASSERT_PTR_NULL(label2); + const char *label2 = linphone_friend_phone_number_get_label(phone_number2); + if (!BC_ASSERT_PTR_NULL(label2)) { + ms_error("label was: %s", label2); + } bctbx_list_free_with_data(phone_numbers, (bctbx_list_free_func)linphone_friend_phone_number_unref); }