diff --git a/src/net/isds_const.h b/src/net/isds_const.h index 4f8e12663c51d3fa0a9bdc9f8b9d992915943359..14c2f59e71e6b6530d7f97c015dfc613fec1de51 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 940d51f1787f11ee3105924a390c98bddb3288cf..05ae05bf54c4c18718abd8fc2a38904af2a1a195 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,33 @@ 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("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 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); + if (msgResponse == Dialogues::NO) { + return; + } + } + const QList dbList = databoxModel->allEntries(); /* List of unique identifiers. */