-
Notifications
You must be signed in to change notification settings - Fork 2
/
DeviceDialog.h
99 lines (81 loc) · 2.43 KB
/
DeviceDialog.h
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
//
// Copyright (C) 2015 Red Hat, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Authors: Daniel Kopecek <dkopecek@redhat.com>
//
#pragma once
#include "LibUsbguard.h"
#include <USB.hpp>
#include <QDialog>
#include <QTimer>
namespace Ui
{
class DeviceDialog;
}
class DeviceDialog : public QDialog
{
Q_OBJECT
public:
enum class DecisionMethod {
Buttons,
MathTest
};
explicit DeviceDialog(quint32 id, QWidget* parent = nullptr);
~DeviceDialog();
void setName(const QString& name);
void setSerial(const QString& serial);
void setDeviceID(const QString& vendor_id, const QString& product_id);
void setInterfaceTypes(const std::vector<usbguard::USBInterfaceType>& interfaces);
void setDefaultDecision(Rule::Target target);
void setDefaultDecisionTimeout(quint32 seconds);
void setDecisionMethod(DecisionMethod method);
void setDecisionIsPermanent(bool state);
void setRejectVisible(bool state);
void setRandomizePosition(bool randomize);
void setMaskSerialNumber(bool state);
Q_SIGNALS:
void allowed(quint32 id, bool permanent);
void blocked(quint32 id, bool permanent);
void rejected(quint32 id, bool permanent);
protected Q_SLOTS:
void timerUpdate();
protected:
void reject();
void accept();
void updateDialog();
void executeDefaultDecision();
void setPosition(bool randomized);
private Q_SLOTS:
void on_allow_button_clicked();
void on_block_button_clicked();
void on_reject_button_clicked();
private:
Ui::DeviceDialog* ui;
Rule::Target _default_decision;
quint32 _default_decision_timeout;
DecisionMethod _decision_method;
bool _reject_enabled;
bool _mask_serial_number;
bool _decision_is_permanent;
QTimer timer;
int time_left;
quint32 device_id;
QString _name;
QString _serial;
QString _device_id;
QStringList _interface_types;
};
/* vim: set ts=2 sw=2 et */