diff --git a/src/chat/chat-message.cpp b/src/chat/chat-message.cpp index 5a9a678a8..fa4c931a7 100644 --- a/src/chat/chat-message.cpp +++ b/src/chat/chat-message.cpp @@ -1310,6 +1310,11 @@ void ChatMessage::removeContent (const Content& content) { d->contents.remove(content); } +const Content& ChatMessage::getInternalContent() const { + L_D(); + return d->internalContent; +} + string ChatMessage::getCustomHeaderValue (const string &headerName) const { L_D(); try { diff --git a/src/chat/chat-message.h b/src/chat/chat-message.h index 14af85871..09bc267cf 100644 --- a/src/chat/chat-message.h +++ b/src/chat/chat-message.h @@ -125,6 +125,7 @@ public: const std::list& getContents() const; void addContent(const Content& content); void removeContent(const Content& content); + const Content& getInternalContent() const; std::string getCustomHeaderValue(const std::string &headerName) const; void addCustomHeader(const std::string &headerName, const std::string &headerValue); diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index c46dd0223..8cac39ada 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -89,6 +89,7 @@ int CpimChatMessageModifier::decode (ChatMessagePrivate *messagePrivate) { ContentType newContentType(message->getContentHeaders()->front()->getValue()); newContent.setContentType(newContentType); newContent.setBody(message->getContent()); + messagePrivate->internalContent = newContent; } else { //TODO } diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 09e8bb4d9..8c0ac3f10 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -17,6 +17,9 @@ */ #include "chat/cpim/cpim.h" +#include "address/address.h" +#include "chat/basic-chat-room.h" +#include "chat/chat-message.h" #include "liblinphone_tester.h" @@ -379,12 +382,29 @@ static void build_message () { BC_ASSERT_STRING_EQUAL(strMessage.c_str(), expectedMessage.c_str()); } -static void cpim_chat_message_modifier_encoder(void) { - -} +static void cpim_chat_message_modifier(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + LpConfig *config = linphone_core_get_config(marie->lc); + lp_config_set_int(config, "sip", "use_cpim", 1); -static void cpim_chat_message_modifier_decoder(void) { + Address paulineAddress(linphone_address_as_string_uri_only(pauline->identity)); + shared_ptr marieRoom = ObjectFactory::create(marie->lc, paulineAddress); + + shared_ptr marieMessage = marieRoom->createMessage("Hello CPIM"); + marieRoom->sendMessage(marieMessage); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1)); + BC_ASSERT_TRUE(ContentType::isCpim(marieMessage->getInternalContent().getContentType().asString())); + BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message); + if (pauline->stat.last_received_chat_message != NULL) { + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline->stat.last_received_chat_message), "Hello CPIM"); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), "text/plain"); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); } test_t cpim_tests[] = { @@ -397,8 +417,7 @@ test_t cpim_tests[] = { TEST_NO_TAG("Parse RFC example", parse_rfc_example), TEST_NO_TAG("Parse Message with generic header parameters", parse_message_with_generic_header_parameters), TEST_NO_TAG("Build Message", build_message), - TEST_NO_TAG("CPIM chat message modifier encoder", cpim_chat_message_modifier_encoder), - TEST_NO_TAG("CPIM chat message modifier decoder", cpim_chat_message_modifier_decoder) + TEST_NO_TAG("CPIM chat message modifier", cpim_chat_message_modifier) }; test_suite_t cpim_test_suite = {