From 3b10f8da340a089353817ee1b0989a7a5151a8ed Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 3 Oct 2017 18:03:50 +0200 Subject: [PATCH] Include the body containing the list of addresses to invite when sending the INVITE to create a client group chat room. --- coreapi/sal/call_op.cpp | 5 +++++ src/chat/client-group-chat-room.cpp | 3 +-- src/conference/session/call-session.cpp | 4 +++- src/conference/session/call-session.h | 3 ++- src/conference/session/media-session.cpp | 4 ++-- src/conference/session/media-session.h | 2 +- src/content/content.cpp | 4 ++++ 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/coreapi/sal/call_op.cpp b/coreapi/sal/call_op.cpp index 68daf9355..6c3b50ba6 100644 --- a/coreapi/sal/call_op.cpp +++ b/coreapi/sal/call_op.cpp @@ -76,6 +76,7 @@ belle_sip_header_allow_t *SalCallOp::create_allow(bool_t enable_update) { int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { ContentType contentType = body.getContentType(); + string contentDisposition = body.getContentDisposition(); size_t bodySize = body.getBody().size(); if (bodySize > SIP_MESSAGE_BODY_LIMIT) { @@ -87,6 +88,10 @@ int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { belle_sip_header_content_type_t *content_type = belle_sip_header_content_type_create(contentType.getType().c_str(), contentType.getSubType().c_str()); belle_sip_message_add_header(msg, BELLE_SIP_HEADER(content_type)); } + if (!contentDisposition.empty()) { + belle_sip_header_content_disposition_t *contentDispositionHeader = belle_sip_header_content_disposition_create(contentDisposition.c_str()); + belle_sip_message_add_header(msg, BELLE_SIP_HEADER(contentDispositionHeader)); + } belle_sip_header_content_length_t *content_length = belle_sip_header_content_length_create(bodySize); belle_sip_message_add_header(msg, BELLE_SIP_HEADER(content_length)); diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index e5890910e..5b2246a5d 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -63,7 +63,6 @@ void ClientGroupChatRoom::addParticipants (const list
&addresses, const content.setBody(getResourceLists(sortedAddresses)); content.setContentType("application/resource-lists+xml"); content.setContentDisposition("recipient-list"); - lInfo() << "Body size: " << content.getSize() << endl << "Body:" << endl << content.getBodyAsString(); CallSessionParams csp; if (params) csp = *params; @@ -74,7 +73,7 @@ void ClientGroupChatRoom::addParticipants (const list
&addresses, const Address addr = me->getAddress(); addr.setParam("text"); session->getPrivate()->getOp()->set_contact_address(addr.getPrivate()->getInternalAddress()); - session->startInvite(nullptr, subject); + session->startInvite(nullptr, subject, &content); d->setState(ChatRoom::State::CreationPending); } // TODO diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index c28da3455..bf8e903ec 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -867,7 +867,7 @@ void CallSession::startIncomingNotification () { } } -int CallSession::startInvite (const Address *destination, const string &subject) { +int CallSession::startInvite (const Address *destination, const string &subject, const Content *content) { L_D(); d->subject = subject; /* Try to be best-effort in giving real local or routable contact address */ @@ -884,6 +884,8 @@ int CallSession::startInvite (const Address *destination, const string &subject) char *from = linphone_address_as_string(d->log->from); /* Take a ref because sal_call() may destroy the CallSession if no SIP transport is available */ shared_ptr ref = getSharedFromThis(); + if (content) + d->op->set_local_body(*content); int result = d->op->call(from, destinationStr.c_str(), subject.empty() ? nullptr : subject.c_str()); ms_free(from); if (result < 0) { diff --git a/src/conference/session/call-session.h b/src/conference/session/call-session.h index 6116895fb..d53f8d26e 100644 --- a/src/conference/session/call-session.h +++ b/src/conference/session/call-session.h @@ -32,6 +32,7 @@ LINPHONE_BEGIN_NAMESPACE class CallPrivate; class CallSessionPrivate; +class Content; class LINPHONE_PUBLIC CallSession : public Object { friend class CallPrivate; @@ -53,7 +54,7 @@ public: LinphoneStatus redirect (const std::string &redirectUri); LinphoneStatus redirect (const Address &redirectAddr); virtual void startIncomingNotification (); - virtual int startInvite (const Address *destination, const std::string &subject = ""); + virtual int startInvite (const Address *destination, const std::string &subject = "", const Content *content = nullptr); LinphoneStatus terminate (const LinphoneErrorInfo *ei = nullptr); LinphoneStatus update (const CallSessionParams *csp, const std::string &subject = ""); diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index c19d55098..c56921792 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -4249,7 +4249,7 @@ void MediaSession::startIncomingNotification () { CallSession::startIncomingNotification(); } -int MediaSession::startInvite (const Address *destination, const string &subject) { +int MediaSession::startInvite (const Address *destination, const string &subject, const Content *content) { L_D(); linphone_core_stop_dtmf_stream(d->core); d->makeLocalMediaDescription(); @@ -4265,7 +4265,7 @@ int MediaSession::startInvite (const Address *destination, const string &subject d->op->set_local_media_description(d->localDesc); } - int result = CallSession::startInvite(destination, subject); + int result = CallSession::startInvite(destination, subject, content); if (result < 0) { if (d->state == LinphoneCallError) d->stopStreams(); diff --git a/src/conference/session/media-session.h b/src/conference/session/media-session.h index 60e2163e2..4318d70dd 100644 --- a/src/conference/session/media-session.h +++ b/src/conference/session/media-session.h @@ -48,7 +48,7 @@ public: LinphoneStatus resume (); void sendVfuRequest (); void startIncomingNotification () override; - int startInvite (const Address *destination, const std::string &subject = "") override; + int startInvite (const Address *destination, const std::string &subject = "", const Content *content = nullptr) override; void startRecording (); void stopRecording (); LinphoneStatus update (const MediaSessionParams *msp, const std::string &subject = ""); diff --git a/src/content/content.cpp b/src/content/content.cpp index 2c3786ea5..25cf8dd91 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -42,12 +42,14 @@ Content::Content (const Content &src) : ClonableObject(*new ContentPrivate) { L_D(); d->body = src.getBody(); d->contentType = src.getContentType(); + d->contentDisposition = src.getContentDisposition(); } Content::Content (Content &&src) : ClonableObject(*new ContentPrivate) { L_D(); d->body = move(src.getPrivate()->body); d->contentType = move(src.getPrivate()->contentType); + d->contentDisposition = move(src.getPrivate()->contentDisposition); } Content &Content::operator= (const Content &src) { @@ -55,6 +57,7 @@ Content &Content::operator= (const Content &src) { if (this != &src) { d->body = src.getBody(); d->contentType = src.getContentType(); + d->contentDisposition = src.getContentDisposition(); } return *this; @@ -64,6 +67,7 @@ Content &Content::operator= (Content &&src) { L_D(); d->body = move(src.getPrivate()->body); d->contentType = move(src.getPrivate()->contentType); + d->contentDisposition = move(src.getPrivate()->contentDisposition); return *this; }