Commit 826ab2fc authored by jehan's avatar jehan Committed by jehan

Change behavior of ContentType == operator to not take parameters into account.

parent 670f01c5
......@@ -283,7 +283,7 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag
);
Content content;
if (message->url && (ContentType(message->content_type).weakEqual(ContentType::ExternalBody))) {
if (message->url && ContentType(message->content_type) == ContentType::ExternalBody) {
lInfo() << "Received a message with an external body URL " << message->url;
content.setContentType(ContentType::FileTransfer);
content.setBody(msg->getPrivate()->createFakeFileTransferFromUrl(message->url));
......
......@@ -204,7 +204,7 @@ void Imdn::parse (const shared_ptr<ChatMessage> &chatMessage) {
bool Imdn::isError (const shared_ptr<ChatMessage> &chatMessage) {
for (const auto &content : chatMessage->getPrivate()->getContents()) {
if (!content->getContentType().weakEqual(ContentType::Imdn))
if (content->getContentType() != ContentType::Imdn)
continue;
istringstream data(content->getBodyAsString());
unique_ptr<Xsd::Imdn::Imdn> imdn(Xsd::Imdn::parseImdn(data, Xsd::XmlSchema::Flags::dont_validate));
......
......@@ -143,7 +143,7 @@ void RemoteConferenceListEventHandler::notifyReceived (const Content *notifyCont
char *from = linphone_address_as_string(linphone_event_get_from(lev));
const IdentityAddress local(from);
if (notifyContent->getContentType().weakEqual(ContentType::ConferenceInfo)) {
if (notifyContent->getContentType() == ContentType::ConferenceInfo) {
// Simple notify received directly from a chat-room
const string &xmlBody = notifyContent->getBodyAsUtf8String();
istringstream data(xmlBody);
......@@ -193,9 +193,9 @@ void RemoteConferenceListEventHandler::notifyReceived (const Content *notifyCont
if (!handler)
continue;
if (contentType.weakEqual(ContentType::Multipart))
if (contentType == ContentType::Multipart)
handler->multipartNotifyReceived(body);
else if (contentType.weakEqual(ContentType::ConferenceInfo))
else if (contentType == ContentType::ConferenceInfo)
handler->notifyReceived(body);
}
}
......
......@@ -133,12 +133,12 @@ ContentType &ContentType::operator= (const ContentType &other) {
return *this;
}
bool ContentType::weakEqual (const ContentType &other) const {
bool ContentType::operator== (const ContentType &other) const {
return (getType() == other.getType()) && (getSubType() == other.getSubType());
}
bool ContentType::operator== (const ContentType &other) const {
if (!weakEqual(other))
bool ContentType::strongEqual(const ContentType &other) const {
if ( *this != other)
return false;
if (getParameters().size() != other.getParameters().size())
return false;
......
......@@ -40,8 +40,10 @@ public:
ContentType &operator= (const ContentType &other);
bool weakEqual (const ContentType &other) const;
bool strongEqual (const ContentType &other) const;
/*does not check parameters*/
bool operator== (const ContentType &other) const;
/*does not check parameters*/
bool operator!= (const ContentType &other) const;
// Delete these operators to prevent putting complicated content-type strings
......
......@@ -107,9 +107,11 @@ LinphoneChatMessage* create_file_transfer_message_from_sintel_trailer(LinphoneCh
return msg;
}
void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) {
LinphoneChatRoom *room = linphone_core_get_chat_room(pauline->lc,marie->identity);
LinphoneChatMessage* msg = linphone_chat_room_create_message(room,"Bli bli bli \n blu");
void text_message_base_with_text(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, const char* text, const char* content_type) {
LinphoneChatRoom *room = linphone_core_get_chat_room(pauline->lc,/*linphone_address_new("sip:jehan-iphone@sip.linphone.org")*/marie->identity);
LinphoneChatMessage* msg = linphone_chat_room_create_message(room, text);
linphone_chat_message_set_content_type(msg, content_type);
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_send(msg);
......@@ -118,13 +120,36 @@ void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline)
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_PTR_NOT_NULL(marie->stat.last_received_chat_message);
if (marie->stat.last_received_chat_message != NULL) {
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(marie->stat.last_received_chat_message), "text/plain");
LinphoneContent *content = (LinphoneContent *)(linphone_chat_message_get_contents(marie->stat.last_received_chat_message)->data);
char* content_type_header = ms_strdup_printf("Content-Type: %s",content_type);
belle_sip_header_content_type_t *belle_sip_content_type = belle_sip_header_content_type_parse(content_type_header);
BC_ASSERT_STRING_EQUAL(linphone_content_get_type(content), belle_sip_header_content_type_get_type(belle_sip_content_type));
BC_ASSERT_STRING_EQUAL(linphone_content_get_subtype(content), belle_sip_header_content_type_get_subtype(belle_sip_content_type));
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie->stat.last_received_chat_message), text);
ms_free(content_type_header);
LinphoneChatRoom *marieCr = linphone_core_get_chat_room(marie->lc, pauline->identity);
if (!marieCr) {
//next try in case of private message
marieCr = linphone_chat_message_get_chat_room(marie->stat.last_received_chat_message);
}
BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(marieCr), 1, int," %i");
if (linphone_chat_room_get_history_size(marieCr) > 0) {
bctbx_list_t *history = linphone_chat_room_get_history(marieCr, 1);
LinphoneChatMessage *recv_msg = (LinphoneChatMessage *)(history->data);
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(recv_msg), text);
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text_content(recv_msg),text);
bctbx_list_free_with_data(history, (bctbx_list_free_func)linphone_chat_message_unref);
}
}
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity));
linphone_chat_message_unref(msg);
}
void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) {
text_message_base_with_text(marie,pauline, "Bli bli bli \n blu", "text/plain");
}
/****************************** Tests starting below ******************************/
static void text_message(void) {
......@@ -137,6 +162,16 @@ static void text_message(void) {
linphone_core_manager_destroy(pauline);
}
static void text_message_with_utf8(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
text_message_base_with_text(marie, pauline, "Salut Fran\xc3\xa7ois", "text/plain;charset=UTF-8");
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void text_message_within_call_dialog(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
......@@ -2345,6 +2380,7 @@ static void migration_from_messages_db (void) {
test_t message_tests[] = {
TEST_NO_TAG("Text message", text_message),
TEST_NO_TAG("Text message UTF8", text_message_with_utf8),
TEST_NO_TAG("Text message with credentials from auth callback", text_message_with_credential_from_auth_callback),
TEST_NO_TAG("Text message with privacy", text_message_with_privacy),
TEST_NO_TAG("Text message compatibility mode", text_message_compatibility_mode),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment