summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-02-20 21:23:22 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-02-20 21:23:22 +0300
commitdd6ac172c4f814fa4b5ace6caca80d00d7e01ac8 (patch)
tree805abd69e64f8e1f268e6415689de8742cac2215 /src
parent79d99837e0fefa32d695dba7e2a13b8a42f39da2 (diff)
bunch of useless threads replaced with a call of ProtoBroadcastAsync
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/meta_services.cpp29
-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/proto_utils.cpp15
4 files changed, 20 insertions, 28 deletions
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index 2cf2a7965a..40f1ca8889 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -178,24 +178,6 @@ INT_PTR Meta_GetStatus(WPARAM, LPARAM)
/// Copied from MSN plugin - sent acks need to be from different thread :(
//////////////////////////////////////////////////////////
-struct TFakeAckParams
-{
- HANDLE hEvent;
- MCONTACT hContact;
- LONG id;
-};
-
-static void __cdecl sttFakeAckFail(TFakeAckParams *tParam)
-{
- WaitForSingleObject(tParam->hEvent, INFINITE);
-
- Sleep(100);
- ProtoBroadcastAck(META_PROTO, tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, (WPARAM)TranslateT("No online contacts found."));
-
- CloseHandle(tParam->hEvent);
- mir_free(tParam);
-}
-
INT_PTR Meta_SendNudge(WPARAM wParam, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(wParam);
@@ -230,16 +212,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam)
MCONTACT hMostOnline = db_mc_getSrmmSub(cc->contactID);
if (!hMostOnline) {
- // send failure to notify user of reason
- HANDLE hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
-
- TFakeAckParams *tfap = (TFakeAckParams *)mir_alloc(sizeof(TFakeAckParams));
- tfap->hContact = ccs->hContact;
- tfap->hEvent = hEvent;
- tfap->id = 10;
- mir_forkThread<TFakeAckParams>(sttFakeAckFail, tfap);
-
- SetEvent(hEvent);
+ ProtoBroadcastAsync(META_PROTO, ccs->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)10, (WPARAM)TranslateT("No online contacts found."));
return 10;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index c271415c83..576ec9f176 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -722,3 +722,5 @@ _WebSocket_InitHeader@12 @809 NONAME
_WebSocket_Connect@12 @810 NONAME
?log@CSrmmBaseDialog@@QBEPAVCSrmmLogWindow@@XZ @811 NONAME
Netlib_Dump @812 NONAME
+?ProtoBroadcastAsync@PROTO_INTERFACE@@QAEXIHHPAXJ@Z @813 NONAME
+ProtoBroadcastAsync @814 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 882311a4a0..dc56f4d10f 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -722,3 +722,5 @@ WebSocket_InitHeader @809 NONAME
WebSocket_Connect @810 NONAME
?log@CSrmmBaseDialog@@QEBAPEAVCSrmmLogWindow@@XZ @811 NONAME
Netlib_Dump @812 NONAME
+?ProtoBroadcastAsync@PROTO_INTERFACE@@QEAAXIHHPEAX_J@Z @813 NONAME
+ProtoBroadcastAsync @814 NONAME
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp
index dea4bf189a..f6330ae487 100644
--- a/src/mir_app/src/proto_utils.cpp
+++ b/src/mir_app/src/proto_utils.cpp
@@ -60,6 +60,21 @@ MIR_APP_DLL(void) Proto_EnumProtocols(int *nProtos, PROTOCOLDESCRIPTOR ***pProto
/////////////////////////////////////////////////////////////////////////////////////////
+static void __cdecl sttFakeAckThread(ACKDATA *ack)
+{
+ Sleep(100);
+ NotifyEventHooks(hAckEvent, 0, (LPARAM)ack);
+ delete ack;
+}
+
+MIR_APP_DLL(void) ProtoBroadcastAsync(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
+{
+ ACKDATA ack = { szModule, hContact, type, result, hProcess, lParam };
+ mir_forkThread<ACKDATA>(sttFakeAckThread, new ACKDATA(ack));
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
ACKDATA ack = { szModule, hContact, type, result, hProcess, lParam };