diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-29 17:40:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-29 17:40:30 +0300 |
commit | f3171017912e0d2d375447d19a786d55302ec3e7 (patch) | |
tree | 49f6878ccafd215b35a08d2bbb008f1269d9a9b5 /protocols/ICQ-WIM | |
parent | f72431f2d07395eb2a35929ad85d28dc3a1eacee (diff) |
ICQ-WIM: more foolproof solution to delete records
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 46 |
2 files changed, 26 insertions, 22 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 52620647ca..5a87f0af89 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -36,7 +36,7 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : PROTO<CIcqProto>(aProtoName, aUserName), m_arHttpQueue(10), - m_arOwnIds(1), + m_arOwnIds(1, PtrKeySortT), m_arCache(20, NumericKeySortT), arMarkReadQueue(10, NumericKeySortT), m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)), diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 2a64a0f731..afca983fb3 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -46,24 +46,33 @@ void CIcqProto::CheckLastId(MCONTACT hContact, const JSONNode &ev) MCONTACT CIcqProto::CheckOwnMessage(const CMStringA &reqId, const CMStringA &msgId, bool bRemove) { - for (auto &own: m_arOwnIds) { - if (!mir_strcmp(reqId, own->m_guid)) { - ProtoBroadcastAck(own->m_hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)own->m_msgid, (LPARAM)msgId.c_str()); - - MCONTACT ret = own->m_hContact; - if (bRemove) { - // here we filter service messages for SecureIM, OTR etc, i.e. messages that - // weren't initialized by SRMM (we identify it by missing server id) - if (db_event_getById(m_szModuleName, msgId) == 0) - db_event_setId(m_szModuleName, 1, msgId); - - mir_cslock lck(m_csOwnIds); - m_arOwnIds.remove(m_arOwnIds.indexOf(&own)); + IcqOwnMessage *pOwn = nullptr; + { + mir_cslock lck(m_csOwnIds); + for (auto &it : m_arOwnIds) { + if (reqId == it->m_guid) { + pOwn = it; + break; } - return ret; } } - return 0; + + if (pOwn == nullptr) + return 0; + + ProtoBroadcastAck(pOwn->m_hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)pOwn->m_msgid, (LPARAM)msgId.c_str()); + + MCONTACT ret = pOwn->m_hContact; + if (bRemove) { + // here we filter service messages for SecureIM, OTR etc, i.e. messages that + // weren't initialized by SRMM (we identify it by missing server id) + if (db_event_getById(m_szModuleName, msgId) == 0) + db_event_setId(m_szModuleName, 1, msgId); + + mir_cslock lck(m_csOwnIds); + m_arOwnIds.remove(pOwn); + } + return ret; } void CIcqProto::CheckPassword() @@ -713,12 +722,7 @@ void CIcqProto::OnSendMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) ProtoBroadcastAck(ownMsg->m_hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)ownMsg->m_msgid, 0); mir_cslock lck(m_csOwnIds); - for (auto &it : m_arOwnIds) { - if (it == ownMsg) { - m_arOwnIds.remove(m_arOwnIds.indexOf(&it)); - break; - } - } + m_arOwnIds.remove(ownMsg); } const JSONNode &data = root.data(); |