diff options
author | George Hazan <ghazan@miranda.im> | 2020-02-20 21:23:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-02-20 21:23:22 +0300 |
commit | dd6ac172c4f814fa4b5ace6caca80d00d7e01ac8 (patch) | |
tree | 805abd69e64f8e1f268e6415689de8742cac2215 /protocols/Dummy/src | |
parent | 79d99837e0fefa32d695dba7e2a13b8a42f39da2 (diff) |
bunch of useless threads replaced with a call of ProtoBroadcastAsync
Diffstat (limited to 'protocols/Dummy/src')
-rw-r--r-- | protocols/Dummy/src/dummy.h | 8 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.cpp | 23 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.h | 1 |
3 files changed, 4 insertions, 28 deletions
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 <http://www.gnu.org/licenses/>. #include "stdafx.h" -void CDummyProto::SendMsgAck(void *p) -{ - if (p == nullptr) - return; - - message_data *data = static_cast<message_data*>(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<CDummyProto> INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); - void __cdecl SendMsgAck(void *param); void __cdecl SearchIdAckThread(void*); char uniqueIdText[100]; |