Commit 96db84a2 authored by Karel Slaný's avatar Karel Slaný

ZFO detail page shows message id.

parent 53bdb932
......@@ -291,6 +291,7 @@ ApplicationWindow {
var fileContent = files.rawFileContent(filePath)
mainStack.push(pageZfoMessageDetail, {
"pageView": mainStack,
"fromLocalDb": false,
"rawZfoContent": fileContent
}, StackView.Immediate)
}
......
......@@ -36,16 +36,17 @@ Component {
/* These properties must be set by caller. */
property var pageView
property var statusBar
property var fromLocalDb: false
property var rawZfoContent /* Raw ZFO file content. */
/* These properties are set from within the page. */
property string zfoId
property var msgAnnotation
property var msgDescrHtml /* Message HTML description. */
property string emailBody
property string zfoId
onRawZfoContentChanged: {
console.log("File path changed.")
zfoId = files.msgIdString(rawZfoContent)
msgAnnotation = files.msgAnnotation(rawZfoContent),
msgDescrHtml = files.msgDescriptionHtml(rawZfoContent),
emailBody = files.msgEmailBody(rawZfoContent)
......@@ -266,6 +267,7 @@ Component {
pageView.push(pageZfoMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
"rawZfoContent": fileContent
}, StackView.Immediate)
} else {
......
......@@ -233,8 +233,9 @@ void Files::openAttachmentFromDb(const QString &userName,
}
if (isZfoFile(fileName)) {
parseXmlData(Q_NULLPTR, Q_NULLPTR, &globFilesModelZfo,
Q_NULLPTR, decodeZfoFile(file.content.toUtf8()));
parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
&globFilesModelZfo, Q_NULLPTR,
decodeZfoFile(file.content.toUtf8()));
return;
}
......@@ -640,30 +641,31 @@ QByteArray Files::decodeZfoFile(const QByteArray &base64ZfoData)
return getXmlFromCms(QByteArray::fromBase64(base64ZfoData));
}
bool Files::parseXmlData(QString *annotation, QString *msgDescrHtml,
FileListModel *attachModel, QString *emailBody, QByteArray data)
bool Files::parseXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel, QString *emailBody,
QByteArray xmlData)
{
qDebug("%s()", __func__);
bool success = false;
Q_ASSERT(!data.isEmpty());
if (data.isEmpty()) {
qDebug() << "ERROR: XML content is empty!";
if (xmlData.isEmpty()) {
Q_ASSERT(0);
qCritical() << "XML content is empty!";
return success;
}
data.prepend("<?xml version='1.0' encoding='utf-8'?>"
xmlData.prepend("<?xml version='1.0' encoding='utf-8'?>"
"<SOAP-ENV:Envelope "
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
"<SOAP-ENV:Body>");
data.append("</SOAP-ENV:Body></SOAP-ENV:Envelope>");
xmlData.append("</SOAP-ENV:Body></SOAP-ENV:Envelope>");
//qDebug() << data;
//qDebug() << xmlData;
QXmlStreamReader xml;
xml.addData(data);
xml.addData(xmlData);
XmlLayer xmlLayer;
Messages::Message msg;
......@@ -785,6 +787,9 @@ bool Files::parseXmlData(QString *annotation, QString *msgDescrHtml,
"to databox.").arg(msg.dmID);
body += "\n";
if (idStr != Q_NULLPTR) {
*idStr = QString::number(msg.dmID);
}
if (annotation != Q_NULLPTR) {
*annotation = msg.dmAnnotation;
}
......@@ -854,11 +859,20 @@ QByteArray Files::base64ToRaw(const QByteArray &base64Data)
return QByteArray::fromBase64(base64Data);
}
QString Files::msgIdString(const QByteArray &rawZfoData)
{
QString msgId;
bool ret = parseXmlData(&msgId, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
Q_NULLPTR, getXmlFromCms(rawZfoData));
return ret ? msgId : QString();
}
QString Files::msgAnnotation(const QByteArray &rawZfoData)
{
QString annotation;
bool ret = parseXmlData(&annotation, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
getXmlFromCms(rawZfoData));
bool ret = parseXmlData(Q_NULLPTR, &annotation, Q_NULLPTR, Q_NULLPTR,
Q_NULLPTR, getXmlFromCms(rawZfoData));
return ret ? annotation : QString();
}
......@@ -866,8 +880,8 @@ QString Files::msgAnnotation(const QByteArray &rawZfoData)
QString Files::msgDescriptionHtml(const QByteArray &rawZfoData)
{
QString htmlDescr;
bool ret = parseXmlData(Q_NULLPTR, &htmlDescr, Q_NULLPTR, Q_NULLPTR,
getXmlFromCms(rawZfoData));
bool ret = parseXmlData(Q_NULLPTR, Q_NULLPTR, &htmlDescr, Q_NULLPTR,
Q_NULLPTR, getXmlFromCms(rawZfoData));
return ret ? htmlDescr : QString();
}
......@@ -875,8 +889,8 @@ QString Files::msgDescriptionHtml(const QByteArray &rawZfoData)
QString Files::msgEmailBody(const QByteArray &rawZfoData)
{
QString emailBody;
bool ret = parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, &emailBody,
getXmlFromCms(rawZfoData));
bool ret = parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR,
&emailBody, getXmlFromCms(rawZfoData));
return ret ? emailBody : QString();
}
......@@ -884,6 +898,6 @@ QString Files::msgEmailBody(const QByteArray &rawZfoData)
bool Files::setAttachmentModel(FileListModel &attachModel,
const QByteArray &rawZfoData)
{
return parseXmlData(Q_NULLPTR, Q_NULLPTR, &attachModel, Q_NULLPTR,
getXmlFromCms(rawZfoData));
return parseXmlData(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, &attachModel,
Q_NULLPTR, getXmlFromCms(rawZfoData));
}
......@@ -151,10 +151,23 @@ public:
Q_INVOKABLE static
QByteArray base64ToRaw(const QByteArray &base64Data);
/*!
* @brief Return message id.
*
* @note QML hasn't got the faintest idea about qint64, therefore the
* number is passed as a string.
*
* @param[in] rawZfoData Raw ZFO data.
* @return String containing message identifier number, or null string
* on error.
*/
Q_INVOKABLE static
QString msgIdString(const QByteArray &rawZfoData);
/*!
* @brief Parses content of ZFO file.
*
* @param[in] filePath Path to file.
* @param[in] rawZfoData Raw ZFO data.
* @return Annotation on success, empty string else.
*/
Q_INVOKABLE static
......@@ -163,7 +176,7 @@ public:
/*!
* @brief Parses content of ZFO file.
*
* @param[in] filePath Path to file.
* @param[in] rawZfoData Raw ZFO data.
* @return Message description on success, empty string else.
*/
Q_INVOKABLE static
......@@ -172,7 +185,7 @@ public:
/*!
* @brief Parses content of ZFO file.
*
* @param[in] filePath Path to file.
* @param[in] rawZfoData Raw ZFO data.
* @return Email containing message on success, empty string else.
*/
Q_INVOKABLE static
......@@ -182,7 +195,7 @@ public:
* @brief Sets attachment model.
*
* @param[out] attachModel Attachment model to be set.
* @param[in] filePath File path with file name.
* @param[in] rawZfoData Raw ZFO data.
* @return true if success.
*/
static
......@@ -269,16 +282,18 @@ private:
* @todo This function must be reworked as it is called multiple times
* on a single message to obtain various data.
*
* @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] data Xml file data.
* @param[in] xmlData Xml file data.
* @return true if success.
*/
static
bool parseXmlData(QString *annotation, QString *msgDescrHtml,
FileListModel *attachModel, QString *emailBody, QByteArray data);
bool parseXmlData(QString *idStr, QString *annotation,
QString *msgDescrHtml, FileListModel *attachModel,
QString *emailBody, QByteArray xmlData);
};
#endif // FILES_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