diff options
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/message.cpp | 349 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 196 | ||||
-rw-r--r-- | plugins/TabSRMM/src/contactcache.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 16 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 95 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.h | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 59 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.h | 21 | ||||
-rw-r--r-- | plugins/TabSRMM/src/version.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/tabsrmm_10.vcxproj | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/tabsrmm_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/tabsrmm_12.vcxproj | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/tabsrmm_12.vcxproj.filters | 3 |
16 files changed, 189 insertions, 577 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index c9427e56d0..01e2481700 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -156,10 +156,6 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce); int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
-// message.c
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
-TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si);
-
#include "chat_resource.h"
extern char szIndicators[];
diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp deleted file mode 100644 index 1aec8c0a66..0000000000 --- a/plugins/TabSRMM/src/chat/message.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////
-// Miranda NG: the free IM client for Microsoft* Windows*
-//
-// Copyright (ñ) 2012-15 Miranda NG project,
-// Copyright (c) 2000-09 Miranda ICQ/IM project,
-// all portions of this codebase are copyrighted to the people
-// listed in contributors.txt.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// you should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-// part of tabSRMM messaging plugin for Miranda.
-//
-// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
-
-#include "..\commonheaders.h"
-
-static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO *si)
-{
- int i;
- MODULEINFO *pMod = pci->MM_FindModule(si->pszModule);
-
- for (i=0; i < pMod->nColorCount ; i++)
- if (pIndex[i] == iCol)
- return i;
-
- return -1;
-}
-
-static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO *si)
-{
- char *p1, *p2, *pEnd;
- int iIndex = 1;
-
- static const char* lpszFmt = "\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];";
- char szRed[10], szGreen[10], szBlue[10];
-
- p1 = strstr(Text, "\\colortbl");
- if (!p1)
- return;
-
- pEnd = strchr(p1, '}');
- p2 = strstr(p1, "\\red");
-
- while (p2 && p2 < pEnd) {
- if (sscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
- MODULEINFO * pMod = pci->MM_FindModule(si->pszModule);
- for (int i=0; i < pMod->nColorCount ; i ++)
- if (pMod->crColors[i] == RGB(atoi(szRed), atoi(szGreen), atoi(szBlue)))
- pIndex[i] = iIndex;
- }
- iIndex++;
- p1 = p2;
- p1 ++;
- p2 = strstr(p1, "\\red");
- }
-}
-
-static int ReadInteger(const char* p, int* result)
-{
- char temp[10];
- int i=0;
- while (isdigit(*p) && i < 9)
- temp[i++] = *p++;
- temp[i] = 0;
-
- if (result != NULL)
- *result = atoi(temp);
-
- return i;
-}
-
-TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
-{
- int i, iRemoveChars;
- char InsertThis[50];
- BOOL bJustRemovedRTF = TRUE;
- BOOL bTextHasStarted = FALSE;
- int iUcMode = 0;
-
- if (!pszText)
- return FALSE;
-
- // create an index of colors in the module and map them to
- // corresponding colors in the RTF color table
- MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
- mir_ptr<int> pIndex((int*)mir_alloc(sizeof(int)*mi->nColorCount));
- for (i = 0; i < mi->nColorCount; i++)
- pIndex[i] = -1;
-
- CreateColorMap(pszText, pIndex, si);
-
- // scan the file for rtf commands and remove or parse them
- char *p1 = strstr(pszText, "\\ltrpar");
- if (p1 == NULL) {
- if ((p1 = strstr(pszText, "\\pard")) == NULL)
- return FALSE;
- p1 += 5;
- }
- else p1 += 7;
-
- memmove(pszText, p1, mir_strlen(p1) + 1);
- p1 = pszText;
-
- // iterate through all characters, if rtf control character found then take action
- while (*p1 != '\0') {
- InsertThis[0] = 0;
- iRemoveChars = 0;
-
- switch (*p1) {
- case '\\':
- if (!memcmp(p1, "\\cf", 3)) { // foreground color
- int iCol, iInd;
- iRemoveChars = 3 + ReadInteger(p1 + 3, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
- bJustRemovedRTF = TRUE;
-
- // if (bTextHasStarted || iInd >= 0)
- // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd);
- }
- else if (!memcmp(p1, "\\highlight", 10)) { //background color
- int iCol, iInd;
- iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
- bJustRemovedRTF = TRUE;
-
- // if (bTextHasStarted || iInd >= 0)
- // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd);
- }
- else if (!memcmp(p1, "\\lang", 5)) { // language id
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 5 + ReadInteger(p1 + 5, NULL);
- }
- else if (!memcmp(p1, "\\par", 4)) { // newline
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 4;
- strcpy(InsertThis, "\n");
- }
- else if (!memcmp(p1, "\\endash", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x93");
- }
- else if (!memcmp(p1, "\\emdash", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x94");
- }
- else if (!memcmp(p1, "\\bullet", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\xA2");
- }
- else if (!memcmp(p1, "\\line", 5)) { // newline
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 5;
- strcpy(InsertThis, "\n");
- }
- else if (!memcmp(p1, "\\b", 2)) { //bold
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0') ? 2 : 3;
- strcpy(InsertThis, (p1[2] != '0') ? "%b" : "%B");
- }
- else if (!memcmp(p1, "\\i", 2)) { // italics
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0') ? 2 : 3;
- strcpy(InsertThis, (p1[2] != '0') ? "%i" : "%I");
- }
- else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iUcMode = p1[3] - '0';
- iRemoveChars = 4;
- }
- else if (!memcmp(p1, "\\ul", 3)) { // underlined
- bTextHasStarted = bJustRemovedRTF = TRUE;
- if (p1[3] == 'n')
- iRemoveChars = 7;
- else if (p1[3] == '0')
- iRemoveChars = 4;
- else
- iRemoveChars = 3;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U");
- }
- else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 2 + ReadInteger(p1 + 2, NULL);
- }
- else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 2;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]);
- }
- else if (p1[1] == '~') { // non-breaking space
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 2;
- strcpy(InsertThis, "\xC2\xA0");
- }
- else if (!memcmp(p1, "\\tab",4)) { // tab
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 4;
- strcpy(InsertThis, "\x09");
- }
- else if (!memcmp(p1, "\\ldblquote",10)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 10;
- strcpy(InsertThis, "\xe2\x80\x9c");
- }
- else if (!memcmp(p1, "\\rdblquote",10)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 10;
- strcpy(InsertThis, "\xe2\x80\x9d");
- }
- else if (!memcmp(p1, "\\lquote",7)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x98");
- }
- else if (!memcmp(p1, "\\rquote",7)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x99");
- }
- else if (p1[1] == '\'') { // special character
- char tmp[4], *p3 = tmp;
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- if (p1[2] != ' ' && p1[2] != '\\') {
- *p3++ = p1[2];
- iRemoveChars = 3;
- if (p1[3] != ' ' && p1[3] != '\\') {
- *p3++ = p1[3];
- iRemoveChars++;
- }
- *p3 = 0;
- sscanf(tmp, "%x", InsertThis);
-
- InsertThis[1] = 0;
- }
- else iRemoveChars = 2;
- }
- else if (bJustRemovedRTF) { // remove unknown RTF command
- int j = 1;
- bJustRemovedRTF = TRUE;
- while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0')
- j++;
- iRemoveChars = j;
- }
- break;
-
- case '{': // other RTF control characters
- case '}':
- iRemoveChars = 1;
- break;
-
- case '\r': case '\n':
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 1;
- break;
-
- case '%': // escape chat -> protocol control character
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 1;
- strcpy(InsertThis, "%%");
- break;
-
- case ' ': // remove spaces following a RTF command
- if (bJustRemovedRTF)
- iRemoveChars = 1;
- bJustRemovedRTF = FALSE;
- bTextHasStarted = TRUE;
- break;
-
- default: // other text that should not be touched
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- break;
- }
-
- // move the memory and paste in new commands instead of the old RTF
- if (InsertThis[0] || iRemoveChars) {
- memmove(p1 + mir_strlen(InsertThis) , p1 + iRemoveChars, mir_strlen(p1) - iRemoveChars + 1);
- memcpy(p1, InsertThis, mir_strlen(InsertThis));
- p1 += mir_strlen(InsertThis);
- }
- else p1++;
- }
-
- return mir_utf8decodeW(pszText);
-}
-
-static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
-{
- static DWORD dwRead;
- char **ppText = (char**)dwCookie;
- if (*ppText == NULL) {
- *ppText = (char *)mir_alloc(cb + 1);
- memcpy(*ppText, pbBuff, cb);
- (*ppText)[cb] = 0;
- *pcb = cb;
- dwRead = cb;
- }
- else {
- char *p = (char*)mir_alloc(dwRead + cb + 1);
- memcpy(p, *ppText, dwRead);
- memcpy(p + dwRead, pbBuff, cb);
- p[dwRead + cb] = 0;
- mir_free(*ppText);
- *ppText = p;
- *pcb = cb;
- dwRead += cb;
- }
- return 0;
-}
-
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si)
-{
- if (hwndDlg == 0 || si == 0)
- return NULL;
-
- char* pszText = NULL;
- EDITSTREAM stream;
- memset(&stream, 0, sizeof(stream));
- stream.pfnCallback = Chat_Message_StreamCallback;
- stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
-
- DWORD dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16);
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_STREAMOUT, dwFlags, (LPARAM)&stream);
- return pszText; // pszText contains the text
-}
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 1f3ddf7f1b..35d55d78c2 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -266,9 +266,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p) }
}
- /*
- * flash window if it is not focused
- */
+ // flash window if it is not focused
if (p->bMustFlash && p->bInactive)
if (!(dat->pContainer->dwFlags & CNT_NOFLASH))
FlashContainer(dat->pContainer, 1, 0);
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 7b16eae570..310e5ecfc6 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -52,12 +52,11 @@ struct MESSAGESUBDATA const CLSID IID_ITextDocument = { 0x8CC497C0, 0xA1DF, 0x11CE, { 0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D } }; -/* - * checking if theres's protected text at the point - * emulates EN_LINK WM_NOTIFY to parent to process links - */ +///////////////////////////////////////////////////////////////////////////////////////// +// checking if theres's protected text at the point +// emulates EN_LINK WM_NOTIFY to parent to process links -static BOOL CheckCustomLink(HWND hwndDlg, POINT* ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded) +static BOOL CheckCustomLink(HWND hwndDlg, POINT *ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded) { long res = 0, cnt = 0; long cpMin = 0, cpMax = 0; @@ -131,7 +130,7 @@ static BOOL CheckCustomLink(HWND hwndDlg, POINT* ptClient, UINT uMsg, WPARAM wPa return bIsCustomLink; } -bool IsStringValidLink(TCHAR* pszText) +bool IsStringValidLink(TCHAR *pszText) { if (pszText == NULL) return false; @@ -145,10 +144,9 @@ bool IsStringValidLink(TCHAR* pszText) return _tcsstr(pszText, _T("://")) != NULL; } -/* - * called whenever a group chat tab becomes active (either by switching tabs or activating a - * container window - */ +///////////////////////////////////////////////////////////////////////////////////////// +// called whenever a group chat tab becomes active(either by switching tabs or activating a +// container window static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) { @@ -255,9 +253,8 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg) dat->pWnd->Invalidate(); } -/* - * initialize button bar, set all the icons and ensure proper button state - */ +///////////////////////////////////////////////////////////////////////////////////////// +// initialize button bar, set all the icons and ensure proper button state static void InitButtons(HWND hwndDlg, SESSION_INFO *si) { @@ -296,10 +293,9 @@ static void Chat_ResizeIeView(const TWindowData *dat) CallService(iMode == 1 ? MS_IEVIEW_WINDOW : MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow); } -/* - * resizer callback for the group chat session window. Called from Mirandas dialog - * resizing service - */ +///////////////////////////////////////////////////////////////////////////////////////// +// resizer callback for the group chat session window.Called from Mirandas dialog +// resizing service static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) { @@ -427,9 +423,8 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } -/* - * subclassing for the message input control (a richedit text control) - */ +///////////////////////////////////////////////////////////////////////////////////////// +// subclassing for the message input control(a richedit text control) static bool TabAutoComplete(HWND hwnd, MESSAGESUBDATA *dat, SESSION_INFO *si) { @@ -523,13 +518,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { HWND hwndParent = GetParent(hwnd); TWindowData *mwdat = (TWindowData*)GetWindowLongPtr(hwndParent, GWLP_USERDATA); - SESSION_INFO *Parentsi = (SESSION_INFO*)mwdat->si; + SESSION_INFO *si = (SESSION_INFO*)mwdat->si; - MESSAGESUBDATA *dat = (MESSAGESUBDATA *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + MESSAGESUBDATA *dat = (MESSAGESUBDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (mwdat->fkeyProcessed && (msg == WM_KEYUP)) { GetKeyboardState(mwdat->kstate); - if ( !(mwdat->kstate[VK_CONTROL] & 0x80) && !(mwdat->kstate[VK_SHIFT] & 0x80)) + if (!(mwdat->kstate[VK_CONTROL] & 0x80) && !(mwdat->kstate[VK_SHIFT] & 0x80)) mwdat->fkeyProcessed = false; return 0; } @@ -542,13 +537,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return CSkin::DrawRichEditFrame(hwnd, mwdat, ID_EXTBKINPUTAREA, msg, wParam, lParam, MessageSubclassProc); case EM_SUBCLASSED: - dat = (MESSAGESUBDATA *) mir_calloc(sizeof(MESSAGESUBDATA)); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat); + dat = (MESSAGESUBDATA*)mir_calloc(sizeof(MESSAGESUBDATA)); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat); return 0; case WM_CONTEXTMENU: { - MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule); + MODULEINFO *mi = pci->MM_FindModule(si->pszModule); CHARRANGE sel, all = { 0, -1}; int idFrom = IDC_CHAT_MESSAGE; @@ -654,7 +649,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, SkinPlaySound("SoundOnTyping"); if (isCtrl && !isAlt && !isShift) { - MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule); + MODULEINFO *mi = pci->MM_FindModule(si->pszModule); switch(wParam) { case 0x09: // ctrl-i (italics) @@ -800,7 +795,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (wParam == VK_TAB && !isCtrl && !isShift) { //tab-autocomplete SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); - bool fCompleted = TabAutoComplete(hwnd, dat, Parentsi); + bool fCompleted = TabAutoComplete(hwnd, dat, si); SendMessage(hwnd, WM_SETREDRAW, TRUE, 0); RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); if (!fCompleted && !PluginConfig.m_bAllowTab) { @@ -831,25 +826,24 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (wParam == VK_UP && isCtrl && !isAlt) { - GETTEXTLENGTHEX gtl = {0}; - SETTEXTEX ste; - LOGFONTA lf; - char *lpPrevCmd = pci->SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule); + char *lpPrevCmd = pci->SM_GetPrevCommand(si->ptszID, si->pszModule); - if (!Parentsi->lpCurrentCommand || !Parentsi->lpCurrentCommand->last) { + if (!si->lpCurrentCommand || !si->lpCurrentCommand->last) { // Next command is not defined. It means currently entered text is not saved in the history and it // need to be saved in the window context. - char *enteredText = Chat_Message_GetFromStream(hwndParent, Parentsi); - if (mwdat->enteredText) { + char *enteredText = Message_GetFromStream(hwndParent); + if (mwdat->enteredText) mir_free(mwdat->enteredText); - } mwdat->enteredText = enteredText; } SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); + LOGFONTA lf; LoadLogfont(MSGFONTID_MESSAGEAREA, &lf, NULL, FONTMODULE); + + SETTEXTEX ste; ste.flags = ST_DEFAULT; ste.codepage = CP_ACP; if (lpPrevCmd) @@ -857,6 +851,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, else SetWindowText(hwnd, _T("")); + GETTEXTLENGTHEX gtl = { 0 }; gtl.flags = GTL_PRECISE; gtl.codepage = CP_ACP; int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); @@ -872,7 +867,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, GETTEXTLENGTHEX gtl = {0}; SETTEXTEX ste; - char *lpPrevCmd = pci->SM_GetNextCommand(Parentsi->ptszID, Parentsi->pszModule); + char *lpPrevCmd = pci->SM_GetNextCommand(si->ptszID, si->pszModule); SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); ste.flags = ST_DEFAULT; @@ -914,9 +909,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { UINT u = 0; UINT u2 = 0; - COLORREF cr; - MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule); + MODULEINFO *mi = pci->MM_FindModule(si->pszModule); + COLORREF cr; LoadLogfont(MSGFONTID_MESSAGEAREA, NULL, &cr, FONTMODULE); CHARFORMAT2 cf; @@ -926,12 +921,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); if (mi && mi->bColor) { - int index = Chat_GetColorIndex(Parentsi->pszModule, cf.crTextColor); + int index = Chat_GetColorIndex(si->pszModule, cf.crTextColor); u = IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR); if (index >= 0) { - Parentsi->bFGSet = TRUE; - Parentsi->iFG = index; + si->bFGSet = TRUE; + si->iFG = index; } if (u == BST_UNCHECKED && cf.crTextColor != cr) @@ -941,13 +936,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (mi && mi->bBkgColor) { - int index = Chat_GetColorIndex(Parentsi->pszModule, cf.crBackColor); + int index = Chat_GetColorIndex(si->pszModule, cf.crBackColor); COLORREF crB = (COLORREF)M.GetDword(FONTMODULE, "inputbg", SRMSGDEFSET_BKGCOLOUR); u = IsDlgButtonChecked(hwndParent, IDC_BKGCOLOR); if (index >= 0) { - Parentsi->bBGSet = TRUE; - Parentsi->iBG = index; + si->bBGSet = TRUE; + si->iBG = index; } if (u == BST_UNCHECKED && cf.crBackColor != crB) @@ -999,7 +994,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_ERASEBKGND: - return CSkin::m_skinEnabled ? 0 : 1; + return !CSkin::m_skinEnabled; case WM_DESTROY: mir_free(dat); @@ -1008,11 +1003,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, MessageSubclassProc, msg, wParam, lParam); } - -/* -* subclassing for the message filter dialog (set and configure event filters for the current -* session -*/ +///////////////////////////////////////////////////////////////////////////////////////// +// subclassing for the message filter dialog (set and configure event filters for the +// current session static UINT _eventorder[] = { @@ -1143,10 +1136,10 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP return FALSE; } -/** - * subclass for some tool bar buttons which must perform special actions - * on right click. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// subclass for some tool bar buttons which must perform special actions +// on right click. + static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -1170,9 +1163,8 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam); } -/* - * subclassing for the message history display (rich edit control in which the chat history appears) - */ +///////////////////////////////////////////////////////////////////////////////////////// +// subclassing for the message history display(rich edit control in which the chat history appears) static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -1282,10 +1274,9 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR return mir_callNextSubclass(hwnd, LogSubclassProc, msg, wParam, lParam); } -/* - * process mouse - hovering for the nickname list. fires events so the protocol can - * show the userinfo - tooltip. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// process mouse - hovering for the nickname list.fires events so the protocol can +// show the userinfo - tooltip. static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *parentdat) { @@ -1353,9 +1344,8 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0 , 400); } -/* - * subclassing for the nickname list control. It is an ownerdrawn listbox - */ +///////////////////////////////////////////////////////////////////////////////////////// +// subclassing for the nickname list control.It is an ownerdrawn listbox static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -1464,10 +1454,8 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_CHAR: case WM_UNICHAR: - /* - * simple incremental search for the user (nick) - list control - * typing esc or movement keys will clear the current search string - */ + // simple incremental search for the user (nick) - list control + // typing esc or movement keys will clear the current search string if (mwdat && mwdat->si) { SESSION_INFO *si = (SESSION_INFO*)mwdat->si; if (wParam == 27 && si->szSearch[0]) { // escape - reset everything @@ -1485,17 +1473,15 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; } TCHAR szNew[2]; - szNew[0] = (TCHAR) wParam; + szNew[0] = (TCHAR)wParam; szNew[1] = '\0'; _tcscat(si->szSearch, szNew); } if (si->szSearch[0]) { - /* - * iterate over the (sorted) list of nicknames and search for the - * string we have - */ + // iterate over the (sorted) list of nicknames and search for the + // string we have int i, iItems = SendMessage(hwnd, LB_GETCOUNT, 0, 0); - for (i=0; i < iItems; i++) { + for (i = 0; i < iItems; i++) { USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, i); if (ui) { if (!_tcsnicmp(ui->pszNick, si->szSearch, mir_tstrlen(si->szSearch))) { @@ -1720,10 +1706,9 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, NicklistSubclassProc, msg, wParam, lParam); } -/* - * calculate the required rectangle for a string using the given font. This is more - * precise than using GetTextExtentPoint...() - */ +///////////////////////////////////////////////////////////////////////////////////////// +// calculate the required rectangle for a string using the given font. This is more +// precise than using GetTextExtentPoint...() int GetTextPixelSize(TCHAR* pszText, HFONT hFont, bool bWidth) { @@ -1749,11 +1734,9 @@ static void __cdecl phase2(void * lParam) PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0); } - -/* - * the actual group chat session window procedure. Handles the entire chat session window - * which is usually a (tabbed) child of a container class window. - */ +///////////////////////////////////////////////////////////////////////////////////////// +// the actual group chat session window procedure.Handles the entire chat session window +// which is usually a (tabbed) child of a container class window. INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -2052,7 +2035,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (wParam == SIZE_MAXIMIZED) PostMessage(hwndDlg, GC_SCROLLTOBOTTOM, 0, 0); - if ( !IsIconic(hwndDlg)) { + if (!IsIconic(hwndDlg)) { int panelHeight = dat->Panel->getHeight() + 1; UTILRESIZEDIALOG urd = { sizeof(urd) }; @@ -2765,7 +2748,7 @@ LABEL_SHOWWINDOW: tszTmp = tszAppeal = (TCHAR*)mir_alloc(bufSize * sizeof(TCHAR)); tr2.lpstrText = (LPTSTR) mir_alloc(sizeof(TCHAR) * 2); if (chr.cpMin) { - /* prepend nick with space if needed */ + // prepend nick with space if needed tr2.chrg.cpMin = chr.cpMin - 1; tr2.chrg.cpMax = chr.cpMin; SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2); @@ -2773,15 +2756,15 @@ LABEL_SHOWWINDOW: *tszTmp++ = _T(' '); _tcscpy(tszTmp, tr.lpstrText); } - else - /* in the beginning of the message window */ + else // in the beginning of the message window mir_sntprintf(tszAppeal, bufSize, tszAplTmpl, tr.lpstrText); + st = mir_tstrlen(tszAppeal); if (chr.cpMax != -1) { tr2.chrg.cpMin = chr.cpMax; tr2.chrg.cpMax = chr.cpMax + 1; - /* if there is no space after selection, - or there is nothing after selection at all... */ + // if there is no space after selection, + // or there is nothing after selection at all... if (!SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || !_istspace(*tr2.lpstrText)) { tszAppeal[st++] = _T(' '); tszAppeal[st++] = _T('\0'); @@ -2893,14 +2876,15 @@ LABEL_SHOWWINDOW: if (GetSendButtonState(hwndDlg) != PBS_DISABLED) { MODULEINFO *mi = pci->MM_FindModule(si->pszModule); - ptrA pszRtf(Chat_Message_GetFromStream(hwndDlg, si)); + ptrA pszRtf(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE))); pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf); - ptrT ptszText(Chat_DoRtfToTags(pszRtf, si)); - if (ptszText == NULL) + CMString ptszText(ptrT(mir_utf8decodeT(pszRtf))); + if (ptszText.IsEmpty()) break; - rtrimt(ptszText); + DoRtfToTags(si->dat, ptszText, mi->nColorCount, mi->crColors); + ptszText.Trim(); if (mi && mi->bAckMsg) { Utils::enableDlgControl(hwndDlg, IDC_CHAT_MESSAGE, false); @@ -2911,16 +2895,14 @@ LABEL_SHOWWINDOW: Utils::enableDlgControl(hwndDlg, IDOK, false); // Typing support for GCW_PRIVMESS sessions - if (si->iType == GCW_PRIVMESS) { - if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON) { + if (si->iType == GCW_PRIVMESS) + if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON) DM_NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF); - } - } bool fSound = true; if (ptszText[0] == '/' || si->iType == GCW_SERVER) fSound = false; - pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0); + pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText.GetBuffer(), 0); mi->idleTimeStamp = time(0); mi->lastIdleCheck = 0; pci->SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE); @@ -3323,12 +3305,10 @@ LABEL_SHOWWINDOW: dat->pContainer->iChilds--; int i = GetTabIndexFromHWND(hwndTab, hwndDlg); - /* - * after closing a tab, we need to activate the tab to the left side of - * the previously open tab. - * normally, this tab has the same index after the deletion of the formerly active tab - * unless, of course, we closed the last (rightmost) tab. - */ + // after closing a tab, we need to activate the tab to the left side of + // the previously open tab. + // normally, this tab has the same index after the deletion of the formerly active tab + // unless, of course, we closed the last (rightmost) tab. if (!dat->pContainer->bDontSmartClose && iTabs > 1 && !bForced) { if (i == iTabs - 1) i--; @@ -3336,10 +3316,10 @@ LABEL_SHOWWINDOW: i++; TabCtrl_SetCurSel(hwndTab, i); - TCITEM item = {0}; + TCITEM item = { 0 }; item.mask = TCIF_PARAM; - TabCtrl_GetItem(hwndTab, i, &item); // retrieve dialog hwnd for the now active tab... - dat->pContainer->hwndActive = (HWND) item.lParam; + TabCtrl_GetItem(hwndTab, i, &item); // retrieve dialog hwnd for the now active tab... + dat->pContainer->hwndActive = (HWND)item.lParam; SendMessage(dat->pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); SetWindowPos(dat->pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW); diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index f7240bbf3c..1d81ddf80b 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -287,7 +287,7 @@ void CContactCache::saveHistory(WPARAM wParam, LPARAM) m_iHistoryTop = (int)wParam; } - szFromStream = ::Message_GetFromStream(GetDlgItem(m_hwnd, IDC_MESSAGE), m_dat, (CP_UTF8 << 16) | (SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | SF_NCRFORNONASCII)); + szFromStream = ::Message_GetFromStream(GetDlgItem(m_hwnd, IDC_MESSAGE), SF_RTFNOOBJS | SFF_PLAINRTF | SF_NCRFORNONASCII); if (szFromStream != NULL) { iLength = iStreamLength = (strlen(szFromStream) + 1); diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index d2221afc73..a5d59698ad 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -796,7 +796,7 @@ void TSAPI DM_InitRichEdit(TWindowData *dat) COLORREF inputcharcolor; if (!fIsChat && GetWindowTextLength(hwndEdit) > 0) - szStreamOut = Message_GetFromStream(hwndEdit, dat, (CP_UTF8 << 16) | (SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE)); + szStreamOut = Message_GetFromStream(hwndEdit); SetWindowText(hwndEdit, _T("")); SendMessage(hwndLog, EM_SETBKGNDCOLOR, 0, colour); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 9bcfd2b3a2..717cfc28a8 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -40,6 +40,8 @@ static const UINT addControls[] = { IDC_ADD, IDC_CANCELADD }; static const UINT btnControls[] = { IDC_RETRY, IDC_CANCELSEND, IDC_MSGSENDLATER, IDC_ADD, IDC_CANCELADD }; static const UINT errorControls[] = { IDC_STATICERRORICON, IDC_STATICTEXT, IDC_RETRY, IDC_CANCELSEND, IDC_MSGSENDLATER}; +static COLORREF rtfDefColors[] = { RGB(255, 0, 0), RGB(0, 0, 255), RGB(0, 255, 0), RGB(255, 0, 255), RGB(255, 255, 0), RGB(0, 255, 255), 0, RGB(255, 255, 255) };
+ static struct { int id; const TCHAR* text; @@ -2016,9 +2018,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SETTEXTEX stx = {ST_KEEPUNDO | ST_SELECTION, CP_UTF8}; char *streamOut = NULL; if (isAlt) - streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), dat, (CP_UTF8 << 16) | (SF_RTFNOOBJS | SFF_PLAINRTF | SFF_SELECTION | SF_USECODEPAGE)); + streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_RTFNOOBJS | SFF_PLAINRTF | SFF_SELECTION); else - streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), dat, (CP_UTF8 << 16) | (SF_TEXT | SFF_SELECTION | SF_USECODEPAGE)); + streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_TEXT | SFF_SELECTION); if (streamOut) { Utils::FilterEventMarkers(streamOut); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)streamOut); @@ -2680,7 +2682,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (GetSendButtonState(hwndDlg) == PBS_DISABLED) break; - ptrA streamOut(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat, final_sendformat ? 0 : (CP_UTF8 << 16) | (SF_TEXT | SF_USECODEPAGE))); + ptrA streamOut(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), final_sendformat ? 0 : SF_TEXT)); if (streamOut == NULL) break; @@ -2690,7 +2692,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char *utfResult = NULL; if (final_sendformat) - DoRtfToTags(dat, decoded); + DoRtfToTags(dat, decoded, SIZEOF(rtfDefColors), rtfDefColors); decoded.Trim(); int bufSize = WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, 0, 0, 0); @@ -2743,7 +2745,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->sendMode & SMODE_CONTAINER && m_pContainer->hwndActive == hwndDlg && GetForegroundWindow() == hwndContainer) { int tabCount = TabCtrl_GetItemCount(hwndTab); - ptrA szFromStream(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat, dat->SendFormat ? 0 : (CP_UTF8 << 16) | (SF_TEXT | SF_USECODEPAGE))); + ptrA szFromStream(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->SendFormat ? 0 : SF_TEXT)); TCITEM tci = { 0 }; tci.mask = TCIF_PARAM; @@ -2859,7 +2861,7 @@ quote_from_last: mir_free(szConverted); } else { - ptrA szFromStream(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), dat, SF_TEXT | SF_USECODEPAGE | SFF_SELECTION)); + ptrA szFromStream(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_TEXT | SFF_SELECTION)); ptrW converted(mir_utf8decodeW(szFromStream)); Utils::FilterEventMarkers(converted); ptrT szQuoted(QuoteText(converted, iCharsPerLine, 0)); @@ -3255,7 +3257,7 @@ quote_from_last: LoadSkinnedProtoIcon(dat->cache->getActiveProto(), dat->cache->getActiveStatus()), 1, PluginConfig.g_hMenuRecent); if (dat->hContact) { if (!dat->fEditNotesActive) { - char *msg = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat, (CP_UTF8 << 16) | (SF_TEXT | SF_USECODEPAGE)); + char *msg = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), SF_TEXT); if (msg) { db_set_utf(dat->hContact, SRMSGMOD, "SavedMsg", msg); mir_free(msg); diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 5c223cbf5c..1a97906f1c 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -787,9 +787,12 @@ void TSAPI FlashOnClist(HWND hwndDlg, TWindowData *dat, MEVENT hEvent, DBEVENTIN }
/////////////////////////////////////////////////////////////////////////////////////////
-// callback function for text streaming
+// retrieve contents of the richedit control by streaming.Used to get the
+// typed message before sending it.
+// caller must mir_free the returned pointer.
+// UNICODE version returns UTF-8 encoded string.
-static DWORD CALLBACK Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
+static DWORD CALLBACK Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
static DWORD dwRead;
char **ppText = (char **)dwCookie;
@@ -812,30 +815,22 @@ static DWORD CALLBACK Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// retrieve contents of the richedit control by streaming.Used to get the
-// typed message before sending it.
-// caller must mir_free the returned pointer.
-// UNICODE version returns UTF-8 encoded string.
-
-char* TSAPI Message_GetFromStream(HWND hwndRtf, const TWindowData *dat, DWORD dwPassedFlags)
+char* TSAPI Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags)
{
- EDITSTREAM stream;
- char *pszText = NULL;
- DWORD dwFlags = 0;
-
- if (hwndRtf == 0 || dat == 0)
+ if (hwndRtf == 0)
return NULL;
- memset(&stream, 0, sizeof(stream));
- stream.pfnCallback = Message_StreamCallback;
- stream.dwCookie = (DWORD_PTR)& pszText; // pass pointer to pointer
+ DWORD dwFlags = (CP_UTF8 << 16) | SF_USECODEPAGE;
if (dwPassedFlags == 0)
- dwFlags = (CP_UTF8 << 16) | (SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE);
+ dwFlags |= (SF_RTFNOOBJS | SFF_PLAINRTF);
else
- dwFlags = (CP_UTF8 << 16) | dwPassedFlags;
- SendMessage(hwndRtf, EM_STREAMOUT, (WPARAM)dwFlags, (LPARAM)&stream);
+ dwFlags |= dwPassedFlags;
+ char *pszText = NULL;
+ EDITSTREAM stream = { 0 };
+ stream.pfnCallback = Message_StreamCallback;
+ stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
+ SendMessage(hwndRtf, EM_STREAMOUT, dwFlags, (LPARAM)&stream);
return pszText; // pszText contains the text
}
@@ -845,7 +840,50 @@ char* TSAPI Message_GetFromStream(HWND hwndRtf, const TWindowData *dat, DWORD dw static TCHAR tszRtfBreaks[] = _T(" \\\n\r");
-BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText)
+static void CreateColorMap(CMString &Text, int iCount, COLORREF *pSrc, int *pDst)
+{
+ const TCHAR *pszText = Text;
+ int iIndex = 1, i = 0;
+
+ static const TCHAR *lpszFmt = _T("\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];");
+ TCHAR szRed[10], szGreen[10], szBlue[10];
+
+ const TCHAR *p1 = _tcsstr(pszText, _T("\\colortbl"));
+ if (!p1)
+ return;
+
+ const TCHAR *pEnd = _tcschr(p1, '}');
+
+ const TCHAR *p2 = _tcsstr(p1, _T("\\red"));
+
+ for (i = 0; i < iCount; i++)
+ pDst[i] = -1;
+
+ while (p2 && p2 < pEnd) {
+ if (_stscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
+ for (int i = 0; i < iCount; i++) {
+ if (pSrc[i] == RGB(_ttoi(szRed), _ttoi(szGreen), _ttoi(szBlue)))
+ pDst[i] = iIndex;
+ }
+ }
+ iIndex++;
+ p1 = p2;
+ p1++;
+
+ p2 = _tcsstr(p1, _T("\\red"));
+ }
+}
+
+static int GetRtfIndex(int iCol, int iCount, int *pIndex)
+{
+ for (int i = 0; i < iCount; i++)
+ if (pIndex[i] == iCol)
+ return i;
+
+ return -1;
+}
+
+BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText, int iNumColors, COLORREF *pColors)
{
if (pszText.IsEmpty())
return FALSE;
@@ -855,23 +893,28 @@ BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText) // create an index of colors in the module and map them to
// corresponding colors in the RTF color table
- Utils::CreateColorMap(pszText);
+ int *pIndex = (int*)_alloca(iNumColors * sizeof(int));
+ CreateColorMap(pszText, iNumColors, pColors, pIndex);
// scan the file for rtf commands and remove or parse them
int idx = pszText.Find(_T("\\pard"));
- if (idx == -1)
- return FALSE;
+ if (idx == -1) {
+ if ((idx = pszText.Find(_T("\\ltrpar"))) == -1)
+ return FALSE;
+ idx += 7;
+ }
+ else idx += 5;
bool bInsideColor = false, bInsideUl = false;
CMString res;
// iterate through all characters, if rtf control character found then take action
- for (const TCHAR *p = pszText.GetString() + idx + 5; *p;) {
+ for (const TCHAR *p = pszText.GetString() + idx; *p;) {
switch (*p) {
case '\\':
if (!_tcsncmp(p, _T("\\cf"), 3)) { // foreground color
int iCol = _ttoi(p + 3);
- int iInd = Utils::RTFColorToIndex(iCol);
+ int iInd = GetRtfIndex(iCol, iNumColors, pIndex);
if (iCol)
res.AppendFormat((iInd > 0) ? (bInsideColor ? _T("[/color][color=%s]") : _T("[color=%s]")) : (bInsideColor ? _T("[/color]") : _T("")), Utils::rtf_ctable[iInd - 1].szName);
diff --git a/plugins/TabSRMM/src/msgdlgutils.h b/plugins/TabSRMM/src/msgdlgutils.h index 0503605e29..5ea784bd6b 100644 --- a/plugins/TabSRMM/src/msgdlgutils.h +++ b/plugins/TabSRMM/src/msgdlgutils.h @@ -44,8 +44,8 @@ void TSAPI ShowPicture(TWindowData *dat, BOOL showNewPic); void TSAPI AdjustBottomAvatarDisplay(TWindowData *dat);
void TSAPI SetDialogToType(HWND hwndDlg);
void TSAPI FlashOnClist(HWND hwndDlg, TWindowData *dat, MEVENT hEvent, DBEVENTINFO *dbei);
-char* TSAPI Message_GetFromStream(HWND hwndDlg, const TWindowData *dat, DWORD dwPassedFlags);
-BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText);
+char* TSAPI Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags = 0);
+BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText, int iNumColors, COLORREF *pColors);
void TSAPI GetMYUIN(TWindowData *dat);
void TSAPI SetMessageLog(TWindowData *dat);
void TSAPI SwitchMessageLog(TWindowData *dat, int iMode);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 5edd2a38b9..84d96a5fbe 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -36,6 +36,19 @@ typedef std::basic_string<TCHAR> tstring; #define MWF_LOG_TEXTFORMAT 0x2000000
#define MSGDLGFONTCOUNT 22
+static TRTFColorTable _rtf_ctable[] =
+{
+ { _T("red"), RGB(255, 0, 0), ID_FONT_RED },
+ { _T("blue"), RGB(0, 0, 255), ID_FONT_BLUE },
+ { _T("green"), RGB(0, 255, 0), ID_FONT_GREEN },
+ { _T("magenta"), RGB(255, 0, 255), ID_FONT_MAGENTA },
+ { _T("yellow"), RGB(255, 255, 0), ID_FONT_YELLOW },
+ { _T("cyan"), RGB(0, 255, 255), ID_FONT_CYAN },
+ { _T("black"), 0, ID_FONT_BLACK },
+ { _T("white"), RGB(255, 255, 255), ID_FONT_WHITE },
+ { _T(""), 0, 0 }
+};
+
int Utils::rtf_ctable_size = 0;
TRTFColorTable* Utils::rtf_ctable = 0;
@@ -538,56 +551,12 @@ void Utils::RTF_ColorAdd(const TCHAR *tszColname, size_t length) rtf_ctable = (TRTFColorTable *)mir_realloc(rtf_ctable, sizeof(TRTFColorTable) * rtf_ctable_size);
COLORREF clr = _tcstol(tszColname, &stopped, 16);
mir_sntprintf(rtf_ctable[rtf_ctable_size - 1].szName, length + 1, _T("%06x"), clr);
- rtf_ctable[rtf_ctable_size - 1].menuid = rtf_ctable[rtf_ctable_size - 1].index = 0;
+ rtf_ctable[rtf_ctable_size - 1].menuid = 0;
clr = _tcstol(tszColname, &stopped, 16);
rtf_ctable[rtf_ctable_size - 1].clr = (RGB(GetBValue(clr), GetGValue(clr), GetRValue(clr)));
}
-void Utils::CreateColorMap(CMString &Text)
-{
- const TCHAR *pszText = Text;
- int iIndex = 1, i = 0;
-
- static const TCHAR *lpszFmt = _T("\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];");
- TCHAR szRed[10], szGreen[10], szBlue[10];
-
- const TCHAR *p1 = _tcsstr(pszText, _T("\\colortbl"));
- if (!p1)
- return;
-
- const TCHAR *pEnd = _tcschr(p1, '}');
-
- const TCHAR *p2 = _tcsstr(p1, _T("\\red"));
-
- for (i=0; i < RTF_CTABLE_DEFSIZE; i++)
- rtf_ctable[i].index = 0;
-
- while (p2 && p2 < pEnd) {
- if (_stscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
- int i;
- for (i=0; i < RTF_CTABLE_DEFSIZE; i++) {
- if (rtf_ctable[i].clr == RGB(_ttoi(szRed), _ttoi(szGreen), _ttoi(szBlue)))
- rtf_ctable[i].index = iIndex;
- }
- }
- iIndex++;
- p1 = p2;
- p1 ++;
-
- p2 = _tcsstr(p1, _T("\\red"));
- }
-}
-
-int Utils::RTFColorToIndex(int iCol)
-{
- for (int i=0; i < RTF_CTABLE_DEFSIZE; i++)
- if (rtf_ctable[i].index == iCol)
- return i + 1;
-
- return 0;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// generic error popup dialog procedure
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index f86e54b8b9..4e210597b3 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -38,22 +38,9 @@ struct TRTFColorTable
{
- TCHAR szName[10];
- COLORREF clr;
- int index;
- int menuid;
-};
-
-static TRTFColorTable _rtf_ctable[] = {
- _T("red"), RGB(255, 0, 0), 0, ID_FONT_RED,
- _T("blue"), RGB(0, 0, 255), 0, ID_FONT_BLUE,
- _T("green"), RGB(0, 255, 0), 0, ID_FONT_GREEN,
- _T("magenta"), RGB(255, 0, 255), 0, ID_FONT_MAGENTA,
- _T("yellow"), RGB(255, 255, 0), 0, ID_FONT_YELLOW,
- _T("cyan"), RGB(0, 255, 255), 0, ID_FONT_CYAN,
- _T("black"), 0, 0, ID_FONT_BLACK,
- _T("white"), RGB(255, 255, 255), 0, ID_FONT_WHITE,
- _T(""), 0, 0, 0
+ TCHAR szName[10];
+ COLORREF clr;
+ int menuid;
};
class Utils {
@@ -74,8 +61,6 @@ public: static LPCTSTR DoubleAmpersands(TCHAR *pszText);
static void RTF_CTableInit();
static void RTF_ColorAdd(const TCHAR *tszColname, size_t length);
- static void CreateColorMap(CMString &Text);
- static int RTFColorToIndex(int iCol);
static int ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey = 0);
static int WriteContainerSettingsToDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey = 0);
static void SettingsToContainer(TContainerData *pContainer);
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h index dc88e85401..dbc32d2397 100644 --- a/plugins/TabSRMM/src/version.h +++ b/plugins/TabSRMM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 8
+#define __BUILD_NUM 9
#include <stdver.h>
diff --git a/plugins/TabSRMM/tabsrmm_10.vcxproj b/plugins/TabSRMM/tabsrmm_10.vcxproj index 8738c1763b..796dc35e54 100644 --- a/plugins/TabSRMM/tabsrmm_10.vcxproj +++ b/plugins/TabSRMM/tabsrmm_10.vcxproj @@ -203,9 +203,6 @@ <ClCompile Include="src\chat\manager.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="src\chat\message.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\muchighlight.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/TabSRMM/tabsrmm_10.vcxproj.filters b/plugins/TabSRMM/tabsrmm_10.vcxproj.filters index 6a9f205fce..9920aa2411 100644 --- a/plugins/TabSRMM/tabsrmm_10.vcxproj.filters +++ b/plugins/TabSRMM/tabsrmm_10.vcxproj.filters @@ -27,9 +27,6 @@ <ClCompile Include="src\chat\manager.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
- <ClCompile Include="src\chat\message.cpp">
- <Filter>Source Files\Chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\muchighlight.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
diff --git a/plugins/TabSRMM/tabsrmm_12.vcxproj b/plugins/TabSRMM/tabsrmm_12.vcxproj index ae1a997668..da067e21fa 100644 --- a/plugins/TabSRMM/tabsrmm_12.vcxproj +++ b/plugins/TabSRMM/tabsrmm_12.vcxproj @@ -206,9 +206,6 @@ <ClCompile Include="src\chat\manager.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="src\chat\message.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\muchighlight.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/TabSRMM/tabsrmm_12.vcxproj.filters b/plugins/TabSRMM/tabsrmm_12.vcxproj.filters index 1ce38ff7fc..2dda328e45 100644 --- a/plugins/TabSRMM/tabsrmm_12.vcxproj.filters +++ b/plugins/TabSRMM/tabsrmm_12.vcxproj.filters @@ -27,9 +27,6 @@ <ClCompile Include="src\chat\manager.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
- <ClCompile Include="src\chat\message.cpp">
- <Filter>Source Files\Chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\muchighlight.cpp">
<Filter>Source Files\Chat</Filter>
</ClCompile>
|