Commit b501bee2 authored by Karel Slaný's avatar Karel Slaný

Showing delivery information from ZFO.

parent 11cf45f1
......@@ -46,6 +46,9 @@ Component {
/* These properties are set from within the page. */
property string zfoId /*Prevents infinite loop that would be caused by setting msgId from within the page. */
property string msgAnnotation
property string msgDescrHtml /* Message HTML description. */
property string emailBody
/*
* showDeliveryInfo modify visibility of some elements on this page.
......@@ -54,10 +57,6 @@ Component {
*/
property bool showDeliveryInfo: false
property string msgAnnotation
property string msgDescrHtml /* Message HTML description. */
property string emailBody
function setTopButtonVisibility() {
/* More than two visible icons causes problems on iOS devices. */
msgEmailButton.visible = !fromLocalDb && (attachmentList.count > 0)
......@@ -75,11 +74,8 @@ Component {
msgAnnotation = msgInfo.annotation
msgDescrHtml = msgInfo.descrHtml
emailBody = msgInfo.emailBody
/*
* TODO: get isDeliveryInfo [bool] from parseXmlData() in files
* and set propetry showDeliveryInfo in this page.
*/
//showDeliveryInfo = msgInfo.isDeliveryInfo
showDeliveryInfo = msgInfo.deliveryInfo
attachmentModel.setZfo(rawZfoContent)
......
......@@ -525,21 +525,23 @@ QByteArray Files::base64ToRaw(const QByteArray &base64Data)
MsgInfo *Files::msgInfo(const QByteArray &rawZfoData)
{
bool deliveryInfo = false;
QString idStr, annot, htmlDescr, emailBody;
bool ret = parseXmlData(&idStr, &annot, &htmlDescr, Q_NULLPTR,
&emailBody, getXmlFromCms(rawZfoData));
bool ret = parseXmlData(&deliveryInfo, &idStr, &annot, &htmlDescr,
Q_NULLPTR, &emailBody, getXmlFromCms(rawZfoData));
return ret ?
new (std::nothrow) MsgInfo(idStr, annot, htmlDescr, emailBody) :
new (std::nothrow) MsgInfo(deliveryInfo, idStr, annot, htmlDescr,
emailBody) :
new (std::nothrow) MsgInfo();
}
bool Files::setAttachmentModel(FileListModel &attachModel,
const QByteArray &rawZfoData)
{
return parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, &attachModel,
Q_NULLPTR, getXmlFromCms(rawZfoData));
return parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
&attachModel, Q_NULLPTR, getXmlFromCms(rawZfoData));
}
bool Files::setAttachmentModel(FileListModel &attachModel,
......@@ -837,9 +839,9 @@ QByteArray Files::decodeZfoFile(const QByteArray &base64ZfoData)
return getXmlFromCms(QByteArray::fromBase64(base64ZfoData));
}
bool Files::parseXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel, QString *emailBody,
QByteArray xmlData)
bool Files::parseXmlData(bool *deliveryInfo, QString *idStr,
QString *annotation, QString *msgDescrHtml, FileListModel *attachModel,
QString *emailBody, QByteArray xmlData)
{
qDebug("%s()", __func__);
......@@ -860,13 +862,19 @@ bool Files::parseXmlData(QString *idStr, QString *annotation,
/* Test if zfo is message, delivery info or unknow format */
if (xmlData.contains(QByteArray("MessageDownloadResponse"))) {
if (deliveryInfo != Q_NULLPTR) {
*deliveryInfo = false;
}
return parseAndShowXmlData(false, idStr, annotation,
msgDescrHtml, attachModel, emailBody, xmlData);
} else if (xmlData.contains(QByteArray("GetDeliveryInfoResponse"))) {
if (deliveryInfo != Q_NULLPTR) {
*deliveryInfo = true;
}
return parseAndShowXmlData(true, idStr, annotation,
msgDescrHtml, attachModel, emailBody, xmlData);
} else {
qDebug() << "Unknow zfo format";
qCritical() << "Unknow ZFO format";
Q_ASSERT(0);
}
......
......@@ -304,6 +304,8 @@ private:
* @todo This function must be reworked as it is called multiple times
* on a single message to obtain various data.
*
* @param[out] deliveryInfo Set to true if ZFO contains delivery
* information.
* @param[out] idStr Message identifier number held in a string.
* @param[out] annotation Annotation string.
* @param[out] msgDescrHtml Message text.
......@@ -313,9 +315,9 @@ private:
* @return true if success.
*/
static
bool parseXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel,
QString *emailBody, QByteArray xmlData);
bool parseXmlData(bool *deliveryInfo, QString *idStr,
QString *annotation, QString *msgDescrHtml,
FileListModel *attachModel, QString *emailBody, QByteArray xmlData);
/*!
* @brief Parse and show xml data of zfo file.
......
......@@ -33,6 +33,7 @@ void MsgInfo::declareQML(void)
MsgInfo::MsgInfo(QObject *parent)
: QObject(parent),
m_deliveryInfo(false),
m_idStr(),
m_annotation(),
m_descrHtml(),
......@@ -42,6 +43,7 @@ MsgInfo::MsgInfo(QObject *parent)
MsgInfo::MsgInfo(const MsgInfo &info)
: QObject(),
m_deliveryInfo(info.m_deliveryInfo),
m_idStr(info.m_idStr),
m_annotation(info.m_annotation),
m_descrHtml(info.m_descrHtml),
......@@ -49,9 +51,11 @@ MsgInfo::MsgInfo(const MsgInfo &info)
{
}
MsgInfo::MsgInfo(const QString &idStr, const QString &annotation,
const QString &descrHtml, const QString &emailBody, QObject *parent)
MsgInfo::MsgInfo(bool deliveryInfo, const QString &idStr,
const QString &annotation, const QString &descrHtml,
const QString &emailBody, QObject *parent)
: QObject(parent),
m_deliveryInfo(deliveryInfo),
m_idStr(idStr),
m_annotation(annotation),
m_descrHtml(descrHtml),
......@@ -59,6 +63,17 @@ MsgInfo::MsgInfo(const QString &idStr, const QString &annotation,
{
}
bool MsgInfo::deliveryInfo(void) const
{
return m_deliveryInfo;
}
void MsgInfo::setDeliveryInfo(bool deliveryInfo)
{
m_deliveryInfo = deliveryInfo;
emit deliveryInfoChanged(m_deliveryInfo);
}
QString MsgInfo::idStr(void) const
{
return m_idStr;
......
......@@ -32,6 +32,7 @@
*/
class MsgInfo : public QObject {
Q_OBJECT
Q_PROPERTY(bool deliveryInfo READ deliveryInfo WRITE setDeliveryInfo NOTIFY deliveryInfoChanged)
Q_PROPERTY(QString idStr READ idStr WRITE setIdStr NOTIFY idStrChanged)
Q_PROPERTY(QString annotation READ annotation WRITE setAnnotation NOTIFY annotationChanged)
Q_PROPERTY(QString descrHtml READ descrHtml WRITE setDescrHtml NOTIFY descrHtmlChanged)
......@@ -58,9 +59,12 @@ public:
*/
MsgInfo(const MsgInfo &info);
MsgInfo(const QString &idStr, const QString &annotation,
const QString &descrHtml, const QString &emailBody,
QObject *parent = Q_NULLPTR);
MsgInfo(bool deliveryInfo, const QString &idStr,
const QString &annotation, const QString &descrHtml,
const QString &emailBody, QObject *parent = Q_NULLPTR);
bool deliveryInfo(void) const;
void setDeliveryInfo(bool deliveryInfo);
QString idStr(void) const;
void setIdStr(const QString &idStr);
......@@ -75,12 +79,14 @@ public:
void setEmailBody(const QString &emailBody);
signals:
void deliveryInfoChanged(bool newDeliveryInfo);
void idStrChanged(const QString &newIdStr);
void annotationChanged(const QString &newAnnotation);
void descrHtmlChanged(const QString &newDescrHtml);
void emailBodyChanged(const QString &newEmailBody);
private:
bool m_deliveryInfo; /*!< True if it is a delivery information. */
QString m_idStr; /*!< Message identifier as a string. */
QString m_annotation; /*!< Message annotation. */
QString m_descrHtml; /*!< Description in HTML. */
......
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