Commit 37b478d3 authored by Martin Straka's avatar Martin Straka

Show delivery info from zfo to QML

parent 3f4f797d
......@@ -851,6 +851,8 @@ bool Files::parseXmlData(QString *idStr, QString *annotation,
return success;
}
//qDebug() << xmlData;
xmlData.prepend("<?xml version='1.0' encoding='utf-8'?>"
"<SOAP-ENV:Envelope "
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
......@@ -858,7 +860,30 @@ bool Files::parseXmlData(QString *idStr, QString *annotation,
"<SOAP-ENV:Body>");
xmlData.append("</SOAP-ENV:Body></SOAP-ENV:Envelope>");
//qDebug() << xmlData;
/* Test if zfo is meaage, delivery info or unknow format */
if (xmlData.contains(QByteArray("MessageDownloadResponse"))) {
return parseMesageXmlData(idStr, annotation, msgDescrHtml,
attachModel, emailBody, xmlData);
} else if (xmlData.contains(QByteArray("GetDeliveryInfoResponse"))) {
return parseDeliveryInfoXmlData(idStr, msgDescrHtml, xmlData);
} else {
qDebug() << "Unknow zfo format";
Q_ASSERT(0);
return success;
}
return success;
}
bool Files::parseMesageXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel, QString *emailBody,
QByteArray &xmlData)
{
qDebug("%s()", __func__);
Q_UNUSED(idStr);
bool success = false;
QXmlStreamReader xml;
xml.addData(xmlData);
......@@ -1004,3 +1029,53 @@ bool Files::parseXmlData(QString *idStr, QString *annotation,
return success;
}
bool Files::parseDeliveryInfoXmlData(QString *idStr, QString *msgDescrHtml,
QByteArray &xmlData)
{
qDebug("%s()", __func__);
QString dmID;
QXmlStreamReader xml;
xml.addData(xmlData);
XmlLayer xmlLayer;
QList<Messages::Event> eventList;
while(!xml.atEnd() && !xml.hasError()){
QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartDocument) {
continue;
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmEvent") {
eventList.append(xmlLayer.parseEvent(xml));
}
if (xml.name() == "dmID") {
xml.readNext();
dmID = xml.text().toString();
}
}
}
QString html = divStart;
html += "<h3>" + QObject::tr("Events") + "</h3>";
foreach (const Messages::Event &event, eventList) {
html += event.dmEventTime + ": " + event.dmEventDescr + "<br/>";
}
html += divEnd;
if (idStr != Q_NULLPTR) {
*idStr = dmID;
}
if (msgDescrHtml != Q_NULLPTR) {
*msgDescrHtml = html;
}
QList<Files::File> fileList;
// remember file list and message detail
stackFileList.push(fileList);
stackMessageDetail.push(html);
return true;
}
......@@ -316,6 +316,34 @@ private:
bool parseXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel,
QString *emailBody, QByteArray xmlData);
/*!
* @brief Parse message xml data of zfo file.
*
* @param[out] idStr Message identifier number held in a string.
* @param[out] annotation Annotation string.
* @param[out] msgDescrHtml Message text.
* @param[out] attachModel Attachment model to be set.
* @param[out] emailBody Email body.
* @param[in] xmlData Xml file data.
* @return true if success.
*/
static
bool parseMesageXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel, QString
*emailBody, QByteArray &xmlData);
/*!
* @brief Parse delivery info xml data of zfo file.
*
* @param[out] idStr Message identifier number held in a string.
* @param[out] msgDescrHtml Delivery info text.
* @param[in] xmlData Xml file data.
* @return true if success.
*/
static
bool parseDeliveryInfoXmlData(QString *idStr, QString *msgDescrHtml,
QByteArray &xmlData);
};
#endif // FILES_H
......@@ -195,6 +195,14 @@ public:
bool completeMessageParse(QXmlStreamReader &xml, Messages::Message &msg,
QList<Files::File> &fileList);
/*!
* @brief Parse event from XML.
*
* @param[in] xml - xml Data for parsing.
* @return Event structure.
*/
Messages::Event parseEvent(QXmlStreamReader &xml);
private:
/*!
......@@ -382,14 +390,6 @@ private:
bool parseGetMsgDeliveryInfoResponse(const QByteArray &xmlData,
QList<Messages::Event> &eventList, QString &txt);
/*!
* @brief Parse event from XML.
*
* @param[in] xml - xml Data for parsing.
* @return Event structure.
*/
Messages::Event parseEvent(QXmlStreamReader &xml);
/*!
* @brief Instance of NetLayer class (net_layer.h).
*
......
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