From 2ffa7047ec0475856481b9e813eecb99b268d2d0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Apr 2013 10:41:27 +0000 Subject: protocols must return unique ids on SendMsg git-svn-id: http://svn.miranda-ng.org/main/trunk@4481 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Twitter/src/proto.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'protocols/Twitter/src/proto.cpp') diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 03b2538910..5a1aa801f6 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -29,6 +29,8 @@ along with this program. If not, see . #include #include +static volatile LONG g_msgid = 1; + TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) { ProtoConstructor(this, proto_name, username); @@ -129,9 +131,13 @@ int TwitterProto::RecvMsg(HANDLE hContact,PROTORECVEVENT *pre) struct send_direct { - send_direct(HANDLE hContact,const std::string &msg) : hContact(hContact),msg(msg) {} + __inline send_direct(HANDLE _hContact, const std::string &_msg, int _msgid) : + hContact(_hContact), msg(_msg), msgid(_msgid) + {} + HANDLE hContact; std::string msg; + int msgid; }; void TwitterProto::SendSuccess(void *p) @@ -146,7 +152,7 @@ void TwitterProto::SendSuccess(void *p) ScopedLock s(twitter_lock_); twit_.send_direct(dbv.pszVal,data->msg); - ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS,(HANDLE)1,0); + ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS,(HANDLE)data->msgid,0); db_free(&dbv); } @@ -166,8 +172,9 @@ int TwitterProto::SendMsg(HANDLE hContact,int flags,const char *msg) else tszMsg = mir_a2t( msg ); - ForkThread(&TwitterProto::SendSuccess, this,new send_direct(hContact,msg)); - return 1; + int seq = InterlockedIncrement(&g_msgid); + ForkThread(&TwitterProto::SendSuccess, this,new send_direct(hContact, msg, seq)); + return seq; } // ************************* -- cgit v1.2.3