Commit 90559a8a authored by Martin Straka's avatar Martin Straka

Allowed to send message larger than 20MB

parent 7fcd2982
/*
* 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
......@@ -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<DataboxModelEntry> dbList = databoxModel->allEntries();
/* List of unique identifiers. */
......
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