summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/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 /protocols/Gadu-Gadu/src
parent79d99837e0fefa32d695dba7e2a13b8a42f39da2 (diff)
bunch of useless threads replaced with a call of ProtoBroadcastAsync
Diffstat (limited to 'protocols/Gadu-Gadu/src')
-rw-r--r--protocols/Gadu-Gadu/src/filetransfer.cpp33
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp69
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h4
3 files changed, 17 insertions, 89 deletions
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp
index 14be05e395..dac2149fb1 100644
--- a/protocols/Gadu-Gadu/src/filetransfer.cpp
+++ b/protocols/Gadu-Gadu/src/filetransfer.cpp
@@ -88,39 +88,12 @@ void GaduProto::dccconnect(uin_t uin)
gg_LeaveCriticalSection(&ft_mutex, "dccconnect", 36, 1, "ft_mutex", 1);
}
-struct ftfaildata
-{
- MCONTACT hContact;
- HANDLE hProcess;
-};
-
-//////////////////////////////////////////////////////////
-// THREAD: File transfer fail
-//
-void __cdecl GaduProto::ftfailthread(void *param)
-{
- struct ftfaildata *ft = (struct ftfaildata *)param;
- debugLogA("ftfailthread(): started. Sending failed file transfer.");
- gg_sleep(100, FALSE, "ftfailthread", 102, 1);
- ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft->hProcess, 0);
- free(ft);
- debugLogA("ftfailthread(): end.");
-}
-
HANDLE ftfail(GaduProto *gg, MCONTACT hContact)
{
- ftfaildata *ft = (ftfaildata*)malloc(sizeof(struct ftfaildata));
-#ifdef DEBUGMODE
- gg->debugLogA("ftfail(): Failing file transfer...");
-#endif
srand(time(0));
- ft->hProcess = (HANDLE)rand();
- ft->hContact = hContact;
-#ifdef DEBUGMODE
- gg->debugLogA("ftfail(): ForkThread 5 GaduProto::ftfailthread");
-#endif
- gg->ForkThread(&GaduProto::ftfailthread, ft);
- return ft->hProcess;
+ HANDLE hProcess = (HANDLE)rand();
+ gg->ProtoBroadcastAsync(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, hProcess);
+ return hProcess;
}
// Info refresh min time (msec) / half-sec
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index 4c11cd975a..7f720bac33 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -163,13 +163,6 @@ INT_PTR GaduProto::GetCaps(int type, MCONTACT)
//////////////////////////////////////////////////////////
// user info request
//
-void __cdecl GaduProto::cmdgetinfothread(void *hContact)
-{
- debugLogA("cmdgetinfothread(): started. Failed info retreival.");
- gg_sleep(100, FALSE, "cmdgetinfothread", 103, 1);
- ProtoBroadcastAck((UINT_PTR)hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
- debugLogA("cmdgetinfothread(): end.");
-}
int GaduProto::GetInfo(MCONTACT hContact, int)
{
@@ -181,7 +174,7 @@ int GaduProto::GetInfo(MCONTACT hContact, int)
#ifdef DEBUGMODE
debugLogA("GetInfo(): ForkThread 6 GaduProto::cmdgetinfothread");
#endif
- ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
return 1;
}
@@ -197,7 +190,7 @@ int GaduProto::GetInfo(MCONTACT hContact, int)
#ifdef DEBUGMODE
debugLogA("GetInfo(): ForkThread 7 GaduProto::cmdgetinfothread");
#endif
- ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
return 1;
}
gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 2, "sess_mutex", 1);
@@ -209,7 +202,7 @@ int GaduProto::GetInfo(MCONTACT hContact, int)
#ifdef DEBUGMODE
debugLogA("GetInfo(): ForkThread 8 GaduProto::cmdgetinfothread");
#endif
- ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
return 1;
}
@@ -224,7 +217,7 @@ int GaduProto::GetInfo(MCONTACT hContact, int)
#ifdef DEBUGMODE
debugLogA("GetInfo(): ForkThread 9 GaduProto::cmdgetinfothread");
#endif
- ForkThread(&GaduProto::cmdgetinfothread, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
gg_pubdir50_free(req);
return 1;
}
@@ -233,20 +226,9 @@ int GaduProto::GetInfo(MCONTACT hContact, int)
}
debugLogA("GetInfo(): Seq %d.", req->seq);
gg_pubdir50_free(req);
-
return 1;
}
-void __cdecl GaduProto::searchthread(void *)
-{
- debugLogA("searchthread(): started. Failed search.");
- gg_sleep(100, FALSE, "searchthread", 104, 1);
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1, 0);
-#ifdef DEBUGMODE
- debugLogA("searchthread(): end.");
-#endif
-}
-
//////////////////////////////////////////////////////////
// when basic search
//
@@ -260,7 +242,7 @@ HANDLE GaduProto::SearchBasic(const wchar_t *id)
#ifdef DEBUGMODE
debugLogA("SearchBasic(): ForkThread 10 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1, 0);
return (HANDLE)1;
}
@@ -274,13 +256,12 @@ HANDLE GaduProto::SearchBasic(const wchar_t *id)
#ifdef DEBUGMODE
debugLogA("SearchBasic(): ForkThread 11 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1, 0);
return (HANDLE)1;
}
gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 2, "sess_mutex", 1);
debugLogA("SearchBasic(): Seq %d.", req->seq);
gg_pubdir50_free(req);
-
return (HANDLE)1;
}
@@ -301,7 +282,7 @@ HANDLE GaduProto::SearchByName(const wchar_t *nick, const wchar_t *firstName, co
#ifdef DEBUGMODE
debugLogA("SearchByName(): ForkThread 12 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
return (HANDLE)1;
}
@@ -342,7 +323,7 @@ HANDLE GaduProto::SearchByName(const wchar_t *nick, const wchar_t *firstName, co
#ifdef DEBUGMODE
debugLogA("SearchByName(): ForkThread 13 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
}
else
{
@@ -368,7 +349,7 @@ HWND GaduProto::SearchAdvanced(HWND hwndDlg)
#ifdef DEBUGMODE
debugLogA("SearchAdvanced(): ForkThread 14 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
return (HWND)1;
}
@@ -478,7 +459,7 @@ HWND GaduProto::SearchAdvanced(HWND hwndDlg)
#ifdef DEBUGMODE
debugLogA("SearchAdvanced(): ForkThread 15 GaduProto::searchthread");
#endif
- ForkThread(&GaduProto::searchthread, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
return (HWND)1;
}
gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 2, "sess_mutex", 1);
@@ -511,20 +492,6 @@ HWND GaduProto::CreateExtendedSearchUI(HWND owner)
MAKEINTRESOURCE(IDD_GGADVANCEDSEARCH), owner, gg_advancedsearchdlgproc, (LPARAM)this);
}
-struct GG_SEQ_ACK
-{
- MCONTACT hContact;
- int seq;
-};
-
-void __cdecl GaduProto::sendackthread(void *ack)
-{
- GG_SEQ_ACK *pAck = (GG_SEQ_ACK *)ack;
- gg_sleep(100, FALSE, "sendackthread", 105, 1);
- ProtoBroadcastAck(pAck->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)pAck->seq, 0);
- mir_free(ack);
-}
-
//////////////////////////////////////////////////////////
// when messsage sent
//
@@ -540,18 +507,10 @@ int GaduProto::SendMsg(MCONTACT hContact, int, const char *msg)
gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1);
int seq = gg_send_message(m_sess, GG_CLASS_CHAT, uin, (BYTE*)msg);
gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1);
- if (!m_gaduOptions.useMsgDeliveryAcknowledge) {
- // Auto-ack message without waiting for server ack
- GG_SEQ_ACK *ack = (GG_SEQ_ACK*)mir_alloc(sizeof(GG_SEQ_ACK));
- if (ack) {
- ack->seq = seq;
- ack->hContact = hContact;
-#ifdef DEBUGMODE
- debugLogA("SendMsg(): ForkThread 16 GaduProto::sendackthread");
-#endif
- ForkThread(&GaduProto::sendackthread, ack);
- }
- }
+
+ // Auto-ack message without waiting for server ack
+ if (!m_gaduOptions.useMsgDeliveryAcknowledge)
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq, 0);
return seq;
}
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index ada0efe1d8..4d6792cad6 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -73,12 +73,8 @@ struct GaduProto : public PROTO<GaduProto>
// Threads
void __cdecl mainthread(void *empty);
- void __cdecl sendackthread(void *);
- void __cdecl searchthread(void *);
- void __cdecl cmdgetinfothread(void *hContact);
void __cdecl getawaymsgthread(void *hContact);
void __cdecl dccmainthread(void *);
- void __cdecl ftfailthread(void *param);
void __cdecl remindpasswordthread(void *param);
//////////////////////////////////////////////////////////////////////////////////////