Skip to content
API Documentation
BastionGuard™
AboutPage Class Reference

#include <AboutPage.hpp>

Inheritance diagram for AboutPage:

Public Member Functions

 AboutPage ()
 AboutPage ()

Private Member Functions

std::pair< std::string, std::string > load_version_build ()
std::string load_license_text ()
std::string load_database_info ()
void buildContent ()

Private Attributes

Gtk::Notebook notebook_

Detailed Description

Definition at line 26 of file AboutPage.hpp.

Constructor & Destructor Documentation

◆ AboutPage() [1/2]

AboutPage::AboutPage ( )

Definition at line 70 of file AboutPage.cpp.

70 : Gtk::Box(Gtk::Orientation::VERTICAL) {
71 set_margin(12);
72
73 // Notebook con i tab
74 append(notebook_);
75
76 // ===== Tab Programma =====
77 auto box_program = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
78
79 // Icona
80 auto picture_icon = Gtk::make_managed<Gtk::Picture>();
81 try {
82 picture_icon->set_file(Gio::File::create_for_path(resource("logo.png")));
83 picture_icon->set_size_request(64, 64);
84 } catch (...) {
85 // fallback se l’icona non esiste
86 }
87 picture_icon->set_halign(Gtk::Align::CENTER);
88 box_program->append(*picture_icon);
89
90 // Nome programma
91 auto [version, build] = load_version_build();
92
93 auto label_name = Gtk::make_managed<Gtk::Label>();
94 label_name->set_use_markup(true);
95 label_name->set_halign(Gtk::Align::CENTER);
96
97 label_name->set_markup(
98 Glib::ustring::compose(
99 "<b>BastionGuard™ Endpoint</b> "
100 "<span size='medium'><i>%1 · build %2</i></span>",
101 version,
102 build
103 )
104 );
105
106
107 box_program->append(*label_name);
108
109 // Copyright
110 auto label_copy = Gtk::make_managed<Gtk::Label>();
111 label_copy->set_use_markup(true);
112 std::time_t t = std::time(nullptr);
113 std::tm tm{};
114 localtime_r(&t, &tm);
115
116 int year = tm.tm_year + 1900;
117 std::string year_str = std::to_string(year);
118 label_copy->set_markup(
119 Glib::ustring::compose(
120 _("© 2025-%1 Calogero Scarnà — BastionGuard™\n"
121 "BastionGuard è stato depositato il 16/12/2025 presso UIBM (Italia) con il numero 302025000196519.\n"
122 "Il motore anti-ransomware e anti-phishing è parte integrante della piattaforma di sicurezza.\n"
123 "Il sistema include la scansione delle periferiche USB,\n"
124 "scansione delle cartelle samba\n"
125 "e le funzionalità di blocco di microfono e webcam.\n"
126 "La protezione comprende la scansione in tempo reale con inotify.\n"
127 "ClamAV® è un marchio registrato da Cisco\n"
128 "%2\n"),
129 year_str,
130 "<a href='https://www.codelinsoft.it' title='Visita CodeLinSoft'>"
131 "Powered by <b>CodeLinSoft</b></a>"
132 )
133 );
134
135
136 label_copy->set_halign(Gtk::Align::CENTER);
137 label_copy->set_justify(Gtk::Justification::CENTER);
138 label_copy->set_wrap(true);
139 box_program->append(*label_copy);
140
141
142 notebook_.append_page(*box_program, _("Programma"));
143
144 // ===== Tab Terze Parti =====
145 auto box_thirdparty = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
146 Glib::ustring thirdparty_text =
147 _("Questa applicazione utilizza:\n"
148 "- ClamAV Antivirus Engine\n"
149 "- GTK4 / gtkmm-4\n"
150 "- Image / libpng\n"
151 "- Rules / yara\n"
152 "- Udev\n"
153 "- Libudev\n"
154 "- Nginx\n"
155 "- php\n"
156 "- Sigc++\n"
157 "- Libsecret\n"
158 "- IDN2\n"
159 "- SQLITE3\n"
160 "- HYPERSCAN\n"
161 "- RE2\n"
162 "- Polkit\n"
163 "- Nlohmann_json\n"
164 "- DNSmasq /blocco pagine\n"
165 "- Antiphishing server/ libsoup\n");
167 thirdparty_text += _("- Sandbox bancario/ chromium sandbox (CEF)\n");
168 }
169 thirdparty_text += _("- MISP lista per le banche\n");
170
171 auto label_thirdparty = Gtk::make_managed<Gtk::Label>(thirdparty_text);
172 label_thirdparty->set_wrap(true);
173 box_thirdparty->append(*label_thirdparty);
174 notebook_.append_page(*box_thirdparty, _("Terze Parti"));
175
176 // ===== Tab Licenza =====
177 auto box_license = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
178
179 auto sw = Gtk::make_managed<Gtk::ScrolledWindow>();
180 sw->set_expand(true);
181 sw->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
182
183 auto tv = Gtk::make_managed<Gtk::TextView>();
184 tv->set_editable(false);
185 tv->set_wrap_mode(Gtk::WrapMode::WORD);
186
187 auto buf = Gtk::TextBuffer::create();
188 buf->set_text(load_license_text());
189 tv->set_buffer(buf);
190
191 sw->set_child(*tv);
192 box_license->append(*sw);
193
194 notebook_.append_page(*box_license, _("Licenza"));
195
196 // ===== Tab Database =====
197 auto box_db = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
198
199 auto swdb = Gtk::make_managed<Gtk::ScrolledWindow>();
200 swdb->set_expand(true);
201 swdb->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
202
203 auto tvdb = Gtk::make_managed<Gtk::TextView>();
204 tvdb->set_editable(false);
205 tvdb->set_wrap_mode(Gtk::WrapMode::WORD);
206
207 auto bufdb = Gtk::TextBuffer::create();
208 bufdb->set_text(load_database_info());
209 tvdb->set_buffer(bufdb);
210
211 swdb->set_child(*tvdb);
212 box_db->append(*swdb);
213
214 notebook_.append_page(*box_db, _("Database"));
215
216}
#define _(s)
std::string load_license_text()
std::pair< std::string, std::string > load_version_build()
Definition AboutPage.cpp:39
Gtk::Notebook notebook_
Definition AboutPage.hpp:31
std::string load_database_info()
std::string resource(const std::string &rel)
Definition Resource.hpp:31

References _, BastionGuard::Platform::cef_available(), load_database_info(), load_license_text(), load_version_build(), notebook_, and resource().

◆ AboutPage() [2/2]

AboutPage::AboutPage ( )

References buildContent().

Member Function Documentation

◆ buildContent()

void AboutPage::buildContent ( )
private

Definition at line 20 of file AboutPage.cpp.

21{
22 set_valign(Gtk::Align::CENTER);
23 set_halign(Gtk::Align::CENTER);
24 set_spacing(16);
25 set_margin_top(40);
26 set_margin_bottom(40);
27 set_margin_start(40);
28 set_margin_end(40);
29
30 {
31 bool loaded = false;
32 auto pic = Gtk::make_managed<Gtk::Picture>();
33 try {
34 auto tex = Gdk::Texture::create_from_filename(resource("logo-sidebar.png"));
35 pic->set_paintable(tex);
36 pic->set_content_fit(Gtk::ContentFit::CONTAIN);
37 pic->set_size_request(128, 128);
38 pic->set_halign(Gtk::Align::CENTER);
39 pic->set_valign(Gtk::Align::CENTER);
40 append(*pic);
41 loaded = true;
42 } catch (...) {}
43
44 if (!loaded) {
45 auto img = Gtk::make_managed<Gtk::Image>();
46 img->set_from_icon_name("security-high-symbolic");
47 img->set_pixel_size(128);
48 img->set_halign(Gtk::Align::CENTER);
49 img->set_valign(Gtk::Align::CENTER);
50 append(*img);
51 }
52 }
53
54 auto appName = Gtk::make_managed<Gtk::Label>();
55 appName->set_markup("<span size='xx-large' weight='bold'>BastionGuard™ Secure Connection</span>");
56 appName->set_halign(Gtk::Align::CENTER);
57 append(*appName);
58
59 auto version = Gtk::make_managed<Gtk::Label>();
60 version->set_markup(
61 "<span size='large' alpha='70%'>" +
62 Glib::ustring(_("Versione")) + " " +
63 Glib::ustring(BG_SECURE_CONNECTION_VERSION) +
64 "</span>");
65 version->set_halign(Gtk::Align::CENTER);
66 append(*version);
67
68 auto sep = Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::HORIZONTAL);
69 sep->set_margin_top(8);
70 sep->set_margin_bottom(8);
71 append(*sep);
72
73 auto desc = Gtk::make_managed<Gtk::Label>(
74 _("Firewall applicativo interattivo per Linux.\n"
75 "Monitora e controlla le connessioni di rete per ogni applicazione."));
76 desc->set_halign(Gtk::Align::CENTER);
77 desc->set_justify(Gtk::Justification::CENTER);
78 desc->set_wrap(true);
79 desc->set_max_width_chars(60);
80 append(*desc);
81
82
83 auto author = Gtk::make_managed<Gtk::Label>();
84 author->set_markup(Glib::ustring("<b>") + _("Autore") + ":</b> Calogero Scarnà");
85 author->set_halign(Gtk::Align::CENTER);
86 append(*author);
87
88 auto license = Gtk::make_managed<Gtk::Label>();
89 license->set_markup(Glib::ustring("<b>") + _("Licenza") + ":</b> GNU General Public License v3.0");
90 license->set_halign(Gtk::Align::CENTER);
91 append(*license);
92
93 auto ghBox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 8);
94 ghBox->set_halign(Gtk::Align::CENTER);
95
96 auto ghBtn = Gtk::make_managed<Gtk::LinkButton>(
97 "https://git.bastionguard.eu/specialworld83/bastionguard-secure-connection",
98 _("Sorgenti su GitHub"));
99 ghBox->append(*ghBtn);
100 append(*ghBox);
101
102 auto copy = Gtk::make_managed<Gtk::Label>();
103 copy->set_markup("<small>Copyright © 2025–2026 Calogero Scarnà</small>");
104 copy->set_halign(Gtk::Align::CENTER);
105 copy->set_margin_top(12);
106 append(*copy);
107}

References _, and resource().

Referenced by AboutPage().

◆ load_database_info()

std::string AboutPage::load_database_info ( )
private

Definition at line 247 of file AboutPage.cpp.

247 {
248 namespace fs = std::filesystem;
249 const std::string path = "/var/lib/clamav";
250
251 if (!fs::exists(path))
252 return _("Directory /var/lib/clamav non trovata.\n");
253
254 std::stringstream out;
255 out << _("📁 Database ClamAV trovati in /var/lib/clamav\n\n");
256
257 for (const auto& entry : fs::directory_iterator(path)) {
258 auto file = entry.path().filename().string();
259
260 if (file.ends_with(".hdb") || file.ends_with(".ndb") ||
261 file.ends_with(".ldb") || file.ends_with(".cdb") ||
262 file.ends_with(".hsb") || file.ends_with(".fp")) {
263
264 out << "✔ " << file << "\n";
265 }
266 else if (file.ends_with(".cld") || file.ends_with(".cvd")) {
267 out << "🔒 " << file << _(" (database ufficiale ClamAV)\n");
268 }
269 else {
270
271 out << "• " << file << "\n";
272 }
273 }
274
275
276 return out.str();
277}

References _.

Referenced by AboutPage().

◆ load_license_text()

std::string AboutPage::load_license_text ( )
private

Definition at line 219 of file AboutPage.cpp.

219 {
220 namespace fs = std::filesystem;
221
222 std::vector<std::string> candidates = {
223 "data/license/COPYING",
224 "/usr/share/BastionGuard/data/license/COPYING",
225 "COPYING",
226 "LICENSE",
227 "/usr/share/doc/BastionGuard/COPYING",
228 "/usr/share/common-licenses/GPL-3"
229 };
230
231 for (const auto& path : candidates) {
232 if (fs::exists(path)) {
233 std::ifstream f(path);
234 if (f.is_open()) {
235 std::stringstream buf;
236 buf << f.rdbuf();
237 return buf.str();
238 }
239 }
240 }
241
242 return _("GNU GPL v3 license text not found.\n"
243 "Assicurati che il file COPYING sia incluso nel progetto "
244 "o che la tua distribuzione fornisca /usr/share/common-licenses/GPL-3.");
245}

References _.

Referenced by AboutPage().

◆ load_version_build()

std::pair< std::string, std::string > AboutPage::load_version_build ( )
private

Definition at line 39 of file AboutPage.cpp.

39 {
40 namespace fs = std::filesystem;
41
42 std::string version = "?.?";
43 std::string build = "?";
44
45 const std::string path = "/usr/share/BastionGuard/data/version.bs";
46
47 if (!fs::exists(path))
48 return {version, build};
49
50 std::ifstream file(path);
51 if (!file.is_open())
52 return {version, build};
53
54 std::string line;
55 while (std::getline(file, line)) {
56 line.erase(0, line.find_first_not_of(" \t"));
57 line.erase(line.find_last_not_of(" \t") + 1);
58
59 if (line.starts_with("version="))
60 version = line.substr(8);
61 else if (line.starts_with("build="))
62 build = line.substr(6);
63 }
64
65 return {version, build};
66}

Referenced by AboutPage().

Member Data Documentation

◆ notebook_

Gtk::Notebook AboutPage::notebook_
private

Definition at line 31 of file AboutPage.hpp.

Referenced by AboutPage().


The documentation for this class was generated from the following files: