BastionGuard/src/PrivacyPage.hpp
specialworld83 f0f913a209 Release 2.0
2026-07-15 10:52:22 +02:00

93 lines
2.4 KiB
C++

/*
* BastionGuard™
* Copyright (C) 2025–2026 Calogero Scarnà
*
* 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, version 3.
*
* 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 <https://www.gnu.org/licenses/>.
*
* BastionGuard™ is a trademark of Calogero Scarnà.
* The BastionGuard™ name and branding are not licensed under the GPL.
*/
#pragma once
#include <gtkmm.h>
#include <thread>
#include <atomic>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <filesystem>
#include "LifetimeGuard.hpp"
class PrivacyPage : public Gtk::Box {
public:
PrivacyPage();
~PrivacyPage();
private:
Gtk::Label lbl_title_;
Gtk::Switch switch_webcam_;
Gtk::Button btn_refresh_;
Gtk::CheckButton chk_auto_refresh_;
Gtk::ScrolledWindow scroller_;
Gtk::TextView txt_processes_;
Gtk::Label lbl_status_;
std::thread monitor_thread_;
std::atomic<bool> monitor_running_{false};
std::set<std::string> known_processes_;
sigc::connection auto_refresh_conn_;
void run_privacy_script_async(bool unblock);
std::atomic<bool> toggle_busy_{false};
bool is_daemon_active();
void start_privacy_daemon();
void unblock_devices_local();
void save_privacy_state(bool enabled);
bool load_privacy_state();
std::vector<std::string> detect_active_devices();
void start_monitor_thread();
void monitor_loop();
void show_permission_popup(const std::string &process_name);
void show_next_alert();
void on_toggle_privacy();
void on_refresh_clicked();
void setup_auto_refresh_toggle();
void update_process_list();
Gtk::Button btn_unlock_;
std::atomic<bool> devices_blocked_{false};
void manual_unlock_devices();
void write_log(const std::string& msg);
// Alive flag per proteggere i molti signal_idle().connect_once con
// [this] da use-after-free se la pagina viene distrutta prima che
// il main loop processi la coda di idle callbacks.
BastionGuard::AliveFlag alive_ = BastionGuard::make_alive_flag();
};