From 48266e479d1fcf5153b29c612866845990fccad8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 May 2015 16:11:58 +0000 Subject: war against atavisms continues - everything that goes to PSS_MESSAGE should be sent as utf8 string; - thus PREF_UNICODE & PREF_UTF support discontinued, these constants are removed; - support for PREF_UNICODE & PREF_UTF in protocols also removed; - PREF_UNICODE used in file transfers (PROTOFILERECVT) replaced with PRFF_UNICODE / PRFF_TCHAR git-svn-id: http://svn.miranda-ng.org/main/trunk@13734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Boltun/src/actionQueue.cpp | 40 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'plugins/Boltun/src/actionQueue.cpp') diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index f9d2166001..18554974be 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -83,31 +83,21 @@ static bool NotifyTyping(MCONTACT hContact) static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info) { - DBEVENTINFO ldbei; - size_t size = info->Answer.length() + 1; - size_t bufsize = size; - char* msg; - - bufsize *= sizeof(TCHAR) + 1; - msg = new char[bufsize]; - - if (!WideCharToMultiByte(CP_ACP, 0, info->Answer.c_str(), -1, msg, (int)size, NULL, NULL)) - memset(msg, '-', (size - 1)); //In case of fault return "----" in ANSI part - memcpy(msg + size, info->Answer.c_str(), size * 2); - - CallContactService(hContact, PSS_MESSAGE, PREF_TCHAR, (LPARAM)msg); - - memset(&ldbei, 0, sizeof(ldbei)); - ldbei.cbSize = sizeof(ldbei); - //FIXME: Error may happen - ldbei.cbBlob = (int)bufsize; - ldbei.pBlob = (PBYTE)(void*)msg; - ldbei.eventType = EVENTTYPE_MESSAGE; - ldbei.flags = DBEF_SENT; - ldbei.szModule = BOLTUN_NAME; - ldbei.timestamp = (DWORD)time(NULL); - - db_event_add(hContact, &ldbei); + ptrA msg(mir_utf8encodeT(info->Answer.c_str())); + size_t bufsize = mir_strlen(msg); + + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)msg); + + DBEVENTINFO dbei = { 0 }; + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = (int)bufsize; + dbei.pBlob = (PBYTE)(char*)msg; + dbei.eventType = EVENTTYPE_MESSAGE; + dbei.flags = DBEF_SENT; + dbei.szModule = BOLTUN_NAME; + dbei.timestamp = (DWORD)time(NULL); + + db_event_add(hContact, &dbei); bot->AnswerGiven(hContact, *info); delete info; -- cgit v1.2.3