summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp18
-rw-r--r--protocols/ICQ-WIM/src/proto.h9
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp4
-rw-r--r--protocols/ICQ-WIM/src/version.h4
4 files changed, 24 insertions, 11 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index d5018a3d53..5e1385ba99 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -199,18 +199,28 @@ void CIcqProto::ProcessHistData(const JSONNode &ev)
__int64 patchVersion = _wtoi64(ev["patchVersion"].as_mstring());
setId(hContact, DB_KEY_PATCHVER, patchVersion);
+ auto *pCache = FindContactByUIN(wszId); // might be NULL for groupchats
+ __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring());
+
// we load history in the very beginning or if the previous message
if (m_bFirstBos) {
- __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring());
+ if (pCache)
+ pCache->m_iProcessedMsgId = srvLastId;
+
if (srvLastId > lastMsgId) {
debugLogA("We need to retrieve history for %S: %lld > %lld", wszId.c_str(), srvLastId, lastMsgId);
RetrieveUserHistory(hContact, lastMsgId, false);
}
}
else {
- for (auto &it : ev["tail"]["messages"])
- ParseMessage(hContact, lastMsgId, it, false, true);
- setId(hContact, DB_KEY_LASTMSGID, lastMsgId);
+ if (!(pCache && pCache->m_iProcessedMsgId >= srvLastId)) {
+ for (auto &it : ev["tail"]["messages"])
+ ParseMessage(hContact, lastMsgId, it, false, true);
+
+ setId(hContact, DB_KEY_LASTMSGID, lastMsgId);
+ if (pCache)
+ pCache->m_iProcessedMsgId = lastMsgId;
+ }
}
// check remote read
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index eb0c5fe6a9..81b8c82789 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -100,10 +100,11 @@ struct IcqCacheItem : public MZeroedObject
{}
CMStringW m_aimid;
- MCONTACT m_hContact;
- bool m_bInList;
- int m_iApparentMode;
- time_t m_timer1, m_timer2;
+ MCONTACT m_hContact;
+ bool m_bInList;
+ __int64 m_iProcessedMsgId;
+ int m_iApparentMode;
+ time_t m_timer1, m_timer2;
};
struct IcqOwnMessage
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index e5090ceb56..8fe19cd0a9 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -42,7 +42,9 @@ void CIcqProto::InitContactCache()
}
}
- m_arCache.insert(new IcqCacheItem(GetUserId(it), it));
+ auto *pCache = new IcqCacheItem(GetUserId(it), it);
+ pCache->m_iProcessedMsgId = getId(it, DB_KEY_LASTMSGID);
+ m_arCache.insert(pCache);
}
}
diff --git a/protocols/ICQ-WIM/src/version.h b/protocols/ICQ-WIM/src/version.h
index 8c60696fe5..3d933bf223 100644
--- a/protocols/ICQ-WIM/src/version.h
+++ b/protocols/ICQ-WIM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
-#define __RELEASE_NUM 11
-#define __BUILD_NUM 11
+#define __RELEASE_NUM 12
+#define __BUILD_NUM 1
#include <stdver.h>