Commit 6a410c62 authored by Martin Straka's avatar Martin Straka
Browse files

Isds actions based on asynchronous qml input dialogue

parent 6c3e7848
...@@ -34,21 +34,26 @@ import QtQuick.Controls 2.1 ...@@ -34,21 +34,26 @@ import QtQuick.Controls 2.1
Dialog { Dialog {
id: root id: root
signal finished(string userName,string accountName, string pwd) signal finished(string isdsAction, string pwdType, string userName, string pwd)
property int minimumInputSize: parent.width / 2 property int minimumInputSize: parent.width / 2
property int maximumInputSize: parent.width / 2 property int maximumInputSize: parent.width / 2
property string dIsdsAction
property string dPwdType
property string dUserName property string dUserName
property string dAccountName
function openInputDialog(userName, accountName, title, text, hidePwd) { function openInputDialog(isdsAction, pwdType, userName, title, text, placeholderText, hidePwd) {
dIsdsAction = isdsAction
dPwdType = pwdType
dUserName = userName dUserName = userName
dAccountName = accountName
root.title = title root.title = title
roottext.text = text roottext.text = text
rootpwd.clear() rootpwd.clear()
rootpwd.placeholderText = title rootpwd.placeholderText = placeholderText
rootpwd.echoMode = (hidePwd) ? TextInput.Password : TextInput.Normal rootpwd.echoMode = (hidePwd) ? TextInput.Password : TextInput.Normal
if (pwdType == "totp" || pwdType == "hotp") {
rootpwd.inputMethodHints = Qt.ImhDigitsOnly
}
root.open() root.open()
} }
...@@ -84,5 +89,5 @@ Dialog { ...@@ -84,5 +89,5 @@ Dialog {
} }
} // ColumnLayout } // ColumnLayout
onAccepted: finished(dUserName, dAccountName, rootpwd.text.toString()) onAccepted: finished(dIsdsAction, dPwdType, dUserName, rootpwd.text.toString())
} }
...@@ -115,12 +115,12 @@ ApplicationWindow { ...@@ -115,12 +115,12 @@ ApplicationWindow {
InputDialogue { InputDialogue {
id: inputDialog id: inputDialog
onFinished: { onFinished: {
isds.returnInputDialogText(userName, accountName, pwd) isds.returnInputDialogText(isdsAction, pwdType, userName, pwd)
} }
Connections { Connections {
target: isds target: isds
onOpenDialogRequest: { onOpenDialogRequest: {
inputDialog.openInputDialog(userName, accountName, title, text, hidePwd) inputDialog.openInputDialog(isdsAction, pwdType, userName, title, text, placeholderText, hidePwd)
} }
} }
} }
......
...@@ -66,7 +66,13 @@ Component { ...@@ -66,7 +66,13 @@ Component {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
isds.getAccountInfo(userName, false) isds.doIsdsAction("getAccountInfo", userName)
}
}
Connections {
target: isds
onRunGetAccountInfoSig: {
isds.getAccountInfo(userName)
} }
} }
} }
......
...@@ -110,7 +110,7 @@ Component { ...@@ -110,7 +110,7 @@ Component {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
statusBarText.text = "" statusBarText.text = ""
isds.syncAllAccounts(accountModel) isds.doIsdsAction("syncAllAccounts", "")
} }
} }
} }
...@@ -260,7 +260,15 @@ Component { ...@@ -260,7 +260,15 @@ Component {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
isds.syncOneAccount(accountModel, rUserName) isds.doIsdsAction("syncOneAccount", rUserName)
}
}
Connections {
target: isds
onRunSyncOneAccountSig: {
if (rUserName == userName) {
isds.syncOneAccount(accountModel, userName)
}
} }
} }
} }
......
...@@ -160,7 +160,7 @@ Component { ...@@ -160,7 +160,7 @@ Component {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (index == 0) { if (index == 0) {
isds.downloadMessage(messageModel, userName, msgType, msgId) isds.doIsdsAction("downloadMessage", userName)
} else if (index == 1) { } else if (index == 1) {
messages.markMessageAsLocallyRead(messageModel, userName, msgId, true) messages.markMessageAsLocallyRead(messageModel, userName, msgId, true)
} else if (index == 2) { } else if (index == 2) {
...@@ -186,5 +186,11 @@ Component { ...@@ -186,5 +186,11 @@ Component {
delegate: messageMenuComponent delegate: messageMenuComponent
} }
} }
Connections {
target: isds
onRunDownloadMessageSig: {
isds.downloadMessage(messageModel, userName, msgType, msgId)
}
}
} }
} }
...@@ -151,7 +151,7 @@ Component { ...@@ -151,7 +151,7 @@ Component {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (index == 0) { if (index == 0) {
isds.downloadMessage(messageModel, userName, msgType, msgId) isds.doIsdsAction("downloadMessage", userName)
} else if (index == 1) { } else if (index == 1) {
files.sendAttachmentsWithEmailFromDb(userName, msgId) files.sendAttachmentsWithEmailFromDb(userName, msgId)
} else if (index == 2) { } else if (index == 2) {
......
...@@ -201,7 +201,7 @@ Component { ...@@ -201,7 +201,7 @@ Component {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (fromLocalDb) { if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId) isds.doIsdsAction("downloadMessage", userName)
} }
} }
} }
...@@ -394,7 +394,7 @@ Component { ...@@ -394,7 +394,7 @@ Component {
if (downloadStart) { if (downloadStart) {
downloadStart = false downloadStart = false
if (fromLocalDb) { if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId) isds.doIsdsAction("downloadMessage", userName)
} }
} }
} }
...@@ -416,7 +416,7 @@ Component { ...@@ -416,7 +416,7 @@ Component {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
if (fromLocalDb) { if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId) isds.doIsdsAction("downloadMessage", userName)
} }
} }
} }
...@@ -433,5 +433,13 @@ Component { ...@@ -433,5 +433,13 @@ Component {
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: "" text: ""
} // Text } // Text
Connections {
target: isds
onRunDownloadMessageSig: {
if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId)
}
}
}
} }
} }
...@@ -215,9 +215,9 @@ Component { ...@@ -215,9 +215,9 @@ Component {
if (downloadStart) { if (downloadStart) {
downloadStart = false downloadStart = false
if (msgType == MessageType.TYPE_RECEIVED) { if (msgType == MessageType.TYPE_RECEIVED) {
isds.syncSingleAccountReceived(accountModel, messageModel, userName) isds.doIsdsAction("syncSingleAccountReceived", userName)
} else if (msgType == MessageType.TYPE_SENT) { } else if (msgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(accountModel, messageModel, userName) isds.doIsdsAction("syncSingleAccountSent", userName)
} }
} }
} }
...@@ -234,6 +234,18 @@ Component { ...@@ -234,6 +234,18 @@ Component {
messages.fillMessageList(messageModel, userName, msgType) messages.fillMessageList(messageModel, userName, msgType)
} }
} }
Connections {
target: isds
onRunSyncSingleAccountReceivedSig: {
isds.syncSingleAccountReceived(accountModel, messageModel, userName)
}
}
Connections {
target: isds
onRunSyncSingleAccountSentSig: {
isds.syncSingleAccountSent(accountModel, messageModel, userName)
}
}
} }
} }
} }
...@@ -78,7 +78,8 @@ Item { ...@@ -78,7 +78,8 @@ Item {
passwordTextField.text.toString(), passwordTextField.text.toString(),
testAccount.checked, rememberPassword.checked, testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString())) { useLS.checked, certPathLabelId.text.toString())) {
isds.getAccountInfo(userNameTextField.text.toString(), true) /* TODO - remove the function or make it asynchronous */
isds.getAccountInfo(userNameTextField.text.toString())
} }
} else { } else {
if (accounts.updateAccount(accountModel, sLoginMethod, if (accounts.updateAccount(accountModel, sLoginMethod,
......
...@@ -84,6 +84,11 @@ ...@@ -84,6 +84,11 @@
#define OTP_TYPE_HOTP "HOTP" #define OTP_TYPE_HOTP "HOTP"
#define OTP_NO_OTP "noOTP" #define OTP_NO_OTP "noOTP"
/* PASSWORD TYPE */
#define PWD_PWD "pwd"
#define PWD_CERT "cert"
#define PWD_HOTP "hotp"
#define PWD_TOTP "totp"
/*! /*!
* @brief Maximum length of message list to be downloaded. * @brief Maximum length of message list to be downloaded.
......
This diff is collapsed.
...@@ -47,104 +47,109 @@ public: ...@@ -47,104 +47,109 @@ public:
~IsdsWrapper(void); ~IsdsWrapper(void);
/*! /*!
* @brief Download message list of all accounts. * @brief Change ISDS login password.
* *
* @param[in,out] acntModelVariant QVariant holding account model * @param[in] userName Account username string.
* to be altered. * @param[in] accountName Account name.
*/ */
Q_INVOKABLE Q_INVOKABLE
void syncAllAccounts(const QVariant &acntModelVariant); bool changePassword(const QString &userName,
const QString &accountName);
/*! /*!
* @brief Download message list of one account. * @brief Do an isds action from QML.
* *
* @param[in,out] acntModelVariant QVariant holding account model * @param[in] isdsAction Isds action identificator.
* to be altered. * @param[in] userName Account user name.
* @param[in] userName Account username string.
*/ */
Q_INVOKABLE Q_INVOKABLE
void syncOneAccount(const QVariant &acntModelVariant, void doIsdsAction(const QString &isdsAction, const QString &userName);
const QString &userName);
/*! /*!
* @brief Download received message list. * @brief Downloads complete message.
* *
* @param[in,out] acntModelVariant QVariant holding account model
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model * @param[in,out] msgModelVariant QVariant holding message model
* to be altered. * to be altered.
* @param[in] userName Account username string. * @param[in] userName Account username string.
* @param[in] messageType Message orientation.
* @param[in] msgId Message ID.
*/ */
Q_INVOKABLE Q_INVOKABLE
void syncSingleAccountReceived(const QVariant &acntModelVariant, void downloadMessage(const QVariant &msgModelVariant,
const QVariant &msgModelVariant, const QString &userName); const QString &userName, enum Messages::MessageType messageType,
qint64 msgId);
/*! /*!
* @brief Download list of sent messages. * @brief Download account info.
* *
* @param[in,out] acntModelVariant QVariant holding account model * @param[in] userName Account username string.
* to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
*/ */
Q_INVOKABLE Q_INVOKABLE
void syncSingleAccountSent(const QVariant &acntModelVariant, void getAccountInfo(const QString &userName);
const QVariant &msgModelVariant, const QString &userName);
/*! /*!
* @brief Download account info. * @brief Downloads delivery info.
* *
* @param[in] userName Account username string. * @param[in] userName Account username string.
* @param[in] isFirstLogin Set on True if it is first login * @param[in] msgId Message ID.
* into databox (when add account to Datovka).
*/ */
Q_INVOKABLE Q_INVOKABLE
void getAccountInfo(const QString &userName, bool isFirstLogin); void getDeliveryInfo(const QString &userName, qint64 msgId);
/*! /*!
* @brief Downloads complete message. * @brief Password string from QML input dialog.
* *
* @param[in,out] msgModelVariant QVariant holding message model * @param[in] isdsAction ISDS Action string.
* to be altered. * @param[in] pwdType Password type string.
* @param[in] userName Account username string. * @param[in] userName Account username string.
* @param[in] messageType Message orientation. * @param[in] accountName Account name string.
* @param[in] msgId Message ID. * @param[in] pwd Password or OTP code.
*/ */
Q_INVOKABLE Q_INVOKABLE
void downloadMessage(const QVariant &msgModelVariant, void returnInputDialogText(const QString &isdsAction,
const QString &userName, enum Messages::MessageType messageType, const QString &pwdType, const QString &userName, const QString &pwd);
qint64 msgId);
/*! /*!
* @brief Downloads delivery info. * @brief Download message list of one account.
* *
* @param[in] userName Account username string. * @param[in,out] acntModelVariant QVariant holding account model
* @param[in] msgId Message ID. * to be altered.
* @param[in] userName Account username string.
*/ */
Q_INVOKABLE Q_INVOKABLE
void getDeliveryInfo(const QString &userName, qint64 msgId); void syncOneAccount(const QVariant &acntModelVariant,
const QString &userName);
/*! /*!
* @brief Change ISDS login password. * @brief Download received message list.
* *
* @param[in] userName Account username string. * @param[in,out] acntModelVariant QVariant holding account model
* @param[in] accountName Account name. * to be altered.
* @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
*/ */
Q_INVOKABLE Q_INVOKABLE
bool changePassword(const QString &userName, void syncSingleAccountReceived(const QVariant &acntModelVariant,
const QString &accountName); const QVariant &msgModelVariant, const QString &userName);
/*! /*!
* @brief Password string from QML input dialog. * @brief Download list of sent messages.
* *
* @param[in] userName Account username string. * @param[in,out] acntModelVariant QVariant holding account model
* @param[in] accountName Account name string. * to be altered.
* @param[in] pwd Password or OTP code. * @param[in,out] msgModelVariant QVariant holding message model
* to be altered.
* @param[in] userName Account username string.
*/ */
Q_INVOKABLE Q_INVOKABLE
void returnInputDialogText(const QString &userName, void syncSingleAccountSent(const QVariant &acntModelVariant,
const QString &accountName, const QString &pwd); const QVariant &msgModelVariant, const QString &userName);
/*!
* @brief Logout and close all active OTP connections, clear cookies.
*/
void closeAllOtpConnections(void);
/*! /*!
* @brief Test if user is connected to databox via OTP. * @brief Test if user is connected to databox via OTP.
...@@ -162,24 +167,22 @@ public: ...@@ -162,24 +167,22 @@ public:
*/ */
bool isdsLogoutOTP(const QString &userName); bool isdsLogoutOTP(const QString &userName);
/*!
* @brief Logout and close all active OTP connections, clear cookies.
*/
void closeAllOtpConnections(void);
signals: signals:
/*! /*!
* @brief Send open QML input dialog request to QML. * @brief Send open QML input dialog request to QML.
* *
* @param[in] isdsAction ISDS Action string.
* @param[in] pwdType Password type string.
* @param[in] userName Account username string. * @param[in] userName Account username string.
* @param[in] accountName Account name string.
* @param[in] title Dialogue title. * @param[in] title Dialogue title.
* @param[in] text Dialogue text. * @param[in] text Dialogue text.
* @param[in] placeholderText Dialogue placeholder text.
* @param[in] hidePwd True means the password will be hidden. * @param[in] hidePwd True means the password will be hidden.
*/ */
void openDialogRequest(QString userName, QString accountName, void openDialogRequest(const QString &isdsAction,
QString title, QString text, bool hidePwd); const QString &pwdType, QString userName, QString title,
QString text, QString placeholderText, bool hidePwd);
/*! /*!
* @brief Set new statusbar text and active busy indicator to QML. * @brief Set new statusbar text and active busy indicator to QML.
...@@ -212,6 +215,55 @@ signals: ...@@ -212,6 +215,55 @@ signals:
*/ */
void downloadAccountInfoFinishedSig(QString userName, bool isLogged); void downloadAccountInfoFinishedSig(QString userName, bool isLogged);
/*!
* @brief Run change password isds action from QML.
*
* @param[in] userName Account user name string.
*/
void runChangePasswordSig(QString userName);
/*!
* @brief Run download mesasge isds action from QML.
*
* @param[in] userName Account user name string.
*/
void runDownloadMessageSig(QString userName);
/*!
* @brief Run download account info action from QML.
*
* @param[in] userName Account user name string.
*/
void runGetAccountInfoSig(QString userName);
/*!
* @brief Run sync all accounts action from QML.
*
* @param[in] userName Account user name string.
*/
void runSyncAllAccountsSig(QString userName);
/*!
* @brief Run sync one account action from QML.
*
* @param[in] userName Account user name string.
*/
void runSyncOneAccountSig(QString userName);
/*!
* @brief Run sync received message list action from QML.
*
* @param[in] userName Account user name string.
*/
void runSyncSingleAccountReceivedSig(QString userName);
/*!
* @brief Run sync sent message list action from QML.
*
* @param[in] userName Account user name string.
*/
void runSyncSingleAccountSentSig(QString userName);
public slots: public slots:
/*! /*!
...@@ -270,17 +322,12 @@ public slots: ...@@ -270,17 +322,12 @@ public slots:
private: private:
/*! /*!
* @brief Download received or sent message list of one account. * @brief Do login action.
* *