Index: sources/storage/Settings.h =================================================================== diff -u -rd866ef66b21f114f07cb80a07860900cd43daff0 -ra75bc5b80ad4ebde50f028b550cd534e589bd059 --- sources/storage/Settings.h (.../Settings.h) (revision d866ef66b21f114f07cb80a07860900cd43daff0) +++ sources/storage/Settings.h (.../Settings.h) (revision a75bc5b80ad4ebde50f028b550cd534e589bd059) @@ -45,6 +45,8 @@ const char *_duplicate_key_off = "duplicate_key_off"; const char *_settingsExt = "conf"; const char *_settingsFormat = "%1/%2.%3"; + const char *_settingsLocalSeparator = "_"; + struct Detail { QString category; QString location; @@ -100,22 +102,25 @@ return QString(literal.arg(vPath).arg(vFile).arg(_settingsExt)); } - bool isValid(const QString &vSettingFile); + bool exists(const QString &vSettingFile); - QString fileName(const QString &vCategory); + QString fileName(const QString &vCategory, const QString &vLocale); + bool parse(const Detail &vDetail); + public: Settings() {} enum Category_Enum { + eSettingsSystem = 0, // has to be the first one to read the other configs according to the locale set in the Systems.conf eInstructions , eConfigurationsDataList , // TODO: the category for this conf is not used. may need to be merged into the Settings, but since it is list, It needs a little more thought. eAlarms , eEvents , eMessagesUnhandled , - eSettingsSystem , eGenericConfirm , - }; + }; // IMPORTANT: not having a eCount in the enum is intentional. to make sure in switch no enum is missed when not using the default. + const int _categoryCount = eGenericConfirm; enum Key_Enum { eKeyTitle , @@ -131,25 +136,25 @@ }; int read (); - int save (const QString &vCategory, const QString &vGroup, const QString &vKey, const QString &vValue); + int saveSystem (const QString &vGroup, const QString &vKey, const QString &vValue); int configurationsMove (QString *vMessage = nullptr, bool vIsUpdate = false); int configurationsPOST (Location_Enum vLoc = Location_Enum::eSecured) { Q_UNUSED(vLoc); return true; } static QString category(Category_Enum vCategory) { - switch (vCategory) { // NOTE: don't use default + switch (vCategory) { // NOTE: don't use default case + case eSettingsSystem : return Storage::Settings_Category_SettingsSystem ; case eInstructions : return Storage::Settings_Category_Instructions ; case eConfigurationsDataList : return Storage::Settings_Category_ConfigurationsDataList ; case eAlarms : return Storage::Settings_Category_Alarms ; case eEvents : return Storage::Settings_Category_Events ; case eMessagesUnhandled : return Storage::Settings_Category_MessagesUnhandled ; - case eSettingsSystem : return Storage::Settings_Category_SettingsSystem ; case eGenericConfirm : return Storage::Settings_Category_GenericConfirm ; } return ""; } static QString key(Key_Enum vKey) { - switch (vKey) { // NOTE: don't use default + switch (vKey) { // NOTE: don't use default case case eKeyTitle : return Storage::Settings_Key_Title ; case eKeyMessage : return Storage::Settings_Key_Message ; case eKeyListTitle : return Storage::Settings_Key_ListTitle ; @@ -161,18 +166,18 @@ //Note: this funtion is specific to the settings and should not use the StorageGlobals function. static QString location(Location_Enum vLoc) { - switch (vLoc) { // NOTE: don't use default + switch (vLoc) { // NOTE: don't use default case case eInit : return Storage::Settings_Path_Init; case eSecured : return Storage::Settings_Path_Name; } return Storage::Settings_Path_Name; } + static bool isCategorySettingsSystem (const QString &vCategory) { return vCategory == category( eSettingsSystem ); } static bool isCategoryInstructions (const QString &vCategory) { return vCategory == category( eInstructions ); } static bool isCategoryConfigurationsDataList (const QString &vCategory) { return vCategory == category( eConfigurationsDataList ); } static bool isCategoryAlarms (const QString &vCategory) { return vCategory == category( eAlarms ); } static bool isCategoryMessagesUnhandled (const QString &vCategory) { return vCategory == category( eMessagesUnhandled ); } - static bool isCategorySettingsSystem (const QString &vCategory) { return vCategory == category( eSettingsSystem ); } static bool isCategoryConfirm (const QString &vCategory) { return vCategory == category( eGenericConfirm ); } static bool isKeyTitle (const QString &vKey ) { return vKey == key ( eKeyTitle ); } static bool isKeyMessage (const QString &vKey ) { return vKey == key ( eKeyMessage ); }