Commit d95dd0bf authored by Martin Straka's avatar Martin Straka

Added support for FindDataboxIsds service and databox info search

parent 1deb4c09
......@@ -129,6 +129,7 @@ SOURCES += \
src/worker/task_download_message.cpp \
src/worker/task_download_message_list.cpp \
src/worker/task_find_databox.cpp \
src/worker/task_find_databox_isds.cpp \
src/worker/task_keep_alive.cpp \
src/worker/task_send_sms.cpp
......@@ -180,6 +181,7 @@ HEADERS += \
src/worker/task_download_message.h \
src/worker/task_download_message_list.h \
src/worker/task_find_databox.h \
src/worker/task_find_databox_isds.h \
src/worker/task_keep_alive.h \
src/worker/task_send_sms.h
......
......@@ -62,6 +62,7 @@ ApplicationWindow {
property Component pageAboutApp: PageAboutApp {}
property Component pageAccountDetail: PageAccountDetail {}
property Component pageChangePassword: PageChangePassword {}
property Component pageDataboxDetail: PageDataboxDetail {}
property Component pageDataboxSearch: PageDataboxSearch {}
property Component pageMenuAccount: PageMenuAccount {}
property Component pageMenuDatovkaSettings: PageMenuDatovkaSettings {}
......
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.1
import cz.nic.mobileDatovka 1.0
Component {
id: pageDataboxDetail
Item {
id: dbDetailPage
/* These properties must be set by caller. */
property var pageView
property var statusBar
property string userName
property string dbID
property string dbType
Component.onCompleted: {
isds.doIsdsAction("findDataboxIsds", userName)
}
Connections {
target: isds
onRunFindDataboxIsdsSig: {
databoxDetailText.text = isds.findDataboxIsds(userName, dbID, dbType)
}
}
PageHeader {
id: headerBar
title: qsTr("Databox info") + " (" + dbID + ")"
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
MouseArea {
anchors.fill: parent
onClicked: {
pageView.pop(StackView.Immediate)
}
}
}
} // PageHeader
Flickable {
id: flickable
z: 0
anchors.top: headerBar.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
contentHeight: flickContent.implicitHeight
Pane {
id: flickContent
anchors.fill: parent
Text {
id: databoxDetailText
color: datovkaPalette.text
width: parent.width
textFormat: TextEdit.RichText
wrapMode: Text.WordWrap
}
} // Pane
ScrollIndicator.vertical: ScrollIndicator {}
} // Flickable
}
}
......@@ -245,6 +245,13 @@ Item {
statusBar.visible = false
/* TODO - insert databox to send page in the future */
console.log(dbID + " " + dbName + " " + dbAddress + " " + dbEffectiveOvm)
pageView.push(pageDataboxDetail, {
"pageView": pageView,
"statusBar": statusBar,
"userName": userName,
"dbID": dbID,
"dbType": "OVM"
}, StackView.Immediate)
}
} // DataboxList
Connections {
......
......@@ -110,6 +110,7 @@
<file>../qml/pages/PageAccountDetail.qml</file>
<file>../qml/pages/PageAccountList.qml</file>
<file>../qml/pages/PageChangePassword.qml</file>
<file>../qml/pages/PageDataboxDetail.qml</file>
<file>../qml/pages/PageDataboxSearch.qml</file>
<file>../qml/pages/PageMenuAccount.qml</file>
<file>../qml/pages/PageMenuDatovkaSettings.qml</file>
......
......@@ -83,6 +83,7 @@ const struct QmlTypeEntry qmlPages[] = {
{ "PageAccountDetail", 1, 0 },
{ "PageAccountList", 1, 0 },
{ "PageChangePassword", 1, 0 },
{ "PageDataboxDetail", 1, 0 },
{ "PageDataboxSearch", 1, 0 },
{ "PageMenuAccount", 1, 0 },
{ "PageMenuDatovkaSettings", 1, 0 },
......
......@@ -37,6 +37,7 @@
#include "src/worker/task_download_message.h"
#include "src/worker/task_download_message_list.h"
#include "src/worker/task_find_databox.h"
#include "src/worker/task_find_databox_isds.h"
#include "src/worker/task_keep_alive.h"
#include "src/worker/task_send_sms.h"
......@@ -177,6 +178,8 @@ void IsdsWrapper::doIsdsAction(const QString &isdsAction,
emit runSyncSingleAccountSentSig(userName);
} else if (isdsAction == "findDatabox") {
emit runFindDataboxSig(userName);
} else if (isdsAction == "findDataboxIsds") {
emit runFindDataboxIsdsSig(userName);
}
} else {
doLoginAction(isdsAction, userName);
......@@ -284,6 +287,31 @@ int IsdsWrapper::findDatabox(const QString &userName,
return databoxModel->rowCount();
}
QString IsdsWrapper::findDataboxIsds(const QString &userName,
const QString &dbID, const QString &dbType)
{
qDebug("%s()", __func__);
if (userName.isEmpty() || dbID.isEmpty()) {
return tr("Error to get databox info from ISDS");
}
/* User must be logged to isds */
if (!isLoggedToIsds(userName)) {
return tr("Error to get databox info from ISDS");
}
TaskFindDataboxIsds *task;
task = new (std::nothrow) TaskFindDataboxIsds(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, dbID, dbType);
task->setAutoDelete(false);
m_workPool.runSingle(task);
QString dbInfo = task->m_dbInfo;
delete task;
return dbInfo;
}
void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
{
qDebug("%s()", __func__);
......
......@@ -98,6 +98,18 @@ public:
const QString &phrase, const QString &searchType,
const QString &searchScope, int page);
/*!
* @brief Find databox info.
*
* @param[in] userName Account username string.
* @param[in] dbID Databox ID.
* @param[in] dbType Databox Type.
* @return Databox detail info string.
*/
Q_INVOKABLE
QString findDataboxIsds(const QString &userName, const QString &dbID,
const QString &dbType);
/*!
* @brief Download account info.
*
......@@ -285,6 +297,13 @@ signals:
*/
void runFindDataboxSig(QString userName);
/*!
* @brief Run find databox isds action from QML.
*
* @param[in] userName Account user name string.
*/
void runFindDataboxIsdsSig(QString userName);
/*!
* @brief Run download account info action from QML.
*
......
......@@ -100,6 +100,28 @@ QByteArray XmlLayer::xmlCreateDownloadMessageSoapRequest(qint64 msgId,
return xmlCreateSoapEnvelope(xmlContent);
}
QByteArray XmlLayer::xmlCreateFindDataBoxSoapRequest(const QString &dbID,
const QString &dbType)
{
QString xmlContent("<FindDataBox xmlns=\"");
xmlContent.append(ISDS_NS);
xmlContent.append("\"><dbOwnerInfo><dbID>");
xmlContent.append(dbID);
xmlContent.append("</dbID><dbType>");
xmlContent.append(dbType);
xmlContent.append("</dbType>");
xmlContent.append("<ic/><pnFirstName/><pnMiddleName/><pnLastName/>");
xmlContent.append("<pnLastNameAtBirth/><firmName/><adCity/><adStreet/>");
xmlContent.append("<adNumberInStreet/><adNumberInMunicipality/>");
xmlContent.append("<adZipCode/><adState/><nationality/><email/>");
xmlContent.append("<telNumber/><identifier/><registryCode/>");
xmlContent.append("<dbState>0</dbState>");
xmlContent.append("<dbEffectiveOVM>false</dbEffectiveOVM>");
xmlContent.append("<dbOpenAddressing>false</dbOpenAddressing>");
xmlContent.append("</dbOwnerInfo></FindDataBox>");
return xmlCreateSoapEnvelope(xmlContent);
}
QByteArray XmlLayer::xmlCreateGetMessageAuthorSoapRequest(qint64 msgId)
{
QString xmlContent("<GetMessageAuthor xmlns=\"");
......@@ -1389,3 +1411,52 @@ Files::File XmlLayer::parseFile(QXmlStreamReader &xml,
}
return file;
}
bool XmlLayer::parseFindDataBoxSoapResponse(const QByteArray &xmlData,
QString &dbInfo, QString &txt)
{
qDebug("%s()", __func__);
bool ret = false;
DbWrapper::AccountInfo accountInfo;
ret = XmlLayer::parseGetOwnerInfoFromLogin(xmlData, accountInfo, txt);
dbInfo.append(divStart);
if (!ret) {
dbInfo.append(strongInfoLine(tr("ISDS says"), txt));
dbInfo.append(divEnd);
return ret;
}
dbInfo.append(strongInfoLine(tr("Data box ID"), accountInfo.dbID));
dbInfo.append(strongInfoLine(tr("Data box type"), accountInfo.dbType));
dbInfo.append(strongInfoLine(tr("IČ"), accountInfo.ic));
dbInfo.append(strongInfoLine(tr("Given name"), accountInfo.pnFirstName));
dbInfo.append(strongInfoLine(tr("Middle name"), accountInfo.pnMiddleName));
dbInfo.append(strongInfoLine(tr("Surname"), accountInfo.pnLastName));
dbInfo.append(strongInfoLine(tr("Surname at birth"), accountInfo.pnLastNameAtBirth));
dbInfo.append(strongInfoLine(tr("Date of birth"), accountInfo.biDate));
dbInfo.append(strongInfoLine(tr("City of birth"), accountInfo.biCity));
dbInfo.append(strongInfoLine(tr("County of birth"), accountInfo.biCounty));
dbInfo.append(strongInfoLine(tr("State of birth"), accountInfo.biState));
dbInfo.append(strongInfoLine(tr("Company name"), accountInfo.firmName));
dbInfo.append(strongInfoLine(tr("City of residence"), accountInfo.adCity));
dbInfo.append(strongInfoLine(tr("Street of residence"), accountInfo.adStreet));
dbInfo.append(strongInfoLine(tr("Number in street"), accountInfo.adNumberInStreet));
dbInfo.append(strongInfoLine(tr("Number in municipality"), accountInfo.adNumberInMunicipality));
dbInfo.append(strongInfoLine(tr("Zip code"), accountInfo.adZipCode));
dbInfo.append(strongInfoLine(tr("State of residence"), accountInfo.adState));
dbInfo.append(strongInfoLine(tr("Nationality"), accountInfo.nationality));
dbInfo.append(strongInfoLine(tr("Databox state"), QString::number(accountInfo.dbState)));
dbInfo.append(strongInfoLine(tr("Effective OVM"), (accountInfo.dbEffectiveOVM) ? tr("Yes") : tr("No")));
dbInfo.append(strongInfoLine(tr("Open addressing"), (accountInfo.dbOpenAddressing) ? tr("Yes") : tr("No")));
dbInfo.append(divEnd);
return ret;
}
......@@ -72,6 +72,17 @@ public:
QByteArray xmlCreateDownloadMessageSoapRequest(qint64 msgId,
enum Messages::MessageType msgDirect);
/*!
* @brief Create find databox info soap request.
*
* @param[in] dbID Databox ID.
* @param[in] dbType Databox type.
* @return Soap request string as byte array.
*/
static
QByteArray xmlCreateFindDataBoxSoapRequest(const QString &dbID,
const QString &dbType);
/*!
* @brief Create get message author soap request.
*
......@@ -411,6 +422,18 @@ public:
static
Files::File parseFile(QXmlStreamReader &xml, const qint64 msgId,
const QString &downloadDate);
/*!
* @brief Parse find databox info xml data.
*
* @param[in] xmlData Xml Data for parsing.
* @param[out] dbInfo Databox info.
* @param[out] txt Error description if something failed.
* @return true if success.
*/
static
bool parseFindDataBoxSoapResponse(const QByteArray &xmlData,
QString &dbInfo, QString &txt);
};
#endif /* _XML_LAYER_H_ */
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#include "src/log/log.h"
#include "src/net/isds_const.h"
#include "src/net/xml_layer.h"
#include "src/worker/pool.h"
#include "src/worker/task_find_databox_isds.h"
TaskFindDataboxIsds::TaskFindDataboxIsds(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, const QString &dbID, const QString &dbType)
: m_result(DL_ERR),
m_dbInfo(),
m_lastError(),
m_ctx(ctx),
m_netLayer(netLayer),
m_dbID(dbID),
m_dbType(dbType)
{
}
void TaskFindDataboxIsds::run(void)
{
if (Q_NULLPTR == m_netLayer) {
Q_ASSERT(0);
return;
}
logDebugLv0NL("Starting find databox info task in thread '%p'",
(void *) QThread::currentThreadId());
/* ### Worker task begin. ### */
logDebugLv1NL("%s", "-----------------------------------------------");
logDebugLv1NL("Finding databox info from account '%s'.",
m_ctx.account_name.toUtf8().constData());
logDebugLv1NL("%s", "-----------------------------------------------");
m_result = findDatabox(m_ctx, m_netLayer, m_dbID, m_dbType,
m_dbInfo, m_lastError);
/* ### Worker task end. ### */
logDebugLv0NL("Finding databox info task finished in thread '%p'",
(void *) QThread::currentThreadId());
}
enum TaskFindDataboxIsds::Result TaskFindDataboxIsds::findDatabox(
IsdsSession::IsdsContext &ctx, NetLayer *netLayer, const QString &dbID,
const QString &dbType, QString &dbInfo, QString &lastError)
{
QByteArray xmlDataOut;
if (ctx.username.isEmpty()) {
Q_ASSERT(0);
lastError = QObject::tr("Internal error");
return DL_ERR;
}
/* Send SOAP request to find databox */
if (!netLayer->sendSoapRequest(ctx, FIND_SERVICE,
XmlLayer::xmlCreateFindDataBoxSoapRequest(dbID, dbType),
xmlDataOut)) {
lastError = ctx.last_isds_msg;
return DL_ISDS_ERROR;
}
/* Parse databoxes from response */
if (!XmlLayer::parseFindDataBoxSoapResponse(xmlDataOut, dbInfo,
ctx.last_isds_msg)) {
lastError = ctx.last_isds_msg;
return DL_XML_ERROR;
}
return DL_SUCCESS;
}
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#ifndef _TASK_FIND_DATABOX_ISDS_H_
#define _TASK_FIND_DATABOX_ISDS_H_
#include "src/net/isds_session.h"
#include "src/net/net_layer.h"
#include "src/worker/task.h"
/*!
* @brief Task describing finding of databox info on isds portale.
*/
class TaskFindDataboxIsds : public Task {
public:
/*!
* @brief Return state describing what happened.
*/
enum Result {
DL_SUCCESS, /*!< Operation was successful. */
DL_ISDS_ERROR, /*!< Error communicating with ISDS. */
DL_XML_ERROR, /*!< Error xml parse. */
DL_DB_INS_ERR, /*!< Error inserting into database. */
DL_ERR /*!< Other error. */
};
/*!
* @brief Constructor.
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbID Search databox ID.
* @param[in] dbType Search databox type.
*/
explicit TaskFindDataboxIsds(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, const QString &dbID, const QString &dbType);
/*!
* @brief Performs actual find databox info.
*/
virtual
void run(void) Q_DECL_OVERRIDE;
/*!
* @brief Find databox.
*
* @param[in] ctx Account isds context (include username).
* @param[in] netLayer Pointer to network manager.
* @param[in] dbID Search databox ID.
* @param[in] dbType Search databox type.
* @param[out] dbInfo Databox detail info string.
* @param[out] lastError Last ISDS error message.
* @return Error state.
*/
static
enum Result findDatabox(IsdsSession::IsdsContext &ctx,
NetLayer *netLayer, const QString &dbID, const QString &dbType,
QString &dbInfo, QString &lastError);
enum Result m_result; /*!< Return state. */
QString m_dbInfo; /*!< Databox info string. */
QString m_lastError; /*!< Last ISDS error message. */
private:
/*!
* Disable copy and assignment.
*/
TaskFindDataboxIsds(const TaskFindDataboxIsds &);
TaskFindDataboxIsds &operator=(const TaskFindDataboxIsds &);
IsdsSession::IsdsContext m_ctx; /*!< Account isds context. */
NetLayer *m_netLayer; /*!< Pointer to network manager to send request. */
const QString m_dbID; /*!< Search databox ID. */
const QString m_dbType; /*!< Search databox type */
};
#endif /* _TASK_FIND_DATABOX_ISDS_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