1. Overview
GTK settings page for enabling protection and inspecting system integration. It tracks the daemon service, autostart desktop entry, saved preference, and backup state, and emits a signal when the user requests a protection change.
File role: Implementation. The file contains 334 lines and belongs to the pages/SettingsPage.cpp path.
The companion file is pages/SettingsPage.hpp.
2. Component Responsibilities
- Implement the behavior declared by the corresponding header or entry-point contract.
- Build service and integration status cards
- Load the saved protection preference
- Check whether the systemd service is enabled
- Check primary and fallback autostart entries
- Display saved, service, autostart, and backup status
- Emit the requested protection state when the user applies changes
3. Dependencies and Integration
Project-level dependencies:
SettingsPage.hppglibmm/i18n.hglibmm/miscutils.hglibmm/markup.h
System and library dependencies:
cstdlibfilesystemfstream
4. Constants and Fixed Configuration
The file declares or uses the following fixed values:
constexpr const char* kServiceName = "bsc-daemon.service";
constexpr const char* kAutostartPath = "/etc/xdg/autostart/bastionguard-sc-autostart.desktop";
constexpr const char* kFallbackAutostartPath = "/etc/xdg/autostart/bastionguard-sc.desktop";
constexpr const char* kAutostartBackupPath = "/etc/xdg/autostart/bastionguard-sc-autostart.desktop.bak";
5. Signals and Event Integration
The file exposes or connects the following signal-related elements:
m_enableSwitch.property_active().signal_changed().connect([this]() {m_applyButton.signal_clicked().connect([this]() {m_refreshButton.signal_clicked().connect([this]() {
GTK-facing callbacks must execute on the main UI context. Components with worker threads use dispatchers or idle callbacks to cross the thread boundary.
6. Functions and Methods
The file exposes or implements 10 detected function or method signatures.
1. SettingsPage
SettingsPage::SettingsPage() : Gtk::Box(Gtk::Orientation::VERTICAL, 0), m_applyButton(_("Applica")), m_refreshButton(_("Aggiorna stato"))
Updates settings page and synchronizes dependent state.
2. setProtectionEnabled
void SettingsPage::setProtectionEnabled(bool enabled)
Updates protection enabled and synchronizes dependent state.
3. setSystemIntegrationStatus
void SettingsPage::setSystemIntegrationStatus(const std::string& text)
Updates system integration status and synchronizes dependent state.
4. buildUi
void SettingsPage::buildUi()
Builds and configures the ui user-interface or internal structure.
5. loadPreference
void SettingsPage::loadPreference()
Loads preference from its persistent or runtime source.
6. serviceEnabled
bool SettingsPage::serviceEnabled() const
Implements the service enabled operation declared by this component.
7. autostartInstalled
bool SettingsPage::autostartInstalled() const
Implements the autostart installed operation declared by this component.
8. backupExists
bool SettingsPage::backupExists() const
Implements the backup exists operation declared by this component.
9. boolText
std::string SettingsPage::boolText(bool value)
Implements the bool text operation declared by this component.
10. refreshState
void SettingsPage::refreshState()
Refreshes state from the authoritative system state.
7. Filesystem, IPC, Network, and Command Interfaces
Relevant literal paths, endpoints, or resource locations include:
/etc/xdg/autostart/bastionguard-sc-autostart.desktop/etc/xdg/autostart/bastionguard-sc.desktop/etc/xdg/autostart/bastionguard-sc-autostart.desktop.bak/bastionguard-sc/service-control.ini
Relevant command or protocol construction lines include:
std::string("systemctl is-enabled ") + kServiceName + " >/dev/null 2>&1";
8. Runtime Flow
- Build service and integration status cards
- Load the saved protection preference
- Check whether the systemd service is enabled
- Check primary and fallback autostart entries
- Display saved, service, autostart, and backup status
- Emit the requested protection state when the user applies changes
9. Runtime and Security Considerations
- Separates saved preference from actual system service state.
- Checks whether an autostart backup exists before reporting integration health.
- Exposes a signal to the controller instead of directly owning all privileged changes.
10. Error Handling and Operational Notes
- Errors are propagated through the return type, callbacks, or the owning controller.
11. Source Integrity
Relative source path: pages/SettingsPage.cpp
SHA-256:
7cc739d97c4c73a8e6615998acd68337051eaf22d93f433b770b6b601606996c
12. Licensing
No standalone license block is present in this file. Licensing follows the surrounding BastionGuard Secure Connection project and its accompanying source notices.
