Skip to content
API Documentation
BastionGuard™
BankPage.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#include <gtkmm.h>
23#include <vector>
24#include <string>
25
26#include "LifetimeGuard.hpp"
27
28// forward
29class SecureBrowser;
30
31class BankPage : public Gtk::Box {
32public:
33 BankPage();
34 ~BankPage() override;
35
36private:
37 Gtk::Entry entry_url_;
38 Gtk::Button btn_refresh_;
41 Gtk::Entry whitelist_entry_;
42 Gtk::Button btn_add_whitelist_;
43 Gtk::ScrolledWindow scroller_banks_;
44 Gtk::ScrolledWindow scroller_white_;
45 Gtk::TextView txt_banks_;
46 Gtk::TextView txt_whitelist_;
47 Gtk::Label lbl_status_;
48
49 // === Apertura banca dentro sandbox bubblewrap ===
50 Gtk::Entry open_bank_entry_;
51 Gtk::Button btn_open_bank_;
52
53
54 std::vector<std::string> whitelist_;
55 std::string selected_bank_url_;
57 sigc::connection auto_update_conn_;
58
59
60 void on_refresh_clicked();
65
66 // Apre l'URL banca dentro BastionGuard-secure (CEF + bwrap, Wayland o X11).
68 bool open_bank_in_sandbox(const std::string& url);
69
70 void populate_bank_list();
71 void load_whitelist();
72 void save_whitelist();
73
74 // === Auto aggiornamento ===
78 void load_settings();
79 void save_settings();
80
81 // === Helpers ===
82 static std::string user_data_dir();
83 static std::string banks_json_user();
84 static std::string banks_json_system();
85 static std::string whitelist_json_user();
86 static bool ensure_parent_dir(const std::string& path);
87 static bool download_url_to_file(const std::string& url, const std::string& dest);
88 static std::string extract_domain(const std::string& url);
89 static std::string clean_domain(const std::string& d);
90 void copy_banklist_to_system(const std::string& source_url);
91
93};
void on_add_whitelist_clicked()
Definition BankPage.cpp:376
void copy_banklist_to_system(const std::string &source_url)
Definition BankPage.cpp:263
static std::string banks_json_system()
Gtk::Entry whitelist_entry_
Definition BankPage.hpp:41
static std::string whitelist_json_user()
sigc::connection auto_update_conn_
Definition BankPage.hpp:57
Gtk::Label lbl_status_
Definition BankPage.hpp:47
Gtk::Entry open_bank_entry_
Definition BankPage.hpp:50
Gtk::ScrolledWindow scroller_white_
Definition BankPage.hpp:44
BastionGuard::AliveFlag alive_
Definition BankPage.hpp:92
void on_open_bank_clicked()
Definition BankPage.cpp:647
Gtk::Entry entry_url_
Definition BankPage.hpp:37
bool auto_update_bank_list()
Definition BankPage.cpp:570
Gtk::Label auto_update_label_
Definition BankPage.hpp:40
void stop_auto_update_timer()
Definition BankPage.cpp:563
std::vector< std::string > whitelist_
Definition BankPage.hpp:54
void start_auto_update_timer()
Definition BankPage.cpp:551
Gtk::Switch auto_update_switch_
Definition BankPage.hpp:39
void on_open_browser_clicked()
void load_whitelist()
Definition BankPage.cpp:404
std::string selected_bank_url_
Definition BankPage.hpp:55
void on_close_browser_clicked()
void save_settings()
Definition BankPage.cpp:624
static std::string clean_domain(const std::string &d)
void on_refresh_clicked()
Definition BankPage.cpp:232
static bool download_url_to_file(const std::string &url, const std::string &dest)
void populate_bank_list()
Definition BankPage.cpp:317
Gtk::TextView txt_banks_
Definition BankPage.hpp:45
Gtk::Button btn_add_whitelist_
Definition BankPage.hpp:42
bool auto_update_enabled_
Definition BankPage.hpp:56
Gtk::Button btn_open_bank_
Definition BankPage.hpp:51
static std::string user_data_dir()
bool merge_whitelist_into_banks_json()
Definition BankPage.cpp:467
static std::string extract_domain(const std::string &url)
Gtk::ScrolledWindow scroller_banks_
Definition BankPage.hpp:43
void load_settings()
Definition BankPage.cpp:602
void save_whitelist()
Definition BankPage.cpp:436
Gtk::TextView txt_whitelist_
Definition BankPage.hpp:46
static std::string banks_json_user()
static bool ensure_parent_dir(const std::string &path)
Gtk::Button btn_refresh_
Definition BankPage.hpp:38
bool open_bank_in_sandbox(const std::string &url)
Definition BankPage.cpp:665
std::shared_ptr< std::atomic< bool > > AliveFlag
AliveFlag make_alive_flag()