diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
commit | 48266e479d1fcf5153b29c612866845990fccad8 (patch) | |
tree | c8cbc908cd3c5f08731e5e8d7eaac6b568007d09 /plugins | |
parent | ebdb556f152734035846f120eb8112f88ef91281 (diff) |
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
Diffstat (limited to 'plugins')
42 files changed, 267 insertions, 891 deletions
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;
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index 843ee1d2ca..21ede36856 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -146,7 +146,7 @@ int CheckDate(MCONTACT hContact) void SendPounce(TCHAR *text, MCONTACT hContact)
{
ptrA pszUtf(mir_utf8encodeT(text));
- if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)pszUtf))
+ if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf))
WindowList_Add(hWindowList, (HWND)hSendId, hContact);
}
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp index c4d6649f2c..ebb544ffd1 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -55,40 +55,6 @@ void TransliterationProtocol::TranslateMessageUTF(WPARAM, LPARAM lParam) strcpy(reinterpret_cast<char*>(ccs->lParam), txtUTF.c_str());
}
-void TransliterationProtocol::TranslateMessageW(WPARAM, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
-
- std::string txtA = reinterpret_cast<const char*>(ccs->lParam);
- int txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1));
- txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA);
-
- std::wstring txtW = reinterpret_cast<const wchar_t*>(ccs->lParam + txtAlen);
- txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW);
-
- txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1));
- const DWORD newSize = static_cast<DWORD>(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1)));
-
- ccs->lParam = reinterpret_cast<LPARAM>(mir_alloc(newSize));
-
- strcpy(reinterpret_cast<char*>(ccs->lParam), txtA.c_str());
- wcscpy(reinterpret_cast<wchar_t*>(ccs->lParam + txtAlen), txtW.c_str());
-}
-
-void TransliterationProtocol::TranslateMessageA(WPARAM, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
-
- std::string txt = reinterpret_cast<const char*>(ccs->lParam);
- txt = TransliterationMap::getInstance().cyrillicToLatin(txt);
-
- const DWORD newSize = static_cast<DWORD>(txt.length() + 1);
-
- ccs->lParam = reinterpret_cast<LPARAM>(mir_alloc(newSize));
-
- strcpy(reinterpret_cast<char*>(ccs->lParam), txt.c_str());
-}
-
//------------------------------------------------------------------------------
INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
@@ -100,12 +66,7 @@ INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam) LPARAM oldlParam = ccs->lParam;
bool msgProcessed = true;
- if (ccs->wParam & PREF_UTF)
- TranslateMessageUTF(wParam, lParam);
- else if (ccs->wParam & PREF_UNICODE)
- TranslateMessageW(wParam, lParam);
- else
- TranslateMessageA(wParam, lParam);
+ TranslateMessageUTF(wParam, lParam);
int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.h b/plugins/CyrTranslit/src/TransliterationProtocol.h index 08cb715447..cf86d183bc 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.h +++ b/plugins/CyrTranslit/src/TransliterationProtocol.h @@ -46,8 +46,6 @@ public: */
static INT_PTR sendMessage(WPARAM wParam, LPARAM lParam);
- static void TranslateMessageA(WPARAM wParam, LPARAM lParam);
- static void TranslateMessageW(WPARAM wParam, LPARAM lParam);
static void TranslateMessageUTF(WPARAM wParam, LPARAM lParam);
private:
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index c32ebf1802..66e5c14b98 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -149,28 +149,21 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam) return 0;
}
- char *message = NULL;
char *szMessage = (char*)pccsd->lParam;
- if (pccsd->wParam & PREF_UNICODE)
- message = mir_utf8encodeW((wchar_t*)&szMessage[mir_strlen(szMessage) + 1]);
- else if (pccsd->wParam & PREF_UTF)
- message = mir_strdup(szMessage);
- else
- message = mir_utf8encode(szMessage);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = MODULE;
dbei.timestamp = time(NULL);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (int)mir_strlen(message);
- dbei.pBlob = (PBYTE)message;
+ dbei.cbBlob = (int)mir_strlen(szMessage);
+ dbei.pBlob = (PBYTE)szMessage;
dbei.flags = DBEF_SENT | DBEF_READ | DBEF_UTF;
db_event_add(pccsd->hContact, &dbei);
- if (message[0] && message[0] == '/')
+ if (*szMessage == '/')
{
// parse commands
- char *sep = strchr(message, ' ');
+ char *sep = strchr(szMessage, ' ');
if (sep != NULL) *sep = 0;
struct
@@ -188,7 +181,7 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam) for (int i = 0; i < SIZEOF(commands); i++)
{
- if (!strcmp(message + 1, commands[i].szCommand))
+ if (!strcmp(szMessage+1, commands[i].szCommand))
{
ULONG messageId = InterlockedIncrement(&hMessageProcess);
@@ -206,9 +199,8 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam) }
char help[1024];
- mir_snprintf(help, SIZEOF(help), Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), message);
+ mir_snprintf(help, SIZEOF(help), Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), szMessage);
CallContactService(GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)help);
-
return 0;
}
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index cceb9ea985..40aa523691 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -228,7 +228,7 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg) char *message = mir_utf8encode(data);
if (ftp->hContact != instance->GetDefaultContact())
{
- if (CallContactService(ftp->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)message) != ACKRESULT_FAILED)
+ if (CallContactService(ftp->hContact, PSS_MESSAGE, 0, (LPARAM)message) != ACKRESULT_FAILED)
{
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.flags = DBEF_UTF | DBEF_SENT/* | DBEF_READ*/;
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 79a897b098..737add6ca9 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -149,25 +149,11 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_ return;
}
- int mirandaSendModeFlag = getMirandaSendModeFlag(targetHandleSzProto);
-
- char* msgBuffer = NULL;
- std::size_t bufSize = 0;
-
- if (mirandaSendModeFlag == PREF_UTF){
- msgBuffer = mir_utf8encodeW(args->userActionSelection);
- bufSize = strlen(msgBuffer) + 1;
- } else if (mirandaSendModeFlag == PREF_UNICODE){
- msgBuffer = mir_t2a(args->userActionSelection);
- bufSize = strlen(msgBuffer) + 1;
- size_t bufSizeT = (wcslen(args->userActionSelection) + 1) * sizeof(wchar_t);
- msgBuffer = (char*)mir_realloc(msgBuffer, bufSizeT + bufSize);
- memcpy((wchar_t*)&msgBuffer[bufSize], args->userActionSelection, bufSizeT);
- bufSize += bufSizeT;
- }
+ ptrA msgBuffer(mir_utf8encodeW(args->userActionSelection));
+ std::size_t bufSize = strlen(msgBuffer) + 1;
- logger->log_p(L"SMTC: mirandaSendModeFlag = [%d] bufSize = [%d]", mirandaSendModeFlag, bufSize);
- HANDLE hProcess = sendMessageMiranda((MCONTACT)args->targetHandle, mirandaSendModeFlag, msgBuffer);
+ logger->log_p(L"SMTC: bufSize = [%d]", bufSize);
+ HANDLE hProcess = sendMessageMiranda((MCONTACT)args->targetHandle, msgBuffer);
logger->log_p(L"SMTC: hProcess = [" SCNuPTR L"]", hProcess);
MIRFOXACKDATA* myMfAck = NULL;
@@ -204,40 +190,38 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_ if (mirandaContact){
contactNameW = mirandaContact->contactNameW.c_str();
MirandaAccount* mirandaAccount = mirandaContact->mirandaAccountPtr;
- if (mirandaAccount){
+ if (mirandaAccount)
tszAccountName = mirandaAccount->tszAccountName;
- }
}
if(myMfAck != NULL && myMfAck->result == ACKRESULT_SUCCESS){
- addMessageToDB((MCONTACT)args->targetHandle, mirandaSendModeFlag, msgBuffer, bufSize, targetHandleSzProto);
+ addMessageToDB((MCONTACT)args->targetHandle, msgBuffer, bufSize, targetHandleSzProto);
if (mode == MFENUM_SMM_ONLY_SEND){
//show notyfication popup (only in SMM_ONLY_SEND mode)
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
- if (contactNameW != NULL && tszAccountName != NULL){
+ if (contactNameW != NULL && tszAccountName != NULL)
mir_sntprintf(buffer, 1024, TranslateT("Message sent to %s (%s)"), contactNameW, tszAccountName);
- } else {
+ else
mir_sntprintf(buffer, 1024, TranslateT("Message sent"));
- }
- if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
+ if(ServiceExists(MS_POPUP_ADDPOPUPCLASS))
ShowClassPopupT("MirFox_Notify", _T("MirFox"), buffer);
- } else {
+ else
PUShowMessageT(buffer, SM_NOTIFY);
- }
delete[] buffer;
- } else if (mode == MFENUM_SMM_SEND_AND_SHOW_MW){
+ }
+ else if (mode == MFENUM_SMM_SEND_AND_SHOW_MW){
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
OnHookOpenMvStruct* onHookOpenMv = new(OnHookOpenMvStruct);
onHookOpenMv->targetHandle = args->targetHandle;
onHookOpenMv->msgBuffer = NULL;
NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
- } else {
- logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
+ else logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
- } else {
+ }
+ else {
//error - show error popup
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
if (myMfAck != NULL){
@@ -281,9 +265,8 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_ EnterCriticalSection(&ackMapCs);
ackMap.erase(hProcess);
LeaveCriticalSection(&ackMapCs);
-
- mir_free(msgBuffer);
- } else if (mode == MFENUM_SMM_ONLY_SHOW_MW){
+ }
+ else if (mode == MFENUM_SMM_ONLY_SHOW_MW) {
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
@@ -295,32 +278,22 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_ msgBuffer->append(L"\r\n");
onHookOpenMv->msgBuffer = msgBuffer;
NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
- } else {
- logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
+ else logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
}
-int MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto)
-{
- if (CallProtoService(targetHandleSzProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF){
- return PREF_UTF;
- } else {
- return PREF_UNICODE;
- }
-}
-
-HANDLE MirandaUtils::sendMessageMiranda(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer)
+HANDLE MirandaUtils::sendMessageMiranda(MCONTACT hContact, char *msgBuffer)
{
- return (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)mirandaSendModeFlag, (LPARAM)msgBuffer);
+ return (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)msgBuffer);
}
-void MirandaUtils::addMessageToDB(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto)
+void MirandaUtils::addMessageToDB(MCONTACT hContact, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto)
{
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((mirandaSendModeFlag&PREF_UTF)==PREF_UTF ? DBEF_UTF : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = targetHandleSzProto;
dbei.timestamp = (DWORD)time(NULL);
dbei.cbBlob = (DWORD)bufSize;
diff --git a/plugins/MirFox/src/MirandaUtils.h b/plugins/MirFox/src/MirandaUtils.h index 08d434a418..f43c7c0f67 100644 --- a/plugins/MirFox/src/MirandaUtils.h +++ b/plugins/MirFox/src/MirandaUtils.h @@ -78,11 +78,9 @@ private: void sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode);
- int getMirandaSendModeFlag(char* targetHandleSzProto);
+ HANDLE sendMessageMiranda(MCONTACT hContact, char* msgBuffer);
- HANDLE sendMessageMiranda(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer);
-
- void addMessageToDB(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto);
+ void addMessageToDB(MCONTACT hContact, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto);
void setStatusOnAccount(ActionThreadArgStruct* args);
diff --git a/plugins/MirOTR/src/otr.cpp b/plugins/MirOTR/src/otr.cpp index 09d912adf8..e8f0bcbe22 100644 --- a/plugins/MirOTR/src/otr.cpp +++ b/plugins/MirOTR/src/otr.cpp @@ -133,7 +133,7 @@ extern "C" { DEBUGOUT_T("OTR_GUI_INJECT_MESSAGE\n"); MCONTACT hContact = (MCONTACT)opdata; if (db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) - CallContactService(hContact, PSS_MESSAGE, PREF_UTF | PREF_BYPASS_OTR, (LPARAM)message); + CallContactService(hContact, PSS_MESSAGE, PREF_BYPASS_OTR, (LPARAM)message); } /* When the list of ConnContexts changes (including a change in diff --git a/plugins/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/src/svcs_proto.cpp index 1d89651585..22b428145e 100644 --- a/plugins/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/src/svcs_proto.cpp @@ -21,44 +21,26 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ return 1; // error const char *oldmessage = (const char *)ccs->lParam; - char *oldmessage_utf = NULL; - - //MessageBox(0, "Send message - converting to UTF-8", "msg", MB_OK); - - if(ccs->wParam & PREF_UTF) { - oldmessage_utf = (char*)oldmessage; - } - else if(ccs->wParam & PREF_UNICODE) { - oldmessage_utf = mir_utf8encodeW((wchar_t*)&oldmessage[strlen(oldmessage)+1]); - } - else { - oldmessage_utf = mir_utf8encode(oldmessage); - } - if (!oldmessage_utf) return 1; + if (!oldmessage) + return 1; // don't filter OTR messages being sent (OTR messages should only happen *after* the otrl_message_sending call below) - if(strncmp(oldmessage_utf, "?OTR", 4) == 0) { + if(strncmp(oldmessage, "?OTR", 4) == 0) { DEBUGOUT_T("OTR message without PREF_BYPASS_OTR\n"); - if (!(ccs->wParam & PREF_UTF)) - mir_free(oldmessage_utf); return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } char *tmpencode = NULL; ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact); if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) { - tmpencode = encode_html_entities_utf8(oldmessage_utf); - if (tmpencode != NULL) { - if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf); - oldmessage_utf = tmpencode; - } + tmpencode = encode_html_entities_utf8(oldmessage); + if (tmpencode != NULL) + oldmessage = tmpencode; } char *newmessage = NULL; char *username = contact_get_id(ccs->hContact); - gcry_error_t err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact, proto, proto, username, OTRL_INSTAG_BEST, oldmessage_utf, NULL, &newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL, add_appdata, (void*)ccs->hContact); - if (tmpencode!= NULL || !(ccs->wParam & PREF_UTF)) - mir_free(oldmessage_utf); + gcry_error_t err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact, proto, proto, username, OTRL_INSTAG_BEST, oldmessage, NULL, &newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL, add_appdata, (void*)ccs->hContact); mir_free(username); if (err) { /* Be *sure* not to send out plaintext */ @@ -66,35 +48,30 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ ShowError(TranslateT(LANG_ENCRYPTION_ERROR)); otrl_message_free(newmessage); return 1; - } else if (newmessage) { - if(!newmessage[0]){ - otrl_message_free(newmessage); - return 1; // skip empty messages (OTR might prevent us sending unencrypted messages by replacing them with empty ones) - } - WPARAM oldflags = ccs->wParam; - if(ccs->wParam & (PREF_UTF|PREF_UNICODE)) { - ccs->lParam = (LPARAM)newmessage; - ccs->wParam &= ~PREF_UNICODE; - ccs->wParam |= PREF_UTF; - } else { - mir_utf8decode(newmessage, NULL); - ccs->lParam = (LPARAM)newmessage; - } - INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); - - DEBUGOUTA("OTR - sending raw message: '"); - DEBUGOUTA((const char*)ccs->lParam); - DEBUGOUTA("'\n"); + } + + if (newmessage == NULL) + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + if(!newmessage[0]){ otrl_message_free(newmessage); - - // reset to original values - ccs->lParam = (LPARAM)oldmessage; - ccs->wParam = oldflags; - return ret; + return 1; // skip empty messages (OTR might prevent us sending unencrypted messages by replacing them with empty ones) } - return CallService(MS_PROTO_CHAINSEND, wParam, lParam); -} + WPARAM oldflags = ccs->wParam; + ccs->lParam = (LPARAM)newmessage; + INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + DEBUGOUTA("OTR - sending raw message: '"); + DEBUGOUTA((const char*)ccs->lParam); + DEBUGOUTA("'\n"); + otrl_message_free(newmessage); + + // reset to original values + ccs->lParam = (LPARAM)oldmessage; + ccs->wParam = oldflags; + return ret; +} INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) { @@ -116,17 +93,9 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) return CallService(MS_PROTO_CHAINRECV, wParam, lParam); char *oldmessage = pre->szMessage; - char *oldmessage_utf = NULL; // convert oldmessage to utf-8 - if(pre->flags & PREF_UTF) { - oldmessage_utf = oldmessage; - } else if(pre->flags & PREF_UNICODE) { - oldmessage_utf = mir_utf8encodeW((wchar_t*)(&oldmessage[strlen(oldmessage)+1])); - } else { - oldmessage_utf = mir_utf8encode(oldmessage); - } - if (!oldmessage_utf) return 1; - + if (!oldmessage) + return 1; ConnContext* context=NULL; char *uname = contact_get_id(ccs->hContact); @@ -135,12 +104,9 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) lib_cs_lock(); int ignore_msg = otrl_message_receiving(otr_user_state, &ops, (void*)ccs->hContact, - proto, proto, uname, oldmessage_utf, + proto, proto, uname, oldmessage, &newmessage, &tlvs, &context, add_appdata, (void*)ccs->hContact); mir_free(uname); - - if ( !(pre->flags & PREF_UTF)) - mir_free(oldmessage_utf); OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv && !Miranda_Terminated()) { @@ -156,38 +122,36 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) if (newmessage) otrl_message_free(newmessage); return 1; // discard internal protocol messages - } else if (newmessage) { - DWORD oldflags = pre->flags; - pre->flags &= ~PREF_UNICODE; - pre->flags |= PREF_UTF; // just use UTF, so we do not have to recode the message + } + if (newmessage == NULL) + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); + + DWORD oldflags = pre->flags; - typedef void (*msg_free_t)(void*); - msg_free_t msg_free = (msg_free_t)otrl_message_free; - if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) { - char* tmp = striphtml(newmessage); - msg_free(newmessage); - newmessage = tmp; - msg_free = mir_free; - } - if (options.prefix_messages) { - size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char); - char* tmp = (char*)mir_alloc( len ); - strcpy(tmp, options.prefix); - strcat(tmp, newmessage); - msg_free(newmessage); - newmessage = tmp; - msg_free = mir_free; - } - pre->szMessage = newmessage; - BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); -/// @todo (White-Tiger#1#03/23/15): why are we doing this? - pre->flags = oldflags; - pre->szMessage = oldmessage; + typedef void (*msg_free_t)(void*); + msg_free_t msg_free = (msg_free_t)otrl_message_free; + if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) { + char* tmp = striphtml(newmessage); msg_free(newmessage); - return ret; + newmessage = tmp; + msg_free = mir_free; } - return CallService(MS_PROTO_CHAINRECV, wParam, lParam); - + if (options.prefix_messages) { + size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char); + char* tmp = (char*)mir_alloc( len ); + strcpy(tmp, options.prefix); + strcat(tmp, newmessage); + msg_free(newmessage); + newmessage = tmp; + msg_free = mir_free; + } + pre->szMessage = newmessage; + BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam); +/// @todo (White-Tiger#1#03/23/15): why are we doing this? + pre->flags = oldflags; + pre->szMessage = oldmessage; + msg_free(newmessage); + return ret; } /* Abort the SMP protocol. Used when malformed or unexpected messages diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 2cb11f610f..997abd82e6 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -321,7 +321,7 @@ void ShowMessageInline(const MCONTACT hContact, const TCHAR *msg) { pre.timestamp = time(0); char *utf = mir_utf8encodeT(buff); pre.szMessage = utf; - pre.flags = PREF_UTF|PREF_BYPASS_OTR; + pre.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, &pre); mir_free(utf); @@ -334,7 +334,7 @@ void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) { PROTORECVEVENT pre = {0}; pre.timestamp = time(0); pre.szMessage = buff; - pre.flags = PREF_UTF|PREF_BYPASS_OTR; + pre.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, &pre); } diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 4596306b56..7774c21448 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -629,27 +629,6 @@ void CAppletManager::HandleEvent(CEvent *pEvent) } } -bool CAppletManager::IsUtfSendAvailable(MCONTACT hContact) { - char* szProto = GetContactProto(hContact); - if ( szProto == NULL ) - return FALSE; - - return ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF ) ? TRUE : FALSE; -} - -//************************************************************************ -// returns the contacts message service name -//************************************************************************ -char *CAppletManager::GetMessageServiceName(MCONTACT hContact,bool bIsUnicode) -{ - char *szProto = GetContactProto(hContact); - - if(szProto == NULL) - return NULL; - - return PSS_MESSAGE; -} - //************************************************************************ // updates all pending message jobs //************************************************************************ @@ -710,17 +689,13 @@ void CAppletManager::FinishMessageJob(SMessageJob *pJob) DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; - dbei.flags = DBEF_SENT; + dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = szProto; dbei.timestamp = time(NULL); // Check if protocoll is valid if(dbei.szModule == NULL) return; - if(pJob->dwFlags & PREF_UTF) { - dbei.flags |= DBEF_UTF; - } - dbei.cbBlob = pJob->iBufferSize; dbei.pBlob = (PBYTE) pJob->pcBuffer; @@ -834,43 +809,16 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact,tstring strMessage } else { - DWORD pref = 0; - bool bIsUnicode = false; - if(CAppletManager::IsUtfSendAvailable(pJob->hContact)) { - pref = PREF_UTF; - char* szMsgUtf = NULL; - szMsgUtf = mir_utf8encodeW( strMessage.c_str()); - - pJob->iBufferSize = (int)strlen(szMsgUtf)+1; - pJob->pcBuffer = (char *)malloc(pJob->iBufferSize); - pJob->dwFlags = PREF_UTF; - - memcpy(pJob->pcBuffer,szMsgUtf,pJob->iBufferSize); - mir_free(szMsgUtf); - } else { - bIsUnicode = !IsUnicodeAscii(strMessage.c_str(),mir_tstrlen(strMessage.c_str())); - if(bIsUnicode) { - pref = PREF_UNICODE; - pJob->iBufferSize = bufSize * (sizeof(TCHAR) + 1); - } else { - pJob->iBufferSize = bufSize; - } - pJob->pcBuffer = (char *)malloc(pJob->iBufferSize); - memcpy(pJob->pcBuffer,strAscii.c_str(),bufSize); + char* szMsgUtf = mir_utf8encodeW(strMessage.c_str()); - if(bIsUnicode) { - memcpy(&pJob->pcBuffer[bufSize],strMessage.c_str(),bufSize*sizeof(TCHAR)); - } - } - char *szService = CAppletManager::GetMessageServiceName(pJob->hContact,bIsUnicode); + pJob->iBufferSize = (int)strlen(szMsgUtf)+1; + pJob->pcBuffer = (char *)malloc(pJob->iBufferSize); + pJob->dwFlags = 0; - if(szService == NULL) - { - free(pJob->pcBuffer); - pJob->pcBuffer = NULL; - return NULL; - } - pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, szService , pref, (LPARAM)pJob->pcBuffer ); + memcpy(pJob->pcBuffer,szMsgUtf,pJob->iBufferSize); + mir_free(szMsgUtf); + + pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer ); CAppletManager::GetInstance()->AddMessageJob(pJob); } diff --git a/plugins/MirandaG15/src/CAppletManager.h b/plugins/MirandaG15/src/CAppletManager.h index 5af6058273..2e70f906ba 100644 --- a/plugins/MirandaG15/src/CAppletManager.h +++ b/plugins/MirandaG15/src/CAppletManager.h @@ -83,9 +83,6 @@ public: // sends typing notifications to the specified contact
static void SendTypingNotification(MCONTACT hContact,bool bEnable);
- // returns the contacts message service name
- static char *GetMessageServiceName(MCONTACT hContact,bool bIsUnicode);
- static bool IsUtfSendAvailable(MCONTACT hContact);
// returns a formatted timestamp string
static tstring GetFormattedTimestamp(tm *time);
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 61a45f0af6..94b5eb018f 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -58,11 +58,9 @@ void __cdecl AutoreplyDelayThread(void *_ad) return;
}
- int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char)+sizeof(WCHAR));
- PBYTE pBuf = (PBYTE)_alloca(ReplyLen);
- memcpy(pBuf, _T2A(ad->Reply), ad->Reply.GetLen() + 1);
- memcpy(pBuf + ad->Reply.GetLen() + 1, ad->Reply, (ad->Reply.GetLen() + 1) * sizeof(WCHAR));
- CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UNICODE, (LPARAM)pBuf);
+ ptrA pszReply(mir_utf8encodeT(ad->Reply));
+ int ReplyLen = (int)mir_strlen(pszReply);
+ CallContactService(ad->hContact, PSS_MESSAGE, 0, (LPARAM)pszReply);
if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY)) { // store in the history
DBEVENTINFO dbeo = { 0 };
@@ -73,7 +71,7 @@ void __cdecl AutoreplyDelayThread(void *_ad) dbeo.timestamp = time(NULL);
dbeo.cbBlob = ReplyLen;
- dbeo.pBlob = pBuf;
+ dbeo.pBlob = (PBYTE)(char*)pszReply;
SleepEx(1000, true); // delay before sending the reply, as we need it to be later than the message we're replying to (without this delay, srmm puts the messages in a wrong order)
db_event_add(ad->hContact, &dbeo);
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 27d6258d50..70a4b0c450 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -150,7 +150,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); return; @@ -179,7 +179,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags { BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); break; @@ -217,7 +217,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); return; @@ -236,7 +236,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); return; @@ -267,7 +267,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); @@ -304,7 +304,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); @@ -524,7 +524,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); string str = "-----PGP KEY RESPONSE-----"; str.append(tmp); - CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)str.c_str()); + CallContactService(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)str.c_str()); if(enc_state) db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); } @@ -540,7 +540,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) ICQ_CUSTOMCAP cap = {0}; strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps)); if(ProtoCallService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) { - CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----"); return 0; } } @@ -586,9 +586,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) { bool isansi = false; - DWORD dbflags = 0; - if((flags & PREF_UTF) == PREF_UTF) - dbflags |= DBEF_UTF; + DWORD dbflags = DBEF_UTF; wstring str = toUTF16(msg); if(bStripTags && bAppendTags) { @@ -752,8 +750,6 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) if(bDebugLog) debuglog<<std::string(time_str()+": adding event to contact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+" on send message."); - if(!(flags & PREF_UTF)) - flags |= PREF_UTF; fix_line_term(str); sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)toUTF8(str).c_str())); } @@ -765,16 +761,11 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINSEND, w, l); if(!ccs->lParam) return CallService(MS_PROTO_CHAINSEND, w, l); - char *msg = nullptr; - if((ccs->wParam & PREF_UTF) == PREF_UTF) - msg = mir_strdup((char*)(ccs->lParam)); - else - msg = mir_utf8encode((char*)(ccs->lParam)); + char *msg = (char*)ccs->lParam; if (!msg) { if(bDebugLog) debuglog<<std::string(time_str()+": info: failed to get message data, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); - mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } if(strstr(msg,"-----BEGIN PGP MESSAGE-----")) @@ -791,10 +782,8 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l) { if(bDebugLog) debuglog<<std::string(time_str()+": info: contact not secured, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); - mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } - mir_free(msg); return returnNoError(ccs->hContact); } @@ -850,7 +839,7 @@ int HookSendMsg(WPARAM w, LPARAM l) if( ProtoCallService(proto, PS_ICQ_CHECKCAPABILITY, hContact, (LPARAM)&cap)) { if(bDebugLog) debuglog<<std::string(time_str()+": info(autoexchange, icq): sending key requiest, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))); - CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, (void*)hContact)); //TODO: wait for message @@ -885,7 +874,7 @@ int HookSendMsg(WPARAM w, LPARAM l) { if(bDebugLog) debuglog<<std::string(time_str()+": info(autoexchange, jabber): autoexchange capability found, sending key request, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))); - CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, (void*)hContact)); //mir_free((char*)dbei->pBlob); @@ -905,10 +894,7 @@ int HookSendMsg(WPARAM w, LPARAM l) } if(isContactSecured(hContact) && (dbei->flags & DBEF_SENT)) //aggressive outgoing events filtering { - DWORD flags = 0; - if((dbei->flags & DBEF_UTF) == DBEF_UTF) - flags |= PREF_UTF; - SendMsgSvc_func(hContact, (char*)dbei->pBlob, flags); + SendMsgSvc_func(hContact, (char*)dbei->pBlob, 0); //TODO: handle errors somehow ... if(bAppendTags) { @@ -921,33 +907,6 @@ int HookSendMsg(WPARAM w, LPARAM l) } return 0; -/* bool stop = false; - int count = 0; */ -/* while(!stop) - { - if(count >= 300) - stop = true; - if(!hcontact_data[hContact].msgs_to_pass.empty()) - { - event_processing_mutex.lock(); - std::list<string>::iterator end = hcontact_data[hContact].msgs_to_pass.end(); - for(std::list<string>::iterator i = hcontact_data[hContact].msgs_to_pass.begin(); i != end; ++i) - { - if(!strcmp((*i).c_str(), (char*)dbei->pBlob)) - { - hcontact_data[hContact].msgs_to_pass.erase(i); - if(bDebugLog) - debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+", message is in allowed list"); - event_processing_mutex.unlock(); - return 0; - } - } - event_processing_mutex.unlock(); - } - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - count++; - } */ - //return 1; } if(!isContactSecured(hContact)) { diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 135a4df41f..b4078f24ac 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -178,7 +178,7 @@ INT_PTR SendKey(WPARAM w, LPARAM l) { BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)szMessage); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage); std::string msg = "Public key "; char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, key_id_str.c_str(), ""); if(!keyid[0]) @@ -1325,7 +1325,7 @@ void send_encrypted_msgs_thread(void *param) extern std::list<HANDLE> sent_msgs; for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p) { - sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)p->c_str())); + sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)p->c_str())); HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT)); boost::this_thread::sleep(boost::posix_time::seconds(1)); } diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index 7daad6dc2f..3f2c96b7b5 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -148,10 +148,11 @@ static void XmlToMsg(MCONTACT hContact, CMString &title, CMString &link, CMStrin if (stamp == 0)
stamp = time(NULL);
+ ptrA pszMessage(mir_utf8encodeT(message));
+
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_TCHAR;
recv.timestamp = (DWORD)stamp;
- recv.tszMessage = (TCHAR*)message.c_str();
+ recv.szMessage = pszMessage;
ProtoChainRecvMsg(hContact, &recv);
}
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index acd1430802..574115edcf 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -830,32 +830,15 @@ struct ReplyEditData WNDPROC oldWndProc;
};
-BOOL IsUtfSendAvailable(MCONTACT hContact)
-{
- char* szProto = GetContactProto(hContact);
- if (szProto == NULL) return FALSE;
- // check for MetaContact and get szProto from subcontact
- if (!mir_strcmp(szProto, META_PROTO)) {
- MCONTACT hSubContact = db_mc_getDefault(hContact);
- if (!hSubContact)
- return FALSE;
- szProto = GetContactProto(hSubContact);
- }
- return(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
-void AddMessageToDB(MCONTACT hContact, char *msg, int flag/*bool utf*/)
+void AddMessageToDB(MCONTACT hContact, char *msg)
{
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((flag&PREF_UTF) == PREF_UTF ? DBEF_UTF : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(NULL);
- if (!((flag & PREF_UTF) == PREF_UTF) && (flag & PREF_UNICODE) == PREF_UNICODE)
- dbei.cbBlob = ((int)mir_tstrlen((LPTSTR)msg) + 1)*sizeof(TCHAR);
- else
- dbei.cbBlob = (int)mir_strlen(msg) + 1;
+ dbei.cbBlob = (int)mir_strlen(msg) + 1;
dbei.pBlob = (PBYTE)msg;
db_event_add(hContact, &dbei);
}
@@ -869,33 +852,19 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_KEYDOWN:
switch (wParam) {
case VK_RETURN:
- {
- char *buf = NULL;
- int flag = 0;
TCHAR msg[2048];
-
GetWindowText(hwnd, msg, SIZEOF(msg));
-
if (wcslen(msg) == 0) {
DestroyWindow(hwnd);
return 0;
}
- // we have unicode message, check if it is possible and reasonable to send it as unicode
- if (IsUtfSendAvailable(dat->hContact)) {
- buf = mir_utf8encodeT(msg);
- flag = PREF_UTF;
- }
- else {
- buf = mir_t2a(msg);
- flag = 0;
- }
- CallContactService(dat->hContact, PSS_MESSAGE, flag, (LPARAM)buf);
- AddMessageToDB(dat->hContact, buf, flag);
- mir_free(buf);
- }
- DestroyWindow(hwnd);
- return 0;
+ {
+ ptrA buf(mir_utf8encodeT(msg));
+ CallContactService(dat->hContact, PSS_MESSAGE, 0, (LPARAM)buf);
+ AddMessageToDB(dat->hContact, buf);
+ }
+ // fall through
case VK_ESCAPE:
DestroyWindow(hwnd);
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 8bf0853259..db0ba35a56 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -145,14 +145,10 @@ static int ackevent(WPARAM, LPARAM lParam) DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((item->flags & PREF_RTL) ? DBEF_RTL : 0);
- if (item->flags & PREF_UTF)
- dbei.flags |= DBEF_UTF;
+ dbei.flags = DBEF_UTF | DBEF_SENT | ((item->flags & PREF_RTL) ? DBEF_RTL : 0);
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(NULL);
dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1;
- if (!(item->flags & PREF_UTF))
- dbei.cbBlob *= sizeof(TCHAR) + 1;
dbei.pBlob = (PBYTE)item->sendBuffer;
MessageWindowEvent evt = { sizeof(evt), (int)item->hSendId, hContact, &dbei };
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index acb56dad6c..586f449cea 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -149,15 +149,6 @@ void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type) NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
}
-static BOOL IsUtfSendAvailable(MCONTACT hContact)
-{
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
int RTL_Detect(WCHAR *pszwText)
{
size_t iLen = mir_wstrlen(pszwText);
@@ -1188,7 +1179,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
dat->flags ^= SMF_RTL;
- if (dat->flags&SMF_RTL) {
+ if (dat->flags & SMF_RTL) {
pf2.wEffects = PFE_RTLPARA;
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
@@ -1480,31 +1471,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case DM_SENDMESSAGE:
if (lParam) {
MessageSendQueueItem *msi = (MessageSendQueueItem *)lParam;
+ SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
+
MessageSendQueueItem *item = CreateSendQueueItem(hwndDlg);
item->hContact = dat->hContact;
item->proto = mir_strdup(dat->szProto);
item->flags = msi->flags;
item->codepage = dat->codePage;
- if (IsUtfSendAvailable(dat->hContact)) {
- char *szMsgUtf = mir_utf8encodeW((TCHAR*)&msi->sendBuffer[strlen(msi->sendBuffer) + 1]);
- item->flags &= ~PREF_UNICODE;
- if (!szMsgUtf)
- break;
-
- if (*szMsgUtf == 0) {
- mir_free(szMsgUtf);
- break;
- }
- item->sendBufferSize = (int)strlen(szMsgUtf) + 1;
- item->sendBuffer = szMsgUtf;
- item->flags |= PREF_UTF;
- }
- else {
- item->sendBufferSize = msi->sendBufferSize;
- item->sendBuffer = (char*)mir_alloc(msi->sendBufferSize);
- memcpy(item->sendBuffer, msi->sendBuffer, msi->sendBufferSize);
- }
- SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
+ item->sendBufferSize = msi->sendBufferSize;
+ item->sendBuffer = mir_strndup(msi->sendBuffer, msi->sendBufferSize);
SendSendQueueItem(item);
}
break;
@@ -1627,48 +1602,40 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
if (dat->hContact != NULL) {
- int ansiBufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->codePage, TRUE) + 1;
- int bufSize = ansiBufSize + GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
-
memset(&pf2, 0, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
- ptrA szSendBuffer((char*)mir_alloc(bufSize));
+ int bufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
+ ptrT ptszUnicode((TCHAR*)mir_alloc(bufSize * sizeof(TCHAR)));
MessageSendQueueItem msi = { 0 };
- msi.flags = PREF_TCHAR;
if (pf2.wEffects & PFE_RTLPARA)
msi.flags |= PREF_RTL;
- msi.sendBufferSize = bufSize;
- msi.sendBuffer = szSendBuffer;
GETTEXTEX gt = { 0 };
gt.flags = GT_USECRLF;
- gt.cb = ansiBufSize;
- gt.codepage = dat->codePage;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)>, (LPARAM)msi.sendBuffer);
- gt.cb = bufSize - ansiBufSize;
+ gt.cb = bufSize;
gt.codepage = 1200;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)>, (LPARAM)&msi.sendBuffer[ansiBufSize]);
- if (RTL_Detect((wchar_t*)&msi.sendBuffer[ansiBufSize]))
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)>, ptszUnicode);
+ if (RTL_Detect(ptszUnicode))
msi.flags |= PREF_RTL;
- if (msi.sendBuffer[0] == 0)
+ msi.sendBuffer = mir_utf8encodeT(ptszUnicode);
+ msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer);
+ if (msi.sendBufferSize == 0)
break;
/* Store messaging history */
- char *msgText = GetRichTextEncoded(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->codePage);
TCmdList *cmdListNew = tcmdlist_last(dat->cmdList);
while (cmdListNew != NULL && cmdListNew->temporary) {
dat->cmdList = tcmdlist_remove(dat->cmdList, cmdListNew);
cmdListNew = tcmdlist_last(dat->cmdList);
}
- if (msgText != NULL) {
- dat->cmdList = tcmdlist_append(dat->cmdList, rtrim(msgText), 20, FALSE);
- mir_free(msgText);
- }
+ if (msi.sendBuffer != NULL)
+ dat->cmdList = tcmdlist_append(dat->cmdList, rtrim(msi.sendBuffer), 20, FALSE);
+
dat->cmdListCurrent = NULL;
if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp index 51c6dbb972..49bc01553e 100644 --- a/plugins/Scriver/src/sendqueue.cpp +++ b/plugins/Scriver/src/sendqueue.cpp @@ -28,17 +28,7 @@ static mir_cs queueMutex; TCHAR* GetSendBufferMsg(MessageSendQueueItem *item)
{
- TCHAR *szMsg = NULL;
- size_t len = strlen(item->sendBuffer);
-
- if (item->flags & PREF_UTF)
- szMsg = mir_utf8decodeW(item->sendBuffer);
- else {
- szMsg = (TCHAR*)mir_alloc(item->sendBufferSize - len - 1);
- memcpy(szMsg, item->sendBuffer + len + 1, item->sendBufferSize - len - 1);
- }
-
- return szMsg;
+ return mir_utf8decodeW(item->sendBuffer);
}
MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender)
diff --git a/plugins/SecureIM/secureim_10.vcxproj b/plugins/SecureIM/secureim_10.vcxproj index 156bf385bd..12bf242797 100644 --- a/plugins/SecureIM/secureim_10.vcxproj +++ b/plugins/SecureIM/secureim_10.vcxproj @@ -200,7 +200,6 @@ <ClInclude Include="src\options.h" />
<ClInclude Include="src\popupOptions.h" />
<ClInclude Include="src\resource.h" />
- <ClInclude Include="src\rtfconv.h" />
<ClInclude Include="src\secureim.h" />
<ClInclude Include="src\splitmsg.h" />
<ClInclude Include="src\svcs_clist.h" />
@@ -230,7 +229,6 @@ <ClCompile Include="src\mmi.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\popupOptions.cpp" />
- <ClCompile Include="src\rtfconv.cpp" />
<ClCompile Include="src\splitmsg.cpp" />
<ClCompile Include="src\commonheaders.cpp" />
<ClCompile Include="src\svcs_clist.cpp" />
diff --git a/plugins/SecureIM/secureim_10.vcxproj.filters b/plugins/SecureIM/secureim_10.vcxproj.filters index ececb6efdf..51fcf274df 100644 --- a/plugins/SecureIM/secureim_10.vcxproj.filters +++ b/plugins/SecureIM/secureim_10.vcxproj.filters @@ -72,9 +72,6 @@ <ClCompile Include="src\popupOptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\rtfconv.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\splitmsg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -137,9 +134,6 @@ <ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\rtfconv.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\secureim.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/SecureIM/secureim_12.vcxproj b/plugins/SecureIM/secureim_12.vcxproj index e158f71170..f1a8922d1f 100644 --- a/plugins/SecureIM/secureim_12.vcxproj +++ b/plugins/SecureIM/secureim_12.vcxproj @@ -203,7 +203,6 @@ <ClInclude Include="src\options.h" />
<ClInclude Include="src\popupOptions.h" />
<ClInclude Include="src\resource.h" />
- <ClInclude Include="src\rtfconv.h" />
<ClInclude Include="src\secureim.h" />
<ClInclude Include="src\splitmsg.h" />
<ClInclude Include="src\svcs_clist.h" />
@@ -233,7 +232,6 @@ <ClCompile Include="src\mmi.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\popupOptions.cpp" />
- <ClCompile Include="src\rtfconv.cpp" />
<ClCompile Include="src\splitmsg.cpp" />
<ClCompile Include="src\commonheaders.cpp" />
<ClCompile Include="src\svcs_clist.cpp" />
diff --git a/plugins/SecureIM/secureim_12.vcxproj.filters b/plugins/SecureIM/secureim_12.vcxproj.filters index ececb6efdf..51fcf274df 100644 --- a/plugins/SecureIM/secureim_12.vcxproj.filters +++ b/plugins/SecureIM/secureim_12.vcxproj.filters @@ -72,9 +72,6 @@ <ClCompile Include="src\popupOptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\rtfconv.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\splitmsg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -137,9 +134,6 @@ <ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\rtfconv.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\secureim.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index 9d3262643f..f416e46339 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -48,7 +48,6 @@ #include "options.h"
#include "popupoptions.h"
#include "loadicons.h"
-#include "rtfconv.h"
#include "cryptopp.h"
#include "loadlib.h"
#include "images.h"
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index d7c57ea17a..a40b6c4974 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -121,18 +121,7 @@ LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) LPSTR encodeMsg(pUinKey ptr, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA *)lParam;
- LPSTR szNewMsg = NULL;
- LPSTR szOldMsg = (LPSTR)pccsd->lParam;
-
- if (pccsd->wParam & PREF_UTF)
- szNewMsg = encrypt(ptr, cpp_encodeU(ptr->cntx, szOldMsg));
- else if (pccsd->wParam & PREF_UNICODE)
- szNewMsg = encrypt(ptr, cpp_encodeW(ptr->cntx, (LPWSTR)(szOldMsg + strlen(szOldMsg) + 1)));
- else
- szNewMsg = encrypt(ptr, cpp_encodeA(ptr->cntx, szOldMsg));
-
- pccsd->wParam &= ~PREF_UNICODE;
- return szNewMsg;
+ return encrypt(ptr, cpp_encodeU(ptr->cntx, (LPSTR)pccsd->lParam));
}
@@ -143,7 +132,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
LPSTR szNewMsg = NULL;
- LPSTR szOldMsg = (ppre->flags&PREF_UTF) ? cpp_decodeU(ptr->cntx, szEncMsg) : cpp_decode(ptr->cntx, szEncMsg);
+ LPSTR szOldMsg = cpp_decodeU(ptr->cntx, szEncMsg);
if (szOldMsg == NULL) {
ptr->decoded = false;
@@ -159,23 +148,12 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) szNewMsg = mir_strdup(Translate(sim101));
break;
}
- ppre->flags &= ~(PREF_UNICODE | PREF_UTF);
- pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF);
}
else {
ptr->decoded = true;
- if (ppre->flags & PREF_UTF) {
- int olen = (int)strlen(szOldMsg) + 1;
- szNewMsg = (LPSTR)mir_alloc(olen);
- memcpy(szNewMsg, szOldMsg, olen);
- }
- else {
- int olen = ((int)strlen(szOldMsg) + 1)*(sizeof(WCHAR) + 1);
- szNewMsg = (LPSTR)mir_alloc(olen);
- memcpy(szNewMsg, szOldMsg, olen);
- ppre->flags |= PREF_UNICODE;
- pccsd->wParam |= PREF_UNICODE;
- }
+ int olen = (int)strlen(szOldMsg) + 1;
+ szNewMsg = (LPSTR)mir_alloc(olen);
+ memcpy(szNewMsg, szOldMsg, olen);
}
ppre->szMessage = szNewMsg;
return szNewMsg;
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 73812cad0a..9137f9b592 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -186,15 +186,7 @@ void addMsg2Queue(pUinKey ptr, WPARAM wParam, LPSTR szMsg) ptrMessage->wParam = wParam;
ptrMessage->nextMessage = NULL;
-
- if (wParam & PREF_UNICODE) {
- int slen = (int)strlen(szMsg) + 1;
- int wlen = (int)wcslen((wchar_t *)(szMsg + slen)) + 1;
- ptrMessage->Message = (LPSTR)mir_alloc(slen + wlen*sizeof(WCHAR));
- memcpy(ptrMessage->Message, szMsg, slen + wlen*sizeof(WCHAR));
- }
- else ptrMessage->Message = mir_strdup(szMsg);
-
+ ptrMessage->Message = mir_strdup(szMsg);
}
void getContactNameA(MCONTACT hContact, LPSTR szName)
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 773dcccd0e..470ffa12de 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -294,7 +294,6 @@ static int onShutdown(WPARAM, LPARAM) DestroyHookableEvent(g_hEvent[1]);
freeContactList();
- free_rtfconv();
DeinitNetlib();
return 0;
@@ -344,8 +343,6 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) return 1;
}
- load_rtfconv();
-
// register plugin module
PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
pd.szName = (char*)MODULENAME;
diff --git a/plugins/SecureIM/src/mmi.cpp b/plugins/SecureIM/src/mmi.cpp index 45361fd5ad..e75a076472 100644 --- a/plugins/SecureIM/src/mmi.cpp +++ b/plugins/SecureIM/src/mmi.cpp @@ -105,22 +105,11 @@ void __fastcall safe_delete(void** p) // преобразуем текст из чистого UTF8 в формат миранды
LPSTR utf8_to_miranda(LPCSTR szUtfMsg, DWORD& flags)
{
- flags &= ~PREF_UNICODE; flags |= PREF_UTF;
return mir_strdup(szUtfMsg);
}
// преобразуем текст из формата миранды в чистый UTF8
LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags)
{
- LPSTR szNewMsg;
- if (flags & PREF_UTF)
- szNewMsg = (LPSTR)szMirMsg;
- else if (flags & PREF_UNICODE)
- szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg + strlen(szMirMsg) + 1));
- else {
- LPWSTR wszMirMsg = mir_a2u(szMirMsg);
- szNewMsg = exp->utf8encode(wszMirMsg);
- mir_free(wszMirMsg);
- }
- return mir_strdup(szNewMsg);
+ return mir_strdup(szMirMsg);
}
diff --git a/plugins/SecureIM/src/rtfconv.cpp b/plugins/SecureIM/src/rtfconv.cpp deleted file mode 100644 index d76b316b22..0000000000 --- a/plugins/SecureIM/src/rtfconv.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "commonheaders.h"
-
-HINSTANCE hRtfconv = NULL;
-RTFCONVSTRING pRtfconvString = NULL;
-
-BOOL load_rtfconv()
-{
- hRtfconv = LoadLibrary(_T("rtfconv.dll"));
- if (hRtfconv == NULL) {
- hRtfconv = LoadLibrary(_T("plugins\\rtfconv.dll"));
- if (hRtfconv == NULL)
- return FALSE;
- }
-
- pRtfconvString = (RTFCONVSTRING)GetProcAddress(hRtfconv, "RtfconvString");
- if (pRtfconvString == NULL) {
- FreeLibrary(hRtfconv);
- return FALSE;
- }
-
- return TRUE;
-}
-
-void free_rtfconv()
-{
- if (hRtfconv)
- FreeLibrary(hRtfconv);
- pRtfconvString = NULL;
- hRtfconv = NULL;
-}
-
-void rtfconvA(LPCSTR rtf, LPWSTR plain)
-{
- pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf) + 1)*sizeof(WCHAR));
-}
-
-void rtfconvW(LPCWSTR rtf, LPWSTR plain)
-{
- pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf) + 1)*sizeof(WCHAR));
-}
diff --git a/plugins/SecureIM/src/rtfconv.h b/plugins/SecureIM/src/rtfconv.h deleted file mode 100644 index eed541a85e..0000000000 --- a/plugins/SecureIM/src/rtfconv.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __RTFCONV_H__
-#define __RTFCONV_H__
-
-#ifndef _INTPTR_T_DEFINED
-#define intptr_t int
-#endif
-
-#define CONVMODE_USE_SYSTEM_TABLE 0x800000 /* Use OS's table only */
-
-typedef intptr_t (WINAPI *RTFCONVSTRING)(const void *pSrcBuffer, void *pDstBuffer,
- int nSrcCodePage, int nDstCodePage, unsigned long dwFlags, size_t nMaxLen);
-
-extern RTFCONVSTRING pRtfconvString;
-
-BOOL load_rtfconv ();
-void free_rtfconv ();
-void rtfconvA(LPCSTR rtf, LPWSTR plain);
-void rtfconvW(LPCWSTR rtf, LPWSTR plain);
-
-#endif
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index 0ebc1de9ed..fb39f770d2 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -55,32 +55,6 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onRecvMsg: %s", szEncMsg);
- // cut rtf tags
- if (pRtfconvString && memcmp(szEncMsg, "{\\rtf1", 6) == 0) {
- SAFE_FREE(szUnrtfMsg);
- int len = (int)strlen(szEncMsg) + 1;
- LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR));
- if (ppre->flags & PREF_UNICODE)
- rtfconvW((LPWSTR)(szEncMsg + len), szTemp);
- else
- rtfconvA(szEncMsg, szTemp);
- len = (int)wcslen(szTemp) - 1;
- while (len) {
- if (szTemp[len] == 0x0D || szTemp[len] == 0x0A)
- szTemp[len] = 0;
- else
- break;
- len--;
- }
- len = (int)wcslen(&szTemp[1]) + 1;
- szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR) + 1));
- WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR) + 1), NULL, NULL);
- memcpy(szUnrtfMsg + len, &szTemp[1], len*sizeof(WCHAR));
- ppre->szMessage = szEncMsg = szUnrtfMsg;
- ppre->flags |= PREF_UNICODE;
- mir_free(szTemp);
- }
-
int ssig = getSecureSig(ppre->szMessage, &szEncMsg);
bool bSecured = (isContactSecured(pccsd->hContact)&SECURED) != 0;
bool bPGP = isContactPGP(pccsd->hContact);
@@ -104,7 +78,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ssig == SiG_NONE && !ptr->msgSplitted) {
Sent_NetLog("onRecvMsg: non-secure message");
- ptrA szPlainMsg((ppre->flags & PREF_UNICODE) ? m_awstrcat(Translate(sim402), szEncMsg) : m_aastrcat(Translate(sim402), szEncMsg));
+ ptrA szPlainMsg(m_aastrcat(Translate(sim402), szEncMsg));
ppre->szMessage = szPlainMsg;
pccsd->wParam |= PREF_SIMNOMETA;
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
@@ -178,8 +152,6 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (!szOldMsg) { // error while decrypting message, send error
SAFE_FREE(ptr->msgSplitted);
- ppre->flags &= ~(PREF_UNICODE | PREF_UTF);
- pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF);
ppre->szMessage = Translate(sim401);
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
}
@@ -761,7 +733,6 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) ptrA keyToSend(InitKeyA(ptr, 0)); // calculate public and private key & fill KeyA
Sent_NetLog("Sending KEY3: %s", keyToSend);
- pccsd->wParam &= ~PREF_UNICODE;
pccsd->wParam |= PREF_METANODB;
pccsd->lParam = (LPARAM)keyToSend;
pccsd->szProtoService = PSS_MESSAGE;
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index b7e8cd0b6d..aa1e5bdfb9 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -230,7 +230,7 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) }else
ptszTemp = Utils_ReplaceVarsT(ptszTemp2);
char* pszUtf = mir_utf8encodeT(ptszTemp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)pszUtf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf);
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp index dc7fe34e84..4ce453a710 100644 --- a/plugins/Spamotron/src/spamotron.cpp +++ b/plugins/Spamotron/src/spamotron.cpp @@ -56,7 +56,6 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) POPUPDATAT ppdp = {0};
DBTIMETOSTRING tts = {0};
char protoOption[256] = {0};
- char *response, *tmp, *challenge;
int buflen = MAX_BUFFER_LENGTH;
TCHAR buf[MAX_BUFFER_LENGTH];
TCHAR *message = NULL, *challengeW = NULL, *tmpW = NULL;
@@ -174,11 +173,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Delete");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess) && (_getCOptB(hContact, "MsgSent", 0))) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
return 0;
}
@@ -243,11 +239,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "Delete");
db_unset(hContact, "CList", "ResponseNum");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess)) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
_notify(hContact, POPUP_APPROVED, TranslateT("Contact %s approved."), NULL);
@@ -368,76 +361,58 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) challengeW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
tmpW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
- switch (_getOptB("Mode", defaultMode))
- {
- case SPAMOTRON_MODE_PLAIN:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- ReplaceVars(challengeW, maxmsglen);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
- break;
+ switch (_getOptB("Mode", defaultMode)) {
+ case SPAMOTRON_MODE_PLAIN:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ ReplaceVars(challengeW, maxmsglen);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
+ break;
- case SPAMOTRON_MODE_ROTATE:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1)) {
- _setCOptD(hContact, "ResponseNum", -1);
- }
- _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
-
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_RANDOM:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- srand(time(NULL));
- _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_MATH:
- a = (rand() % 10) + 1;
- b = (rand() % 10) + 1;
- mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
- else
- _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
- ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
- _setCOptD(hContact, "ResponseMath", a + b);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
- break;
+ case SPAMOTRON_MODE_ROTATE:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1))
+ _setCOptD(hContact, "ResponseNum", -1);
+
+ _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_RANDOM:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ srand(time(NULL));
+ _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_MATH:
+ a = (rand() % 10) + 1;
+ b = (rand() % 10) + 1;
+ mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
+ else
+ _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
+ ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
+ _setCOptD(hContact, "ResponseMath", a + b);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
+ break;
}
free(challengeW);
free(tmpW);
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp index bcb22c885d..1e6da982db 100755 --- a/plugins/StopSpamMod/src/stopspam.cpp +++ b/plugins/StopSpamMod/src/stopspam.cpp @@ -66,9 +66,8 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, hContact, hDbEvent) msg = 0; //is it useful ? } if(msg) { - char * buff=mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str()); - CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM) buff); - mir_free(buff); + ptrA buff(mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str())); + CallContactService(hcntct, PSS_MESSAGE, 0, (LPARAM)buff); } return 1; } @@ -197,9 +196,9 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) if((Stricmp(_T("ICQ"),prot.c_str()))||(!gbAutoReqAuth)) { char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str()); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf); mir_free(buf); - }; + } // Note: For ANSI can be not work if(!Stricmp(_T("ICQ"),prot.c_str())){ // grand auth. @@ -298,9 +297,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) else q += variables_parse(gbQuestion, hContact); - char * buf=mir_utf8encodeW(q.c_str()); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); - mir_free(buf); + CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeW(q.c_str()))); // increment question count DWORD questCount = db_get_dw(hContact, pluginName, "QuestionCount", 0); diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index 58845a2ce1..5e51915364 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -27,7 +27,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) if (db_get_b(hcntct, "CList", "NotOnList", 0) && !db_get_b(hcntct, pluginName, answeredSetting, 0) && !IsExistMyMessage(hcntct)) {
if (!plSets->HandleAuthReq.Get()) {
char *buf = mir_utf8encodeW(variables_parse(plSets->AuthRepl.Get(), hcntct).c_str());
- CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hcntct, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
}
@@ -120,7 +120,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) // send congratulation
char * buf = mir_utf8encodeW(variables_parse(plSets->Congratulation.Get(), hContact).c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
// process the event
@@ -140,7 +140,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) char * buf = mir_utf8encodeW(q.c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index f5fa1e308f..83c7f532ee 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -70,7 +70,6 @@ void TSAPI HandleMenuEntryFromhContact(MCONTACT iSelection); * gneric msgwindow functions(creation, container management etc.)
*/
-BOOL TSAPI IsUtfSendAvailable(MCONTACT hContact);
HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, int isSend,
const char *pszInitialText, BOOL bActivateTAb, BOOL bPopupContainer, BOOL bWantPopup, MEVENT hdbEvent);
int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 2367fc9d6c..81ae18d9a8 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -72,15 +72,6 @@ static void _clrMsgFilter(LPARAM lParam) m->wParam = 0;
}
-BOOL TSAPI IsUtfSendAvailable(MCONTACT hContact)
-{
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// show a modified context menu for the richedit control(s)
// @param dat message window data
@@ -2422,8 +2413,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (job->hSendId == 0 && job->hContact == 0)
break;
- job->hSendId = (HANDLE)CallContactService(job->hContact, PSS_MESSAGE,
- (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->szSendBuffer);
+ job->hSendId = (HANDLE)CallContactService(job->hContact, PSS_MESSAGE, job->dwFlags, (LPARAM)job->szSendBuffer);
resent++;
}
@@ -2671,23 +2661,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (decoded.IsEmpty())
break;
- char *utfResult = NULL;
if (final_sendformat)
DoRtfToTags(dat, decoded, SIZEOF(rtfDefColors), rtfDefColors);
decoded.TrimRight();
int bufSize = WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, 0, 0, 0);
- size_t memRequired = 0;
int flags = 0;
- if (!IsUtfSendAvailable(dat->hContact)) {
- flags |= PREF_UNICODE;
- memRequired = bufSize + (mir_wstrlen(decoded) + 1) * sizeof(WCHAR);
- }
- else {
- flags |= PREF_UTF;
- utfResult = mir_utf8encodeT(decoded);
- memRequired = strlen(utfResult) + 1;
- }
+ char *utfResult = mir_utf8encodeT(decoded);
+ size_t memRequired = strlen(utfResult) + 1;
// try to detect RTL
HWND hwndEdit = GetDlgItem(hwndDlg, IDC_MESSAGE);
@@ -2711,15 +2692,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->sendBuffer = (char *)mir_realloc(dat->sendBuffer, memRequired);
dat->iSendBufferSize = memRequired;
}
- if (utfResult) {
- memcpy(dat->sendBuffer, utfResult, memRequired);
- mir_free(utfResult);
- }
- else {
- WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, bufSize, 0, 0);
- if (flags & PREF_UNICODE)
- memcpy(&dat->sendBuffer[bufSize], decoded, (mir_wstrlen(decoded) + 1) * sizeof(WCHAR));
- }
+
+ memcpy(dat->sendBuffer, utfResult, memRequired);
+ mir_free(utfResult);
if (memRequired == 0 || dat->sendBuffer[0] == 0)
break;
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index fddb95208a..f373ca98fa 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -417,12 +417,7 @@ int CSendLater::sendIt(CSendLaterJob *job) job->iSendCount++;
job->hTargetContact = hContact;
job->bCode = CSendLaterJob::JOB_WAITACK;
-
- DWORD dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE;
- if (dwFlags & PREF_UTF)
- job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->sendBuffer);
- else
- job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->pBuf);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)job->sendBuffer);
return 0;
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 98b9932f7f..4e9471f662 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -137,75 +137,6 @@ static int SendChunkA(char *chunk, MCONTACT hContact, char *szSvc, DWORD dwFlags return(CallContactService(hContact, szSvc, dwFlags, (LPARAM)chunk)); } -static void DoSplitSendW(LPVOID param) -{ - SendJob *job = sendQueue->getJobByIndex((int)param); - BOOL fFirstSend = FALSE; - WCHAR *wszSaved, savedChar; - size_t iCur = 0, iSavedCur = 0, i; - BOOL fSplitting = TRUE; - MCONTACT hContact = job->hContact; - DWORD dwFlags = job->dwFlags; - size_t chunkSize = job->chunkSize / 2; - - size_t iLen = mir_strlen(job->szSendBuffer); - WCHAR *wszBegin = (WCHAR*)& job->szSendBuffer[iLen + 1]; - WCHAR *wszTemp = (WCHAR*)mir_alloc(sizeof(WCHAR) * (mir_wstrlen(wszBegin) + 1)); - memcpy(wszTemp, wszBegin, sizeof(WCHAR) * (mir_wstrlen(wszBegin) + 1)); - wszBegin = wszTemp; - - do { - iCur += chunkSize; - if (iCur > iLen) - fSplitting = FALSE; - - // try to "word wrap" the chunks - split on word boundaries (space characters), if possible. - // SPLIT_WORD_CUTOFF = max length of unbreakable words, longer words may be split. - if (fSplitting) { - i = 0; - wszSaved = &wszBegin[iCur]; - iSavedCur = iCur; - while (iCur) { - if (wszBegin[iCur] == (TCHAR)' ') { - wszSaved = &wszBegin[iCur]; - break; - } - if (i == SPLIT_WORD_CUTOFF) { // no space found backwards, restore old split position - iCur = iSavedCur; - wszSaved = &wszBegin[iCur]; - break; - } - i++; - iCur--; - } - savedChar = *wszSaved; - *wszSaved = 0; - int id = SendChunkW(wszTemp, hContact, dwFlags); - if (!fFirstSend) { - job->hSendId = (HANDLE)id; - fFirstSend = TRUE; - PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SPLITSENDACK, (WPARAM)param, 0); - } - *wszSaved = savedChar; - wszTemp = wszSaved; - if (savedChar == (TCHAR)' ') { - wszTemp++; - iCur++; - } - } - else { - int id = SendChunkW(wszTemp, hContact, dwFlags); - if (!fFirstSend) { - job->hSendId = (HANDLE)id; - fFirstSend = TRUE; - PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SPLITSENDACK, (WPARAM)param, 0); - } - } - Sleep(500L); - } while (fSplitting); - mir_free(wszBegin); -} - static void DoSplitSendA(LPVOID param) { SendJob *job = sendQueue->getJobByIndex((int)param); @@ -279,14 +210,7 @@ static void DoSplitSendA(LPVOID param) size_t SendQueue::getSendLength(const int iEntry, int sendMode) { SendJob &p = m_jobs[iEntry]; - if (p.dwFlags & PREF_UNICODE && !(sendMode & SMODE_FORCEANSI)) { - size_t iLen = mir_strlen(p.szSendBuffer); - WCHAR *wszBuf = (WCHAR*)&p.szSendBuffer[iLen + 1]; - char *utf8 = mir_utf8encodeT(wszBuf); - p.iSendLength = mir_strlen(utf8); - mir_free(utf8); - } - else p.iSendLength = mir_strlen(p.szSendBuffer); + p.iSendLength = mir_strlen(p.szSendBuffer); return p.iSendLength; } @@ -365,13 +289,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) m_jobs[iEntry].chunkSize = dat->nMax; DWORD dwOldFlags = m_jobs[iEntry].dwFlags; - if (dat->sendMode & SMODE_FORCEANSI) - m_jobs[iEntry].dwFlags &= ~PREF_UNICODE; - - if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI) - mir_forkthread(DoSplitSendA, (LPVOID)iEntry); - else - mir_forkthread(DoSplitSendW, (LPVOID)iEntry); + mir_forkthread(DoSplitSendA, (LPVOID)iEntry); m_jobs[iEntry].dwFlags = dwOldFlags; } else { @@ -394,8 +312,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) clearJob(iEntry); return 0; } - m_jobs[iEntry].hSendId = (HANDLE)CallContactService(dat->hContact, PSS_MESSAGE, - (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].szSendBuffer); + m_jobs[iEntry].hSendId = (HANDLE)CallContactService(dat->hContact, PSS_MESSAGE, m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].szSendBuffer); if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks ACKDATA ack = { 0 }; @@ -472,13 +389,8 @@ void SendQueue::logError(const TWindowData *dat, int iSendJobIndex, const TCHAR iMsgLen = 0; dbei.pBlob = NULL; } - if (m_jobs[iSendJobIndex].dwFlags & PREF_UTF) - dbei.flags = DBEF_UTF; - if (iSendJobIndex >= 0) { - if (m_jobs[iSendJobIndex].dwFlags & PREF_UNICODE) { - iMsgLen *= 3; - } - } + + dbei.flags = DBEF_UTF; dbei.cbBlob = (int)iMsgLen; dbei.timestamp = time(NULL); dbei.szModule = (char *)szErrMsg; @@ -545,13 +457,8 @@ void SendQueue::recallFailed(const TWindowData *dat, int iEntry) const return; // message area is empty, so we can recall the failed message... - SETTEXTEX stx = { ST_DEFAULT, 1200 }; - if (m_jobs[iEntry].dwFlags & PREF_UNICODE) - SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)&m_jobs[iEntry].szSendBuffer[mir_strlen(m_jobs[iEntry].szSendBuffer) + 1]); - else { - stx.codepage = (m_jobs[iEntry].dwFlags & PREF_UTF) ? CP_UTF8 : CP_ACP; - SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_jobs[iEntry].szSendBuffer); - } + SETTEXTEX stx = { ST_DEFAULT, CP_UTF8 }; + SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_jobs[iEntry].szSendBuffer); UpdateSaveAndSendButton(const_cast<TWindowData *>(dat)); SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETSEL, (WPARAM)-1, (LPARAM)-1); } @@ -698,12 +605,9 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) cc->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1); } - if (job.dwFlags & PREF_UNICODE) - dbei.cbBlob *= sizeof(TCHAR) + 1; if (job.dwFlags & PREF_RTL) dbei.flags |= DBEF_RTL; - if (job.dwFlags & PREF_UTF) - dbei.flags |= DBEF_UTF; + dbei.flags |= DBEF_UTF; dbei.pBlob = (PBYTE)job.szSendBuffer; MessageWindowEvent evt = { sizeof(evt), (int)job.hSendId, job.hContact, &dbei }; @@ -816,41 +720,21 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b } else mir_sntprintf(tszHeader, SIZEOF(tszHeader), _T("M%d|"), time(0)); - if (job->dwFlags & PREF_UTF || !(job->dwFlags & PREF_UNICODE)) { - char *utf_header = mir_utf8encodeT(tszHeader); - size_t required = mir_strlen(utf_header) + mir_strlen(job->szSendBuffer) + 10; - char *tszMsg = reinterpret_cast<char *>(mir_alloc(required)); + char *utf_header = mir_utf8encodeT(tszHeader); + size_t required = mir_strlen(utf_header) + mir_strlen(job->szSendBuffer) + 10; + char *tszMsg = reinterpret_cast<char *>(mir_alloc(required)); - if (fIsSendLater) { - mir_snprintf(tszMsg, required, "%s%s", job->szSendBuffer, utf_header); - db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, tszMsg); - } - else { - mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer); - sendLater->addJob(tszMsg, hContact); - } - mir_free(utf_header); - mir_free(tszMsg); + if (fIsSendLater) { + mir_snprintf(tszMsg, required, "%s%s", job->szSendBuffer, utf_header); + db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, tszMsg); } - else if (job->dwFlags & PREF_UNICODE) { - size_t iLen = mir_strlen(job->szSendBuffer); - wchar_t *wszMsg = (wchar_t *)&job->szSendBuffer[iLen + 1]; - - size_t required = sizeof(TCHAR) * (mir_tstrlen(tszHeader) + mir_wstrlen(wszMsg) + 10); - - TCHAR *tszMsg = reinterpret_cast<TCHAR *>(mir_alloc(required)); - if (fIsSendLater) - mir_sntprintf(tszMsg, required, _T("%s%s"), wszMsg, tszHeader); - else - mir_sntprintf(tszMsg, required, _T("%s%s"), tszHeader, wszMsg); - char *utf = mir_utf8encodeT(tszMsg); - if (fIsSendLater) - db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, utf); - else - sendLater->addJob(utf, hContact); - mir_free(utf); - mir_free(tszMsg); + else { + mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer); + sendLater->addJob(tszMsg, hContact); } + mir_free(utf_header); + mir_free(tszMsg); + if (fIsSendLater) { int iCount = db_get_dw(hContact ? hContact : job->hContact, "SendLater", "count", 0); iCount++; diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index 8a7974b621..310eb5eece 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -208,7 +208,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) strncpy(szMsgPart, szBuf, cbPortion);
szMsgPart[cbPortion] = 0;
- HANDLE hMsgProc = (HANDLE)CallContactService(hForwardTo, PSS_MESSAGE, PREF_UTF, (LPARAM)szMsgPart);
+ HANDLE hMsgProc = (HANDLE)CallContactService(hForwardTo, PSS_MESSAGE, 0, (LPARAM)szMsgPart);
MESSAGE_PROC* msgProc = (MESSAGE_PROC*)mir_alloc(sizeof(MESSAGE_PROC));
msgProc->hProcess = hMsgProc;
|