From 69d3e7b522f304911e4e5f680f9469e884182c50 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 24 Apr 2017 14:00:23 +0200 Subject: [PATCH] fix(app): fix implicit conversions and limit file size in chat --- linphone-desktop/src/components/camera/Camera.cpp | 4 ++-- .../src/components/camera/CameraPreview.cpp | 4 ++-- linphone-desktop/src/components/chat/ChatModel.cpp | 12 +++++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/linphone-desktop/src/components/camera/Camera.cpp b/linphone-desktop/src/components/camera/Camera.cpp index acef14043..ebe1c7917 100644 --- a/linphone-desktop/src/components/camera/Camera.cpp +++ b/linphone-desktop/src/components/camera/Camera.cpp @@ -76,8 +76,8 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & // It's not the same thread as render. coreManager->lockVideoRender(); - mContextInfo->width = size.width(); - mContextInfo->height = size.height(); + mContextInfo->width = static_cast(size.width()); + mContextInfo->height = static_cast(size.height()); mContextInfo->functions = MSFunctions::getInstance()->getFunctions(); mUpdateContextInfo = true; diff --git a/linphone-desktop/src/components/camera/CameraPreview.cpp b/linphone-desktop/src/components/camera/CameraPreview.cpp index 4eebdf6ea..36d8faaa1 100644 --- a/linphone-desktop/src/components/camera/CameraPreview.cpp +++ b/linphone-desktop/src/components/camera/CameraPreview.cpp @@ -71,8 +71,8 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const // It's not the same thread as render. coreManager->lockVideoRender(); - mContextInfo->width = size.width(); - mContextInfo->height = size.height(); + mContextInfo->width = static_cast(size.width()); + mContextInfo->height = static_cast(size.height()); mContextInfo->functions = MSFunctions::getInstance()->getFunctions(); mUpdateContextInfo = true; diff --git a/linphone-desktop/src/components/chat/ChatModel.cpp b/linphone-desktop/src/components/chat/ChatModel.cpp index 19beb1e19..dac5cd1e4 100644 --- a/linphone-desktop/src/components/chat/ChatModel.cpp +++ b/linphone-desktop/src/components/chat/ChatModel.cpp @@ -41,6 +41,9 @@ #define THUMBNAIL_IMAGE_FILE_HEIGHT 100 #define THUMBNAIL_IMAGE_FILE_WIDTH 100 +// In Bytes. +#define FILE_SIZE_LIMIT 524288000 + using namespace std; // ============================================================================= @@ -367,10 +370,17 @@ void ChatModel::sendFileMessage (const QString &path) { if (!file.exists()) return; + qint64 fileSize = file.size(); + if (fileSize > FILE_SIZE_LIMIT) { + qWarning() << QStringLiteral("Unable to send file. (Size limit=%1)").arg(FILE_SIZE_LIMIT); + return; + } + shared_ptr content = CoreManager::getInstance()->getCore()->createContent(); content->setType("application"); content->setSubtype("octet-stream"); - content->setSize(file.size()); + + content->setSize(static_cast(fileSize)); content->setName(::Utils::qStringToLinphoneString(QFileInfo(file).fileName())); shared_ptr message = mChatRoom->createFileTransferMessage(content);