Commit 0cae7fe7 authored by Martin Straka's avatar Martin Straka

Added download account info task and delivery info task

parent 0ba311ff
......@@ -120,6 +120,8 @@ SOURCES += \
src/sqlite/message_db.cpp \
src/worker/pool.cpp \
src/worker/task.cpp \
src/worker/task_download_account_info.cpp \
src/worker/task_download_delivery_info.cpp \
src/worker/task_download_message.cpp \
src/worker/task_download_message_list.cpp \
src/worker/task_keep_alive.cpp
......@@ -163,6 +165,8 @@ HEADERS += \
src/sqlite/message_db.h \
src/worker/pool.h \
src/worker/task.h \
src/worker/task_download_account_info.h \
src/worker/task_download_delivery_info.h \
src/worker/task_download_message.h \
src/worker/task_download_message_list.h \
src/worker/task_keep_alive.h
......
......@@ -36,7 +36,7 @@
#define ISDS_OTP_TESTING_LOCATOR "https://www.czebox.cz/"
#define MOJE_ID_LOCATOR "https://www.datovka.cz/"
/* ISDS SOAP endpoind services */
/* ISDS SOAP endpoint services */
#define LOGIN_SERVICE "DS/dz"
#define MESSAGE_SERVICE "DS/dx"
#define DB_SERVICE "DS/DsManage"
......@@ -79,6 +79,10 @@
#define OTP_ERROR_NOT_SEND "authentication.info.totpNotSended"
#define OTP_ERROR_NOT_ORDERED "authentication.info.totpNotOrdered"
/* ISDS OTP login indetificators */
#define OTP_TYPE_TOTP "TOTP"
#define OTP_TYPE_HOTP "HOTP"
/*!
* @brief Maximum length of message list to be downloaded.
*/
......
......@@ -24,15 +24,16 @@
#include <QDebug>
#include "src/dialogues/dialogues.h"
#include "src/net/isds_wrapper.h"
#include "src/models/accountmodel.h"
#include "src/models/messagemodel.h"
#include "src/net/isds_wrapper.h"
#include "src/settings.h"
#include "src/worker/task_download_account_info.h"
#include "src/worker/task_download_delivery_info.h"
#include "src/worker/task_download_message.h"
#include "src/worker/task_download_message_list.h"
#include "src/worker/task_keep_alive.h"
IsdsWrapper::IsdsWrapper(QObject *parent)
: QObject(parent),
m_workPool(1)
......@@ -85,88 +86,23 @@ bool IsdsWrapper::syncOneAccount(const QVariant &acntModelVariant,
bool IsdsWrapper::syncSingleAccountReceived(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName)
{
qDebug("%s()", __func__);
if (userName.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Empty user name"), tr("Internal error"));
return false;
}
QString errText;
if (!isLoggedToIsds(userName, errText)) {
showLoginProblemDialog(userName, errText);
return false;
}
emit statusBarTextChanged(tr("%1: downloading received").arg(userName),
true, true);
TaskDownloadMessageList *task;
task = new (std::nothrow) TaskDownloadMessageList(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper,
Messages::TYPE_RECEIVED,
(globSet.downloadOnlyNewMsgs) ? DOWNLOAD_NEW_MESSAGES : DOWNLOAD_ALL_MESSAGES,
1, MESSAGE_LIST_LIMIT);
task->setAutoDelete(false);
m_workPool.runSingle(task);
QList<qint64> receivedMsgIds = task->m_msgIds;
bool success = TaskDownloadMessageList::DL_SUCCESS == task->m_result;
delete task;
if (!success) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("%1: received messages").arg(userName),
tr("Failed to download list of received messages for user name '%1'.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
} else {
emit statusBarTextChanged(
m_isdsSession.isdsCtxMap[userName].last_isds_msg,
false, true);
}
if (globSet.downloadCompleteMsgs) {
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
}
foreach (qint64 msgId, receivedMsgIds) {
TaskDownloadMessage *task;
task = new (std::nothrow) TaskDownloadMessage(
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
&m_dbWrapper, msgId,
Messages::TYPE_RECEIVED, messageModel);
task->setAutoDelete(true);
m_workPool.assignLo(task, WorkerPool::PREPEND);
}
}
AccountListModel *accountModel =
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
qWarning("%s", "Cannot access account model.");
} else {
MessageDb *msgDb = globMessageDbsPtr->accessMessageDb(
globSet.dbsLocation, userName,
AccountListModel::globAccounts[userName].storeToDisk());
if (msgDb != Q_NULLPTR) {
accountModel->updateCounters(userName,
msgDb->getCntOfNewMsgs(MessageDb::TYPE_RECEIVED),
msgDb->getMessageCount(MessageDb::TYPE_RECEIVED),
-1, -1);
}
}
return success;
return syncSingleAccount(acntModelVariant, msgModelVariant, userName,
Messages::TYPE_RECEIVED);
}
bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName)
{
return syncSingleAccount(acntModelVariant, msgModelVariant, userName,
Messages::TYPE_SENT);
}
bool IsdsWrapper::syncSingleAccount(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName,
enum Messages::MessageType msgDirect)
{
qDebug("%s()", __func__);
if (userName.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Empty user name"), tr("Internal error"));
......@@ -179,26 +115,29 @@ bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
return false;
}
emit statusBarTextChanged(tr("%1: downloading sent").arg(userName),
true, true);
QString msgType = tr("received");
if (msgDirect == Messages::TYPE_SENT) {
msgType = tr("sent");
}
emit statusBarTextChanged(tr("%1: downloading %2").arg(userName).arg(msgType), true, true);
TaskDownloadMessageList *task;
task = new (std::nothrow) TaskDownloadMessageList(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper,
Messages::TYPE_SENT,
(globSet.downloadOnlyNewMsgs) ? DOWNLOAD_NEW_MESSAGES : DOWNLOAD_ALL_MESSAGES,
msgDirect, (globSet.downloadOnlyNewMsgs) ? DOWNLOAD_NEW_MESSAGES : DOWNLOAD_ALL_MESSAGES,
1, MESSAGE_LIST_LIMIT);
task->setAutoDelete(false);
m_workPool.runSingle(task);
QList<qint64> sentMsgIds = task->m_msgIds;
QList<qint64> msgIds = task->m_msgIds;
bool success = TaskDownloadMessageList::DL_SUCCESS == task->m_result;
delete task;
if (!success) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("%1: sent messages").arg(userName),
tr("Failed to download list of sent messages for user name %1.").arg(userName),
tr("%1: %2 messages").arg(userName).arg(msgType),
tr("Failed to download list of %1 messages for user name '%2'.").arg(msgType).arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
} else {
emit statusBarTextChanged(
......@@ -213,15 +152,14 @@ bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
qWarning("%s", "Cannot access message model.");
}
foreach (qint64 msgId, sentMsgIds) {
foreach (qint64 msgId, msgIds) {
TaskDownloadMessage *task;
task = new (std::nothrow) TaskDownloadMessage(
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
&m_dbWrapper, msgId,
Messages::TYPE_SENT, messageModel);
&m_dbWrapper, msgId, msgDirect, messageModel);
task->setAutoDelete(true);
m_workPool.assignHi(task);
m_workPool.assignLo(task, WorkerPool::APPEND);
}
}
......@@ -234,10 +172,17 @@ bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
globSet.dbsLocation, userName,
AccountListModel::globAccounts[userName].storeToDisk());
if (msgDb != Q_NULLPTR) {
accountModel->updateCounters(userName,
-1, -1,
msgDb->getCntOfNewMsgs(MessageDb::TYPE_SENT),
msgDb->getMessageCount(MessageDb::TYPE_SENT));
if (msgDirect == Messages::TYPE_RECEIVED) {
accountModel->updateCounters(userName,
msgDb->getCntOfNewMsgs(MessageDb::TYPE_RECEIVED),
msgDb->getMessageCount(MessageDb::TYPE_RECEIVED),
-1, -1);
} else {
accountModel->updateCounters(userName,
-1, -1,
msgDb->getCntOfNewMsgs(MessageDb::TYPE_SENT),
msgDb->getMessageCount(MessageDb::TYPE_SENT));
}
}
}
......@@ -277,20 +222,14 @@ bool IsdsWrapper::getAccountInfo(const QString &userName, bool isFirstLogin)
emit statusBarTextChanged(tr("Getting account info %1").
arg(userName), true, true);
success = success &&
m_xmlLayer.isdsGetOwnerInfoFromLogin(m_isdsSession.isdsCtxMap[userName]);
emit statusBarTextChanged(tr("Getting user info %1").
arg(userName), true, true);
success = success &&
m_xmlLayer.isdsGetUserInfoFromLogin(m_isdsSession.isdsCtxMap[userName]);
emit statusBarTextChanged(tr("Getting password info %1").
arg(userName), true, true);
TaskDownloadAccountInfo *task;
task = new (std::nothrow) TaskDownloadAccountInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper);
task->setAutoDelete(false);
m_workPool.runSingle(task);
success = success &&
m_xmlLayer.isdsGetPasswordExpiration(m_isdsSession.isdsCtxMap[userName]);
success = TaskDownloadAccountInfo::DL_SUCCESS == task->m_result;
delete task;
if (!success) {
Dialogues::errorMessage(Dialogues::CRITICAL,
......@@ -337,12 +276,16 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
emit statusBarTextChanged(tr("Downloading delivery info %1").
arg(QString::number(msgId)), true, true);
/* NOTE: Method isdsGetMsgDeliveryInfoWithoutCms() is obsolete
* according ISDS specification. Not used now.
* The isdsGetMsgDeliveryInfoWithCms() method is used.
*/
if (!m_xmlLayer.isdsGetMsgDeliveryInfoWithCms(
m_isdsSession.isdsCtxMap[userName], msgId)) {
TaskDownloadDeliveryInfo *task;
task = new (std::nothrow) TaskDownloadDeliveryInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper, msgId);
task->setAutoDelete(false);
m_workPool.runSingle(task);
bool success = TaskDownloadDeliveryInfo::DL_SUCCESS == task->m_result;
delete task;
if (!success) {
Dialogues::errorMessage(Dialogues::WARNING,
tr("Delivery info: %1").arg(userName),
tr("Failed to download delivery info for message %1.").arg(msgId),
......@@ -572,16 +515,14 @@ void IsdsWrapper::downloadMessage(MessageListModel *messageModel,
}
}
m_xmlLayer.isdsGetMsgAuthorInfo(m_isdsSession.isdsCtxMap[userName], msgId);
m_xmlLayer.isdsMarkMsgAsDownloaded(m_isdsSession.isdsCtxMap[userName],
msgId);
TaskDownloadDeliveryInfo *task;
task = new (std::nothrow) TaskDownloadDeliveryInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper, msgId);
task->setAutoDelete(false);
m_workPool.runSingle(task);
/* NOTE: Method isdsGetMsgDeliveryInfoWithoutCms() is obsolete
* according ISDS specification. Not used now.
* The isdsGetMsgDeliveryInfoWithCms() method is used.
*/
m_xmlLayer.isdsGetMsgDeliveryInfoWithCms(
m_isdsSession.isdsCtxMap[userName], msgId);
success = TaskDownloadDeliveryInfo::DL_SUCCESS == task->m_result;
delete task;
emit statusBarTextChanged(tr("Message %1 has been downloaded").arg(msgId),
false, true);
......
......@@ -205,6 +205,21 @@ public slots:
void removeIsdsCtx(const QString &userName);
private:
/*!
* @brief Download received or sent message list of one account.
*
* @param[in,out] acntModelVariant QVariant holding account model
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
* @return True on success.
*/
bool syncSingleAccount(const QVariant &acntModelVariant,
const QVariant &msgModelVariant, const QString &userName,
enum Messages::MessageType msgDirect);
/*!
* @brief Downloads complete message.
*
......
......@@ -34,7 +34,7 @@
/*
* Class NetLayer realizes POST/GET requests
* and provides network management for ISDS connection.
* Class is initialised and used in the XmlLayer class (xml_layer.h)
* Class is initialised and used in the ISDS wrapper class (isds_wrapper.h)
*/
class NetLayer : public QObject {
Q_OBJECT
......@@ -44,7 +44,7 @@ public:
/*!
* @brief Constructor.
*/
NetLayer(QObject *parent = 0);
NetLayer(QObject *parent = Q_NULLPTR);
/*!
* @brief Create ISDS change password request from context.
......
This diff is collapsed.
This diff is collapsed.
/*
* 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 "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_account_info.h"
TaskDownloadAccountInfo::TaskDownloadAccountInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper)
: m_result(DL_ERR),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper)
{
}
void TaskDownloadAccountInfo::run(void)
{
if (Q_NULLPTR == m_netLayer) {
Q_ASSERT(0);
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
logDebugLv0NL("Starting download account info task in thread '%p'",
(void *) QThread::currentThreadId());
/* ### Worker task begin. ### */
logDebugLv1NL("%s", "-----------------------------------------------");
logDebugLv1NL("Downloading account info for account '%s'.",
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadAccountInfo(m_ctx, m_netLayer, m_dbWrapper);
/* ### Worker task end. ### */
logDebugLv0NL("Download account info task finished in thread '%p'",
(void *) QThread::currentThreadId());
}
enum TaskDownloadAccountInfo::Result TaskDownloadAccountInfo::downloadAccountInfo(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper)
{
if (ctx.username.isEmpty()) {
Q_ASSERT(0);
return DL_ERR;
}
DbWrapper::AccountInfo accountInfo;
DbWrapper::UserInfo userInfo;
QString expirDate;
QByteArray xmlDataOut;
/* Send SOAP request to download account owner info */
if (!netLayer->sendSoapRequest(ctx, DB_SERVICE,
XmlLayer::xmlCreateGetOwnerInfoFromLoginSoapRequest(),
xmlDataOut)) {
return DL_ISDS_ERROR;
}
/* Parse SOAP response */
accountInfo.key = ctx.username;
if (!XmlLayer::parseGetOwnerInfoFromLogin(xmlDataOut, accountInfo,
ctx.last_isds_msg)) {
return DL_XML_ERROR;
}
/* Store data into db */
if (!dbWrapper->insertAccountInfoToDb(accountInfo)) {
return DL_DB_INS_ERR;
}
/* Send SOAP request to download user info */
if (!netLayer->sendSoapRequest(ctx, DB_SERVICE,
XmlLayer::xmlCreateGetUserInfoFromLoginSoapRequest(), xmlDataOut)) {
return DL_ISDS_ERROR;
}
/* Parse SOAP response */
userInfo.key = ctx.username;
if (!XmlLayer::parseGetUserInfoFromLogin(xmlDataOut, userInfo,
ctx.last_isds_msg)) {
return DL_XML_ERROR;
}
/* Store data into db */
if (!dbWrapper->insertUserInfoToDb(userInfo)) {
return DL_DB_INS_ERR;
}
/* Send SOAP request download password info */
if (!netLayer->sendSoapRequest(ctx, DB_SERVICE,
XmlLayer::xmlCreateGetPasswordInfoSoapRequest(), xmlDataOut)) {
return DL_ISDS_ERROR;
}
/* Parse SOAP response */
if (!XmlLayer::parseGetPasswordInfo(xmlDataOut, expirDate,
ctx.last_isds_msg)) {
return DL_XML_ERROR;
}
/* Store data into db */
if (!dbWrapper->insertPwdExpirationToDb(ctx.username, expirDate)) {
return DL_DB_INS_ERR;
}
return DL_SUCCESS;
}
/*
* 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 _TASK_DOWNLOAD_ACCOUNT_INFO_H_
#define _TASK_DOWNLOAD_ACCOUNT_INFO_H_
#include "src/net/isds_session.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/worker/task.h"
/*!
* @brief Task describing download account info.
*/
class TaskDownloadAccountInfo : public Task {
public:
/*!
* @brief Return state describing what happened.
*/
enum Result {
DL_SUCCESS, /*!< Operation was successful. */
DL_ISDS_ERROR, /*!< Error communicating with ISDS. */
DL_XML_ERROR, /*!< Error xml parse. */
DL_DB_INS_ERR, /*!< Error inserting into database. */
DL_ERR /*!< Other error. */
};
/*!
* @brief Constructor.
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
*/
explicit TaskDownloadAccountInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper);
/*!
* @brief Performs actual account info download.
*/
virtual
void run(void) Q_DECL_OVERRIDE;
/*!
* @brief Download account info.
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @return Error state.
*/
static
enum Result downloadAccountInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper);
enum Result m_result; /*!< Return state. */
private:
/*!
* Disable copy and assignment.
*/
TaskDownloadAccountInfo(const TaskDownloadAccountInfo &);
TaskDownloadAccountInfo &operator=(const TaskDownloadAccountInfo &);
IsdsSession::IsdsContext m_ctx; /*!< Account isds context. */
NetLayer *m_netLayer; /*!< Pointer to network manager to send request. */
DbWrapper *m_dbWrapper; /*!< Pointer to database wrapper to store reply. */
};
#endif /* _TASK_DOWNLOAD_ACCOUNT_INFO_H_ */
/*
* 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 "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_delivery_info.h"
TaskDownloadDeliveryInfo::TaskDownloadDeliveryInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId)
: m_result(DL_ERR),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper),
m_msgId(msgId)
{
}
void TaskDownloadDeliveryInfo::run(void)
{
if (Q_NULLPTR == m_netLayer) {
Q_ASSERT(0);
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
logDebugLv0NL("Starting download message delivery info task in thread '%p'",
(void *) QThread::currentThreadId());
/* ### Worker task begin. ### */
logDebugLv1NL("%s", "-----------------------------------------------");
logDebugLv1NL("Downloading message delivery info %s for account '%s'.",
QString::number(m_msgId).toUtf8().constData(),
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadDeliveryInfo(m_ctx, m_netLayer, m_dbWrapper, m_msgId);
/* ### Worker task end. ### */
logDebugLv0NL("Download message message delivery info task finished in thread '%p'",
(void *) QThread::currentThreadId());
}
enum TaskDownloadDeliveryInfo::Result TaskDownloadDeliveryInfo::downloadDeliveryInfo(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper,
qint64 msgId)
{
if (ctx.username.isEmpty()) {
Q_ASSERT(0);
return DL_ERR;
}
QByteArray xmlDataOut;
QList<Messages::Event> eventList;
/* Send SOAP request */
if (!netLayer->sendSoapRequest(ctx, MESSAGE_SERVICE,
XmlLayer::xmlCreateSignedDeliveryInfoSoapRequest(msgId),
xmlDataOut)) {
return DL_ISDS_ERROR;
}
/* Parse SOAP response */
if (!XmlLayer::parseGetMsgDeliveryInfoResponse(xmlDataOut, eventList,
ctx.last_isds_msg)) {
return DL_XML_ERROR;
}
if (eventList.isEmpty()) {
return DL_ERR;
}
/* Store data into db */
if (!dbWrapper->insertMesasgeDeliveryInfoToDb(ctx.username, eventList,
msgId, ctx.last_isds_msg)) {
return DL_DB_INS_ERR;
}
return DL_SUCCESS;
}
/*
* 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 _TASK_DOWNLOAD_DELIVERY_INFO_H_
#define _TASK_DOWNLOAD_DELIVERY_INFO_H_
#include "src/net/isds_session.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/worker/task.h"
/*!
* @brief Task describing download delivery info.
*/
class TaskDownloadDeliveryInfo : public Task {
public:
/*!
* @brief Return state describing what happened.
*/
enum Result {
DL_SUCCESS, /*!< Operation was successful. */
DL_ISDS_ERROR, /*!< Error communicating with ISDS. */