diff options
36 files changed, 84 insertions, 412 deletions
diff --git a/include/m_core.h b/include/m_core.h index ee75f1c1f2..3d765da7f3 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -315,6 +315,7 @@ MIR_CORE_DLL(int) mir_vsnwprintf(_Pre_notnull_ _Always_(_Post_z_) wchar_t *bu struct PROTO_INTERFACE;
MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0);
+MIR_APP_DLL(void) ProtoBroadcastAsync(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0);
// avatar support functions
diff --git a/include/m_protoint.h b/include/m_protoint.h index a5263835f3..8eb162d807 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -91,6 +91,8 @@ public: __forceinline INT_PTR ProtoBroadcastAck(MCONTACT hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam = 0) {
return ::ProtoBroadcastAck(m_szModuleName, hContact, type, hResult, hProcess, lParam); }
+ __forceinline void ProtoBroadcastAsync(MCONTACT hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam = 0) {
+ return ::ProtoBroadcastAsync(m_szModuleName, hContact, type, hResult, hProcess, lParam); }
__forceinline INT_PTR delSetting(const char *name) { return db_unset(NULL, m_szModuleName, name); }
__forceinline INT_PTR delSetting(MCONTACT hContact, const char *name) { return db_unset(hContact, m_szModuleName, name); }
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex cbecd7fe9b..43a7316556 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 6cf421c98e..4479d1c9a3 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index cda830c3d5..626b30088e 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -386,16 +386,10 @@ MCONTACT CDiscordProto::AddToList(int flags, PROTOSEARCHRESULT *psr) //////////////////////////////////////////////////////////////////////////////////////// // SendMsg -void __cdecl CDiscordProto::SendMessageAckThread(void *param) -{ - Sleep(100); - ProtoBroadcastAck((UINT_PTR)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)TranslateT("Protocol is offline or user isn't authorized yet")); -} - int CDiscordProto::SendMsg(MCONTACT hContact, int /*flags*/, const char *pszSrc) { if (!m_bOnline) { - ForkThread(&CDiscordProto::SendMessageAckThread, (void*)hContact); + ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)TranslateT("Protocol is offline or user isn't authorized yet")); return 1; } diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index f165ca40c2..e42fe720a1 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -159,7 +159,6 @@ class CDiscordProto : public PROTO<CDiscordProto> void __cdecl SendFileThread(void*); void __cdecl ServerThread(void*); void __cdecl SearchThread(void *param); - void __cdecl SendMessageAckThread(void* param); void __cdecl BatchChatCreate(void* param); void __cdecl GetAwayMsgThread(void *param); 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]; diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp index c59fca360b..cc3bcd875b 100644 --- a/protocols/Facebook/src/proto.cpp +++ b/protocols/Facebook/src/proto.cpp @@ -175,16 +175,10 @@ INT_PTR FacebookProto::GetCaps(int type, MCONTACT) ///////////////////////////////////////////////////////////////////////////////////////// -void __cdecl FacebookProto::SendMessageAckThread(void *param) -{ - Sleep(100); - ProtoBroadcastAck((UINT_PTR)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)TranslateT("Protocol is offline or user isn't authorized yet")); -} - int FacebookProto::SendMsg(MCONTACT hContact, int, const char *pszSrc) { if (!m_bOnline) { - ForkThread(&FacebookProto::SendMessageAckThread, (void *)hContact); + ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)TranslateT("Protocol is offline or user isn't authorized yet")); return 1; } diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index bd3eca0938..6bf94d6060 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -475,7 +475,6 @@ class FacebookProto : public PROTO<FacebookProto> FacebookUser* AddContact(const CMStringW &wszId, bool bTemp = true); - void __cdecl SendMessageAckThread(void *); void __cdecl ServerThread(void *); public: 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);
//////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index d05c5a5027..1b4fbb5a31 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -630,47 +630,17 @@ HANDLE CIrcProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t** ppszFile ////////////////////////////////////////////////////////////////////////////////////////
// SendMessage - sends a message
-struct TFakeAckParam
-{
- __inline TFakeAckParam(MCONTACT _hContact, int _msgid) :
- hContact(_hContact), msgid(_msgid)
- {}
-
- MCONTACT hContact;
- int msgid;
-};
-
-void __cdecl CIrcProto::AckMessageFail(void *info)
-{
- Thread_SetName("IRC: AckMessageFail");
- ProtoBroadcastAck((UINT_PTR)info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, (LPARAM)TranslateT("The protocol is not online"));
-}
-
-void __cdecl CIrcProto::AckMessageFailDcc(void *info)
-{
- Thread_SetName("IRC: AckMessageFailDcc");
- ProtoBroadcastAck((UINT_PTR)info, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, (LPARAM)TranslateT("The dcc chat connection is not active"));
-}
-
-void __cdecl CIrcProto::AckMessageSuccess(void *info)
-{
- Thread_SetName("IRC: AckMessageSuccess");
- TFakeAckParam *param = (TFakeAckParam*)info;
- ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)param->msgid, 0);
- delete param;
-}
-
int CIrcProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
BYTE bDcc = getByte(hContact, "DCC", 0);
WORD wStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if (bDcc && wStatus != ID_STATUS_ONLINE) {
- ForkThread(&CIrcProto::AckMessageFailDcc, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, (LPARAM)TranslateT("The dcc chat connection is not active"));
return 0;
}
if (!bDcc && (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING)) {
- ForkThread(&CIrcProto::AckMessageFail, (void*)hContact);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, (LPARAM)TranslateT("The protocol is not online"));
return 0;
}
@@ -680,7 +650,7 @@ int CIrcProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) mir_free(result);
int seq = InterlockedIncrement(&g_msgid);
- ForkThread(&CIrcProto::AckMessageSuccess, new TFakeAckParam(hContact, seq));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
return seq;
}
diff --git a/protocols/IRCG/src/ircproto.h b/protocols/IRCG/src/ircproto.h index 11f43c23b3..fb8839d056 100644 --- a/protocols/IRCG/src/ircproto.h +++ b/protocols/IRCG/src/ircproto.h @@ -232,9 +232,6 @@ struct CIrcProto : public PROTO<CIrcProto> // ircproto.cpp void __cdecl AckBasicSearch(void* param); - void __cdecl AckMessageFail(void* info); - void __cdecl AckMessageFailDcc(void* info); - void __cdecl AckMessageSuccess(void* info); int SetStatusInternal(int iNewStatus, bool bIsInternal); diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index d31e9fac62..2359adcc2f 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -305,7 +305,6 @@ bool CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) }
ft->jibb->dwTransferredSize += (DWORD)numRead;
-
ft->std.currentFileProgress += numRead;
ft->std.totalProgress += numRead;
ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 5e67a49b61..68403b4254 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -906,29 +906,6 @@ MEVENT CJabberProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) ////////////////////////////////////////////////////////////////////////////////////////
// JabberSendMessage - sends a message
-struct TFakeAckParams
-{
- inline TFakeAckParams(MCONTACT _hContact, const wchar_t *_msg, int _msgid = 0)
- : hContact(_hContact), msg(_msg), msgid(_msgid)
- {
- }
-
- MCONTACT hContact;
- const wchar_t *msg;
- int msgid;
-};
-
-void __cdecl CJabberProto::SendMessageAckThread(void* param)
-{
- Thread_SetName("Jabber: SendMessageAckThread");
- TFakeAckParams *par = (TFakeAckParams*)param;
- Sleep(100);
- debugLogA("Broadcast ACK");
- ProtoBroadcastAck(par->hContact, ACKTYPE_MESSAGE, par->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, (HANDLE)par->msgid, (LPARAM)par->msg);
- debugLogA("Returning from thread");
- delete par;
-}
-
static char PGP_PROLOG[] = "-----BEGIN PGP MESSAGE-----\r\n\r\n";
static char PGP_EPILOG[] = "\r\n-----END PGP MESSAGE-----\r\n";
@@ -936,8 +913,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz {
char szClientJid[JABBER_MAX_JID_LEN];
if (!m_bJabberOnline || !GetClientJID(hContact, szClientJid, _countof(szClientJid))) {
- TFakeAckParams *param = new TFakeAckParams(hContact, TranslateT("Protocol is offline or no JID"));
- ForkThread(&CJabberProto::SendMessageAckThread, param);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, 0, (LPARAM)TranslateT("Protocol is offline or no JID"));
return 1;
}
@@ -945,8 +921,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz if (!OmemoCheckSession(hContact)) {
OmemoPutMessageToOutgoingQueue(hContact, unused_unknown, pszSrc);
int id = SerialNext();
- TFakeAckParams *param = new TFakeAckParams(hContact, nullptr, id);
- ForkThread(&CJabberProto::SendMessageAckThread, param);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id);
return id;
}
}
@@ -974,8 +949,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz if (m_bUseOMEMO && OmemoIsEnabled(hContact) && !mir_strcmp(msgType, "chat")) {
// TODO: check if message encrypted for at least one session and return error if not
if (!OmemoEncryptMessage(m, pszSrc, hContact)) {
- TFakeAckParams *param = new TFakeAckParams(hContact, TranslateT("No valid OMEMO session exists"));
- ForkThread(&CJabberProto::SendMessageAckThread, param);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, 0, (LPARAM)TranslateT("No valid OMEMO session exists"));
return 0;
}
}
@@ -1024,7 +998,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz m_ThreadInfo->send(m);
- ForkThread(&CJabberProto::SendMessageAckThread, new TFakeAckParams(hContact, nullptr, id));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id);
}
else {
XmlAddAttrID(m, id);
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 57647a9733..0f22c2e977 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -705,53 +705,18 @@ int CMsnProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre) }
/////////////////////////////////////////////////////////////////////////////////////////
-
-struct TFakeAckParams
-{
- inline TFakeAckParams(MCONTACT p2, long p3, const char* p4, CMsnProto *p5, int p6 = ACKTYPE_MESSAGE) :
- hContact(p2),
- id(p3),
- msg(p4),
- proto(p5),
- type(p6)
- {}
-
- MCONTACT hContact;
- int type;
- long id;
- const char* msg;
- CMsnProto *proto;
-};
-
-void CMsnProto::MsnFakeAck(void* arg)
-{
- TFakeAckParams* tParam = (TFakeAckParams*)arg;
-
- Sleep(150);
- tParam->proto->ProtoBroadcastAck(tParam->hContact, tParam->type,
- tParam->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
- (HANDLE)tParam->id, LPARAM(tParam->msg));
-
- delete tParam;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// MsnSendMessage - sends the message to a server
int CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
{
- const char *errMsg = nullptr;
-
if (!msnLoggedIn) {
- errMsg = Translate("Protocol is offline");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)999999, (LPARAM)Translate("Protocol is offline"));
return 999999;
}
char tEmail[MSN_MAX_EMAIL_LEN];
if (MSN_IsMeByContact(hContact, tEmail)) {
- errMsg = Translate("You cannot send message to yourself");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)999999, (LPARAM)Translate("You cannot send message to yourself"));
return 999999;
}
@@ -767,43 +732,39 @@ int CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) switch (netId) {
case NETID_MOB:
if (mir_strlen(msg) > 133) {
- errMsg = Translate("Message is too long: SMS page limited to 133 UTF8 chars");
seq = 999997;
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, (LPARAM)Translate("Message is too long: SMS page limited to 133 UTF8 chars"));
}
else {
- errMsg = nullptr;
seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag);
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
}
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
break;
case NETID_YAHOO:
if (mir_strlen(msg) > 1202) {
seq = 999996;
- errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, (LPARAM)Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"));
}
else {
seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag);
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, nullptr, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
}
break;
default:
if (mir_strlen(msg) > 1202) {
seq = 999996;
- errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, (LPARAM)Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"));
}
else {
if (netId != NETID_LCS) {
seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE);
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, nullptr, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
}
else {
seq = 999993;
- errMsg = Translate("Offline messaging is not allowed for LCS contacts");
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, (LPARAM)Translate("Offline messaging is not allowed for LCS contacts"));
}
}
break;
@@ -835,7 +796,7 @@ int CMsnProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT *hCo }
msg.Append("</contacts>");
seq = msnNsThread->sendMessage('1', tEmail, netId, msg, MSG_CONTACT);
- ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, nullptr, this, ACKTYPE_CONTACTS));
+ ProtoBroadcastAsync(hContact, ACKTYPE_CONTACTS, ACKRESULT_SUCCESS, (HANDLE)seq);
return seq;
}
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 347757ab75..0d0fa760a1 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -246,8 +246,6 @@ struct CMsnProto : public PROTO<CMsnProto> void __cdecl MsnFileAckThread(void* arg);
void __cdecl MsnSearchAckThread(void* arg);
- void __cdecl sttFakeAvatarAck(void* arg);
- void __cdecl MsnFakeAck(void* arg);
void __cdecl MsnGetAwayMsgThread(void* arg);
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 8d9ef1105c..9c20fd7c50 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -55,12 +55,6 @@ INT_PTR CMsnProto::GetAvatar(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// MsnGetAvatarInfo - retrieve the avatar info
-void CMsnProto::sttFakeAvatarAck(void* arg)
-{
- Sleep(100);
- ProtoBroadcastAck(((PROTO_AVATAR_INFORMATION*)arg)->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, arg);
-}
-
INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION*)lParam;
@@ -69,7 +63,8 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (pai->hContact) {
cont = Lists_Get(pai->hContact);
- if (cont == nullptr) return GAIR_NOAVATAR;
+ if (cont == nullptr)
+ return GAIR_NOAVATAR;
/*
if ((cont->cap1 & 0xf0000000) == 0)
@@ -125,9 +120,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) WORD wStatus = getWord(pai->hContact, "Status", ID_STATUS_OFFLINE);
if (wStatus == ID_STATUS_OFFLINE) {
delSetting(pai->hContact, "AvatarHash");
- PROTO_AVATAR_INFORMATION *fakeAI = new PROTO_AVATAR_INFORMATION;
- *fakeAI = *pai;
- ForkThread(&CMsnProto::sttFakeAvatarAck, fakeAI);
+ ProtoBroadcastAck(pai->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, pai);
}
else if (!getString(pai->hContact, "AvatarUrl", &dbv)) {
pushAvatarRequest(pai->hContact, dbv.pszVal);
diff --git a/protocols/NewsAggregator/Src/Services.cpp b/protocols/NewsAggregator/Src/Services.cpp index eda85edfdc..b7abe6146c 100644 --- a/protocols/NewsAggregator/Src/Services.cpp +++ b/protocols/NewsAggregator/Src/Services.cpp @@ -116,16 +116,10 @@ INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM) return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(g_plugin.getIcon(IDI_ICON)) : 0; } -static void __cdecl AckThreadProc(void *param) -{ - Sleep(100); - ProtoBroadcastAck(MODULENAME, (MCONTACT)param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1); -} - INT_PTR NewsAggrGetInfo(WPARAM, LPARAM lParam) { CCSDATA *ccs = (CCSDATA *)lParam; - mir_forkthread(AckThreadProc, (void*)ccs->hContact); + ProtoBroadcastAsync(MODULENAME, ccs->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1); return 0; } 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<TFakeAckParams>(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<TFakeAckParams>(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<TFakeAckParams>(sttFakeAckMessageSuccessThread, tfap);
-
+ ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)ret);
return ret;
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 62ecf196e8..8b357a0dce 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -167,7 +167,6 @@ private: // contacts search
void __cdecl SearchByNameAsync(void *arg);
- void __cdecl SearchFailedAsync(void *arg);
static INT_PTR CALLBACK SearchDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 83e4b883cb..b36b66e80c 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -49,12 +49,6 @@ void CToxProto::SearchByNameAsync(void *arg) mir_free(arg);
}
-void CToxProto::SearchFailedAsync(void*)
-{
- Thread_SetName(MODULE ": SearchFailedThread");
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HWND)1, 0);
-}
-
INT_PTR CToxProto::SearchDlgProc(HWND hwnd, UINT uMsg, WPARAM, LPARAM lParam)
{
CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
@@ -96,14 +90,14 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) psr.id.a = mir_strdup(query.c_str());
Contact_AddBySearch(m_szModuleName, &psr, owner);
- ForkThread(&CToxProto::SearchFailedAsync, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
}
else {
regex = "^\\s*(([^ @/:;()\"']+)(@[A-Za-z]+.[A-Za-z]{2,6})?)\\s*$";
if (std::regex_search(query, match, regex))
ForkThread(&CToxProto::SearchByNameAsync, mir_strdup(query.c_str()));
else
- ForkThread(&CToxProto::SearchFailedAsync, nullptr);
+ ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1);
}
return (HWND)1;
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 3629a59f35..e2780da7b1 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -118,33 +118,6 @@ INT_PTR CTwitterProto::GetCaps(int type, MCONTACT) /////////////////////////////////////////////////////////////////////////////////////////
-struct TSendDirect
-{
- __inline TSendDirect(MCONTACT _hContact, const CMStringA &_msg, int _msgid) :
- hContact(_hContact), msg(_msg), msgid(_msgid)
- {}
-
- MCONTACT hContact;
- CMStringA msg;
- int msgid;
-};
-
-void CTwitterProto::SendSuccess(void *p)
-{
- if (p == nullptr)
- return;
-
- auto *data = (TSendDirect*)p;
-
- CMStringA id(getMStringA(data->hContact, TWITTER_KEY_ID));
- if (!id.IsEmpty()) {
- send_direct(id, data->msg);
- ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)data->msgid, 0);
- }
-
- delete data;
-}
-
MEVENT CTwitterProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
{
MEVENT res = CSuper::RecvMsg(hContact, pre);
@@ -158,8 +131,14 @@ int CTwitterProto::SendMsg(MCONTACT hContact, int, const char *msg) if (m_iStatus != ID_STATUS_ONLINE)
return 0;
+ CMStringA id(getMStringA(hContact, TWITTER_KEY_ID));
+ if (id.IsEmpty())
+ return 0;
+
+ send_direct(id, msg);
+
int seq = InterlockedIncrement(&g_msgid);
- ForkThread(&CTwitterProto::SendSuccess, new TSendDirect(hContact, msg, seq));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)seq);
return seq;
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 498925ff4a..ba2773a18c 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -202,7 +202,6 @@ public: // Threads
void __cdecl AddToListWorker(void *p);
- void __cdecl SendSuccess(void *);
void __cdecl DoSearch(void *);
void __cdecl SignOn(void *);
void __cdecl MessageLoop(void *);
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index fcf50d7fd5..bfdcf3003d 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -19,15 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////////////
-void CVkProto::SendMsgAck(void *param)
-{
- debugLogA("CVkProto::SendMsgAck");
- CVkSendMsgParam *ack = (CVkSendMsgParam *)param;
- Sleep(100);
- ProtoBroadcastAck(ack->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)ack->iMsgID);
- delete ack;
-}
-
int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
{
debugLogA("CVkProto::SendMsg");
@@ -38,7 +29,7 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID", VK_INVALID_USER);
if (iUserID == VK_INVALID_USER || iUserID == VK_FEED_USER) {
- ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, 0);
return 0;
}
@@ -70,7 +61,7 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) Push(pReq);
if (!m_vkOptions.bServerDelivery && !bIsChat)
- ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, uMsgId));
+ ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)uMsgId);
if (!IsEmpty(pszRetMsg))
SendMsg(hContact, 0, pszRetMsg);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 8a356310ec..bad4617a4b 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -385,7 +385,6 @@ private: void SetAvatarUrl(MCONTACT hContact, CMStringW &wszUrl);
void GetAvatarFileName(MCONTACT hContact, wchar_t *pwszDest, size_t cbLen);
void ReloadAvatarInfo(MCONTACT hContact);
- void __cdecl SendMsgAck(void *param);
void __cdecl ChatContactTypingThread(void *p);
void StopChatContactTyping(int iChatId, LONG iUserId);
void OnCreateNewChat(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp index c3c9b4ab4b..bc86236668 100644 --- a/protocols/Weather/src/weather_svcs.cpp +++ b/protocols/Weather/src/weather_svcs.cpp @@ -170,12 +170,8 @@ static void __cdecl WeatherGetAwayMsgThread(void *arg) Sleep(100); MCONTACT hContact = (DWORD_PTR)arg; - DBVARIANT dbv; - if (!db_get_ws(hContact, "CList", "StatusMsg", &dbv)) { - ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.pwszVal); - db_free(&dbv); - } - else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1); + ptrW wszStatus(db_get_wsa(hContact, "CList", "StatusMsg")); + ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, wszStatus); } static INT_PTR WeatherGetAwayMsg(WPARAM, LPARAM lParam) 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 };
|