From dd6ac172c4f814fa4b5ace6caca80d00d7e01ac8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 20 Feb 2020 21:23:22 +0300 Subject: bunch of useless threads replaced with a call of ProtoBroadcastAsync --- protocols/Dummy/src/dummy.h | 8 -------- protocols/Dummy/src/dummy_proto.cpp | 23 ++++------------------- protocols/Dummy/src/dummy_proto.h | 1 - 3 files changed, 4 insertions(+), 28 deletions(-) (limited to 'protocols/Dummy/src') diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index 1bc004cfaf..42963e632c 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -24,14 +24,6 @@ struct CDummyProto; #define DUMMY_ID_SETTING "UniqueIdSetting" #define DUMMY_KEY_ALLOW_SENDING "AllowSending" -struct message_data -{ - message_data(MCONTACT hContact, const std::string &msg, int msgid) : hContact(hContact), msg(msg), msgid(msgid) {} - MCONTACT hContact; - std::string msg; - int msgid; -}; - struct ttemplate { const char *name; diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 65e0c46e4e..bd5b556649 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -17,24 +17,6 @@ along with this program. If not, see . #include "stdafx.h" -void CDummyProto::SendMsgAck(void *p) -{ - if (p == nullptr) - return; - - message_data *data = static_cast(p); - - Sleep(100); - - if (getByte(DUMMY_KEY_ALLOW_SENDING, 0)) - ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)data->msgid); - else - ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)data->msgid, - (LPARAM)TranslateT("This Dummy account has disabled sending messages. Enable it in account options.")); - - delete data; -} - void CDummyProto::SearchIdAckThread(void *targ) { PROTOSEARCHRESULT psr = { 0 }; @@ -126,7 +108,10 @@ int CDummyProto::SendMsg(MCONTACT hContact, int, const char *msg) std::string message = msg; unsigned int id = InterlockedIncrement(&this->msgid); - ForkThread(&CDummyProto::SendMsgAck, new message_data(hContact, message, id)); + if (getByte(DUMMY_KEY_ALLOW_SENDING, 0)) + ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id); + else + ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)TranslateT("This Dummy account has disabled sending messages. Enable it in account options.")); return id; } diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index 530038bdbf..0f07cdbe6d 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -42,7 +42,6 @@ struct CDummyProto : public PROTO INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); - void __cdecl SendMsgAck(void *param); void __cdecl SearchIdAckThread(void*); char uniqueIdText[100]; -- cgit v1.2.3