aboutsummaryrefslogtreecommitdiff
path: root/src/Bindings.h
blob: 3aa3e777d6ccabd545fdbcd374b48070869eb1bd (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* generated by rust_qt_binding_generator */
/* Beware: a lot of const pointers mentioned in this file are mutating data on the Rust side. */
#ifndef BINDINGS_H
#define BINDINGS_H

#include <QtCore/QObject>
#include <QtCore/QAbstractItemModel>

class PasswordMaker;
class Profiles;
class Settings;

class PasswordMaker : public QObject
{
    Q_OBJECT
public:
    class Private;
private:
    Profiles* const m_profiles;
    Settings* const m_settings;
    const Private * m_d;
    Private * const m_d_owned;
    Q_PROPERTY(QString generated_password READ generated_password NOTIFY generated_passwordChanged FINAL)
    Q_PROPERTY(quint8 generator_state READ generator_state NOTIFY generator_stateChanged FINAL)
    Q_PROPERTY(bool i_say_sexy_things_to_myself_while_im_dancing READ i_say_sexy_things_to_myself_while_im_dancing WRITE setI_say_sexy_things_to_myself_while_im_dancing NOTIFY i_say_sexy_things_to_myself_while_im_dancingChanged FINAL)
    Q_PROPERTY(QString master_password READ master_password WRITE setMaster_password NOTIFY master_passwordChanged FINAL)
    Q_PROPERTY(Profiles* profiles READ profiles NOTIFY profilesChanged FINAL)
    Q_PROPERTY(Settings* settings READ settings NOTIFY settingsChanged FINAL)
    Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged FINAL)
    Q_PROPERTY(QString used_text READ used_text WRITE setUsed_text NOTIFY used_textChanged FINAL)
    explicit PasswordMaker(bool owned, QObject *parent);
public:
    explicit PasswordMaker(QObject *parent = nullptr);
    ~PasswordMaker();
    QString generated_password() const;
    quint8 generator_state() const;
    bool i_say_sexy_things_to_myself_while_im_dancing() const;
    void setI_say_sexy_things_to_myself_while_im_dancing(bool v);
    QString master_password() const;
    void setMaster_password(const QString& v);
    const Profiles* profiles() const;
    Profiles* profiles();
    const Settings* settings() const;
    Settings* settings();
    QString url() const;
    void setUrl(const QString& v);
    QString used_text() const;
    void setUsed_text(const QString& v);
    Q_INVOKABLE void profile_changed() const;
    Q_INVOKABLE bool store_settings() const;
Q_SIGNALS:
    void generated_passwordChanged();
    void generator_stateChanged();
    void i_say_sexy_things_to_myself_while_im_dancingChanged();
    void master_passwordChanged();
    void profilesChanged();
    void settingsChanged();
    void urlChanged();
    void used_textChanged();
};

class Profiles : public QAbstractItemModel
{
    Q_OBJECT
    friend class PasswordMaker;
public:
    class Private;
private:
    const Private * m_d;
    Private * const m_d_owned;
    Q_PROPERTY(quint32 current_profile READ current_profile WRITE setCurrent_profile NOTIFY current_profileChanged FINAL)
    Q_PROPERTY(QString current_profile_name READ current_profile_name NOTIFY current_profile_nameChanged FINAL)
    explicit Profiles(bool owned, QObject *parent);
public:
    explicit Profiles(QObject *parent = nullptr);
    ~Profiles();
    quint32 current_profile() const;
    void setCurrent_profile(quint32 v);
    QString current_profile_name() const;
    Q_INVOKABLE bool store() const;

    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &index) const override;
    bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    bool canFetchMore(const QModelIndex &parent) const override;
    void fetchMore(const QModelIndex &parent) override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
    int role(const char* name) const;
    QHash<int, QByteArray> roleNames() const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
    Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    Q_INVOKABLE QString characters(int row) const;
    Q_INVOKABLE bool setCharacters(int row, const QString& value);
    Q_INVOKABLE quint8 hash_algorithm(int row) const;
    Q_INVOKABLE bool setHash_algorithm(int row, quint8 value);
    Q_INVOKABLE quint8 leet_level(int row) const;
    Q_INVOKABLE bool setLeet_level(int row, quint8 value);
    Q_INVOKABLE QString modifier(int row) const;
    Q_INVOKABLE bool setModifier(int row, const QString& value);
    Q_INVOKABLE QString name(int row) const;
    Q_INVOKABLE bool setName(int row, const QString& value);
    Q_INVOKABLE quint32 password_length(int row) const;
    Q_INVOKABLE bool setPassword_length(int row, quint32 value);
    Q_INVOKABLE QString prefix(int row) const;
    Q_INVOKABLE bool setPrefix(int row, const QString& value);
    Q_INVOKABLE QString suffix(int row) const;
    Q_INVOKABLE bool setSuffix(int row, const QString& value);
    Q_INVOKABLE bool use_domain(int row) const;
    Q_INVOKABLE bool setUse_domain(int row, bool value);
    Q_INVOKABLE quint8 use_leet(int row) const;
    Q_INVOKABLE bool setUse_leet(int row, quint8 value);
    Q_INVOKABLE bool use_port_path(int row) const;
    Q_INVOKABLE bool setUse_port_path(int row, bool value);
    Q_INVOKABLE bool use_protocol(int row) const;
    Q_INVOKABLE bool setUse_protocol(int row, bool value);
    Q_INVOKABLE bool use_subdomains(int row) const;
    Q_INVOKABLE bool setUse_subdomains(int row, bool value);
    Q_INVOKABLE bool use_undefined_as_protocol_fallback(int row) const;
    Q_INVOKABLE bool setUse_undefined_as_protocol_fallback(int row, bool value);
    Q_INVOKABLE bool use_user_info(int row) const;
    Q_INVOKABLE bool setUse_user_info(int row, bool value);
    Q_INVOKABLE QString username(int row) const;
    Q_INVOKABLE bool setUsername(int row, const QString& value);

Q_SIGNALS:
    // new data is ready to be made available to the model with fetchMore()
    // the passed QVariant contains a quintptr which is the internal id.
    // This is the same index that the fetch_more function typically expects on the Rust side.
    // Previously this Signal sent a QModelIndex, but that was changed due to threading issues.
    // If you need to create a QModelIndex from the internal id, you can expose the profiles_row() method
    // on the underlying Rust object as a function and use it. Just beware that this Signal is
    // typically sent from arbitrary threads, so compute the index at the Slot side.
    // While speaking of threads: Make sure the internal ID of your model entries is stable.
    // If it can change, it's up to you to ensure that it does not do so between sending this
    // signal and receiving the corresponding fetchMore() call on the other side of the Connection.
    void newDataReady(const QVariant &parent) const;
private:
    QHash<QPair<int,Qt::ItemDataRole>, QVariant> m_headerData;
    void initHeaderData();
    void updatePersistentIndexes();
Q_SIGNALS:
    void current_profileChanged();
    void current_profile_nameChanged();
};

class Settings : public QObject
{
    Q_OBJECT
    friend class PasswordMaker;
public:
    class Private;
private:
    const Private * m_d;
    Private * const m_d_owned;
    Q_PROPERTY(QVariant clear_generated_password_seconds READ clear_generated_password_seconds WRITE setClear_generated_password_seconds NOTIFY clear_generated_password_secondsChanged FINAL)
    Q_PROPERTY(QVariant clear_master_password_seconds READ clear_master_password_seconds WRITE setClear_master_password_seconds NOTIFY clear_master_password_secondsChanged FINAL)
    Q_PROPERTY(bool hide_generated_password READ hide_generated_password WRITE setHide_generated_password NOTIFY hide_generated_passwordChanged FINAL)
    explicit Settings(bool owned, QObject *parent);
public:
    explicit Settings(QObject *parent = nullptr);
    ~Settings();
    QVariant clear_generated_password_seconds() const;
    void setClear_generated_password_seconds(const QVariant& v);
    QVariant clear_master_password_seconds() const;
    void setClear_master_password_seconds(const QVariant& v);
    bool hide_generated_password() const;
    void setHide_generated_password(bool v);
Q_SIGNALS:
    void clear_generated_password_secondsChanged();
    void clear_master_password_secondsChanged();
    void hide_generated_passwordChanged();
};
#endif // BINDINGS_H