From b996b817ffa3e54694eccfd061bef177e25ec0f0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 16 Mar 2017 12:53:50 +0300 Subject: tabSRMM: fix for saving private container options --- plugins/TabSRMM/src/containeroptions.cpp | 39 ++++++++++++++++---------------- plugins/TabSRMM/src/msgdialog.cpp | 5 ++-- plugins/TabSRMM/src/msgs.cpp | 6 ++--- plugins/TabSRMM/src/utils.cpp | 26 ++++++++++++--------- 4 files changed, 40 insertions(+), 36 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp index 8397d885df..0bd8026973 100644 --- a/plugins/TabSRMM/src/containeroptions.cpp +++ b/plugins/TabSRMM/src/containeroptions.cpp @@ -252,35 +252,35 @@ INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CNTPRIVATE: - { - - if (IsDlgButtonChecked(hwndDlg, IDC_CNTPRIVATE)) { - Utils::ReadPrivateContainerSettings(pContainer, true); - pContainer->settings->fPrivate = true; - } - else { - if (pContainer->settings != &PluginConfig.globalContainerSettings) { - char szCname[40]; - mir_snprintf(szCname, "%s%d_Blob", CNT_BASEKEYNAME, pContainer->iContainerIndex); - Utils::WriteContainerSettingsToDB(0, pContainer->settings, szCname); - mir_free(pContainer->settings); - } - pContainer->settings = &PluginConfig.globalContainerSettings; - pContainer->settings->fPrivate = false; + if (IsDlgButtonChecked(hwndDlg, IDC_CNTPRIVATE)) { + Utils::ReadPrivateContainerSettings(pContainer, true); + pContainer->settings->fPrivate = true; + } + else { + if (pContainer->settings != &PluginConfig.globalContainerSettings) { + char szCname[40]; + mir_snprintf(szCname, "%s%d", CNT_BASEKEYNAME, pContainer->iContainerIndex); + Utils::WriteContainerSettingsToDB(0, pContainer->settings, szCname); + mir_free(pContainer->settings); } - SendMessage(hwndDlg, DM_SC_INITDIALOG, 0, (LPARAM)pContainer->settings); - goto do_apply; + pContainer->settings = &PluginConfig.globalContainerSettings; + pContainer->settings->fPrivate = false; } + SendMessage(hwndDlg, DM_SC_INITDIALOG, 0, (LPARAM)pContainer->settings); + goto do_apply; + case IDC_TRANSPARENCY: { bool isTrans = IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENCY) != 0; Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_ACTIVE, isTrans); Utils::enableDlgControl(hwndDlg, IDC_TRANSPARENCY_INACTIVE, isTrans); - goto do_apply; } + goto do_apply; + case IDC_SECTIONTREE: case IDC_DESC: return 0; + case IDC_SAVESIZEASGLOBAL: { WINDOWPLACEMENT wp = { 0 }; @@ -297,14 +297,15 @@ INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_O_ENABLESOUNDS: SendMessage(hwndDlg, DM_SC_CONFIG, 0, 0); break; + case IDC_TITLEFORMAT: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return TRUE; goto do_apply; + case IDC_SELECTTHEME: { const wchar_t *szFileName = GetThemeFileName(0); - if (PathFileExists(szFileName)) { SetDlgItemText(hwndDlg, IDC_THEME, szFileName); goto do_apply; diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 6d38ee53d1..1da0798432 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1366,10 +1366,8 @@ void CSrmmWindow::UpdateTitle() } else wcsncpy_s(newtitle, L"Forward", _TRUNCATE); - if (mir_wstrcmp(newtitle, m_wszTitle)) { + if (mir_wstrcmp(newtitle, m_wszTitle)) bChanged = true; - item.mask |= TCIF_TEXT; - } SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); @@ -1390,6 +1388,7 @@ void CSrmmWindow::UpdateTitle() if (m_idle != dwOldIdle || bChanged) { if (bChanged) { + item.mask |= TCIF_TEXT; item.pszText = m_wszTitle; wcsncpy_s(m_wszTitle, newtitle, _TRUNCATE); if (m_pWnd) diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 067b9a5290..ca10099448 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -699,10 +699,10 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, wchar_t *szStatus = pcli->pfnGetStatusModeDescription(szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); - if (M.GetByte("tabstatus", 1)) - mir_snwprintf(tabtitle, L"%s (%s) ", newcontactname, szStatus); + if (PluginConfig.m_bStatusOnTabs) + mir_snwprintf(tabtitle, L"%s (%s)", newcontactname, szStatus); else - mir_snwprintf(tabtitle, L"%s ", newcontactname); + mir_snwprintf(tabtitle, L"%s", newcontactname); HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS); // hide the active tab diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 2e2a6f690d..5d9f257857 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -511,13 +511,11 @@ struct TOldContainerSettings int Utils::ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey) { - memcpy(cs, &PluginConfig.globalContainerSettings, sizeof(TContainerSettings)); - CMStringA szSetting(szKey ? szKey : CNT_KEYNAME); - cs->iSplitterX = db_get_dw(0, SRMSGMOD_T, szSetting + "_SplitterX", -1); - if (cs->iSplitterX == -1) { // nothing? try the old format + int iSplitterX = db_get_dw(0, SRMSGMOD_T, szSetting + "_SplitterX", -1); + if (iSplitterX == -1) { // nothing? try the old format DBVARIANT dbv = { 0 }; - if (0 == db_get(hContact, SRMSGMOD_T, szSetting, &dbv)) { + if (0 == db_get(hContact, SRMSGMOD_T, szSetting + "_Blob", &dbv)) { TOldContainerSettings oldBin = {}; if (dbv.type == DBVT_BLOB && dbv.cpbVal > 0 && dbv.cpbVal <= sizeof(oldBin)) { ::memcpy(&oldBin, (void*)dbv.pbVal, dbv.cpbVal); @@ -528,10 +526,12 @@ int Utils::ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettin if (szKey == nullptr) cs->iSplitterX = db_get_dw(0, CHAT_MODULE, "SplitterX", 150); cs->iSplitterY = oldBin.iSplitterY; + cs->iSplitterX = 35; wcsncpy_s(cs->szTitleFormat, oldBin.szTitleFormat, _TRUNCATE); cs->avatarMode = oldBin.avatarMode; cs->ownAvatarMode = oldBin.ownAvatarMode; cs->autoCloseSeconds = oldBin.autoCloseSeconds; + cs->fPrivate = oldBin.fPrivate != 0; WriteContainerSettingsToDB(hContact, cs, szKey); db_unset(hContact, SRMSGMOD_T, szSetting); ::db_free(&dbv); @@ -547,10 +547,12 @@ int Utils::ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettin cs->dwFlagsEx = db_get_dw(hContact, SRMSGMOD_T, szSetting + "_FlagsEx", 0); cs->dwTransparency = db_get_dw(hContact, SRMSGMOD_T, szSetting + "_Transparency", 0); cs->panelheight = db_get_dw(hContact, SRMSGMOD_T, szSetting + "_PanelY", 0); + cs->iSplitterX = iSplitterX; cs->iSplitterY = db_get_dw(hContact, SRMSGMOD_T, szSetting + "_SplitterY", 0); cs->avatarMode = db_get_w(hContact, SRMSGMOD_T, szSetting + "_AvatarMode", 0); cs->ownAvatarMode = db_get_w(hContact, SRMSGMOD_T, szSetting + "_OwnAvatarMode", 0); cs->autoCloseSeconds = db_get_w(hContact, SRMSGMOD_T, szSetting + "_AutoCloseSecs", 0); + cs->fPrivate = db_get_b(hContact, SRMSGMOD_T, szSetting + "_Private", 0) != 0; db_get_wstatic(hContact, SRMSGMOD_T, szSetting + "_Format", cs->szTitleFormat, _countof(cs->szTitleFormat)); return 0; } @@ -568,6 +570,7 @@ int Utils::WriteContainerSettingsToDB(const MCONTACT hContact, TContainerSetting db_set_w(hContact, SRMSGMOD_T, szSetting + "_AvatarMode", cs->avatarMode); db_set_w(hContact, SRMSGMOD_T, szSetting + "_OwnAvatarMode", cs->ownAvatarMode); db_set_w(hContact, SRMSGMOD_T, szSetting + "_AutoCloseSecs", cs->autoCloseSeconds); + db_set_b(hContact, SRMSGMOD_T, szSetting + "_Private", cs->fPrivate); return 0; } @@ -596,14 +599,15 @@ void Utils::ContainerToSettings(TContainerData *pContainer) void Utils::ReadPrivateContainerSettings(TContainerData *pContainer, bool fForce) { char szCname[50]; - TContainerSettings csTemp = { 0 }; + TContainerSettings csTemp; + memcpy(&csTemp, &PluginConfig.globalContainerSettings, sizeof(csTemp)); - mir_snprintf(szCname, "%s%d_Blob", CNT_BASEKEYNAME, pContainer->iContainerIndex); + mir_snprintf(szCname, "%s%d", CNT_BASEKEYNAME, pContainer->iContainerIndex); Utils::ReadContainerSettingsFromDB(0, &csTemp, szCname); if (csTemp.fPrivate || fForce) { - if (pContainer->settings == 0 || pContainer->settings == &PluginConfig.globalContainerSettings) - pContainer->settings = (TContainerSettings *)mir_alloc(sizeof(TContainerSettings)); - memcpy((void*)pContainer->settings, (void*)&csTemp, sizeof(TContainerSettings)); + if (pContainer->settings == nullptr || pContainer->settings == &PluginConfig.globalContainerSettings) + pContainer->settings = (TContainerSettings *)mir_alloc(sizeof(csTemp)); + memcpy(pContainer->settings, &csTemp, sizeof(csTemp)); pContainer->settings->fPrivate = true; } else pContainer->settings = &PluginConfig.globalContainerSettings; @@ -615,7 +619,7 @@ void Utils::SaveContainerSettings(TContainerData *pContainer, const char *szSett pContainer->dwFlags &= ~(CNT_DEFERREDCONFIGURE | CNT_CREATE_MINIMIZED | CNT_DEFERREDSIZEREQUEST | CNT_CREATE_CLONED); if (pContainer->settings->fPrivate) { - mir_snprintf(szCName, "%s%d_Blob", szSetting, pContainer->iContainerIndex); + mir_snprintf(szCName, "%s%d", szSetting, pContainer->iContainerIndex); WriteContainerSettingsToDB(0, pContainer->settings, szCName); } mir_snprintf(szCName, "%s%d_theme", szSetting, pContainer->iContainerIndex); -- cgit v1.2.3