Skip to content
API Documentation
BastionGuard™
UpdatePage.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
28struct SourceItem {
29 std::string name;
30 std::string url;
31 std::string username;
32 std::string secret_key;
33 bool requires_auth = false;
34};
35
36class UpdatePage : public Gtk::Box {
37public:
38 UpdatePage();
40 void updateSaneSecurity();
41private:
42 Gtk::Button updateButton;
43 Gtk::Switch serviceSwitch;
44 Gtk::Label sourcesLabel;
46 Gtk::TextView outputView;
47 Glib::RefPtr<Gtk::TextBuffer> buffer;
48 Gtk::Notebook* sourcesNotebook = nullptr;
49 Gtk::Box* sourcesBox = nullptr;
50 Gtk::Switch saneAutoSwitch;
51 bool checkSaneTimer();
52 void onSaneAutoToggled();
53 void onUpdateClicked();
54 void onServiceToggled();
55 void onAddSourceClicked();
58
59 bool checkServiceStatus();
60 void loadSources();
61 void saveSources();
62 void createSourceRow(const SourceItem& src = {});
63 void testConnection(const std::string& name, const std::string& url, bool auth, const std::string& user);
64 void logSafe(const std::string& msg);
65 std::string generateSecretKey();
66 std::string lookupPassword(const std::string& key);
67 bool storePassword(const std::string& key, const std::string& password);
68
70};
std::string lookupPassword(const std::string &key)
void updateFromExtraSources()
Gtk::Button addSourceButton
BastionGuard::AliveFlag alive_
bool checkServiceStatus()
void onSaneAutoToggled()
void onSaveSourcesClicked()
Gtk::Box * sourcesBox
void createSourceRow(const SourceItem &src={})
Gtk::Button saveSourcesButton
Glib::RefPtr< Gtk::TextBuffer > buffer
void onAddSourceClicked()
void logSafe(const std::string &msg)
void updateSaneSecurity()
bool checkSaneTimer()
Gtk::Label sourcesLabel
void saveSources()
std::string generateSecretKey()
void onServiceToggled()
bool storePassword(const std::string &key, const std::string &password)
Gtk::TextView outputView
Gtk::Switch serviceSwitch
Gtk::Notebook * sourcesNotebook
Gtk::Switch saneAutoSwitch
void loadSources()
void onUpdateClicked()
Gtk::Button updateButton
void testConnection(const std::string &name, const std::string &url, bool auth, const std::string &user)
std::shared_ptr< std::atomic< bool > > AliveFlag
AliveFlag make_alive_flag()
std::string url
std::string secret_key
std::string username
bool requires_auth
std::string name