diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-27 21:04:41 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-27 21:04:41 +0300 |
commit | 390d3ecc13780511a2416eb4eb82a14a06516945 (patch) | |
tree | d2b134d10b92e78b8375e106e5fcb957a72d3b22 /protocols/ICQ-WIM/src/utils.cpp | |
parent | e0b3359cf55fbf3d83faad624265d928023f0928 (diff) |
fixes #3810 (ICQ: неверно работает Last seen в user details)
Diffstat (limited to 'protocols/ICQ-WIM/src/utils.cpp')
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index 56ef3dce88..6db1050801 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -169,10 +169,17 @@ bool IsValidType(const JSONNode &n) int CIcqProto::StatusFromPresence(const JSONNode &presence, MCONTACT hContact)
{
+ auto *pUser = FindUser(GetUserId(hContact));
+ if (pUser == nullptr)
+ return -1;
+
CMStringW wszStatus = presence["state"].as_mstring();
int iStatus;
- if (wszStatus == L"online")
+ if (wszStatus == L"online") {
+ pUser->m_bWasOnline = true;
iStatus = ID_STATUS_ONLINE;
+ setDword(hContact, DB_KEY_ONLINETS, time(0));
+ }
else if (wszStatus == L"offline")
iStatus = ID_STATUS_OFFLINE;
else if (wszStatus == L"n/a")
@@ -187,17 +194,21 @@ int CIcqProto::StatusFromPresence(const JSONNode &presence, MCONTACT hContact) return -1;
int iLastSeen = presence["lastseen"].as_int();
- if (iLastSeen != 0)
- setDword(hContact, DB_KEY_LASTSEEN, iLastSeen);
+ if (iLastSeen != 0) {
+ if (iLastSeen == 1388520000) // 01/01/2014, 00:00 GMT
+ setWString(hContact, DB_KEY_LASTSEEN, TranslateT("long time ago"));
+ else
+ setDword(hContact, DB_KEY_LASTSEEN, iLastSeen);
+ }
else {
- if (getDword(hContact, DB_KEY_ONLINETS))
+ if (pUser->m_bWasOnline) {
iStatus = ID_STATUS_ONLINE;
+ setDword(hContact, DB_KEY_ONLINETS, time(0));
+ }
else {
- if (auto *pUser = FindUser(GetUserId(hContact))) {
- mir_cslock lck(m_csLastSeenQueue);
- m_arLastSeenQueue.insert(pUser);
- m_impl.m_lastSeen.Start(500);
- }
+ mir_cslock lck(m_csLastSeenQueue);
+ m_arLastSeenQueue.insert(pUser);
+ m_impl.m_lastSeen.Start(500);
return -1;
}
}
@@ -255,14 +266,32 @@ CMStringW fileText2url(const CMStringW &wszText) /////////////////////////////////////////////////////////////////////////////////////////
+static wchar_t g_statBuf[100];
+
+wchar_t* time2text(DBVARIANT *dbv)
+{
+ switch (dbv->type) {
+ case DBVT_WCHAR:
+ return dbv->pwszVal;
+
+ case DBVT_DWORD:
+ return time2text(time_t(dbv->dVal));
+
+ case DBVT_UTF8:
+ wcsncpy_s(g_statBuf, Utf2T(dbv->pszVal), _TRUNCATE);
+ return g_statBuf;
+ }
+
+ return L"";
+}
+
wchar_t* time2text(time_t ts)
{
if (ts == 0)
return L"";
- static wchar_t buf[100];
- TimeZone_PrintTimeStamp(NULL, ts, L"D t", buf, _countof(buf), 0);
- return buf;
+ TimeZone_PrintTimeStamp(NULL, ts, L"D t", g_statBuf, _countof(g_statBuf), 0);
+ return g_statBuf;
}
/////////////////////////////////////////////////////////////////////////////////////////
|