diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index a4163b196..f512f5abc 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -143,7 +143,6 @@ private: FileTransferChatMessageModifier fileTransferChatMessageModifier; // Cache for returned values, used for compatibility with previous C API - std::string appData; std::string fileTransferFilePath; ContentType cContentType; std::string cText; diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index dd5d21be3..c3a520072 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -202,14 +202,22 @@ void ChatMessagePrivate::setFileTransferFilepath (const string &path) { } const string &ChatMessagePrivate::getAppdata () const { - return appData; + for (const Content *c : contents) { + if (c->getContentType().isFile()) { + FileContent *fileContent = (FileContent *)c; + return fileContent->getFilePath(); + } + } + return Utils::getEmptyConstRefObject(); } void ChatMessagePrivate::setAppdata (const string &data) { - appData = data; - - // TODO: history. - // linphone_chat_message_store_appdata(L_GET_C_BACK_PTR(this)); + for (const Content *c : contents) { + if (c->getContentType().isFile()) { + FileContent *fileContent = (FileContent *)c; + return fileContent->setFilePath(data); + } + } } const string &ChatMessagePrivate::getExternalBodyUrl () const { diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index 6f4014c3c..e167a7a7e 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -49,12 +49,7 @@ ChatMessageModifier::Result FileTransferChatMessageModifier::encode (const share // For each FileContent, upload it and create a FileTransferContent for (Content *content : chatMessage->getContents()) { ContentType contentType = content->getContentType(); - //TODO Improve - if (contentType != ContentType::FileTransfer && contentType != ContentType::PlainText && - contentType != ContentType::ExternalBody && contentType != ContentType::Imdn && - contentType != ContentType::ImIsComposing && contentType != ContentType::ResourceLists && - contentType != ContentType::Sdp && contentType != ContentType::ConferenceInfo && - contentType != ContentType::Cpim) { + if (contentType.isFile()) { lInfo() << "Found content with type " << contentType.asString() << ", set it for file upload"; FileContent *fileContent = (FileContent *)content; currentFileContentToTransfer = fileContent; diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index 4be8f9626..00805bfc6 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -154,6 +154,18 @@ bool ContentType::isValid () const { return !d->type.empty() && !d->subType.empty(); } +bool ContentType::isFile() const { + //TODO Improve + if (*this != ContentType::FileTransfer && *this != ContentType::PlainText && + *this != ContentType::ExternalBody && *this != ContentType::Imdn && + *this != ContentType::ImIsComposing && *this != ContentType::ResourceLists && + *this != ContentType::Sdp && *this != ContentType::Cpim && + *this != ContentType::ConferenceInfo) { + return true; + } + return false; +} + string ContentType::asString () const { L_D(); if (isValid()) { diff --git a/src/content/content-type.h b/src/content/content-type.h index f3039c164..fe5147645 100644 --- a/src/content/content-type.h +++ b/src/content/content-type.h @@ -46,6 +46,7 @@ public: bool operator!= (const std::string &contentType) const = delete; bool isValid () const; + bool isFile () const; const std::string &getType () const; bool setType (const std::string &type);