Commit 79d114b1 authored by Karel Slaný's avatar Karel Slaný

Hid the widget-based implementation of WidgetMessageDialogue::message().

parent e95a26db
......@@ -83,7 +83,7 @@ TRANSLATIONS_FILES += \
SOURCES += \
src/accounts.cpp \
src/dialogues/input_dialogue.cpp \
src/dialogues/dialogues.cpp \
src/dialogues/qml_dialogue_helper.cpp \
src/dialogues/qml_input_dialogue.cpp \
src/dialogues/widget_input_dialogue.cpp \
......@@ -120,7 +120,7 @@ SOURCES += \
HEADERS += \
src/accounts.h \
src/common.h \
src/dialogues/input_dialogue.h \
src/dialogues/dialogues.h \
src/dialogues/qml_dialogue_helper.h \
src/dialogues/qml_input_dialogue.h \
src/dialogues/widget_input_dialogue.h \
......
......@@ -27,7 +27,7 @@
#include "src/accounts.h"
#include "src/common.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/net/isds_wrapper.h"
#include "src/net/isds_session.h"
#include "src/settings.h"
......@@ -110,13 +110,12 @@ bool Accounts::removeAccount(const QString &userName, bool showDialog)
qDebug("%s()", __func__);
if (showDialog) {
int msgResponse = WidgetMessageDialogue::message(
QMessageBox::Question,
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("Remove account: %1").arg(userName),
tr("Do you want to remove the account '%1'?").arg(userName),
tr("Note: It will also remove all related local databases and account information."),
QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (msgResponse == QMessageBox::No) {
Dialogues::NO | Dialogues::YES, Dialogues::NO);
if (msgResponse == Dialogues::NO) {
return false;
}
}
......@@ -187,7 +186,7 @@ void Accounts::updateAccount(const QString &loginMetod,
qDebug("%s()", __func__);
if (acntName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Problem while updating account"),
tr("Account name has not been specified!"),
tr("This field must be filled in."));
......@@ -270,7 +269,7 @@ bool Accounts::createAccount(const QString &loginMetod,
qDebug("%s()", __func__);
if (userName.isEmpty() || acntName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Problem while creating account"),
tr("User name or account name has not been specified!"),
tr("These fields must be filled in."));
......@@ -290,7 +289,7 @@ bool Accounts::createAccount(const QString &loginMetod,
acntData.setCertPath(url.toLocalFile());
if (globAccountsModelPtr->addAccount(acntData) == -2) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Creating account: %1").arg(userName),
tr("Account '%1' could not be created.").arg(acntName),
tr("Account with user name '%1' already exists.").arg(userName));
......
......@@ -25,9 +25,12 @@
#define USE_QML_DIALOGUES 1
#endif /* !defined(Q_OS_IOS) */
#include "src/dialogues/input_dialogue.h"
#include <QWindow>
#include "src/dialogues/dialogues.h"
#include "src/dialogues/qml_input_dialogue.h"
#include "src/dialogues/widget_input_dialogue.h"
#include "src/dialogues/widget_message_dialogue.h"
#if !defined(USE_QML_DIALOGUES)
/*!
......@@ -61,7 +64,126 @@ QLineEdit::EchoMode toLineEditEchoMode(
}
#endif /* !defined(USE_QML_DIALOGUES) */
QString InputDialogue::getText(QObject *parent, const QString &title,
/*!
* @brief Converts dialogue icon from helper class definition.
*
* @param[in] icon Icon as used in Dialogues.
* @return Icon as used in WidgetMessageDialogue.
*/
static
enum QMessageBox::Icon toMessageBoxIcon(enum Dialogues::Icon icon)
{
switch (icon) {
case Dialogues::NO_ICON:
return QMessageBox::NoIcon;
break;
case Dialogues::QUESTION:
return QMessageBox::Question;
break;
case Dialogues::INFORMATION:
return QMessageBox::Information;
break;
case Dialogues::WARNING:
return QMessageBox::Warning;
break;
case Dialogues::CRITICAL:
return QMessageBox::Critical;
break;
default:
Q_ASSERT(0);
return QMessageBox::NoIcon;
break;
}
}
/*!
* @brief Converts dialogue button from helper class definition.
*
* @param[in] button Button as used in Dialogues.
* @return Button as used in WidgetMessageDialogue.
*/
static
enum QMessageBox::StandardButton toMessageBoxButton(
enum Dialogues::Button button)
{
switch (button) {
case Dialogues::OK:
return QMessageBox::Ok;
break;
case Dialogues::CANCEL:
return QMessageBox::Cancel;
break;
case Dialogues::YES:
return QMessageBox::Yes;
break;
case Dialogues::NO:
return QMessageBox::No;
break;
case Dialogues::NO_BUTTON:
return QMessageBox::NoButton;
break;
default:
Q_ASSERT(0);
return QMessageBox::NoButton;
break;
}
}
/*!
* @brief Concerts return value from message dialogue.
*
* @param[in] retVal Return value as returned by message dialogue.
* @return Converted value.
*/
static
int toDialogueRetVal(int retVal)
{
switch (retVal) {
case -1:
return -1;
break;
case QMessageBox::Ok:
return Dialogues::OK;
break;
case QMessageBox::Cancel:
return Dialogues::CANCEL;
break;
case QMessageBox::Yes:
return Dialogues::YES;
break;
case QMessageBox::No:
return Dialogues::NO;
break;
case QMessageBox::NoButton:
return Dialogues::NO_BUTTON;
break;
default:
Q_ASSERT(0);
return retVal;
break;
}
}
/*!
* @brief Converts dialogue button from helper class definition.
*
* @param[in] button Button as used in Dialogues.
* @return Button as used in WidgetMessageDialogue.
*/
static
QMessageBox::StandardButtons toMessageBoxButtons(Dialogues::Buttons buttons)
{
QMessageBox::StandardButtons outButtons = QMessageBox::NoButton;
outButtons |= (buttons & Dialogues::OK) ? QMessageBox::Ok : QMessageBox::NoButton;
outButtons |= (buttons & Dialogues::CANCEL) ? QMessageBox::Cancel : QMessageBox::NoButton;
outButtons |= (buttons & Dialogues::YES) ? QMessageBox::Yes : QMessageBox::NoButton;
outButtons |= (buttons & Dialogues::NO) ? QMessageBox::No : QMessageBox::NoButton;
return outButtons;
}
QString Dialogues::getText(QObject *parent, const QString &title,
const QString &message, enum QmlDlgHelper::QmlDlgEchoMode echoMode,
const QString &text, const QString &placeholderText, bool *ok,
Qt::InputMethodHints inputMethodHints)
......@@ -77,3 +199,21 @@ QString InputDialogue::getText(QObject *parent, const QString &title,
Qt::Dialog, inputMethodHints);
#endif /* defined(USE_QML_DIALOGUES) */
}
int Dialogues::message(enum Icon icon, const QString &title,
const QString &text, const QString &infoText,
Buttons buttons, enum Button dfltButton,
const QList< QPair<QString, int> > &customButtons, int *selected)
{
return toDialogueRetVal(
WidgetMessageDialogue::message(toMessageBoxIcon(icon), title,
text, infoText, toMessageBoxButtons(buttons),
toMessageBoxButton(dfltButton), customButtons, selected));
}
void Dialogues::errorMessage(enum Icon icon, const QString &title,
const QString &text, const QString &infoText)
{
WidgetMessageDialogue::errorMessage(toMessageBoxIcon(icon), title,
text, infoText);
}
......@@ -21,27 +21,49 @@
* the two.
*/
#ifndef _INPUT_DIALOGUE_H_
#define _INPUT_DIALOGUE_H_
#ifndef _DIALOGUES_H_
#define _DIALOGUES_H_
#include <QObject>
#include <QWindow>
#include "src/dialogues/qml_dialogue_helper.h"
/*!
* @brief Encapsulates input dialogues.
* @brief Encapsulates dialogues.
*/
class InputDialogue : public QObject {
class Dialogues : public QObject {
Q_OBJECT
private:
/*!
* @brief Private constructor.
*/
explicit InputDialogue(QObject *parent = Q_NULLPTR);
explicit Dialogues(QObject *parent = Q_NULLPTR);
public:
/*!
* @brief Dialogue icon decoration.
*/
enum Icon {
NO_ICON,
QUESTION,
INFORMATION,
WARNING,
CRITICAL
};
/*!
* @brief Dialogue button declaration.
*/
enum Button {
OK = 0x00000400,
CANCEL = 0x00400000,
YES = 0x00004000,
NO = 0x00010000,
NO_BUTTON = 0x00000000
};
Q_DECLARE_FLAGS(Buttons, Button)
/*!
* @brief Generates a text edit dialogue. Paste button is added on
* Android devices.
......@@ -64,6 +86,42 @@ public:
const QString &text = QString(),
const QString &placeholderText = QString(), bool *ok = Q_NULLPTR,
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
/*!
* @brief Show message and await response.
*
* @param[in] icon Icon identifying importance of the message.
* @param[in] title Title of the dialogue window.
* @param[in] text Main message of the dialogue.
* @param[in] infoText Additional informative text.
* @param[in] buttons Standard buttons to be displayed.
* @param[in] dfltButton Identifies default action button.
* @param[in] customButtons List of pairs of custom button strings and values.
* @param[out] selected Value of selected custom button.
* @return Dialogue code or standard button value, -1 if custom button
* was selected and custom button was selected then \a selected is
* set to value of custom button.
*/
static
int message(enum Icon icon, const QString &title,
const QString &text, const QString &infoText,
Buttons buttons = NO_BUTTON, enum Button dfltButton = NO_BUTTON,
const QList< QPair<QString, int> > &customButtons = QList< QPair<QString, int> >(),
int *selected = Q_NULLPTR);
/*!
* @brief Show error message that can only be acknowledged.
*
* @param[in] icon Icon identifying importance of the message.
* @param[in] title Title of the dialogue window.
* @param[in] text Main message of the dialogue.
* @param[in] infoText Additional informative text.
*/
static
void errorMessage(enum Icon icon, const QString &title,
const QString &text, const QString &infoText);
};
#endif /* _INPUT_DIALOGUE_H_ */
Q_DECLARE_OPERATORS_FOR_FLAGS(Dialogues::Buttons)
#endif /* _DIALOGUES_H_ */
......@@ -30,7 +30,7 @@
#include <QQmlEngine> /* qmlRegisterType */
#include "src/common.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/files.h"
#include "src/settings.h"
#include "src/io/filesystem.h"
......@@ -289,19 +289,18 @@ void Files::openAttachment(const QString &fileName, const QByteArray &base64Data
*/
#else /* !defined Q_OS_IOS */
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(filePath))) {
WidgetMessageDialogue::message(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Open attachment error"),
tr("There is no application to open this file format."),
tr("File: '%1'").arg(filePath),
QMessageBox::Ok, QMessageBox::Ok);
tr("File: '%1'").arg(filePath));
}
#endif /* defined Q_OS_IOS */
} else {
qCritical() << "Cannot create temporary file for" << fileName;
WidgetMessageDialogue::message(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Open attachment error"),
tr("Cannot save selected file to disk for opening."),
QString(), QMessageBox::Ok, QMessageBox::Ok);
QString());
}
}
......@@ -380,12 +379,12 @@ void Files::deleteFileDb(const QString &userName)
{
qDebug("%s()", __func__);
int msgResponse = WidgetMessageDialogue::message(QMessageBox::Question,
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("Delete files: %1").arg(userName),
tr("Do you want to clean up the file database of account '%1'?").arg(userName),
tr("Note: All attachment files of messages will be removed from the database."),
QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (msgResponse == QMessageBox::No) {
Dialogues::NO | Dialogues::YES, Dialogues::NO);
if (msgResponse == Dialogues::NO) {
return;
}
......@@ -635,14 +634,12 @@ void attachmentSavingNotification(const QString &destPath)
{
QFileInfo fi(destPath);
WidgetMessageDialogue::message(
!destPath.isEmpty() ? QMessageBox::Information :
QMessageBox::Critical,
Dialogues::errorMessage(
!destPath.isEmpty() ? Dialogues::INFORMATION : Dialogues::CRITICAL,
QObject::tr("Attachment saving"),
!destPath.isEmpty() ? QObject::tr("Attachments have been saved.") :
QObject::tr("Attachments have not been saved!"),
QObject::tr("Path: '%1'").arg(fi.absolutePath()),
QMessageBox::Ok, QMessageBox::Ok);
QObject::tr("Path: '%1'").arg(fi.absolutePath()));
}
void Files::saveAttachmentsToDiskDb(const QString &userName,
......
......@@ -34,7 +34,7 @@
#include "src/common.h"
#include "src/dialogues/qml_dialogue_helper.h"
#include "src/dialogues/qml_input_dialogue.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/files.h"
#include "src/locker.h"
#include "src/net/isds_wrapper.h"
......@@ -351,7 +351,7 @@ int main(int argc, char *argv[])
arg(globSet.lastUpdateStr()), false, true);
}
} else {
WidgetMessageDialogue::errorMessage(QMessageBox::Warning,
Dialogues::errorMessage(Dialogues::WARNING,
QObject::tr("Security problem"),
QObject::tr("OpenSSL support is required!"),
QObject::tr("The device does not support OpenSSL. "
......
......@@ -29,7 +29,7 @@
#include <QStorageInfo>
#include "src/common.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/messages.h"
#include "src/settings.h"
#include "src/models/accountmodel.h"
......@@ -185,12 +185,12 @@ void Messages::deleteMessageFromDbs(const QString &userName, qint64 msgId)
return;
}
int msgResponse = WidgetMessageDialogue::message(QMessageBox::Question,
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("Delete message: %1").arg(msgId),
tr("Do you want to delete the message '%1'?").arg(msgId),
tr("Note: It will delete all attachments and message information from the local database."),
QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (msgResponse == QMessageBox::No) {
Dialogues::NO | Dialogues::YES, Dialogues::NO);
if (msgResponse == Dialogues::NO) {
return;
}
......@@ -262,11 +262,10 @@ bool Messages::moveOrCreateNewDbsToNewLocation(const QString &newLocation)
{
QStorageInfo si(newLocation);
if (si.bytesAvailable() < allDbSize) {
WidgetMessageDialogue::message(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("New location error"),
tr("It is not possible to store databases in the new location because there is not enough free space left."),
tr("Databases size is %1 MB.").arg(allDbSize / (1024 * 1024)),
QMessageBox::Ok, QMessageBox::Ok);
tr("Databases size is %1 MB.").arg(allDbSize / (1024 * 1024)));
return false;
}
}
......@@ -330,11 +329,11 @@ enum Messages::ReloactionAction Messages::askAction(void)
customButtons.append(QPair<QString, int>(tr("Create new"), RA_CREATE_NEW));
int customVal = -1;
WidgetMessageDialogue::message(QMessageBox::Question,
Dialogues::message(Dialogues::QUESTION,
tr("Change database location"),
tr("What do you want to do with the currently used database files?"),
tr("You have the option to move the current database files to a new location or you can delete them and create new empty databases."),
QMessageBox::Cancel, QMessageBox::Cancel,
Dialogues::CANCEL, Dialogues::CANCEL,
customButtons, &customVal);
if (customVal == RA_RELOCATE) {
......
......@@ -26,7 +26,7 @@
#include <QFileInfo>
#include "src/common.h"
#include "src/dialogues/input_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/net/isds_const.h"
#include "src/net/isds_session.h"
#include "src/net/xml_layer.h"
......@@ -123,7 +123,7 @@ bool IsdsSession::setCertificateData(const QString &userName,
return false;
}
const QString passPhrase = InputDialogue::getText(Q_NULLPTR,
const QString passPhrase = Dialogues::getText(Q_NULLPTR,
tr("Certificate password: %1").arg(userName),
tr("Certificate password for '%1' required").arg(accountName),
QmlDlgHelper::EM_PWD, QString(), tr("Enter certificate password"),
......
......@@ -23,8 +23,7 @@
#include <QDebug>
#include "src/dialogues/input_dialogue.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/net/isds_wrapper.h"
#include "src/models/accountmodel.h"
#include "src/settings.h"
......@@ -50,7 +49,7 @@ void IsdsWrapper::downloadMessage(const QString &userName, int mesasgeType,
QString errTxt = tr("Wrong username or message ID");
if (userName.isEmpty() || msgId <= 0) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), errTxt, tr("Internal error"));
return;
}
......@@ -66,8 +65,7 @@ void IsdsWrapper::downloadMessage(const QString &userName, int mesasgeType,
if (mesasgeType == MessageDb::TYPE_RECEIVED) {
if (!m_xmlLayer.isdsGetCompleteMsgWithoutCms(
m_isdsSession.isdsCtxMap[userName], msgId)) {
WidgetMessageDialogue::errorMessage(
QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Delivery info: %1").arg(userName),
tr("Failed to download complete received message %1.").arg(msgId),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -76,8 +74,7 @@ void IsdsWrapper::downloadMessage(const QString &userName, int mesasgeType,
} else {
if (!m_xmlLayer.isdsGetCompleteSentMsgWithCms(
m_isdsSession.isdsCtxMap[userName], msgId)) {
WidgetMessageDialogue::errorMessage(
QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Downloading message: %1").arg(userName),
tr("Failed to download complete sent message %1.").arg(msgId),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -107,7 +104,7 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
QString errTxt = tr("Wrong username or message ID");
if (userName.isEmpty() || msgId <= 0) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), errTxt, tr("Internal error"));
return;
}
......@@ -122,7 +119,7 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
if (!m_xmlLayer.isdsGetMsgDeliveryInfoWithoutCms(
m_isdsSession.isdsCtxMap[userName], msgId)) {
WidgetMessageDialogue::errorMessage(QMessageBox::Warning,
Dialogues::errorMessage(Dialogues::WARNING,
tr("Delivery info: %1").arg(userName),
tr("Failed to download delivery info for message %1.").arg(msgId),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -174,7 +171,7 @@ bool IsdsWrapper::syncSingleAccountReceived(const QString &userName)
/* ========================================================================= */
{
if (userName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Empty user name"), tr("Internal error"));
return false;
}
......@@ -194,7 +191,7 @@ bool IsdsWrapper::syncSingleAccountReceived(const QString &userName)
if (!m_xmlLayer.isdsGetReceivedMessageList(
m_isdsSession.isdsCtxMap[userName],
globSet.downloadOnlyNewMsgs, receivedMsgIds)) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("%1: received messages").arg(userName),
tr("Failed to download list of received messages for user name '%1'.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -226,7 +223,7 @@ bool IsdsWrapper::syncSingleAccountSent(const QString &userName)
/* ========================================================================= */
{
if (userName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), tr("Empty user name"), tr("Internal error"));
return false;
}
......@@ -245,7 +242,7 @@ bool IsdsWrapper::syncSingleAccountSent(const QString &userName)
if (!m_xmlLayer.isdsGetSentMessageList(
m_isdsSession.isdsCtxMap[userName],
globSet.downloadOnlyNewMsgs, sentMsgIds)) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("%1: sent messages").arg(userName),
tr("Failed to download list of sent messages for user name %1.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -276,7 +273,7 @@ bool IsdsWrapper::getAccountInfo(const QString &userName, bool firstLogin)
QString errTxt = tr("Wrong username");
if (userName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), errTxt, tr("Internal error"));
return false;
}
......@@ -309,7 +306,7 @@ bool IsdsWrapper::getAccountInfo(const QString &userName, bool firstLogin)
m_xmlLayer.isdsGetPasswordExpiration(m_isdsSession.isdsCtxMap[userName]);
if (!success) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Account info: %1").arg(userName),
tr("Failed to get account info for username %1.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -336,7 +333,7 @@ void IsdsWrapper::changePassword(const QString &userName,
QString errTxt = tr("Wrong username");
if (userName.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), errTxt, tr("Internal error"));
return;
}
......@@ -347,7 +344,7 @@ void IsdsWrapper::changePassword(const QString &userName,
}
bool ok;
QString newPwd = InputDialogue::getText(Q_NULLPTR,
QString newPwd = Dialogues::getText(Q_NULLPTR,
tr("New password: %1").arg(userName),
tr("Enter new password for account\n'%1'").arg(accountName),
QmlDlgHelper::EM_NORMAL, QString(), tr("Enter password"), &ok);
......@@ -355,7 +352,7 @@ void IsdsWrapper::changePassword(const QString &userName,
return;
}
if (!isCorrectPassword(newPwd)) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Change password: %1").arg(userName),
tr("Wrong password format for username '%1'.").arg(userName),
tr("The new password must contain at least 8 characters including "
......@@ -365,25 +362,24 @@ void IsdsWrapper::changePassword(const QString &userName,
if (m_isdsSession.isdsCtxMap[userName].login_method == USERNAME_PWD_TOTP) {
/* Show SMS request dialogue. */
int msgResponse = WidgetMessageDialogue::message(
QMessageBox::Question, tr("SMS code: %1").arg(userName),
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("SMS code: %1").arg(userName),
tr("Account '%1' requires authentication with SMS code.").arg(accountName),
tr("Do you want to send SMS code now?"),
QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes);
if (msgResponse == QMessageBox::No) {
Dialogues::NO | Dialogues::YES, Dialogues::YES);
if (msgResponse == Dialogues::NO) {
return;
}
if (!m_xmlLayer.isdsSendSMS(m_isdsSession.isdsCtxMap[userName])) {
WidgetMessageDialogue::errorMessage(
QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Change password: %1").arg(userName),
tr("Failed to send SMS code for username '%1'.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
return;
}
QString text = InputDialogue::getText(Q_NULLPTR,
QString text = Dialogues::getText(Q_NULLPTR,
tr("SMS code: %1").arg(userName),
tr("SMS code for '%1' required").arg(accountName),
QmlDlgHelper::EM_NORMAL, QString(), tr("Enter SMS code"),
......@@ -395,7 +391,7 @@ void IsdsWrapper::changePassword(const QString &userName,
}
} else if (m_isdsSession.isdsCtxMap[userName].login_method == USERNAME_PWD_HOTP) {
QString text = InputDialogue::getText(Q_NULLPTR,
QString text = Dialogues::getText(Q_NULLPTR,
tr("Security code: %1").arg(userName),
tr("Security code for '%1' required").arg(accountName),
QmlDlgHelper::EM_NORMAL, QString(),
......@@ -412,7 +408,7 @@ void IsdsWrapper::changePassword(const QString &userName,
if (!m_xmlLayer.isdsChangePassword(m_isdsSession.isdsCtxMap[userName],
newPwd)) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Change password: %1").arg(userName),
tr("Failed to change password for username '%1'.").arg(userName),
m_isdsSession.isdsCtxMap[userName].last_isds_msg);
......@@ -568,7 +564,7 @@ void IsdsWrapper::showLoginProblemDialog(const QString &userName,
emit statusBarTextChanged("", false, false);
if (!errTxt.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Login problem: %1").arg(userName),
tr("Error while logging in with username '%1'.").arg(userName),
tr("System ISDS returns:") + " " + errTxt + "\n\n" +
......@@ -588,7 +584,7 @@ void IsdsWrapper::showFirstLoginProblemDialog(const QString &userName,
emit statusBarTextChanged("", false, false);
if (!errTxt.isEmpty()) {
WidgetMessageDialogue::errorMessage(QMessageBox::Critical,
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Problem adding account: %1").arg(userName),
tr("New account could not be created because an error occurred "
"while trying to log in with user name '%1'.").arg(userName),
......
......@@ -31,8 +31,7 @@
#include <QTimer>
#include "src/common.h"
#include "src/dialogues/input_dialogue.h"
#include "src/dialogues/widget_message_dialogue.h"
#include "src/dialogues/dialogues.h"
#include "src/net/net_layer.h"
#include "src/net/xml_layer.h"
#include "src/net/isds_const.h"
......@@ -141,7 +140,7 @@ bool NetLayer::createLoginRequest(IsdsContext &ctx,
if (ctx.password.isEmpty()) {
do {
pwd = InputDialogue::getText(Q_NULLPTR,
pwd = Dialogues::getText(Q_NULLPTR,
tr("Password: %1").arg(ctx.username),
tr("Password for '%1' missing").arg(ctx.account_name),
QmlDlgHelper::EM_PWD, QString(),
......@@ -160,7 +159,7 @@ bool NetLayer::createLoginRequest(IsdsContext &ctx,
if (ctx.login_method == USERNAME_PWD_HOTP) {
do {
pwd = InputDialogue::getText(Q_NULLPTR,
pwd = Dialogues::getText(Q_NULLPTR,
tr("Security code: %1").arg(ctx.username),
tr("Security code for '%1' required").arg(ctx.account_name),
QmlDlgHelper::EM_NORMAL, QString(),
......@@ -178,12 +177,12 @@ bool NetLayer::createLoginRequest(IsdsContext &ctx,
} else if (ctx.login_method == USERNAME_PWD_TOTP) {
/* Show SMS dialogue. */
int msgResponse = WidgetMessageDialogue::message(
QMessageBox::Question, tr("SMS code: %1").arg(ctx.username),
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("SMS code: %1").arg(ctx.username),
tr("Account '%1' requires authentication with SMS code.").arg(ctx.account_name),
tr("Do you want to send SMS code now?"),
QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes);
if (msgResponse == QMessageBox::No) {
Dialogues::NO | Dialogues::YES, Dialogues::YES);
if (msgResponse == Dialogues::NO) {
return success;
}
authorization.append(ctx.username + ":" + ctx.password);
......@@ -579,7 +578,7 @@ bool NetLayer::doTotpLoginRequest(IsdsContext &ctx, const QByteArray &xmlDataIn,
do {