From f9c7760f54c279327a977b0cb5ee028c8f0c0bfb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 1 Dec 2016 20:51:42 +0300 Subject: more fixes --- plugins/BossKeyPlus/src/BossKey.cpp | 17 +++-- plugins/ExternalAPI/m_msg_buttonsbar.h | 28 -------- plugins/FTPFileYM/src/ftpfile.cpp | 21 +++--- .../MirLua/Modules/m_msg_buttonsbar/src/main.cpp | 11 +-- .../MirLua/Modules/m_msg_buttonsbar/src/stdafx.h | 1 + plugins/MirOTR/src/options.cpp | 1 - plugins/MirOTR/src/options.h | 2 +- plugins/MirOTR/src/svcs_srmm.cpp | 30 ++++---- plugins/PasteIt/src/PasteIt.cpp | 30 ++++---- plugins/QuickMessages/src/Utils.cpp | 40 +++++------ plugins/QuickMessages/src/options.cpp | 7 +- plugins/QuickReplies/src/events.cpp | 44 ++++-------- plugins/TabSRMM/src/buttonbar.h | 6 -- plugins/TabSRMM/src/buttonsbar.cpp | 41 ----------- plugins/TabSRMM/src/chat/window.cpp | 8 +-- plugins/TabSRMM/src/containeroptions.cpp | 2 +- plugins/TabSRMM/src/globals.cpp | 1 - plugins/TabSRMM/src/msgdialog.cpp | 8 +-- plugins/TabSRMM/src/msgs.h | 2 - plugins/TranslitSwitcher/src/TranslitSwitcher.cpp | 81 +++++++--------------- plugins/TranslitSwitcher/src/stdafx.h | 1 + 21 files changed, 120 insertions(+), 262 deletions(-) (limited to 'plugins') diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 5d7921af84..0c2766fa25 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -585,25 +585,24 @@ static int TabsrmmButtonPressed(WPARAM, LPARAM lParam) static int TabsrmmButtonsInit(WPARAM, LPARAM) { - BBButton bbd = { 0 }; - - bbd.cbSize = sizeof(BBButton); + BBButton bbd = {}; bbd.pszModuleName = MOD_NAME; bbd.dwDefPos = 5000; bbd.pwszTooltip = LPGENW("Hide Miranda NG"); bbd.bbbFlags = BBBF_ISRSIDEBUTTON | BBBF_CANBEHIDDEN; bbd.hIcon = iconList[0].hIcolib; - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - + Srmm_AddButton(&bbd); return 0; } -static wchar_t *VariablesBossKey(ARGUMENTSINFO *ai) { - if (ai->cbSize < sizeof(ARGUMENTSINFO)) return NULL; - if (ai->argc != 1) return NULL; +static wchar_t* VariablesBossKey(ARGUMENTSINFO *ai) +{ + if (ai->cbSize < sizeof(ARGUMENTSINFO)) + return NULL; + if (ai->argc != 1) + return NULL; ai->flags |= AIF_DONTPARSE; - return GetBossKeyText(); } diff --git a/plugins/ExternalAPI/m_msg_buttonsbar.h b/plugins/ExternalAPI/m_msg_buttonsbar.h index 11413d853b..8b73f987a3 100644 --- a/plugins/ExternalAPI/m_msg_buttonsbar.h +++ b/plugins/ExternalAPI/m_msg_buttonsbar.h @@ -1,32 +1,4 @@ #ifndef M_MSG_BUTTONSBAR_H__ #define M_MSG_BUTTONSBAR_H__ -//////////////////////////////////////////////////////////////// -//Events -// - -/////////////////////////////////////////////////// -// ButtonClicked event -// wParam = (HANDLE)hContact; -// lParam = (CustomButtonClickData *)&CustomButtonClickData; -// catch to show a popup menu, etc. -#define ME_MSG_BUTTONPRESSED "TabSRMM/ButtonsBar/ButtonPressed" - - -// event flags -#define BBCF_RIGHTBUTTON (1<<0) -#define BBCF_SHIFTPRESSED (1<<1) -#define BBCF_CONTROLPRESSED (1<<2) -#define BBCF_ARROWCLICKED (1<<3) - -typedef struct { - int cbSize; - POINT pt; // screen coordinates for menus - char* pszModule; // button owners name - DWORD dwButtonId; // registered button ID - HWND hwndFrom; // button parents HWND - MCONTACT hContact; - DWORD flags; // BBCF_ flags -} CustomButtonClickData; - #endif //M_MSG_BUTTONSBAR_H__ \ No newline at end of file diff --git a/plugins/FTPFileYM/src/ftpfile.cpp b/plugins/FTPFileYM/src/ftpfile.cpp index 143108bf41..90dc4e12eb 100644 --- a/plugins/FTPFileYM/src/ftpfile.cpp +++ b/plugins/FTPFileYM/src/ftpfile.cpp @@ -181,18 +181,15 @@ void InitHotkeys() void InitTabsrmmButton() { - if (ServiceExists(MS_BB_ADDBUTTON)) { - BBButton btn = { 0 }; - btn.cbSize = sizeof(btn); - btn.dwButtonID = 1; - btn.pszModuleName = MODULE; - btn.dwDefPos = 105; - btn.hIcon = iconList[ServerList::FTP_COUNT].hIcolib; - btn.bbbFlags = BBBF_ISARROWBUTTON | BBBF_ISIMBUTTON | BBBF_CANBEHIDDEN; - btn.pwszTooltip = TranslateT("FTP File"); - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&btn); - HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); - } + BBButton btn = {}; + btn.dwButtonID = 1; + btn.pszModuleName = MODULE; + btn.dwDefPos = 105; + btn.hIcon = iconList[ServerList::FTP_COUNT].hIcolib; + btn.bbbFlags = BBBF_ISARROWBUTTON | BBBF_ISIMBUTTON | BBBF_CANBEHIDDEN; + btn.pwszTooltip = TranslateT("FTP File"); + Srmm_AddButton(&btn); + HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); } //------------ MENU & BUTTON HANDLERS ------------// diff --git a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp index 81da1b92a9..2fcbfe320a 100644 --- a/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp +++ b/plugins/MirLua/Modules/m_msg_buttonsbar/src/main.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" +int hLangpack = 0; + static BBButton* MakeBBButton(lua_State *L) { BBButton *bbb = (BBButton*)mir_calloc(sizeof(BBButton)); - bbb->cbSize = sizeof(BBButton); bbb->dwDefPos = 100; lua_getfield(L, -1, "Module"); @@ -39,7 +40,7 @@ static int lua_AddButton(lua_State *L) BBButton* bbb = MakeBBButton(L); - INT_PTR res = CallService(MS_BB_ADDBUTTON, 0, (LPARAM)bbb); + INT_PTR res = Srmm_AddButton(bbb); lua_pushinteger(L, res); return 1; @@ -55,7 +56,7 @@ static int lua_ModifyButton(lua_State *L) BBButton* bbb = MakeBBButton(L); - INT_PTR res = CallService(MS_BB_MODIFYBUTTON, 0, (LPARAM)bbb); + INT_PTR res = Srmm_ModifyButton(bbb); lua_pushinteger(L, res); mir_free(bbb->pszModuleName); @@ -69,11 +70,11 @@ static int lua_RemoveButton(lua_State *L) { ptrA szModuleName(mir_utf8decodeA(luaL_checkstring(L, 1))); - BBButton mbb = { sizeof(BBButton) }; + BBButton mbb = {}; mbb.pszModuleName = szModuleName; mbb.dwButtonID = luaL_checkinteger(L, 2); - INT_PTR res = ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&mbb); + INT_PTR res = ::Srmm_RemoveButton(&mbb); lua_pushinteger(L, res); return 1; diff --git a/plugins/MirLua/Modules/m_msg_buttonsbar/src/stdafx.h b/plugins/MirLua/Modules/m_msg_buttonsbar/src/stdafx.h index 89ca58c4fd..50b75904b4 100644 --- a/plugins/MirLua/Modules/m_msg_buttonsbar/src/stdafx.h +++ b/plugins/MirLua/Modules/m_msg_buttonsbar/src/stdafx.h @@ -7,6 +7,7 @@ #include #include +#include #include #endif //_COMMON_H_ \ No newline at end of file diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index f0382af233..ea2050bbf6 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -89,7 +89,6 @@ void LoadOptions() options.bHavePopups = 0 != ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_SHOWMESSAGE); options.bHaveSecureIM = 0 != ServiceExists("SecureIM/IsContactSecured"); - options.bHaveButtonsBar = 0 != ServiceExists(MS_BB_ADDBUTTON); LoadFilenames(); } diff --git a/plugins/MirOTR/src/options.h b/plugins/MirOTR/src/options.h index 1aca058985..17efb1c139 100644 --- a/plugins/MirOTR/src/options.h +++ b/plugins/MirOTR/src/options.h @@ -32,7 +32,7 @@ typedef struct { bool end_offline, end_window_close; // temporary options - bool bHavePopups, bHaveSecureIM, bHaveButtonsBar; + bool bHavePopups, bHaveSecureIM; } Options; diff --git a/plugins/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/src/svcs_srmm.cpp index 485f7b73bb..882d0eaf70 100644 --- a/plugins/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/src/svcs_srmm.cpp @@ -65,8 +65,8 @@ void SetEncryptionStatus(MCONTACT hContact, TrustLevel level) Srmm_ModifyIcon(hContact, &sid); Srmm_ModifyIcon(hContact, &sid2); + Srmm_SetButtonState(hContact, &button); - if (options.bHaveButtonsBar) CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&button); db_set_dw(hContact, MODULENAME, "TrustLevel", level); if (!chat_room) { @@ -88,14 +88,14 @@ void SetEncryptionStatus(MCONTACT hContact, TrustLevel level) int SVC_ButtonsBarLoaded(WPARAM, LPARAM) { - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&OTRButton); + Srmm_AddButton(&OTRButton); return 0; } int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) { - CustomButtonClickData* cbcd = (CustomButtonClickData *)l; - if (cbcd->cbSize == sizeof(CustomButtonClickData) && cbcd->dwButtonId == 0 && mir_strcmp(cbcd->pszModule, MODULENAME)==0) { + CustomButtonClickData *cbcd = (CustomButtonClickData *)l; + if (cbcd->dwButtonId == 0 && !mir_strcmp(cbcd->pszModule, MODULENAME)) { MCONTACT hContact = (MCONTACT)w; char *proto = GetContactProto(hContact); @@ -133,19 +133,17 @@ void InitSRMM() // hook the window events so that we can can change the status of the icon HookEvent(ME_MSG_ICONPRESSED, SVC_IconPressed); - if (options.bHaveButtonsBar) { - memset(&OTRButton, 0, sizeof(OTRButton)); - OTRButton.cbSize = sizeof(OTRButton); - OTRButton.dwButtonID = 0; - OTRButton.pszModuleName = MODULENAME; - OTRButton.dwDefPos = 200; - OTRButton.bbbFlags = BBBF_ISRSIDEBUTTON|BBBF_CANBEHIDDEN|BBBF_ISIMBUTTON; - OTRButton.pwszTooltip = TranslateT(LANG_OTR_TOOLTIP); - OTRButton.hIcon = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); - HookEvent(ME_MSG_TOOLBARLOADED, SVC_ButtonsBarLoaded); - HookEvent(ME_MSG_BUTTONPRESSED, SVC_ButtonsBarPressed); - } + memset(&OTRButton, 0, sizeof(OTRButton)); + OTRButton.pszModuleName = MODULENAME; + OTRButton.dwDefPos = 200; + OTRButton.bbbFlags = BBBF_ISRSIDEBUTTON | BBBF_CANBEHIDDEN | BBBF_ISIMBUTTON; + OTRButton.pwszTooltip = TranslateT(LANG_OTR_TOOLTIP); + OTRButton.hIcon = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); + + HookEvent(ME_MSG_TOOLBARLOADED, SVC_ButtonsBarLoaded); + HookEvent(ME_MSG_BUTTONPRESSED, SVC_ButtonsBarPressed); } + void DeinitSRMM() { IcoLib_Release(ICON_NOT_PRIVATE, 0); diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index eb34cf7634..c36034cd26 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -336,23 +336,19 @@ void DefWebPageChanged() void InitTabsrmmButton() { - if (ServiceExists(MS_BB_ADDBUTTON)) - { - BBButton btn = { 0 }; - btn.cbSize = sizeof(btn); - btn.dwButtonID = 1; - btn.pszModuleName = MODULE; - btn.dwDefPos = 110; - btn.hIcon = icon.hIcolib; - btn.bbbFlags = BBBF_ISARROWBUTTON | BBBF_ISIMBUTTON | BBBF_CANBEHIDDEN | BBBF_ISCHATBUTTON; - btn.pwszTooltip = TranslateT("Paste It"); - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&btn); - - if (hTabsrmmButtonPressed != NULL) - UnhookEvent(hTabsrmmButtonPressed); - - hTabsrmmButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); - } + BBButton btn = {}; + btn.dwButtonID = 1; + btn.pszModuleName = MODULE; + btn.dwDefPos = 110; + btn.hIcon = icon.hIcolib; + btn.bbbFlags = BBBF_ISARROWBUTTON | BBBF_ISIMBUTTON | BBBF_CANBEHIDDEN | BBBF_ISCHATBUTTON; + btn.pwszTooltip = TranslateT("Paste It"); + Srmm_AddButton(&btn); + + if (hTabsrmmButtonPressed != NULL) + UnhookEvent(hTabsrmmButtonPressed); + + hTabsrmmButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); } int WindowEvent(WPARAM, MessageWindowEventData* lParam) diff --git a/plugins/QuickMessages/src/Utils.cpp b/plugins/QuickMessages/src/Utils.cpp index e7eb41f334..015c19f6e0 100644 --- a/plugins/QuickMessages/src/Utils.cpp +++ b/plugins/QuickMessages/src/Utils.cpp @@ -239,27 +239,24 @@ static HANDLE AddIcon(char* szIcoName) DWORD BalanceButtons(int buttonsWas, int buttonsNow) { - if (!ServiceExists(MS_BB_ADDBUTTON)) { - BBButton bb = { sizeof(bb) }; - bb.pszModuleName = PLGNAME; + BBButton bb = {}; + bb.pszModuleName = PLGNAME; - while (buttonsWas > buttonsNow) { - bb.dwButtonID = --buttonsWas; - CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bb); - } + while (buttonsWas > buttonsNow) { + bb.dwButtonID = --buttonsWas; + Srmm_RemoveButton(&bb); + } - while (buttonsWas < buttonsNow) { - if (ServiceExists(MS_BB_ADDBUTTON)) { - char iconname[40]; - mir_snprintf(iconname, LPGEN("Quick Messages Button %u"), buttonsWas); - bb.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; - bb.dwButtonID = buttonsWas++; - bb.dwDefPos = 300 + buttonsWas; - bb.hIcon = AddIcon(iconname); - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bb); - } - } + while (buttonsWas < buttonsNow) { + char iconname[40]; + mir_snprintf(iconname, LPGEN("Quick Messages Button %u"), buttonsWas); + bb.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; + bb.dwButtonID = buttonsWas++; + bb.dwDefPos = 300 + buttonsWas; + bb.hIcon = AddIcon(iconname); + Srmm_AddButton(&bb); } + return buttonsNow; } @@ -366,23 +363,20 @@ wchar_t* getMenuEntry(int buttonnum, int entrynum, BYTE mode) int RegisterCustomButton(WPARAM, LPARAM) { - if (!ServiceExists(MS_BB_ADDBUTTON)) - return 1; - for (int i = 0; i < g_iButtonsCount; i++) { ListData* ld = ButtonsList[i]; char iconname[40]; mir_snprintf(iconname, LPGEN("Quick Messages Button %u"), i); - BBButton bbd = { sizeof(bbd) }; + BBButton bbd = {}; bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; bbd.dwButtonID = i; bbd.dwDefPos = 320 + i; bbd.hIcon = AddIcon(iconname); bbd.pszModuleName = PLGNAME; bbd.pwszTooltip = ld->ptszButtonName; - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + Srmm_AddButton(&bbd); } return 0; } diff --git a/plugins/QuickMessages/src/options.cpp b/plugins/QuickMessages/src/options.cpp index 944727dcbb..482d750c79 100644 --- a/plugins/QuickMessages/src/options.cpp +++ b/plugins/QuickMessages/src/options.cpp @@ -252,13 +252,12 @@ void SaveMenuTree() } - if (ServiceExists(MS_BB_MODIFYBUTTON) && ((ld->dwOPFlags&QMF_NEW) || (ld->dwOPFlags&QMF_RENAMED) || bDeleted)) { + if (((ld->dwOPFlags & QMF_NEW) || (ld->dwOPFlags & QMF_RENAMED) || bDeleted)) { BBButton bb = { 0 }; - bb.cbSize = sizeof(BBButton); bb.pszModuleName = PLGNAME; bb.dwButtonID = iBl; bb.pwszTooltip = ld->ptszButtonName; - CallService(MS_BB_MODIFYBUTTON, 0, (LPARAM)&bb); + Srmm_ModifyButton(&bb); } @@ -278,7 +277,7 @@ void SaveMenuTree() for (i = 0; i < sl->realCount; i++) { ButtonData * bd = (ButtonData *)sl->items[i]; - if (bd->dwOPFlags&QMF_DELETNEEDED) { + if (bd->dwOPFlags & QMF_DELETNEEDED) { RemoveMenuEntryNode(sl, i--); continue; } diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp index 1839bc891a..121d9a56ae 100644 --- a/plugins/QuickReplies/src/events.cpp +++ b/plugins/QuickReplies/src/events.cpp @@ -48,25 +48,21 @@ int OnModulesLoaded(WPARAM, LPARAM) hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized); hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); - if ( ServiceExists(MS_BB_ADDBUTTON)) { - Icon_Register(hInstance, "TabSRMM/Quick Replies", &icon, 1); - - char buttonNameTranslated[32], buttonName[32]; - mir_snprintf(buttonNameTranslated, "%s %x", Translate("Button"), iNumber + 1); - mir_snprintf(buttonName, MODULE" %x", iNumber + 1); - - BBButton bbd = {0}; - bbd.cbSize = sizeof(BBButton); - bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; - bbd.pszModuleName = buttonName; - bbd.pwszTooltip = LPGENW("Quick Replies\r\nLeft button - open menu\r\nRight button - options page"); - bbd.hIcon = icon.hIcolib; - bbd.dwButtonID = iNumber; - bbd.dwDefPos = 220; - - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - } + Icon_Register(hInstance, "TabSRMM/Quick Replies", &icon, 1); + + char buttonNameTranslated[32], buttonName[32]; + mir_snprintf(buttonNameTranslated, "%s %x", Translate("Button"), iNumber + 1); + mir_snprintf(buttonName, MODULE" %x", iNumber + 1); + + BBButton bbd = {}; + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; + bbd.pszModuleName = buttonName; + bbd.pwszTooltip = LPGENW("Quick Replies\r\nLeft button - open menu\r\nRight button - options page"); + bbd.hIcon = icon.hIcolib; + bbd.dwButtonID = iNumber; + bbd.dwDefPos = 220; + Srmm_AddButton(&bbd); return 0; } @@ -139,18 +135,6 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) int OnPreShutdown(WPARAM, LPARAM) { - if (ServiceExists(MS_BB_REMOVEBUTTON)) - { - char buttonName[32]; - mir_snprintf(buttonName, MODULE" %x", iNumber + 1); - - BBButton bbd = {0}; - bbd.cbSize = sizeof(BBButton); - bbd.pszModuleName = buttonName; - bbd.dwButtonID = iNumber; - - CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); - } UnhookEvent(hOnButtonPressed); UnhookEvent(hOnOptInitialized); UnhookEvent(hOnPreShutdown); diff --git a/plugins/TabSRMM/src/buttonbar.h b/plugins/TabSRMM/src/buttonbar.h index 52201ebb12..b29538554e 100644 --- a/plugins/TabSRMM/src/buttonbar.h +++ b/plugins/TabSRMM/src/buttonbar.h @@ -1,20 +1,14 @@ #ifndef _BUTTONSBAR_H #define _BUTTONSBAR_H -#define MIN_CBUTTONID 4000 -#define MAX_CBUTTONID 5000 - -struct CustomButtonData; struct TWindowData; -void CB_DeInitCustomButtons(); void CB_InitCustomButtons(); void BB_InitDlgButtons(TWindowData *dat); void BB_RefreshTheme(const TWindowData *dat); BOOL BB_SetButtonsPos(TWindowData *dat); void BB_RedrawButtons(TWindowData *dat); -void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code); void CB_DestroyAllButtons(HWND hwndDlg); void CB_DestroyButton(HWND hwndDlg, TWindowData *dat, DWORD dwButtonCID, DWORD dwFlags); diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index c44e2cba44..7c39d01b8c 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" -HANDLE hHookButtonPressedEvt; - ///////////////////////////////////////////////////////////////////////////////////////// // Global functions @@ -396,38 +394,6 @@ BOOL BB_SetButtonsPos(TWindowData *dat) return EndDeferWindowPos(hdwp); } -void BB_CustomButtonClick(TWindowData *dat, DWORD idFrom, HWND hwndFrom, BOOL code) -{ - RECT rc; - GetWindowRect(hwndFrom, &rc); - - bool bFromArrow = false; - - CustomButtonClickData cbcd = { 0 }; - cbcd.cbSize = sizeof(cbcd); - cbcd.pt.x = rc.left; - cbcd.pt.y = rc.bottom; - - CustomButtonData *cbd; - for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { - if (cbd->m_dwButtonCID == idFrom) { - cbcd.pszModule = cbd->m_pszModuleName; - cbcd.dwButtonId = cbd->m_dwButtonOrigID; - } - else if (cbd->m_dwArrowCID == idFrom) { - bFromArrow = true; - cbcd.pszModule = cbd->m_pszModuleName; - cbcd.dwButtonId = cbd->m_dwButtonOrigID; - } - } - - cbcd.hwndFrom = dat->hwnd; - cbcd.hContact = dat->hContact; - cbcd.flags = (code ? BBCF_RIGHTBUTTON : 0) | (GetKeyState(VK_SHIFT) & 0x8000 ? BBCF_SHIFTPRESSED : 0) | (GetKeyState(VK_CONTROL) & 0x8000 ? BBCF_CONTROLPRESSED : 0) | (bFromArrow ? BBCF_ARROWCLICKED : 0); - - NotifyEventHooks(hHookButtonPressedEvt, dat->hContact, (LPARAM)&cbcd); -} - void CB_DestroyAllButtons(HWND hwndDlg) { CustomButtonData *cbd; @@ -474,12 +440,5 @@ void CB_ChangeButton(HWND hwndDlg, TWindowData *dat, CustomButtonData *cbd) void CB_InitCustomButtons() { - hHookButtonPressedEvt = CreateHookableEvent(ME_MSG_BUTTONPRESSED); - HookEvent(ME_MSG_TOOLBARLOADED, CB_InitDefaultButtons); } - -void CB_DeInitCustomButtons() -{ - DestroyHookableEvent(hHookButtonPressedEvt); -} diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 646a4398f1..423320a909 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2074,7 +2074,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar { DWORD idFrom = GetDlgCtrlID((HWND)wParam); if (idFrom >= MIN_CBUTTONID && idFrom <= MAX_CBUTTONID) - BB_CustomButtonClick(dat, idFrom, (HWND)wParam, 1); + Srmm_ClickToolbarIcon(dat->hContact, idFrom, (HWND)wParam, 1); } break; @@ -2611,7 +2611,7 @@ LABEL_SHOWWINDOW: case WM_COMMAND: if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID){ - BB_CustomButtonClick(dat, LOWORD(wParam), GetDlgItem(hwndDlg, LOWORD(wParam)), 0); + Srmm_ClickToolbarIcon(dat->hContact, LOWORD(wParam), GetDlgItem(hwndDlg, LOWORD(wParam)), 0); break; } @@ -3196,7 +3196,7 @@ LABEL_SHOWWINDOW: UpdateStatusBar(dat); break; - case DM_BBNEEDUPDATE: + case WM_CBD_UPDATED: if (lParam) CB_ChangeButton(hwndDlg, dat, (CustomButtonData*)lParam); else @@ -3205,7 +3205,7 @@ LABEL_SHOWWINDOW: BB_SetButtonsPos(dat); return 0; - case DM_CBDESTROY: + case WM_CBD_REMOVED: if (lParam) CB_DestroyButton(hwndDlg, dat, (DWORD)wParam, (DWORD)lParam); else diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp index c3adeb98e6..b8c57dd415 100644 --- a/plugins/TabSRMM/src/containeroptions.cpp +++ b/plugins/TabSRMM/src/containeroptions.cpp @@ -93,7 +93,7 @@ void TSAPI ApplyContainerSetting(TContainerData *pContainer, DWORD flags, UINT m if (fForceResize) SendMessage(pContainer->hwnd, WM_SIZE, 0, 1); - BroadCastContainer(pContainer, DM_BBNEEDUPDATE, 0, 0); + BroadCastContainer(pContainer, WM_CBD_UPDATED, 0, 0); } #define NR_O_PAGES 10 diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index fe655afa41..71b2a095c1 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -470,7 +470,6 @@ int CGlobals::PreshutdownSendRecv(WPARAM, LPARAM) db_set_dw(hContact, SRMSGMOD_T, "messagecount", 0); ::SI_DeinitStatusIcons(); - ::CB_DeInitCustomButtons(); // the event API DestroyHookableEvent(PluginConfig.m_event_MsgWin); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 567673c5a5..cb92cdf4e0 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2595,7 +2595,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l // custom button handling if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) { - BB_CustomButtonClick(dat, LOWORD(wParam), GetDlgItem(hwndDlg, LOWORD(wParam)), 0); + Srmm_ClickToolbarIcon(dat->hContact, LOWORD(wParam), GetDlgItem(hwndDlg, LOWORD(wParam)), 0); break; } @@ -2848,7 +2848,7 @@ quote_from_last: { DWORD idFrom = GetDlgCtrlID((HWND)wParam); if (idFrom >= MIN_CBUTTONID && idFrom <= MAX_CBUTTONID) { - BB_CustomButtonClick(dat, idFrom, (HWND)wParam, 1); + Srmm_ClickToolbarIcon(dat->hContact, idFrom, (HWND)wParam, 1); break; } } @@ -3004,7 +3004,7 @@ quote_from_last: } return 0; - case DM_BBNEEDUPDATE: + case WM_CBD_UPDATED: if (lParam) CB_ChangeButton(hwndDlg, dat, (CustomButtonData*)lParam); else @@ -3013,7 +3013,7 @@ quote_from_last: BB_SetButtonsPos(dat); return 0; - case DM_CBDESTROY: + case WM_CBD_REMOVED: if (lParam) CB_DestroyButton(hwndDlg, dat, (DWORD)wParam, (DWORD)lParam); else diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index a765921139..38911e1741 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -573,8 +573,6 @@ struct TNewWindowData #define DM_PLAYINCOMINGSOUND (TM_USER+92) #define DM_SENDMESSAGECOMMANDW (TM_USER+93) #define DM_REMOVEPOPUPS (TM_USER+94) -#define DM_BBNEEDUPDATE (TM_USER+96) -#define DM_CBDESTROY (TM_USER+97) #define DM_LOGSTATUSCHANGE (TM_USER+98) #define DM_SC_BUILDLIST (TM_USER+100) #define DM_SC_INITDIALOG (TM_USER+101) diff --git a/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp b/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp index 497e429a3d..21bdd2b69e 100644 --- a/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp +++ b/plugins/TranslitSwitcher/src/TranslitSwitcher.cpp @@ -80,63 +80,31 @@ INT_PTR ServiceInvert(WPARAM, LPARAM lParam) int OnModulesLoaded(WPARAM, LPARAM) { HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); - if (ServiceExists(MS_BB_ADDBUTTON)) { - Icon_Register(hInst, "TabSRMM/TranslitSwitcher", iconList, _countof(iconList)); - - BBButton bbd = { 0 }; - bbd.cbSize = sizeof(BBButton); - bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; - bbd.pszModuleName = "Switch Layout and Send"; - bbd.pwszTooltip = TranslateT("Switch Layout and Send"); - bbd.hIcon = iconList[0].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 30; - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - - bbd.pszModuleName = "Translit and Send"; - bbd.pwszTooltip = TranslateT("Translit and Send"); - bbd.hIcon = iconList[1].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 40; - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - - bbd.pszModuleName = "Invert Case and Send"; - bbd.pwszTooltip = TranslateT("Invert Case and Send"); - bbd.hIcon = iconList[2].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 50; - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - } - return 0; -} -int OnPreShutdown(WPARAM, LPARAM) -{ - if (ServiceExists(MS_BB_REMOVEBUTTON)) { - BBButton bbd = { 0 }; - bbd.cbSize = sizeof(BBButton); - bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; - bbd.pszModuleName = "Switch Layout and Send"; - bbd.pwszTooltip = TranslateT("Switch Layout and Send"); - bbd.hIcon = iconList[0].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 30; - CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); - - bbd.pszModuleName = "Translit and Send"; - bbd.pwszTooltip = TranslateT("Translit and Send"); - bbd.hIcon = iconList[1].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 40; - CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); - - bbd.pszModuleName = "Invert Case and Send"; - bbd.pwszTooltip = TranslateT("Invert Case and Send"); - bbd.hIcon = iconList[2].hIcolib; - bbd.dwButtonID = 1; - bbd.dwDefPos = 50; - CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd); - } + Icon_Register(hInst, "TabSRMM/TranslitSwitcher", iconList, _countof(iconList)); + + BBButton bbd = {}; + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; + bbd.pszModuleName = "Switch Layout and Send"; + bbd.pwszTooltip = TranslateT("Switch Layout and Send"); + bbd.hIcon = iconList[0].hIcolib; + bbd.dwButtonID = 1; + bbd.dwDefPos = 30; + Srmm_AddButton(&bbd); + + bbd.pszModuleName = "Translit and Send"; + bbd.pwszTooltip = TranslateT("Translit and Send"); + bbd.hIcon = iconList[1].hIcolib; + bbd.dwButtonID = 1; + bbd.dwDefPos = 40; + Srmm_AddButton(&bbd); + + bbd.pszModuleName = "Invert Case and Send"; + bbd.pwszTooltip = TranslateT("Invert Case and Send"); + bbd.hIcon = iconList[2].hIcolib; + bbd.dwButtonID = 1; + bbd.dwDefPos = 50; + Srmm_AddButton(&bbd); return 0; } @@ -151,7 +119,6 @@ extern "C" __declspec(dllexport) int Load(void) CreateServiceFunction(MS_TS_INVERTCASE, ServiceInvert); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); HOTKEYDESC hkd = { sizeof(hkd) }; hkd.dwFlags = HKD_UNICODE; diff --git a/plugins/TranslitSwitcher/src/stdafx.h b/plugins/TranslitSwitcher/src/stdafx.h index 662bef8ed7..b0c897172d 100644 --- a/plugins/TranslitSwitcher/src/stdafx.h +++ b/plugins/TranslitSwitcher/src/stdafx.h @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. #include #include +#include #include #include #include -- cgit v1.2.3