Commit 0b5defc7 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed cache string in c-chat-message

parent 8ee8885d
......@@ -46,7 +46,7 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(ChatMessage,
LinphoneAddress *to; // cache for shared_ptr<Address>
LinphoneChatMessageStateChangedCb message_state_changed_cb;
void* message_state_changed_user_data;
mutable string contentTypeCache;
mutable char *contentTypeCache;
)
static void _linphone_chat_message_constructor (LinphoneChatMessage *msg) {
......@@ -60,6 +60,8 @@ static void _linphone_chat_message_destructor (LinphoneChatMessage *msg) {
linphone_address_unref(msg->from);
if (msg->to)
linphone_address_unref(msg->to);
if (msg->contentTypeCache)
ms_free(msg->contentTypeCache);
}
// =============================================================================
......@@ -319,8 +321,11 @@ void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChat
// =============================================================================
const char * linphone_chat_message_get_content_type(LinphoneChatMessage *msg) {
msg->contentTypeCache = L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().asString();
return L_STRING_TO_C(msg->contentTypeCache);
if (msg->contentTypeCache) {
ms_free(msg->contentTypeCache);
}
msg->contentTypeCache = ms_strdup(L_STRING_TO_C(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getContentType().asString()));
return msg->contentTypeCache;
}
void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type) {
......
......@@ -551,6 +551,12 @@ void ChatRoom::compose () {
shared_ptr<ChatMessage> ChatRoom::createFileTransferMessage (const LinphoneContent *initialContent) {
L_D();
shared_ptr<ChatMessage> chatMessage = createMessage();
/* TODO
Content content;
content.setContentType(ContentType::FileTransfer);
content.setBody(linphone_content_get_string_buffer(initialContent));
chatMessage->addContent(content);*/
chatMessage->setToAddress(d->peerAddress);
chatMessage->setFromAddress(linphone_core_get_identity(d->core));
......@@ -565,7 +571,7 @@ shared_ptr<ChatMessage> ChatRoom::createMessage (const string &message) {
shared_ptr<ChatMessage> chatMessage = createMessage();
Content content;
content.setContentType("text/plain");
content.setContentType(ContentType::PlainText);
content.setBody(message);
chatMessage->addContent(content);
......
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