From cffe05b54d4ebed92421397015f949ecfa6d6764 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 30 Mar 2017 13:42:05 +0300 Subject: fix for a major crutch in QuickReplies --- plugins/QuickReplies/src/events.cpp | 37 ++++++++++------------------ plugins/QuickReplies/src/options.cpp | 41 +++++++++++++------------------ plugins/QuickReplies/src/quickreplies.cpp | 2 -- plugins/QuickReplies/src/version.h | 22 ++++++++--------- 4 files changed, 41 insertions(+), 61 deletions(-) diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp index 121d9a56ae..73f918c9d7 100644 --- a/plugins/QuickReplies/src/events.cpp +++ b/plugins/QuickReplies/src/events.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2010 Unsane This is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #include "stdafx.h" @@ -38,7 +38,7 @@ int OnModulesLoaded(WPARAM, LPARAM) { UnhookEvent(hOnModulesLoaded); - if ( !ServiceExists(MS_QUICKREPLIES_SERVICE)) { + if (!ServiceExists(MS_QUICKREPLIES_SERVICE)) { iNumber = 0; hQuickRepliesService = CreateServiceFunction(MS_QUICKREPLIES_SERVICE, QuickRepliesService); } @@ -61,7 +61,6 @@ int OnModulesLoaded(WPARAM, LPARAM) bbd.hIcon = icon.hIcolib; bbd.dwButtonID = iNumber; bbd.dwDefPos = 220; - Srmm_AddButton(&bbd); return 0; } @@ -82,8 +81,7 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) mir_snprintf(key, "RepliesCount_%x", iNumber); int count = db_get_w(NULL, MODULE, key, 0); - if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON) - { + if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON) { mir_snprintf(buttonName, "%s %x", Translate("Button"), iNumber + 1); Options_Open(L"Message Sessions", L"Quick Replies", _A2T(buttonName)); return 0; @@ -92,12 +90,10 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) HMENU hMenu = CreatePopupMenu(); LIST replyList(1); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { mir_snprintf(key, "Reply_%x_%x", iNumber, i); - wchar_t *value = db_get_wsa(NULL, MODULE, key); - - if (!value) + ptrW value(db_get_wsa(NULL, MODULE, key)); + if (value == nullptr) replyList.insert(mir_wstrdup(L"")); else replyList.insert(variables_parsedup(value, 0, wParam)); @@ -106,26 +102,19 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL); else AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i]); - - mir_free(value); } int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL); - if (index > 0) - { - if (mir_wstrcmp(replyList[index - 1], L"")) - { - HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); - if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); - - SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList[index - 1]); + if (index > 0) { + if (mir_wstrcmp(replyList[index - 1], L"")) { + CallService(MS_MSG_SENDMESSAGEW, cbcd->hContact, (LPARAM)replyList[index - 1]); mir_snprintf(key, "ImmediatelySend_%x", iNumber); - if ((BYTE)db_get_b(NULL, MODULE, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED) + if (db_get_b(NULL, MODULE, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED) SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); } } - + for (int i = 0; i < replyList.getCount(); i++) mir_free(replyList[i]); replyList.destroy(); @@ -139,4 +128,4 @@ int OnPreShutdown(WPARAM, LPARAM) UnhookEvent(hOnOptInitialized); UnhookEvent(hOnPreShutdown); return 0; -} \ No newline at end of file +} diff --git a/plugins/QuickReplies/src/options.cpp b/plugins/QuickReplies/src/options.cpp index 4f2b3ffd2c..157e6a3e85 100644 --- a/plugins/QuickReplies/src/options.cpp +++ b/plugins/QuickReplies/src/options.cpp @@ -19,35 +19,32 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" -static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_CHAR: - if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) - { // ctrl-a + if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-a SendMessage(hwnd, EM_SETSEL, 0, -1); return 0; } - if (wParam == 26 && GetKeyState(VK_CONTROL) & 0x8000) - { // ctrl-z + if (wParam == 26 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-z SendMessage(hwnd, EM_UNDO, 0, 0); return 0; } - if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) - { // ctrl-backspace + if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-backspace DWORD start, end; WCHAR text[1024]; - SendMessage(hwnd, EM_GETSEL, (WPARAM) & end, (LPARAM) (PDWORD) NULL); + SendMessage(hwnd, EM_GETSEL, (WPARAM)&end, 0); SendMessage(hwnd, WM_KEYDOWN, VK_LEFT, 0); - SendMessage(hwnd, EM_GETSEL, (WPARAM) & start, (LPARAM) (PDWORD) NULL); + SendMessage(hwnd, EM_GETSEL, (WPARAM)&start, 0); GetWindowText(hwnd, text, _countof(text)); - memmove(text + start, text + end, sizeof(WCHAR) * (mir_wstrlen(text) + 1 - end)); + memmove(text + start, text + end, sizeof(WCHAR)*(mir_wstrlen(text) + 1 - end)); SetWindowText(hwnd, text); SendMessage(hwnd, EM_SETSEL, start, start); - SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM) hwnd); + SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd); return 0; } break; @@ -58,7 +55,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { + switch (uMsg) { case WM_INITDIALOG: { char key[64]; @@ -77,12 +74,10 @@ INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR mir_snprintf(key, "RepliesCount_%x", iNumber); count = db_get_w(NULL, MODULE, key, 0); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { mir_snprintf(key, "Reply_%x_%x", iNumber, i); wchar_t *value = db_get_wsa(NULL, MODULE, key); - if (value) - { + if (value) { replies.Append(value); replies.Append(L"\r\n"); } @@ -94,7 +89,7 @@ INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_VARIABLES: variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL); break; @@ -120,8 +115,7 @@ INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR mir_snprintf(key, "RepliesCount_%x", iNumber); count = db_get_b(NULL, MODULE, key, 0); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { mir_snprintf(key, "Reply_%x_%x", iNumber, i); db_unset(NULL, MODULE, key); } @@ -137,8 +131,7 @@ INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR count = 0; int pos = -1, prev = 0; - while ((pos = replies.Find(L"\r\n", prev)) != -1) - { + while ((pos = replies.Find(L"\r\n", prev)) != -1) { mir_snprintf(key, "Reply_%x_%x", iNumber, count++); db_set_ws(NULL, MODULE, key, replies.Mid(prev, pos - prev).GetBuffer()); prev = pos + 2; @@ -150,7 +143,7 @@ INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR db_set_w(NULL, MODULE, key, count); mir_snprintf(key, "ImmediatelySend_%x", iNumber); - db_set_b(NULL, MODULE, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY)); + db_set_b(NULL, MODULE, key, IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY)); return TRUE; } @@ -181,4 +174,4 @@ int OnOptInitialized(WPARAM wParam, LPARAM) odp.pfnDlgProc = DlgProcOptionsPage; Options_AddPage(wParam, &odp); return 0; -} \ No newline at end of file +} diff --git a/plugins/QuickReplies/src/quickreplies.cpp b/plugins/QuickReplies/src/quickreplies.cpp index 475a30e06e..8e452608ff 100644 --- a/plugins/QuickReplies/src/quickreplies.cpp +++ b/plugins/QuickReplies/src/quickreplies.cpp @@ -52,12 +52,10 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) extern "C" __declspec(dllexport) int Load(void) { - mir_getLP(&pluginInfoEx); hOnModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); - return 0; } diff --git a/plugins/QuickReplies/src/version.h b/plugins/QuickReplies/src/version.h index ca6ff93917..bb1331a137 100644 --- a/plugins/QuickReplies/src/version.h +++ b/plugins/QuickReplies/src/version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 8 -#define __RELEASE_NUM 1 -#define __BUILD_NUM 0 +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 9 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 0 #include -#define __PLUGIN_NAME "Quick replies" -#define __FILENAME "QuickReplies.dll" -#define __DESCRIPTION "Plugin for quick insert (or sending) pre-defined messages in message input area." -#define __AUTHOR "Unsane" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "http://miranda-ng.org/p/QuickReplies/" -#define __COPYRIGHT "© 2010 Unsane" +#define __PLUGIN_NAME "Quick replies" +#define __FILENAME "QuickReplies.dll" +#define __DESCRIPTION "Plugin for quick insert (or sending) pre-defined messages in message input area." +#define __AUTHOR "Unsane" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://miranda-ng.org/p/QuickReplies/" +#define __COPYRIGHT "© 2010 Unsane" -- cgit v1.2.3