File indexing completed on 2024-12-22 04:56:59

0001 /*
0002     SPDX-FileCopyrightText: 2018 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "ewspasswordauth.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include "ewsclient_debug.h"
0012 
0013 EwsPasswordAuth::EwsPasswordAuth(const QString &username, QObject *parent)
0014     : EwsAbstractAuth(parent)
0015     , mUsername(username)
0016 {
0017 }
0018 
0019 void EwsPasswordAuth::init()
0020 {
0021     Q_EMIT requestWalletPassword(false);
0022 }
0023 
0024 bool EwsPasswordAuth::getAuthData(QString &username, QString &password, QStringList &customHeaders)
0025 {
0026     Q_UNUSED(customHeaders)
0027 
0028     if (!mPassword.isNull()) {
0029         username = mUsername;
0030         password = mPassword;
0031         return true;
0032     }
0033     return false;
0034 }
0035 
0036 void EwsPasswordAuth::notifyRequestAuthFailed()
0037 {
0038     EwsAbstractAuth::notifyRequestAuthFailed();
0039 }
0040 
0041 bool EwsPasswordAuth::authenticate(bool interactive)
0042 {
0043     Q_UNUSED(interactive)
0044 
0045     return false;
0046 }
0047 
0048 const QString &EwsPasswordAuth::reauthPrompt() const
0049 {
0050     static const QString prompt;
0051     return prompt;
0052 }
0053 
0054 const QString &EwsPasswordAuth::authFailedPrompt() const
0055 {
0056     static const QString prompt =
0057         i18nc("@info", "The username/password for the Microsoft Exchange EWS account <b>%1</b> is not valid. Please update it in the account settings page.");
0058     return prompt;
0059 }
0060 
0061 void EwsPasswordAuth::walletPasswordRequestFinished(const QString &password)
0062 {
0063     mPassword = password;
0064 
0065     if (!password.isNull()) {
0066         Q_EMIT authSucceeded();
0067     } else {
0068         Q_EMIT authFailed(QStringLiteral("Password request failed"));
0069     }
0070 }
0071 
0072 void EwsPasswordAuth::walletMapRequestFinished(const QMap<QString, QString> &map)
0073 {
0074     Q_UNUSED(map)
0075 }
0076 
0077 void EwsPasswordAuth::setUsername(const QString &username)
0078 {
0079     mUsername = username;
0080 }
0081 
0082 #include "moc_ewspasswordauth.cpp"