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 /src | |
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 'src')
-rw-r--r-- | src/core/stdfile/src/file.cpp | 65 | ||||
-rw-r--r-- | src/core/stdmsg/src/cmdlist.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 38 | ||||
-rw-r--r-- | src/modules/metacontacts/meta_services.cpp | 2 | ||||
-rw-r--r-- | src/modules/protocols/protocols.cpp | 21 | ||||
-rw-r--r-- | src/modules/protocols/protoint.cpp | 4 |
6 files changed, 49 insertions, 83 deletions
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 042d1fe44e..fbe092784a 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -371,27 +371,6 @@ INT_PTR openRecDir(WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-static void sttRecvCreateBlob(DBEVENTINFO &dbei, int fileCount, char **pszFiles, char *szDescr)
-{
- dbei.cbBlob = sizeof(DWORD);
-
- for (int i = 0; i < fileCount; i++)
- dbei.cbBlob += (int)mir_strlen(pszFiles[i]) + 1;
-
- dbei.cbBlob += (int)mir_strlen(szDescr) + 1;
-
- if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
- return;
-
- *(DWORD*)dbei.pBlob = 0;
- BYTE* p = dbei.pBlob + sizeof(DWORD);
- for (int i = 0; i < fileCount; i++) {
- strcpy((char*)p, pszFiles[i]);
- p += mir_strlen(pszFiles[i]) + 1;
- }
- strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
-}
-
static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA*)lParam;
@@ -402,20 +381,46 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(ccs->hContact);
dbei.timestamp = pre->timestamp;
- dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
+ dbei.flags = DBEF_UTF | (pre->dwFlags & PREF_CREATEREAD) ? DBEF_READ : 0;
dbei.eventType = EVENTTYPE_FILE;
- char **pszFiles = (char**)alloca(pre->fileCount * sizeof(char*));
- for (int i = 0; i < pre->fileCount; i++)
- pszFiles[i] = Utf8EncodeT(pre->ptszFiles[i]);
+ bool bUnicode = (pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE;
- char *szDescr = Utf8EncodeT(pre->tszDescription);
- dbei.flags |= DBEF_UTF;
- sttRecvCreateBlob(dbei, pre->fileCount, pszFiles, szDescr);
+ char *szDescr, **pszFiles;
+ if (bUnicode) {
+ pszFiles = (char**)alloca(pre->fileCount * sizeof(char*));
+ for (int i = 0; i < pre->fileCount; i++)
+ pszFiles[i] = Utf8EncodeT(pre->ptszFiles[i]);
+
+ szDescr = Utf8EncodeT(pre->tszDescription);
+ }
+ else {
+ pszFiles = pre->pszFiles;
+ szDescr = pre->szDescription;
+ }
+
+ dbei.cbBlob = sizeof(DWORD);
for (int i = 0; i < pre->fileCount; i++)
- mir_free(pszFiles[i]);
- mir_free(szDescr);
+ dbei.cbBlob += (int)mir_strlen(pszFiles[i]) + 1;
+
+ dbei.cbBlob += (int)mir_strlen(szDescr) + 1;
+
+ if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
+ return 0;
+
+ *(DWORD*)dbei.pBlob = 0;
+ BYTE* p = dbei.pBlob + sizeof(DWORD);
+ for (int i = 0; i < pre->fileCount; i++) {
+ strcpy((char*)p, pszFiles[i]);
+ p += mir_strlen(pszFiles[i]) + 1;
+ if (bUnicode)
+ mir_free(pszFiles[i]);
+ }
+
+ strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
+ if (bUnicode)
+ mir_free(szDescr);
MEVENT hdbe = db_event_add(ccs->hContact, &dbei);
PushFileEvent(ccs->hContact, hdbe, pre->lParam);
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index f462ddbb14..4fa38ae9ac 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -94,7 +94,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | (p->flags & PREF_UTF ? DBEF_UTF : 0) | (p->flags & PREF_RTL ? DBEF_RTL : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & PREF_RTL ? DBEF_RTL : 0);
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(0);
dbei.cbBlob = (DWORD)mir_strlen(p->szMsg);
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 9e72a86f62..af2c574587 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -53,15 +53,6 @@ static void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type) }
}
-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;
-}
-
static int RTL_Detect(const TCHAR *ptszText)
{
int iLen = (int)_tcslen(ptszText);
@@ -81,34 +72,13 @@ int SendMessageDirect(const TCHAR *szMsg, MCONTACT hContact, char *szProto) return NULL;
int flags = 0;
- int bufSize = 0;
- char *sendBuffer = NULL;
-
if (RTL_Detect(szMsg))
flags |= PREF_RTL;
- if (IsUtfSendAvailable(hContact)) {
- flags |= PREF_UTF;
- sendBuffer = mir_utf8encodeT(szMsg);
- if (!sendBuffer || !sendBuffer[0]) {
- mir_free(sendBuffer);
- return NULL;
- }
- bufSize = (int)strlen(sendBuffer) + 1;
- }
- else {
- flags |= PREF_TCHAR;
- sendBuffer = mir_t2a(szMsg);
- if (!sendBuffer || !sendBuffer[0]) {
- mir_free(sendBuffer);
- return NULL;
- }
- bufSize = (int)strlen(sendBuffer) + 1;
-
- size_t bufSizeT = (_tcslen(szMsg) + 1) * sizeof(TCHAR);
- sendBuffer = (char*)mir_realloc(sendBuffer, bufSizeT + bufSize);
- memcpy((TCHAR*)&sendBuffer[bufSize], szMsg, bufSizeT);
- bufSize += (int)bufSizeT;
+ char *sendBuffer = mir_utf8encodeT(szMsg);
+ if (!sendBuffer || !sendBuffer[0]) {
+ mir_free(sendBuffer);
+ return NULL;
}
if (sendBuffer == NULL)
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 7c10f7de2f..9d3a0c89a0 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -63,7 +63,7 @@ INT_PTR Meta_GetCaps(WPARAM wParam, LPARAM lParam) return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
case PFLAGNUM_4:
- return PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDUTF;
+ return PF4_SUPPORTTYPING | PF4_AVATARS;
case PFLAGNUM_5:
return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 2a0c2b9b2a..3787696bd9 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -124,20 +124,14 @@ static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam) ptrA pszTemp;
mir_ptr<BYTE> pszBlob;
- DBEVENTINFO dbei = { sizeof(dbei) };
+ DBEVENTINFO dbei = { 0 };
+ dbei.cbSize = sizeof(dbei);
+ dbei.flags = DBEF_UTF;
dbei.szModule = GetContactProto(ccs->hContact);
dbei.timestamp = pre->timestamp;
dbei.eventType = EVENTTYPE_MESSAGE;
- if (pre->flags & PREF_UNICODE) {
- pszTemp = mir_utf8encodeT(pre->tszMessage);
- dbei.pBlob = (PBYTE)(char*)pszTemp;
- dbei.cbBlob = (DWORD)strlen(pszTemp) + 1;
- dbei.flags |= DBEF_UTF;
- }
- else {
- dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1;
- dbei.pBlob = (PBYTE)pre->szMessage;
- }
+ dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1;
+ dbei.pBlob = (PBYTE)pre->szMessage;
if (pre->cbCustomDataSize != 0) {
pszBlob = (PBYTE)mir_alloc(dbei.cbBlob + pre->cbCustomDataSize);
@@ -149,8 +143,6 @@ static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam) if (pre->flags & PREF_CREATEREAD)
dbei.flags |= DBEF_READ;
- if (pre->flags & PREF_UTF)
- dbei.flags |= DBEF_UTF;
if (pre->flags & PREF_SENT)
dbei.flags |= DBEF_SENT;
@@ -164,8 +156,7 @@ static INT_PTR Proto_AuthRecv(WPARAM wParam, LPARAM lParam) DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = (char*)wParam;
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 = pre->lParam;
dbei.pBlob = (PBYTE)pre->szMessage;
diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp index 9152877e44..d6b9a9f39f 100644 --- a/src/modules/protocols/protoint.cpp +++ b/src/modules/protocols/protoint.cpp @@ -208,9 +208,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return res;
}
- int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg)
+ int __cdecl SendMsg(MCONTACT hContact, const char* msg)
{
- CCSDATA ccs = { hContact, PSS_MESSAGE, flags, (LPARAM)msg };
+ CCSDATA ccs = { hContact, PSS_MESSAGE, 0, (LPARAM)msg };
return (int)ProtoCallService(m_szModuleName, PSS_MESSAGE, 0, (LPARAM)&ccs);
}
|