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

#pragma once

#include <QHash>
#include <QObject>
#include <QSharedPointer>

#include <mtx/events.hpp>
#include <mtx/events/encrypted.hpp>

class DeviceVerificationFlow;
class TimelineModel;
class TimelineModel;
class TimelineViewManager;
class RoomlistModel;

class VerificationManager : public QObject
{
    Q_OBJECT

public:
    VerificationManager(TimelineViewManager *o = nullptr);

    Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
    void verifyUser(QString userid);
    void verifyDevice(QString userid, QString deviceid);

signals:
    void newDeviceVerificationRequest(DeviceVerificationFlow *flow);

public slots:
    void receivedRoomDeviceVerificationRequest(
      const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
      TimelineModel *model);
    void receivedDeviceVerificationRequest(const mtx::events::msg::KeyVerificationRequest &msg,
                                           std::string sender);
    void receivedDeviceVerificationStart(const mtx::events::msg::KeyVerificationStart &msg,
                                         std::string sender);

private:
    QHash<QString, QSharedPointer<DeviceVerificationFlow>> dvList;
    bool isInitialSync_ = false;
    RoomlistModel *rooms_;
};