From bd80013253c1fabc856c05c4f839d00ec18b2b06 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 23 Jul 2012 12:31:44 +0000 Subject: QuickMessages, QuickReplies: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1119 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/QuickReplies/Icons/qicon.ico | Bin 2038 -> 0 bytes plugins/QuickReplies/common.h | 71 ------- .../QuickReplies/docs/quickreplies-translation.txt | 17 ++ plugins/QuickReplies/events.cpp | 186 ------------------ plugins/QuickReplies/options.cpp | 210 --------------------- plugins/QuickReplies/quickreplies-translation.txt | 17 -- plugins/QuickReplies/quickreplies.cpp | 69 ------- plugins/QuickReplies/quickreplies_10.vcxproj | 31 ++- .../QuickReplies/quickreplies_10.vcxproj.filters | 21 +-- plugins/QuickReplies/res/qicon.ico | Bin 0 -> 2038 bytes plugins/QuickReplies/res/resources.rc | 129 +++++++++++++ plugins/QuickReplies/res/version.rc | 117 ++++++++++++ plugins/QuickReplies/resource.h | 29 --- plugins/QuickReplies/resources.rc | 129 ------------- plugins/QuickReplies/src/common.h | 71 +++++++ plugins/QuickReplies/src/events.cpp | 186 ++++++++++++++++++ plugins/QuickReplies/src/options.cpp | 210 +++++++++++++++++++++ plugins/QuickReplies/src/quickreplies.cpp | 69 +++++++ plugins/QuickReplies/src/resource.h | 29 +++ plugins/QuickReplies/src/version.h | 20 ++ plugins/QuickReplies/version.h | 20 -- plugins/QuickReplies/version.rc | 117 ------------ 22 files changed, 868 insertions(+), 880 deletions(-) delete mode 100644 plugins/QuickReplies/Icons/qicon.ico delete mode 100644 plugins/QuickReplies/common.h create mode 100644 plugins/QuickReplies/docs/quickreplies-translation.txt delete mode 100644 plugins/QuickReplies/events.cpp delete mode 100644 plugins/QuickReplies/options.cpp delete mode 100644 plugins/QuickReplies/quickreplies-translation.txt delete mode 100644 plugins/QuickReplies/quickreplies.cpp create mode 100644 plugins/QuickReplies/res/qicon.ico create mode 100644 plugins/QuickReplies/res/resources.rc create mode 100644 plugins/QuickReplies/res/version.rc delete mode 100644 plugins/QuickReplies/resource.h delete mode 100644 plugins/QuickReplies/resources.rc create mode 100644 plugins/QuickReplies/src/common.h create mode 100644 plugins/QuickReplies/src/events.cpp create mode 100644 plugins/QuickReplies/src/options.cpp create mode 100644 plugins/QuickReplies/src/quickreplies.cpp create mode 100644 plugins/QuickReplies/src/resource.h create mode 100644 plugins/QuickReplies/src/version.h delete mode 100644 plugins/QuickReplies/version.h delete mode 100644 plugins/QuickReplies/version.rc (limited to 'plugins/QuickReplies') diff --git a/plugins/QuickReplies/Icons/qicon.ico b/plugins/QuickReplies/Icons/qicon.ico deleted file mode 100644 index 23c3765fd9..0000000000 Binary files a/plugins/QuickReplies/Icons/qicon.ico and /dev/null differ diff --git a/plugins/QuickReplies/common.h b/plugins/QuickReplies/common.h deleted file mode 100644 index e65994372c..0000000000 --- a/plugins/QuickReplies/common.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (C) 2010 Unsane - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This 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 -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. -*/ - - -#ifndef __QUICK_REPLY_H__ -#define __QUICK_REPLY_H__ - -#define MIRANDA_VER 0x0A00 - -#include -#include -#include - -#include "tchar.h" - -#include -#include -#include -#include -#include -#include - -#include "m_msg_buttonsbar.h" -#include "m_variables.h" - -#include "resource.h" -#include "version.h" - -#define MODULE_NAME __INTERNAL_NAME -#define TEXT_LIMIT 2048 -#define IDC_MESSAGE 1002 -#define IDC_CHATMESSAGE 1009 - -#define MS_QUICKREPLIES_SERVICE MODULE_NAME"/Service" - -extern HINSTANCE hInstance; - -extern BYTE iNumber; - -extern HANDLE hOnOptInitialized; -extern HANDLE hOnButtonPressed; -extern HANDLE hQuickRepliesService; -extern HANDLE hOnModulesLoaded; -extern HANDLE hOnPreShutdown; - -typedef std::wstring tString; - -INT_PTR QuickRepliesService(WPARAM wParam, LPARAM lParam); - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam); -int OnOptInitialized(WPARAM wParam, LPARAM lParam); -int OnButtonPressed(WPARAM wParam, LPARAM lParam); -int OnPreShutdown(WPARAM wParam, LPARAM lParam); - -#endif //__QUICK_REPLY_H__ \ No newline at end of file diff --git a/plugins/QuickReplies/docs/quickreplies-translation.txt b/plugins/QuickReplies/docs/quickreplies-translation.txt new file mode 100644 index 0000000000..fae9a1e2b2 --- /dev/null +++ b/plugins/QuickReplies/docs/quickreplies-translation.txt @@ -0,0 +1,17 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/QuickReplies/events.cpp +;[Button] + +; ../../plugins/QuickReplies/options.cpp +;[Message Sessions] +;[Quick Replies] + +; ../../plugins/QuickReplies/resources.rc +;[- Add \"---\" for separator.] +;[- Add your replies, one per line.] +;[- Press [v] button for variable's help.] +;[Hints:] +;[Send replies immediately] +;[Variables] diff --git a/plugins/QuickReplies/events.cpp b/plugins/QuickReplies/events.cpp deleted file mode 100644 index 2227c6d6f1..0000000000 --- a/plugins/QuickReplies/events.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* -Copyright (C) 2010 Unsane - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This 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 -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. -*/ - -#include "common.h" - -using namespace std; - -BYTE iNumber; - -HANDLE hOnOptInitialized; -HANDLE hOnButtonPressed; -HANDLE hQuickRepliesService; - -INT_PTR QuickRepliesService(WPARAM, LPARAM) -{ - return TRUE; -} - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - UnhookEvent(hOnModulesLoaded); - HANDLE hIcon = NULL; - char buttonName[32]; - - if (!ServiceExists(MS_QUICKREPLIES_SERVICE)) - { - iNumber = 0; - hQuickRepliesService = CreateServiceFunction(MS_QUICKREPLIES_SERVICE, QuickRepliesService); - } - else iNumber = DBGetContactSettingByte(NULL, MODULE_NAME, "InstancesCount", 0); - DBWriteContactSettingByte(NULL, MODULE_NAME, "InstancesCount", iNumber + 1); - - hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized); - hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); - - char buttonNameTranslated[32]; - mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1); - mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x",Translate("Button"), iNumber + 1); - - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(sid); - sid.pszSection = "TabSRMM/Quick Replies"; - sid.cx = sid.cy = 16; - sid.pszDescription = buttonNameTranslated; - sid.pszName = buttonName; - sid.hDefaultIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QICON)); - hIcon = Skin_AddIcon(&sid); - - if (ServiceExists(MS_BB_ADDBUTTON)) { - mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1); - - BBButton bbd = {0}; - bbd.cbSize = sizeof(BBButton); - bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON; - bbd.pszModuleName = buttonName; - bbd.ptszTooltip = _T("Quick Replies\r\nLeft button - open menu\r\nRight button - options page"); - bbd.hIcon = hIcon; - bbd.dwButtonID = iNumber; - bbd.dwDefPos = 220; - - CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); - } - - return 0; -} - -int OnButtonPressed(WPARAM wParam, LPARAM lParam) -{ - char key[64]; - int index = 0; - int count = 0; - HMENU hMenu = NULL; - char buttonName[32]; - tString replies = _T(""); - vector replyList; - CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; - - mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1); - if (strcmp(cbcd->pszModule, buttonName)) - return 0; - - if (cbcd->dwButtonId != iNumber) - return 1; - - mir_snprintf(key, 64, "RepliesCount_%x", iNumber); - count = DBGetContactSettingWord(NULL, MODULE_NAME, key, 0); - - { - if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON) - { - mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1); - - OPENOPTIONSDIALOG ood = {0}; - ood.cbSize = sizeof(ood); - ood.pszGroup = "Message Sessions"; - ood.pszPage = "Quick Replies"; - ood.pszTab = buttonName; - - CallService(MS_OPT_OPENOPTIONS, NULL, (LPARAM)&ood); - - return 0; - } - - hMenu = CreatePopupMenu(); - - DBVARIANT dbv = {0}; - - for (int i = 0; i < count; i++) - { - mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); - DBGetContactSettingTString(NULL, MODULE_NAME, key, &dbv); - - if (dbv.ptszVal == NULL) - replyList.push_back(_T("")); - else - replyList.push_back((TCHAR*)variables_parsedup(dbv.ptszVal, 0, (HANDLE)wParam)); - - if (_tcscmp(dbv.ptszVal, _T("---"))) - AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i].c_str()); - else - AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL); - } - - DBFreeVariant(&dbv); - } - - { - int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL); - if (index > 0) - { - if (_tcscmp(replyList.at(index - 1).c_str(), _T(""))) - { - HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); - if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); - - SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList.at(index - 1).c_str()); - - mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); - if ((BYTE)DBGetContactSettingByte(NULL, MODULE_NAME, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED) - SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); - } - } - } - - for (std::vector::reverse_iterator item = replyList.rbegin(); item != replyList.rend(); ++item) - ((tString)*item).clear(); - replyList.clear(); - - return 1; -} - -int OnPreShutdown(WPARAM wParam, LPARAM lParam) -{ - if (ServiceExists(MS_BB_REMOVEBUTTON)) - { - char buttonName[32]; - mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %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); - return 0; -} \ No newline at end of file diff --git a/plugins/QuickReplies/options.cpp b/plugins/QuickReplies/options.cpp deleted file mode 100644 index 3c96f42e89..0000000000 --- a/plugins/QuickReplies/options.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* -Copyright (C) 2010 Unsane - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This 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 -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. -*/ - -#include "common.h" - -static WNDPROC OldMessageEditProc; - -static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) - { - case WM_CHAR: - { - 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 - SendMessage(hwnd, EM_UNDO, 0, 0); - return 0; - } - - 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, WM_KEYDOWN, VK_LEFT, 0); - SendMessage(hwnd, EM_GETSEL, (WPARAM) & start, (LPARAM) (PDWORD) NULL); - GetWindowText(hwnd, text, 1024); - MoveMemory(text + start, text + end, sizeof(WCHAR) * (wcslen(text) + 1 - end)); - SetWindowText(hwnd, text); - //SAFE_FREE((void**)&text); - SendMessage(hwnd, EM_SETSEL, start, start); - SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM) hwnd); - return 0; - } - } - break; - } - - return CallWindowProc(OldMessageEditProc, hwnd, msg, wParam, lParam); -} - -INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - { - char key[64]; - int count = 0; - DBVARIANT dbv = {0}; - tString replies = _T(""); - - TranslateDialogDefault(hwndDlg); - variables_skin_helpbutton(hwndDlg, IDC_VARIABLES); - - SendDlgItemMessage(hwndDlg, IDC_REPLIES, EM_LIMITTEXT, TEXT_LIMIT, 0); - OldMessageEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_REPLIES), GWLP_WNDPROC, (LONG_PTR)MessageEditSubclassProc); - - mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); - CheckDlgButton(hwndDlg, IDC_IMMEDIATELY, (BYTE)DBGetContactSettingWord(NULL, MODULE_NAME, key, 1)); - - mir_snprintf(key, 64, "RepliesCount_%x", iNumber); - count = DBGetContactSettingWord(NULL, MODULE_NAME, key, 0); - - for (int i = 0; i < count; i++) - { - mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); - if (!DBGetContactSettingTString(NULL, MODULE_NAME, key, &dbv)) - if(dbv.ptszVal != NULL) - replies.append(dbv.ptszVal); - if (i < count - 1) - replies.append(_T("\r\n")); - } - SetDlgItemText(hwndDlg, IDC_REPLIES, replies.c_str()); - - DBFreeVariant(&dbv); - - return TRUE; - } - break; - - case WM_COMMAND: - { - if (HIWORD(wParam) == BN_CLICKED) - { - switch(LOWORD(wParam)) - { - case IDC_VARIABLES: - { - variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL); - } - break; - - case IDC_IMMEDIATELY: - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - } - } - break; - - case WM_NOTIFY: - { - NMHDR *p = ((LPNMHDR)lParam); - - switch (p->code) - { - case PSN_APPLY: - { - char key[64]; - int count = 0; - TCHAR tszReplies[TEXT_LIMIT]; - - mir_snprintf(key, 64, "RepliesCount_%x", iNumber); - count = DBGetContactSettingByte(NULL, MODULE_NAME, key, 0); - - for (int i = 0; i < count; i++) - { - mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); - DBDeleteContactSetting(NULL, MODULE_NAME, key); - } - - GetDlgItemText(hwndDlg, IDC_REPLIES, tszReplies, TEXT_LIMIT); - { - tString replies = tszReplies; - - if (replies.length() > 0) - replies.append(_T("\r\n")); - - count = 0; - tString::size_type pos = tString::npos; - while ((pos = replies.find(_T("\r\n"))) != tString::npos) - { - mir_snprintf(key, 64, "Reply_%x_%x", iNumber, count++); - DBWriteContactSettingTString(NULL, MODULE_NAME, key, replies.substr(0, pos).c_str()); - replies = replies.substr(pos + 2); - } - } - - mir_snprintf(key, 64, "RepliesCount_%x", iNumber); - DBWriteContactSettingWord(NULL, MODULE_NAME, key, count); - - mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); - DBWriteContactSettingByte(NULL, MODULE_NAME, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY)); - - mir_free(key); - - return TRUE; - } - break; - } - } - break; - } - - if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - return FALSE; -} - -static UINT expertOnlyControls[] = { IDC_VARIABLES, IDC_VARIABLES_HINT }; - -int OnOptInitialized(WPARAM wParam, LPARAM lParam) -{ - char tabName[32]; - mir_snprintf(tabName, SIZEOF(tabName), "Button %x", iNumber + 1); - - OPTIONSDIALOGPAGE odp = {0}; - odp.cbSize = sizeof(odp); - odp.pszGroup = LPGEN("Message Sessions"); - odp.pszTitle = LPGEN("Quick Replies"); - odp.pszTab = tabName; - odp.position = iNumber; - odp.hInstance = hInstance; - - odp.expertOnlyControls = expertOnlyControls; - odp.nExpertOnlyControls = SIZEOF(expertOnlyControls); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PAGE); - odp.pfnDlgProc = DlgProcOptionsPage; - Options_AddPage(wParam, &odp); - - return 0; -} \ No newline at end of file diff --git a/plugins/QuickReplies/quickreplies-translation.txt b/plugins/QuickReplies/quickreplies-translation.txt deleted file mode 100644 index fae9a1e2b2..0000000000 --- a/plugins/QuickReplies/quickreplies-translation.txt +++ /dev/null @@ -1,17 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/QuickReplies/events.cpp -;[Button] - -; ../../plugins/QuickReplies/options.cpp -;[Message Sessions] -;[Quick Replies] - -; ../../plugins/QuickReplies/resources.rc -;[- Add \"---\" for separator.] -;[- Add your replies, one per line.] -;[- Press [v] button for variable's help.] -;[Hints:] -;[Send replies immediately] -;[Variables] diff --git a/plugins/QuickReplies/quickreplies.cpp b/plugins/QuickReplies/quickreplies.cpp deleted file mode 100644 index 063ef0c8d3..0000000000 --- a/plugins/QuickReplies/quickreplies.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (C) 2010 Unsane - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This 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 -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. -*/ - -#include "common.h" - -HINSTANCE hInstance = NULL; -int hLangpack; - -HANDLE hOnModulesLoaded; -HANDLE hOnPreShutdown; - -PLUGININFOEX pluginInfoEx = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {A6A031B6-D32F-4842-98C6-EC716C576B77} - {0xa6a031b6, 0xd32f, 0x4842, {0x98, 0xc6, 0xec, 0x71, 0x6c, 0x57, 0x6b, 0x77}} -}; - -BOOL WINAPI DllMain(HINSTANCE hInstanceDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInstance = hInstanceDLL; - - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -extern "C" __declspec(dllexport) int Load(void) -{ - - mir_getLP(&pluginInfoEx); - - hOnModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); - - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - DestroyServiceFunction(hQuickRepliesService); - return 0; -} diff --git a/plugins/QuickReplies/quickreplies_10.vcxproj b/plugins/QuickReplies/quickreplies_10.vcxproj index 51984a7c50..d24696a110 100644 --- a/plugins/QuickReplies/quickreplies_10.vcxproj +++ b/plugins/QuickReplies/quickreplies_10.vcxproj @@ -75,13 +75,12 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;quickreplies_EXPORTS;UNICODE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true false true Fast Level3 - 4996;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -101,7 +100,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;quickreplies_EXPORTS;UNICODE;_UNICODE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -109,7 +108,6 @@ Fast Level3 EditAndContinue - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -129,13 +127,12 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;quickreplies_EXPORTS;UNICODE;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true false true Fast Level3 - 4996;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -155,14 +152,13 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;quickreplies_EXPORTS;UNICODE;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL true Fast Level3 - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -177,21 +173,18 @@ - - - + + + - + + - - - - - - - + + + diff --git a/plugins/QuickReplies/quickreplies_10.vcxproj.filters b/plugins/QuickReplies/quickreplies_10.vcxproj.filters index 82b24be170..d53f3be127 100644 --- a/plugins/QuickReplies/quickreplies_10.vcxproj.filters +++ b/plugins/QuickReplies/quickreplies_10.vcxproj.filters @@ -12,37 +12,32 @@ - + Header Files - + Header Files - + Header Files - - Resource Files - - - - + Resource Files - + Resource Files - + Source Files - + Source Files - + Source Files diff --git a/plugins/QuickReplies/res/qicon.ico b/plugins/QuickReplies/res/qicon.ico new file mode 100644 index 0000000000..23c3765fd9 Binary files /dev/null and b/plugins/QuickReplies/res/qicon.ico differ diff --git a/plugins/QuickReplies/res/resources.rc b/plugins/QuickReplies/res/resources.rc new file mode 100644 index 0000000000..fdac5b7230 --- /dev/null +++ b/plugins/QuickReplies/res/resources.rc @@ -0,0 +1,129 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// нейтральный resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONS_PAGE DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Send replies immediately",IDC_IMMEDIATELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,48,177,182,13 + EDITTEXT IDC_REPLIES,48,79,204,94,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL + LTEXT "- Add your replies, one per line.",IDC_STATIC,54,44,198,10 + CONTROL "Variables",IDC_VARIABLES,"MButtonClass",WS_TABSTOP,236,176,16,14 + LTEXT "Hints:",IDC_STATIC,48,35,204,8 + LTEXT "- Add ""---"" for separator.",IDC_STATIC,54,55,198,10 + LTEXT "- Press [v] button for variable's help.",IDC_VARIABLES_HINT,54,66,198,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPTIONS_PAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 293 + VERTGUIDE, 48 + VERTGUIDE, 54 + VERTGUIDE, 230 + VERTGUIDE, 236 + VERTGUIDE, 252 + TOPMARGIN, 7 + BOTTOMMARGIN, 223 + HORZGUIDE, 44 + HORZGUIDE, 190 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_QICON ICON "qicon.ico" +#endif // нейтральный resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// русский resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // русский resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/QuickReplies/res/version.rc b/plugins/QuickReplies/res/version.rc new file mode 100644 index 0000000000..cc6b3bf17a --- /dev/null +++ b/plugins/QuickReplies/res/version.rc @@ -0,0 +1,117 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// нейтральный resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", __INTERNAL_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + VALUE "ProductVersion", __VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + +#endif // нейтральный resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// русский resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\version.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // русский resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/QuickReplies/resource.h b/plugins/QuickReplies/resource.h deleted file mode 100644 index a27459012f..0000000000 --- a/plugins/QuickReplies/resource.h +++ /dev/null @@ -1,29 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resources.rc -// -#define IDD_OPTIONS_PAGE 101 -#define IDI_QICON 102 -#define IDC_THEMELIST 1001 -#define IDC_RELOAD 1002 -#define IDC_TITLE 1003 -#define IDC_DESCRIPTION 1004 -#define IDC_CONTACTS 1005 -#define IDC_PREVIEW 1006 -#define IDC_NOPREVIEW 1007 -#define IDC_AUTHORS 1008 -#define IDC_IMMEDIATELY 1009 -#define IDC_REPLIES 1010 -#define IDC_VARIABLES 1011 -#define IDC_VARIABLES_HINT 1013 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1014 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/QuickReplies/resources.rc b/plugins/QuickReplies/resources.rc deleted file mode 100644 index 2ef1204ff2..0000000000 --- a/plugins/QuickReplies/resources.rc +++ /dev/null @@ -1,129 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// нейтральный resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPTIONS_PAGE DIALOGEX 0, 0, 300, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "Send replies immediately",IDC_IMMEDIATELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,48,177,182,13 - EDITTEXT IDC_REPLIES,48,79,204,94,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL - LTEXT "- Add your replies, one per line.",IDC_STATIC,54,44,198,10 - CONTROL "Variables",IDC_VARIABLES,"MButtonClass",WS_TABSTOP,236,176,16,14 - LTEXT "Hints:",IDC_STATIC,48,35,204,8 - LTEXT "- Add ""---"" for separator.",IDC_STATIC,54,55,198,10 - LTEXT "- Press [v] button for variable's help.",IDC_VARIABLES_HINT,54,66,198,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPTIONS_PAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - VERTGUIDE, 48 - VERTGUIDE, 54 - VERTGUIDE, 230 - VERTGUIDE, 236 - VERTGUIDE, 252 - TOPMARGIN, 7 - BOTTOMMARGIN, 223 - HORZGUIDE, 44 - HORZGUIDE, 190 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_QICON ICON "Icons\\qicon.ico" -#endif // нейтральный resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// русский resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // русский resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/QuickReplies/src/common.h b/plugins/QuickReplies/src/common.h new file mode 100644 index 0000000000..e65994372c --- /dev/null +++ b/plugins/QuickReplies/src/common.h @@ -0,0 +1,71 @@ +/* +Copyright (C) 2010 Unsane + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +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. +*/ + + +#ifndef __QUICK_REPLY_H__ +#define __QUICK_REPLY_H__ + +#define MIRANDA_VER 0x0A00 + +#include +#include +#include + +#include "tchar.h" + +#include +#include +#include +#include +#include +#include + +#include "m_msg_buttonsbar.h" +#include "m_variables.h" + +#include "resource.h" +#include "version.h" + +#define MODULE_NAME __INTERNAL_NAME +#define TEXT_LIMIT 2048 +#define IDC_MESSAGE 1002 +#define IDC_CHATMESSAGE 1009 + +#define MS_QUICKREPLIES_SERVICE MODULE_NAME"/Service" + +extern HINSTANCE hInstance; + +extern BYTE iNumber; + +extern HANDLE hOnOptInitialized; +extern HANDLE hOnButtonPressed; +extern HANDLE hQuickRepliesService; +extern HANDLE hOnModulesLoaded; +extern HANDLE hOnPreShutdown; + +typedef std::wstring tString; + +INT_PTR QuickRepliesService(WPARAM wParam, LPARAM lParam); + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam); +int OnOptInitialized(WPARAM wParam, LPARAM lParam); +int OnButtonPressed(WPARAM wParam, LPARAM lParam); +int OnPreShutdown(WPARAM wParam, LPARAM lParam); + +#endif //__QUICK_REPLY_H__ \ No newline at end of file diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp new file mode 100644 index 0000000000..2227c6d6f1 --- /dev/null +++ b/plugins/QuickReplies/src/events.cpp @@ -0,0 +1,186 @@ +/* +Copyright (C) 2010 Unsane + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +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. +*/ + +#include "common.h" + +using namespace std; + +BYTE iNumber; + +HANDLE hOnOptInitialized; +HANDLE hOnButtonPressed; +HANDLE hQuickRepliesService; + +INT_PTR QuickRepliesService(WPARAM, LPARAM) +{ + return TRUE; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + UnhookEvent(hOnModulesLoaded); + HANDLE hIcon = NULL; + char buttonName[32]; + + if (!ServiceExists(MS_QUICKREPLIES_SERVICE)) + { + iNumber = 0; + hQuickRepliesService = CreateServiceFunction(MS_QUICKREPLIES_SERVICE, QuickRepliesService); + } + else iNumber = DBGetContactSettingByte(NULL, MODULE_NAME, "InstancesCount", 0); + DBWriteContactSettingByte(NULL, MODULE_NAME, "InstancesCount", iNumber + 1); + + hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized); + hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); + + char buttonNameTranslated[32]; + mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1); + mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x",Translate("Button"), iNumber + 1); + + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(sid); + sid.pszSection = "TabSRMM/Quick Replies"; + sid.cx = sid.cy = 16; + sid.pszDescription = buttonNameTranslated; + sid.pszName = buttonName; + sid.hDefaultIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QICON)); + hIcon = Skin_AddIcon(&sid); + + if (ServiceExists(MS_BB_ADDBUTTON)) { + mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1); + + BBButton bbd = {0}; + bbd.cbSize = sizeof(BBButton); + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON; + bbd.pszModuleName = buttonName; + bbd.ptszTooltip = _T("Quick Replies\r\nLeft button - open menu\r\nRight button - options page"); + bbd.hIcon = hIcon; + bbd.dwButtonID = iNumber; + bbd.dwDefPos = 220; + + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + } + + return 0; +} + +int OnButtonPressed(WPARAM wParam, LPARAM lParam) +{ + char key[64]; + int index = 0; + int count = 0; + HMENU hMenu = NULL; + char buttonName[32]; + tString replies = _T(""); + vector replyList; + CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; + + mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1); + if (strcmp(cbcd->pszModule, buttonName)) + return 0; + + if (cbcd->dwButtonId != iNumber) + return 1; + + mir_snprintf(key, 64, "RepliesCount_%x", iNumber); + count = DBGetContactSettingWord(NULL, MODULE_NAME, key, 0); + + { + if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON) + { + mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1); + + OPENOPTIONSDIALOG ood = {0}; + ood.cbSize = sizeof(ood); + ood.pszGroup = "Message Sessions"; + ood.pszPage = "Quick Replies"; + ood.pszTab = buttonName; + + CallService(MS_OPT_OPENOPTIONS, NULL, (LPARAM)&ood); + + return 0; + } + + hMenu = CreatePopupMenu(); + + DBVARIANT dbv = {0}; + + for (int i = 0; i < count; i++) + { + mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); + DBGetContactSettingTString(NULL, MODULE_NAME, key, &dbv); + + if (dbv.ptszVal == NULL) + replyList.push_back(_T("")); + else + replyList.push_back((TCHAR*)variables_parsedup(dbv.ptszVal, 0, (HANDLE)wParam)); + + if (_tcscmp(dbv.ptszVal, _T("---"))) + AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i].c_str()); + else + AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL); + } + + DBFreeVariant(&dbv); + } + + { + int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL); + if (index > 0) + { + if (_tcscmp(replyList.at(index - 1).c_str(), _T(""))) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList.at(index - 1).c_str()); + + mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); + if ((BYTE)DBGetContactSettingByte(NULL, MODULE_NAME, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED) + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + } + } + + for (std::vector::reverse_iterator item = replyList.rbegin(); item != replyList.rend(); ++item) + ((tString)*item).clear(); + replyList.clear(); + + return 1; +} + +int OnPreShutdown(WPARAM wParam, LPARAM lParam) +{ + if (ServiceExists(MS_BB_REMOVEBUTTON)) + { + char buttonName[32]; + mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %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); + return 0; +} \ No newline at end of file diff --git a/plugins/QuickReplies/src/options.cpp b/plugins/QuickReplies/src/options.cpp new file mode 100644 index 0000000000..3c96f42e89 --- /dev/null +++ b/plugins/QuickReplies/src/options.cpp @@ -0,0 +1,210 @@ +/* +Copyright (C) 2010 Unsane + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +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. +*/ + +#include "common.h" + +static WNDPROC OldMessageEditProc; + +static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) + { + case WM_CHAR: + { + 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 + SendMessage(hwnd, EM_UNDO, 0, 0); + return 0; + } + + 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, WM_KEYDOWN, VK_LEFT, 0); + SendMessage(hwnd, EM_GETSEL, (WPARAM) & start, (LPARAM) (PDWORD) NULL); + GetWindowText(hwnd, text, 1024); + MoveMemory(text + start, text + end, sizeof(WCHAR) * (wcslen(text) + 1 - end)); + SetWindowText(hwnd, text); + //SAFE_FREE((void**)&text); + SendMessage(hwnd, EM_SETSEL, start, start); + SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM) hwnd); + return 0; + } + } + break; + } + + return CallWindowProc(OldMessageEditProc, hwnd, msg, wParam, lParam); +} + +INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + char key[64]; + int count = 0; + DBVARIANT dbv = {0}; + tString replies = _T(""); + + TranslateDialogDefault(hwndDlg); + variables_skin_helpbutton(hwndDlg, IDC_VARIABLES); + + SendDlgItemMessage(hwndDlg, IDC_REPLIES, EM_LIMITTEXT, TEXT_LIMIT, 0); + OldMessageEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_REPLIES), GWLP_WNDPROC, (LONG_PTR)MessageEditSubclassProc); + + mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); + CheckDlgButton(hwndDlg, IDC_IMMEDIATELY, (BYTE)DBGetContactSettingWord(NULL, MODULE_NAME, key, 1)); + + mir_snprintf(key, 64, "RepliesCount_%x", iNumber); + count = DBGetContactSettingWord(NULL, MODULE_NAME, key, 0); + + for (int i = 0; i < count; i++) + { + mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); + if (!DBGetContactSettingTString(NULL, MODULE_NAME, key, &dbv)) + if(dbv.ptszVal != NULL) + replies.append(dbv.ptszVal); + if (i < count - 1) + replies.append(_T("\r\n")); + } + SetDlgItemText(hwndDlg, IDC_REPLIES, replies.c_str()); + + DBFreeVariant(&dbv); + + return TRUE; + } + break; + + case WM_COMMAND: + { + if (HIWORD(wParam) == BN_CLICKED) + { + switch(LOWORD(wParam)) + { + case IDC_VARIABLES: + { + variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL); + } + break; + + case IDC_IMMEDIATELY: + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + } + } + break; + + case WM_NOTIFY: + { + NMHDR *p = ((LPNMHDR)lParam); + + switch (p->code) + { + case PSN_APPLY: + { + char key[64]; + int count = 0; + TCHAR tszReplies[TEXT_LIMIT]; + + mir_snprintf(key, 64, "RepliesCount_%x", iNumber); + count = DBGetContactSettingByte(NULL, MODULE_NAME, key, 0); + + for (int i = 0; i < count; i++) + { + mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i); + DBDeleteContactSetting(NULL, MODULE_NAME, key); + } + + GetDlgItemText(hwndDlg, IDC_REPLIES, tszReplies, TEXT_LIMIT); + { + tString replies = tszReplies; + + if (replies.length() > 0) + replies.append(_T("\r\n")); + + count = 0; + tString::size_type pos = tString::npos; + while ((pos = replies.find(_T("\r\n"))) != tString::npos) + { + mir_snprintf(key, 64, "Reply_%x_%x", iNumber, count++); + DBWriteContactSettingTString(NULL, MODULE_NAME, key, replies.substr(0, pos).c_str()); + replies = replies.substr(pos + 2); + } + } + + mir_snprintf(key, 64, "RepliesCount_%x", iNumber); + DBWriteContactSettingWord(NULL, MODULE_NAME, key, count); + + mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber); + DBWriteContactSettingByte(NULL, MODULE_NAME, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY)); + + mir_free(key); + + return TRUE; + } + break; + } + } + break; + } + + if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + + return FALSE; +} + +static UINT expertOnlyControls[] = { IDC_VARIABLES, IDC_VARIABLES_HINT }; + +int OnOptInitialized(WPARAM wParam, LPARAM lParam) +{ + char tabName[32]; + mir_snprintf(tabName, SIZEOF(tabName), "Button %x", iNumber + 1); + + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.pszGroup = LPGEN("Message Sessions"); + odp.pszTitle = LPGEN("Quick Replies"); + odp.pszTab = tabName; + odp.position = iNumber; + odp.hInstance = hInstance; + + odp.expertOnlyControls = expertOnlyControls; + odp.nExpertOnlyControls = SIZEOF(expertOnlyControls); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PAGE); + 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 new file mode 100644 index 0000000000..063ef0c8d3 --- /dev/null +++ b/plugins/QuickReplies/src/quickreplies.cpp @@ -0,0 +1,69 @@ +/* +Copyright (C) 2010 Unsane + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This 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 +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. +*/ + +#include "common.h" + +HINSTANCE hInstance = NULL; +int hLangpack; + +HANDLE hOnModulesLoaded; +HANDLE hOnPreShutdown; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {A6A031B6-D32F-4842-98C6-EC716C576B77} + {0xa6a031b6, 0xd32f, 0x4842, {0x98, 0xc6, 0xec, 0x71, 0x6c, 0x57, 0x6b, 0x77}} +}; + +BOOL WINAPI DllMain(HINSTANCE hInstanceDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInstance = hInstanceDLL; + + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + + mir_getLP(&pluginInfoEx); + + hOnModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + DestroyServiceFunction(hQuickRepliesService); + return 0; +} diff --git a/plugins/QuickReplies/src/resource.h b/plugins/QuickReplies/src/resource.h new file mode 100644 index 0000000000..a27459012f --- /dev/null +++ b/plugins/QuickReplies/src/resource.h @@ -0,0 +1,29 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resources.rc +// +#define IDD_OPTIONS_PAGE 101 +#define IDI_QICON 102 +#define IDC_THEMELIST 1001 +#define IDC_RELOAD 1002 +#define IDC_TITLE 1003 +#define IDC_DESCRIPTION 1004 +#define IDC_CONTACTS 1005 +#define IDC_PREVIEW 1006 +#define IDC_NOPREVIEW 1007 +#define IDC_AUTHORS 1008 +#define IDC_IMMEDIATELY 1009 +#define IDC_REPLIES 1010 +#define IDC_VARIABLES 1011 +#define IDC_VARIABLES_HINT 1013 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1014 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/QuickReplies/src/version.h b/plugins/QuickReplies/src/version.h new file mode 100644 index 0000000000..6c87a94d0d --- /dev/null +++ b/plugins/QuickReplies/src/version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 8 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#define __PLUGIN_NAME "Quick Replies" +#define __INTERNAL_NAME "QuickReplies" +#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://nightly.miranda.im/" +#define __COPYRIGHT "© 2010 Unsane" diff --git a/plugins/QuickReplies/version.h b/plugins/QuickReplies/version.h deleted file mode 100644 index 6c87a94d0d..0000000000 --- a/plugins/QuickReplies/version.h +++ /dev/null @@ -1,20 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 8 -#define __RELEASE_NUM 1 -#define __BUILD_NUM 0 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) - -#define __PLUGIN_NAME "Quick Replies" -#define __INTERNAL_NAME "QuickReplies" -#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://nightly.miranda.im/" -#define __COPYRIGHT "© 2010 Unsane" diff --git a/plugins/QuickReplies/version.rc b/plugins/QuickReplies/version.rc deleted file mode 100644 index 95c065fb90..0000000000 --- a/plugins/QuickReplies/version.rc +++ /dev/null @@ -1,117 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "version.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// нейтральный resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", __INTERNAL_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - VALUE "ProductVersion", __VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif // нейтральный resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// русский resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "version.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // русский resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - -- cgit v1.2.3