diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-13 20:27:43 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-13 20:27:43 +0300 |
commit | 4770a5e9184ded282139e66782afdd6d04010ee5 (patch) | |
tree | 685c8ec059777d343b14812dd6bb748422ed2ee8 | |
parent | bc382bfeb00236e2dbbb143cfe35dd3716a2f7e2 (diff) |
common chat code moved to the core
-rw-r--r-- | include/m_chat_int.h | 6 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/main.cpp | 19 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 30 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 19 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/muchighlight.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/muchighlight.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 8 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 18 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_util.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 117 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 3 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 23 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 2 |
17 files changed, 99 insertions, 173 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index bf84cd85d2..1aa18d7b4e 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -70,7 +70,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GC_SETTABHIGHLIGHT (WM_USER+138)
#define GC_SETMESSAGEHIGHLIGHT (WM_USER+139)
#define GC_REDRAWLOG2 (WM_USER+140)
-#define GC_REDRAWLOG3 (WM_USER+141)
#define TIMERID_FLASHWND 1
@@ -309,7 +308,6 @@ struct CHAT_MANAGER SESSION_INFO* (*GetActiveSession)(void);
SESSION_INFO* (*SM_FindSession)(const wchar_t *pszID, const char *pszModule);
HICON (*SM_GetStatusIcon)(SESSION_INFO *si, USERINFO * ui);
- BOOL (*SM_AddEvent)(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted);
BOOL (*SM_PostMessage)(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL (*SM_BroadcastMessage)(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync);
void (*SM_AddCommand)(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand);
@@ -372,7 +370,7 @@ struct CHAT_MANAGER int (*GetColorIndex)(const char *pszModule, COLORREF cr);
char* (*Log_SetStyle)(int style);
- BOOL (*IsHighlighted)(SESSION_INFO *si, GCEVENT *pszText);
+ bool (*IsHighlighted)(SESSION_INFO *si, GCEVENT *pszText);
wchar_t* (*RemoveFormatting)(const wchar_t *pszText);
void (*ReloadSettings)(void);
@@ -401,7 +399,7 @@ struct CHAT_MANAGER void (*OnReplaceSession)(SESSION_INFO*);
void (*ShowRoom)(SESSION_INFO*, WPARAM wp, BOOL bSetForeground);
- void (*OnAddLog)(SESSION_INFO*, int);
+ void (*OnAddLog)(SESSION_INFO*);
void (*OnClearLog)(SESSION_INFO*);
void (*OnGetLogName)(SESSION_INFO*, const wchar_t*);
void (*OnEventBroadcast)(SESSION_INFO *si, GCEVENT *gce);
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)) diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index a32ffae315..d22366faff 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -149,17 +149,11 @@ static void OnCreateModule(MODULEINFO *mi) ImageList_AddIcon(hIconsList, mi->hOfflineTalkIcon); } -static void OnAddLog(SESSION_INFO *si, int isOk) +static void OnAddLog(SESSION_INFO *si) { - if (isOk && si->hWnd) { - g_TabSession.pLog = si->pLog; - g_TabSession.pLogEnd = si->pLogEnd; - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - } - else if (si->hWnd) { + if (si->hWnd) { g_TabSession.pLog = si->pLog; g_TabSession.pLogEnd = si->pLogEnd; - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); } } @@ -224,15 +218,9 @@ static void OnOfflineSession(SESSION_INFO *si) static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce) { - if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone) { - g_TabSession.pLog = si->pLog; - g_TabSession.pLogEnd = si->pLogEnd; - SendMessage(si->hWnd, GC_ADDLOG, 0, 0); - } - else if (si->hWnd && si->bInitDone) { + if (si->hWnd && si->bInitDone) { g_TabSession.pLog = si->pLog; g_TabSession.pLogEnd = si->pLogEnd; - SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); } } diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp index 39521530b6..566c29f442 100644 --- a/src/core/stdmsg/src/chat_util.cpp +++ b/src/core/stdmsg/src/chat_util.cpp @@ -51,7 +51,7 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG return 0; } -void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw, BOOL) +void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw) { if (hwndDlg == 0 || lin == 0 || si == 0) return; diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 30f03c8421..c257c2c1a4 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -216,6 +216,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { SESSION_INFO *Parentsi = (SESSION_INFO*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); MESSAGESUBDATA *dat = (MESSAGESUBDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + CHARRANGE sel; switch (msg) { case EM_SUBCLASSED: @@ -269,8 +270,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } } } - else - dat->lastEnterTime = 0; + else dat->lastEnterTime = 0; if (wParam == 1 && isCtrl && !isAlt) { //ctrl-a SendMessage(hwnd, EM_SETSEL, 0, -1); @@ -526,8 +526,8 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return TRUE; } } - //fall through - + + // fall through case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_KILLFOCUS: @@ -536,7 +536,6 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_RBUTTONDOWN: { - CHARRANGE sel, all = { 0, -1 }; HMENU hSubMenu = GetSubMenu(g_hMenu, 4); TranslateMenu(hSubMenu); SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); @@ -553,6 +552,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, pt.y = (short)HIWORD(lParam); ClientToScreen(hwnd, &pt); + CHARRANGE all = { 0, -1 }; UINT uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); switch (uID) { case 0: @@ -579,7 +579,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case ID_MESSAGE_SELECTALL: - SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)& all); + SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&all); break; case ID_MESSAGE_CLEAR: @@ -761,9 +761,10 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + CHARRANGE sel; + switch (msg) { case WM_LBUTTONUP: - CHARRANGE sel; SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin != sel.cpMax) { SendMessage(hwnd, WM_COPY, 0, 0); @@ -810,18 +811,14 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); if (DragDetect(hwnd, tci.pt) && TabCtrl_GetItemCount(hwnd) > 1) { - int i; tci.flags = TCHT_ONITEM; - ScreenToClient(hwnd, &tci.pt); - i = TabCtrl_HitTest(hwnd, &tci); + int i = TabCtrl_HitTest(hwnd, &tci); if (i != -1) { TCITEM tc; - SESSION_INFO *s = NULL; - tc.mask = TCIF_PARAM; TabCtrl_GetItem(hwnd, i, &tc); - s = (SESSION_INFO*)tc.lParam; + SESSION_INFO *s = (SESSION_INFO*)tc.lParam; if (s) { BOOL bOnline = db_get_w(s->hContact, s->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE ? TRUE : FALSE; MODULEINFO *mi = pci->MM_FindModule(s->pszModule); @@ -873,7 +870,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_LBUTTONDBLCLK: { - TCHITTESTINFO tci = { 0 }; + TCHITTESTINFO tci = {}; tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); tci.flags = TCHT_ONITEM; @@ -886,7 +883,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break; case WM_MBUTTONUP: - TCHITTESTINFO tci = { 0 }; + TCHITTESTINFO tci = {}; tci.pt.x = (short)LOWORD(GetMessagePos()); tci.pt.y = (short)HIWORD(GetMessagePos()); tci.flags = TCHT_ONITEM; @@ -1067,13 +1064,14 @@ 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); } INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { SESSION_INFO *s, *si = (SESSION_INFO*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); RECT rc; + CHARRANGE sel; switch (uMsg) { case WM_INITDIALOG: @@ -1112,7 +1110,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (g_Settings.bTabsEnable && g_Settings.TabRestore) { TABLIST *node = g_TabList; while (node) { - SESSION_INFO *s = pci->SM_FindSession(node->pszID, node->pszModule); + s = pci->SM_FindSession(node->pszID, node->pszModule); if (s) SendMessage(hwndDlg, GC_ADDTAB, -1, (LPARAM)s); @@ -1133,10 +1131,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case GC_SETWNDPROPS: + InitButtons(hwndDlg, si); { - InitButtons(hwndDlg, si); - - // stupid hack to make icons show. I dunno why this is needed currently MODULEINFO *mi = pci->MM_FindModule(si->pszModule); HICON hIcon = si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon; if (!hIcon) { @@ -1334,10 +1330,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags&pLog->iType) != 0) index++; } - Log_StreamInEvent(hwndDlg, pLog, si, TRUE, FALSE); + Log_StreamInEvent(hwndDlg, pLog, si, TRUE); mir_forkthread(phase2, si); } - else Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE, FALSE); + else Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); } else SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); break; @@ -1345,18 +1341,12 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case GC_REDRAWLOG2: si->LastTime = 0; if (si->pLog) - Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE, FALSE); - break; - - case GC_REDRAWLOG3: - si->LastTime = 0; - if (si->pLog) - Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE, TRUE); + Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE); break; case GC_ADDLOG: if (si->pLogEnd) - Log_StreamInEvent(hwndDlg, si->pLog, si, FALSE, FALSE); + Log_StreamInEvent(hwndDlg, si->pLog, si, FALSE); else SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); break; @@ -1423,7 +1413,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } else i = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB)); - END_REMOVETAB: +END_REMOVETAB: if (i != -1 && i < tabId) { TCITEM id = { 0 }; TabCtrl_DeleteItem(GetDlgItem(hwndDlg, IDC_TAB), i); @@ -1435,7 +1425,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } } - SESSION_INFO *s = (SESSION_INFO*)id.lParam; + s = (SESSION_INFO*)id.lParam; if (s) pci->ShowRoom(s, (WPARAM)WINDOW_VISIBLE, wParam == 1 ? FALSE : TRUE); } @@ -1586,7 +1576,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TCITEM id = { 0 }; id.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id); - SESSION_INFO *s = (SESSION_INFO*)id.lParam; + s = (SESSION_INFO*)id.lParam; if (s) { if (s->wState & STATE_TALK) { s->wState &= ~STATE_TALK; @@ -1887,7 +1877,6 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar scroll.nPos = scroll.nMax - scroll.nPage + 1; SetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &scroll, TRUE); - CHARRANGE sel; sel.cpMin = sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG)); SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)&sel); PostMessage(GetDlgItem(hwndDlg, IDC_LOG), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); @@ -1920,7 +1909,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &tci); - SESSION_INFO *s = (SESSION_INFO*)tci.lParam; + s = (SESSION_INFO*)tci.lParam; if (s) { s->wState &= ~GC_EVENT_HIGHLIGHT; s->wState &= ~STATE_TALK; @@ -1962,11 +1951,12 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TCITEM id = { 0 }; id.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id); - SESSION_INFO *s = (SESSION_INFO*)id.lParam; ClientToScreen(GetDlgItem(hwndDlg, IDC_TAB), &tci.pt); HMENU hSubMenu = GetSubMenu(g_hMenu, 5); TranslateMenu(hSubMenu); + + s = (SESSION_INFO*)id.lParam; if (s) { WORD w = db_get_w(s->hContact, s->pszModule, "TabPosition", 0); if (w == 0) @@ -2018,19 +2008,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case EN_MSGFILTER: if (((LPNMHDR)lParam)->idFrom == IDC_LOG && ((MSGFILTER *)lParam)->msg == WM_RBUTTONUP) { - CHARRANGE sel, all = { 0, -1 }; - POINT pt; - UINT uID = 0; - HMENU hMenu = 0; - wchar_t pszWord[4096]; - - pt.x = (short)LOWORD(((ENLINK *)lParam)->lParam); - pt.y = (short)HIWORD(((ENLINK *)lParam)->lParam); + POINT pt = { GET_X_LPARAM(((ENLINK *)lParam)->lParam), GET_Y_LPARAM(((ENLINK *)lParam)->lParam) }; ClientToScreen(((LPNMHDR)lParam)->hwndFrom, &pt); // fixing stuff for searches - pszWord[0] = '\0'; - POINTL ptl = { (LONG)pt.x, (LONG)pt.y }; ScreenToClient(GetDlgItem(hwndDlg, IDC_LOG), (LPPOINT)&ptl); long iCharIndex = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_CHARFROMPOS, 0, (LPARAM)&ptl); @@ -2040,22 +2021,21 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar long start = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_FINDWORDBREAK, WB_LEFT, iCharIndex);//-iChars; long end = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_FINDWORDBREAK, WB_RIGHT, iCharIndex);//-iChars; + wchar_t pszWord[4096]; pszWord[0] = '\0'; if (end - start > 0) { TEXTRANGE tr; - memset(&tr, 0, sizeof(TEXTRANGE)); - - CHARRANGE cr; - cr.cpMin = start; - cr.cpMax = end; - tr.chrg = cr; tr.lpstrText = pszWord; + tr.chrg.cpMin = start; + tr.chrg.cpMax = end; long iRes = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETTEXTRANGE, 0, (LPARAM)&tr); if (iRes > 0) for (size_t iLen = mir_wstrlen(pszWord) - 1; wcschr(szTrimString, pszWord[iLen]); iLen--) pszWord[iLen] = 0; } - uID = CreateGCMenu(hwndDlg, &hMenu, 1, pt, si, NULL, pszWord); + CHARRANGE all = { 0, -1 }; + HMENU hMenu = 0; + UINT uID = CreateGCMenu(hwndDlg, &hMenu, 1, pt, si, NULL, pszWord); switch (uID) { case 0: PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); @@ -2063,26 +2043,24 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case ID_COPYALL: SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel); - SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& all); + SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)&all); SendMessage(((LPNMHDR)lParam)->hwndFrom, WM_COPY, 0, 0); SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)&sel); PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); break; case ID_CLEARLOG: - { - SESSION_INFO *s = pci->SM_FindSession(si->ptszID, si->pszModule); - if (s) { - SetDlgItemText(hwndDlg, IDC_LOG, L""); - pci->LM_RemoveAll(&s->pLog, &s->pLogEnd); - s->iEventCount = 0; - s->LastTime = 0; - si->iEventCount = 0; - si->LastTime = 0; - si->pLog = s->pLog; - si->pLogEnd = s->pLogEnd; - PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); - } + s = pci->SM_FindSession(si->ptszID, si->pszModule); + if (s) { + SetDlgItemText(hwndDlg, IDC_LOG, L""); + pci->LM_RemoveAll(&s->pLog, &s->pLogEnd); + s->iEventCount = 0; + s->LastTime = 0; + si->iEventCount = 0; + si->LastTime = 0; + si->pLog = s->pLog; + si->pLogEnd = s->pLogEnd; + PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0); } break; @@ -2111,12 +2089,11 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case EN_LINK: if (((LPNMHDR)lParam)->idFrom == IDC_LOG) { - switch (((ENLINK *)lParam)->msg) { + switch (((ENLINK*)lParam)->msg) { case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: { - CHARRANGE sel; SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin != sel.cpMax) break; @@ -2407,7 +2384,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar id.mask = TCIF_PARAM; for (j; j >= 0; j--) { TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), j, &id); - SESSION_INFO *s = (SESSION_INFO*)id.lParam; + s = (SESSION_INFO*)id.lParam; if (s) TabM_AddTab(s->ptszID, s->pszModule); } diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 92426c4a7a..a46288de7d 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -128,7 +128,7 @@ void Unload_ChatModule(); void Load_ChatModule();
// log.c
-void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw, BOOL bPhaseTwo);
+void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw);
void ValidateFilename(wchar_t * filename);
char* Log_CreateRtfHeader(MODULEINFO * mi);
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 5ad1c4e85b..2d3c5b3130 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -46,6 +46,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData); char* Log_SetStyle(int style);
// chat_manager.cpp
+BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted);
BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
char* SM_GetUsers(SESSION_INFO *si);
BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
@@ -99,7 +100,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighl int GetColorIndex(const char *pszModule, COLORREF cr);
void CheckColorsInModule(const char *pszModule);
int GetRichTextLength(HWND hwnd);
-BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
+bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
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);
BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const wchar_t* pszUID, const wchar_t* pszText, INT_PTR dwItem);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index b602a42bc4..3c0bc47c8a 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -185,7 +185,7 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return chatApi.hIcons[ICON_STATUS0];
}
-static BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted)
+BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted)
{
SESSION_INFO *p = SM_FindSession(pszID, pszModule);
if (p == NULL)
@@ -1083,7 +1083,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.GetActiveSession = GetActiveSession;
chatApi.SM_FindSession = SM_FindSession;
chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
- chatApi.SM_AddEvent = SM_AddEvent;
chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
chatApi.SM_AddCommand = SM_AddCommand;
chatApi.SM_GetPrevCommand = SM_GetPrevCommand;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 879fab56c9..3840ece962 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -429,6 +429,13 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) if (chatApi.OnEventBroadcast)
chatApi.OnEventBroadcast(p, gce);
+ if (p->hWnd && p->bInitDone) {
+ if (SM_AddEvent(p->ptszID, p->pszModule, gce, FALSE))
+ SendMessage(p->hWnd, GC_ADDLOG, 0, 0);
+ else
+ SendMessage(p->hWnd, GC_REDRAWLOG2, 0, 0);
+ }
+
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
DoFlashParam param = { p, gce, FALSE, bManyFix };
CallFunctionSync(stubFlash, ¶m);
@@ -457,8 +464,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce)))
return 1;
- BOOL bIsHighlighted = FALSE;
- BOOL bRemoveFlag = FALSE;
+ bool bIsHighlighted = false, bRemoveFlag = false;
// Do different things according to type of event
switch (gcd->iType) {
@@ -548,13 +554,22 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) return 0;
if (si && (si->bInitDone || gcd->iType == GC_EVENT_TOPIC || (gcd->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- int isOk = chatApi.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
+ if (si->hWnd) {
+ int isOk = SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
+ if (isOk)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+ }
+
if (chatApi.OnAddLog)
- chatApi.OnAddLog(si, isOk);
+ chatApi.OnAddLog(si);
+
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
DoFlashParam param = { si, gce, bIsHighlighted, 0 };
CallFunctionSync(stubFlash, ¶m);
}
+
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
chatApi.LogToFile(si, gce);
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 2ff093934a..566e1c07e7 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -413,7 +413,7 @@ const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2) static wchar_t szTrimString[] = L":,.!?;\'>)";
-BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
+bool IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
if (!g_Settings->bHighlightEnabled || !g_Settings->pszHighlightWords || !gce || !si || !si->pMe)
return FALSE;
|