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
//! Anti-idle keep-alive settings — prevents SSH/connection timeouts.
use crate::SettingsUI;
use crate::section::collapsing_section;
use std::collections::HashSet;
pub(super) fn show_anti_idle_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"Anti-Idle Keep-Alive",
"notifications_anti_idle",
false,
collapsed,
|ui| {
ui.label(
"Prevents SSH and connection timeouts by periodically sending invisible characters.",
);
ui.add_space(4.0);
if ui
.checkbox(
&mut settings.config.notifications.anti_idle_enabled,
"Send code when idle",
)
.on_hover_text("Periodically send a character to keep connections alive")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
ui.horizontal(|ui| {
ui.label("Seconds before sending:");
if ui
.add(
egui::DragValue::new(&mut settings.config.notifications.anti_idle_seconds)
.range(10..=3600)
.speed(1.0),
)
.on_hover_text("How long to wait before sending keep-alive (10-3600 seconds)")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
ui.horizontal(|ui| {
ui.label("Character to send:");
egui::ComboBox::from_id_salt("notifications_anti_idle_code")
.selected_text(match settings.config.notifications.anti_idle_code {
0 => "NUL (0x00)",
5 => "ENQ (0x05)",
27 => "ESC (0x1B)",
32 => "Space (0x20)",
_ => "Custom",
})
.show_ui(ui, |ui| {
if ui
.selectable_value(
&mut settings.config.notifications.anti_idle_code,
0,
"NUL (0x00) - Null character, most common",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.selectable_value(
&mut settings.config.notifications.anti_idle_code,
27,
"ESC (0x1B) - Escape, safe for most apps",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.selectable_value(
&mut settings.config.notifications.anti_idle_code,
5,
"ENQ (0x05) - Enquiry, may trigger answerback",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.selectable_value(
&mut settings.config.notifications.anti_idle_code,
32,
"Space (0x20) - Visible but harmless",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
});
ui.horizontal(|ui| {
ui.label("Custom ASCII code:");
if ui
.add(
egui::DragValue::new(&mut settings.config.notifications.anti_idle_code)
.range(0..=127)
.speed(1.0),
)
.on_hover_text("ASCII code (0-127) to send as keep-alive")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
ui.label(format!(
"(0x{:02X})",
settings.config.notifications.anti_idle_code
));
});
},
);
}