70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
/*
|
|
* BastionGuard™
|
|
* Copyright (C) 2025–2026 Calogero Scarnà
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, version 3.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* BastionGuard™ is a trademark of Calogero Scarnà.
|
|
* The BastionGuard™ name and branding are not licensed under the GPL.
|
|
*/
|
|
|
|
#pragma once
|
|
#include <gtkmm.h>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
#include "LifetimeGuard.hpp"
|
|
|
|
struct SourceItem {
|
|
std::string name;
|
|
std::string url;
|
|
std::string username;
|
|
std::string secret_key;
|
|
bool requires_auth = false;
|
|
};
|
|
|
|
class UpdatePage : public Gtk::Box {
|
|
public:
|
|
UpdatePage();
|
|
~UpdatePage();
|
|
void updateSaneSecurity();
|
|
private:
|
|
Gtk::Button updateButton;
|
|
Gtk::Switch serviceSwitch;
|
|
Gtk::Label sourcesLabel;
|
|
Gtk::Button addSourceButton, saveSourcesButton;
|
|
Gtk::TextView outputView;
|
|
Glib::RefPtr<Gtk::TextBuffer> buffer;
|
|
Gtk::Notebook* sourcesNotebook = nullptr;
|
|
Gtk::Box* sourcesBox = nullptr;
|
|
Gtk::Switch saneAutoSwitch;
|
|
bool checkSaneTimer();
|
|
void onSaneAutoToggled();
|
|
void onUpdateClicked();
|
|
void onServiceToggled();
|
|
void onAddSourceClicked();
|
|
void onSaveSourcesClicked();
|
|
void updateFromExtraSources();
|
|
|
|
bool checkServiceStatus();
|
|
void loadSources();
|
|
void saveSources();
|
|
void createSourceRow(const SourceItem& src = {});
|
|
void testConnection(const std::string& name, const std::string& url, bool auth, const std::string& user);
|
|
void logSafe(const std::string& msg);
|
|
std::string generateSecretKey();
|
|
std::string lookupPassword(const std::string& key);
|
|
bool storePassword(const std::string& key, const std::string& password);
|
|
|
|
BastionGuard::AliveFlag alive_ = BastionGuard::make_alive_flag();
|
|
};
|