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

This commit is contained in:
Sylvain Berfini 2018-03-07 13:29:15 +01:00
parent 30380ff39e
commit 12f0e6c1ed
3 changed files with 16 additions and 5 deletions

View file

@ -138,6 +138,9 @@ public:
LinphoneContent *getFileTransferInformation () const;
void setFileTransferInformation (const LinphoneContent *content);
void addContent (Content &content);
void removeContent (const Content &content);
bool downloadFile ();

View file

@ -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 {

View file

@ -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;
}