From 4cd0aa5643498a9be9a2fc3ed6e1a88807d4dc8f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Oct 2023 11:42:41 +0300 Subject: MS_SMILEYADD_SELECTSMILEY - new service for custom smiley selector --- plugins/ExternalAPI/m_smileyadd.h | 20 +++ plugins/SmileyAdd/SmileyAdd.vcxproj | 1 - plugins/SmileyAdd/SmileyAdd.vcxproj.filters | 3 - plugins/SmileyAdd/src/dlgboxsubclass.cpp | 2 +- plugins/SmileyAdd/src/main.cpp | 86 ++++++++-- plugins/SmileyAdd/src/services.cpp | 253 ++++++++++++++-------------- plugins/SmileyAdd/src/services.h | 43 ----- plugins/SmileyAdd/src/smltool.cpp | 4 + plugins/SmileyAdd/src/smltool.h | 3 +- plugins/SmileyAdd/src/stdafx.h | 3 +- 10 files changed, 225 insertions(+), 193 deletions(-) delete mode 100644 plugins/SmileyAdd/src/services.h diff --git a/plugins/ExternalAPI/m_smileyadd.h b/plugins/ExternalAPI/m_smileyadd.h index 636dda0bcd..cfb46fb509 100644 --- a/plugins/ExternalAPI/m_smileyadd.h +++ b/plugins/ExternalAPI/m_smileyadd.h @@ -67,6 +67,7 @@ struct SMADD_INFO int NumberOfSmileys; // Number of total smileys defined }; +#define MS_SMILEYADD_GETINFO "SmileyAdd/GetInfo" #define MS_SMILEYADD_GETINFO2 "SmileyAdd/GetInfo2" ///////////////////////////////////////////////////////////////////////////////////////// @@ -216,3 +217,22 @@ struct SMADD_CONT }; #define MS_SMILEYADD_LOADCONTACTSMILEYS "SmileyAdd/LoadContactSmileys" + +///////////////////////////////////////////////////////////////////////////////////////// +// Displays SmileyTool window to choose a smiley +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_SELECTSMILEY*) ¶m; + +struct SMADD_SELECTSMILEY +{ + const char *pszSmileys; // list of smileys or zero to display all pack + int xPosition; + int yPosition; + int direction; + HWND hWndTarget; + HWND hWndParent; + UINT targetMessage; + WPARAM targetWParam; +}; + +#define MS_SMILEYADD_SELECTSMILEY "SmileyAdd/SelectSmiley" diff --git a/plugins/SmileyAdd/SmileyAdd.vcxproj b/plugins/SmileyAdd/SmileyAdd.vcxproj index f47e95b879..3f1ef12004 100644 --- a/plugins/SmileyAdd/SmileyAdd.vcxproj +++ b/plugins/SmileyAdd/SmileyAdd.vcxproj @@ -55,7 +55,6 @@ - diff --git a/plugins/SmileyAdd/SmileyAdd.vcxproj.filters b/plugins/SmileyAdd/SmileyAdd.vcxproj.filters index 73600edd2e..be05668048 100644 --- a/plugins/SmileyAdd/SmileyAdd.vcxproj.filters +++ b/plugins/SmileyAdd/SmileyAdd.vcxproj.filters @@ -70,9 +70,6 @@ Header Files - - Header Files - Header Files diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index 0dd3cafd0d..377b77c729 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -54,7 +54,7 @@ struct MsgWndData : public MZeroedObject static OBJLIST g_MsgWndList(10, HandleKeySortT); -int UpdateSrmmDlg(WPARAM wParam, LPARAM) +int UpdateSrmmDlg(WPARAM, LPARAM) { Srmm_ApplyOptions(); return 0; diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp index 08c0f6924a..8f18584071 100644 --- a/plugins/SmileyAdd/src/main.cpp +++ b/plugins/SmileyAdd/src/main.cpp @@ -25,6 +25,13 @@ HGENMENU hContactMenuItem; CMPlugin g_plugin; +static IconItem iconList[] = +{ + { LPGEN("Button smiley"), "SmileyAdd_ButtonSmiley", IDI_SMILINGICON } +}; + +void InitServices(); + ///////////////////////////////////////////////////////////////////////////////////////// static const PLUGININFOEX pluginInfoEx = @@ -46,11 +53,72 @@ CMPlugin::CMPlugin() : {} ///////////////////////////////////////////////////////////////////////////////////////// +// Events -static IconItem iconList[] = +int AccountListChanged(WPARAM wParam, LPARAM lParam) { - { LPGEN("Button smiley"), "SmileyAdd_ButtonSmiley", IDI_SMILINGICON } -}; + PROTOACCOUNT *acc = (PROTOACCOUNT *)lParam; + + switch (wParam) { + case PRAC_ADDED: + if (acc != nullptr) { + const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(L"Standard")->GetFilename(); + g_SmileyCategories.AddAccountAsCategory(acc, defaultFile); + } + break; + + case PRAC_CHANGED: + if (acc != nullptr && acc->szModuleName != nullptr) { + CMStringW name(acc->szModuleName); + SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(name); + if (smc != nullptr) { + if (acc->tszAccountName) + name = acc->tszAccountName; + smc->SetDisplayName(name); + } + } + break; + + case PRAC_REMOVED: + g_SmileyCategories.DeleteAccountAsCategory(acc); + break; + + case PRAC_CHECKED: + if (acc != nullptr) { + if (acc->bIsEnabled) { + const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(L"Standard")->GetFilename(); + g_SmileyCategories.AddAccountAsCategory(acc, defaultFile); + } + else g_SmileyCategories.DeleteAccountAsCategory(acc); + } + break; + } + return 0; +} + +static int DbSettingChanged(WPARAM hContact, LPARAM lParam) +{ + if (hContact == 0) + return 0; + + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; + if (cws->value.type == DBVT_DELETED) + return 0; + + if (strcmp(cws->szSetting, "Transport") == 0) { + SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(L"Standard"); + if (smc != nullptr) + g_SmileyCategories.AddContactTransportAsCategory(hContact, smc->GetFilename()); + } + return 0; +} + + +static int ReloadColors(WPARAM, LPARAM) +{ + opt.SelWndBkgClr = db_get_dw(0, "SmileyAdd", "SelWndBkgClr", GetSysColor(COLOR_WINDOW)); + return 0; +} static int ModulesLoaded(WPARAM, LPARAM) { @@ -99,24 +167,16 @@ int CMPlugin::Load() HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, MirandaShutdown); HookEvent(ME_OPT_INITIALISE, SmileysOptionsInitialize); - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, RebuildContactMenu); HookEvent(ME_SMILEYADD_OPTIONSCHANGED, UpdateSrmmDlg); HookEvent(ME_PROTO_ACCLISTCHANGED, AccountListChanged); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DbSettingChanged); - HookEvent(ME_COLOUR_RELOAD, ReloadColour); + HookEvent(ME_COLOUR_RELOAD, ReloadColors); HookEvent(ME_MSG_BUTTONPRESSED, SmileyButtonPressed); HookTemporaryEvent(ME_MSG_TOOLBARLOADED, SmileyButtonCreate); // create the smiley services - CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceSmileysCommand); - CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfoCommand2); - CreateServiceFunction(MS_SMILEYADD_REGISTERCATEGORY, RegisterPack); - CreateServiceFunction(MS_SMILEYADD_BATCHPARSE, ParseTextBatch); - CreateServiceFunction(MS_SMILEYADD_BATCHFREE, FreeTextBatch); - CreateServiceFunction(MS_SMILEYADD_CUSTOMCATMENU, CustomCatMenu); - CreateServiceFunction(MS_SMILEYADD_RELOAD, ReloadPack); - CreateServiceFunction(MS_SMILEYADD_LOADCONTACTSMILEYS, LoadContactSmileys); + InitServices(); return 0; } diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index b2dbc14ea4..9a6fa4de47 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -20,8 +20,6 @@ along with this program. If not, see . #include "stdafx.h" -static LIST menuHandleArray(5); - ///////////////////////////////////////////////////////////////////////////////////////// // Service functions @@ -83,7 +81,7 @@ SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackC ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) +static INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) { SMADD_RICHEDIT *smre = (SMADD_RICHEDIT*)lParam; if (smre == nullptr) @@ -135,19 +133,19 @@ static int GetInfoCommandE(SMADD_INFO *smre, bool retDup) return TRUE; } -INT_PTR GetInfoCommand(WPARAM, LPARAM lParam) +static INT_PTR GetInfoCommand(WPARAM, LPARAM lParam) { return GetInfoCommandE((SMADD_INFO*)lParam, false); } -INT_PTR GetInfoCommand2(WPARAM, LPARAM lParam) +static INT_PTR GetInfoCommand2(WPARAM, LPARAM lParam) { return GetInfoCommandE((SMADD_INFO*)lParam, true); } ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) +static INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) { SMADD_BATCHPARSE *smre = (SMADD_BATCHPARSE*)lParam; if (smre == nullptr) @@ -195,7 +193,7 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR FreeTextBatch(WPARAM, LPARAM lParam) +static INT_PTR FreeTextBatch(WPARAM, LPARAM lParam) { delete[](SMADD_BATCHPARSERES*)lParam; return TRUE; @@ -203,7 +201,7 @@ INT_PTR FreeTextBatch(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR RegisterPack(WPARAM, LPARAM lParam) +static INT_PTR RegisterPack(WPARAM, LPARAM lParam) { SMADD_REGCAT *smre = (SMADD_REGCAT*)lParam; if (smre == nullptr) @@ -218,83 +216,9 @@ INT_PTR RegisterPack(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR CustomCatMenu(WPARAM hContact, LPARAM lParam) -{ - if (lParam != 0) { - SmileyCategoryType *smct = g_SmileyCategories.GetSmileyCategory((unsigned)lParam - 3); - if (smct != nullptr) - opt.WriteContactCategory(hContact, smct->GetName()); - else { - CMStringW empty; - if (lParam == 1) empty = L""; - opt.WriteContactCategory(hContact, empty); - } - NotifyEventHooks(g_hevOptionsChanged, hContact, 0); - } - - for (auto &it : menuHandleArray) - Menu_RemoveItem((HGENMENU)it); - menuHandleArray.destroy(); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -INT_PTR ReloadPack(WPARAM, LPARAM lParam) -{ - if (lParam) { - SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(_A2T((char *)lParam)); - if (smc != nullptr) - smc->Load(); - } - else { - g_SmileyCategories.ClearAll(); - g_SmileyCategories.AddAllProtocolsAsCategory(); - g_SmileyCategories.ClearAndLoadAll(); - } - - NotifyEventHooks(g_hevOptionsChanged, 0, 0); - return 0; -} - -INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam) -{ - SMADD_CONT *cont = (SMADD_CONT *)lParam; - - switch (cont->type) { - case 0: - g_SmileyPackCStore.AddSmileyPack(cont->pszModule, cont->path); - NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); - break; - - case 1: - g_SmileyPackCStore.AddSmiley(cont->pszModule, cont->path); - NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); - break; - - case 2: - WIN32_FIND_DATAW findData; - CMStringW wszPath(cont->path); - HANDLE hFind = FindFirstFileW(wszPath, &findData); - if (hFind != INVALID_HANDLE_VALUE) { - int idx = wszPath.ReverseFind('\\'); - if (idx != -1) - wszPath.Truncate(idx + 1); - - do { - if (!mir_wstrcmp(findData.cFileName, L".") || !mir_wstrcmp(findData.cFileName, L".")) - continue; - - CMStringW wszFileName = wszPath + findData.cFileName; - g_SmileyPackCStore.AddSmiley(cont->pszModule, wszFileName); - } while (FindNextFileW(hFind, &findData)); - } - } - return 0; -} +static LIST menuHandleArray(5); -int RebuildContactMenu(WPARAM wParam, LPARAM) +static int RebuildContactMenu(WPARAM wParam, LPARAM) { auto &smc = g_SmileyCategories.GetSmileyCategoryList(); @@ -331,7 +255,7 @@ int RebuildContactMenu(WPARAM wParam, LPARAM) const int ind = i + 3; mi.position = ind; - mi.name.w = (wchar_t*)smc[i].GetDisplayName().c_str(); + mi.name.w = (wchar_t *)smc[i].GetDisplayName().c_str(); if (cat == smc[i].GetName()) { mi.flags |= CMIF_CHECKED; @@ -367,69 +291,138 @@ int RebuildContactMenu(WPARAM wParam, LPARAM) return 0; } +INT_PTR CustomCatMenu(WPARAM hContact, LPARAM lParam) +{ + if (lParam != 0) { + SmileyCategoryType *smct = g_SmileyCategories.GetSmileyCategory((unsigned)lParam - 3); + if (smct != nullptr) + opt.WriteContactCategory(hContact, smct->GetName()); + else { + CMStringW empty; + if (lParam == 1) empty = L""; + opt.WriteContactCategory(hContact, empty); + } + NotifyEventHooks(g_hevOptionsChanged, hContact, 0); + } + + for (auto &it : menuHandleArray) + Menu_RemoveItem((HGENMENU)it); + menuHandleArray.destroy(); + + return TRUE; +} + ///////////////////////////////////////////////////////////////////////////////////////// -// Events -int AccountListChanged(WPARAM wParam, LPARAM lParam) +static INT_PTR ReloadPack(WPARAM, LPARAM lParam) { - PROTOACCOUNT *acc = (PROTOACCOUNT*)lParam; + if (lParam) { + SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(_A2T((char *)lParam)); + if (smc != nullptr) + smc->Load(); + } + else { + g_SmileyCategories.ClearAll(); + g_SmileyCategories.AddAllProtocolsAsCategory(); + g_SmileyCategories.ClearAndLoadAll(); + } - switch (wParam) { - case PRAC_ADDED: - if (acc != nullptr) { - const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(L"Standard")->GetFilename(); - g_SmileyCategories.AddAccountAsCategory(acc, defaultFile); - } - break; + NotifyEventHooks(g_hevOptionsChanged, 0, 0); + return 0; +} - case PRAC_CHANGED: - if (acc != nullptr && acc->szModuleName != nullptr) { - CMStringW name(acc->szModuleName); - SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(name); - if (smc != nullptr) { - if (acc->tszAccountName) - name = acc->tszAccountName; - smc->SetDisplayName(name); - } - } +///////////////////////////////////////////////////////////////////////////////////////// + +static INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam) +{ + SMADD_CONT *cont = (SMADD_CONT *)lParam; + + switch (cont->type) { + case 0: + g_SmileyPackCStore.AddSmileyPack(cont->pszModule, cont->path); + NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); break; - case PRAC_REMOVED: - g_SmileyCategories.DeleteAccountAsCategory(acc); + case 1: + g_SmileyPackCStore.AddSmiley(cont->pszModule, cont->path); + NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); break; - case PRAC_CHECKED: - if (acc != nullptr) { - if (acc->bIsEnabled) { - const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(L"Standard")->GetFilename(); - g_SmileyCategories.AddAccountAsCategory(acc, defaultFile); - } - else g_SmileyCategories.DeleteAccountAsCategory(acc); + case 2: + WIN32_FIND_DATAW findData; + CMStringW wszPath(cont->path); + HANDLE hFind = FindFirstFileW(wszPath, &findData); + if (hFind != INVALID_HANDLE_VALUE) { + int idx = wszPath.ReverseFind('\\'); + if (idx != -1) + wszPath.Truncate(idx + 1); + + do { + if (!mir_wstrcmp(findData.cFileName, L".") || !mir_wstrcmp(findData.cFileName, L".")) + continue; + + CMStringW wszFileName = wszPath + findData.cFileName; + g_SmileyPackCStore.AddSmiley(cont->pszModule, wszFileName); + } while (FindNextFileW(hFind, &findData)); } - break; } return 0; } -int DbSettingChanged(WPARAM hContact, LPARAM lParam) -{ - if (hContact == 0) - return 0; - - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if (cws->value.type == DBVT_DELETED) - return 0; +///////////////////////////////////////////////////////////////////////////////////////// - if (strcmp(cws->szSetting, "Transport") == 0) { - SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(L"Standard"); - if (smc != nullptr) - g_SmileyCategories.AddContactTransportAsCategory(hContact, smc->GetFilename()); +static INT_PTR SelectSmiley(WPARAM, LPARAM lParam) +{ + auto *pParam = (SMADD_SELECTSMILEY *)lParam; + if (pParam == nullptr || !g_pEmoji) + return 1; + + SmileyPackType *pPack; + if (pParam->pszSmileys) { + ptrW pText(mir_utf8decodeW(pParam->pszSmileys)); + pPack = new SmileyPackType(); + auto &pList = g_pEmoji->GetSmileyList(); + + for (auto *p = wcstok(pText, L" "); p; p = wcstok(0, L" ")) { + for (auto &it : pList) { + if (it->GetTriggerText() == p) { + pPack->GetSmileyList().insert(new SmileyType(*it)); + break; + } + } + } } + else pPack = new SmileyPackType(*g_pEmoji); + + SmileyToolWindowParam *stwp = new SmileyToolWindowParam; + stwp->pSmileyPack = pPack; + stwp->bOwnsPack = true; + stwp->hWndParent = pParam->hWndParent; + stwp->hWndTarget = pParam->hWndTarget; + stwp->targetMessage = pParam->targetMessage; + stwp->targetWParam = pParam->targetWParam; + stwp->direction = pParam->direction; + stwp->xPosition = pParam->xPosition; + stwp->yPosition = pParam->yPosition; + mir_forkThread(SmileyToolThread, stwp); return 0; } -int ReloadColour(WPARAM, LPARAM) +///////////////////////////////////////////////////////////////////////////////////////// +// Module entry point + +void InitServices() { - opt.SelWndBkgClr = db_get_dw(0, "SmileyAdd", "SelWndBkgClr", GetSysColor(COLOR_WINDOW)); - return 0; + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, RebuildContactMenu); + + CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceSmileysCommand); + CreateServiceFunction(MS_SMILEYADD_GETINFO, GetInfoCommand); + CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfoCommand2); + CreateServiceFunction(MS_SMILEYADD_REGISTERCATEGORY, RegisterPack); + CreateServiceFunction(MS_SMILEYADD_BATCHPARSE, ParseTextBatch); + CreateServiceFunction(MS_SMILEYADD_BATCHFREE, FreeTextBatch); + CreateServiceFunction(MS_SMILEYADD_CUSTOMCATMENU, CustomCatMenu); + CreateServiceFunction(MS_SMILEYADD_RELOAD, ReloadPack); + CreateServiceFunction(MS_SMILEYADD_LOADCONTACTSMILEYS, LoadContactSmileys); + CreateServiceFunction(MS_SMILEYADD_SELECTSMILEY, SelectSmiley); } diff --git a/plugins/SmileyAdd/src/services.h b/plugins/SmileyAdd/src/services.h deleted file mode 100644 index da37065f52..0000000000 --- a/plugins/SmileyAdd/src/services.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -Miranda SmileyAdd Plugin -Copyright (C) 2005 - 2011 Boris Krasnovskiy -Copyright (C) 2003 - 2004 Rein-Peter de Boer - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef SMILEYADD_SERVICES_H_ -#define SMILEYADD_SERVICES_H_ - -// service commands -INT_PTR ReplaceSmileysCommand(WPARAM wParam, LPARAM lParam); -INT_PTR GetInfoCommand(WPARAM wParam, LPARAM); -INT_PTR GetInfoCommand2(WPARAM wParam, LPARAM); -INT_PTR RegisterPack(WPARAM wParam, LPARAM lParam); -INT_PTR ParseTextBatch(WPARAM wParam, LPARAM lParam); -INT_PTR FreeTextBatch(WPARAM wParam, LPARAM lParam); -INT_PTR CustomCatMenu(WPARAM, LPARAM lParam); -INT_PTR ReloadPack(WPARAM, LPARAM lParam); -INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam); - -// events -int RebuildContactMenu(WPARAM wParam, LPARAM); -int AccountListChanged(WPARAM wParam, LPARAM lParam); -int DbSettingChanged(WPARAM wParam, LPARAM lParam); -int ReloadColour(WPARAM, LPARAM); - -SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact = 0, SmileyPackCType **smlc = nullptr); - -#endif // SMILEYADD_SERVICES_H_ - diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp index 9aeef4becd..765d154fb1 100644 --- a/plugins/SmileyAdd/src/smltool.cpp +++ b/plugins/SmileyAdd/src/smltool.cpp @@ -713,5 +713,9 @@ void __cdecl SmileyToolThread(SmileyToolWindowParam *stwp) } UnregisterClass(L"SmileyTool", g_plugin.getInst()); } + + if (stwp->bOwnsPack) + delete stwp->pSmileyPack; + delete stwp; } diff --git a/plugins/SmileyAdd/src/smltool.h b/plugins/SmileyAdd/src/smltool.h index a2cdd74508..4a4243205c 100644 --- a/plugins/SmileyAdd/src/smltool.h +++ b/plugins/SmileyAdd/src/smltool.h @@ -22,9 +22,10 @@ along with this program. If not, see . class SmileyPackType; -struct SmileyToolWindowParam +struct SmileyToolWindowParam : public MZeroedObject { SmileyPackType *pSmileyPack; + bool bOwnsPack; int xPosition; int yPosition; int direction; diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h index 909d296f38..7db517fc71 100644 --- a/plugins/SmileyAdd/src/stdafx.h +++ b/plugins/SmileyAdd/src/stdafx.h @@ -78,7 +78,6 @@ along with this program. If not, see . #include "SmileyBase.h" #include "smileys.h" #include "customsmiley.h" -#include "services.h" #include "options.h" #include "download.h" #include "anim.h" @@ -121,6 +120,8 @@ int SmileyButtonPressed(WPARAM, LPARAM); // functions for general use (defined in general.cpp) int CalculateTextHeight(HDC hdc, CHARFORMAT2 *chf); +SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact = 0, SmileyPackCType **smlc = nullptr); + MCONTACT DecodeMetaContact(MCONTACT hContact); bool IsSmileyProto(char *proto); -- cgit v1.2.3