diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 3422a19b7..75e4eb03e 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -59,16 +59,13 @@ shared_ptr ClientGroupChatRoomPrivate::createSession () { CallSessionParams csp; csp.addCustomHeader("Require", "recipient-list-invite"); + csp.addCustomContactParameter("text"); shared_ptr focus = qConference->getPrivate()->focus; shared_ptr session = focus->getPrivate()->createSession(*q, &csp, false, q); const Address &myAddress = q->getMe()->getAddress(); session->configure(LinphoneCallOutgoing, nullptr, nullptr, myAddress, focus->getContactAddress()); session->initiateOutgoing(); - - Address addr = myAddress; - addr.setParam("text"); - session->getPrivate()->getOp()->set_contact_address(addr.getPrivate()->getInternalAddress()); return session; } diff --git a/src/conference/params/call-session-params-p.h b/src/conference/params/call-session-params-p.h index e56e0bb26..23e3eb2ed 100644 --- a/src/conference/params/call-session-params-p.h +++ b/src/conference/params/call-session-params-p.h @@ -20,6 +20,8 @@ #ifndef _CALL_SESSION_PARAMS_P_H_ #define _CALL_SESSION_PARAMS_P_H_ +#include + #include "object/clonable-object-p.h" #include "call-session-params.h" @@ -48,6 +50,8 @@ public: SalCustomHeader * getCustomHeaders () const; void setCustomHeaders (const SalCustomHeader *ch); + const std::unordered_map &getCustomContactParameters () const { return customContactParameters; } + LinphoneCall *getReferer () const { return referer; } void setReferer (LinphoneCall *call) { referer = call; } @@ -61,6 +65,7 @@ private: bool internalCallUpdate = false; bool noUserConsent = false; /* When set to true an UPDATE request will be used instead of reINVITE */ SalCustomHeader *customHeaders = nullptr; + std::unordered_map customContactParameters; LinphoneCall *referer = nullptr; /* In case call creation is consecutive to an incoming transfer, this points to the original call */ L_DECLARE_PUBLIC(CallSessionParams); diff --git a/src/conference/params/call-session-params.cpp b/src/conference/params/call-session-params.cpp index 463e490d2..828d5a50d 100644 --- a/src/conference/params/call-session-params.cpp +++ b/src/conference/params/call-session-params.cpp @@ -54,6 +54,7 @@ void CallSessionParamsPrivate::clone (const CallSessionParamsPrivate &src, CallS /* The management of the custom headers is not optimal. We copy everything while ref counting would be more efficient. */ if (src.customHeaders) dst.customHeaders = sal_custom_header_clone(src.customHeaders); + dst.customContactParameters = src.customContactParameters; dst.referer = src.referer; } @@ -137,4 +138,28 @@ const char * CallSessionParams::getCustomHeader (const string &headerName) const return sal_custom_header_find(d->customHeaders, headerName.c_str()); } +// ----------------------------------------------------------------------------- + +void CallSessionParams::addCustomContactParameter (const std::string ¶mName, const std::string ¶mValue) { + L_D(); + auto it = d->customContactParameters.find(paramName); + if (it != d->customContactParameters.end()) + d->customContactParameters.erase(it); + pair param(paramName, paramValue); + d->customContactParameters.insert(param); +} + +void CallSessionParams::clearCustomContactParameters () { + L_D(); + d->customContactParameters.clear(); +} + +std::string CallSessionParams::getCustomContactParameter (const std::string ¶mName) const { + L_D(); + auto it = d->customContactParameters.find(paramName); + if (it == d->customContactParameters.end()) + return ""; + return it->second; +} + LINPHONE_END_NAMESPACE diff --git a/src/conference/params/call-session-params.h b/src/conference/params/call-session-params.h index 70ed155aa..1d152308f 100644 --- a/src/conference/params/call-session-params.h +++ b/src/conference/params/call-session-params.h @@ -56,6 +56,10 @@ public: void clearCustomHeaders (); const char * getCustomHeader (const std::string &headerName) const; + void addCustomContactParameter (const std::string ¶mName, const std::string ¶mValue = ""); + void clearCustomContactParameters (); + std::string getCustomContactParameter (const std::string ¶mName) const; + protected: explicit CallSessionParams (CallSessionParamsPrivate &p); diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index de2e583ee..ccb20d225 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -600,9 +600,13 @@ void CallSessionPrivate::updateCurrentParams () const {} // ----------------------------------------------------------------------------- void CallSessionPrivate::setContactOp () { + L_Q(); SalAddress *salAddress = nullptr; LinphoneAddress *contact = getFixedContact(); if (contact) { + auto contactParams = q->getParams()->getPrivate()->getCustomContactParameters(); + for (auto it = contactParams.begin(); it != contactParams.end(); it++) + linphone_address_set_param(contact, it->first.c_str(), it->second.empty() ? nullptr : it->second.c_str()); salAddress = const_cast(L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress()); op->set_contact_address(salAddress); linphone_address_unref(contact); @@ -652,10 +656,10 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const { char *addr = sal_address_as_string(pingOp->get_contact_address()); result = linphone_address_new(addr); ms_free(addr); - } else if (destProxy && destProxy->op && _linphone_proxy_config_get_contact_without_params(destProxy)) { + } else if (destProxy && destProxy->op && linphone_proxy_config_get_contact(destProxy)) { /* If using a proxy, use the contact address as guessed with the REGISTERs */ lInfo() << "Contact has been fixed using proxy"; - result = linphone_address_clone(_linphone_proxy_config_get_contact_without_params(destProxy)); + result = linphone_address_clone(linphone_proxy_config_get_contact(destProxy)); } else { result = linphone_core_get_primary_contact_parsed(core); if (result) {