29 #ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H
30 #define GPGFRONTEND_GLOBALSETTINGSTATION_H
32 #include <sys/_types/_int64_t.h>
36 #include "GpgFrontendBuildInstallInfo.h"
37 #include "core/GpgFrontendCore.h"
38 #include "core/GpgFunctionObject.h"
67 libconfig::Setting &GetUISettings() noexcept;
75 T LookupSettings(std::
string path, T default_value) noexcept {
76 T value = default_value;
78 value =
static_cast<T
>(GetUISettings().lookup(path));
80 SPDLOG_WARN(
"setting not found: {}", path);
90 [[nodiscard]] std::filesystem::path
GetAppDir()
const {
return app_path_; }
92 [[nodiscard]] std::filesystem::path GetAppDataPath()
const {
93 return app_data_path_;
102 return app_log_path_;
111 auto db_path = app_configure_path_ /
"db";
112 if (!std::filesystem::exists(db_path)) {
113 std::filesystem::create_directory(db_path);
118 [[nodiscard]] std::filesystem::path GetAppConfigPath()
const {
119 return app_configure_path_;
128 return app_resource_path_ /
"gpg1.4" /
"gpg";
137 return app_locale_path_;
146 return app_resource_path_;
155 return app_resource_path_ /
"certs";
158 [[nodiscard]] std::string GetLogFilesSize()
const;
160 [[nodiscard]] std::string GetDataObjectsFilesSize()
const;
162 void ClearAllLogFiles()
const;
164 void ClearAllDataObjects()
const;
170 void SyncSettings() noexcept;
173 std::filesystem::path app_path_ = QCoreApplication::applicationDirPath()
175 std::filesystem::path app_data_path_ =
176 QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
178 std::filesystem::path app_log_path_ =
179 app_data_path_ / "logs";
180 std::filesystem::path app_data_objs_path_ =
181 app_data_path_ / "data_objs";
183 #ifdef LINUX_INSTALL_BUILD
184 std::filesystem::path app_resource_path_ =
185 std::filesystem::path(APP_LOCALSTATE_PATH) /
188 std::filesystem::path app_resource_path_ =
189 RESOURCE_DIR_BOOST_PATH(app_path_);
192 #ifdef LINUX_INSTALL_BUILD
193 std::filesystem::path app_locale_path_ =
194 std::string(APP_LOCALE_PATH);
196 std::filesystem::path app_locale_path_ =
197 app_resource_path_ /
"locales";
200 std::filesystem::path app_configure_path_ =
201 QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
203 std::filesystem::path ui_config_dir_path_ =
204 app_configure_path_ /
"conf";
205 std::filesystem::path ui_config_path_ =
206 ui_config_dir_path_ /
"main.cfg";
214 void init_app_secure_key();
220 int64_t get_files_size_at_path(std::filesystem::path path,
221 std::string filename_pattern)
const;
227 std::string get_human_readable_size(int64_t size)
const;
233 void delete_all_files(std::filesystem::path path,
234 std::string filename_pattern)
const;
Definition: GlobalSettingStation.h:47
std::filesystem::path GetLocaleDir() const
Get the Locale Dir object.
Definition: GlobalSettingStation.h:136
libconfig::Config ui_cfg_
UI Configure File.
Definition: GlobalSettingStation.h:208
std::filesystem::path GetCertsDir() const
Get the Certs Dir object.
Definition: GlobalSettingStation.h:154
std::filesystem::path GetLogDir() const
Get the Log Dir object.
Definition: GlobalSettingStation.h:101
std::filesystem::path GetStandaloneGpgBinDir() const
Get the Standalone Gpg Bin Dir object.
Definition: GlobalSettingStation.h:127
std::filesystem::path GetAppDir() const
Get the App Dir object.
Definition: GlobalSettingStation.h:90
std::filesystem::path GetStandaloneDatabaseDir() const
Get the Standalone Database Dir object.
Definition: GlobalSettingStation.h:110
~GlobalSettingStation() noexcept override
Destroy the Global Setting Station object.
std::filesystem::path GetResourceDir() const
Get the Resource Dir object.
Definition: GlobalSettingStation.h:145
Definition: GpgFunctionObject.h:150
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:251
Definition: CoreCommonUtil.cpp:31