From 0dbba78f4fb4a05945be5aab0848c01881b8ac12 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Aug 2020 18:09:03 +0300 Subject: SmileyAdd: - fixes #2545 (SmileyAdd: missing assigned per-contact smileys categories); - unused service MS_SMILEYADD_SHOWSELECTION removed; - name conflict resolution; - version bump; --- plugins/SmileyAdd/src/AniSmileyObject.cpp | 2 +- plugins/SmileyAdd/src/dlgboxsubclass.cpp | 4 +- plugins/SmileyAdd/src/download.cpp | 2 +- plugins/SmileyAdd/src/imagecache.cpp | 2 +- plugins/SmileyAdd/src/main.cpp | 1 - plugins/SmileyAdd/src/richcall.cpp | 4 +- plugins/SmileyAdd/src/services.cpp | 82 +++++++++++++++++-------------- plugins/SmileyAdd/src/services.h | 4 +- plugins/SmileyAdd/src/smileys.h | 2 +- plugins/SmileyAdd/src/smltool.cpp | 4 +- plugins/SmileyAdd/src/version.h | 2 +- 11 files changed, 57 insertions(+), 52 deletions(-) (limited to 'plugins/SmileyAdd/src') diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp index b5043d51c1..d18fd3ba15 100644 --- a/plugins/SmileyAdd/src/AniSmileyObject.cpp +++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp @@ -86,7 +86,7 @@ public: if (m_hwnd == nullptr) return; - REOBJECT reObj = { 0 }; + REOBJECT reObj = {}; reObj.cbStruct = sizeof(reObj); { CComPtr RichEditOle; diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index 1f11c44b48..315ea88f36 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -33,7 +33,7 @@ struct MsgWndData : public MZeroedObject void CreateSmileyButton(void) { - SmileyPackType *SmileyPack = GetSmileyPack(ProtocolName); + SmileyPackType *SmileyPack = FindSmileyPack(ProtocolName); bool doSmileyButton = SmileyPack != nullptr && SmileyPack->VisibleSmileyCount() != 0; doSmileyReplace = true; @@ -135,7 +135,7 @@ int SmileyButtonPressed(WPARAM, LPARAM lParam) return 0; SmileyToolWindowParam *stwp = new SmileyToolWindowParam; - stwp->pSmileyPack = GetSmileyPack(dat->ProtocolName); + stwp->pSmileyPack = FindSmileyPack(dat->ProtocolName, dat->hContact); stwp->hWndParent = pcbc->hwndFrom; stwp->hWndTarget = dat->hwndInput; stwp->targetMessage = EM_REPLACESEL; diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp index a200d51e1f..5b51b9970b 100644 --- a/plugins/SmileyAdd/src/download.cpp +++ b/plugins/SmileyAdd/src/download.cpp @@ -43,7 +43,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwn { int result = 0xBADBAD; char *szRedirUrl = nullptr; - NETLIBHTTPREQUEST nlhr = { 0 }; + NETLIBHTTPREQUEST nlhr = {}; // initialize the netlib request nlhr.cbSize = sizeof(nlhr); diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp index 5959f2c1a3..3aea12abc6 100644 --- a/plugins/SmileyAdd/src/imagecache.cpp +++ b/plugins/SmileyAdd/src/imagecache.cpp @@ -454,7 +454,7 @@ void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) GetObject(m_bmp, sizeof(bm), &bm); if (bm.bmBitsPixel == 32) { - BLENDFUNCTION bf = { 0 }; + BLENDFUNCTION bf = {}; bf.SourceConstantAlpha = 255; bf.AlphaFormat = AC_SRC_ALPHA; GdiAlphaBlend(hdc, x, y, sizeX, sizeY, hdcImg, 0, 0, bm.bmWidth, bm.bmHeight, bf); diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp index 632dcd3b44..dd043cdf27 100644 --- a/plugins/SmileyAdd/src/main.cpp +++ b/plugins/SmileyAdd/src/main.cpp @@ -115,7 +115,6 @@ int CMPlugin::Load() // create the smiley services CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceSmileysCommand); - CreateServiceFunction(MS_SMILEYADD_SHOWSELECTION, ShowSmileySelectionCommand); CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfoCommand2); CreateServiceFunction(MS_SMILEYADD_REGISTERCATEGORY, RegisterPack); CreateServiceFunction(MS_SMILEYADD_BATCHPARSE, ParseTextBatch); diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp index 1d9fc73d2f..ed0c886ae1 100644 --- a/plugins/SmileyAdd/src/richcall.cpp +++ b/plugins/SmileyAdd/src/richcall.cpp @@ -56,7 +56,7 @@ static void SetPosition(HWND hwnd) int objectCount = RichEditOle->GetObjectCount(); for (int i = objectCount - 1; i >= 0; i--) { - REOBJECT reObj = { 0 }; + REOBJECT reObj = {}; reObj.cbStruct = sizeof(REOBJECT); HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_POLEOBJ); @@ -132,7 +132,7 @@ static void ReplaceContactSmileys(RichEditData *rdt, const CHARRANGE &sel, bool { if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return; SmileyPackCType *smcp = nullptr; - SmileyPackType *SmileyPack = GetSmileyPack(Proto_GetBaseAccountName(rdt->hContact), rdt->inputarea ? nullptr : &smcp); + SmileyPackType *SmileyPack = FindSmileyPack(Proto_GetBaseAccountName(rdt->hContact), rdt->hContact, rdt->inputarea ? nullptr : &smcp); ReplaceSmileys(rdt->hwnd, SmileyPack, smcp, sel, false, ignoreLast, unFreeze); } diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index aca7e2a8c5..e238b75ba5 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -24,7 +24,7 @@ LIST menuHandleArray(5); //implementation of service functions -SmileyPackType* GetSmileyPack(const char *proto, SmileyPackCType **smlc) +SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackCType **smlc) { if (smlc) *smlc = g_SmileyPackCStore.GetSmileyPack(proto); @@ -33,28 +33,59 @@ SmileyPackType* GetSmileyPack(const char *proto, SmileyPackCType **smlc) return nullptr; CMStringW categoryName; - if (proto == nullptr || proto[0] == 0) - categoryName = L"Standard"; - else { - categoryName = _A2T(proto); - if (opt.UseOneForAll) { - SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName); - if (smc == nullptr || smc->IsProto()) - categoryName = L"Standard"; + if (hContact != 0) { + opt.ReadContactCategory(hContact, categoryName); + if (categoryName == L"") return nullptr; + if (!categoryName.IsEmpty() && g_SmileyCategories.GetSmileyCategory(categoryName) == nullptr) { + categoryName.Empty(); + opt.WriteContactCategory(hContact, categoryName); + } + + if (categoryName.IsEmpty() && !opt.UseOneForAll) { + char *protonam = Proto_GetBaseAccountName(hContact); + if (protonam != nullptr) { + DBVARIANT dbv; + if (db_get_ws(hContact, protonam, "Transport", &dbv) == 0) { + categoryName = dbv.pwszVal; + db_free(&dbv); + } + else if (opt.UsePhysProto && db_get_ws(0, protonam, "AM_BaseProto", &dbv) == 0) { + categoryName = L"AllProto"; + categoryName += dbv.pwszVal; + db_free(&dbv); + CMStringW categoryFileName = g_SmileyCategories.GetSmileyCategory(categoryName) ? g_SmileyCategories.GetSmileyCategory(categoryName)->GetFilename() : L""; + if (categoryFileName.IsEmpty()) + categoryName = _A2T(protonam); + } + else + categoryName = _A2T(protonam); + } + } + } + + if (categoryName.IsEmpty()) { + if (proto == nullptr || proto[0] == 0) + categoryName = L"Standard"; + else { + categoryName = _A2T(proto); + if (opt.UseOneForAll) { + SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName); + if (smc == nullptr || smc->IsProto()) + categoryName = L"Standard"; + } } } return g_SmileyCategories.GetSmileyPack(categoryName); } - INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) { SMADD_RICHEDIT3 *smre = (SMADD_RICHEDIT3*)lParam; if (smre == nullptr) return FALSE; - SMADD_RICHEDIT3 smrec = { 0 }; + SMADD_RICHEDIT3 smrec = {}; memcpy(&smrec, smre, min(smre->cbSize, sizeof(smrec))); static const CHARRANGE selection = { 0, LONG_MAX }; @@ -62,7 +93,7 @@ INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) else if (smrec.rangeToReplace->cpMax < 0) smrec.rangeToReplace->cpMax = LONG_MAX; SmileyPackCType *smcp = nullptr; - SmileyPackType *SmileyPack = GetSmileyPack(smrec.Protocolname, (smrec.flags & SAFLRE_NOCUSTOM) ? nullptr : &smcp); + SmileyPackType *SmileyPack = FindSmileyPack(smrec.Protocolname, smrec.hContact, (smrec.flags & SAFLRE_NOCUSTOM) ? nullptr : &smcp); ReplaceSmileys(smre->hwndRichEditControl, SmileyPack, smcp, *smrec.rangeToReplace, smrec.hContact == 0, false, false, (smre->flags & SAFLRE_FIREVIEW) ? true : false); @@ -70,34 +101,11 @@ INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) return TRUE; } - -INT_PTR ShowSmileySelectionCommand(WPARAM, LPARAM lParam) -{ - SMADD_SHOWSEL3 *smaddInfo = (SMADD_SHOWSEL3*)lParam; - - if (smaddInfo == nullptr) return FALSE; - HWND parent = smaddInfo->hwndParent; - - SmileyToolWindowParam *stwp = new SmileyToolWindowParam; - stwp->pSmileyPack = GetSmileyPack(smaddInfo->Protocolname); - stwp->hWndParent = parent; - stwp->hWndTarget = smaddInfo->hwndTarget; - stwp->targetMessage = smaddInfo->targetMessage; - stwp->targetWParam = smaddInfo->targetWParam; - stwp->xPosition = smaddInfo->xPosition; - stwp->yPosition = smaddInfo->yPosition; - stwp->direction = smaddInfo->Direction; - mir_forkThread(SmileyToolThread, stwp); - - return TRUE; -} - - static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup) { if (smre == nullptr) return FALSE; - SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname); + SmileyPackType *SmileyPack = FindSmileyPack(smre->Protocolname); if (SmileyPack == nullptr || SmileyPack->SmileyCount() == 0) { smre->ButtonIcon = nullptr; smre->NumberOfSmileys = 0; @@ -138,7 +146,7 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) SmileyPackCType *smcp = nullptr; SmileysQueueType smllist; - SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname, (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? nullptr : &smcp); + SmileyPackType *SmileyPack = FindSmileyPack(smre->Protocolname, smre->hContact, (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? nullptr : &smcp); if (smre->flag & SAFL_UNICODE) LookupAllSmileys(SmileyPack, smcp, smre->wstr, smllist, false); diff --git a/plugins/SmileyAdd/src/services.h b/plugins/SmileyAdd/src/services.h index 86b1b3742b..da37065f52 100644 --- a/plugins/SmileyAdd/src/services.h +++ b/plugins/SmileyAdd/src/services.h @@ -22,7 +22,6 @@ along with this program. If not, see . // service commands INT_PTR ReplaceSmileysCommand(WPARAM wParam, LPARAM lParam); -INT_PTR ShowSmileySelectionCommand(WPARAM wParam, LPARAM lParam); INT_PTR GetInfoCommand(WPARAM wParam, LPARAM); INT_PTR GetInfoCommand2(WPARAM wParam, LPARAM); INT_PTR RegisterPack(WPARAM wParam, LPARAM lParam); @@ -38,8 +37,7 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam); int DbSettingChanged(WPARAM wParam, LPARAM lParam); int ReloadColour(WPARAM, LPARAM); -SmileyPackType* GetSmileyPack(const char* proto, SmileyPackCType** smlc = nullptr); - +SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact = 0, SmileyPackCType **smlc = nullptr); #endif // SMILEYADD_SERVICES_H_ diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h index 8071e12770..ad73daa727 100644 --- a/plugins/SmileyAdd/src/smileys.h +++ b/plugins/SmileyAdd/src/smileys.h @@ -212,7 +212,7 @@ public: bool AddSmileyPack(CMStringW &filename, CMStringW &packname); void ClearAndFreeAll(void); - SmileyPackType* GetSmileyPack(CMStringW& filename); + SmileyPackType* GetSmileyPack(CMStringW &filename); }; diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp index 901cb07210..7a1fe4c3e8 100644 --- a/plugins/SmileyAdd/src/smltool.cpp +++ b/plugins/SmileyAdd/src/smltool.cpp @@ -296,7 +296,7 @@ void SmileyToolWindowType::MouseMove(int xposition, int yposition) if (but<0) SendMessage(m_hToolTip, TTM_ACTIVATE, FALSE, 0); else if (m_CurrMouseTrack != but) { - TOOLINFO ti = { 0 }; + TOOLINFO ti = {}; ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.hwnd = m_hwndDialog; @@ -503,7 +503,7 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam) //add tooltips m_hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, nullptr, g_plugin.getInst(), nullptr); - TOOLINFO ti = { 0 }; + TOOLINFO ti = {}; ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.hwnd = m_hwndDialog; diff --git a/plugins/SmileyAdd/src/version.h b/plugins/SmileyAdd/src/version.h index fd79d40249..38e63ce7e5 100644 --- a/plugins/SmileyAdd/src/version.h +++ b/plugins/SmileyAdd/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 3 #define __RELEASE_NUM 2 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include -- cgit v1.2.3