From 22a761bfdbc4b9951ea193fba7b2cc75376ebec2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Oct 2012 12:15:51 +0000 Subject: - adaptation for new NG filters; - code cleaning; - version bump + the special resource added git-svn-id: http://svn.miranda-ng.org/main/trunk@1862 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CyrTranslit/CyrTranslit_10.vcxproj | 4 +- plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters | 8 +- plugins/CyrTranslit/res/CyrTranslit.rc | 113 ------------- plugins/CyrTranslit/res/version.rc | 40 +++++ plugins/CyrTranslit/src/MirandaContact.cpp | 163 ++++++++----------- plugins/CyrTranslit/src/MirandaContact.h | 174 ++++++++++----------- plugins/CyrTranslit/src/TransliterationMap.cpp | 6 +- .../CyrTranslit/src/TransliterationProtocol.cpp | 95 ++++------- plugins/CyrTranslit/src/TransliterationProtocol.h | 3 - plugins/CyrTranslit/src/main.cpp | 20 +-- plugins/CyrTranslit/src/plugin.h | 18 +-- plugins/CyrTranslit/src/version.h | 43 +++++ 12 files changed, 286 insertions(+), 401 deletions(-) delete mode 100644 plugins/CyrTranslit/res/CyrTranslit.rc create mode 100644 plugins/CyrTranslit/res/version.rc create mode 100644 plugins/CyrTranslit/src/version.h (limited to 'plugins/CyrTranslit') diff --git a/plugins/CyrTranslit/CyrTranslit_10.vcxproj b/plugins/CyrTranslit/CyrTranslit_10.vcxproj index 5f49acbf13..d8fbda81c5 100644 --- a/plugins/CyrTranslit/CyrTranslit_10.vcxproj +++ b/plugins/CyrTranslit/CyrTranslit_10.vcxproj @@ -173,10 +173,10 @@ - + - + diff --git a/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters b/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters index 19885e96b5..cb35ab642d 100644 --- a/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters +++ b/plugins/CyrTranslit/CyrTranslit_10.vcxproj.filters @@ -46,11 +46,11 @@ - - Resource Files - + - + + Resource Files + \ No newline at end of file diff --git a/plugins/CyrTranslit/res/CyrTranslit.rc b/plugins/CyrTranslit/res/CyrTranslit.rc deleted file mode 100644 index bb61ce1a7e..0000000000 --- a/plugins/CyrTranslit/res/CyrTranslit.rc +++ /dev/null @@ -1,113 +0,0 @@ -// 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 - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#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 // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Dutch (Netherlands) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) -#ifdef _WIN32 -LANGUAGE LANG_DUTCH, SUBLANG_DUTCH -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,3,0 - PRODUCTVERSION 1,0,3,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "CyrTrans Dynamic Link Library" - VALUE "FileVersion", "1, 0, 3, 0" - VALUE "InternalName", "CyrTrans" - VALUE "LegalCopyright", "Copyright (C) 2005 Ivan Krechetov, modified 2006-2009 by ValeraVi" - VALUE "OriginalFilename", "CyrTrans.dll" - VALUE "ProductName", " CyrTrans Dynamic Link Library" - VALUE "ProductVersion", "1, 0, 3, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // Dutch (Netherlands) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/CyrTranslit/res/version.rc b/plugins/CyrTranslit/res/version.rc new file mode 100644 index 0000000000..b8fb57b0de --- /dev/null +++ b/plugins/CyrTranslit/res/version.rc @@ -0,0 +1,40 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +///////////////////////////////////////////////////////////////////////////// +// +// 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 "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/CyrTranslit/src/MirandaContact.cpp b/plugins/CyrTranslit/src/MirandaContact.cpp index 0f5df412b2..931ed6e2c6 100644 --- a/plugins/CyrTranslit/src/MirandaContact.cpp +++ b/plugins/CyrTranslit/src/MirandaContact.cpp @@ -24,23 +24,22 @@ namespace CyrTranslit { -const std::string MirandaContact::SETTINGS_MODULE = "CyrTranslit"; +const char* MirandaContact::SETTINGS_MODULE = "CyrTranslit"; -const std::string MirandaContact::SETTING_SHOULD_TRANSLITERATE - = "translit"; +const char* MirandaContact::SETTING_SHOULD_TRANSLITERATE = "translit"; char *MirandaContact::MENU_ITEM_TEXT = "&Transliterate (ÔÛÂÀ->FYVA)"; char *MirandaContact::MENU_COMMAND_CALLBACK_SERVICE - = "CyrTranslit/ContactMenuCmd"; - + = "CyrTranslit/ContactMenuCmd"; + HANDLE MirandaContact::hTransliterateCmdMenuItem = 0; //------------------------------------------------------------------------------ MirandaContact::MirandaContact() - : handle(0), - transliterateOutgoingMessages(false) + : handle(0), + transliterateOutgoingMessages(false) { } @@ -54,139 +53,107 @@ MirandaContact::~MirandaContact() void MirandaContact::initialize() { - CreateServiceFunction(MENU_COMMAND_CALLBACK_SERVICE,onMenuCommandTransliterate); - generateMenuItemsForAllContacts(); - - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPreBuildContactMenu); - - TransliterationProtocol::initialize(); - activateTransliterationProtocolForSubscribedContacts(); + CreateServiceFunction(MENU_COMMAND_CALLBACK_SERVICE,onMenuCommandTransliterate); + generateMenuItemsForAllContacts(); + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPreBuildContactMenu); + + TransliterationProtocol::initialize(); + activateTransliterationProtocolForSubscribedContacts(); } //------------------------------------------------------------------------------ MirandaContact MirandaContact::getContact(HANDLE hContact) { - int b = DBGetContactSettingByte( - hContact, - SETTINGS_MODULE.c_str(), - SETTING_SHOULD_TRANSLITERATE.c_str(), - 0); - - MirandaContact ret; - ret.handle = hContact; - ret.transliterateOutgoingMessages = (b != 0); - - return ret; -} + int b = db_get_b(hContact, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, 0); -//------------------------------------------------------------------------------ + MirandaContact ret; + ret.handle = hContact; + ret.transliterateOutgoingMessages = (b != 0); -void MirandaContact::save() const -{ - DBWriteContactSettingByte( - handle, - SETTINGS_MODULE.c_str(), - SETTING_SHOULD_TRANSLITERATE.c_str(), - transliterateOutgoingMessages? 1 : 0); + return ret; } //------------------------------------------------------------------------------ -bool MirandaContact::shouldTransliterateOutgoingMessages() const +void MirandaContact::save() const { - return transliterateOutgoingMessages; + db_set_b(handle, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, transliterateOutgoingMessages); } //------------------------------------------------------------------------------ -void MirandaContact::fillInMenuItem(CLISTMENUITEM &mi) +bool MirandaContact::shouldTransliterateOutgoingMessages() const { - mi.cbSize = sizeof(CLISTMENUITEM); - mi.pszName = MENU_ITEM_TEXT; - mi.flags = 0; - mi.position = 65535; - mi.hIcon = NULL; - mi.pszService = MENU_COMMAND_CALLBACK_SERVICE; - mi.pszPopupName = NULL; - mi.popupPosition = 0; - mi.hotKey = 0; - mi.pszContactOwner = NULL; + return transliterateOutgoingMessages; } //------------------------------------------------------------------------------ void MirandaContact::generateMenuItemsForAllContacts() { - CLISTMENUITEM mi; - fillInMenuItem(mi); - hTransliterateCmdMenuItem = Menu_AddContactMenuItem(&mi); + CLISTMENUITEM mi; + mi.cbSize = sizeof(CLISTMENUITEM); + mi.pszName = MENU_ITEM_TEXT; + mi.flags = 0; + mi.position = 65535; + mi.hIcon = NULL; + mi.pszService = MENU_COMMAND_CALLBACK_SERVICE; + mi.pszPopupName = NULL; + mi.popupPosition = 0; + mi.hotKey = 0; + mi.pszContactOwner = NULL; + hTransliterateCmdMenuItem = Menu_AddContactMenuItem(&mi); } //------------------------------------------------------------------------------ void MirandaContact::activateTransliterationProtocolForSubscribedContacts() { - HANDLE hContact = db_find_first(); - if(!hContact) - return; - - do - { - MirandaContact mc = getContact(reinterpret_cast(hContact)); - - if(mc.shouldTransliterateOutgoingMessages()) - { - TransliterationProtocol::activateForContact(mc.handle); - } - } while(hContact = db_find_next(hContact)); + HANDLE hContact = db_find_first(); + if (!hContact) + return; + + do { + MirandaContact mc = getContact(reinterpret_cast(hContact)); + if (mc.shouldTransliterateOutgoingMessages()) + mc.save(); + } + while(hContact = db_find_next(hContact)); } //------------------------------------------------------------------------------ INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam) { - HANDLE hContact = reinterpret_cast(wParam); - if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - - MirandaContact mc = getContact(hContact); - mc.transliterateOutgoingMessages = !mc.transliterateOutgoingMessages; - mc.save(); - - if(mc.shouldTransliterateOutgoingMessages()) - { - TransliterationProtocol::activateForContact(mc.handle); - } - else - { - TransliterationProtocol::deactivateForContact(mc.handle); - } - - return 0; + HANDLE hContact = reinterpret_cast(wParam); + if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) + return 0; + + MirandaContact mc = getContact(hContact); + mc.transliterateOutgoingMessages = !mc.transliterateOutgoingMessages; + mc.save(); + return 0; } //------------------------------------------------------------------------------ int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM lParam) { - if(!hTransliterateCmdMenuItem) return 0; - HANDLE hContact = reinterpret_cast(wParam); - if(!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - - MirandaContact mc = getContact(hContact); - - CLISTMENUITEM mi; - fillInMenuItem(mi); - - DWORD toSet = mc.shouldTransliterateOutgoingMessages()? CMIF_CHECKED : 0; - mi.flags = CMIM_FLAGS | toSet; - - CallService( - MS_CLIST_MODIFYMENUITEM, - reinterpret_cast(hTransliterateCmdMenuItem), - reinterpret_cast(&mi)); - - return 0; + if (!hTransliterateCmdMenuItem) return 0; + HANDLE hContact = reinterpret_cast(wParam); + if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; + + MirandaContact mc = getContact(hContact); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.flags = CMIM_FLAGS; + if (mc.shouldTransliterateOutgoingMessages()) + mi.flags |= CMIF_CHECKED; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hTransliterateCmdMenuItem, (LPARAM)&mi); + return 0; } } \ No newline at end of file diff --git a/plugins/CyrTranslit/src/MirandaContact.h b/plugins/CyrTranslit/src/MirandaContact.h index 0e29f3d74e..1fdda0156e 100644 --- a/plugins/CyrTranslit/src/MirandaContact.h +++ b/plugins/CyrTranslit/src/MirandaContact.h @@ -25,99 +25,97 @@ namespace CyrTranslit { /** - * The Miranda IM contact abstraction in respect to the transliteration process. - */ +* The Miranda IM contact abstraction in respect to the transliteration process. +*/ class MirandaContact { public: - /** - * This message must be sent on Miranda startup. - */ - static void initialize(); - - /** - * A factory method which instantiates new MirandaContact objects, loading - * its data from the Miranda database. - * - * @param hContact The handle of the contact object to be instantiated. - * @return The Miranda IM contact having the passed handle. - */ - static MirandaContact getContact(HANDLE hContact); - - /** - * Saves this object's data to the persistent storage -- the Miranda - * database. This information may be retreived later on by means of - * getContact() factory method invocation. - */ - void save() const; - - /** - * @return True only if the Cyrillic transliteration is on for this contact. - */ - bool shouldTransliterateOutgoingMessages() const; - - ~MirandaContact(); + /** + * This message must be sent on Miranda startup. + */ + static void initialize(); + + /** + * A factory method which instantiates new MirandaContact objects, loading + * its data from the Miranda database. + * + * @param hContact The handle of the contact object to be instantiated. + * @return The Miranda IM contact having the passed handle. + */ + static MirandaContact getContact(HANDLE hContact); + + /** + * Saves this object's data to the persistent storage -- the Miranda + * database. This information may be retreived later on by means of + * getContact() factory method invocation. + */ + void save() const; + + /** + * @return True only if the Cyrillic transliteration is on for this contact. + */ + bool shouldTransliterateOutgoingMessages() const; + + ~MirandaContact(); private: - static const std::string SETTINGS_MODULE; - static const std::string SETTING_SHOULD_TRANSLITERATE; - - static char *MENU_ITEM_TEXT; - - MirandaContact(); - - /** - * Must be called on Miranda start-up to generate the transliteration - * command menu items for all the contacts (a contact-specific menu). - */ - static void generateMenuItemsForAllContacts(); - - static void activateTransliterationProtocolForSubscribedContacts(); - - /** - * This is a callback function for the transliteration command menu item. - * This menu item is contact-specific. - * - * @param wParam The HANDLE of the contact that owns the activated menu - * item. - * @param lParam hwndContactList - * @return Always returns 0. - */ - static INT_PTR onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam); - - /** - * This is a service name to bind the onMenuCommandTransliterate() method to - * within the Miranda IM framework. - */ - static char *MENU_COMMAND_CALLBACK_SERVICE; - - /** - * Stores the handle to a single user menu item shared by all the contacts. - * This menu item has a contact-specific state -- checked or unchecked, as - * far as for some contacts transliteration may be on, and for others it may - * be off. - * - * MirandaContact class makes the necessary update just before a menu is - * shown for a contact: it checks or unchecks the transliteration menu item. - * - * When the transliteration menu item is activated by a user, the - * transliteration setting (on or off) is inverted for the contact owing the - * menu. - */ - static HANDLE hTransliterateCmdMenuItem; - - /** - * @param wParam The HANDLE of the contact that owns the menu item being - * built. - * @param lParam = 0. - * @return Always returns 0. - */ - static int onPreBuildContactMenu(WPARAM wParam, LPARAM lParam); - - static void fillInMenuItem(CLISTMENUITEM &mi); - - HANDLE handle; - bool transliterateOutgoingMessages; + static const char* SETTINGS_MODULE; + static const char* SETTING_SHOULD_TRANSLITERATE; + + static char *MENU_ITEM_TEXT; + + MirandaContact(); + + /** + * Must be called on Miranda start-up to generate the transliteration + * command menu items for all the contacts (a contact-specific menu). + */ + static void generateMenuItemsForAllContacts(); + + static void activateTransliterationProtocolForSubscribedContacts(); + + /** + * This is a callback function for the transliteration command menu item. + * This menu item is contact-specific. + * + * @param wParam The HANDLE of the contact that owns the activated menu + * item. + * @param lParam hwndContactList + * @return Always returns 0. + */ + static INT_PTR onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam); + + /** + * This is a service name to bind the onMenuCommandTransliterate() method to + * within the Miranda IM framework. + */ + static char *MENU_COMMAND_CALLBACK_SERVICE; + + /** + * Stores the handle to a single user menu item shared by all the contacts. + * This menu item has a contact-specific state -- checked or unchecked, as + * far as for some contacts transliteration may be on, and for others it may + * be off. + * + * MirandaContact class makes the necessary update just before a menu is + * shown for a contact: it checks or unchecks the transliteration menu item. + * + * When the transliteration menu item is activated by a user, the + * transliteration setting (on or off) is inverted for the contact owing the + * menu. + */ + static HANDLE hTransliterateCmdMenuItem; + + /** + * @param wParam The HANDLE of the contact that owns the menu item being + * built. + * @param lParam = 0. + * @return Always returns 0. + */ + static int onPreBuildContactMenu(WPARAM wParam, LPARAM lParam); + + HANDLE handle; + bool transliterateOutgoingMessages; }; } \ No newline at end of file diff --git a/plugins/CyrTranslit/src/TransliterationMap.cpp b/plugins/CyrTranslit/src/TransliterationMap.cpp index f678c0a16e..0e763fa854 100644 --- a/plugins/CyrTranslit/src/TransliterationMap.cpp +++ b/plugins/CyrTranslit/src/TransliterationMap.cpp @@ -37,7 +37,7 @@ TransliterationMap::Guard::~Guard() const TransliterationMap& TransliterationMap::getInstance() { - if(!pInstance) + if (!pInstance) { pInstance = new TransliterationMap(); } @@ -195,7 +195,7 @@ std::string TransliterationMap::cyrillicToLatin(char c) const std::string ret(1, c); CharMap::const_iterator it = theMap.find(c); - if(it != theMap.end()) + if (it != theMap.end()) { ret = (*it).second; } @@ -209,7 +209,7 @@ std::wstring TransliterationMap::cyrillicToLatin(wchar_t c) const std::wstring ret(1, c); WCharMap::const_iterator it = theMapW.find(c); - if(it != theMapW.end()) + if (it != theMapW.end()) { ret = (*it).second; } diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp index 1738aa818d..afba765122 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -30,81 +30,77 @@ char *TransliterationProtocol::MODULE_NAME = "ProtoCyrTranslitByIKR"; void TransliterationProtocol::initialize() { - PROTOCOLDESCRIPTOR desc; - desc.cbSize = sizeof(desc); - desc.szName = MODULE_NAME; - desc.type = PROTOTYPE_TRANSLATION; - - CallService( - MS_PROTO_REGISTERMODULE, - 0, - reinterpret_cast(&desc)); - - CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessageA); - CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE"W", sendMessageW); + PROTOCOLDESCRIPTOR desc; + desc.cbSize = sizeof(desc); + desc.szName = MODULE_NAME; + desc.type = PROTOTYPE_TRANSLATION; + CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast(&desc)); + + CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessageA); + CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE"W", sendMessageW); } //------------------------------------------------------------------------------ void TransliterationProtocol::TranslateMessageUTF(WPARAM wParam, LPARAM lParam) { - CCSDATA *ccs = reinterpret_cast(lParam); + CCSDATA *ccs = reinterpret_cast(lParam); wchar_t* txtWdecoded = mir_utf8decodeW(reinterpret_cast(ccs->lParam)); std::wstring txtW = txtWdecoded; mir_free(txtWdecoded); - txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); + txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); char* txtUTFencoded = mir_utf8encodeW(txtW.c_str()); std::string txtUTF = txtUTFencoded; mir_free(txtUTFencoded); - + ccs->lParam = reinterpret_cast(mir_alloc(txtUTF.length())); - strcpy(reinterpret_cast(ccs->lParam), txtUTF.c_str()); + strcpy(reinterpret_cast(ccs->lParam), txtUTF.c_str()); } void TransliterationProtocol::TranslateMessageW(WPARAM wParam, LPARAM lParam) { - CCSDATA *ccs = reinterpret_cast(lParam); + CCSDATA *ccs = reinterpret_cast(lParam); - std::string txtA = reinterpret_cast(ccs->lParam); + std::string txtA = reinterpret_cast(ccs->lParam); int txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); - txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA); + txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA); - std::wstring txtW = reinterpret_cast(ccs->lParam + txtAlen); - txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); + std::wstring txtW = reinterpret_cast(ccs->lParam + txtAlen); + txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW); txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1)); - const DWORD newSize = static_cast(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1))); - - ccs->lParam = reinterpret_cast(mir_alloc(newSize)); - - strcpy(reinterpret_cast(ccs->lParam), txtA.c_str()); - wcscpy(reinterpret_cast(ccs->lParam + txtAlen), txtW.c_str()); + const DWORD newSize = static_cast(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1))); + + ccs->lParam = reinterpret_cast(mir_alloc(newSize)); + + strcpy(reinterpret_cast(ccs->lParam), txtA.c_str()); + wcscpy(reinterpret_cast(ccs->lParam + txtAlen), txtW.c_str()); } void TransliterationProtocol::TranslateMessageA(WPARAM wParam, LPARAM lParam) { - CCSDATA *ccs = reinterpret_cast(lParam); + CCSDATA *ccs = reinterpret_cast(lParam); std::string txt = reinterpret_cast(ccs->lParam); txt = TransliterationMap::getInstance().cyrillicToLatin(txt); - + const DWORD newSize = static_cast(txt.length() + 1); - + ccs->lParam = reinterpret_cast(mir_alloc(newSize)); - + strcpy(reinterpret_cast(ccs->lParam), txt.c_str()); } INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam) { - CCSDATA *ccs = reinterpret_cast(lParam); + CCSDATA *ccs = reinterpret_cast(lParam); LPARAM oldlParam = ccs->lParam; TranslateMessageW(wParam, lParam); - int ret = CallService(MS_PROTO_CHAINSEND /* "W" */, wParam, lParam); + int ret = CallService(MS_PROTO_CHAINSEND /* "W" */, wParam, lParam); mir_free(reinterpret_cast(ccs->lParam)); ccs->lParam = oldlParam; @@ -119,23 +115,16 @@ INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam) LPARAM oldlParam = ccs->lParam; bool msgProcessed = true; - if(ccs->wParam & PREF_UTF) - { + if (ccs->wParam & PREF_UTF) TranslateMessageUTF(wParam, lParam); - } - else if(ccs->wParam & PREF_UNICODE) - { + else if (ccs->wParam & PREF_UNICODE) TranslateMessageW(wParam, lParam); - } else - { TranslateMessageA(wParam, lParam); - } int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); - if(msgProcessed) - { + if (msgProcessed) { mir_free(reinterpret_cast(ccs->lParam)); ccs->lParam = oldlParam; } @@ -143,24 +132,4 @@ INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam) return ret; } -//------------------------------------------------------------------------------ - -void TransliterationProtocol::activateForContact(HANDLE hContact) -{ - CallService( - MS_PROTO_ADDTOCONTACT, - reinterpret_cast(hContact), - reinterpret_cast(MODULE_NAME)); -} - -//------------------------------------------------------------------------------ - -void TransliterationProtocol::deactivateForContact(HANDLE hContact) -{ - CallService( - MS_PROTO_REMOVEFROMCONTACT, - reinterpret_cast(hContact), - reinterpret_cast(MODULE_NAME)); -} - } diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.h b/plugins/CyrTranslit/src/TransliterationProtocol.h index 52d9fc0e74..30c890d971 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.h +++ b/plugins/CyrTranslit/src/TransliterationProtocol.h @@ -51,9 +51,6 @@ public: static void TranslateMessageW(WPARAM wParam, LPARAM lParam); static void TranslateMessageUTF(WPARAM wParam, LPARAM lParam); - static void activateForContact(HANDLE hContact); - static void deactivateForContact(HANDLE hContact); - private: static char *MODULE_NAME; diff --git a/plugins/CyrTranslit/src/main.cpp b/plugins/CyrTranslit/src/main.cpp index 49761dc305..8266dd748d 100644 --- a/plugins/CyrTranslit/src/main.cpp +++ b/plugins/CyrTranslit/src/main.cpp @@ -25,15 +25,15 @@ int hLangpack = 0; PLUGININFOEX pluginInfoEx={ sizeof(PLUGININFOEX), - PLG_SHORTNAME, - PLG_VERSION, - PLG_DESCRIPTION, - PLG_AUTHOR, - PLG_AUTHOREMAIL, - PLG_COPYRIGHT, - PLG_HOMEPAGE, - PLG_FLAGS, - MIID_V_CYRTRANSLIT + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + {0xbcec0bd7, 0xca59, 0x44b2, {0x9a, 0x14, 0x3a, 0x14, 0x98, 0x0f, 0x52, 0x4a}} }; //------------------------------------------------------------------------------ @@ -69,4 +69,4 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void) { return 0; -} \ No newline at end of file +} diff --git a/plugins/CyrTranslit/src/plugin.h b/plugins/CyrTranslit/src/plugin.h index bc6cf74a1e..f136504e2f 100644 --- a/plugins/CyrTranslit/src/plugin.h +++ b/plugins/CyrTranslit/src/plugin.h @@ -43,20 +43,4 @@ #include "m_clist.h" #include "m_langpack.h" - -/****** PLUGIN DEFINES *******************************************************/ - -// pluginInfo: -#define PLG_SHORTNAME "CyrTranslit" -#define PLG_VERSION PLUGIN_MAKE_VERSION(1, 0, 3, 0) -#define PLG_DESCRIPTION "Replaces (for the selected contacts only) the Cyrillic letters in the "\ - "outgoing messages with the phonetically equivalent Latin letter "\ - "combinations." -#define PLG_AUTHOR "ValeraVi, Ivan Krechetov" -#define PLG_AUTHOREMAIL "valeravi@vi-soft.com.ua" -#define PLG_COPYRIGHT "© 2005-2009 ValeraVi, Ivan Krechetov" -#define PLG_HOMEPAGE "http://miranda-ng.org/" -#define PLG_FLAGS 0 /*UNICODE_AWARE, will be set dynamically*/ -#define MIID_V_CYRTRANSLIT {0xbcec0bd7, 0xca59, 0x44b2, {0x9a, 0x14, 0x3a, 0x14, 0x98, 0x0f, 0x52, 0x4a}} - - +#include "version.h" diff --git a/plugins/CyrTranslit/src/version.h b/plugins/CyrTranslit/src/version.h new file mode 100644 index 0000000000..5805e97258 --- /dev/null +++ b/plugins/CyrTranslit/src/version.h @@ -0,0 +1,43 @@ +/* + +'File Association Manager'-Plugin for Miranda IM + +Copyright (C) 2005-2007 H. Herkenrath + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (AssocMgr-License.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#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 "CyrTranslit" +#define __INTERNAL_NAME "CyrTranslit" +#define __FILENAME "CyrTranslit.dll" +#define __DESCRIPTION "Replaces (for the selected contacts only) the Cyrillic letters in the "\ + "outgoing messages with the phonetically equivalent Latin letter "\ + "combinations." +#define __AUTHOR "ValeraVi, Ivan Krechetov" +#define __AUTHOREMAIL "valeravi@vi-soft.com.ua" +#define __AUTHORWEB "http://miranda-ng.org/" +#define __COPYRIGHT "© 2005-2009 ValeraVi, Ivan Krechetov" -- cgit v1.2.3