summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-08-15 13:49:37 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-08-15 13:49:37 +0300
commitf52b5cc86d9eff2494902157c8fc0a4e019a3c95 (patch)
tree9f668bf7b89decd53757589d74e476aac81eb451 /src/mir_app
parentd05dd78157058eea348f0d7666c7c6b0570ef25b (diff)
fixes #799 (Crash on receiving msg in FB group chat)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/srmm_util.cpp40
3 files changed, 44 insertions, 0 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 890a9eec7f..a0addf8ff5 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -451,3 +451,5 @@ Hotkey_Subclass @455
Hotkey_Unregister @456
Hotkey_Unsubclass @457
Hotkey_Check @458
+?SetStatusText@CSrmmBaseDialog@@UAEXPB_WPAUHICON__@@@Z @459 NONAME
+Srmm_SetStatusText @460
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index f5e2debc70..963f8cd9ad 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -451,3 +451,5 @@ Hotkey_Subclass @455
Hotkey_Unregister @456
Hotkey_Unsubclass @457
Hotkey_Check @458
+?SetStatusText@CSrmmBaseDialog@@UEAAXPEB_WPEAUHICON__@@@Z @459 NONAME
+Srmm_SetStatusText @460
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index ad0abe21a3..f9e7ed65c5 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -24,6 +24,8 @@ 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;
@@ -50,6 +52,8 @@ MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pb
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
{
if (hContact == 0)
@@ -71,12 +75,48 @@ MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(void) Srmm_Broadcast(UINT msg, WPARAM wParam, LPARAM lParam)
{
WindowList_Broadcast(g_hWindowList, msg, wParam, lParam);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact)
{
return WindowList_Find(g_hWindowList, hContact);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// serializes all thread-unsafe operation to the first thread
+
+struct SSTParam
+{
+ HWND hwnd;
+ const wchar_t *wszText;
+ HICON hIcon;
+};
+
+static INT_PTR CALLBACK sttSetStatusText(void *_p)
+{
+ SSTParam *param = (SSTParam*)_p;
+
+ CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)GetWindowLongPtr(param->hwnd, GWLP_USERDATA);
+ if (pDlg != nullptr)
+ pDlg->SetStatusText((param->wszText == nullptr) ? L"" : param->wszText, param->hIcon);
+ return 0;
+}
+
+MIR_APP_DLL(void) Srmm_SetStatusText(MCONTACT hContact, const wchar_t *wszText, HICON hIcon)
+{
+ HWND hwnd = Srmm_FindWindow(hContact);
+ if (hwnd == nullptr)
+ hwnd = Srmm_FindWindow(db_mc_getMeta(hContact));
+ if (hwnd == nullptr)
+ return;
+
+ SSTParam param = { hwnd, wszText, hIcon };
+ CallFunctionSync(sttSetStatusText, &param);
+}