Commit dff712cb authored by Martin Straka's avatar Martin Straka

Refactor message db to new isds structures

parent b3a0dcfc
......@@ -29,11 +29,13 @@
#include "src/dialogues/dialogues.h"
#include "src/global.h"
#include "src/datovka_shared/isds/type_conversion.h"
#include "src/messages.h"
#include "src/models/accountmodel.h"
#include "src/models/databoxmodel.h"
#include "src/models/messagemodel.h"
#include "src/settings.h"
#include "src/sqlite/dbs.h"
#include "src/sqlite/message_db_container.h"
#include "src/sqlite/file_db_container.h"
......@@ -185,35 +187,40 @@ MsgEnvelope *Messages::getMsgEnvelopeDataAndSetRecipient(
return Q_NULLPTR;
}
MsgEnvelope msg = msgDb->getMessageEnvelopeFromDb(msgId);
Isds::Envelope envelope = msgDb->getMessageEnvelopeFromDb(msgId);
// Add recipient to model
DataboxListModel *dbModel =
DataboxListModel::fromVariant(dbModelVariant);
if (dbModel != Q_NULLPTR) {
DataboxModelEntry dbEntry;
dbEntry.setDbID(msg.dbIDSender());
dbEntry.setDbName(msg.dmSender());
dbEntry.setDbAddress(msg.dmSenderAddress());
dbEntry.setDbID(envelope.dbIDSender());
dbEntry.setDbName(envelope.dmSender());
dbEntry.setDbAddress(envelope.dmSenderAddress());
dbModel->addEntry(dbEntry);
}
// Return message envelope data into QML
return new (std::nothrow) MsgEnvelope(msg.dmID(), msg.dmAnnotation(),
msg.dbIDSender(), msg.dmSender(), msg.dmSenderAddress(),
msg.dmSenderType(), msg.dmSenderOrgUnit(), msg.dmSenderOrgUnitNum(),
msg.dmSenderRefNumber(), msg.dmSenderIdent(), msg.dbIDRecipient(),
msg.dmRecipient(), msg.dmRecipientAddress(),
msg.dmRecipientOrgUnit(), msg.dmRecipientOrgUnitNum(),
msg.dmAmbiguousRecipient(), msg.dmRecipientRefNumber(),
msg.dmRecipientIdent(), msg.dmLegalTitleLaw(),
msg.dmLegalTitleYear(), msg.dmLegalTitleSect(),
msg.dmLegalTitlePar(), msg.dmLegalTitlePoint(), msg.dmToHands(),
msg.dmPersonalDelivery(), msg.dmAllowSubstDelivery(),
msg.dmQTimestamp(), msg.dmDeliveryTime(), msg.dmAcceptanceTime(),
msg.dmMessageStatus(), msg.dmAttachmentSize(), msg.dmType(),
msg._dmMessageType(), msg._dmDownloadDate(), msg._dmCustomData(),
msg._dmAttachDownloaded(), msg._dmReadLocally());
return new (std::nothrow) MsgEnvelope(envelope.dmId(),
envelope.dmAnnotation(), envelope.dbIDSender(), envelope.dmSender(),
envelope.dmSenderAddress(), envelope.dmSenderType(),
envelope.dmSenderOrgUnit(), envelope.dmSenderOrgUnitNumStr(),
envelope.dmSenderRefNumber(), envelope.dmSenderIdent(),
envelope.dbIDRecipient(), envelope.dmRecipient(),
envelope.dmRecipientAddress(), envelope.dmRecipientOrgUnit(),
envelope.dmRecipientOrgUnitNumStr(),
envelope.dmAmbiguousRecipient() == Isds::Type::BOOL_TRUE,
envelope.dmRecipientRefNumber(), envelope.dmRecipientIdent(),
envelope.dmLegalTitleLawStr(), envelope.dmLegalTitleYearStr(),
envelope.dmLegalTitleSect(), envelope.dmLegalTitlePar(),
envelope.dmLegalTitlePoint(), envelope.dmToHands(),
envelope.dmPersonalDelivery() == Isds::Type::BOOL_TRUE,
envelope.dmAllowSubstDelivery() == Isds::Type::BOOL_TRUE,
envelope.dmQTimestamp(),
utcDateTimeToDbFormatStr(envelope.dmDeliveryTime()),
utcDateTimeToDbFormatStr(envelope.dmAcceptanceTime()),
Isds::dmState2Variant(envelope.dmMessageStatus()).toInt(),
envelope.dmAttachmentSize(), envelope.dmType());
}
void Messages::markMessageAsLocallyRead(const QVariant &msgModelVariant,
......
......@@ -185,13 +185,6 @@ public:
*/
void deleteExpiredMessagesFromDbs(int days);
// Holds message event inforamtion
class Event {
public:
QString dmEventTime;
QString dmEventDescr;
};
signals:
/*!
......
/*
* 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 <QQmlEngine> /* qmlRegisterType */
#include "src/qml_interaction/attachment_data.h"
void AttachmentData::declareQML(void)
{
qmlRegisterType<AttachmentData>("cz.nic.mobileDatovka.attachmentData", 1, 0, "AttachmentData");
qRegisterMetaType<AttachmentData>();
}
AttachmentData::AttachmentData(QObject *parent)
: QObject(parent),
m_fileId(0),
m_dmId(0),
m_dmFileDescr(),
m_dmUpFileGuid(),
m_dmFileGuid(),
m_dmMimeType(),
m_dmFormat(),
m_dmFileMetaType(),
m_dmEncodedContent(),
m_dmFileSize(),
m_dmDownloadDate(),
m_icon()
{
}
AttachmentData::AttachmentData(const AttachmentData &data)
: QObject(),
m_fileId(data.m_fileId),
m_dmId(data.m_dmId),
m_dmFileDescr(data.m_dmFileDescr),
m_dmUpFileGuid(data.m_dmUpFileGuid),
m_dmFileGuid(data.m_dmFileGuid),
m_dmMimeType(data.m_dmMimeType),
m_dmFormat(data.m_dmFormat),
m_dmFileMetaType(data.m_dmFileMetaType),
m_dmEncodedContent(data.m_dmEncodedContent),
m_dmFileSize(data.m_dmFileSize),
m_dmDownloadDate(data.m_dmDownloadDate),
m_icon(data.m_icon)
{
}
AttachmentData::AttachmentData(int fileId, qint64 dmId,
const QString &dmFileDescr, const QString &dmUpFileGuid,
const QString &dmFileGuid, const QString &dmMimeType, const QString &dmFormat,
const QString &dmFileMetaType, const QString &dmEncodedContent,
const QString &_dmFileSize, const QString &_dmDownloadDate,
const QString &_icon, QObject *parent)
: QObject(parent),
m_fileId(fileId),
m_dmId(dmId),
m_dmFileDescr(dmFileDescr),
m_dmUpFileGuid(dmUpFileGuid),
m_dmFileGuid(dmFileGuid),
m_dmMimeType(dmMimeType),
m_dmFormat(dmFormat),
m_dmFileMetaType(dmFileMetaType),
m_dmEncodedContent(dmEncodedContent),
m_dmFileSize(_dmFileSize),
m_dmDownloadDate(_dmDownloadDate),
m_icon(_icon)
{
}
int AttachmentData::fileId(void) const
{
return m_fileId;
}
void AttachmentData::setFileId(int fileId)
{
m_fileId = fileId;
}
qint64 AttachmentData::dmId(void) const
{
return m_dmId;
}
void AttachmentData::setDmId(qint64 dmId)
{
m_dmId = dmId;
}
QString AttachmentData::dmFileDescr(void) const
{
return m_dmFileDescr;
}
void AttachmentData::setDmFileDescr(const QString &dmFileDescr)
{
m_dmFileDescr = dmFileDescr;
}
QString AttachmentData::dmUpFileGuid(void) const
{
return m_dmUpFileGuid;
}
void AttachmentData::setDmUpFileGuid(const QString &dmUpFileGuid)
{
m_dmUpFileGuid = dmUpFileGuid;
}
QString AttachmentData::dmFileGuid(void) const
{
return m_dmFileGuid;
}
void AttachmentData::setDmFileGuid(const QString &dmFileGuid)
{
m_dmFileGuid = dmFileGuid;
}
QString AttachmentData::dmMimeType(void) const
{
return m_dmMimeType;
}
void AttachmentData::setDmMimeType(const QString &dmMimeType)
{
m_dmMimeType = dmMimeType;
}
QString AttachmentData::dmFormat(void) const
{
return m_dmFormat;
}
void AttachmentData::setDmFormat(const QString &dmFormat)
{
m_dmFormat = dmFormat;
}
QString AttachmentData::dmFileMetaType(void) const
{
return m_dmFileMetaType;
}
void AttachmentData::setDmFileMetaType(const QString &dmFileMetaType)
{
m_dmFileMetaType = dmFileMetaType;
}
QString AttachmentData::dmEncodedContent(void) const
{
return m_dmEncodedContent;
}
void AttachmentData::setDmEncodedContent(const QString &dmEncodedContent)
{
m_dmEncodedContent = dmEncodedContent;
}
QString AttachmentData::_dmFileSize(void) const
{
return m_dmFileSize;
}
void AttachmentData::_setDmFileSize(const QString &_dmFileSize)
{
m_dmFileSize = _dmFileSize;
}
QString AttachmentData::_dmDownloadDate(void) const
{
return m_dmDownloadDate;
}
void AttachmentData::_setDmDownloadDate(const QString &_dmDownloadDate)
{
m_dmDownloadDate = _dmDownloadDate;
}
QString AttachmentData::_icon(void) const
{
return m_icon;
}
void AttachmentData::_setIcon(const QString &_icon)
{
m_icon = _icon;
}
AttachmentData *AttachmentData::fromVariant(const QVariant &attachDataVariant)
{
if (!attachDataVariant.canConvert<QObject *>()) {
return Q_NULLPTR;
}
QObject *obj = qvariant_cast<QObject *>(attachDataVariant);
return qobject_cast<AttachmentData *>(obj);
}
/*
* 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_DATA_H_
#define _ATTACHMENT_DATA_H_
#include <QObject>
#include <QString>
/*!
* @brief Class holds attachment data.
*/
class AttachmentData : public QObject {
Q_OBJECT
Q_PROPERTY(int fileId READ fileId WRITE setFileId)
Q_PROPERTY(qint64 dmId READ dmId WRITE setDmId)
Q_PROPERTY(QString dmFileDescr READ dmFileDescr WRITE setDmFileDescr)
Q_PROPERTY(QString dmUpFileGuid READ dmUpFileGuid WRITE setDmUpFileGuid)
Q_PROPERTY(QString dmFileGuid READ dmFileGuid WRITE setDmFileGuid)
Q_PROPERTY(QString dmMimeType READ dmMimeType WRITE setDmMimeType)
Q_PROPERTY(QString dmFormat READ dmFormat WRITE setDmFormat)
Q_PROPERTY(QString dmFileMetaType READ dmFileMetaType WRITE setDmFileMetaType)
Q_PROPERTY(QString dmEncodedContent READ dmEncodedContent WRITE setDmEncodedContent)
Q_PROPERTY(QString _dmFileSize READ _dmFileSize WRITE _setDmFileSize)
Q_PROPERTY(QString _dmDownloadDate READ _dmDownloadDate WRITE _setDmDownloadDate)
Q_PROPERTY(QString _icon READ _icon WRITE _setIcon)
public:
/* Don't forget to declare various properties to the QML system. */
static
void declareQML(void);
/*!
* @brief Constructor.
*
* @param[in] parent Parent object.
*/
explicit AttachmentData(QObject *parent = Q_NULLPTR);
/*!
* @brief Copy constructor.
*
* @note Needed for QVariant conversion.
*
* @param[in] info Attachment data to be copied.
*/
AttachmentData(const AttachmentData &data);
AttachmentData(int fileId, qint64 dmId, const QString &dmFileDescr,
const QString &dmUpFileGuid, const QString &dmFileGuid,
const QString &dmMimeType, const QString &dmFormat,
const QString &dmFileMetaType, const QString &dmEncodedContent,
const QString &_dmFileSize, const QString &_dmDownloadDate,
const QString &_icon, QObject *parent = Q_NULLPTR);
/*!
* @brief Assignment operator.
*
* @note gcc 5.4 bitches about missing operator= declaration.
*
* @param[in] data Attachment data.
* @return Reference to itself.
*/
AttachmentData &operator=(const AttachmentData &data);
int fileId(void) const;
void setFileId(int fileId);
qint64 dmId(void) const;
void setDmId(qint64 dmId);
QString dmFileDescr(void) const;
void setDmFileDescr(const QString &dmFileDescr);
QString dmUpFileGuid(void) const;
void setDmUpFileGuid(const QString &dmUpFileGuid);
QString dmFileGuid(void) const;
void setDmFileGuid(const QString &dmFileGuid);
QString dmMimeType(void) const;
void setDmMimeType(const QString &dmMimeType);
QString dmFormat(void) const;
void setDmFormat(const QString &dmFormat);
QString dmFileMetaType(void) const;
void setDmFileMetaType(const QString &dmFileMetaType);
QString dmEncodedContent(void) const;
void setDmEncodedContent(const QString &dmEncodedContent);
QString _dmFileSize(void) const;
void _setDmFileSize(const QString &_dmFileSize);
QString _dmDownloadDate(void) const;
void _setDmDownloadDate(const QString &_dmDownloadDate);
QString _icon(void) const;
void _setIcon(const QString &_icon);
/*!
* @brief Converts QVariant obtained from QML into data pointer.
*
* @note Some weird stuff happens in QML when passing attachment data
* directly as constant reference. Wrong constructors are called
* and no data are passed. That's because we are using a QVariant.
* This function does not allocate a new data.
*
* @param[in] attachDataVariant QVariant holding the attachment data.
* @return Pointer to data if it could be acquired, Q_NULLPTR else.
*/
static
AttachmentData *fromVariant(const QVariant &attachDataVariant);
private:
int m_fileId; /*!< File identifier. */
qint64 m_dmId; /*!< Message identifier. */
QString m_dmFileDescr; /*!< File name. */
QString m_dmUpFileGuid; /*!< ISDS guid. */
QString m_dmFileGuid; /*!< File guid. */
QString m_dmMimeType; /*!< File mime type. */
QString m_dmFormat; /*!< File format. */
QString m_dmFileMetaType; /*!< File meta mime type. */
QString m_dmEncodedContent; /*!< Base64 file content. */
QString m_dmFileSize; /*!< File size string in kB. */
QString m_dmDownloadDate; /*!< File download date. */
QString m_icon; /*!< File icon resource. */
};
/* QML passes its arguments via QVariant. */
Q_DECLARE_METATYPE(AttachmentData)
#endif /* _ATTACHMENT_DATA_H_ */
......@@ -48,7 +48,7 @@ MsgEnvelope::MsgEnvelope(QObject *parent)
m_dmRecipientAddress(),
m_dmRecipientOrgUnit(),
m_dmRecipientOrgUnitNum(),
m_dmAmbiguousRecipient(),
m_dmAmbiguousRecipient(false),
m_dmRecipientRefNumber(),
m_dmRecipientIdent(),
m_dmLegalTitleLaw(),
......@@ -64,12 +64,7 @@ MsgEnvelope::MsgEnvelope(QObject *parent)
m_dmAcceptanceTime(),
m_dmMessageStatus(0),
m_dmAttachmentSize(0),
m_dmType(),
m_dmMessageType(0),
m_dmDownloadDate(),
m_dmCustomData(),
m_dmAttachDownloaded(false),
m_dmReadLocally(false)
m_dmType()
{
}
......@@ -106,12 +101,7 @@ MsgEnvelope::MsgEnvelope(const MsgEnvelope &data)
m_dmAcceptanceTime(data.m_dmAcceptanceTime),
m_dmMessageStatus(data.m_dmMessageStatus),
m_dmAttachmentSize(data.m_dmAttachmentSize),
m_dmType(data.m_dmType),
m_dmMessageType(data.m_dmMessageType),
m_dmDownloadDate(data.m_dmDownloadDate),
m_dmCustomData(data.m_dmCustomData),
m_dmAttachDownloaded(data.m_dmAttachDownloaded),
m_dmReadLocally(data.m_dmReadLocally)
m_dmType(data.m_dmType)
{
}
......@@ -122,7 +112,7 @@ MsgEnvelope::MsgEnvelope(qint64 dmID, const QString &dmAnnotation,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
const QString &dbIDRecipient, const QString &dmRecipient,
const QString &dmRecipientAddress, const QString &dmRecipientOrgUnit,
const QString &dmRecipientOrgUnitNum, const QString &dmAmbiguousRecipient,
const QString &dmRecipientOrgUnitNum, bool dmAmbiguousRecipient,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmLegalTitleLaw, const QString &dmLegalTitleYear,
const QString &dmLegalTitleSect, const QString &dmLegalTitlePar,
......@@ -130,8 +120,7 @@ MsgEnvelope::MsgEnvelope(qint64 dmID, const QString &dmAnnotation,
bool dmPersonalDelivery, bool dmAllowSubstDelivery,
const QString &dmQTimestamp, const QString &dmDeliveryTime,
const QString &dmAcceptanceTime, int dmMessageStatus, int dmAttachmentSize,
const QString &dmType, int _dmMessageType, const QString &_dmDownloadDate,
const QString &_dmCustomData, bool _dmAttachDownloaded, bool _dmReadLocally,
const QString &dmType,
QObject *parent)
: QObject(parent),
m_dmID(dmID),
......@@ -165,12 +154,7 @@ MsgEnvelope::MsgEnvelope(qint64 dmID, const QString &dmAnnotation,
m_dmAcceptanceTime(dmAcceptanceTime),
m_dmMessageStatus(dmMessageStatus),
m_dmAttachmentSize(dmAttachmentSize),
m_dmType(dmType),
m_dmMessageType(_dmMessageType),
m_dmDownloadDate(_dmDownloadDate),
m_dmCustomData(_dmCustomData),
m_dmAttachDownloaded(_dmAttachDownloaded),
m_dmReadLocally(_dmReadLocally)
m_dmType(dmType)
{
}
......@@ -324,12 +308,12 @@ void MsgEnvelope::setDmRecipientOrgUnitNum(const QString &dmRecipientOrgUnitNum)
m_dmRecipientOrgUnitNum = dmRecipientOrgUnitNum;
}
QString MsgEnvelope::dmAmbiguousRecipient(void) const
bool MsgEnvelope::dmAmbiguousRecipient(void) const
{
return m_dmAmbiguousRecipient;
}
void MsgEnvelope::setDmAmbiguousRecipient(const QString &dmAmbiguousRecipient)
void MsgEnvelope::setDmAmbiguousRecipient(bool dmAmbiguousRecipient)
{
m_dmAmbiguousRecipient = dmAmbiguousRecipient;
}
......@@ -493,54 +477,6 @@ void MsgEnvelope::setDmType(const QString &dmType)
m_dmType = dmType;
}
int MsgEnvelope::_dmMessageType(void) const
{
return m_dmMessageType;
}
void MsgEnvelope::_setDmMessageType(int _dmMessageType)
{
m_dmMessageType = _dmMessageType;
}
QString MsgEnvelope::_dmDownloadDate(void) const
{
return m_dmDownloadDate;
}
void MsgEnvelope::_setDmDownloadDate(const QString &_dmDownloadDate)
{
m_dmDownloadDate = _dmDownloadDate;
}
QString MsgEnvelope::_dmCustomData(void) const
{
return m_dmCustomData;
}
void MsgEnvelope::_setDmCustomData(const QString &_dmCustomData)
{
m_dmCustomData = _dmCustomData;
}
bool MsgEnvelope::_dmAttachDownloaded(void) const
{
return m_dmAttachDownloaded;
}
void MsgEnvelope::_setDmAttachDownloaded(bool _dmAttachDownloaded)
{
m_dmAttachDownloaded = _dmAttachDownloaded;
}
bool MsgEnvelope::_dmReadLocally(void) const
{
return m_dmReadLocally;
}
void MsgEnvelope::_setDmReadLocally(bool _dmReadLocally)
{
m_dmReadLocally = _dmReadLocally;
}
MsgEnvelope *MsgEnvelope::fromVariant(const QVariant &msgEnvelDataVariant)
{
if (!msgEnvelDataVariant.canConvert<QObject *>()) {
......
......@@ -50,7 +50,7 @@ class MsgEnvelope : public QObject {
Q_PROPERTY(QString dmRecipientAddress READ dmRecipientAddress WRITE setDmRecipientAddress)
Q_PROPERTY(QString dmRecipientOrgUnit READ dmRecipientOrgUnit WRITE setDmRecipientOrgUnit)
Q_PROPERTY(QString dmRecipientOrgUnitNum READ dmRecipientOrgUnitNum WRITE setDmRecipientOrgUnitNum)
Q_PROPERTY(QString dmAmbiguousRecipient READ dmAmbiguousRecipient WRITE setDmAmbiguousRecipient)
Q_PROPERTY(bool dmAmbiguousRecipient READ dmAmbiguousRecipient WRITE setDmAmbiguousRecipient)
Q_PROPERTY(QString dmRecipientRefNumber READ dmRecipientRefNumber WRITE setDmRecipientRefNumber)
Q_PROPERTY(QString dmRecipientIdent READ dmRecipientIdent WRITE setDmRecipientIdent)
......@@ -70,12 +70,6 @@ class MsgEnvelope : public QObject {
Q_PROPERTY(int dmAttachmentSize READ dmAttachmentSize WRITE setDmAttachmentSize)
Q_PROPERTY(QString dmType READ dmType WRITE setDmType)
Q_PROPERTY(int _dmMessageType READ _dmMessageType WRITE _setDmMessageType)
Q_PROPERTY(QString _dmDownloadDate READ _dmDownloadDate WRITE _setDmDownloadDate)
Q_PROPERTY(QString _dmCustomData READ _dmCustomData WRITE _setDmCustomData)
Q_PROPERTY(bool _dmAttachDownloaded READ _dmAttachDownloaded WRITE _setDmAttachDownloaded)
Q_PROPERTY(bool _dmReadLocally READ _dmReadLocally WRITE _setDmReadLocally)
public:
/* Don't forget to declare various properties to the QML system. */
......@@ -116,7 +110,7 @@ public:
const QString &dmRecipientAddress,
const QString &dmRecipientOrgUnit,
const QString &dmRecipientOrgUnitNum,
const QString &dmAmbiguousRecipient,
bool dmAmbiguousRecipient,
const QString &dmRecipientRefNumber,
const QString &dmRecipientIdent,
......@@ -136,11 +130,6 @@ public:
int dmAttachmentSize,
const QString &dmType,
int _dmMessageType,
const QString &_dmDownloadDate,
const QString &_dmCustomData,
bool _dmAttachDownloaded,
bool _dmReadLocally,
QObject *parent = Q_NULLPTR);
/*!
......@@ -185,8 +174,8 @@ public:
void setDmRecipientOrgUnit(const QString &dmRecipientOrgUnit);
QString dmRecipientOrgUnitNum(void) const;
void setDmRecipientOrgUnitNum(const QString &dmRecipientOrgUnitNum);
QString dmAmbiguousRecipient(void) const;
void setDmAmbiguousRecipient(const QString &dmAmbiguousRecipient);
bool dmAmbiguousRecipient(void) const;
void setDmAmbiguousRecipient(bool dmAmbiguousRecipient);
QString dmRecipientRefNumber(void) const;
void setDmRecipientRefNumber(const QString &dmRecipientRefNumber);
QString dmRecipientIdent(void) const;
......@@ -222,17 +211,6 @@ public:
QString dmType(void) const;
void setDmType(const QString &dmType);
int _dmMessageType(void) const;
void _setDmMessageType(int _dmMessageType);
QString _dmDownloadDate(void) const;
void _setDmDownloadDate(const QString &_dmDownloadDate);
QString _dmCustomData(void) const;
void _setDmCustomData(const QString &_dmCustomData);
bool _dmAttachDownloaded(void) const;
void _setDmAttachDownloaded(bool _dmAttachDownloaded);
bool _dmReadLocally(void) const;
void _setDmReadLocally(bool _dmReadLocally);
/*!
* @brief Converts QVariant obtained from QML into data pointer.
*
......@@ -266,7 +244,7 @@ private:
QString m_dmRecipientAddress;
QString m_dmRecipientOrgUnit;
QString m_dmRecipientOrgUnitNum;
QString m_dmAmbiguousRecipient;
bool m_dmAmbiguousRecipient;
QString m_dmRecipientRefNumber;
QString m_dmRecipientIdent;
......@@ -285,12 +263,6 @@ private:
int m_dmMessageStatus;
int m_dmAttachmentSize;
QString m_dmType;
int m_dmMessageType;
QString m_dmDownloadDate;
QString m_dmCustomData;
bool m_dmAttachDownloaded;
bool m_dmReadLocally;
};
/* QML passes its arguments via QVariant. */
......
......@@ -279,11 +279,11 @@ int MessageDb::getMessageCountFromDb(enum MessageType messageType)
return 0;
}
MsgEnvelope MessageDb::getMessageEnvelopeFromDb(qint64 dmId)
Isds::Envelope MessageDb::getMessageEnvelopeFromDb(qint64 dmId)
{
QSqlQuery query(m_db);
QString queryStr;
MsgEnvelope msgEnvel;
Isds::Envelope envelope;
queryStr = "SELECT dmAnnotation, "
"dbIDSender, dmSender, dmSenderAddress, dmSenderType, "
......@@ -294,58 +294,61 @@ MsgEnvelope MessageDb::getMessageEnvelopeFromDb(qint64 dmId)
"dmLegalTitleYear, dmLegalTitleSect, dmLegalTitlePar, "
"dmLegalTitlePoint, dmToHands, dmPersonalDelivery, "
"dmAllowSubstDelivery, dmQTimestamp, dmDeliveryTime, "
"dmAcceptanceTime, dmMessageStatus, dmAttachmentSize, dmType, "
"_dmMessageType, _dmDownloadDate, _dmCustomData, "
"_dmAttachDownloaded, _dmReadLocally "
"dmAcceptanceTime, dmMessageStatus, dmAttachmentSize, dmType "
"FROM messages WHERE dmID = :dmID";
if (!query.prepare(queryStr)) {
return msgEnvel;
return Isds::Envelope();
}
query.bindValue(":dmID", dmId);
if (query.exec() && query.isActive() &&
query.first() && query.isValid()) {
msgEnvel.setDmID(dmId);
msgEnvel.setDmAnnotation(query.value(0).toString());
msgEnvel.setDbIDSender(query.value(1).toString());
msgEnvel.setDmSender(query.value(2).toString());
msgEnvel.setDmSenderAddress(query.value(3).toString());
msgEnvel.setDmSenderType(query.value(4).toInt());
msgEnvel.setDmSenderOrgUnit(query.value(5).toString());
msgEnvel.setDmSenderOrgUnitNum(query.value(6).toString());
msgEnvel.setDmSenderRefNumber(query.value(7).toString());
msgEnvel.setDmSenderIdent(query.value(8).toString());
msgEnvel.setDbIDRecipient(query.value(9).toString());
msgEnvel.setDmRecipient(query.value(10).toString());
msgEnvel.setDmRecipientAddress(query.value(11).toString());