Fixed 2 issues related to content type parameters : one in = operator, one in the Sal

This commit is contained in:
Sylvain Berfini 2018-03-26 10:57:08 +02:00
parent c0a7c027a6
commit 8f2be0252a
5 changed files with 27 additions and 4 deletions

View file

@ -121,6 +121,7 @@ ContentType &ContentType::operator= (const ContentType &other) {
if (this != &other) {
setType(other.getType());
setSubType(other.getSubType());
cleanParameters();
addParameters(other.getParameters());
}

View file

@ -35,6 +35,11 @@ Header::Header(HeaderPrivate &p) : ClonableObject(p) {
}
void Header::cleanParameters() {
L_D();
d->parameters.clear();
}
const std::list<HeaderParam> &Header::getParameters () const {
L_D();

View file

@ -33,6 +33,7 @@ class HeaderParam;
class LINPHONE_PUBLIC Header : public ClonableObject {
public:
void cleanParameters();
const std::list<HeaderParam> &getParameters () const;
void addParameter (const std::string &paramName, const std::string &paramValue);
void addParameter (const HeaderParam &param);

View file

@ -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);

View file

@ -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);