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/Scriver/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/Scriver/src')
-rw-r--r-- | plugins/Scriver/src/globals.cpp | 6 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 65 | ||||
-rw-r--r-- | plugins/Scriver/src/sendqueue.cpp | 12 |
3 files changed, 18 insertions, 65 deletions
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)
|