Commit 187bf93e authored by Martin Straka's avatar Martin Straka

Download delivery info tasks is asynchronous

parent 671350fd
......@@ -60,6 +60,11 @@ IsdsWrapper::IsdsWrapper(QObject *parent)
SIGNAL(downloadMessageListFinishedSignal(QString, bool, QString, QString, bool)),
this,
SLOT(downloadMessageListFinished(QString, bool, QString, QString, bool)));
connect(&globMsgProcEmitter,
SIGNAL(downloadDeliveryInfoFinishedSignal(QString, qint64, bool, QString)),
this,
SLOT(downloadDeliveryInfoFinished(QString, qint64, bool, QString)));
}
IsdsWrapper::~IsdsWrapper(void)
......@@ -251,8 +256,8 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
TaskDownloadDeliveryInfo *task;
task = new (std::nothrow) TaskDownloadDeliveryInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, &m_dbWrapper, msgId);
task->setAutoDelete(false);
m_workPool.runSingle(task);
task->setAutoDelete(true);
m_workPool.assignHi(task);
bool success = TaskDownloadDeliveryInfo::DL_SUCCESS == task->m_result;
delete task;
......@@ -269,6 +274,19 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
}
}
void IsdsWrapper::downloadDeliveryInfoFinished(const QString &userName,
qint64 msgId, bool success, const QString &errTxt)
{
if (!success) {
Dialogues::errorMessage(Dialogues::WARNING,
tr("Delivery info: %1").arg(userName),
tr("Failed to download delivery info for message %1.").arg(msgId),
errTxt);
} else {
emit statusBarTextChanged(errTxt, false, true);
}
}
bool IsdsWrapper::changePassword(const QString &userName,
const QString &accountName)
{
......
......@@ -238,6 +238,17 @@ public slots:
bool success, const QString &statusBarText, const QString &errTxt,
bool isMsgReceived);
/*!
* @brief Do some actions when download delivery info finished.
*
* @param[in] userName Account username string.
* @param[in] msgId Message ID.
* @param[in] success True if success.
* @param[in] errTxt Errot description.
*/
void downloadDeliveryInfoFinished(const QString &userName,
qint64 msgId, bool success, const QString &errTxt);
private:
/*!
......
......@@ -57,6 +57,17 @@ signals:
void downloadMessageListFinishedSignal(const QString &userName,
bool success, const QString &statusBarText, const QString &errTxt,
bool isMsgReceived);
/*!
* @brief Do some actions when download delivery info finished.
*
* @param[in] userName Account username string.
* @param[in] msgId Message ID.
* @param[in] success True if success.
* @param[in] errTxt Errot description.
*/
void downloadDeliveryInfoFinishedSignal(const QString &userName,
qint64 msgId, bool success, const QString &errTxt);
};
/*!
......
......@@ -24,6 +24,7 @@
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/emitter.h"
#include "src/worker/pool.h" /* List with whole messages. */
#include "src/worker/task_download_delivery_info.h"
......@@ -64,6 +65,10 @@ void TaskDownloadDeliveryInfo::run(void)
/* ### Worker task end. ### */
emit globMsgProcEmitter.downloadDeliveryInfoFinishedSignal(m_ctx.username,
m_msgId, TaskDownloadDeliveryInfo::DL_SUCCESS == m_result,
m_ctx.last_isds_msg);
logDebugLv0NL("Download message message delivery info task finished in thread '%p'",
(void *) QThread::currentThreadId());
}
......
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