diff options
author | George Hazan <ghazan@miranda.im> | 2021-08-06 22:19:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-08-06 22:19:50 +0300 |
commit | 8cef81c096966af5775861220e67432648a29a7e (patch) | |
tree | 3cb143c8d10afbfc16a08b7321ada952602438f1 /protocols/ICQ-WIM/src | |
parent | ef7ba795a1a2be36522c67a06822fbe3ec972782 (diff) |
ICQ: same idea for presence packets
Diffstat (limited to 'protocols/ICQ-WIM/src')
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index bbf0792cc9..918782e5cc 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -321,26 +321,31 @@ void CIcqProto::ProcessPresence(const JSONNode &ev) CMStringW aimId = ev["aimId"].as_mstring(); IcqCacheItem *pCache = FindContactByUIN(aimId); - if (pCache) { - int iNewStatus = StatusFromString(ev["state"].as_mstring()); - - // major crutch dedicated to the official client behaviour to go offline - // when its window gets closed. we change the status of a contact to the - // first chosen one from options and initialize a timer - if (iNewStatus == ID_STATUS_OFFLINE) { - if (m_iTimeDiff1) { - iNewStatus = m_iStatus1; - pCache->m_timer1 = time(0); - } - } - // if a client returns back online, we clear timers not to play with statuses anymore - else pCache->m_timer1 = pCache->m_timer2 = 0; + if (pCache == nullptr) + return; - setWord(pCache->m_hContact, "Status", iNewStatus); + int iNewStatus = StatusFromString(ev["state"].as_mstring()); - Json2string(pCache->m_hContact, ev, "friendly", "Nick"); - CheckAvatarChange(pCache->m_hContact, ev); + int iLastSeen = ev["lastseen"].as_int(); + if (iLastSeen == 0) + iNewStatus = ID_STATUS_ONLINE; + + // major crutch dedicated to the official client behaviour to go offline + // when its window gets closed. we change the status of a contact to the + // first chosen one from options and initialize a timer + if (iNewStatus == ID_STATUS_OFFLINE) { + if (m_iTimeDiff1) { + iNewStatus = m_iStatus1; + pCache->m_timer1 = time(0); + } } + // if a client returns back online, we clear timers not to play with statuses anymore + else pCache->m_timer1 = pCache->m_timer2 = 0; + + setWord(pCache->m_hContact, "Status", iNewStatus); + + Json2string(pCache->m_hContact, ev, "friendly", "Nick"); + CheckAvatarChange(pCache->m_hContact, ev); } void CIcqProto::ProcessSessionEnd(const JSONNode &/*ev*/) |