From 8f2be0252a03c9fc8361d3221e94f6c5325163dd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 26 Mar 2018 10:57:08 +0200 Subject: [PATCH] Fixed 2 issues related to content type parameters : one in = operator, one in the Sal --- src/content/content-type.cpp | 1 + src/content/header/header.cpp | 5 +++++ src/content/header/header.h | 1 + src/sal/op.cpp | 8 +++++++- tester/multipart-tester.cpp | 16 +++++++++++++--- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index be3b7da00..e34241a40 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -121,6 +121,7 @@ ContentType &ContentType::operator= (const ContentType &other) { if (this != &other) { setType(other.getType()); setSubType(other.getSubType()); + cleanParameters(); addParameters(other.getParameters()); } diff --git a/src/content/header/header.cpp b/src/content/header/header.cpp index a621a2e8b..0c8017e60 100644 --- a/src/content/header/header.cpp +++ b/src/content/header/header.cpp @@ -35,6 +35,11 @@ Header::Header(HeaderPrivate &p) : ClonableObject(p) { } +void Header::cleanParameters() { + L_D(); + d->parameters.clear(); +} + const std::list &Header::getParameters () const { L_D(); diff --git a/src/content/header/header.h b/src/content/header/header.h index 9fb3dab47..822839516 100644 --- a/src/content/header/header.h +++ b/src/content/header/header.h @@ -33,6 +33,7 @@ class HeaderParam; class LINPHONE_PUBLIC Header : public ClonableObject { public: + void cleanParameters(); const std::list &getParameters () const; void addParameter (const std::string ¶mName, const std::string ¶mValue); void addParameter (const HeaderParam ¶m); diff --git a/src/sal/op.cpp b/src/sal/op.cpp index e5e211f3b..497a7a99b 100644 --- a/src/sal/op.cpp +++ b/src/sal/op.cpp @@ -1029,12 +1029,18 @@ void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { /* if we just deciphered a message, use the deciphered part(which can be a rcs xml body pointing to the file to retreive from server)*/ salmsg.text=(!external_body)?belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)):NULL; salmsg.url=NULL; - salmsg.content_type = ms_strdup_printf("%s/%s", belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type)); + + char buffer[1024]; + size_t offset = 0; + belle_sip_parameters_marshal(BELLE_SIP_PARAMETERS(content_type), buffer, 1024, &offset); + buffer[offset] = '\0'; + salmsg.content_type = ms_strdup_printf("%s/%s%s", belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), buffer); if (external_body && belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")) { size_t url_length=strlen(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")); salmsg.url = ms_strdup(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")+1); /* skip first "*/ ((char*)salmsg.url)[url_length-2]='\0'; /*remove trailing "*/ } + salmsg.message_id=message_id; salmsg.time=date ? belle_sip_header_date_get_time(date) : time(NULL); this->root->callbacks.message_received(this,&salmsg); diff --git a/tester/multipart-tester.cpp b/tester/multipart-tester.cpp index d3b9f21b5..c94dc9a2e 100644 --- a/tester/multipart-tester.cpp +++ b/tester/multipart-tester.cpp @@ -82,9 +82,19 @@ static void chat_message_multipart_modifier_base(bool first_file_transfer, bool BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message); - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), "multipart/mixed"); - if (!first_file_transfer) { - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline->stat.last_received_chat_message), "Hello part 1"); + + if (first_file_transfer || second_file_transfer) { + LinphoneContent *content = linphone_chat_message_get_file_transfer_information(pauline->stat.last_received_chat_message); + BC_ASSERT_PTR_NOT_NULL(content); + linphone_content_unref(content); + } + if (!first_file_transfer || !second_file_transfer) { + const char *content = linphone_chat_message_get_text_content(pauline->stat.last_received_chat_message); + BC_ASSERT_PTR_NOT_NULL(content); + if (!first_file_transfer) + BC_ASSERT_STRING_EQUAL(content, "Hello part 1"); + else if (!second_file_transfer) + BC_ASSERT_STRING_EQUAL(content, "Hello part 2"); } linphone_core_manager_destroy(marie);