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/Sametime/src/sametime.cpp | 37 +------------------------------ protocols/Sametime/src/sametime.h | 4 ---- protocols/Sametime/src/sametime_proto.cpp | 23 +++---------------- 3 files changed, 4 insertions(+), 60 deletions(-) (limited to 'protocols/Sametime/src') diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index 189e877a66..186ebcda7f 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -87,43 +87,8 @@ void SametimeInitIcons(void) } // Copied from MSN plugin - sent acks need to be from different thread -void __cdecl sttFakeAckInfoSuccessThread(TFakeAckParams* tParam) -{ - CSametimeProto* proto = tParam->proto; - proto->debugLogW(L"sttFakeAckInfoSuccessThread() start"); - - Sleep(100); - proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1); - - proto->debugLogW(L"sttFakeAckInfoSuccessThread() end"); - mir_free(tParam); -} - -void __cdecl sttFakeAckMessageSuccessThread(TFakeAckParams* tParam) -{ - CSametimeProto* proto = tParam->proto; - proto->debugLogW(L"sttFakeAckMessageSuccessThread() start"); - - Sleep(100); - proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->lParam, 0); - - proto->debugLogW(L"sttFakeAckMessageSuccessThread() end"); - mir_free(tParam); -} - -void __cdecl sttFakeAckMessageFailedThread(TFakeAckParams* tParam) -{ - CSametimeProto* proto = tParam->proto; - proto->debugLogW(L"sttFakeAckMessageFailedThread() start"); - - Sleep(100); - proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, tParam->lParam); ///TODO tParam->lParam: add error message - - proto->debugLogW(L"sttFakeAckMessageFailedThread() end"); - mir_free(tParam); -} -void __cdecl sttRecvAwayThread(TFakeAckParams* tParam) +void __cdecl sttRecvAwayThread(TFakeAckParams *tParam) { CSametimeProto* proto = tParam->proto; proto->debugLogW(L"sttRecvAwayThread() start"); diff --git a/protocols/Sametime/src/sametime.h b/protocols/Sametime/src/sametime.h index 2714779be2..e553b3bd33 100644 --- a/protocols/Sametime/src/sametime.h +++ b/protocols/Sametime/src/sametime.h @@ -50,12 +50,8 @@ struct TFakeAckParams LPARAM lParam; }; -void __cdecl sttFakeAckInfoSuccessThread(TFakeAckParams* tParam); -void __cdecl sttFakeAckMessageFailedThread(TFakeAckParams* tParam); -void __cdecl sttFakeAckMessageSuccessThread(TFakeAckParams* tParam); void __cdecl sttRecvAwayThread(TFakeAckParams* tParam); - //sametime structs typedef struct Options_tag { diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 37b158cb1a..7f583c3e1d 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -131,14 +131,7 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType) if (!session) return 1; - ///TODO unimplemented - getting contact info - - TFakeAckParams* tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams)); - tfap->proto = this; - tfap->hContact = hContact; - tfap->lParam = NULL; - mir_forkThread(sttFakeAckInfoSuccessThread, tfap); - + ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, 0); return 0; } @@ -205,11 +198,7 @@ int CSametimeProto::SendMsg(MCONTACT hContact, int, const char* msg) char *proto = Proto_GetBaseAccountName(hContact); if (!proto || mir_strcmp(proto, m_szModuleName) != 0 || db_get_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) { - TFakeAckParams* tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams)); - tfap->proto = this; - tfap->hContact = hContact; - tfap->lParam = 0; - mir_forkThread(sttFakeAckMessageFailedThread, tfap); + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, 0); return 0; } @@ -217,13 +206,7 @@ int CSametimeProto::SendMsg(MCONTACT hContact, int, const char* msg) return 0; int ret = (INT_PTR)SendMessageToUser(hContact, msg); - - TFakeAckParams *tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams)); - tfap->proto = this; - tfap->hContact = hContact; - tfap->lParam = (LPARAM)ret; - mir_forkThread(sttFakeAckMessageSuccessThread, tfap); - + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)ret); return ret; } -- cgit v1.2.3