Use app user paths for various settings

This commit is contained in:
Ken Van Hoeylandt 2026-08-16 16:14:54 +02:00
parent 8383645722
commit c63fbfef9b
5 changed files with 32 additions and 10 deletions

View File

@ -7,10 +7,10 @@
#include <Tactility/app/chat/ChatSettings.h>
#include <Tactility/app/chat/ChatProtocol.h>
#include <Tactility/DeprecatedPaths.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <app/paths.h>
#include <crypt/crypt.h>
#include <esp_random.h>
@ -28,7 +28,11 @@ namespace tt::app::chat {
constexpr auto* TAG = "ChatSettings";
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/chat.properties";
char path[256];
if (app_paths_get_user_data_path("Chat", "chat.properties", path, sizeof(path)) != ERROR_NONE) {
return "";
}
return path;
}
constexpr auto* KEY_SENDER_ID = "senderId";

View File

@ -1,11 +1,11 @@
#ifdef ESP_PLATFORM
#include <Tactility/DeprecatedPaths.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <map>
#include <string>
#include <app/paths.h>
#include <tactility/log.h>
namespace tt::service::development {
@ -13,7 +13,11 @@ namespace tt::service::development {
constexpr auto* TAG = "DevSettings";
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/development.properties";
char path[256];
if (app_paths_get_user_data_path("Development", "development.properties", path, sizeof(path)) != ERROR_NONE) {
return "";
}
return path;
}
constexpr auto* SETTINGS_KEY_ENABLE_ON_BOOT = "enableOnBoot";

View File

@ -2,7 +2,8 @@
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/DeprecatedPaths.h>
#include <app/paths.h>
#include <map>
#include <string>
@ -11,7 +12,11 @@
namespace tt::settings::display {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/display.properties";
char path[256];
if (app_paths_get_user_data_path("Display", "display.properties", path, sizeof(path)) != ERROR_NONE) {
return "";
}
return path;
}
constexpr auto* SETTINGS_KEY_ORIENTATION = "orientation";

View File

@ -1,7 +1,8 @@
#include <Tactility/settings/TrackballSettings.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/DeprecatedPaths.h>
#include <app/paths.h>
#include <map>
#include <string>
@ -10,7 +11,11 @@
namespace tt::settings::trackball {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/trackball.properties";
char path[256];
if (app_paths_get_user_data_path("TrackballSettings", "trackball.properties", path, sizeof(path)) != ERROR_NONE) {
return "";
}
return path;
}
constexpr auto* KEY_TRACKBALL_ENABLED = "trackballEnabled";

View File

@ -1,8 +1,8 @@
#include <Tactility/DeprecatedPaths.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/settings/WebServerSettings.h>
#include <app/paths.h>
#include <tactility/log.h>
#include <charconv>
@ -22,7 +22,11 @@ namespace tt::settings::webserver {
constexpr auto* TAG = "WebServerSettings";
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/webserver.properties";
char path[256];
if (app_paths_get_user_data_path("WebServerSettings", "webserver.properties", path, sizeof(path)) != ERROR_NONE) {
return "";
}
return path;
}
// Property keys