Commit 61fea120 authored by Karel Slaný's avatar Karel Slaný

Merge branch 'reply-pdz' into 'develop'

Added support for PDZ

See merge request !84
parents 9f7bad34 2e25e4ab
......@@ -44,6 +44,9 @@ Item {
/* This property defines mandate textinput width. */
property int mandateFieldLenght : defaultTextFont.font.pointSize * 4
/* This property holds message type for sending. */
property string dmType: ""
/* Return file name from file path */
function getFileNameFromPath(filePath) {
return filePath.replace(/^.*[\\\/]/, '')
......@@ -75,6 +78,13 @@ Item {
dmSenderIdent.text = msgEnvelope.dmRecipientIdent
dmRecipientRefNumber.text = msgEnvelope.dmSenderRefNumber
dmRecipientIdent.text = msgEnvelope.dmSenderIdent
if (msgEnvelope.dmType === "I") {
replyPDZ.visible = true
dmType = "O"
} else {
replyPDZ.visible = false
dmType = ""
}
setMandate(msgEnvelope)
}
......@@ -111,19 +121,26 @@ Item {
}
Component.onCompleted: {
actionButton.enabled = false
initPDZ.visible = false
initPDZ.checked = false
replyPDZ.visible = false
replyPDZ.checked = true
var boxEffectiveOVM = accounts.boxEffectiveOVM(userName)
dmOVM.visible = boxEffectiveOVM
dmAllowSubstDelivery.visible = boxEffectiveOVM
if (action === "new") {
initPDZ.visible = !boxEffectiveOVM
headerBar.title = qsTr("Create message") + " (" + userName + ")"
} else if (action === "reply") {
setReplyData(userName, msgId)
} else if (action === "template") {
initPDZ.visible = !boxEffectiveOVM
setTemplateData(userName, msgId)
} else if (action == "fwdzfo") {
initPDZ.visible = !boxEffectiveOVM
setForwardZfoData(userName, msgId)
}
actionButton.enabled = false
var boxEffectiveOVM = accounts.boxEffectiveOVM(userName)
dmOVM.visible = boxEffectiveOVM
dmAllowSubstDelivery.visible = boxEffectiveOVM
}
/* File dialog for choose of files from the storage */
......@@ -222,8 +239,8 @@ Item {
dmLegalTitlePoint.text.toString(), dmToHands.text.toString(),
dmRecipientRefNumber.text.toString(), dmRecipientIdent.text.toString(),
dmSenderRefNumber.text.toString(), dmSenderIdent.text.toString(),
dmOVM.checked, dmPublishOwnID.checked,
dmAllowSubstDelivery.checked, dmPersonalDelivery.checked)
dmOVM.checked, dmPublishOwnID.checked, dmAllowSubstDelivery.checked,
dmPersonalDelivery.checked, dmType)
}
}
......@@ -307,16 +324,38 @@ Item {
}
Switch {
id: dmAllowSubstDelivery
visible: false
text: qsTr("Allow acceptance through fiction")
font.pointSize: defaultTextFont.font.pointSize
checked: true
}
Switch {
id: dmOVM
visible: false
text: qsTr("Send as OVM")
font.pointSize: defaultTextFont.font.pointSize
checked: true
}
Switch {
id: initPDZ
visible: false
text: qsTr("Pay transfer charges for reply")
font.pointSize: defaultTextFont.font.pointSize
checked: false
onClicked: {
(initPDZ.checked) ? dmType = "I" : dmType = ""
}
}
Switch {
id: replyPDZ
visible: false
text: qsTr("Use offered payment of transfer charges by recipient")
font.pointSize: defaultTextFont.font.pointSize
checked: true
onClicked: {
(replyPDZ.checked) ? dmType = "O" : dmType = ""
}
}
}
}
//----RECIPIENTS SECTION------------
......
......@@ -444,7 +444,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery)
bool dmPersonalDelivery, const QString &dmType)
{
qDebug("%s()", __func__);
......@@ -484,6 +484,24 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID,
return;
}
/* Mesasge is PDZ init, dmSenderRefNumber must be filled */
if (dmType == "I" && dmSenderRefNumber.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Pre-paid transfer charges for message reply have been enabled."),
tr("The sender reference number must be specified in the additional section in order to send the message."));
return;
}
/* Mesasge is PDZ reply, dmRecipientRefNumber must be filled */
if (dmType == "O" && dmRecipientRefNumber.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Message uses the offered payment of transfer charges by the recipient."),
tr("The recipient reference number must be specified in the additional section in order to send the message."));
return;
}
MsgEnvelope msg;
/* Fill message envelope */
msg.setDmAnnotation(dmAnnotation);
......@@ -499,6 +517,7 @@ void IsdsWrapper::sendMessage(const QString &userName, qint64 dmID,
msg.setDmSenderIdent(dmSenderIdent);
msg.setDmAllowSubstDelivery(dmAllowSubstDelivery);
msg.setDmPersonalDelivery(dmPersonalDelivery);
msg.setDmType(dmType);
int totalAttachmentSizeKBs = 0;
FileDb *fDb = NULL;
......
......@@ -190,6 +190,7 @@ public:
* @param[in] dmPublishOwnID True if add sender name to message.
* @param[in] dmAllowSubstDelivery True if allow acceptance by fiction.
* @param[in] dmPersonalDelivery True if personal delivery.
* @param[in] dmType Message type [K,V,I,O,...].
*/
Q_INVOKABLE
void sendMessage(const QString &userName, qint64 dmID,
......@@ -201,7 +202,7 @@ public:
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery);
bool dmPersonalDelivery, const QString &dmType);
/*!
* @brief Sent SMS request.
......
......@@ -229,7 +229,14 @@ QByteArray XmlLayer::xmlCreateSendMessageSoapRequest(const MsgEnvelope &msg,
QString xmlContent("<CreateMessage xmlns=\"");
xmlContent.append(ISDS_NS);
xmlContent.append("\">");
xmlContent.append("<dmEnvelope>");
if (msg.dmType().isEmpty()) {
xmlContent.append("<dmEnvelope>");
} else {
xmlContent.append("<dmEnvelope dmType=\"");
xmlContent.append(msg.dmType());
xmlContent.append("\">");
}
xmlContent.append("<dmSenderOrgUnit/><dmSenderOrgUnitNum/>");
xmlContent.append("<dbIDRecipient>");
xmlContent.append(msg.dbIDRecipient());
......@@ -308,7 +315,6 @@ QByteArray XmlLayer::xmlCreateSendMessageSoapRequest(const MsgEnvelope &msg,
xmlContent.append(msg.dmLegalTitlePoint());
xmlContent.append("</dmLegalTitlePoint>");
}
xmlContent.append("<dmPersonalDelivery>");
xmlContent.append((msg.dmPersonalDelivery())?"true":"false");
xmlContent.append("</dmPersonalDelivery>");
......@@ -381,6 +387,10 @@ bool XmlLayer::completeMessageParse(QXmlStreamReader &xml,
bool ret = true;
if (msg.dmType().isNull()) {
msg.setDmType("V");
}
while ((xml.tokenType() != QXmlStreamReader::StartElement)
&& (xml.name() != "dmDm")) {
return false;
......@@ -395,7 +405,6 @@ bool XmlLayer::completeMessageParse(QXmlStreamReader &xml,
if (xml.name() == "dmID") {
xml.readNext();
msg.setDmID(xml.text().toLongLong());
//qDebug() << msg.dmID;
} else
if (xml.name() == "dbIDSender") {
xml.readNext();
......@@ -776,8 +785,6 @@ bool XmlLayer::parseSignedMessageDownloadResponse(const QByteArray &xmlData,
while(!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
//qDebug() << token << xml.name() << xml.text()
// << xml.error() << xml.errorString();
if (xml.error() != QXmlStreamReader::NoError) {
return false;
}
......@@ -785,6 +792,13 @@ bool XmlLayer::parseSignedMessageDownloadResponse(const QByteArray &xmlData,
continue;
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmReturnedMessage") {
foreach (const QXmlStreamAttribute &attr, xml.attributes()) {
if (attr.name() == "dmType") {
msg.setDmType(attr.value().toString());
}
}
}
if (xml.name() == "dmDm") {
completeMessageParse(xml, msg, fileList);
}
......@@ -1304,19 +1318,23 @@ MsgEnvelope XmlLayer::msgEnvelopeParse(QXmlStreamReader &xml,
return msg;
}
foreach (const QXmlStreamAttribute &attr, xml.attributes()) {
if (attr.name() == "dmType") {
msg.setDmType(attr.value().toString());
}
}
xml.readNext();
while (!(xml.tokenType() == QXmlStreamReader::EndElement
&& xml.name() == "dmRecord")) {
if (xml.tokenType() == QXmlStreamReader::StartElement){
if (xml.tokenType() == QXmlStreamReader::StartElement) {
if (xml.name() == "dmOrdinal") {
xml.readNext();
//qDebug() << xml.text().toString();
}
if (xml.name() == "dmID") {
xml.readNext();
msg.setDmID(xml.text().toLongLong());
//qDebug() << msg.dmID;
} else
if (xml.name() == "dbIDSender") {
xml.readNext();
......@@ -1439,6 +1457,11 @@ MsgEnvelope XmlLayer::msgEnvelopeParse(QXmlStreamReader &xml,
}
xml.readNext();
}
if (msg.dmType().isNull()) {
msg.setDmType("V");
}
msg.setDmQTimestamp(QString());
msg._setDmMessageType(messageType);
msg._setDmReadLocally(false);
......
......@@ -49,6 +49,39 @@ const QVector<QString> MessageDb::msgStatus = {"dmDeliveryTime",
const QVector<QString> MessageDb::fileItemIds = {"id", "message_id",
"dmEncodedContent", "_dmFileDescr", "LENGTH(dmEncodedContent)"};
const QString dmTypeToText(const QString &val)
{
if (val.size() != 1) {
qCritical() << "Unknown message type value" << val.toUtf8().constData();
return QString();
}
switch (val[0].toLatin1()) {
case 'V':
return QObject::tr("Public data message");
break;
case 'K':
return QObject::tr("Postal data message");
break;
case 'I':
return QObject::tr("Initialising postal data message");
break;
case 'O':
return QObject::tr("Reply postal data message");
break;
case 'X':
return QObject::tr("Initialising postal data message - expired");
break;
case 'Y':
return QObject::tr("Initialising postal data message - used");
break;
default:
qCritical() << "Unknown message type value" << val[0].toLatin1();
return QObject::tr("Unknown message typ");
break;
}
}
const QString msgStatusToText(int status)
{
switch (status) {
......@@ -452,7 +485,7 @@ QString MessageDb::getMessageDetailDataFromDb(qint64 dmId) const
"dmAnnotation, dmAttachmentSize, "
"dbIDSender, dmSender, dmSenderAddress, _dmCustomData, "
"dbIDRecipient, dmRecipient, dmRecipientAddress, "
"dmPersonalDelivery, dmAllowSubstDelivery "
"dmPersonalDelivery, dmAllowSubstDelivery, dmType "
"FROM messages WHERE dmID = :dmID";
if (!query.prepare(queryStr)) {
goto fail;
......@@ -469,6 +502,10 @@ QString MessageDb::getMessageDetailDataFromDb(qint64 dmId) const
(query.value(10).toBool()) ? QObject::tr("Yes") : QObject::tr("No"));
html += strongInfoLine(QObject::tr("Delivery by fiction"),
(query.value(11).toBool()) ? QObject::tr("Yes") : QObject::tr("No"));
if (!query.value(12).toString().isEmpty()) {
html += strongInfoLine(QObject::tr("Message type"),
dmTypeToText(query.value(12).toString()));
}
if (query.value(0).toInt() == TYPE_RECEIVED) {
/* Information about message sender. */
......
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