Commit ac672dc3 authored by Martin Straka's avatar Martin Straka

Added send message core and pool task

parent 081138ac
......@@ -84,6 +84,7 @@ TRANSLATIONS_FILES += \
SOURCES += \
src/accounts.cpp \
src/auxiliaries/attachment_helper.cpp \
src/dialogues/dialogues.cpp \
src/dialogues/qml_dialogue_helper.cpp \
src/dialogues/qml_input_dialogue.cpp \
......@@ -133,11 +134,13 @@ SOURCES += \
src/worker/task_find_databox.cpp \
src/worker/task_find_databox_fulltext.cpp \
src/worker/task_keep_alive.cpp \
src/worker/task_send_message.cpp \
src/worker/task_send_sms.cpp \
src/zfo.cpp
HEADERS += \
src/accounts.h \
src/auxiliaries/attachment_helper.h \
src/common.h \
src/dialogues/dialogues.h \
src/dialogues/qml_dialogue_helper.h \
......@@ -188,6 +191,7 @@ HEADERS += \
src/worker/task_find_databox.h \
src/worker/task_find_databox_fulltext.h \
src/worker/task_keep_alive.h \
src/worker/task_send_message.h \
src/worker/task_send_sms.h \
src/zfo.h
......
......@@ -91,7 +91,9 @@ Item {
}
if (!isInFiletList) {
var fileName = getFileNameFromPath(path)
addFileToFieList(path, noFileId, fileName, "~1KB", "qrc:/fileicons/fileicon_blank.png", false)
addFileToFieList(path, noFileId, fileName,
getFileSizeString(files.getAttachmentSizeInBytes(path)),
files.getAttachmentFileIcon(fileName), false)
}
}
}
......@@ -157,8 +159,30 @@ Item {
anchors.bottom: parent.bottom
width: parent.width
Connections {
target: isds
onRunSendMessageSig: {
for (var i = 0; i < sendMsgRecipientModel.rowCount(); i++) {
recipientIds.push(sendMsgRecipientModel.get(i).rDbID)
recipientNames.push(sendMsgRecipientModel.get(i).rDbName)
}
for (var j = 0; j < sendMsgAttachmentModel.rowCount(); j++) {
filePaths.push(sendMsgAttachmentModel.get(j).path)
}
isds.sendMessage(userName, dmAnnotation.text.toString(),
recipientIds, recipientNames, filePaths,
dmLegalTitleLaw.text.toString(), dmLegalTitleYear.text.toString(),
dmLegalTitleSect.text.toString(), dmLegalTitlePar.text.toString(),
dmLegalTitlePoint.text.toString(), dmToHands.text.toString(),
dmRecipientRefNumber.text.toString(), dmRecipientIdent.text.toString(),
dmSenderRefNumber.text.toString(), dmSenderIdent.text.toString(),
dmOVM.checked, dmPublishOwnID.checked,
dmAllowSubstDelivery.checked, dmPersonalDelivery.checked)
}
}
function doSendRequest() {
// TODO - add isds.doIsdsAction("sendMessage", userName)
isds.doIsdsAction("sendMessage", userName)
}
/* Enable send message button if all required fields are filled */
......
/*
* Copyright (C) 2014-2017 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#include <QFileInfo>
#include <QSet>
#include "src/auxiliaries/attachment_helper.h"
/*
* There is list of know file extension sufixes. For these we have png images.
*/
const QSet<QString> knowExp = QSet<QString> () <<
"avi" << "bmp" << "doc" << "docx" << "dwg" << "gif" << "html" <<
"htm" << "jpeg" << "jpg" << "mpeg" << "mpg" << "mp3" << "ods" <<
"odt" << "pdf" << "png" << "ppt" << "pptx" << "rtf" << "tiff" <<
"txt" << "wav" << "xls" << "xlsx" << "xml" << "zfo";
QString getApproximatelyAttachmentFileSizeFromBase64(int base64Length)
{
QString str = "";
base64Length = base64Length * 3 / 4;
if (base64Length >= 1000) {
str = "~" + QString::number(base64Length / 1000) + " KB" ;
} else {
str = "~" + QString::number(base64Length) + " B" ;
}
return str;
}
QString getAttachmentFileIconFromFileExtension(QString fileName)
{
QString img = "qrc:/fileicons/fileicon_blank.png";
QFileInfo fi(fileName);
const QString ext = fi.suffix();
ext.toLower();
if (!ext.isNull()) {
if (knowExp.contains(ext)) {
img = "qrc:/fileicons/fileicon_" + ext + ".png";
}
}
return img;
}
/*
* Copyright (C) 2014-2017 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#ifndef _ATTACHMENT_HELPER_H_
#define _ATTACHMENT_HELPER_H_
#include <QString>
/*!
* @brief Get aproximatle attachment file size from base64 length.
*
* @param[in] base64Length Base64 content length.
* @return Aproximatle file size string.
*/
QString getApproximatelyAttachmentFileSizeFromBase64(int base64Length);
/*!
* @brief Get attachment icon from attachment file extension.
*
* @param[in] fileName Attachment filename with extension.
* @return Attachment icon filename string.
*/
QString getAttachmentFileIconFromFileExtension(QString fileName);
#endif /* _ATTACHMENT_HELPER_H_ */
......@@ -29,6 +29,7 @@
#include <QUrl>
#include <QQmlEngine> /* qmlRegisterType */
#include "src/auxiliaries/attachment_helper.h"
#include "src/common.h"
#include "src/dialogues/dialogues.h"
#include "src/files.h"
......@@ -214,6 +215,17 @@ void getAttchment(FileDb::FileData &file, const QString &userName,
file = fDb->getFileContentFromDb(fileId);
}
QString Files::getAttachmentFileIcon(const QString &fileName)
{
return getAttachmentFileIconFromFileExtension(fileName);
}
qint64 Files::getAttachmentSizeInBytes(const QString &filePath)
{
QFileInfo fileInfo(filePath);
return fileInfo.size();
}
QByteArray Files::getAttachmentDb(const QString &userName,
const QString &msgIdStr, int fileId)
{
......
......@@ -44,6 +44,24 @@ public:
*/
explicit Files(QObject *parent = Q_NULLPTR);
/*!
* @brief Get attachment file icon from file name.
*
* @param[in] fileName File name.
* @return File icon resources string.
*/
Q_INVOKABLE
QString getAttachmentFileIcon(const QString &fileName);
/*!
* @brief Get attachment file size in bytes.
*
* @param[in] filePath Path to file.
* @return File size in bytes.
*/
Q_INVOKABLE
qint64 getAttachmentSizeInBytes(const QString &filePath);
/*!
* @brief Obtain attachment from database.
*
......
......@@ -22,6 +22,7 @@
*/
#include <QDebug>
#include <QFileInfo>
#include "src/dialogues/dialogues.h"
#include "src/models/accountmodel.h"
......@@ -39,6 +40,7 @@
#include "src/worker/task_find_databox.h"
#include "src/worker/task_find_databox_fulltext.h"
#include "src/worker/task_keep_alive.h"
#include "src/worker/task_send_message.h"
#include "src/worker/task_send_sms.h"
IsdsWrapper::IsdsWrapper(QObject *parent)
......@@ -73,6 +75,11 @@ IsdsWrapper::IsdsWrapper(QObject *parent)
SIGNAL(downloadMessageListFinishedSignal(QString, bool, QString, QString, bool)),
this,
SLOT(downloadMessageListFinished(QString, bool, QString, QString, bool)));
connect(&globMsgProcEmitter,
SIGNAL(sendMessageFinishedSignal(QString, QString, QString, qint64, bool, QString)),
this,
SLOT(sendMessageFinished(QString, QString, QString, qint64, bool, QString)));
}
IsdsWrapper::~IsdsWrapper(void)
......@@ -179,6 +186,8 @@ void IsdsWrapper::doIsdsAction(const QString &isdsAction,
emit runFindDataboxFulltextSig(userName);
} else if (isdsAction == "findDatabox") {
emit runFindDataboxSig(userName);
} else if (isdsAction == "sendMessage") {
emit runSendMessageSig(userName);
}
} else {
doLoginAction(isdsAction, userName);
......@@ -423,6 +432,64 @@ void IsdsWrapper::inputDialogReturnPassword(const QString &isdsAction,
}
}
void IsdsWrapper::sendMessage(const QString &userName, const QString &dmAnnotation,
const QStringList &recipients, const QStringList &recipientName,
const QStringList &filePaths,
const QString &dmLegalTitleLaw, const QString &dmLegalTitleYear,
const QString &dmLegalTitleSect, const QString &dmLegalTitlePar,
const QString &dmLegalTitlePoint, const QString &dmToHands,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery)
{
qDebug("%s()", __func__);
if (userName.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Empty user name"), tr("Internal error"));
return;
}
/* User must be logged to isds */
if (!isLoggedToIsds(userName)) {
return;
}
QList<QPair<QString, QByteArray>> fileList;
QPair<QString, QByteArray> fileData;
/* Add files from storage or disk */
foreach (const QString &file, filePaths) {
QFileInfo fi(file);
fileData.first = fi.fileName();
QFile fin(file);
if (!fin.open(QIODevice::ReadOnly)) {
continue;
}
fileData.second = fin.readAll().toBase64();
fileList.append(fileData);
}
emit statusBarTextChanged(tr("%1: sending message").arg(userName),
true, true);
/* Send message to all recipients */
for (int i = 0; i < recipients.count(); ++i) {
TaskSendMessage *task;
task = new (std::nothrow) TaskSendMessage(
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
dmAnnotation, recipients.at(i), recipientName.at(i),
dmLegalTitleLaw, dmLegalTitleYear, dmLegalTitleSect,
dmLegalTitlePar, dmLegalTitlePoint, dmToHands,
dmRecipientRefNumber, dmRecipientIdent,
dmSenderRefNumber, dmSenderIdent, dmOVM, dmPublishOwnID,
dmAllowSubstDelivery, dmPersonalDelivery, fileList);
task->setAutoDelete(true);
m_workPool.assignHi(task);
}
}
bool IsdsWrapper::sendSMS(const QString &userName, const QString &oldPwd)
{
qDebug("%s()", __func__);
......@@ -596,6 +663,26 @@ void IsdsWrapper::downloadMessageListFinished(const QString &userName,
}
}
void IsdsWrapper::sendMessageFinished(const QString &userName,
const QString &dbIDRecipient, const QString &dmRecipient, qint64 msgId,
bool success, const QString &errTxt)
{
emit statusBarTextChanged(errTxt, false, true);
/* Show result dialogue */
if (!success) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Send message error: %1").arg(userName),
tr("Failed to send mesasge to recipient '%1' (%2)'.").arg(dmRecipient).arg(dbIDRecipient),
tr("ISDS returns: %1").arg(errTxt));
} else {
Dialogues::errorMessage(Dialogues::INFORMATION,
tr("Send message: %1").arg(userName),
tr("Message has sent to recipient '%1' (%2) as message id '%3'.").arg(dmRecipient).arg(dbIDRecipient).arg(msgId),
tr("ISDS returns: %1").arg(errTxt));
}
}
void IsdsWrapper::removeIsdsCtx(const QString &userName)
{
m_isdsSession.removeIsdsCtx(userName);
......
......@@ -168,6 +168,42 @@ public:
void inputDialogReturnPassword(const QString &isdsAction,
const QString &pwdType, const QString &userName, const QString &pwd);
/*!
* @brief Send message.
*
* @param[in] userName Account username string.
* @param[in] dmAnnotation Message subject string.
* @param[in] recipients List of recipient databox IDs.
* @param[in] recipientName Recipient full name.
* @param[in] filePaths List of path to files.
* @param[in] dmLegalTitleLaw Mandate Law string.
* @param[in] dmLegalTitleYear Mandate Year string.
* @param[in] dmLegalTitleSect Mandate Section string.
* @param[in] dmLegalTitlePar Mandate Paragraph string.
* @param[in] dmLegalTitlePoint Mandate Letter string.
* @param[in] dmToHands Mesasge to hands string.
* @param[in] dmRecipientRefNumber Your ref. number string.
* @param[in] dmRecipientIdent Your identification string.
* @param[in] dmSenderRefNumber Our ref. number string.
* @param[in] dmSenderIdent Our identification string.
* @param[in] dmOVM True if send message as OVM.
* @param[in] dmPublishOwnID True if add sender name to message.
* @param[in] dmAllowSubstDelivery True if allow acceptance by fiction.
* @param[in] dmPersonalDelivery True if personal delivery.
* @return Soap request string as byte array.
*/
Q_INVOKABLE
void sendMessage(const QString &userName,
const QString &dmAnnotation, const QStringList &recipients,
const QStringList &recipientName, const QStringList &filePaths,
const QString &dmLegalTitleLaw, const QString &dmLegalTitleYear,
const QString &dmLegalTitleSect, const QString &dmLegalTitlePar,
const QString &dmLegalTitlePoint, const QString &dmToHands,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery);
/*!
* @brief Sent SMS request.
*
......@@ -311,6 +347,13 @@ signals:
*/
void runGetAccountInfoSig(QString userName);
/*!
* @brief Run send message isds action from QML.
*
* @param[in] userName Account user name string.
*/
void runSendMessageSig(QString userName);
/*!
* @brief Run sync all accounts action from QML.
*
......@@ -404,6 +447,20 @@ public slots:
bool success, const QString &statusBarText, const QString &errTxt,
bool isMsgReceived);
/*!
* @brief Do post actions when send message finished.
*
* @param[in] userName Account username string.
* @param[in] dbIDRecipient Message recipient databox ID string.
* @param[in] dmRecipient Recipient full name.
* @param[in] msgId Send message ID.
* @param[in] success True if success.
* @param[in] errTxt Errot description.
*/
void sendMessageFinished(const QString &userName,
const QString &dbIDRecipient, const QString &dmRecipient,
qint64 msgId, bool success, const QString &errTxt);
/*!
* @brief Removed ISDS context of account. Run this slot
* when account is deleted or its setting was updated.
......
......@@ -26,6 +26,7 @@
#include <QDateTime>
#include <QFileInfo>
#include "src/auxiliaries/attachment_helper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
......@@ -33,15 +34,6 @@
#include "src/crypto/crypto.h"
#endif
/*
* There is list of know file extension sufixes. For these we have png images.
*/
const QSet<QString> knowExp = QSet<QString> () <<
"avi" << "bmp" << "doc" << "docx" << "dwg" << "gif" << "html" <<
"htm" << "jpeg" << "jpg" << "mpeg" << "mpg" << "mp3" << "ods" <<
"odt" << "pdf" << "png" << "ppt" << "pptx" << "rtf" << "tiff" <<
"txt" << "wav" << "xls" << "xlsx" << "xml" << "zfo";
XmlLayer::XmlLayer(QObject *parent)
: QObject(parent)
{
......@@ -51,32 +43,6 @@ XmlLayer::~XmlLayer(void)
{
}
QString XmlLayer::getApproximatelyFileSizeFromBase64(int base64Length)
{
QString str = "";
base64Length = base64Length * 3 / 4;
if (base64Length >= 1000) {
str = "~" + QString::number(base64Length / 1000) + " KB" ;
} else {
str = "~" + QString::number(base64Length) + " B" ;
}
return str;
}
QString XmlLayer::getAttachmentFileIconFromFileExtension(QString fileName)
{
QString img = "qrc:/fileicons/fileicon_blank.png";
QFileInfo fi(fileName);
const QString ext = fi.suffix();
ext.toLower();
if (!ext.isNull()) {
if (knowExp.contains(ext)) {
img = "qrc:/fileicons/fileicon_" + ext + ".png";
}
}
return img;
}
QByteArray XmlLayer::xmlCreateDownloadMessageSoapRequest(qint64 msgId,
enum Messages::MessageType msgDirect)
{
......@@ -257,6 +223,136 @@ QByteArray XmlLayer::xmlCreateMarkMessageAsDownloadedSoapRequest(qint64 msgId)
return xmlCreateSoapEnvelope(xmlContent);
}
QByteArray XmlLayer::xmlCreateSendMessageSoapRequest(const QString &dmAnnotation,
const QString &dbIDRecipient, const QString &dmLegalTitleLaw,
const QString &dmLegalTitleYear, const QString &dmLegalTitleSect,
const QString &dmLegalTitlePar, const QString &dmLegalTitlePoint,
const QString &dmToHands, const QString &dmRecipientRefNumber,
const QString &dmRecipientIdent, const QString &dmSenderRefNumber,
const QString &dmSenderIdent, bool dmOVM, bool dmPublishOwnID,
bool dmAllowSubstDelivery, bool dmPersonalDelivery,
const QList<QPair<QString, QByteArray>> &fileList)
{
QString xmlContent("<CreateMessage xmlns=\"");
xmlContent.append(ISDS_NS);
xmlContent.append("\">");
xmlContent.append("<dmEnvelope>");
xmlContent.append("<dmSenderOrgUnit/><dmSenderOrgUnitNum/>");
xmlContent.append("<dbIDRecipient>");
xmlContent.append(dbIDRecipient);
xmlContent.append("</dbIDRecipient>");
xmlContent.append("<dmRecipientOrgUnit/><dmRecipientOrgUnitNum/>");
if (dmToHands.isEmpty()) {
xmlContent.append("<dmToHands/>");
} else {
xmlContent.append("<dmToHands>");
xmlContent.append(dmToHands);
xmlContent.append("</dmToHands>");
}
xmlContent.append("<dmAnnotation>");
xmlContent.append(dmAnnotation);
xmlContent.append("</dmAnnotation>");
if (dmRecipientRefNumber.isEmpty()) {
xmlContent.append("<dmRecipientRefNumber/>");
} else {
xmlContent.append("<dmRecipientRefNumber>");
xmlContent.append(dmRecipientRefNumber);
xmlContent.append("</dmRecipientRefNumber>");
}
if (dmSenderRefNumber.isEmpty()) {
xmlContent.append("<dmSenderRefNumber/>");
} else {
xmlContent.append("<dmSenderRefNumber>");
xmlContent.append(dmSenderRefNumber);
xmlContent.append("</dmSenderRefNumber>");
}
if (dmRecipientIdent.isEmpty()) {
xmlContent.append("<dmRecipientIdent/>");
} else {
xmlContent.append("<dmRecipientIdent>");
xmlContent.append(dmRecipientIdent);
xmlContent.append("</dmRecipientIdent>");
}
if (dmSenderIdent.isEmpty()) {
xmlContent.append("<dmSenderIdent/>");
} else {
xmlContent.append("<dmSenderIdent>");
xmlContent.append(dmSenderIdent);
xmlContent.append("</dmSenderIdent>");
}
if (dmLegalTitleLaw.isEmpty()) {
xmlContent.append("<dmLegalTitleLaw/>");
} else {
xmlContent.append("<dmLegalTitleLaw>");
xmlContent.append(dmLegalTitleLaw);
xmlContent.append("</dmLegalTitleLaw>");
}
if (dmLegalTitleYear.isEmpty()) {
xmlContent.append("<dmLegalTitleYear/>");
} else {
xmlContent.append("<dmLegalTitleYear>");
xmlContent.append(dmLegalTitleYear);
xmlContent.append("</dmLegalTitleYear>");
}
if (dmLegalTitleSect.isEmpty()) {
xmlContent.append("<dmLegalTitleSect/>");
} else {
xmlContent.append("<dmLegalTitleSect>");
xmlContent.append(dmLegalTitleSect);
xmlContent.append("</dmLegalTitleSect>");
}
if (dmLegalTitlePar.isEmpty()) {
xmlContent.append("<dmLegalTitlePar/>");
} else {
xmlContent.append("<dmLegalTitlePar>");
xmlContent.append(dmLegalTitlePar);
xmlContent.append("</dmLegalTitlePar>");
}
if (dmLegalTitlePoint.isEmpty()) {
xmlContent.append("<dmLegalTitlePoint/>");
} else {
xmlContent.append("<dmLegalTitlePoint>");
xmlContent.append(dmLegalTitlePoint);
xmlContent.append("</dmLegalTitlePoint>");
}
xmlContent.append("<dmPersonalDelivery>");
xmlContent.append((dmPersonalDelivery)?"true":"false");
xmlContent.append("</dmPersonalDelivery>");
xmlContent.append("<dmAllowSubstDelivery>");
xmlContent.append((dmAllowSubstDelivery)?"true":"false");
xmlContent.append("</dmAllowSubstDelivery>");
xmlContent.append("<dmOVM>");
xmlContent.append((dmOVM)?"true":"false");
xmlContent.append("</dmOVM>");
xmlContent.append("<dmPublishOwnID>");
xmlContent.append((dmPublishOwnID)?"true":"false");
xmlContent.append("</dmPublishOwnID>");
xmlContent.append("</dmEnvelope>");
xmlContent.append("<dmFiles>");
for (int i = 0; i < fileList.count(); ++i) {
xmlContent.append("<dmFile dmMimeType=\"\" dmFileMetaType=\"");
(i > 0) ? xmlContent.append("enclosure") : xmlContent.append("main");
xmlContent.append("\" dmFileDescr=\"");
xmlContent.append(fileList.at(i).first);
xmlContent.append("\">");
xmlContent.append("<dmEncodedContent>");
xmlContent.append(fileList.at(i).second);
xmlContent.append("</dmEncodedContent>");
xmlContent.append("</dmFile>");
}
xmlContent.append("</dmFiles>");
xmlContent.append("</CreateMessage>");
return xmlCreateSoapEnvelope(xmlContent);
}
QByteArray XmlLayer::xmlCreateSendSMSSoapRequest(void)
{
QString xmlContent("<SendSMSCode xmlns=\"");
......@@ -550,6 +646,47 @@ bool XmlLayer::parseDbStatusFromXml(const QByteArray &xmlData, QString &txt)
return (dbStatusCode == "0000");
}
bool XmlLayer::parseSentMessageStatusFromXml(const QByteArray &xmlData,
qint64 &msgID, QString &txt)
{
QXmlStreamReader xml;
xml.addData(xmlData);
QString dmStatusCode = "-1";
while(!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartDocument) {
continue;
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmStatus") {
/* Parse first part of xml response <q:dmStatus> */
while (!(xml.tokenType() == QXmlStreamReader::EndElement
&& xml.name() == "dmStatus")) {
if (xml.tokenType() ==
QXmlStreamReader::StartElement) {
if (xml.name() == "dmStatusCode") {
xml.readNext();
dmStatusCode =
xml.text().toString();
} else if (xml.name() == "dmStatusMessage") {
xml.readNext();
txt = xml.text().toString();
}
}
xml.readNext();
}
}
if (xml.name() == "dmID") {
xml.readNext();
msgID = xml.text().toLongLong();
}
}
}
return (dmStatusCode == "0000");
}
bool XmlLayer::parseLoginResponse(const QByteArray &xmlData, QString &txt)
{
return parseDmStatusFromXml(xmlData, txt);
......@@ -1405,7 +1542,7 @@ Files::File XmlLayer::parseFile(QXmlStreamReader &xml,
xml.readNext();
file.dmEncodedContent = xml.text().toString();
file._dmFileSize =
getApproximatelyFileSizeFromBase64(file.dmEncodedContent.length());
getApproximatelyAttachmentFileSizeFromBase64(file.dmEncodedContent.length());
file._dmDownloadDate = downloadDate;
file._icon = getAttachmentFileIconFromFileExtension(file.dmFileDescr);
......
......@@ -43,24 +43,6 @@ public:
XmlLayer(QObject *parent = Q_NULLPTR);
~XmlLayer(void);
/*!
* @brief Get aproximatle file size from base64 length.
*
* @param[in] base64Length Base64 content length.
* @return Aproximatle file size string.
*/
static
QString getApproximatelyFileSizeFromBase64(int base64Length);
/*!
* @brief Get attachment icon from attachment file extension.
*
* @param[in] fileName Attachment filename with extension.
* @return Attachment icon filename string.
*/
static
QString getAttachmentFileIconFromFileExtension(QString fileName);
/*!
* @brief Create download message soap request.
*
......@@ -188,6 +170,39 @@ public:
static
QByteArray xmlCreateMarkMessageAsDownloadedSoapRequest(qint64 msgId);
/*!
* @brief Create send message soap request.
*
* @param[in] dmAnnotation Message subject string.
* @param[in] dbIDRecipient Message recipient databox ID string.
* @param[in] dmLegalTitleLaw Mandate Law string.
* @param[in] dmLegalTitleYear Mandate Year string.
* @param[in] dmLegalTitleSect Mandate Section string.
* @param[in] dmLegalTitlePar Mandate Paragraph string.
* @param[in] dmLegalTitlePoint Mandate Letter string.
* @param[in] dmToHands Mesasge to hands string.
* @param[in] dmRecipientRefNumber Your ref. number string.
* @param[in] dmRecipientIdent Your identification string.
* @param[in] dmSenderRefNumber Our ref. number string.
* @param[in] dmSenderIdent Our identification string.
* @param[in] dmOVM True if send message as OVM.
* @param[in] dmPublishOwnID True if add sender name to message.
* @param[in] dmAllowSubstDelivery True if allow acceptance by fiction.
* @param[in] dmPersonalDelivery True if personal delivery.
* @param[in] fileList List of files (first = filename, second = file content in base64).
* @return Soap request string as byte array.
*/