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/SecureIM/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 'plugins/SecureIM/src')
-rw-r--r-- | plugins/SecureIM/src/commonheaders.h | 1 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_dll.cpp | 32 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_lists.cpp | 10 | ||||
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 3 | ||||
-rw-r--r-- | plugins/SecureIM/src/mmi.cpp | 13 | ||||
-rw-r--r-- | plugins/SecureIM/src/rtfconv.cpp | 40 | ||||
-rw-r--r-- | plugins/SecureIM/src/rtfconv.h | 20 | ||||
-rw-r--r-- | plugins/SecureIM/src/svcs_proto.cpp | 31 |
8 files changed, 8 insertions, 142 deletions
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;
|