From 3d56e7622af87e2f39ba759ee3761dafc8278d56 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jan 2024 21:53:39 +0300 Subject: ICQ: when a history is loaded from server, offline files are resfreshed too --- protocols/ICQ-WIM/src/proto.h | 2 +- protocols/ICQ-WIM/src/server.cpp | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'protocols') diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 72da1da766..027747b562 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -243,7 +243,7 @@ class CIcqProto : public PROTO void Json2string(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting, bool bIsPartial); MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = INVALID_CONTACT_ID, bool bIsPartial = false); void ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &msg, bool bCreateRead, bool bLocalTime); - void ParseMessagePart(MCONTACT hContact, const JSONNode &msg, MEVENT hOldEvent, IcqFileInfo *&pFileInfo); + void ParseMessagePart(MCONTACT hContact, const JSONNode &msg, IcqFileInfo *&pFileInfo); IcqFileInfo* RetrieveFileInfo(MCONTACT hContact, const CMStringW &wszUrl); int StatusFromPresence(const JSONNode &presence, MCONTACT hContact); void ProcessPatchVersion(MCONTACT hContact, __int64 currPatch); diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 137be511a4..b67df41639 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -542,7 +542,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo else if (szType == "quote") pQuote = &jt; else if (szType == "text") - ParseMessagePart(hContact, jt, hOldEvent, pFileInfo); + ParseMessagePart(hContact, jt, pFileInfo); } if (pForward) { @@ -551,7 +551,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo wszText.Truncate(idx + 2); if (!pFileInfo) { - ParseMessagePart(hContact, *pForward, hOldEvent, pFileInfo); + ParseMessagePart(hContact, *pForward, pFileInfo); if (pFileInfo) pFileInfo->wszDescr = wszText; } @@ -561,7 +561,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo szReply = pQuote->at("msgId").as_mstring(); if (!pFileInfo) { - ParseMessagePart(hContact, *pQuote, hOldEvent, pFileInfo); + ParseMessagePart(hContact, *pQuote, pFileInfo); if (pFileInfo) pFileInfo->wszDescr = wszText; } @@ -593,7 +593,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo auto *p = strrchr(pFileInfo->szUrl, '/'); auto *pszShortName = (p == nullptr) ? pFileInfo->szUrl.c_str() : p + 1; - DB::EventInfo dbei; + DB::EventInfo dbei(hOldEvent); dbei.flags = DBEF_TEMPORARY; dbei.szId = szMsgId; dbei.timestamp = iMsgTime; @@ -605,7 +605,13 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo dbei.szReplyId = szReply; if (isChatRoom(hContact)) dbei.szUserId = szSender; - ProtoChainRecvFile(hContact, DB::FILE_BLOB(pFileInfo, pszShortName, T2Utf(pFileInfo->wszDescr)), dbei); + + DB::FILE_BLOB blob(pFileInfo, pszShortName, T2Utf(pFileInfo->wszDescr)); + if (hOldEvent) { + blob.write(dbei); + db_event_edit(hOldEvent, &dbei, true); + } + else ProtoChainRecvFile(hContact, blob, dbei); return; } @@ -655,7 +661,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo } } -void CIcqProto::ParseMessagePart(MCONTACT hContact, const JSONNode &part, MEVENT hOldEvent, IcqFileInfo *&pFileInfo) +void CIcqProto::ParseMessagePart(MCONTACT hContact, const JSONNode &part, IcqFileInfo *&pFileInfo) { if (pFileInfo != nullptr) return; @@ -665,10 +671,6 @@ void CIcqProto::ParseMessagePart(MCONTACT hContact, const JSONNode &part, MEVENT if (wszUrl.IsEmpty()) return; - CMStringW wszText(part["text"].as_mstring()); - if (hOldEvent && fileText2url(wszText)) - return; - if (!CheckFile(hContact, wszUrl, pFileInfo)) return; -- cgit v1.2.3