Skip to content
API Documentation
BastionGuard™
wizard_window.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
22#pragma once
23#include <gtkmm.h>
24#include <filesystem>
25#include <string>
26#include <thread>
27#include <mutex>
28#include <vector>
29
30namespace BastionGuard::wizard {
31
32class WizardWindow : public Gtk::Window {
33public:
35 ~WizardWindow() override;
36
37 sigc::signal<void()> signal_finished();
38
39private:
40
41 void build_headerbar();
42 void build_sidebar(Gtk::Box& mainBox);
43 void build_pages();
44 void set_page(int idx);
45 void update_nav();
46
47 void on_next();
48 void on_back();
49 void on_cancel();
50 void on_finish();
51
52
53 void append_log(const Glib::ustring& line);
54
55 void start_execution();
56 void worker_run();
57 void finish_execution(bool ok);
58 bool install_native_host(const std::string& src_host,
59 const std::string& extension_id);
60 bool apply_web_config();
61 bool configure_dnsmasq();
62
63 bool write_config_file();
66 bool run_net_setup();
70
71 bool is_firewall_active();
73 void append_dnsmasq_log(const Glib::ustring& line);
74 Gtk::ComboBoxText m_combo_os;
77 Gtk::Button m_btn_apply_web;
78 Gtk::Box m_pg_web;
79 Gtk::Label m_desc_web;
80 Gtk::CheckButton m_chk_webconf;
82
83 Gtk::Box m_pg_banks;
84 Gtk::Label m_desc_banks;
85 Gtk::CheckButton m_chk_download_banks;
88 Gtk::Box m_pg_dnsmasq;
89 Gtk::Label m_desc_dnsmasq;
90 Gtk::CheckButton m_chk_dnsmasq;
91
92 Gtk::ScrolledWindow m_log_scroll_dnsmasq;
93 Gtk::TextView m_log_view_dnsmasq;
94 Glib::RefPtr<Gtk::TextBuffer> m_log_buf_dnsmasq;
95
96 std::string detect_distro() const;
97 std::string detect_webserver() const;
98 std::pair<int,int> read_current_ports(const std::string& websrv) const;
99 bool update_webserver_ports(const std::string& websrv, int http_port, int https_port);
101 bool updating_https = false;
102 bool updating_http = false;
103
104 Gtk::Box m_root;
105 Gtk::Stack m_stack;
106 Gtk::Box m_nav;
107
108 Gtk::Button m_btn_back;
109 Gtk::Button m_btn_next;
110 Gtk::Button m_btn_finish;
111 Gtk::Button m_btn_cancel;
112
113 Gtk::Box m_pg_welcome;
114 Gtk::Box m_pg_resolv;
117 Gtk::Box m_pg_certs;
118 Gtk::Box m_pg_native;
120 Gtk::Box m_pg_summary;
121
122 Gtk::Label m_label_welcome;
123 Gtk::Label m_desc_resolv;
124 Gtk::Label m_desc_firewall;
125 Gtk::Label m_desc_nftables;
126 Gtk::Label m_desc_certs;
127 Gtk::Label m_desc_native;
129
130 Gtk::CheckButton m_chk_resolv;
131 Gtk::CheckButton m_chk_firewall;
132 Gtk::CheckButton m_chk_enable_nftables;
133 Gtk::CheckButton m_chk_certs;
134 Gtk::CheckButton m_chk_native_host;
135 Gtk::CheckButton m_chk_useragent;
139 Gtk::ScrolledWindow m_log_scroll_nft;
140 Gtk::TextView m_log_view_nft;
141 Glib::RefPtr<Gtk::TextBuffer> m_log_buf_nft;
142
143 Gtk::Label m_label_summary;
144 Gtk::ScrolledWindow m_log_scroll;
145 Gtk::TextView m_log_view;
146 Glib::RefPtr<Gtk::TextBuffer> m_log_buf;
147
148 std::vector<Gtk::ToggleButton*> m_step_buttons;
149
150 sigc::signal<void()> m_signal_finished;
151
152 int m_page_idx = 0;
153 bool m_running = false;
154 std::thread m_worker;
155 Glib::Dispatcher m_dispatcher;
156 Glib::Dispatcher m_done_dispatcher;
157 std::mutex m_log_mutex;
158 std::vector<Glib::ustring> m_log_queue;
159 bool m_result_ok = false;
160
161 std::string config_dir;
162 std::string config_file;
163};
164
165} // namespace BastionGuard::wizard
std::pair< int, int > read_current_ports(const std::string &websrv) const
Gtk::ScrolledWindow m_log_scroll_dnsmasq
void build_sidebar(Gtk::Box &mainBox)
Glib::RefPtr< Gtk::TextBuffer > m_log_buf
bool update_webserver_ports(const std::string &websrv, int http_port, int https_port)
void append_log(const Glib::ustring &line)
Glib::RefPtr< Gtk::TextBuffer > m_log_buf_nft
std::vector< Gtk::ToggleButton * > m_step_buttons
bool install_native_host(const std::string &src_host, const std::string &extension_id)
std::vector< Glib::ustring > m_log_queue
sigc::signal< void()> signal_finished()
sigc::signal< void()> m_signal_finished
Glib::RefPtr< Gtk::TextBuffer > m_log_buf_dnsmasq
void append_dnsmasq_log(const Glib::ustring &line)