From 48540940b6c28bb4378abfeb500ec45a625b37b6 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 15 May 2012 10:38:20 +0000 Subject: initial commit git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TranslitSwitcher/Docs/Readme.txt | 4 + plugins/TranslitSwitcher/Res/InvertSend.ico | Bin 0 -> 2038 bytes plugins/TranslitSwitcher/Res/SwitchSend.ico | Bin 0 -> 2038 bytes plugins/TranslitSwitcher/Res/TranslitSend.ico | Bin 0 -> 2038 bytes plugins/TranslitSwitcher/Resource.h | 18 + plugins/TranslitSwitcher/Resource.rc | 48 ++ plugins/TranslitSwitcher/Src/Layoutproc.cpp | 945 +++++++++++++++++++++ plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp | 230 +++++ plugins/TranslitSwitcher/Src/TranslitSwitcher.h | 59 ++ plugins/TranslitSwitcher/TranslitSwitcher_10.sln | 25 + .../TranslitSwitcher/TranslitSwitcher_10.vcxproj | 188 ++++ .../TranslitSwitcher_10.vcxproj.filters | 44 + plugins/TranslitSwitcher/Version.h | 28 + plugins/TranslitSwitcher/Version.rc | 38 + 14 files changed, 1627 insertions(+) create mode 100644 plugins/TranslitSwitcher/Docs/Readme.txt create mode 100644 plugins/TranslitSwitcher/Res/InvertSend.ico create mode 100644 plugins/TranslitSwitcher/Res/SwitchSend.ico create mode 100644 plugins/TranslitSwitcher/Res/TranslitSend.ico create mode 100644 plugins/TranslitSwitcher/Resource.h create mode 100644 plugins/TranslitSwitcher/Resource.rc create mode 100644 plugins/TranslitSwitcher/Src/Layoutproc.cpp create mode 100644 plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp create mode 100644 plugins/TranslitSwitcher/Src/TranslitSwitcher.h create mode 100644 plugins/TranslitSwitcher/TranslitSwitcher_10.sln create mode 100644 plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj create mode 100644 plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters create mode 100644 plugins/TranslitSwitcher/Version.h create mode 100644 plugins/TranslitSwitcher/Version.rc (limited to 'plugins/TranslitSwitcher') diff --git a/plugins/TranslitSwitcher/Docs/Readme.txt b/plugins/TranslitSwitcher/Docs/Readme.txt new file mode 100644 index 0000000000..adf6b52020 --- /dev/null +++ b/plugins/TranslitSwitcher/Docs/Readme.txt @@ -0,0 +1,4 @@ +for adding symbol when you resend message add in your db: +[TranslitSwitcher] +ResendSymbol=u* +where * is resend symbol \ No newline at end of file diff --git a/plugins/TranslitSwitcher/Res/InvertSend.ico b/plugins/TranslitSwitcher/Res/InvertSend.ico new file mode 100644 index 0000000000..67171c377b Binary files /dev/null and b/plugins/TranslitSwitcher/Res/InvertSend.ico differ diff --git a/plugins/TranslitSwitcher/Res/SwitchSend.ico b/plugins/TranslitSwitcher/Res/SwitchSend.ico new file mode 100644 index 0000000000..7d5362debb Binary files /dev/null and b/plugins/TranslitSwitcher/Res/SwitchSend.ico differ diff --git a/plugins/TranslitSwitcher/Res/TranslitSend.ico b/plugins/TranslitSwitcher/Res/TranslitSend.ico new file mode 100644 index 0000000000..737ab57615 Binary files /dev/null and b/plugins/TranslitSwitcher/Res/TranslitSend.ico differ diff --git a/plugins/TranslitSwitcher/Resource.h b/plugins/TranslitSwitcher/Resource.h new file mode 100644 index 0000000000..b98a6590c2 --- /dev/null +++ b/plugins/TranslitSwitcher/Resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resources.rc +// +#define IDI_SWITCHSEND 101 +#define IDI_TRANSLITSEND 102 +#define IDI_INVERTSEND 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/TranslitSwitcher/Resource.rc b/plugins/TranslitSwitcher/Resource.rc new file mode 100644 index 0000000000..b405fa8e86 --- /dev/null +++ b/plugins/TranslitSwitcher/Resource.rc @@ -0,0 +1,48 @@ +// 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_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SWITCHSEND ICON "res/SwitchSend.ico" +IDI_TRANSLITSEND ICON "res/TranslitSend.ico" +IDI_INVERTSEND ICON "res/InvertSend.ico" + + +#endif // Ðóññêèé (Ðîññèÿ) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/TranslitSwitcher/Src/Layoutproc.cpp b/plugins/TranslitSwitcher/Src/Layoutproc.cpp new file mode 100644 index 0000000000..ff77523d6c --- /dev/null +++ b/plugins/TranslitSwitcher/Src/Layoutproc.cpp @@ -0,0 +1,945 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +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 "TranslitSwitcher.h" + +SMADD_BATCHPARSE2 smgp; +SMADD_BATCHPARSERES *smileyPrs = NULL; + +BOOL isItSmiley(unsigned int position) +{ + unsigned int j; + + if (smileyPrs == NULL) + return FALSE; + + for (j = 0; j < smgp.numSmileys; j++) + { + if (position >= smileyPrs[j].startChar && position < (smileyPrs[j].startChar + smileyPrs[j].size)) + return TRUE; + } + + return FALSE; +} + +static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) +{ + static int sendBufferSize; + char ** ppText = (char **) dwCookie; + + if (*ppText == NULL) + sendBufferSize = 0; + + *ppText = (char *)mir_realloc(*ppText, sendBufferSize + cb + 2); + memcpy (*ppText + sendBufferSize, pbBuff, cb); + sendBufferSize += cb; + *((TCHAR *)(*ppText + sendBufferSize)) = '\0'; + *pcb = cb; + return 0; +} + +TCHAR* Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags) +{ + EDITSTREAM stream = {0}; + TCHAR *pszText = NULL; + + if (hwndRtf == 0) + return NULL; + + stream.pfnCallback = StreamOutCallback; + stream.dwCookie = (DWORD_PTR) & pszText; + SendMessage(hwndRtf, EM_STREAMOUT, (WPARAM)dwPassedFlags, (LPARAM) & stream); + + return pszText; +} + +VOID Transliterate(TCHAR*& str) +{ + TCHAR* newStr = (TCHAR*)mir_alloc(sizeof(TCHAR)*lstrlen(str)*3+1); + newStr[0] = 0; + for (; *str != 0; str++) + { + switch (str[0]) + { + case _T('à'): _tcscat(newStr, _T("a")); break; + case _T('á'): _tcscat(newStr, _T("b")); break; + case _T('â'): _tcscat(newStr, _T("v")); break; + case _T('ã'): _tcscat(newStr, _T("g")); break; + case _T('ä'): _tcscat(newStr, _T("d")); break; + case _T('å'): _tcscat(newStr, _T("e")); break; + case _T('¸'): _tcscat(newStr, _T("ye")); break; + case _T('æ'): _tcscat(newStr, _T("zh")); break; + case _T('ç'): _tcscat(newStr, _T("z")); break; + case _T('è'): _tcscat(newStr, _T("i")); break; + case _T('é'): _tcscat(newStr, _T("y")); break; + case _T('ê'): _tcscat(newStr, _T("k")); break; + case _T('ë'): _tcscat(newStr, _T("l")); break; + case _T('ì'): _tcscat(newStr, _T("m")); break; + case _T('í'): _tcscat(newStr, _T("n")); break; + case _T('î'): _tcscat(newStr, _T("o")); break; + case _T('ï'): _tcscat(newStr, _T("p")); break; + case _T('ð'): _tcscat(newStr, _T("r")); break; + case _T('ñ'): _tcscat(newStr, _T("s")); break; + case _T('ò'): _tcscat(newStr, _T("t")); break; + case _T('ó'): _tcscat(newStr, _T("u")); break; + case _T('ô'): _tcscat(newStr, _T("f")); break; + case _T('õ'): _tcscat(newStr, _T("kh")); break; + case _T('ö'): _tcscat(newStr, _T("ts")); break; + case _T('÷'): _tcscat(newStr, _T("ch")); break; + case _T('ø'): _tcscat(newStr, _T("sh")); break; + case _T('ù'): _tcscat(newStr, _T("sch")); break; + case _T('ú'): _tcscat(newStr, _T("'")); break; + case _T('û'): _tcscat(newStr, _T("yi")); break; + case _T('ü'): _tcscat(newStr, _T("")); break; + case _T('ý'): _tcscat(newStr, _T("e")); break; + case _T('þ'): _tcscat(newStr, _T("yu")); break; + case _T('ÿ'): _tcscat(newStr, _T("ya")); break; + case _T('À'): _tcscat(newStr, _T("A")); break; + case _T('Á'): _tcscat(newStr, _T("B")); break; + case _T('Â'): _tcscat(newStr, _T("V")); break; + case _T('Ã'): _tcscat(newStr, _T("G")); break; + case _T('Ä'): _tcscat(newStr, _T("D")); break; + case _T('Å'): _tcscat(newStr, _T("E")); break; + case _T('¨'): _tcscat(newStr, _T("Ye")); break; + case _T('Æ'): _tcscat(newStr, _T("Zh")); break; + case _T('Ç'): _tcscat(newStr, _T("Z")); break; + case _T('È'): _tcscat(newStr, _T("I")); break; + case _T('É'): _tcscat(newStr, _T("Y")); break; + case _T('Ê'): _tcscat(newStr, _T("K")); break; + case _T('Ë'): _tcscat(newStr, _T("L")); break; + case _T('Ì'): _tcscat(newStr, _T("M")); break; + case _T('Í'): _tcscat(newStr, _T("N")); break; + case _T('Î'): _tcscat(newStr, _T("O")); break; + case _T('Ï'): _tcscat(newStr, _T("P")); break; + case _T('Ð'): _tcscat(newStr, _T("R")); break; + case _T('Ñ'): _tcscat(newStr, _T("S")); break; + case _T('Ò'): _tcscat(newStr, _T("T")); break; + case _T('Ó'): _tcscat(newStr, _T("U")); break; + case _T('Ô'): _tcscat(newStr, _T("F")); break; + case _T('Õ'): _tcscat(newStr, _T("Kh")); break; + case _T('Ö'): _tcscat(newStr, _T("Ts")); break; + case _T('×'): _tcscat(newStr, _T("Ch")); break; + case _T('Ø'): _tcscat(newStr, _T("Sh")); break; + case _T('Ù'): _tcscat(newStr, _T("Sch")); break; + case _T('Ú'): _tcscat(newStr, _T("'")); break; + case _T('Û'): _tcscat(newStr, _T("Yi")); break; + case _T('Ü'): _tcscat(newStr, _T("")); break; + case _T('Ý'): _tcscat(newStr, _T("E")); break; + case _T('Þ'): _tcscat(newStr, _T("Yu")); break; + case _T('ß'): _tcscat(newStr, _T("Ya")); break; + + case _T('a'): _tcscat(newStr, _T("à")); break; + case _T('b'): _tcscat(newStr, _T("á")); break; + case _T('v'): _tcscat(newStr, _T("â")); break; + case _T('g'): _tcscat(newStr, _T("ã")); break; + case _T('d'): _tcscat(newStr, _T("ä")); break; + case _T('e'): _tcscat(newStr, _T("å")); break; + case _T('z'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("æ")); + str++; + break; + } + else + { + _tcscat(newStr, _T("ç")); + break; + } + } + case _T('i'): _tcscat(newStr, _T("è")); break; + case _T('y'): + { + if (str[1] == _T('a')) + { + _tcscat(newStr, _T("ÿ")); + str++; + break; + } + else if (str[1] == _T('e')) + { + _tcscat(newStr, _T("¸")); + str++; + break; + } + else if (str[1] == _T('u')) + { + _tcscat(newStr, _T("þ")); + str++; + break; + } + else if (str[1] == _T('i')) + { + _tcscat(newStr, _T("û")); + str++; + break; + } + else + { + _tcscat(newStr, _T("é")); + break; + } + } + case _T('k'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("õ")); + str++; + break; + } + else + { + _tcscat(newStr, _T("ê")); + break; + } + } + case _T('l'): _tcscat(newStr, _T("ë")); break; + case _T('m'): _tcscat(newStr, _T("ì")); break; + case _T('n'): _tcscat(newStr, _T("í")); break; + case _T('o'): _tcscat(newStr, _T("î")); break; + case _T('p'): _tcscat(newStr, _T("ï")); break; + case _T('r'): _tcscat(newStr, _T("ð")); break; + case _T('s'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("ø")); + str++; + break; + } + else if (str[1] == _T('c') && str[2] == _T('h')) + { + _tcscat(newStr, _T("ù")); + str+=2; + break; + } + else + { + _tcscat(newStr, _T("ñ")); + break; + } + } + case _T('t'): + { + if (str[1] == _T('s')) + { + _tcscat(newStr, _T("ö")); + str++; + break; + } + else + { + _tcscat(newStr, _T("ò")); + break; + } + } + case _T('u'): _tcscat(newStr, _T("ó")); break; + case _T('f'): _tcscat(newStr, _T("ô")); break; + case _T('c'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("÷")); + str++; + break; + } + } + case _T('A'): _tcscat(newStr, _T("À")); break; + case _T('B'): _tcscat(newStr, _T("Á")); break; + case _T('V'): _tcscat(newStr, _T("Â")); break; + case _T('G'): _tcscat(newStr, _T("Ã")); break; + case _T('D'): _tcscat(newStr, _T("Ä")); break; + case _T('E'): _tcscat(newStr, _T("Å")); break; + case _T('Y'): + { + if (str[1] == _T('a')) + { + _tcscat(newStr, _T("ß")); + str++; + break; + } + else if (str[1] == _T('e')) + { + _tcscat(newStr, _T("¨")); + str++; + break; + } + else if (str[1] == _T('u')) + { + _tcscat(newStr, _T("Þ")); + str++; + break; + } + else if (str[1] == _T('i')) + { + _tcscat(newStr, _T("Û")); + str++; + break; + } + else + { + _tcscat(newStr, _T("É")); + break; + } + } + case _T('Z'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Æ")); + str++; + break; + } + else + { + _tcscat(newStr, _T("Ç")); + break; + } + } + case _T('I'): _tcscat(newStr, _T("È")); break; + case _T('K'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Õ")); + str++; + break; + } + else + { + _tcscat(newStr, _T("Ê")); + break; + } + } + case _T('L'): _tcscat(newStr, _T("Ë")); break; + case _T('M'): _tcscat(newStr, _T("Ì")); break; + case _T('N'): _tcscat(newStr, _T("Í")); break; + case _T('O'): _tcscat(newStr, _T("Î")); break; + case _T('P'): _tcscat(newStr, _T("Ï")); break; + case _T('R'): _tcscat(newStr, _T("Ð")); break; + case _T('S'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("Ø")); + str++; + break; + } + else if (str[1] == _T('c') && str[2] == _T('h')) + { + _tcscat(newStr, _T("Ù")); + str+=2; + break; + } + else + { + _tcscat(newStr, _T("Ñ")); + break; + } + } + case _T('T'): + { + if (str[1] == _T('s')) + { + _tcscat(newStr, _T("Ö")); + str++; + break; + } + else + { + _tcscat(newStr, _T("Ò")); + break; + } + } + case _T('U'): _tcscat(newStr, _T("Ó")); break; + case _T('F'): _tcscat(newStr, _T("Ô")); break; + case _T('C'): + { + if (str[1] == _T('h')) + { + _tcscat(newStr, _T("×")); + str++; + break; + } + } + case _T('\''): _tcscat(newStr, _T("ú")); break; + + default: { TCHAR Temp[2] = { str[0], 0} ; _tcscat(newStr, &Temp[0]); } + } + } + int len = lstrlen(newStr); + str = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR)); + str[0] = 0; + _tcscpy(str, newStr); + mir_free(newStr); +} + +VOID Invert(TCHAR *str) +{ + while(*str) + { + if(IsCharUpper(*str)) + { + *str = (TCHAR)CharLower((LPTSTR)*str); + } + else if(IsCharLower(*str)) + *str = (TCHAR)CharUpper((LPTSTR)*str); + str++; + } + keybd_event(VK_CAPITAL,0x45,KEYEVENTF_EXTENDEDKEY|0,0); + keybd_event(VK_CAPITAL,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0); +} + +VOID SwitchLayout(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[MAX_PATH]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + if((lstrcmp(szClassName, _T("THppRichEdit.UnicodeClass")) == 0 || lstrcmp(szClassName, _T("THistoryGrid.UnicodeClass")) == 0 || lstrcmp(szClassName, _T("TExtHistoryGrid.UnicodeClass")) == 0 || lstrcmp(szClassName, _T("Internet Explorer_Server")) == 0) && ServiceExists(MS_POPUP_SHOWMESSAGE)) // make popup here + { + TCHAR buf[2048]; + + if (lstrcmp(szClassName, _T("Internet Explorer_Server")) == 0) + { + TCHAR *selected = 0; + IEVIEWEVENT event; + HWND hwnd3 = GetParent(GetParent(hwnd2)); + ZeroMemory((void *)&event, sizeof(event)); + event.cbSize = sizeof(IEVIEWEVENT); + event.hContact = 0; + event.dwFlags = 0; + event.iType = IEE_GET_SELECTION; + event.hwnd = hwnd3; + selected = (TCHAR *)CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event); + lstrcpy(buf, selected); + } + else + SendMessage(hwnd2, WM_GETTEXT, SIZEOF(buf), (LPARAM)buf); // gimme, gimme, gimme... + + int slen = lstrlen(buf); + if (slen != 0) + { + HKL hkl; + ActivateKeyboardLayout((HKL)HKL_NEXT, KLF_ACTIVATE); // go to next layout before.... + hkl = GetKeyboardLayout(dwThreadID); + ActivateKeyboardLayout((HKL)HKL_PREV, KLF_ACTIVATE); // return to prev layout + + if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) + { + ZeroMemory(&smgp, sizeof(smgp)); + smgp.cbSize = sizeof(smgp); + smgp.str = buf; + smgp.flag = SAFL_TCHAR; + smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); + } + + for(int i = 0; i < slen; i++) + { + SHORT vks; + BYTE keys[256] = {0}; + + vks = VkKeyScanEx(buf[i], hkl); + + keys[VK_SHIFT] = (HIBYTE(vks) & 1) ? 0xFF : 0x00; // shift + keys[VK_CONTROL] = (HIBYTE(vks) & 2) ? 0xFF : 0x00; // ctrl + keys[VK_MENU] = (HIBYTE(vks) & 4) ? 0xFF : 0x00; // alt + + if (!isItSmiley(i)) + { + TCHAR tchr; + if(ToUnicodeEx(LOBYTE(vks), 0, keys, &tchr, 1, 0, GetKeyboardLayout(dwThreadID)) == 1) + buf[i] = tchr; + } + } + + if (smileyPrs != NULL) + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smileyPrs); + + POPUPDATAT_V2 pd; + ZeroMemory(&pd, sizeof(pd)); + pd.cbSize = sizeof(POPUPDATAT_V2); + pd.lchContact = NULL; //(HANDLE)wParam; + pd.lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM) "SwitchLayout and Send"); + lstrcpyn(pd.lptzText, buf, SIZEOF(pd.lptzText)); + lstrcpyn(pd.lptzContactName, TranslateT("TranslitSwitcher"), SIZEOF(pd.lptzContactName)); + pd.colorBack = pd.colorText = 0; + pd.iSeconds = 0; + CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, 0); + + //PUShowMessageT(buf, SM_NOTIFY); + } + } + else + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int i, slen, start = 0, end = 0; + TCHAR *sel, tchr; + BOOL somethingIsSelected = TRUE; + SHORT vks; + BYTE keys[256] = {0}; + HKL hkl = GetKeyboardLayout(dwThreadID); + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) + { + ZeroMemory(&smgp, sizeof(smgp)); + smgp.cbSize = sizeof(smgp); + smgp.str = sel; + smgp.flag = SAFL_TCHAR; + smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); + } + + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && !_istspace(sel[start+1])) || isItSmiley(start)) + break; + start--; + } + } + + ActivateKeyboardLayout((HKL)HKL_PREV, KLF_ACTIVATE); + + for(i = start; i < end; i++) + { + vks = VkKeyScanEx(sel[i], hkl); + + keys[VK_SHIFT] = (HIBYTE(vks) & 1) ? 0xFF : 0x00; // shift + keys[VK_CONTROL] = (HIBYTE(vks) & 2) ? 0xFF : 0x00; // ctrl + keys[VK_MENU] = (HIBYTE(vks) & 4) ? 0xFF : 0x00; // alt + + if (!isItSmiley(i)) + { + if(ToUnicodeEx(LOBYTE(vks), 0, keys, &tchr, 1, 0, GetKeyboardLayout(dwThreadID)) == 1) + sel[i] = tchr; + } + } + + if (smileyPrs != NULL) + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smileyPrs); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)sel); + else + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)sel); + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + } + } + } +} + +void TranslitLayout(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[16]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int slen, start = 0, end = 0; + TCHAR *sel, *boo; + BOOL somethingIsSelected = TRUE; + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && (end-start>2)) || isItSmiley(start)) + break; + start--; + } + boo = (TCHAR*)mir_alloc((end-start+1 ) * sizeof(TCHAR)); + _tcsncpy(boo, sel+start, end-start); + boo[end-start] = 0; + } + else + { + boo = (TCHAR*)mir_alloc((slen+1 ) * sizeof(TCHAR)); + _tcscpy(boo, sel); + } + + Transliterate(boo); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)boo); + else + { + TCHAR* NewText = (TCHAR*)mir_alloc((start+_tcslen(boo)+(slen-start)+1)* sizeof(TCHAR)); + NewText[0] = 0; + _tcsncat(NewText, sel, start); + _tcscat(NewText, boo); + _tcsncat(NewText, sel+end, slen-end); + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)NewText); + mir_free(NewText); + } + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + mir_free(boo); + } + } + } +} + +void InvertCase(BOOL lastword) +{ + HWND hwnd = GetForegroundWindow(); + + if(hwnd != NULL) + { + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); + HWND hwnd2 = GetFocus(); + + if(hwnd2 != NULL) + { + TCHAR szClassName[16]; + + GetClassName(hwnd2, szClassName, SIZEOF(szClassName)); + + if(lstrcmp(szClassName, _T("RichEdit20W")) == 0) + { + DWORD dwStart, dwEnd; + int slen, start = 0, end = 0; + TCHAR *sel, *boo; + BOOL somethingIsSelected = TRUE; + + SendMessage(hwnd2, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + + if (dwStart == dwEnd) + somethingIsSelected = FALSE; + + if (somethingIsSelected) + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE|SFF_SELECTION); + else + sel = Message_GetFromStream(hwnd2, SF_TEXT|SF_UNICODE); + + slen = lstrlen(sel); + + if (slen != 0) + { + end = slen; + if (lastword && !somethingIsSelected) + { + end = dwStart; + while (end < slen) + { + if (_istspace(sel[end]) || isItSmiley(end)) + break; + end++; + } + start = dwStart-1; + while (start > 0 && start < (int)dwStart) + { + if ((_istspace(sel[start]) && (end-start>2)) || isItSmiley(start)) + break; + start--; + } + boo = (TCHAR*)mir_alloc((end-start+1 ) * sizeof(TCHAR)); + _tcsncpy(boo, sel+start, end-start); + boo[end-start] = 0; + } + else + { + boo = (TCHAR*)mir_alloc((slen+1 ) * sizeof(TCHAR)); + _tcscpy(boo, sel); + } + + Invert(boo); + + if (somethingIsSelected) + SendMessage(hwnd2, EM_REPLACESEL, FALSE, (LPARAM)boo); + else + { + TCHAR* NewText = (TCHAR*)mir_alloc((start+_tcslen(boo)+(slen-start)+1)* sizeof(TCHAR)); + NewText[0] = 0; + _tcsncat(NewText, sel, start); + _tcscat(NewText, boo); + _tcsncat(NewText, sel+end, slen-end); + SendMessage(hwnd2, WM_SETTEXT, 0, (LPARAM)NewText); + mir_free(NewText); + } + + SendMessage(hwnd2, EM_SETSEL, dwStart, dwEnd); + } + mir_free(sel); + mir_free(boo); + } + } + } +} + +int OnButtonPressed(WPARAM wParam, LPARAM lParam) +{ + CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; + if (lstrcmpA(cbcd->pszModule, "SwitchLayout and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + DWORD dwProcessID; + DWORD dwThreadID = GetWindowThreadProcessId(cbcd->hwndFrom, &dwProcessID); + HKL hkl = GetKeyboardLayout(dwThreadID); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + + if (slen != 0) + { + ZeroMemory(&smgp, sizeof(smgp)); + smgp.cbSize = sizeof(smgp); + smgp.str = sel; + smgp.flag = SAFL_TCHAR; + + if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) + smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); + + ActivateKeyboardLayout((HKL)HKL_PREV, KLF_ACTIVATE); + + for(int i = 0; i < slen; i++) + { + TCHAR tchr; + BYTE keys[256] = {0}; + SHORT vks = VkKeyScanEx(sel[i], hkl); + + keys[VK_SHIFT] = (HIBYTE(vks) & 1) ? 0xFF : 0x00; // shift + keys[VK_CONTROL] = (HIBYTE(vks) & 2) ? 0xFF : 0x00; // ctrl + keys[VK_MENU] = (HIBYTE(vks) & 4) ? 0xFF : 0x00; // alt + + if (!isItSmiley(i)) + { + if(ToUnicodeEx(LOBYTE(vks), 0, keys, &tchr, 1, 0, GetKeyboardLayout(dwThreadID)) == 1) + sel[i] = tchr; + } + } + if (smileyPrs != NULL) + CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smileyPrs); + + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = slen + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + } + mir_free(sel); + return 1; + } + if (lstrcmpA(cbcd->pszModule, "Translit and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + if (slen != 0) + Transliterate(sel); + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = lstrlen(sel) + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + mir_free(sel); + return 1; + } + if (lstrcmpA(cbcd->pszModule, "Invert Case and Send") == 0) + { + HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); + if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); + + BYTE byKeybState[256]; + GetKeyboardState(byKeybState); + byKeybState[VK_CONTROL] = 128; + SetKeyboardState(byKeybState); + SendMessage(hEdit, WM_KEYDOWN, VK_UP, 0); + byKeybState[VK_CONTROL] = 0; + SetKeyboardState(byKeybState); + + TCHAR *sel = Message_GetFromStream(hEdit, SF_TEXT|SF_UNICODE); + int slen = lstrlen(sel); + if (slen != 0) + Invert(sel); + DBVARIANT dbv = {0}; + DBGetContactSettingTString(NULL, "TranslitSwitcher", "ResendSymbol", &dbv); + if (lstrcmp(dbv.ptszVal, NULL) == 0) + { + DBFreeVariant(&dbv); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + if (_tcsncmp(sel, dbv.ptszVal, _tcslen(dbv.ptszVal)) == 0) + { + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)sel); + SendMessage(hEdit, EM_SETSEL, 0, slen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + } + else + { + int FinalLen = slen + SIZEOF(dbv.ptszVal) + 1; + TCHAR* FinalString = (TCHAR*)mir_alloc((FinalLen+1)*sizeof(TCHAR)); + mir_sntprintf(FinalString, FinalLen, _T("%s %s"), dbv.ptszVal, sel); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)FinalString); + SendMessage(hEdit, EM_SETSEL, 0, FinalLen); + SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); + mir_free(FinalString); + } + } + mir_free(sel); + return 1; + } + return 0; +} \ No newline at end of file diff --git a/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp b/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp new file mode 100644 index 0000000000..1ec9f7f0e0 --- /dev/null +++ b/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp @@ -0,0 +1,230 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +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 "TranslitSwitcher.h" + +HINSTANCE hInst = NULL; +PLUGINLINK *pluginLink; +struct MM_INTERFACE mmi; +struct UTF8_INTERFACE utfi; +HANDLE hOnButtonPressed; +int hLangpack; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + 0, + MIID_TS +}; + +HANDLE hHook; +HANDLE hService, hService2, hService3; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +static const MUUID interfaces[] = {MIID_TS, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +//------------------------------------------------------------------------------------------------------- +#define MS_TS_SWITCHLAYOUT "TranslitSwitcher/SwitchLayout" +INT_PTR ServiceSwitch(WPARAM wParam, LPARAM lParam) +{ + SwitchLayout(lParam); + return 0; +} + +#define MS_TS_TRANSLITLAYOUT "TranslitSwitcher/TranslitLayout" +INT_PTR ServiceTranslit(WPARAM wParam, LPARAM lParam) +{ + TranslitLayout(lParam); + return 0; +} + +#define MS_TS_INVERTCASE "TranslitSwitcher/InvertCase" +INT_PTR ServiceInvert(WPARAM wParam, LPARAM lParam) +{ + InvertCase(lParam); + return 0; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + HICON hSwitchIcon = NULL, hTranslitIcon = NULL, hInvertIcon = NULL; + + HOTKEYDESC hkd = {0}; + hkd.cbSize = sizeof(hkd); + hkd.dwFlags = HKD_TCHAR; + + hService = CreateServiceFunction(MS_TS_SWITCHLAYOUT, ServiceSwitch); + hService2 = CreateServiceFunction(MS_TS_TRANSLITLAYOUT, ServiceTranslit); + hService3 = CreateServiceFunction(MS_TS_INVERTCASE, ServiceInvert); + + hkd.pszName = "TranslitSwitcher/ConvertAllOrSelected"; + hkd.ptszDescription = _T("Convert All / Selected"); + hkd.ptszSection = _T("TranslitSwitcher"); + hkd.pszService = MS_TS_SWITCHLAYOUT; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/ConvertLastOrSelected"; + hkd.ptszDescription = _T("Convert Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'R') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/TranslitAllOrSelected"; + hkd.ptszDescription = _T("Translit All / Selected"); + hkd.pszService = MS_TS_TRANSLITLAYOUT; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/TranslitLastOrSelected"; + hkd.ptszDescription = _T("Translit Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'T') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/InvertCaseAllOrSelected"; + hkd.ptszDescription = _T("Invert Case All / Selected"); + hkd.pszService = MS_TS_INVERTCASE; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL+HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL; + hkd.lParam = FALSE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "TranslitSwitcher/InvertCaseLastOrSelected"; + hkd.ptszDescription = _T("Invert Case Last / Selected"); + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT+HKCOMB_A, 'Y') | HKF_MIRANDA_LOCAL; + hkd.lParam = TRUE; + + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed); + if (ServiceExists(MS_BB_ADDBUTTON) && ServiceExists(MS_SKIN2_ADDICON)) + { + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.ptszSection = _T("TabSRMM/TranslitSwitcher"); + sid.cx = sid.cy = 16; + sid.ptszDescription = _T("SwitchLayout and Send"); + sid.pszName = "SwitchLayout and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND)); + hSwitchIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + + sid.ptszDescription = _T("Translit and Send"); + sid.pszName = "Translit and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND)); + hTranslitIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + + sid.ptszDescription = _T("Invert Case and Send"); + sid.pszName = "Invert Case and Send"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND)); + hInvertIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid); + } + else if (ServiceExists(MS_BB_ADDBUTTON)) + { + hSwitchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND)); + hTranslitIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND)); + hInvertIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND)); + } + + if (ServiceExists(MS_BB_ADDBUTTON)) + { + BBButton bbd = {0}; + bbd.cbSize = sizeof(BBButton); + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; + bbd.pszModuleName = "SwitchLayout and Send"; + bbd.ptszTooltip = TranslateT("SwitchLayout and Send"); + bbd.hIcon = (HANDLE)hSwitchIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 30; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + bbd.pszModuleName = "Translit and Send"; + bbd.ptszTooltip = TranslateT("Translit and Send"); + bbd.hIcon = (HANDLE)hTranslitIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 40; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + + bbd.pszModuleName = "Invert Case and Send"; + bbd.ptszTooltip = TranslateT("Invert Case and Send"); + bbd.hIcon = (HANDLE)hInvertIcon; + bbd.dwButtonID = 1; + bbd.dwDefPos = 50; + CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); + } + + DestroyIcon(hSwitchIcon); + DestroyIcon(hTranslitIcon); + DestroyIcon(hInvertIcon); + + return 0; +} + +//------------------------------------------------------------------------------------------------------- + +extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) +{ + pluginLink = link; + mir_getMMI(&mmi); + mir_getUTFI(&utfi); + mir_getLP(&pluginInfoEx); + + hHook = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + DestroyServiceFunction(hService); + DestroyServiceFunction(hService2); + DestroyServiceFunction(hService3); + UnhookEvent(hHook); + UnhookEvent(hOnButtonPressed); + + return 0; +} \ No newline at end of file diff --git a/plugins/TranslitSwitcher/Src/TranslitSwitcher.h b/plugins/TranslitSwitcher/Src/TranslitSwitcher.h new file mode 100644 index 0000000000..cc720c19eb --- /dev/null +++ b/plugins/TranslitSwitcher/Src/TranslitSwitcher.h @@ -0,0 +1,59 @@ +/* +Copyright (C) 2007 Dmitry Titkov (C) 2010 tico-tico, Mataes + +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. +*/ + +#define MIRANDA_VER 0x0900 +#define MIRANDA_CUSTOM_LP + +#ifndef __TRANSLITSWIITCHER_H__ +#define __TRANSLITSWIITCHER_H__ + +#include +#include +#include +#include + +#include "newpluginapi.h" +#include "m_options.h" +#include "m_langpack.h" +#include "m_database.h" +#include "m_hotkeys.h" +#include "m_protosvc.h" +#include "win2k.h" +#include +#include "m_msg_buttonsbar.h" +#include "m_popup.h" + +#include "..\version.h" +#include "..\resource.h" +#include "m_smileyadd.h" +#include "m_ieview.h" +#include "m_popup2.h" + +#define IDC_MESSAGE 1002 +#define IDC_CHATMESSAGE 1009 + +VOID SwitchLayout(BOOL); +VOID TranslitLayout(BOOL); +VOID InvertCase(BOOL); +int OnButtonPressed(WPARAM wParam, LPARAM lParam); + +// {0286947D-3140-4222-B5AD-2C92315E1C1E} +#define MIID_TS { 0x286947d, 0x3140, 0x4222, { 0xb5, 0xad, 0x2c, 0x92, 0x31, 0x5e, 0x1c, 0x1e } } + +#endif diff --git a/plugins/TranslitSwitcher/TranslitSwitcher_10.sln b/plugins/TranslitSwitcher/TranslitSwitcher_10.sln new file mode 100644 index 0000000000..834b2422bd --- /dev/null +++ b/plugins/TranslitSwitcher/TranslitSwitcher_10.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TranslitSwitcher", "TranslitSwitcher_10.vcxproj", "{82F96271-4136-4B0E-AB6F-040DE7A4DD1E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Unicode|Win32 = Debug Unicode|Win32 + Debug Unicode|x64 = Debug Unicode|x64 + Release Unicode|Win32 = Release Unicode|Win32 + Release Unicode|x64 = Release Unicode|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Debug Unicode|x64.ActiveCfg = Debug Unicode|x64 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Debug Unicode|x64.Build.0 = Debug Unicode|x64 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E}.Release Unicode|x64.Build.0 = Release Unicode|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj new file mode 100644 index 0000000000..e62d312c02 --- /dev/null +++ b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + + + + TranslitSwitcher + {82F96271-4136-4B0E-AB6F-040DE7A4DD1E} + TranslitSwitcher + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + + + true + Windows + $(IntDir)$(TargetName).lib + MachineX86 + + + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + 4996 + + + true + Windows + $(IntDir)$(TargetName).lib + + + + + Full + OnlyExplicitInline + Size + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + Fast + Level3 + ProgramDatabase + 4996 + + + Windows + true + true + $(IntDir)$(TargetName).lib + MachineX86 + + + + + Full + OnlyExplicitInline + Size + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;TRANSLITSWIITCHER_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + Fast + Level3 + ProgramDatabase + 4996 + + + Windows + true + true + $(IntDir)$(TargetName).lib + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters new file mode 100644 index 0000000000..409eda7983 --- /dev/null +++ b/plugins/TranslitSwitcher/TranslitSwitcher_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/TranslitSwitcher/Version.h b/plugins/TranslitSwitcher/Version.h new file mode 100644 index 0000000000..794cba7490 --- /dev/null +++ b/plugins/TranslitSwitcher/Version.h @@ -0,0 +1,28 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#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) + +#ifdef _UNICODE +#if defined(WIN64) || defined(_WIN64) + #define __PLUGIN_NAME "Switch Layout or Transliterate (Unicode x64)" +#else + #define __PLUGIN_NAME "Switch Layout or Transliterate (Unicode)" +#endif +#else + #define __PLUGIN_NAME "Switch Layout or Transliterate" +#endif +#define __INTERNAL_NAME "TranslitSwitcher" +#define __FILENAME "TranslitSwitcher.dll" +#define __DESCRIPTION "Allows to switch a layout or transliterate or invert case of the entered text in the message window with SmileyAdd support." +#define __AUTHOR "Mataes, tico-tico, Tim" +#define __AUTHOREMAIL "mataes2007@gmail.com" +#define __AUTHORWEB "http://mataes.googlecode.com/svn/Miranda/Plugins/TranslitSwitcher/" +#define __COPYRIGHT "© 2011-2010 Mataes, tico-tico © 2007 Dmitry Titkov" diff --git a/plugins/TranslitSwitcher/Version.rc b/plugins/TranslitSwitcher/Version.rc new file mode 100644 index 0000000000..936c89e8e0 --- /dev/null +++ b/plugins/TranslitSwitcher/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +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 "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END \ No newline at end of file -- cgit v1.2.3