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 /src/mir_app | |
parent | bc382bfeb00236e2dbbb143cfe35dd3716a2f7e2 (diff) |
common chat code moved to the core
Diffstat (limited to 'src/mir_app')
-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 |
4 files changed, 23 insertions, 8 deletions
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;
|