diff --git a/CMakeLists.txt b/CMakeLists.txt index f329f094e..7a0c23d34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ if( NOT (LinphoneCxx_FOUND) OR NOT (Linphone_FOUND) OR NOT (bctoolbox_FOUND) OR message("Linphone packages are not installed. Build and install it in order to build Minizip and then Desktop Application.") set(CMAKE_INSTALL_PREFIX "${LINPHONE_OUTPUT_DIR}") add_subdirectory("linphone-sdk" "${SDK_BUILD_DIR}") -elseif( FORCE_SDK_BUILD ) +elseif( APPLI_FORCE_SDK_BUILD ) set(CMAKE_INSTALL_PREFIX "${LINPHONE_OUTPUT_DIR}") add_subdirectory("linphone-sdk" "${SDK_BUILD_DIR}") else() diff --git a/linphone-sdk b/linphone-sdk index bff2ab076..894987807 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit bff2ab0768b4f6b0f8fc73d02acd61ca3360ff82 +Subproject commit 89498780719d40c60c60aa0f6eb3b5ab4c047c9e diff --git a/src/app/logger/Logger.cpp b/src/app/logger/Logger.cpp index 3b5544d37..e227cf82f 100644 --- a/src/app/logger/Logger.cpp +++ b/src/app/logger/Logger.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "config.h" @@ -168,6 +169,8 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri mMutex.lock(); fprintf(stderr, format, dateTime.constData(), QThread::currentThread(), contextStr, localMsg.constData()); + if( level == BCTBX_LOG_FATAL) + QMessageBox::critical(nullptr, "Linphone will crash", msg); // Print an error message before sending msg to bctoolbox bctbx_log(QtDomain, level, "QT: %s%s", contextStr, localMsg.constData()); mMutex.unlock(); diff --git a/src/components/chat/ChatModel.cpp b/src/components/chat/ChatModel.cpp index d2895ca83..f468edcfb 100644 --- a/src/components/chat/ChatModel.cpp +++ b/src/components/chat/ChatModel.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "app/App.hpp" #include "app/paths/Paths.hpp" @@ -75,8 +76,11 @@ QString MessageAppData::toString()const void MessageAppData::fromString(const QString& p_data) { QStringList fields = p_data.split(':'); - m_id = fields[0]; - m_path = fields[1]; + if( fields.size() > 1) + { + m_id = fields[0]; + m_path = fields[1]; + } } QString MessageAppData::toString(const QVector& p_data) { @@ -113,8 +117,8 @@ static inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr
  • &mes std::list > contents = message->getContents(); if( contents.size() > 0) { - QString thumbnailPath = QString::fromStdString(contents.front()->getFilePath()); - QImage image(thumbnailPath); + MessageAppData thumbnailData; + thumbnailData.m_path = QString::fromStdString(contents.front()->getFilePath()); + QImage image(thumbnailData.m_path); if (image.isNull()) return; int rotation = 0; QExifImageHeader exifImageHeader; - if (exifImageHeader.loadFromJpeg(thumbnailPath)) + if (exifImageHeader.loadFromJpeg(thumbnailData.m_path)) rotation = int(exifImageHeader.value(QExifImageHeader::ImageTag::Orientation).toShort()); QImage thumbnail = image.scaled( @@ -155,14 +160,14 @@ static inline void createThumbnail (const shared_ptr &mes } QString uuid = QUuid::createUuid().toString(); - QString fileId = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2)); + thumbnailData.m_id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2)); - if (!thumbnail.save(Utils::coreStringToAppString(Paths::getThumbnailsDirPath()) + fileId, "jpg", 100)) { - qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(thumbnailPath); + if (!thumbnail.save(Utils::coreStringToAppString(Paths::getThumbnailsDirPath()) + thumbnailData.m_id , "jpg", 100)) { + qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(thumbnailData.m_path); return; } - message->setAppdata(Utils::appStringToCoreString(fileId)); + message->setAppdata(thumbnailData.toString().toStdString()); } } @@ -170,9 +175,9 @@ static inline void removeFileMessageThumbnail (const shared_ptrgetFileTransferInformation()) { message->cancelFileTransfer(); MessageAppData thumbnailFile = getMessageAppData(message); - if(thumbnailFile.m_path.size() > 0) + if(thumbnailFile.m_id.size() > 0) { - QString thumbnailPath = QString::fromStdString(Paths::getThumbnailsDirPath()) + thumbnailFile.m_path; + QString thumbnailPath = QString::fromStdString(Paths::getThumbnailsDirPath()) + thumbnailFile.m_id; if (!QFile::remove(thumbnailPath)) qWarning() << QStringLiteral("Unable to remove `%1`.").arg(thumbnailPath); } @@ -281,10 +286,6 @@ private: createThumbnail(message); fillThumbnailProperty((*it).first, message); - MessageAppData thumbnailFile = getMessageAppData(message); - thumbnailFile.m_path = QString::fromStdString(message->getContents().front()->getFilePath()); - - message->setAppdata(thumbnailFile.toString().toStdString()); (*it).first["wasDownloaded"] = true; App::getInstance()->getNotifier()->notifyReceivedFileMessage(message); @@ -552,8 +553,7 @@ void ChatModel::downloadFile (int id) { default: qWarning() << QStringLiteral("Unable to download file of entry %1. It was not uploaded.").arg(id); return; - } - + } bool soFarSoGood; const QString safeFilePath = Utils::getSafeFilePath( QStringLiteral("%1%2") @@ -569,9 +569,14 @@ void ChatModel::downloadFile (int id) { message->addListener(mMessageHandlers); message->getContents().front()->setFilePath(safeFilePath.toStdString()); -// Download only the first content. Maybe a bug.. or not. - if (!message->downloadContent(message->getContents().front())) - qWarning() << QStringLiteral("Unable to download file of entry %1.").arg(id); + + if( !message->isFileTransfer()) + QMessageBox::warning(nullptr, "Download File", "This file was already downloaded and is no more on the server. Your peer have to resend it if you want to get it"); + else + { + if (!message->downloadContent(message->getFileTransferInformation())) + qWarning() << QStringLiteral("Unable to download file of entry %1.").arg(id); + } } void ChatModel::openFile (int id, bool showDirectory) {