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
use gtk::glib;
use crate::main::context::{SkContextDetail, SkContextDetailKind, SkContextDetailLevel};
use crate::main::flatpak::permissions::{PermissionDetails, SkPermissionSummary};
use crate::main::i18n::i18n;
#[glib::flags(name = "SkSubsystemPermission")]
pub enum SkSubsystemPermission {
#[flags_value(name = "none")]
NONE = 1 << 0,
#[flags_value(name = "unknown")]
UNKNOWN = 1 << 1,
#[flags_value(name = "network")]
NETWORK = 1 << 2,
#[flags_value(name = "ipc")]
IPC = 1 << 3,
}
impl PermissionDetails for SkSubsystemPermission {
fn summary(&self) -> SkPermissionSummary {
let mut summary = SkPermissionSummary::empty();
if self.contains(Self::NETWORK) {
summary |= SkPermissionSummary::NETWORK_ACCESS;
}
if self.contains(Self::UNKNOWN) {
summary |= SkPermissionSummary::UNKNOWN;
}
summary
}
fn context_details(&self) -> Vec<SkContextDetail> {
let mut details = Vec::new();
let icon_name = "network-wireless-symbolic";
let kind = SkContextDetailKind::Icon;
if self.contains(Self::NETWORK) {
let level = SkContextDetailLevel::Neutral;
let title = i18n("Network Access");
let description = i18n("Can access the internet / local network");
details.push(SkContextDetail::new(
kind,
icon_name,
level,
&title,
&description,
));
} else {
let level = SkContextDetailLevel::Good;
let title = i18n("No Network Access");
let description = i18n("Cannot access the internet / local network");
details.push(SkContextDetail::new(
kind,
icon_name,
level,
&title,
&description,
));
}
if self.contains(Self::UNKNOWN) {
let icon_name = "dialog-question-symbolic";
let level = SkContextDetailLevel::Bad;
let title = i18n("Access to Unknown Subsystem");
let description = i18n("Can access an unknown subsystem");
details.push(SkContextDetail::new(
kind,
icon_name,
level,
&title,
&description,
));
}
details
}
}
impl From<&str> for SkSubsystemPermission {
fn from(value: &str) -> Self {
match value {
"network" => Self::NETWORK,
"ipc" => Self::IPC,
_ => Self::UNKNOWN,
}
}
}