blob: 942e1aa419cbbae0e54a74de05f3b573081ab0ad (
plain)
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
|
#pragma once
#include <QString>
#include "aoapplication.h"
#include "ext_packet.h"
#include "keyring.h"
class KeySelectDialog : public QDialog
{
Q_OBJECT
public:
explicit KeySelectDialog(KeyringModel *model, QStringView username, QWidget *parent = nullptr);
private:
KeyringModel *m_model;
signals:
void key_selected(QByteArrayView key_id, QStringView key_name);
};
class KeyPassphraseDialog : public QDialog
{
Q_OBJECT
public:
explicit KeyPassphraseDialog(QStringView key_name, QWidget *parent = nullptr);
void display_error(ResponseResult error) const;
private:
QLabel *m_err_lbl;
QLineEdit *m_pw_line;
signals:
void passphrase_submitted(QByteArrayView passphrase);
};
// The only reason this inherits QObject is so I can call deleteLater()
// when the authentication finishes. Auth flow involves coordinating two
// asynchronous dialogs emitting signals, so I'd rather let Qt's event loop
// clean everything up to be safe.
class AuthFlow : public QObject
{
Q_OBJECT
public:
explicit AuthFlow(AOApplication *ao_app, const AuthChallenge &challenge, QWidget *parent = nullptr);
private:
enum class FlowMode
{
Default,
Saved
};
FlowMode m_mode;
AOApplication *m_ao_app;
AuthChallenge m_challenge;
KeySelectDialog *m_key_dlg;
KeyPassphraseDialog *m_pwd_dlg;
void on_key_selected(QByteArrayView key_id, QStringView key_name);
};
void start_auth_flow(AOApplication *ao_app, QString username);
|