Commit 75b49a88 authored by Karel Slaný's avatar Karel Slaný

DbWrapper is no longer a QObject.

Made all its methods static. Made constructor private. Deleted all
instances as they are not needed.
parent 60e50a77
/*
* 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
......@@ -29,11 +29,6 @@
#include "src/sqlite/account_db.h"
#include "src/sqlite/zfo_db.h"
DbWrapper::DbWrapper(QObject *parent)
: QObject(parent)
{
}
QString DbWrapper::createAccountInfoStringForQml(
const DbWrapper::AccountInfo &accountInfo)
{
......
/*
* 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
......@@ -24,7 +24,7 @@
#ifndef _DB_WRAPPER_H_
#define _DB_WRAPPER_H_
#include <QObject>
#include <QCoreApplication> /* Q_DECLARE_TR_FUNCTIONS */
#include "src/qml_interaction/message_envelope.h"
#include "src/sqlite/message_db_container.h"
......@@ -34,11 +34,10 @@
* Class DbWrapper updates data from http response to database.
* Class is initialised and used in the ISDS wrapper class (isds_wrapper.h)
*/
class DbWrapper : public QObject {
Q_OBJECT
class DbWrapper {
Q_DECLARE_TR_FUNCTIONS(DbWrapper)
public:
/*!
* @brief Holds information about an account and owner of databox.
*/
......@@ -99,11 +98,6 @@ public:
QString _pwdExpDate;
};
/*!
* @brief Constructor.
*/
DbWrapper(QObject *parent = Q_NULLPTR);
/*!
* @brief Create account info text for QML.
*
......@@ -127,6 +121,7 @@ public:
* message downloading.
* @return true if success.
*/
static
bool insertMessageListToDb(const QString &userName,
enum MessageDb::MessageType messageType,
const QList<MsgEnvelope> &messages,
......@@ -142,6 +137,7 @@ public:
* @param[out] txt Error description if something fails.
* @return true if success.
*/
static
bool insertCompleteMessageToDb(const QString &userName,
MsgEnvelope &msg, QList<AttachmentData> &fileList,
QString &txt);
......@@ -153,6 +149,7 @@ public:
* @param[in] expirDate Password expiration date string.
* @return true if success.
*/
static
bool insertPwdExpirationToDb(const QString &userName,
const QString &expirDate);
......@@ -162,6 +159,7 @@ public:
* @param[in] accountInfo Account info struct.
* @return true if success.
*/
static
bool insertAccountInfoToDb(const DbWrapper::AccountInfo &accountInfo);
/*!
......@@ -170,6 +168,7 @@ public:
* @param[in] userInfo User info struct.
* @return true if success.
*/
static
bool insertUserInfoToDb(const DbWrapper::UserInfo &userInfo);
/*!
......@@ -182,6 +181,7 @@ public:
* @param[out] txt Error description if something fails.
* @return true if success.
*/
static
bool updateAuthorInfo(const QString &userName, const QString &userType,
const QString &authorName, qint64 msgId, QString &txt);
......@@ -194,6 +194,7 @@ public:
* @param[out] txt Error description if something fails.
* @return true if success.
*/
static
bool insertMesasgeDeliveryInfoToDb(const QString &userName,
const QList<Messages::Event> &eventList, qint64 msgId,
QString &txt);
......@@ -207,8 +208,15 @@ public:
* @param[in] zfoData Zfo data.
* @return true if success.
*/
static
bool insertZfoToDb(qint64 msgId, bool isTestAccount, int zfoSize,
const QByteArray &zfoData);
private:
/*!
* @brief Private constructor.
*/
DbWrapper(void);
};
......
......@@ -144,7 +144,7 @@ QString IsdsWrapper::importZfoMessages(const QString &userName,
zfoNumber++;
TaskImportZfo *task;
task = new (std::nothrow) TaskImportZfo(&m_isdsSession,
&m_netLayer, &m_dbWrapper, userNameList, file,
&m_netLayer, userNameList, file,
authenticate, zfoNumber, zfoTotal);
task->setAutoDelete(true);
globWorkPool.assignLo(task);
......@@ -293,7 +293,7 @@ void IsdsWrapper::getAccountInfo(const QString &userName)
TaskDownloadAccountInfo *task;
task = new (std::nothrow) TaskDownloadAccountInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper);
m_isdsSession.isdsCtxMap[userName], &m_netLayer);
task->setAutoDelete(true);
globWorkPool.assignHi(task);
}
......@@ -419,8 +419,7 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
TaskDownloadDeliveryInfo *task =
new (std::nothrow) TaskDownloadDeliveryInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper,
msgId);
m_isdsSession.isdsCtxMap[userName], &m_netLayer, msgId);
task->setAutoDelete(true);
globWorkPool.assignHi(task);
bool success = TaskDownloadDeliveryInfo::DL_SUCCESS == task->m_result;
......@@ -678,7 +677,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID,
TaskSendMessage *task;
task = new (std::nothrow) TaskSendMessage(
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
&m_dbWrapper, msg, attachList, dmOVM, dmPublishOwnID,
msg, attachList, dmOVM, dmPublishOwnID,
taskIdentifiers.at(i));
task->setAutoDelete(true);
globWorkPool.assignHi(task);
......@@ -1028,7 +1027,7 @@ void IsdsWrapper::downloadMessage(MessageListModel *messageModel,
TaskDownloadMessage *task;
task = new (std::nothrow) TaskDownloadMessage(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper,
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
msgId, messageType, messageModel, (globSet.zfoDbSizeMBs > 0),
AccountListModel::globAccounts[userName].isTestAccount());
task->setAutoDelete(true);
......@@ -1239,7 +1238,7 @@ void IsdsWrapper::syncSingleAccount(const QVariant &acntModelVariant,
/* Create download message list task and run it */
TaskDownloadMessageList *task;
task = new (std::nothrow) TaskDownloadMessageList(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper,
m_isdsSession.isdsCtxMap[userName], &m_netLayer,
msgDirect, (globSet.downloadOnlyNewMsgs) ? DOWNLOAD_NEW_MESSAGES : DOWNLOAD_ALL_MESSAGES,
1, MESSAGE_LIST_LIMIT, &globWorkPool, messageModel, accountModel,
globSet.downloadCompleteMsgs, globSet.dbsLocation,
......
......@@ -27,7 +27,6 @@
#include <QObject>
#include "src/messages.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/net/isds_const.h"
#include "src/net/isds_session.h"
......@@ -600,13 +599,6 @@ private:
const QVariant &msgModelVariant, const QString &userName,
enum Messages::MessageType msgDirect);
/*!
* @brief Instance of DbWrapper class (db_wrapper.h).
*
* Object DbWrapper stores response data to database.
*/
DbWrapper m_dbWrapper;
/*!
* @brief Instance of NetLayer class (net_layer.h).
*
......
/*
* 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
......@@ -24,17 +24,17 @@
#include <QThread>
#include "src/log/log.h"
#include "src/net/db_wrapper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/task_download_account_info.h"
TaskDownloadAccountInfo::TaskDownloadAccountInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper)
NetLayer *netLayer)
: m_result(DL_ERR),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper)
m_netLayer(netLayer)
{
}
......@@ -45,11 +45,6 @@ void TaskDownloadAccountInfo::run(void)
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
logDebugLv0NL("Starting download account info task in thread '%p'",
(void *) QThread::currentThreadId());
......@@ -60,7 +55,7 @@ void TaskDownloadAccountInfo::run(void)
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadAccountInfo(m_ctx, m_netLayer, m_dbWrapper);
m_result = downloadAccountInfo(m_ctx, m_netLayer);
/* ### Worker task end. ### */
......@@ -72,7 +67,7 @@ void TaskDownloadAccountInfo::run(void)
}
enum TaskDownloadAccountInfo::Result TaskDownloadAccountInfo::downloadAccountInfo(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper)
IsdsSession::IsdsContext &ctx, NetLayer *netLayer)
{
if (ctx.username.isEmpty()) {
Q_ASSERT(0);
......@@ -99,7 +94,7 @@ enum TaskDownloadAccountInfo::Result TaskDownloadAccountInfo::downloadAccountInf
}
/* Store data into db */
if (!dbWrapper->insertAccountInfoToDb(accountInfo)) {
if (!DbWrapper::insertAccountInfoToDb(accountInfo)) {
return DL_DB_INS_ERR;
}
......@@ -117,7 +112,7 @@ enum TaskDownloadAccountInfo::Result TaskDownloadAccountInfo::downloadAccountInf
}
/* Store data into db */
if (!dbWrapper->insertUserInfoToDb(userInfo)) {
if (!DbWrapper::insertUserInfoToDb(userInfo)) {
return DL_DB_INS_ERR;
}
......@@ -134,7 +129,7 @@ enum TaskDownloadAccountInfo::Result TaskDownloadAccountInfo::downloadAccountInf
}
/* Store data into db */
if (!dbWrapper->insertPwdExpirationToDb(ctx.username, expirDate)) {
if (!DbWrapper::insertPwdExpirationToDb(ctx.username, expirDate)) {
return DL_DB_INS_ERR;
}
......
/*
* 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
......@@ -25,7 +25,6 @@
#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"
......@@ -50,10 +49,9 @@ public:
*
* @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);
NetLayer *netLayer);
/*!
* @brief Performs actual account info download.
......@@ -66,12 +64,11 @@ public:
*
* @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);
NetLayer *netLayer);
enum Result m_result; /*!< Return state. */
......@@ -84,7 +81,6 @@ private:
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
* 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
......@@ -24,17 +24,17 @@
#include <QThread>
#include "src/log/log.h"
#include "src/net/db_wrapper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/task_download_delivery_info.h"
TaskDownloadDeliveryInfo::TaskDownloadDeliveryInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId)
NetLayer *netLayer, qint64 msgId)
: m_result(DL_ERR),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper),
m_msgId(msgId)
{
}
......@@ -46,11 +46,6 @@ void TaskDownloadDeliveryInfo::run(void)
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
logDebugLv0NL("Starting download message delivery info task in thread '%p'",
(void *) QThread::currentThreadId());
......@@ -62,7 +57,7 @@ void TaskDownloadDeliveryInfo::run(void)
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadDeliveryInfo(m_ctx, m_netLayer, m_dbWrapper, m_msgId);
m_result = downloadDeliveryInfo(m_ctx, m_netLayer, m_msgId);
/* ### Worker task end. ### */
......@@ -75,8 +70,7 @@ void TaskDownloadDeliveryInfo::run(void)
}
enum TaskDownloadDeliveryInfo::Result TaskDownloadDeliveryInfo::downloadDeliveryInfo(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper,
qint64 msgId)
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, qint64 msgId)
{
if (ctx.username.isEmpty()) {
Q_ASSERT(0);
......@@ -101,7 +95,7 @@ enum TaskDownloadDeliveryInfo::Result TaskDownloadDeliveryInfo::downloadDelivery
/* Store data into db */
if (!eventList.isEmpty()) {
if (!dbWrapper->insertMesasgeDeliveryInfoToDb(ctx.username,
if (!DbWrapper::insertMesasgeDeliveryInfoToDb(ctx.username,
eventList, msgId, ctx.last_isds_msg)) {
return DL_DB_INS_ERR;
}
......
/*
* 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
......@@ -25,7 +25,6 @@
#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"
......@@ -50,11 +49,10 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgId Message identifier.
*/
explicit TaskDownloadDeliveryInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId);
NetLayer *netLayer, qint64 msgId);
/*!
* @brief Performs actual message delivery info download.
......@@ -67,13 +65,12 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgId Message identifier.
* @return Error state.
*/
static
enum Result downloadDeliveryInfo(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId);
NetLayer *netLayer, qint64 msgId);
enum Result m_result; /*!< Return state. */
......@@ -86,7 +83,6 @@ private:
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. */
qint64 m_msgId; /*!< Message ID. */
};
......
/*
* 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
......@@ -25,6 +25,7 @@
#include "src/log/log.h"
#include "src/io/filesystem.h"
#include "src/net/db_wrapper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/qml_interaction/message_envelope.h"
......@@ -33,13 +34,12 @@
#include "src/sqlite/message_db_container.h"
TaskDownloadMessage::TaskDownloadMessage(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId,
NetLayer *netLayer, qint64 msgId,
enum Messages::MessageType msgDirect, MessageListModel *messageModel,
bool saveZfo, bool isTestAccount)
: m_result(DL_ERR),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper),
m_msgId(msgId),
m_msgDirect(msgDirect),
m_messageModel(messageModel),
......@@ -55,11 +55,6 @@ void TaskDownloadMessage::run(void)
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
if ((Messages::TYPE_RECEIVED != m_msgDirect)
&& (Messages::TYPE_SENT != m_msgDirect)) {
Q_ASSERT(0);
......@@ -77,7 +72,7 @@ void TaskDownloadMessage::run(void)
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadMessage(m_ctx, m_netLayer, m_dbWrapper, m_msgId,
m_result = downloadMessage(m_ctx, m_netLayer, m_msgId,
m_msgDirect, m_messageModel, m_saveZfo, m_isTestAccount);
/* ### Worker task end. ### */
......@@ -91,7 +86,7 @@ void TaskDownloadMessage::run(void)
}
enum TaskDownloadMessage::Result TaskDownloadMessage::downloadMessage(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper,
IsdsSession::IsdsContext &ctx, NetLayer *netLayer,
qint64 msgId, enum Messages::MessageType msgDirect,
MessageListModel *messageModel, bool saveZfo, bool isTestAccount)
{
......@@ -125,7 +120,7 @@ enum TaskDownloadMessage::Result TaskDownloadMessage::downloadMessage(
}
/* Store data into db */
if (!dbWrapper->insertCompleteMessageToDb(ctx.username, msg,
if (!DbWrapper::insertCompleteMessageToDb(ctx.username, msg,
fileList, ctx.last_isds_msg)) {
return DL_DB_INS_ERR;
}
......@@ -150,7 +145,7 @@ enum TaskDownloadMessage::Result TaskDownloadMessage::downloadMessage(
ctx.last_isds_msg);
/* Store data into db */
dbWrapper->updateAuthorInfo(ctx.username, userType, authorName,
DbWrapper::updateAuthorInfo(ctx.username, userType, authorName,
msgId, ctx.last_isds_msg);
/* Send SOAP request mark message as read (only for received message) */
......@@ -171,14 +166,14 @@ enum TaskDownloadMessage::Result TaskDownloadMessage::downloadMessage(
/* Store delivery info into db */
if (!eventList.isEmpty()) {
dbWrapper->insertMesasgeDeliveryInfoToDb(
DbWrapper::insertMesasgeDeliveryInfoToDb(
ctx.username, eventList, msgId,
ctx.last_isds_msg);
}
/* Save message ZFO to zfo database */
if (saveZfo) {
dbWrapper->insertZfoToDb(msgId, isTestAccount, zfoData.size(),
DbWrapper::insertZfoToDb(msgId, isTestAccount, zfoData.size(),
zfoData);
}
......
/*
* 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
......@@ -26,7 +26,6 @@
#include "src/models/messagemodel.h"
#include "src/net/isds_session.h"
#include "src/net/db_wrapper.h"
#include "src/net/net_layer.h"
#include "src/messages.h"
#include "src/worker/task.h"
......@@ -52,7 +51,6 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgId Message identifier.
* @param[in] msgDirect Received or sent message.
* @param[in] messageModel Pointer to message model.
......@@ -60,7 +58,7 @@ public:
* @param[in] isTestAccount True if account is ISDS testing.
*/
explicit TaskDownloadMessage(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId,
NetLayer *netLayer, qint64 msgId,
enum Messages::MessageType msgDirect,
MessageListModel *messageModel, bool saveZfo, bool isTestAccount);
......@@ -75,7 +73,6 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgId Message identifier.
* @param[in] msgDirect Received or sent message.
* @param[in] messageModel Pointer to message model.
......@@ -86,7 +83,7 @@ public:
*/
static
enum Result downloadMessage(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, qint64 msgId,
NetLayer *netLayer, qint64 msgId,
enum Messages::MessageType msgDirect, MessageListModel *messageModel,
bool saveZfo, bool isTestAccount);
......@@ -101,7 +98,6 @@ private:
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. */
qint64 m_msgId; /*!< Message ID. */
enum Messages::MessageType m_msgDirect; /*!< Sent or received message. */
MessageListModel *m_messageModel; /*!< Pointer to message model. */
......
/*
* 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
......@@ -25,6 +25,7 @@
#include "src/datovka_shared/worker/pool.h" /* List with whole messages. */
#include "src/log/log.h"
#include "src/net/db_wrapper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/qml_interaction/message_envelope.h"
......@@ -34,7 +35,7 @@
#include "src/sqlite/message_db_container.h"
TaskDownloadMessageList::TaskDownloadMessageList(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper, enum Messages::MessageType msgDirect,
NetLayer *netLayer, enum Messages::MessageType msgDirect,
uint dmStatusFilter, uint dmOffset, uint dmLimit, WorkerPool *workPool,
MessageListModel *messageModel, AccountListModel *accountModel,
bool downloadCompleteMsgs, const QString &dbsLocation,
......@@ -43,7 +44,6 @@ TaskDownloadMessageList::TaskDownloadMessageList(IsdsSession::IsdsContext &ctx,
m_statusBarText(),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbWrapper(dbWrapper),
m_msgDirect(msgDirect),
m_dmStatusFilter(dmStatusFilter),
m_dmOffset(dmOffset),
......@@ -65,11 +65,6 @@ void TaskDownloadMessageList::run(void)
return;
}
if (Q_NULLPTR == m_dbWrapper) {
Q_ASSERT(0);
return;
}
if ((Messages::TYPE_RECEIVED != m_msgDirect)
&& (Messages::TYPE_SENT != m_msgDirect)) {
Q_ASSERT(0);
......@@ -87,7 +82,7 @@ void TaskDownloadMessageList::run(void)
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = downloadMessageList(m_ctx, m_netLayer, m_dbWrapper,
m_result = downloadMessageList(m_ctx, m_netLayer,
m_msgDirect, m_dmStatusFilter, m_dmOffset, m_dmLimit,
m_workPool, m_messageModel, m_accountModel, m_downloadCompleteMsgs,
m_dbsLocation, m_saveZfo, m_isTestAccount, m_statusBarText);
......@@ -103,7 +98,7 @@ void TaskDownloadMessageList::run(void)
}
enum TaskDownloadMessageList::Result TaskDownloadMessageList::downloadMessageList(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, DbWrapper *dbWrapper,
IsdsSession::IsdsContext &ctx, NetLayer *netLayer,
enum Messages::MessageType msgDirect, uint dmStatusFilter,
uint dmOffset, uint dmLimit, WorkerPool *workPool,
MessageListModel *messageModel, AccountListModel *accountModel,
......@@ -135,7 +130,7 @@ enum TaskDownloadMessageList::Result TaskDownloadMessageList::downloadMessageLis
/* Store data into db */
QList<qint64> messageChangedStatusList;
if (!dbWrapper->insertMessageListToDb(ctx.username,
if (!DbWrapper::insertMessageListToDb(ctx.username,
(Messages::TYPE_RECEIVED == msgDirect) ? MessageDb::TYPE_RECEIVED : MessageDb::TYPE_SENT,
messages, messageChangedStatusList, ctx.last_isds_msg,
listOfNewMsgIds)) {
......@@ -172,7 +167,7 @@ enum TaskDownloadMessageList::Result TaskDownloadMessageList::downloadMessageLis
/* Store delivery info into db */
if (!eventList.isEmpty()) {
dbWrapper->insertMesasgeDeliveryInfoToDb(
DbWrapper::insertMesasgeDeliveryInfoToDb(
ctx.username, eventList, msgId,
ctx.last_isds_msg);
}
......@@ -210,7 +205,7 @@ enum TaskDownloadMessageList::Result TaskDownloadMessageList::downloadMessageLis
foreach (qint64 msgId, listOfNewMsgIds) {
TaskDownloadMessage *task;
task = new (std::nothrow) TaskDownloadMessage(ctx,
netLayer, dbWrapper, msgId, msgDirect, messageModel,
netLayer, msgId, msgDirect, messageModel,
saveZfo, isTestAccount);
task->setAutoDelete(true);
workPool->assignLo(task, WorkerPool::APPEND);
......
/*
* 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
......@@ -31,11 +31,9 @@
#include "src/models/accountmodel.h"
#include "src/models/messagemodel.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 message list.
*/
......@@ -57,7 +55,6 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgDirect Received or sent message.
* @param[in] dmStatusFilter Dowanlod message status filter.
* @param[in] dmOffset Message download offset.
......@@ -71,7 +68,7 @@ public:
* @param[in] isTestAccount True if account is ISDS testing.
*/
explicit TaskDownloadMessageList(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper,
NetLayer *netLayer,
enum Messages::MessageType msgDirect, uint dmStatusFilter,
uint dmOffset, uint dmLimit, WorkerPool *workPool,
MessageListModel *messageModel, AccountListModel *accountModel,
......@@ -89,7 +86,6 @@ public:
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbWrapper Pointer to database wrapper.
* @param[in] msgDirect Received or sent message.
* @param[in] dmStatusFilter Dowanlod message status filter.
* @param[in] dmOffset Message download offset.
......@@ -108,7 +104,7 @@ public:
*/
static
enum Result downloadMessageList(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, DbWrapper *dbWrapper,
NetLayer *netLayer,
enum Messages::MessageType msgDirect, uint dmStatusFilter,
uint dmOffset, uint dmLimit, WorkerPool *workPool,
MessageListModel *messageModel, AccountListModel *accountModel,
......@@ -127,7 +123,6 @@ private:
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. */
enum Messages::MessageType m_msgDirect; /*!< Sent or received list. */
uint m_dmStatusFilter; /*!< Defines type of messages to be downloaded. */
uint m_dmOffset; /*!< Message download offset. */
......
......@@ -26,6 +26,7 @@
#include <QThread>
#include "src/log/log.h"
#include "src/net/db_wrapper.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/sqlite/account_db.h"
......@@ -33,13 +34,12 @@
#include "src/worker/task_import_zfo.h"
TaskImportZfo::TaskImportZfo(IsdsSession *isdsSession, NetLayer *netLayer,
DbWrapper *dbWrapper, const QStringList &userNameList,
const QStringList &userNameList,
const QString &fileName, bool authenticate, int zfoNumber, int zfoTotal)
: m_result(IMP_ERR),
m_errText(),
m_isdsSession(isdsSession),