summary refs log tree commit diff
path: root/src/encryption/SelfVerificationStatus.h
blob: 8d28f46af3c8855b96e23cb487368e5523d4ec3b (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
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include <QQmlEngine>

class SelfVerificationStatus : public QObject
{
    Q_OBJECT

    QML_ELEMENT
    QML_SINGLETON

    Q_PROPERTY(Status status READ status NOTIFY statusChanged)
    Q_PROPERTY(bool hasSSSS READ hasSSSS NOTIFY hasSSSSChanged)

public:
    SelfVerificationStatus(QObject *o = nullptr);
    enum Status
    {
        AllVerified,
        NoMasterKey,
        UnverifiedMasterKey,
        UnverifiedDevices,
    };
    Q_ENUM(Status)

    Q_INVOKABLE void
    setupCrosssigning(bool useSSSS, const QString &password, bool useOnlineKeyBackup);
    Q_INVOKABLE void verifyMasterKey();
    Q_INVOKABLE void verifyMasterKeyWithPassphrase();
    Q_INVOKABLE void verifyUnverifiedDevices();

    Status status() const { return status_; }
    bool hasSSSS() const { return hasSSSS_; }

signals:
    void statusChanged();
    void hasSSSSChanged();
    void setupCompleted();
    void showRecoveryKey(QString key);
    void setupFailed(QString message);

public slots:
    void invalidate();

private:
    Status status_ = AllVerified;
    bool hasSSSS_  = true;
};