blob: dcf6148981df7c3934d498361b2fac72e44f31e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QObject>
#include <QQmlEngine>
#include <QString>
#include <mtx/user_interactive.hpp>
#include <mtxclient/http/client.hpp>
class RegisterPage : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString error READ error NOTIFY errorChanged)
Q_PROPERTY(QString hsError READ hsError NOTIFY hsErrorChanged)
Q_PROPERTY(QString usernameError READ usernameError NOTIFY lookingUpUsernameChanged)
Q_PROPERTY(bool registering READ registering NOTIFY registeringChanged)
Q_PROPERTY(bool supported READ supported NOTIFY lookingUpHsChanged)
Q_PROPERTY(bool lookingUpHs READ lookingUpHs NOTIFY lookingUpHsChanged)
Q_PROPERTY(bool lookingUpUsername READ lookingUpUsername NOTIFY lookingUpUsernameChanged)
Q_PROPERTY(bool usernameAvailable READ usernameAvailable NOTIFY lookingUpUsernameChanged)
Q_PROPERTY(bool usernameUnavailable READ usernameUnavailable NOTIFY lookingUpUsernameChanged)
public:
RegisterPage(QObject *parent = nullptr);
Q_INVOKABLE void setServer(const QString &server);
Q_INVOKABLE void checkUsername(const QString &name);
Q_INVOKABLE void
startRegistration(const QString &username, const QString &password, const QString &deviceName);
Q_INVOKABLE QString initialDeviceName() const;
bool registering() const { return registering_; }
bool supported() const { return supported_; }
bool lookingUpHs() const { return lookingUpHs_; }
bool lookingUpUsername() const { return lookingUpUsername_; }
bool usernameAvailable() const { return usernameAvailable_; }
bool usernameUnavailable() const { return usernameUnavailable_; }
QString error() const { return registrationError_; }
QString usernameError() const { return usernameError_; }
QString hsError() const { return hsError_; }
signals:
void errorChanged();
void hsErrorChanged();
void registeringChanged();
void lookingUpHsChanged();
void lookingUpUsernameChanged();
void registerOk();
private:
void versionsCheck();
void setHsError(const QString &err);
void setError(const QString &err);
QString registrationError_, hsError_, usernameError_;
bool registering_ = false;
bool supported_ = false;
bool lookingUpHs_ = false;
bool lookingUpUsername_ = false;
bool usernameAvailable_ = false;
bool usernameUnavailable_ = false;
QString lastServer;
};
|