Commit 12f0e6c1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed issue when downloading a file from a chat message loaded from database (and thus locked)

parent 30380ff3
......@@ -138,6 +138,9 @@ public:
LinphoneContent *getFileTransferInformation () const;
void setFileTransferInformation (const LinphoneContent *content);
void addContent (Content &content);
void removeContent (const Content &content);
bool downloadFile ();
......
......@@ -371,6 +371,14 @@ bool ChatMessagePrivate::downloadFile () {
return false;
}
void ChatMessagePrivate::addContent (Content &content) {
getContents().push_back(&content);
}
void ChatMessagePrivate::removeContent (const Content &content) {
getContents().remove(&const_cast<Content &>(content));
}
void ChatMessagePrivate::loadFileTransferUrlFromBodyToContent() {
L_Q();
int errorCode = 0;
......@@ -718,7 +726,7 @@ void ChatMessagePrivate::send () {
if (content->getContentType() == ContentType::FileTransfer) {
FileTransferContent *fileTransferContent = (FileTransferContent *)content;
it = contents.erase(it);
q->addContent(*fileTransferContent->getFileContent());
addContent(*fileTransferContent->getFileContent());
delete fileTransferContent;
} else {
it++;
......@@ -962,13 +970,13 @@ const list<Content *> &ChatMessage::getContents () const {
void ChatMessage::addContent (Content &content) {
L_D();
if (!d->isReadOnly)
d->getContents().push_back(&content);
d->addContent(content);
}
void ChatMessage::removeContent (const Content &content) {
L_D();
if (!d->isReadOnly)
d->getContents().remove(&const_cast<Content &>(content));
d->removeContent(content);
}
const Content &ChatMessage::getInternalContent () const {
......
......@@ -750,12 +750,12 @@ void FileTransferChatMessageModifier::onRecvEnd (belle_sip_user_body_handler_t *
if (retval <= 0 && message->getState() != ChatMessage::State::FileTransferError) {
// Remove the FileTransferContent from the message and store the FileContent
FileContent *fileContent = currentFileContentToTransfer;
message->addContent(*fileContent);
message->getPrivate()->addContent(*fileContent);
for (Content *content : message->getContents()) {
if (content->getContentType() == ContentType::FileTransfer) {
FileTransferContent *fileTransferContent = (FileTransferContent*)content;
if (fileTransferContent->getFileContent() == fileContent) {
message->removeContent(*content);
message->getPrivate()->removeContent(*content);
delete fileTransferContent;
break;
}
......
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