diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-17 17:42:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-17 17:42:48 +0000 |
commit | d0735d50571bca069ee2fe372095b3750a32f51d (patch) | |
tree | 19d87e89cf4c4cf583b3d6873e0273c96795b8e6 /src | |
parent | e5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e (diff) |
- fix for tray icon blinking in chats;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@17310 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 30 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 50 | ||||
-rw-r--r-- | src/mir_app/src/clcfiledrop.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/modules.cpp | 31 |
7 files changed, 82 insertions, 35 deletions
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index b6fdad1875..679e24e880 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -210,7 +210,7 @@ BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* cle.hDbEvent = hEvent;
cle.flags = type | CLEF_TCHAR;
cle.hIcon = hIcon;
- cle.pszService = "GChat/DblClickEvent" ;
+ cle.pszService = "GChat/DblClickEvent";
cle.ptszTooltip = TranslateW(szBuf);
if (!ServiceExists(cle.pszService))
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 635478ce8f..9758431011 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -123,8 +123,6 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re while (pTemp != NULL) {
// match
if ((!pszID && pTemp->iType != GCW_SERVER || !mir_wstrcmpi(pTemp->ptszID, pszID)) && !mir_strcmpi(pTemp->pszModule, pszModule)) {
- void *pItemData = pTemp->pItemData;
-
if (chatApi.OnRemoveSession)
chatApi.OnRemoveSession(pTemp);
DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (INT_PTR)pTemp->pItemData);
@@ -142,7 +140,7 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re SM_FreeSession(pTemp);
if (pszID)
- return (int)pItemData;
+ return 1;
if (pLast)
pTemp = pLast->next;
@@ -224,31 +222,6 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return chatApi.hIcons[ICON_STATUS0];
}
-static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce)
-{
- int bManyFix = 0;
-
- for (SESSION_INFO *p = chatApi.wndList; p != NULL; p = p->next) {
- if (!p->bInitDone || mir_strcmpi(p->pszModule, gce->pDest->pszModule))
- continue;
-
- if (!chatApi.UM_FindUser(p->pUsers, gce->ptszUID))
- continue;
-
- if (chatApi.OnEventBroadcast)
- chatApi.OnEventBroadcast(p, gce);
-
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- chatApi.DoSoundsFlashPopupTrayStuff(p, gce, FALSE, bManyFix);
-
- bManyFix++;
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
- chatApi.LogToFile(p, gce);
- }
-
- return 0;
-}
-
static BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted)
{
SESSION_INFO *p = SM_FindSession(pszID, pszModule);
@@ -1244,7 +1217,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.SM_SetStatusEx = SM_SetStatusEx;
chatApi.SM_SendUserMessage = SM_SendUserMessage;
chatApi.SM_AddStatus = SM_AddStatus;
- chatApi.SM_AddEventToAllMatchingUID = SM_AddEventToAllMatchingUID;
chatApi.SM_AddEvent = SM_AddEvent;
chatApi.SM_SendMessage = SM_SendMessage;
chatApi.SM_PostMessage = SM_PostMessage;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 2320292da5..c6b1e486ec 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -353,6 +353,19 @@ MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool /////////////////////////////////////////////////////////////////////////////////////////
// handles chat event
+struct DoFlashParam
+{
+ SESSION_INFO *si;
+ GCEVENT *gce;
+ int i1, i2;
+};
+
+static INT_PTR __stdcall stubFlash(void *param)
+{
+ DoFlashParam *p = (DoFlashParam*)param;
+ return chatApi.DoSoundsFlashPopupTrayStuff(p->si, p->gce, p->i1, p->i2);
+}
+
static void AddUser(GCEVENT *gce)
{
SESSION_INFO *si = chatApi.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
@@ -372,6 +385,33 @@ static void AddUser(GCEVENT *gce) chatApi.OnNewUser(si, ui);
}
+static BOOL AddEventToAllMatchingUID(GCEVENT *gce)
+{
+ int bManyFix = 0;
+
+ for (SESSION_INFO *p = chatApi.wndList; p != NULL; p = p->next) {
+ if (!p->bInitDone || mir_strcmpi(p->pszModule, gce->pDest->pszModule))
+ continue;
+
+ if (!chatApi.UM_FindUser(p->pUsers, gce->ptszUID))
+ continue;
+
+ if (chatApi.OnEventBroadcast)
+ chatApi.OnEventBroadcast(p, gce);
+
+ if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
+ DoFlashParam param = { p, gce, FALSE, bManyFix };
+ CallFunctionSync(stubFlash, ¶m);
+ }
+
+ bManyFix++;
+ if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
+ chatApi.LogToFile(p, gce);
+ }
+
+ return 0;
+}
+
EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce)
{
BOOL bIsHighlighted = FALSE;
@@ -471,7 +511,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) }
else {
// Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
- chatApi.SM_AddEventToAllMatchingUID(gce);
+ AddEventToAllMatchingUID(gce);
if (!bRemoveFlag)
return 0;
}
@@ -480,7 +520,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (pWnd) {
SESSION_INFO *si = chatApi.SM_FindSession(pWnd, pMod);
- // fix for IRC's old stuyle mode notifications. Should not affect any other protocol
+ // fix for IRC's old style mode notifications. Should not affect any other protocol
if ((gcd->iType == GC_EVENT_ADDSTATUS || gcd->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
return 0;
@@ -491,8 +531,10 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) int isOk = chatApi.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
if (chatApi.OnAddLog)
chatApi.OnAddLog(si, isOk);
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- chatApi.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
+ 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/clcfiledrop.cpp b/src/mir_app/src/clcfiledrop.cpp index 77ece42958..294a65e1a4 100644 --- a/src/mir_app/src/clcfiledrop.cpp +++ b/src/mir_app/src/clcfiledrop.cpp @@ -108,7 +108,7 @@ HRESULT CDropTarget::DragOver(DWORD /*grfKeyState*/, POINTL pt, DWORD * pdwEffec return S_OK;
}
cli.pfnTrayIconPauseAutoHide(0, 0);
- ClcData *dat = (ClcData *) GetWindowLongPtr(hwndCurrentDrag, 0);
+ ClcData *dat = (ClcData*)GetWindowLongPtr(hwndCurrentDrag, 0);
shortPt.x = pt.x;
shortPt.y = pt.y;
ScreenToClient(hwndCurrentDrag, &shortPt);
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index a9bdba9103..435036b9b4 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1010,3 +1010,4 @@ db_delete_module @1161 ?SetMaxLength@CCtrlEdit@@QAEXI@Z @1167 NONAME
?SetRange@CCtrlSpin@@QAEXFF@Z @1168 NONAME
db_get_current @1169
+CallFunctionSync @1170
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index c7279247af..f08ff49cdf 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1010,3 +1010,4 @@ db_delete_module @1161 ?SetMaxLength@CCtrlEdit@@QEAAXI@Z @1167 NONAME
?SetRange@CCtrlSpin@@QEAAXFF@Z @1168 NONAME
db_get_current @1169
+CallFunctionSync @1170
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index 7fd0cfc45a..a462d456f4 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -571,6 +571,8 @@ MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lP return item.result; } +///////////////////////////////////////////////////////////////////////////////////////// + MIR_CORE_DLL(int) CallFunctionAsync(void(__stdcall *func)(void *), void *arg) { if (GetCurrentThreadId() == mainThreadId) @@ -580,6 +582,35 @@ MIR_CORE_DLL(int) CallFunctionAsync(void(__stdcall *func)(void *), void *arg) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + +struct TSyncCallParam +{ + INT_PTR (__stdcall *func)(void *); + void *arg; + HANDLE hDoneEvent; + INT_PTR result; +}; + +static void CALLBACK CallFuncToMainAPCFunc(ULONG_PTR dwParam) +{ + TSyncCallParam *item = (TSyncCallParam*)dwParam; + item->result = (*item->func)(item->arg); + SetEvent(item->hDoneEvent); +} + +MIR_CORE_DLL(INT_PTR) CallFunctionSync(INT_PTR (__stdcall *func)(void *), void *arg) +{ + if (GetCurrentThreadId() == mainThreadId) + return func(arg); + + TSyncCallParam param = { func, arg, getThreadEvent() }; + QueueMainThread(CallFuncToMainAPCFunc, ¶m, param.hDoneEvent); + return param.result; +} + +///////////////////////////////////////////////////////////////////////////////////////// + MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst) { mir_cslock lck(csServices); |