From 53669871fc860856c80c2d79cb6b21d52ea25440 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Sep 2023 12:56:54 +0300 Subject: unneeded conversions removed --- plugins/SmileyAdd/src/services.cpp | 20 +++++++++----------- plugins/SmileyAdd/src/smileys.cpp | 9 +++++---- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'plugins/SmileyAdd/src') diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 73fcb7e450..eb9210e2eb 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -58,9 +58,9 @@ SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackC auto *p = g_SmileyCategories.GetSmileyCategory(categoryName); if (!p || p->GetFilename().IsEmpty()) - categoryName = _A2T(protonam); + categoryName = protonam; } - else categoryName = _A2T(protonam); + else categoryName = protonam; } } } @@ -69,7 +69,7 @@ SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackC if (proto == nullptr || proto[0] == 0) categoryName = L"Standard"; else { - categoryName = _A2T(proto); + categoryName = proto; if (opt.UseOneForAll) { SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName); if (smc == nullptr || smc->IsProto()) @@ -206,15 +206,13 @@ INT_PTR FreeTextBatch(WPARAM, LPARAM lParam) INT_PTR RegisterPack(WPARAM, LPARAM lParam) { SMADD_REGCAT *smre = (SMADD_REGCAT*)lParam; + if (smre == nullptr || smre->cbSize < sizeof(SMADD_REGCAT)) + return FALSE; - if (smre == nullptr || smre->cbSize < sizeof(SMADD_REGCAT)) return FALSE; - if (IsBadStringPtrA(smre->name, 50) || IsBadStringPtrA(smre->dispname, 50)) return FALSE; - - - CMStringW nmd(_A2T(smre->dispname)); - CMStringW nm(_A2T(smre->name)); - g_SmileyCategories.AddAndLoad(nm, nmd); + if (IsBadStringPtrA(smre->name, 50) || IsBadStringPtrA(smre->dispname, 50)) + return FALSE; + g_SmileyCategories.AddAndLoad(_A2T(smre->name), _A2T(smre->dispname)); return TRUE; } @@ -386,7 +384,7 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam) case PRAC_CHANGED: if (acc != nullptr && acc->szModuleName != nullptr) { - CMStringW name(_A2T(acc->szModuleName)); + CMStringW name(acc->szModuleName); SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(name); if (smc != nullptr) { if (acc->tszAccountName) diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index cb4df861bc..480cc67db0 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -480,7 +480,7 @@ bool SmileyPackType::LoadSmileyFileMSL(const CMStringW &filename, bool onlyInfo, if (len > 2 && *(wchar_t*)buf == 0xfeff) tbuf = ((wchar_t*)buf + 1); else if (len > 3 && buf[0] == '\xef' && buf[1] == '\xbb' && buf[2] == '\xbf') - tbuf = _A2T(buf + 3, CP_UTF8); + tbuf = Utf2T(buf + 3); else tbuf = _A2T(buf); @@ -801,10 +801,11 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr paths = defaultFile; } + _A2T wszModule(acc->szModuleName); if (acc->tszAccountName) - AddCategory(_A2T(acc->szModuleName), acc->tszAccountName, acc->bIsVirtual ? smcVirtualProto : smcProto, paths); + AddCategory(wszModule, acc->tszAccountName, acc->bIsVirtual ? smcVirtualProto : smcProto, paths); else - AddCategory(_A2T(acc->szModuleName), _A2T(acc->szModuleName), acc->bIsVirtual ? smcVirtualProto : smcProto, paths); + AddCategory(wszModule, wszModule, acc->bIsVirtual ? smcVirtualProto : smcProto, paths); } void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMStringW &defaultFile) @@ -829,7 +830,7 @@ void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMStringW &defa void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) { - CMStringW tname(_A2T(acc->szModuleName)); + CMStringW tname(acc->szModuleName); for (auto &hContact : Contacts()) { char *proto = Proto_GetBaseAccountName(hContact); -- cgit v1.2.3