diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-13 19:16:08 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-13 19:16:08 +0300 |
commit | 49550ee2fedc4a2f339612e1fe9e6ad4173fa6bc (patch) | |
tree | 546e2e942ada00a55ccca1986e285b3a36b126e0 /plugins/StatusManager | |
parent | 4268ae190a49c46e6f440b36f190c856d41009d9 (diff) |
minor code cleaning
Diffstat (limited to 'plugins/StatusManager')
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_options.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 5f2931dc5b..90bdc218aa 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -507,24 +507,6 @@ static int DeleteSetting(const char *szSetting, void *lParam) return 0; } -static int ClearDatabase(char* filter) -{ - LIST<char> arSettings(10); - db_enum_settings(0, DeleteSetting, SSMODULENAME, &arSettings); - - for (int i = 0; i < arSettings.getCount(); i++) { - if ((filter == nullptr) || (!strncmp(filter, arSettings[i], mir_strlen(filter)))) - db_unset(0, SSMODULENAME, arSettings[i]); - mir_free(arSettings[i]); - } - - if (filter == nullptr) - db_unset(0, "AutoAway", "Confirm"); - - return 0; -} - - INT_PTR CALLBACK addProfileDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static HWND hwndParent; @@ -748,12 +730,20 @@ public: virtual void OnApply() override { - char setting[128]; int oldCount = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); for (int i = 0; i < oldCount; i++) { - mir_snprintf(setting, "%d_", i); - ClearDatabase(setting); + LIST<char> arSettings(10); + db_enum_settings(0, DeleteSetting, SSMODULENAME, &arSettings); + + char setting[128]; + int len = mir_snprintf(setting, "%d_", i); + for (int k = 0; k < arSettings.getCount(); k++) { + if (!strncmp(setting, arSettings[k], len)) + db_unset(0, SSMODULENAME, arSettings[k]); + mir_free(arSettings[k]); + } } + for (int i = 0; i < arProfiles.getCount(); i++) { PROFILEOPTIONS& po = arProfiles[i]; db_set_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), po.showDialog); @@ -767,6 +757,7 @@ public: TSettingsList& ar = *po.ps; for (int j = 0; j < ar.getCount(); j++) { if (ar[j].m_szMsg != nullptr) { + char setting[128]; mir_snprintf(setting, "%s_%s", ar[j].m_szName, SETTING_PROFILE_STSMSG); db_set_ws(0, SSMODULENAME, OptName(i, setting), ar[j].m_szMsg); } |