From 4770a5e9184ded282139e66782afdd6d04010ee5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Dec 2016 20:27:43 +0300 Subject: common chat code moved to the core --- plugins/Scriver/src/chat/main.cpp | 19 ------------------- plugins/Scriver/src/chat/window.cpp | 8 +------- plugins/TabSRMM/src/chat/chat.h | 30 ++++++++++++++---------------- plugins/TabSRMM/src/chat/main.cpp | 19 ------------------- plugins/TabSRMM/src/chat/muchighlight.cpp | 8 ++++---- plugins/TabSRMM/src/chat/muchighlight.h | 2 +- plugins/TabSRMM/src/chat/tools.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 8 +------- 8 files changed, 22 insertions(+), 74 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp index b0379b0743..7e2ff29318 100644 --- a/plugins/Scriver/src/chat/main.cpp +++ b/plugins/Scriver/src/chat/main.cpp @@ -45,14 +45,6 @@ void LoadModuleIcons(MODULEINFO *mi) ImageList_Destroy(hList); } -static void OnAddLog(SESSION_INFO *si, int isOk) -{ - if (isOk && si->hWnd) - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - else if (si->hWnd) - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); -} - static void OnDblClickSession(SESSION_INFO *si) { PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0); @@ -76,14 +68,6 @@ static void OnReplaceSession(SESSION_INFO *si) RedrawWindow(GetDlgItem(si->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE); } -static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce) -{ - if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone) - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - else if (si->hWnd && si->bInitDone) - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); -} - static void OnSetStatusBar(SESSION_INFO *si) { if (si->hWnd) @@ -164,14 +148,11 @@ int Chat_Load() pci->OnSetStatus = OnSetStatus; - pci->OnAddLog = OnAddLog; - pci->OnRemoveSession = OnRemoveSession; pci->OnRenameSession = OnRenameSession; pci->OnReplaceSession = OnReplaceSession; pci->OnDblClickSession = OnDblClickSession; - pci->OnEventBroadcast = OnEventBroadcast; pci->OnSetStatusBar = OnSetStatusBar; pci->OnFlashWindow = OnFlashWindow; pci->OnFlashHighlight = OnFlashHighlight; diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 8c503be2c7..f65ec5a5f5 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -903,7 +903,7 @@ static void __cdecl phase2(void *lParam) SESSION_INFO *si = (SESSION_INFO*)lParam; Sleep(30); if (si && si->hWnd) - PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0); + PostMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); } static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -1140,12 +1140,6 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); break; - case GC_REDRAWLOG3: - si->LastTime = 0; - if (si->pLog) - Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); - break; - case GC_ADDLOG: if (si->pLogEnd) Log_StreamInEvent(hwndDlg, si->pLog, si, FALSE); diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index d85b8986a6..9c813ccb7f 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -139,22 +139,20 @@ BOOL SM_ReconfigureFilters(); int UM_CompareItem(USERINFO *u1, const wchar_t* pszNick, WORD wStatus); -//clist.c - -//tools.c -BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix); -int Chat_GetColorIndex(const char* pszModule, COLORREF cr); -wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2); -int GetRichTextLength(HWND hwnd); -BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText); -char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex); -UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText); -void DestroyGCMenu(HMENU *hMenu, int iIndex); -void Chat_SetFilters(SESSION_INFO *si); -void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p); -BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce); -int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...); -BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce); +// tools.c +BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix); +int Chat_GetColorIndex(const char* pszModule, COLORREF cr); +wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2); +int GetRichTextLength(HWND hwnd); +bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText); +char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex); +UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText); +void DestroyGCMenu(HMENU *hMenu, int iIndex); +void Chat_SetFilters(SESSION_INFO *si); +void DoFlashAndSoundWorker(FLASH_PARAMS* p); +BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce); +int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...); +BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce); #include "chat_resource.h" diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index e55c8d3082..a7c5d17be8 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -34,14 +34,6 @@ HMENU g_hMenu = NULL; CHAT_MANAGER *pci; TMUCSettings g_Settings; -static void OnAddLog(SESSION_INFO *si, int isOk) -{ - if (isOk && si->hWnd) - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - else if (si->hWnd) - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); -} - static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi) { si->bFilterEnabled = db_get_b(si->hContact, "Chat", "FilterEnabled", M.GetByte("Chat", "FilterEnabled", 0)); @@ -78,14 +70,6 @@ static void OnReplaceSession(SESSION_INFO *si) RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE); } -static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce) -{ - if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone) - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - else if (si->hWnd && si->bInitDone) - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); -} - static void OnSetTopic(SESSION_INFO *si) { if (si->hWnd) @@ -273,15 +257,12 @@ int Chat_Load() pci->OnSetStatus = OnSetStatus; pci->OnSetTopic = OnSetTopic; - pci->OnAddLog = OnAddLog; - pci->OnCreateSession = OnCreateSession; pci->OnRemoveSession = OnRemoveSession; pci->OnRenameSession = OnRenameSession; pci->OnReplaceSession = OnReplaceSession; pci->OnDblClickSession = OnDblClickSession; - pci->OnEventBroadcast = OnEventBroadcast; pci->OnSetStatusBar = OnSetStatusBar; pci->OnChangeNick = OnChangeNick; pci->ShowRoom = ShowRoom; diff --git a/plugins/TabSRMM/src/chat/muchighlight.cpp b/plugins/TabSRMM/src/chat/muchighlight.cpp index 441183f454..9bba67c75a 100644 --- a/plugins/TabSRMM/src/chat/muchighlight.cpp +++ b/plugins/TabSRMM/src/chat/muchighlight.cpp @@ -110,18 +110,18 @@ void CMUCHighlight::tokenize(wchar_t *tszString, wchar_t**& patterns, UINT& nr) } } -int CMUCHighlight::match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dwFlags) +bool CMUCHighlight::match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dwFlags) { int result = 0, nResult = 0; if (pgce == 0 || m_Valid == false) - return 0; + return false; if ((m_dwFlags & MATCH_TEXT) && (dwFlags & MATCH_TEXT) && (m_fHighlightMe || m_iTextPatterns > 0) && psi != 0) { wchar_t *p = pci->RemoveFormatting(pgce->ptszText); p = NEWWSTR_ALLOCA(p); if (p == NULL) - return 0; + return false; CharLower(p); wchar_t *tszMe = ((psi && psi->pMe) ? NEWWSTR_ALLOCA(psi->pMe->pszNick) : 0); @@ -173,7 +173,7 @@ skip_textpatterns: } } - return(result | nResult); + return result || nResult; } /** diff --git a/plugins/TabSRMM/src/chat/muchighlight.h b/plugins/TabSRMM/src/chat/muchighlight.h index 5f8533868e..013341c37e 100644 --- a/plugins/TabSRMM/src/chat/muchighlight.h +++ b/plugins/TabSRMM/src/chat/muchighlight.h @@ -54,7 +54,7 @@ public: void init(); void cleanup(); - int match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dwFlags = MATCH_NICKNAME); + bool match(const GCEVENT *pgce, const SESSION_INFO *psi, DWORD dwFlags = MATCH_NICKNAME); static INT_PTR CALLBACK dlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); // option page dlg proc static INT_PTR CALLBACK dlgProcAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); // for the "add to" dialog diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 55d6578512..0b0f309a6f 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -671,7 +671,7 @@ char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex) return 0; } -BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce) +bool IsHighlighted(SESSION_INFO *si, GCEVENT *gce) { if (!g_Settings.bHighlightEnabled || !gce || gce->bIsMe) return FALSE; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 67d25d9174..abde116c23 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1562,7 +1562,7 @@ static void __cdecl phase2(void * lParam) SESSION_INFO *si = (SESSION_INFO*)lParam; Sleep(30); if (si && si->hWnd) - PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0); + PostMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1910,12 +1910,6 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); break; - case GC_REDRAWLOG3: - si->LastTime = 0; - if (si->pLog) - Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); - break; - case GC_ADDLOG: if (g_Settings.bUseDividers && g_Settings.bDividersUsePopupConfig) { if (!MessageWindowOpened(0, (LPARAM)hwndDlg)) -- cgit v1.2.3