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 --- protocols/SkypeClassic/src/filexfer.cpp | 34 ++++++----------------- protocols/SkypeClassic/src/gchat.cpp | 4 +-- protocols/SkypeClassic/src/skype.cpp | 49 +++++++-------------------------- protocols/SkypeClassic/src/skypesvc.cpp | 2 +- 4 files changed, 21 insertions(+), 68 deletions(-) (limited to 'protocols/SkypeClassic/src') diff --git a/protocols/SkypeClassic/src/filexfer.cpp b/protocols/SkypeClassic/src/filexfer.cpp index 0c53202a83..d0caedea03 100644 --- a/protocols/SkypeClassic/src/filexfer.cpp +++ b/protocols/SkypeClassic/src/filexfer.cpp @@ -21,19 +21,11 @@ INT_PTR SkypeRecvFile(WPARAM, LPARAM lParam) dbei.szModule = SKYPE_PROTONAME; dbei.timestamp = pre->timestamp; if (pre->flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ; - if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; dbei.eventType = EVENTTYPE_FILE; dbei.cbBlob = sizeof(DWORD); - if (pre->flags & PREF_UNICODE) { - for (nFiles = 0; cbFilename = wcslen((wchar_t*)&pre->szMessage[dbei.cbBlob])*sizeof(wchar_t); nFiles++) - dbei.cbBlob += DWORD(cbFilename) + sizeof(wchar_t); - dbei.cbBlob += sizeof(wchar_t); - } - else { - for (nFiles = 0; cbFilename = strlen(&pre->szMessage[dbei.cbBlob]); nFiles++) - dbei.cbBlob += DWORD(cbFilename) + 1; - dbei.cbBlob++; - } + for (nFiles = 0; cbFilename = strlen(&pre->szMessage[dbei.cbBlob]); nFiles++) + dbei.cbBlob += DWORD(cbFilename) + 1; + dbei.cbBlob++; dbei.pBlob = (PBYTE)pre->szMessage; TYP_MSGLENTRY *pEntry = MsgList_Add(pre->lParam, db_event_add(ccs->hContact, &dbei)); @@ -48,21 +40,12 @@ INT_PTR SkypeRecvFile(WPARAM, LPARAM lParam) pfts->hContact = ccs->hContact; pfts->totalFiles = nFiles; if (pfts->pszFiles = (char**)calloc(nFiles + 1, sizeof(char*))) { - if (pre->flags & PREF_UNICODE) { - wchar_t *pFN; - for (size_t i = 0; cbFilename = wcslen(pFN = (wchar_t*)&pre->szMessage[iOffs])*sizeof(wchar_t); i++) { - pfts->pszFiles[i] = (char*)wcsdup(pFN); - iOffs += cbFilename + sizeof(wchar_t); - } - } - else { - char *pFN; - for (size_t i = 0; cbFilename = strlen(pFN = &pre->szMessage[iOffs]); i++) { - pfts->pszFiles[i] = strdup(pFN); - iOffs += cbFilename + 1; - } - if (pre->flags & PREF_UTF) pfts->flags |= PFTS_UTF; + char *pFN; + for (size_t i = 0; cbFilename = strlen(pFN = &pre->szMessage[iOffs]); i++) { + pfts->pszFiles[i] = strdup(pFN); + iOffs += cbFilename + 1; } + pfts->flags |= PFTS_UTF; ret = pre->lParam; } } @@ -244,7 +227,6 @@ BOOL FXHandleRecv(PROTORECVEVENT *pre, MCONTACT hContact) cbMsg = cbNewSize - 1; } else pszMsgNum = NULL; - pre->flags |= PREF_UTF; free(pszFN); } } diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp index cbd154ac4a..93ad849677 100644 --- a/protocols/SkypeClassic/src/gchat.cpp +++ b/protocols/SkypeClassic/src/gchat.cpp @@ -621,11 +621,11 @@ int GCEventHook(WPARAM,LPARAM lParam) { // remove the ending linebreak for (pEnd = &gch->ptszText[_tcslen(gch->ptszText) - 1]; *pEnd==_T('\r') || *pEnd==_T('\n'); pEnd--) *pEnd=0; - // Send message to the chat-contact + // Send message to the chat-contact if (ccs.hContact = find_chat(gch->pDest->ptszID)) { // If PREF_UTF is supported, just convert it to UTF8 and pass the buffer to PSS_MESSAGE ccs.lParam = (LPARAM)make_utf8_string(gch->ptszText); - ccs.wParam = PREF_UTF; + ccs.wParam = 0; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } diff --git a/protocols/SkypeClassic/src/skype.cpp b/protocols/SkypeClassic/src/skype.cpp index 60c5f89556..e152a1496e 100644 --- a/protocols/SkypeClassic/src/skype.cpp +++ b/protocols/SkypeClassic/src/skype.cpp @@ -513,8 +513,6 @@ static void QueryUserWaitingAuthorization(char *pszNick, char *pszAuthRq) pCurBlob += sizeof(DWORD); // Not used memcpy(pCurBlob, &hContact, sizeof(HANDLE)); pCurBlob += sizeof(HANDLE); - pre.flags |= PREF_UTF; - sprintf(pCurBlob, "%s%c%s%c%s%c%c%s", pszNick, 0, firstname ? firstname : "", 0, lastname ? lastname : "", 0, 0, authmsg ? authmsg : ""); CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs); @@ -1215,28 +1213,15 @@ void FetchMessageThread(fetchmsg_arg *pargs) { if (!isGroupChat) { // I guess Groupchat doesn't support UTF8? msg = ptr; - pre.flags |= PREF_UTF; } - else { // Older version has to decode either UTF8->ANSI or UTF8->UNICODE + else { + // Older version has to decode either UTF8->ANSI or UTF8->UNICODE // This could be replaced by mir_getUTFI - functions for Miranda 0.5+ builds, but we stay // 0.4 compatible for backwards compatibility. Unfortunately this requires us to link with utf8.c -#ifdef _UNICODE - int wcLen; -#endif - if (utf8_decode(msgptr, &msg) == -1) { free(ptr); __leave; } -#ifdef _UNICODE - msglen = (int)strlen(msg) + 1; - msgptr = (char*)make_unicode_string((const unsigned char*)msgptr); - wcLen = int(_tcslen((TCHAR*)msgptr) + 1)*sizeof(TCHAR); - msg = (char*)realloc(msg, msglen + wcLen); - memcpy(msg + msglen, msgptr, wcLen); - free(msgptr); - pre.flags |= PREF_UNICODE; -#endif msgptr = msg; free(ptr); } @@ -1309,13 +1294,11 @@ void FetchMessageThread(fetchmsg_arg *pargs) { if (!(dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0))) dbei.szModule = SKYPE_PROTONAME; dbei.cbBlob = msglen; - if (pre.flags & PREF_UNICODE) - dbei.cbBlob += sizeof(WCHAR)*((DWORD)wcslen((WCHAR*)&msgptr[dbei.cbBlob]) + 1); dbei.pBlob = (PBYTE)msgptr; dbei.timestamp = timestamp > 0 ? timestamp : (DWORD)SkypeTime(NULL); dbei.flags = direction; - if (pre.flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ; - if (pre.flags & PREF_UTF) dbei.flags |= DBEF_UTF; + if (pre.flags & PREF_CREATEREAD) + dbei.flags |= DBEF_READ; dbei.eventType = EVENTTYPE_MESSAGE; pme = MsgList_Add((DWORD)pre.lParam, db_event_add(hContact, &dbei)); @@ -2711,7 +2694,7 @@ void MessageSendWatchThread(void *a) { INT_PTR SkypeSendMessage(WPARAM, LPARAM lParam) { CCSDATA *ccs = (CCSDATA *)lParam; DBVARIANT dbv; - char *msg = (char *)ccs->lParam, *utfmsg = NULL, *mymsgcmd = cmdMessage, szId[16] = { 0 }; + char *msg = (char *)ccs->lParam, *mymsgcmd = cmdMessage, szId[16] = { 0 }; static DWORD dwMsgNum = 0; BYTE bIsChatroom = 0 != db_get_b(ccs->hContact, SKYPE_PROTONAME, "ChatRoom", 0); @@ -2728,24 +2711,14 @@ INT_PTR SkypeSendMessage(WPARAM, LPARAM lParam) { mymsgcmd = "MESSAGE"; } - if (ccs->wParam & PREF_UTF) { - utfmsg = msg; - } - else if (ccs->wParam & PREF_UNICODE) { - utfmsg = (char*)make_utf8_string((WCHAR*)(msg + strlen(msg) + 1)); - } - else { - if (utf8_encode(msg, &utfmsg) == -1) utfmsg = NULL; - } if (protocol >= 4) { InterlockedIncrement((LONG*)&dwMsgNum); sprintf(szId, "#M%d ", dwMsgNum++); } InterlockedIncrement(&sendwatchers); bool sendok = true; - if (!utfmsg || SkypeSend("%s%s %s %s", szId, mymsgcmd, dbv.pszVal, utfmsg)) + if (!msg || SkypeSend("%s%s %s %s", szId, mymsgcmd, dbv.pszVal, msg)) sendok = false; - if (utfmsg && utfmsg != msg) free(utfmsg); db_free(&dbv); if (sendok) { @@ -2777,12 +2750,11 @@ INT_PTR SkypeRecvMessage(WPARAM, LPARAM lParam) dbei.cbSize = sizeof(dbei); dbei.szModule = SKYPE_PROTONAME; dbei.timestamp = pre->timestamp; - if (pre->flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ; - if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF; + if (pre->flags & PREF_CREATEREAD) + dbei.flags |= DBEF_READ; + dbei.flags |= DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (int)strlen(pre->szMessage) + 1; - if (pre->flags & PREF_UNICODE) - dbei.cbBlob += sizeof(wchar_t)*((DWORD)wcslen((wchar_t*)&pre->szMessage[dbei.cbBlob]) + 1); dbei.pBlob = (PBYTE)pre->szMessage; MsgList_Add((DWORD)pre->lParam, db_event_add(ccs->hContact, &dbei)); return 0; @@ -2838,8 +2810,7 @@ INT_PTR SkypeRecvAuth(WPARAM, LPARAM lParam) { dbei.cbSize = sizeof(dbei); dbei.szModule = SKYPE_PROTONAME; dbei.timestamp = pre->timestamp; - dbei.flags = ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0); - dbei.flags |= (pre->flags & PREF_UTF) ? DBEF_UTF : 0; + dbei.flags = DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0); dbei.eventType = EVENTTYPE_AUTHREQUEST; dbei.cbBlob = (int)pre->lParam; dbei.pBlob = (PBYTE)pre->szMessage; diff --git a/protocols/SkypeClassic/src/skypesvc.cpp b/protocols/SkypeClassic/src/skypesvc.cpp index 1ca79ec62b..fae8b8cd3b 100644 --- a/protocols/SkypeClassic/src/skypesvc.cpp +++ b/protocols/SkypeClassic/src/skypesvc.cpp @@ -131,7 +131,7 @@ INT_PTR SkypeGetCaps(WPARAM wParam, LPARAM) case PFLAGNUM_3: return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE | PF2_IDLE; case PFLAGNUM_4: - return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_AVATARS | PF4_SUPPORTTYPING /* Not really, but libgaim compat. */ | PF4_IMSENDUTF; + return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_AVATARS | PF4_SUPPORTTYPING; case PFLAGNUM_5: return Proto_Status2Flag(db_get_dw(NULL, SKYPE_PROTONAME, "SkypeOutStatusMode", ID_STATUS_ONTHEPHONE)); case PFLAG_UNIQUEIDTEXT: -- cgit v1.2.3