Commit 88f44130 authored by Martin Straka's avatar Martin Straka

Added support for PDZ

parent 9f7bad34
......@@ -43,6 +43,7 @@ Item {
/* This property defines mandate textinput width. */
property int mandateFieldLenght : defaultTextFont.font.pointSize * 4
property string dmType: ""
/* Return file name from file path */
function getFileNameFromPath(filePath) {
......@@ -75,6 +76,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 +119,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 +237,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 +322,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,22 @@ 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("Send error"), tr("Message has set pay transfer charges for reply."),
tr("For sending, the sender reference number must be filled in the additional section."));
return;
}
/* Mesasge is PDZ reply, dmRecipientRefNumber must be filled */
if (dmType == "O" && dmRecipientRefNumber.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Send error"), tr("Message has set use offered payment of transfer charges by recipient."),
tr("For sending, the recipient reference number must be filled in the additional section."));
return;
}
MsgEnvelope msg;
/* Fill message envelope */
msg.setDmAnnotation(dmAnnotation);
......@@ -499,6 +515,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();
xml.readNext();;
}
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);
......
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