2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-09-18 01:21:14 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2022-06-17 04:11:31 +03:00
|
|
|
#include <mtxclient/http/client.hpp>
|
2021-09-18 01:21:14 +03:00
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class UIA final : public QObject
|
2021-09-18 01:21:14 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static UIA *instance();
|
|
|
|
|
|
|
|
UIA(QObject *parent = nullptr)
|
|
|
|
: QObject(parent)
|
2022-09-25 21:05:08 +03:00
|
|
|
{
|
|
|
|
}
|
2021-09-18 01:21:14 +03:00
|
|
|
|
|
|
|
mtx::http::UIAHandler genericHandler(QString context);
|
|
|
|
|
|
|
|
QString title() const { return title_; }
|
|
|
|
|
|
|
|
public slots:
|
2022-10-04 00:57:30 +03:00
|
|
|
void continuePassword(const QString &password);
|
|
|
|
void continueEmail(const QString &email);
|
|
|
|
void continuePhoneNumber(const QString &countryCode, const QString &phoneNumber);
|
|
|
|
void submit3pidToken(const QString &token);
|
2021-11-03 20:36:12 +03:00
|
|
|
void continue3pidReceived();
|
2021-09-18 01:21:14 +03:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void password();
|
2021-11-03 20:36:12 +03:00
|
|
|
void email();
|
|
|
|
void phoneNumber();
|
|
|
|
|
|
|
|
void confirm3pidToken();
|
|
|
|
void prompt3pidToken();
|
|
|
|
void tokenAccepted();
|
2021-09-18 01:21:14 +03:00
|
|
|
|
|
|
|
void titleChanged();
|
2021-11-03 20:36:12 +03:00
|
|
|
void error(QString msg);
|
2021-09-18 01:21:14 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::optional<mtx::http::UIAHandler> currentHandler;
|
|
|
|
mtx::user_interactive::Unauthorized currentStatus;
|
|
|
|
QString title_;
|
2021-11-03 20:36:12 +03:00
|
|
|
|
|
|
|
// for 3pids like email and phone number
|
|
|
|
std::string client_secret;
|
|
|
|
std::string sid;
|
|
|
|
std::string submit_url;
|
|
|
|
bool email_ = true;
|
2021-09-18 01:21:14 +03:00
|
|
|
};
|