summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM/src/proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-12-24 17:03:50 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-12-24 17:03:50 +0300
commitca6bffd6d1a5d38d2c5f151a2e831d517e4ccbc2 (patch)
treeaab6760c07ce9256647543d6aa0430f848299a3b /protocols/ICQ-WIM/src/proto.cpp
parent93af1070aaa1de81d573ff0ec879e74df036dd01 (diff)
fixes #2282 (ICQ: add message deletion support)
Diffstat (limited to 'protocols/ICQ-WIM/src/proto.cpp')
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index b6f27ec26a..3b00ee14c5 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -45,6 +45,7 @@ CIcqProto::CIcqProto(const char *aProtoName, const wchar_t *aUserName) :
m_arOwnIds(1, PtrKeySortT),
m_arCache(20, &CompareCache),
m_arGroups(10, NumericKeySortT),
+ m_arDeleteQueue(10),
m_arMarkReadQueue(10, NumericKeySortT),
m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
m_szOwnId(this, DB_KEY_ID),
@@ -202,6 +203,44 @@ void CIcqProto::OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// batch events deletion from the server
+
+void CIcqProto::BatchDeleteMsg()
+{
+ auto *pReq = new AsyncRapiRequest(this, "delMsgBatch");
+
+ JSONNode ids(JSON_ARRAY); ids.set_name("msgIds");
+
+ mir_cslock lck(m_csDeleteQueue);
+ for (auto &it : m_arDeleteQueue) {
+ ids.push_back(JSONNode("", _atoi64(it)));
+ mir_free(it);
+ }
+
+ pReq->params << WCHAR_PARAM("sn", GetUserId(m_hDeleteContact)) << BOOL_PARAM("shared", true) << ids;
+ Push(pReq);
+
+ m_arDeleteQueue.destroy();
+ m_hDeleteContact = INVALID_CONTACT_ID;
+}
+
+void CIcqProto::OnEventDeleted(MCONTACT hContact, MEVENT hEvent)
+{
+ if (m_hDeleteContact != INVALID_CONTACT_ID)
+ if (m_hDeleteContact != hContact)
+ BatchDeleteMsg();
+
+ DB::EventInfo dbei(hEvent, false);
+ if (!dbei || !dbei.szId)
+ return;
+
+ mir_cslock lck(m_csDeleteQueue);
+ m_hDeleteContact = hContact;
+ m_arDeleteQueue.insert(mir_strdup(dbei.szId));
+ m_impl.m_delete.Start(100);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
void CIcqProto::OnFileRecv(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
{
@@ -338,6 +377,7 @@ INT_PTR CIcqProto::SvcGotoInbox(WPARAM, LPARAM)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// mark events read at the server
void CIcqProto::SendMarkRead()
{