Skip to content
API Documentation
BastionGuard™
BastionGuard-ransomware-alert.cpp File Reference

Go to the source code of this file.

Classes

class  AlertWindow
class  AlertApp

Functions

static std::string resolve_theme_css ()
static bool load_lang_conf ()
int main (int argc, char *argv[])

Variables

const char introspection_xml []

Function Documentation

◆ load_lang_conf()

bool load_lang_conf ( )
static

Definition at line 305 of file BastionGuard-ransomware-alert.cpp.

306{
307 const std::string lang_conf = Glib::get_home_dir() + "/.config/BastionGuard/lang.conf";
308 std::ifstream f(lang_conf);
309 if (!f.is_open())
310 return false;
311
312 std::string line;
313 bool any = false;
314
315 while (std::getline(f, line)) {
316 if (line.empty() || line[0] == '#')
317 continue;
318
319 auto pos = line.find('=');
320 if (pos == std::string::npos)
321 continue;
322
323 std::string key = line.substr(0, pos);
324 std::string val = line.substr(pos + 1);
325
326 // trim minimo (spazi attorno)
327 auto ltrim = [](std::string& s){
328 s.erase(0, s.find_first_not_of(" \t\r\n"));
329 };
330 auto rtrim = [](std::string& s){
331 s.erase(s.find_last_not_of(" \t\r\n") + 1);
332 };
333 ltrim(key); rtrim(key);
334 ltrim(val); rtrim(val);
335
336 if (!key.empty() && !val.empty()) {
337 setenv(key.c_str(), val.c_str(), 1);
338 any = true;
339 }
340 }
341
342 return any;
343}

References load_lang_conf().

Referenced by load_lang_conf(), load_lang_conf(), load_lang_conf(), load_lang_conf(), load_lang_conf(), load_lang_conf(), load_lang_conf(), load_lang_conf(), main(), and main().

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 345 of file BastionGuard-ransomware-alert.cpp.

345 {
346 bool loaded = load_lang_conf();
347 std::setlocale(LC_ALL, "");
348 bindtextdomain("BastionGuard", LOCALEDIR);
349 bind_textdomain_codeset("BastionGuard", "UTF-8");
350 textdomain("BastionGuard");
351 if (loaded) {
352 std::cerr << _("[Lang] Config caricata da ~/.config/BastionGuard/lang.conf") << "\n";
353 } else {
354 std::cerr << _("[Lang] Nessuna config trovata, uso locale di sistema") << "\n";
355 }
356 AlertApp app;
357 return app.run(argc, argv);
358}
#define _(s)
static bool load_lang_conf()
#define LOCALEDIR
int run(int argc, char *argv[])

References _, load_lang_conf(), LOCALEDIR, main(), and AlertApp::run().

Referenced by main(), main(), main(), main(), main(), MainWindow::MainWindow(), and SecureBrowser::open().

◆ resolve_theme_css()

std::string resolve_theme_css ( )
static

Definition at line 39 of file BastionGuard-ransomware-alert.cpp.

39 {
40 const std::string conf =
41 Glib::get_home_dir() + "/.config/BastionGuard/theme.conf";
42 std::ifstream tf(conf);
43 std::string theme;
44 if (tf >> theme && theme == "dark")
45 return "BastionGuard-dark.css";
46 return "BastionGuard.css";
47}

References resolve_theme_css().

Referenced by AlertWindow::AlertWindow().

Variable Documentation

◆ introspection_xml

const char introspection_xml[]
Initial value:
=
"<node>"
" <interface name='org.BastionGuard.Ransomware.Alert'>"
" <method name='ShowAlert'>"
" <arg type='s' direction='in'/>"
" <arg type='s' direction='in'/>"
" </method>"
" </interface>"
"</node>"

Definition at line 191 of file BastionGuard-ransomware-alert.cpp.

Referenced by AlertApp::run().