diff options
-rw-r--r-- | include/m_chat_int.h | 8 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 106114 -> 106654 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 101568 -> 102060 bytes | |||
-rw-r--r-- | plugins/Scriver/src/chat/log.cpp | 28 | ||||
-rw-r--r-- | plugins/Scriver/src/utils.cpp | 28 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat.h | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_log.cpp | 31 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_main.cpp | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 25 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_util.cpp | 60 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/srmm_util.cpp | 74 |
13 files changed, 95 insertions, 165 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 1342e2b591..7b2b0c35b1 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -410,6 +410,14 @@ EXTERN_C MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pDa /////////////////////////////////////////////////////////////////////////////////////////
+// receives LOGSTREAMDATA* as the first parameter
+EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
+
+// receives char** as the first parameter
+EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_MessageStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase
{
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 635b465d5f..37217195ba 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 20a5dae756..adc426b0eb 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp index c3c716981d..ded37a01bc 100644 --- a/plugins/Scriver/src/chat/log.cpp +++ b/plugins/Scriver/src/chat/log.cpp @@ -25,32 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EM_GETSCROLLPOS (WM_USER+221)
#endif
-static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
-{
- LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA*)dwCookie;
- if (lstrdat) {
- // create the RTF
- if (lstrdat->buffer == nullptr) {
- lstrdat->bufferOffset = 0;
- lstrdat->buffer = pci->Log_CreateRTF(lstrdat);
- lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer);
- }
-
- // give the RTF to the RE control
- *pcb = min(cb, LONG(lstrdat->bufferLen - lstrdat->bufferOffset));
- memcpy(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
- lstrdat->bufferOffset += *pcb;
-
- // free stuff if the streaming operation is complete
- if (lstrdat->bufferOffset == lstrdat->bufferLen) {
- mir_free(lstrdat->buffer);
- lstrdat->buffer = nullptr;
- }
- }
-
- return 0;
-}
-
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw)
{
if (hwndDlg == 0 || lin == 0 || si == 0)
@@ -72,7 +46,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra streamData.isFirst = bRedraw ? 1 : (GetRichTextLength(hwndRich, CP_ACP, FALSE) == 0);
EDITSTREAM stream = { 0 };
- stream.pfnCallback = Log_StreamCallback;
+ stream.pfnCallback = Srmm_LogStreamCallback;
stream.dwCookie = (DWORD_PTR)&streamData;
SCROLLINFO scroll;
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index f15c4d957e..9fa78c4ecf 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -101,32 +101,6 @@ int SetRichTextRTF(HWND hwnd, const char *text) return GetRichTextLength(hwnd, 1200, FALSE);
}
-static DWORD CALLBACK RichTextStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
-{
- static DWORD dwRead;
- char **ppText = (char**)dwCookie;
-
- if (*ppText == nullptr) {
- *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* GetRichTextRTF(HWND hwnd)
{
if (hwnd == 0)
@@ -134,7 +108,7 @@ char* GetRichTextRTF(HWND hwnd) char *pszText = nullptr;
EDITSTREAM stream = { 0 };
- stream.pfnCallback = RichTextStreamCallback;
+ stream.pfnCallback = Srmm_MessageStreamCallback;
stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
SendMessage(hwnd, EM_STREAMOUT, SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16), (LPARAM)&stream);
return pszText; // pszText contains the text
diff --git a/plugins/TabSRMM/src/chat.h b/plugins/TabSRMM/src/chat.h index 9551527c54..0fdd8849c0 100644 --- a/plugins/TabSRMM/src/chat.h +++ b/plugins/TabSRMM/src/chat.h @@ -101,6 +101,7 @@ extern CHAT_MANAGER saveCI; // log.c
char* Log_CreateRtfHeader(MODULEINFO *mi);
+char* Log_CreateRTF(LOGSTREAMDATA *streamData);
// window.c
int GetTextPixelSize(wchar_t* pszText, HFONT hFont, bool bWidth);
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index 38d6a0d134..e598846f4d 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -696,7 +696,7 @@ char* Log_CreateRtfHeader(MODULEINFO *mi) return str.Detach();
}
-static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
+char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
LOGINFO *lin = streamData->lin;
MODULEINFO *mi = pci->MM_FindModule(streamData->si->pszModule);
@@ -830,33 +830,6 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) return str.Detach();
}
-static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
-{
- LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA*)dwCookie;
-
- if (lstrdat) {
- // create the RTF
- if (lstrdat->buffer == nullptr) {
- lstrdat->bufferOffset = 0;
- lstrdat->buffer = Log_CreateRTF(lstrdat);
- lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer);
- }
-
- // give the RTF to the RE control
- *pcb = min(cb, lstrdat->bufferLen - lstrdat->bufferOffset);
- memcpy(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
- lstrdat->bufferOffset += *pcb;
-
- // mir_free stuff if the streaming operation is complete
- if (lstrdat->bufferOffset == lstrdat->bufferLen) {
- mir_free(lstrdat->buffer);
- lstrdat->buffer = nullptr;
- }
- }
-
- return 0;
-}
-
void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw)
{
CHARRANGE oldsel, sel, newsel;
@@ -881,7 +854,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) bool bFlag = false, fDoReplace;
EDITSTREAM stream = { 0 };
- stream.pfnCallback = Log_StreamCallback;
+ stream.pfnCallback = Srmm_LogStreamCallback;
stream.dwCookie = (DWORD_PTR)& streamData;
SCROLLINFO scroll = { 0 };
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 570dd311be..31aed38421 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -235,6 +235,7 @@ int Chat_Load() pci->LogToFile = LogToFile;
pci->DoPopup = DoPopup;
pci->ShowPopup = ShowPopup;
+ pci->Log_CreateRTF = Log_CreateRTF;
pci->Log_CreateRtfHeader = Log_CreateRtfHeader;
pci->UM_CompareItem = UM_CompareItem;
pci->ReloadSettings();
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index cd1a49147b..30c5fff688 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -764,29 +764,6 @@ void CTabBaseDlg::FlashOnClist(MEVENT hEvent, DBEVENTINFO *dbei) // 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 dwRead;
- char **ppText = (char **)dwCookie;
-
- if (*ppText == nullptr) {
- *ppText = (char *)mir_alloc(cb + 2);
- memcpy(*ppText, pbBuff, cb);
- *pcb = cb;
- dwRead = cb;
- *(*ppText + cb) = '\0';
- }
- else {
- char *p = (char *)mir_realloc(*ppText, dwRead + cb + 2);
- memcpy(p + dwRead, pbBuff, cb);
- *ppText = p;
- *pcb = cb;
- dwRead += cb;
- *(*ppText + dwRead) = '\0';
- }
- return 0;
-}
-
char* TSAPI Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags)
{
if (hwndRtf == 0)
@@ -800,7 +777,7 @@ char* TSAPI Message_GetFromStream(HWND hwndRtf, DWORD dwPassedFlags) char *pszText = nullptr;
EDITSTREAM stream = { 0 };
- stream.pfnCallback = Message_StreamCallback;
+ stream.pfnCallback = Srmm_MessageStreamCallback;
stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
SendMessage(hwndRtf, EM_STREAMOUT, dwFlags, (LPARAM)&stream);
return pszText; // pszText contains the text
diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp index 00dfb9a49a..26d8f37f12 100644 --- a/src/core/stdmsg/src/chat_util.cpp +++ b/src/core/stdmsg/src/chat_util.cpp @@ -21,36 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" - -// The code for streaming the text is to a large extent copied from -// the srmm module and then modified to fit the chat module. - -static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) -{ - LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA*)dwCookie; - if (lstrdat) { - // create the RTF - if (lstrdat->buffer == NULL) { - lstrdat->bufferOffset = 0; - lstrdat->buffer = pci->Log_CreateRTF(lstrdat); - lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer); - } - - // give the RTF to the RE control - *pcb = min(cb, lstrdat->bufferLen - lstrdat->bufferOffset); - memcpy(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb); - lstrdat->bufferOffset += *pcb; - - // free stuff if the streaming operation is complete - if (lstrdat->bufferOffset == lstrdat->bufferLen) { - mir_free(lstrdat->buffer); - lstrdat->buffer = NULL; - } - } - - return 0; -} - void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw) { if (hwndDlg == 0 || lin == 0 || si == 0) @@ -71,7 +41,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra BOOL bFlag = FALSE; EDITSTREAM stream = {}; - stream.pfnCallback = Log_StreamCallback; + stream.pfnCallback = Srmm_LogStreamCallback; stream.dwCookie = (DWORD_PTR)& streamData; SCROLLINFO scroll; @@ -156,32 +126,6 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra ///////////////////////////////////////////////////////////////////////////////////////// -static DWORD CALLBACK 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* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si) { if (hwndDlg == 0 || si == 0) @@ -190,7 +134,7 @@ char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si) char* pszText = NULL; EDITSTREAM stream; memset(&stream, 0, sizeof(stream)); - stream.pfnCallback = Message_StreamCallback; + stream.pfnCallback = Srmm_MessageStreamCallback; stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer DWORD dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 58a81567f4..e725d21d0f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -408,3 +408,5 @@ ProtoGetAvatarMimeType @401 ??2CSrmmBaseDialog@@SAPAXI@Z @409 NONAME
??3CSrmmBaseDialog@@SAXPAX@Z @410 NONAME
?isChat@CSrmmBaseDialog@@QBE_NXZ @411 NONAME
+Srmm_LogStreamCallback @412
+Srmm_MessageStreamCallback @413
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 4616073840..b23014f010 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -408,3 +408,5 @@ ProtoGetAvatarMimeType @401 ??2CSrmmBaseDialog@@SAPEAX_K@Z @409 NONAME
??3CSrmmBaseDialog@@SAXPEAX@Z @410 NONAME
?isChat@CSrmmBaseDialog@@QEBA_NXZ @411 NONAME
+Srmm_LogStreamCallback @412
+Srmm_MessageStreamCallback @413
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp new file mode 100644 index 0000000000..78ed59e436 --- /dev/null +++ b/src/mir_app/src/srmm_util.cpp @@ -0,0 +1,74 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-17 Miranda NG 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. +*/ + +#include "stdafx.h" +#include "chat.h" + +MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb) +{ + LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA*)dwCookie; + if (lstrdat) { + // create the RTF + if (lstrdat->buffer == nullptr) { + lstrdat->bufferOffset = 0; + lstrdat->buffer = chatApi.Log_CreateRTF(lstrdat); + lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer); + } + + // give the RTF to the RE control + *pcb = min(cb, LONG(lstrdat->bufferLen - lstrdat->bufferOffset)); + memcpy(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb); + lstrdat->bufferOffset += *pcb; + + // free stuff if the streaming operation is complete + if (lstrdat->bufferOffset == lstrdat->bufferLen) { + mir_free(lstrdat->buffer); + lstrdat->buffer = nullptr; + } + } + + return 0; +} + +MIR_APP_DLL(DWORD) CALLBACK Srmm_MessageStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) +{ + static DWORD dwRead; + char **ppText = (char **)dwCookie; + + if (*ppText == nullptr) { + *ppText = (char *)mir_alloc(cb + 2); + memcpy(*ppText, pbBuff, cb); + *pcb = cb; + dwRead = cb; + *(*ppText + cb) = '\0'; + } + else { + char *p = (char *)mir_realloc(*ppText, dwRead + cb + 2); + memcpy(p + dwRead, pbBuff, cb); + *ppText = p; + *pcb = cb; + dwRead += cb; + *(*ppText + dwRead) = '\0'; + } + return 0; +} |