Skip to content
API Documentation
BastionGuard™
PrivacyPage.hpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#pragma once
22
23#include <gtkmm.h>
24#include <thread>
25#include <atomic>
26#include <vector>
27#include <string>
28#include <set>
29#include <queue>
30#include <filesystem>
31
32#include "LifetimeGuard.hpp"
33
34class PrivacyPage : public Gtk::Box {
35public:
38
39private:
40
41 Gtk::Label lbl_title_;
42 Gtk::Switch switch_webcam_;
43 Gtk::Button btn_refresh_;
44 Gtk::CheckButton chk_auto_refresh_;
45 Gtk::ScrolledWindow scroller_;
46 Gtk::TextView txt_processes_;
47 Gtk::Label lbl_status_;
48
49
50 std::thread monitor_thread_;
51 std::atomic<bool> monitor_running_{false};
52 std::set<std::string> known_processes_;
53 sigc::connection auto_refresh_conn_;
54
55 void run_privacy_script_async(bool unblock);
56
57
58 std::atomic<bool> toggle_busy_{false};
59
60
61 bool is_daemon_active();
64
65
66 void save_privacy_state(bool enabled);
67 bool load_privacy_state();
68
69
70 std::vector<std::string> detect_active_devices();
72 void monitor_loop();
73
74
75 void show_permission_popup(const std::string &process_name);
76 void show_next_alert();
77
78
79 void on_toggle_privacy();
80 void on_refresh_clicked();
83 Gtk::Button btn_unlock_;
84 std::atomic<bool> devices_blocked_{false};
86
87 void write_log(const std::string& msg);
88
89 // Alive flag per proteggere i molti signal_idle().connect_once con
90 // [this] da use-after-free se la pagina viene distrutta prima che
91 // il main loop processi la coda di idle callbacks.
93};
std::vector< std::string > detect_active_devices()
void monitor_loop()
void write_log(const std::string &msg)
std::atomic< bool > toggle_busy_
BastionGuard::AliveFlag alive_
bool load_privacy_state()
std::atomic< bool > devices_blocked_
void start_monitor_thread()
Gtk::TextView txt_processes_
void on_toggle_privacy()
void show_permission_popup(const std::string &process_name)
void save_privacy_state(bool enabled)
Gtk::Switch switch_webcam_
Gtk::Button btn_unlock_
Gtk::Button btn_refresh_
sigc::connection auto_refresh_conn_
void run_privacy_script_async(bool unblock)
void show_next_alert()
Gtk::Label lbl_title_
Gtk::ScrolledWindow scroller_
void unblock_devices_local()
void update_process_list()
std::atomic< bool > monitor_running_
std::thread monitor_thread_
std::set< std::string > known_processes_
void on_refresh_clicked()
Gtk::Label lbl_status_
void start_privacy_daemon()
Gtk::CheckButton chk_auto_refresh_
void setup_auto_refresh_toggle()
void manual_unlock_devices()
bool is_daemon_active()
std::shared_ptr< std::atomic< bool > > AliveFlag
AliveFlag make_alive_flag()