mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 17:29:20 +00:00
Use GRUU address in From header when sending messages.
This commit is contained in:
parent
1ca9d64af8
commit
cf7c300b07
9 changed files with 38 additions and 37 deletions
|
|
@ -3542,9 +3542,11 @@ static void linphone_transfer_routes_to_op(bctbx_list_t *routes, SalOp *op){
|
|||
|
||||
void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy){
|
||||
bctbx_list_t *routes=NULL;
|
||||
const LinphoneAddress *contactAddr = nullptr;
|
||||
const char *identity;
|
||||
|
||||
if (proxy){
|
||||
contactAddr = linphone_proxy_config_get_contact(proxy);
|
||||
identity=linphone_proxy_config_get_identity(proxy);
|
||||
if (linphone_proxy_config_get_privacy(proxy)!=LinphonePrivacyDefault) {
|
||||
op->set_privacy(linphone_proxy_config_get_privacy(proxy));
|
||||
|
|
@ -3569,7 +3571,12 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon
|
|||
ms_free(addr);
|
||||
}
|
||||
|
||||
op->set_from(identity);
|
||||
if (op->getUseGruuInFrom() && contactAddr && linphone_address_has_uri_param(contactAddr, "gr")) {
|
||||
char *contactAddrStr = linphone_address_as_string_uri_only(contactAddr);
|
||||
op->set_from(contactAddrStr);
|
||||
bctbx_free(contactAddrStr);
|
||||
} else
|
||||
op->set_from(identity);
|
||||
op->set_sent_custom_header(headers);
|
||||
op->set_realm(linphone_proxy_config_get_realm(proxy));
|
||||
|
||||
|
|
|
|||
|
|
@ -1433,11 +1433,16 @@ uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cf
|
|||
|
||||
const LinphoneAddress *linphone_proxy_config_get_contact (const LinphoneProxyConfig *cfg) {
|
||||
// Workaround for wrapping.
|
||||
if (cfg->contact_address)
|
||||
linphone_address_unref(cfg->contact_address);
|
||||
if (cfg->contact_address) {
|
||||
linphone_address_unref(cfg->contact_address);
|
||||
const_cast<LinphoneProxyConfig *>(cfg)->contact_address = NULL;
|
||||
}
|
||||
|
||||
// Warning : Do not remove, the op can change its contact_address
|
||||
char *buf = sal_address_as_string(cfg->op->get_contact_address());
|
||||
const SalAddress *salAddr = cfg->op->get_contact_address();
|
||||
if (!salAddr)
|
||||
return NULL;
|
||||
char *buf = sal_address_as_string(salAddr);
|
||||
const_cast<LinphoneProxyConfig *>(cfg)->contact_address = linphone_address_new(buf);
|
||||
ms_free(buf);
|
||||
|
||||
|
|
|
|||
|
|
@ -574,6 +574,7 @@ void ChatMessagePrivate::send () {
|
|||
LinphoneAddress *peer = linphone_address_new(q->getToAddress().asString().c_str());
|
||||
/* Sending out of call */
|
||||
salOp = op = new SalMessageOp(core->getCCore()->sal);
|
||||
op->setUseGruuInFrom(true);
|
||||
linphone_configure_op(
|
||||
core->getCCore(), op, peer, getSalCustomHeaders(),
|
||||
!!lp_config_get_int(core->getCCore()->config, "sip", "chat_msg_with_contact", 0)
|
||||
|
|
@ -630,26 +631,14 @@ void ChatMessagePrivate::send () {
|
|||
// End of message modification
|
||||
// ---------------------------------------
|
||||
|
||||
if (internalContent.isEmpty()) {
|
||||
if (internalContent.isEmpty())
|
||||
internalContent = *(contents.front());
|
||||
}
|
||||
|
||||
auto msgOp = dynamic_cast<SalMessageOpInterface *>(op);
|
||||
if (internalContent.getContentType().isValid()) {
|
||||
msgOp->send_message(
|
||||
q->getFromAddress().asString().c_str(),
|
||||
q->getToAddress().asString().c_str(),
|
||||
internalContent.getContentType().asString().c_str(),
|
||||
internalContent.getBodyAsString().c_str(),
|
||||
q->getToAddress().asString().c_str()
|
||||
);
|
||||
} else {
|
||||
msgOp->send_message(
|
||||
q->getFromAddress().asString().c_str(),
|
||||
q->getToAddress().asString().c_str(),
|
||||
internalContent.getBodyAsString().c_str()
|
||||
);
|
||||
}
|
||||
msgOp->send_message(internalContent.getContentType().asString().c_str(), internalContent.getBodyAsString().c_str());
|
||||
} else
|
||||
msgOp->send_message(ContentType::PlainText.asString().c_str(), internalContent.getBodyAsString().c_str());
|
||||
|
||||
for (Content *content : contents) {
|
||||
// Restore FileContents and remove FileTransferContents
|
||||
|
|
|
|||
|
|
@ -1501,10 +1501,10 @@ void SalCallOp::process_notify(const belle_sip_request_event_t *event, belle_sip
|
|||
}
|
||||
}
|
||||
|
||||
int SalCallOp::send_message(const char *from, const char *to, const char* content_type, const char *msg, const char *peer_uri) {
|
||||
int SalCallOp::send_message(const char* content_type, const char *msg) {
|
||||
if (!this->dialog) return -1;
|
||||
belle_sip_request_t* req=belle_sip_dialog_create_queued_request(this->dialog,"MESSAGE");
|
||||
prepare_message_request(req, content_type, msg, peer_uri);
|
||||
prepare_message_request(req, content_type, msg);
|
||||
return send_request(req);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public:
|
|||
void set_sdp_handling(SalOpSDPHandling handling);
|
||||
|
||||
// Implementation of SalMessageOpInterface
|
||||
int send_message(const char *from, const char *to, const char* content_type, const char *msg, const char *peer_uri) override;
|
||||
int send_message(const char* content_type, const char *msg) override;
|
||||
int reply(SalReason reason) override {return SalOp::reply_message(reason);}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -26,12 +26,11 @@ class SalMessageOpInterface {
|
|||
public:
|
||||
virtual ~SalMessageOpInterface() = default;
|
||||
|
||||
int send_message(const char *from, const char *to, const char *msg) {return send_message(from,to,"text/plain",msg, nullptr);}
|
||||
virtual int send_message(const char *from, const char *to, const char* content_type, const char *msg, const char *peer_uri) = 0;
|
||||
virtual int send_message(const char* content_type, const char *msg) = 0;
|
||||
virtual int reply(SalReason reason) = 0;
|
||||
|
||||
protected:
|
||||
void prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg, const char *peer_uri);
|
||||
void prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg);
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void SalMessageOp::fill_cbs() {
|
|||
this->type=Type::Message;
|
||||
}
|
||||
|
||||
void SalMessageOpInterface::prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg, const char *peer_uri) {
|
||||
void SalMessageOpInterface::prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg) {
|
||||
char content_type_raw[256];
|
||||
size_t content_length = msg?strlen(msg):0;
|
||||
time_t curtime = ms_time(NULL);
|
||||
|
|
@ -91,16 +91,13 @@ void SalMessageOpInterface::prepare_message_request(belle_sip_request_t *req, co
|
|||
}
|
||||
}
|
||||
|
||||
int SalMessageOp::send_message(const char *from, const char *to, const char* content_type, const char *msg, const char *peer_uri) {
|
||||
int SalMessageOp::send_message(const char* content_type, const char *msg) {
|
||||
fill_cbs();
|
||||
if (from) set_from(from);
|
||||
if (to) set_to(to);
|
||||
this->dir=Dir::Outgoing;
|
||||
|
||||
belle_sip_request_t* req=build_request("MESSAGE");
|
||||
if (req == NULL ) return -1;
|
||||
if (get_contact_address()) belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(create_contact()));
|
||||
prepare_message_request(req, content_type, msg, peer_uri);
|
||||
this->dir = Dir::Outgoing;
|
||||
belle_sip_request_t *req = build_request("MESSAGE");
|
||||
if (!req)
|
||||
return -1;
|
||||
prepare_message_request(req, content_type, msg);
|
||||
return send_request(req);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class SalMessageOp: public SalOp, public SalMessageOpInterface {
|
|||
public:
|
||||
SalMessageOp(Sal *sal): SalOp(sal) {}
|
||||
|
||||
int send_message(const char *from, const char *to, const char* content_type, const char *msg, const char *peer_uri) override;
|
||||
int send_message(const char* content_type, const char *msg) override;
|
||||
int reply(SalReason reason) override {return SalOp::reply_message(reason);}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ public:
|
|||
|
||||
void set_sent_custom_header(SalCustomHeader* ch);
|
||||
|
||||
bool getUseGruuInFrom () { return useGruuInFrom; }
|
||||
void setUseGruuInFrom (bool value) { useGruuInFrom = value; }
|
||||
|
||||
void enable_cnx_ip_to_0000_if_sendonly(bool_t yesno) {this->_cnx_ip_to_0000_if_sendonly_enabled = yesno;}
|
||||
bool_t cnx_ip_to_0000_if_sendonly_enabled() const {return this->_cnx_ip_to_0000_if_sendonly_enabled;}
|
||||
|
||||
|
|
@ -253,6 +256,7 @@ protected:
|
|||
bool_t has_auth_pending = FALSE;
|
||||
bool_t supports_session_timers = FALSE;
|
||||
bool_t op_released = FALSE;
|
||||
bool useGruuInFrom = false;
|
||||
|
||||
friend class Sal;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue