From 7442e2473e41113ca0fbb40c7816267b3e5cbd16 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 29 Jan 2015 19:45:00 +0000 Subject: fix for user typing notifications git-svn-id: http://svn.miranda-ng.org/main/trunk@11953 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 2 +- protocols/WhatsApp/src/chat.cpp | 2 -- protocols/WhatsApp/src/entities.h | 7 ----- protocols/WhatsApp/src/messages.cpp | 33 ++++++---------------- protocols/WhatsApp/src/proto.h | 2 -- 5 files changed, 10 insertions(+), 36 deletions(-) (limited to 'protocols/WhatsApp') diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index fcb659e97b..b5f52bb1e2 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -208,7 +208,7 @@ bool WAConnection::read() throw(WAException) parseAck(node); else if (ProtocolTreeNode::tagEquals(node, "receipt")) parseReceipt(node); - else if (ProtocolTreeNode::tagEquals(node, "chatstates")) + else if (ProtocolTreeNode::tagEquals(node, "chatstate")) parseChatStates(node); delete node; diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 4c3d3afeeb..361da25850 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -38,8 +38,6 @@ int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam) debugLogA("**Chat - Outgoing message: %s", text); this->SendMsg(hContact, IS_CHAT, msg.c_str()); - // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda - GCDEST gcd = { m_szModuleName, hook->pDest->ptszID, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; diff --git a/protocols/WhatsApp/src/entities.h b/protocols/WhatsApp/src/entities.h index 7cf037792e..c55e3dfd8a 100644 --- a/protocols/WhatsApp/src/entities.h +++ b/protocols/WhatsApp/src/entities.h @@ -12,13 +12,6 @@ struct send_direct HANDLE msgid; }; -struct send_typing -{ - send_typing(MCONTACT hContact, const int status) : hContact(hContact), status(status) {} - MCONTACT hContact; - int status; -}; - struct input_box { tstring text; diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp index 37b2ebad65..e139af9512 100644 --- a/protocols/WhatsApp/src/messages.cpp +++ b/protocols/WhatsApp/src/messages.cpp @@ -87,32 +87,17 @@ void WhatsAppProto::onIsTyping(const std::string& paramString, bool paramBoolean int WhatsAppProto::UserIsTyping(MCONTACT hContact, int type) { - if (hContact && isOnline()) - ForkThread(&WhatsAppProto::SendTypingWorker, new send_typing(hContact, type)); - - return 0; -} - -void WhatsAppProto::SendTypingWorker(void* p) -{ - if (p == NULL) - return; - - send_typing *typing = static_cast(p); - - // Don't send typing notifications to contacts which are offline - if (getWord(typing->hContact, "Status", 0) == ID_STATUS_OFFLINE) - return; - - ptrA jid(getStringA(typing->hContact, WHATSAPP_KEY_ID)); - if (jid && this->isOnline()) { - if (typing->status == PROTOTYPE_SELFTYPING_ON) - m_pConnection->sendComposing((char*)jid); - else - m_pConnection->sendPaused((char*)jid); + if (hContact && isOnline()) { + ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); + if (jid && isOnline()) { + if (type == PROTOTYPE_SELFTYPING_ON) + m_pConnection->sendComposing((char*)jid); + else + m_pConnection->sendPaused((char*)jid); + } } - delete typing; + return 0; } void WhatsAppProto::onMessageStatusUpdate(FMessage* fmsg) diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index 09e98b8a7c..cff4d14f65 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -103,8 +103,6 @@ public: ////////////////////////////////////////////////////////////////////////////////////// // Worker Threads - void __cdecl SendMsgWorker(void*); - void __cdecl SendTypingWorker(void*); void __cdecl SendGetGroupInfoWorker(void*); void __cdecl SendSetGroupNameWorker(void*); void __cdecl SendCreateGroupWorker(void*); -- cgit v1.2.3