From 8ffc77be71507825a8f7585bcabff8ccc370206a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 8 Dec 2018 20:12:16 +0300 Subject: db_get_sa / db_get_wsa to receive the default value, massive code simplification --- plugins/TabSRMM/src/chat_options.cpp | 8 +------- plugins/TabSRMM/src/container.cpp | 23 +++++------------------ plugins/TabSRMM/src/functions.h | 2 +- 3 files changed, 7 insertions(+), 26 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 3b973cc1b2..e7d7be142c 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -218,13 +218,7 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM lf->lfCharSet = SYMBOL_CHARSET; wcsncpy_s(lf->lfFaceName, L"Webdings", _TRUNCATE); } - else { - ptrW tszDefFace(db_get_wsa(0, szMod, str)); - if (tszDefFace == nullptr) - wcsncpy_s(lf->lfFaceName, fol[i].szDefFace, _TRUNCATE); - else - wcsncpy_s(lf->lfFaceName, tszDefFace, _TRUNCATE); - } + else wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, szMod, str, fol[i].szDefFace)), _TRUNCATE); } } diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 733f760aa3..a3c633d5eb 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2119,34 +2119,21 @@ void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc) // retrieve the container name for the given contact handle. // if none is assigned, return the name of the default container -int TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen) +void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen) { // single window mode using cloned (temporary) containers if (M.GetByte("singlewinmode", 0)) { wcsncpy_s(szName, iNameLen, L"Message Session", _TRUNCATE); - return 0; + return; } // use clist group names for containers... if (M.GetByte("useclistgroups", 0)) { - ptrW tszGroup(db_get_wsa(hContact, "CList", "Group")); - if (tszGroup == nullptr) { - wcsncpy_s(szName, iNameLen, L"default", _TRUNCATE); - return 0; - } - - wcsncpy_s(szName, iNameLen, tszGroup, _TRUNCATE); - return 1; - } - - ptrW tszContainerName(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY)); - if (tszContainerName == nullptr) { - wcsncpy_s(szName, iNameLen, L"default", _TRUNCATE); - return 0; + wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, "CList", "Group", L"default")), _TRUNCATE); + return; } - wcsncpy_s(szName, iNameLen, tszContainerName, _TRUNCATE); - return 1; + wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, L"default")), _TRUNCATE); } void TSAPI DeleteContainer(int iIndex) diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index a4877a57b9..9d3f58b3e9 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -90,7 +90,7 @@ void TSAPI ReflashContainer(TContainerData *pContainer); void TSAPI CloseAllContainers(); void TSAPI DeleteContainer(int iIndex); void TSAPI RenameContainer(int iIndex, const wchar_t *newName); -int TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen); +void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen); HMENU TSAPI BuildContainerMenu(); void TSAPI ApplyContainerSetting(TContainerData *pContainer, DWORD flags, UINT mode, bool fForceResize); void TSAPI BroadCastContainer(const TContainerData *pContainer, UINT message, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3