summaryrefslogtreecommitdiff
path: root/plugins/CyrTranslit/src/TransliterationProtocol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CyrTranslit/src/TransliterationProtocol.cpp')
-rw-r--r--plugins/CyrTranslit/src/TransliterationProtocol.cpp66
1 files changed, 20 insertions, 46 deletions
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp
index 516d2257d3..436b68918f 100644
--- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp
+++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp
@@ -19,60 +19,34 @@
#include "stdafx.h"
-namespace CyrTranslit
-{
-
-char *TransliterationProtocol::MODULENAME = "ProtoCyrTranslitByIKR";
-
-//------------------------------------------------------------------------------
-
-void TransliterationProtocol::initialize()
-{
- Proto_RegisterModule(PROTOTYPE_TRANSLATION, MODULENAME);
-
- CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, sendMessage);
-}
+#define MODULENAME "ProtoCyrTranslitByIKR"
-//------------------------------------------------------------------------------
-void TransliterationProtocol::TranslateMessageUTF(WPARAM, LPARAM lParam)
+namespace CyrTranslit
{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
-
- wchar_t* txtWdecoded = mir_utf8decodeW(reinterpret_cast<const char*>(ccs->lParam));
- std::wstring txtW = txtWdecoded;
- mir_free(txtWdecoded);
+ //------------------------------------------------------------------------------
- txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW);
+ void TransliterationProtocol::initialize()
+ {
+ Proto_RegisterModule(PROTOTYPE_TRANSLATION, MODULENAME);
- char* txtUTFencoded = mir_utf8encodeW(txtW.c_str());
- std::string txtUTF = txtUTFencoded;
- mir_free(txtUTFencoded);
-
- ccs->lParam = reinterpret_cast<LPARAM>(mir_alloc(txtUTF.length()));
- mir_strcpy(reinterpret_cast<char*>(ccs->lParam), txtUTF.c_str());
-}
-
-//------------------------------------------------------------------------------
-
-INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
- if ( !MirandaContact::bIsActive(ccs->hContact))
- return Proto_ChainSend(wParam, ccs);
+ CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, sendMessage);
+ }
- LPARAM oldlParam = ccs->lParam;
- bool msgProcessed = true;
+ //------------------------------------------------------------------------------
- TranslateMessageUTF(wParam, lParam);
+ INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
+ {
+ CCSDATA *ccs = (CCSDATA *)lParam;
+ if (!MirandaContact::bIsActive(ccs->hContact))
+ return Proto_ChainSend(wParam, ccs);
- int ret = Proto_ChainSend(wParam, ccs);
+ LPARAM oldlParam = ccs->lParam;
+
+ CMStringA szEncoded(cyrillicToLatin((char *)ccs->lParam));
+ ccs->lParam = (LPARAM)szEncoded.c_str();
- if (msgProcessed) {
- mir_free(reinterpret_cast<void*>(ccs->lParam));
+ int ret = Proto_ChainSend(wParam, ccs);
ccs->lParam = oldlParam;
+ return ret;
}
-
- return ret;
-}
-
}