blob: 0687c8a6f6f1494d639e42a3abd8e9a43f67ffe6 (
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
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
|
#include "permissionmanager.hpp"
PermissionManager::PermissionManager(std::string path)
: path(path)
{
if (std::filesystem::exists(this->path)) {
std::ifstream in(path);
std::string content;
in >> this->_lock_mouse;
in >> this->_location;
in >> this->_notification;
in >> this->_media_audio_capture;
in >> this->_media_video_capture;
in >> this->_desktop_video_capture;
in >> this->_desktop_audio_video_capture;
}
}
PermissionManager::~PermissionManager()
{
this->save();
}
void
PermissionManager::save()
{
std::ofstream out(this->path);
out << this->_lock_mouse;
out << this->_location;
out << this->_notification;
out << this->_media_audio_capture;
out << this->_media_video_capture;
out << this->_desktop_video_capture;
out << this->_desktop_audio_video_capture;
}
bool
PermissionManager::get(QWebEnginePage::Feature feature)
{
switch (feature) {
case QWebEnginePage::Feature::MouseLock:
return this->_lock_mouse;
case QWebEnginePage::Feature::Geolocation:
return this->_location;
case QWebEnginePage::Feature::Notifications:
return this->_notification;
case QWebEnginePage::Feature::MediaAudioCapture:
return this->_media_audio_capture;
case QWebEnginePage::Feature::MediaVideoCapture:
return this->_media_video_capture;
case QWebEnginePage::Feature::MediaAudioVideoCapture:
return this->_media_video_capture && this->_media_audio_capture;
case QWebEnginePage::Feature::DesktopVideoCapture:
return this->_desktop_video_capture;
case QWebEnginePage::Feature::DesktopAudioVideoCapture:
return this->_desktop_audio_video_capture;
default:
/* unreachable except QWebEnginePage::Feature gets new entries */
return false;
}
}
void
PermissionManager::set(QWebEnginePage::Feature feature, bool value)
{
switch (feature) {
case QWebEnginePage::Feature::MouseLock:
this->_lock_mouse = value;
break;
case QWebEnginePage::Feature::Geolocation:
this->_location = value;
break;
case QWebEnginePage::Feature::Notifications:
this->_notification = value;
break;
case QWebEnginePage::Feature::MediaAudioCapture:
this->_media_audio_capture = value;
break;
case QWebEnginePage::Feature::MediaVideoCapture:
this->_media_video_capture = value;
break;
case QWebEnginePage::Feature::MediaAudioVideoCapture:
this->_media_audio_capture = value;
this->_media_video_capture = value;
break;
case QWebEnginePage::Feature::DesktopVideoCapture:
this->_desktop_video_capture = value;
break;
case QWebEnginePage::Feature::DesktopAudioVideoCapture:
this->_desktop_audio_video_capture = value;
break;
}
}
|