summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-04 22:51:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-04 22:51:49 +0300
commit5e3a8cf7fddfadc0b3e9a0165cbc903c7be1e68a (patch)
treea04968cfc01ab72a83f812ded7a9f8868899d18e /protocols/ICQ-WIM/src
parent338a21fdbdab5863b17dd64aa087110cc33049d6 (diff)
nah... we immediately use the first status when a contact goes offline, then the second one, then ID_STATUS_OFFLINE
Diffstat (limited to 'protocols/ICQ-WIM/src')
-rw-r--r--protocols/ICQ-WIM/src/options.cpp2
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp17
-rw-r--r--protocols/ICQ-WIM/src/server.cpp23
3 files changed, 25 insertions, 17 deletions
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp
index dbac044638..f470d604de 100644
--- a/protocols/ICQ-WIM/src/options.cpp
+++ b/protocols/ICQ-WIM/src/options.cpp
@@ -191,7 +191,7 @@ public:
bool OnInitDialog() override
{
if (cmbStatus1.GetHwnd()) {
- for (int iStatus = ID_STATUS_OFFLINE; iStatus <= ID_STATUS_OUTTOLUNCH; iStatus++) {
+ for (DWORD iStatus = ID_STATUS_OFFLINE; iStatus <= ID_STATUS_OUTTOLUNCH; iStatus++) {
int idx = cmbStatus1.AddString(Clist_GetStatusModeDescription(iStatus, 0));
cmbStatus1.SetItemData(idx, iStatus);
if (iStatus == m_proto->m_iStatus1)
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index e6553c1f51..4b31779393 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -195,19 +195,18 @@ void CIcqProto::ProcessPresence(const JSONNode &ev)
int iNewStatus = StatusFromString(ev["state"].as_mstring());
// major crutch dedicated to the official client behaviour to go offline
- // when its window gets closed. we don't really change the status of a contact
- // but initialize a timer instead
+ // 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)
+ if (m_iTimeDiff1) {
+ iNewStatus = m_iStatus1;
pCache->m_timer1 = time(0);
- else
- setDword(pCache->m_hContact, "Status", iNewStatus);
+ }
}
// if a client returns back online, we clear timers not to play with statuses anymore
- else {
- pCache->m_timer1 = pCache->m_timer2 = 0;
- setDword(pCache->m_hContact, "Status", iNewStatus);
- }
+ else pCache->m_timer1 = pCache->m_timer2 = 0;
+
+ setDword(pCache->m_hContact, "Status", iNewStatus);
Json2string(pCache->m_hContact, ev, "friendly", "Nick");
CheckAvatarChange(pCache->m_hContact, ev);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index c7f7bb3c05..9c0c199c8a 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -103,16 +103,25 @@ void CIcqProto::CheckStatus()
int diff1 = m_iTimeDiff1, diff2 = m_iTimeDiff2;
for (auto &it : m_arCache) {
- if (diff2 && it->m_timer2 && now - it->m_timer2 > m_iTimeDiff2) {
- it->m_timer2 = 0;
- setDword(it->m_hContact, "Status", m_iStatus2);
+ // this contact is really offline and is on the first timer
+ // if the first timer is expired, we clear it and look for the second status
+ if (diff1 && it->m_timer1 && now - it->m_timer1 > diff1) {
+ it->m_timer1 = 0;
+
+ // if the second timer is set up, activate it
+ if (m_iTimeDiff2) {
+ setDword(it->m_hContact, "Status", m_iStatus2);
+ it->m_timer2 = now;
+ }
+ // if the second timer is not set, simply mark a contact as offline
+ else setDword(it->m_hContact, "Status", ID_STATUS_OFFLINE);
continue;
}
- if (diff1 && it->m_timer1 && now - it->m_timer1 > diff1) {
- setDword(it->m_hContact, "Status", m_iStatus1);
- it->m_timer1 = 0;
- it->m_timer2 = now;
+ // if the second timer is expired, set status to offline
+ if (diff2 && it->m_timer2 && now - it->m_timer2 > m_iTimeDiff2) {
+ it->m_timer2 = 0;
+ setDword(it->m_hContact, "Status", ID_STATUS_OFFLINE);
}
}
}