From 90559a8a4c1298e1b1bcea1c5dcecde869120896 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Thu, 8 Nov 2018 14:41:06 +0100 Subject: [PATCH 1/3] Allowed to send message larger than 20MB --- src/net/isds_const.h | 19 ++++++++++++------- src/net/isds_wrapper.cpp | 27 +++++++++++++++++++++------ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/net/isds_const.h b/src/net/isds_const.h index 4f8e1266..14c2f59e 100644 --- a/src/net/isds_const.h +++ b/src/net/isds_const.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2017 CZ.NIC + * Copyright (C) 2014-2018 CZ.NIC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -21,8 +21,7 @@ * the two. */ -#ifndef _ISDS_CONST_H_ -#define _ISDS_CONST_H_ +#pragma once /* HTTP request timeout, default 5 minutes */ #define ISDS_TIMEOUT 300000 @@ -110,8 +109,14 @@ #define DOWNLOAD_ALL_MESSAGES 2046 /*! - * @brief Maximum attachment size in kB for message sending (ISDS 20 MB). + * @brief Maximum attachment size in MB for message sending (ISDS 20 MB). */ -#define SEND_ATTACH_SIZE_LIMIT_KB 20000 +#define SEND_ATTACH_SIZE_LIMIT_MB 20 -#endif // _ISDS_CONST_H_ +/*! + * @brief Maximum attachment size in MB for message sending (ISDS OVM 50 MB). + * + * @note New ISDS message size limit is 50MB because some + * OVM databoxes can receive message up to 50MB. + */ +#define SEND_OVM_ATTACH_SIZE_LIMIT_MB 50 diff --git a/src/net/isds_wrapper.cpp b/src/net/isds_wrapper.cpp index 940d51f1..2131a749 100644 --- a/src/net/isds_wrapper.cpp +++ b/src/net/isds_wrapper.cpp @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -712,17 +712,32 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID, envelope.setDmAttachmentSize(totalAttachmentSizeKBs); - /* Test if total attachment size is above the limit */ - if (totalAttachmentSizeKBs > SEND_ATTACH_SIZE_LIMIT_KB) { + /* Get total attachment in MB for error dialogue */ + int totalAttachmentSizeMB = totalAttachmentSizeKBs / 1024; + + /* Test if total attachment size is above the limit 50MB */ + if (totalAttachmentSizeMB > SEND_OVM_ATTACH_SIZE_LIMIT_MB) { Dialogues::errorMessage(Dialogues::CRITICAL, - tr("%1: Error sending message!").arg(userName), + tr("%1: Message problem").arg(userName), tr("Total attachment size exceeds the limit!"), - tr("Current total attachment size is %1 kB. ISDS limits its size to %2 kB. Reduce the total attachment size and try sending the message again.") - .arg(totalAttachmentSizeKBs).arg(SEND_ATTACH_SIZE_LIMIT_KB) + tr("Current total attachment size is %1 MB. ISDS limits its size to %2 MB. Reduce the total attachment size and try sending the message again.") + .arg(totalAttachmentSizeMB).arg(SEND_OVM_ATTACH_SIZE_LIMIT_MB) ); return; } + /* Test if total attachment size is larger then 20 MB */ + if (totalAttachmentSizeMB >= SEND_ATTACH_SIZE_LIMIT_MB) { + int msgResponse = Dialogues::message(Dialogues::QUESTION, + tr("%1: Message problem").arg(userName), + tr("Total size of attachments is larger than %1 MB! Most of databoxes cannot receive a message larger than %1 MB. However some OVM databoxes can receive message up to %2 MB.") + .arg(SEND_ATTACH_SIZE_LIMIT_MB).arg(SEND_OVM_ATTACH_SIZE_LIMIT_MB), + tr("Do you really want to send the large message?"), Dialogues::NO | Dialogues::YES, Dialogues::NO); + if (msgResponse == Dialogues::NO) { + return; + } + } + const QList dbList = databoxModel->allEntries(); /* List of unique identifiers. */ -- GitLab From 3ed3216c102a3c41bb5480cc14563c002b5e7be4 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Thu, 8 Nov 2018 15:02:30 +0100 Subject: [PATCH 2/3] Minor refactoring --- src/net/isds_wrapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/net/isds_wrapper.cpp b/src/net/isds_wrapper.cpp index 2131a749..61287975 100644 --- a/src/net/isds_wrapper.cpp +++ b/src/net/isds_wrapper.cpp @@ -732,7 +732,8 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID, tr("%1: Message problem").arg(userName), tr("Total size of attachments is larger than %1 MB! Most of databoxes cannot receive a message larger than %1 MB. However some OVM databoxes can receive message up to %2 MB.") .arg(SEND_ATTACH_SIZE_LIMIT_MB).arg(SEND_OVM_ATTACH_SIZE_LIMIT_MB), - tr("Do you really want to send the large message?"), Dialogues::NO | Dialogues::YES, Dialogues::NO); + tr("Do you really want to send the large message?"), + Dialogues::NO | Dialogues::YES, Dialogues::NO); if (msgResponse == Dialogues::NO) { return; } -- GitLab From 4d8e0eaf5a46d7df34105ba07e7bdab8e591efaf Mon Sep 17 00:00:00 2001 From: Karel Slany Date: Thu, 15 Nov 2018 13:53:50 +0100 Subject: [PATCH 3/3] Changes in wording. --- src/net/isds_wrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/isds_wrapper.cpp b/src/net/isds_wrapper.cpp index 61287975..05ae05bf 100644 --- a/src/net/isds_wrapper.cpp +++ b/src/net/isds_wrapper.cpp @@ -720,7 +720,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID, Dialogues::errorMessage(Dialogues::CRITICAL, tr("%1: Message problem").arg(userName), tr("Total attachment size exceeds the limit!"), - tr("Current total attachment size is %1 MB. ISDS limits its size to %2 MB. Reduce the total attachment size and try sending the message again.") + tr("Total attachment size is %1 MB. ISDS limits its size to %2 MB. Reduce the total attachment size and try sending the message again.") .arg(totalAttachmentSizeMB).arg(SEND_OVM_ATTACH_SIZE_LIMIT_MB) ); return; @@ -730,7 +730,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID, if (totalAttachmentSizeMB >= SEND_ATTACH_SIZE_LIMIT_MB) { int msgResponse = Dialogues::message(Dialogues::QUESTION, tr("%1: Message problem").arg(userName), - tr("Total size of attachments is larger than %1 MB! Most of databoxes cannot receive a message larger than %1 MB. However some OVM databoxes can receive message up to %2 MB.") + tr("Total size of attachments exceeds %1 MB. Most of the data boxes cannot receive messages larger than %1 MB. However, some OVM data boxes can receive message up to %2 MB.") .arg(SEND_ATTACH_SIZE_LIMIT_MB).arg(SEND_OVM_ATTACH_SIZE_LIMIT_MB), tr("Do you really want to send the large message?"), Dialogues::NO | Dialogues::YES, Dialogues::NO); -- GitLab