29 #ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H
30 #define GPGFRONTEND_GLOBALSETTINGSTATION_H
34 #include "GpgFrontendBuildInstallInfo.h"
35 #include "core/GpgFrontendCore.h"
36 #include "core/GpgFunctionObject.h"
65 libconfig::Setting &GetUISettings() noexcept;
73 T LookupSettings(std::
string path, T default_value) noexcept {
74 T value = default_value;
76 value =
static_cast<T
>(GetUISettings().lookup(path));
78 SPDLOG_WARN(
"setting not found: {}", path);
88 [[nodiscard]] std::filesystem::path
GetAppDir()
const {
return app_path_; }
90 [[nodiscard]] std::filesystem::path GetAppDataPath()
const {
91 return app_data_path_;
99 [[nodiscard]] std::filesystem::path
GetLogDir()
const {
100 return app_log_path_;
109 auto db_path = app_configure_path_ /
"db";
110 if (!std::filesystem::exists(db_path)) {
111 std::filesystem::create_directory(db_path);
116 [[nodiscard]] std::filesystem::path GetAppConfigPath()
const {
117 return app_configure_path_;
126 return app_resource_path_ /
"gpg1.4" /
"gpg";
135 return app_locale_path_;
144 return app_resource_path_;
153 return app_resource_path_ /
"certs";
156 [[nodiscard]] std::string GetLogFilesSize()
const;
158 [[nodiscard]] std::string GetDataObjectsFilesSize()
const;
160 void ClearAllLogFiles()
const;
162 void ClearAllDataObjects()
const;
168 void SyncSettings() noexcept;
171 std::filesystem::path app_path_ = QCoreApplication::applicationDirPath()
173 std::filesystem::path app_data_path_ =
174 QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
176 std::filesystem::path app_log_path_ =
177 app_data_path_ / "logs";
178 std::filesystem::path app_data_objs_path_ =
179 app_data_path_ / "data_objs";
181 #ifdef LINUX_INSTALL_BUILD
182 std::filesystem::path app_resource_path_ =
183 std::filesystem::path(APP_LOCALSTATE_PATH) /
186 std::filesystem::path app_resource_path_ =
187 RESOURCE_DIR_BOOST_PATH(app_path_);
190 #ifdef LINUX_INSTALL_BUILD
191 std::filesystem::path app_locale_path_ =
192 std::string(APP_LOCALE_PATH);
194 std::filesystem::path app_locale_path_ =
195 app_resource_path_ /
"locales";
198 std::filesystem::path app_configure_path_ =
199 QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
201 std::filesystem::path ui_config_dir_path_ =
202 app_configure_path_ /
"conf";
203 std::filesystem::path ui_config_path_ =
204 ui_config_dir_path_ /
"main.cfg";
212 void init_app_secure_key();
218 int64_t get_files_size_at_path(std::filesystem::path path,
219 std::string filename_pattern)
const;
225 std::string get_human_readable_size(int64_t size)
const;
231 void delete_all_files(std::filesystem::path path,
232 std::string filename_pattern)
const;
Definition: GlobalSettingStation.h:45
std::filesystem::path GetLocaleDir() const
Get the Locale Dir object.
Definition: GlobalSettingStation.h:134
libconfig::Config ui_cfg_
UI Configure File.
Definition: GlobalSettingStation.h:206
std::filesystem::path GetCertsDir() const
Get the Certs Dir object.
Definition: GlobalSettingStation.h:152
std::filesystem::path GetLogDir() const
Get the Log Dir object.
Definition: GlobalSettingStation.h:99
std::filesystem::path GetStandaloneGpgBinDir() const
Get the Standalone Gpg Bin Dir object.
Definition: GlobalSettingStation.h:125
std::filesystem::path GetAppDir() const
Get the App Dir object.
Definition: GlobalSettingStation.h:88
std::filesystem::path GetStandaloneDatabaseDir() const
Get the Standalone Database Dir object.
Definition: GlobalSettingStation.h:108
~GlobalSettingStation() noexcept override
Destroy the Global Setting Station object.
std::filesystem::path GetResourceDir() const
Get the Resource Dir object.
Definition: GlobalSettingStation.h:143
Definition: GpgFunctionObject.h:150
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:251
Definition: CoreCommonUtil.cpp:31