summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp25
-rw-r--r--protocols/ICQ-WIM/src/server.cpp4
-rw-r--r--protocols/ICQ-WIM/src/stdafx.h1
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp33
4 files changed, 32 insertions, 31 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index a7e59c3744..d76cf4df18 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -325,20 +325,21 @@ void CIcqProto::ProcessPresence(const JSONNode &ev)
return;
int iNewStatus = StatusFromPresence(ev, pCache->m_hContact);
-
- // 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 (iNewStatus > 0) {
+ // 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 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);
+ setWord(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 b50e304079..e25272a0af 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -367,7 +367,9 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact)
Json2int(hContact, buddy, "idleTime", "IdleTS");
Json2int(hContact, buddy, "memberSince", DB_KEY_MEMBERSINCE);
- setWord(hContact, "Status", StatusFromPresence(buddy, hContact));
+ int iStatus = StatusFromPresence(buddy, hContact);
+ if (iStatus > 0)
+ setWord(hContact, "Status", iStatus);
const JSONNode &profile = buddy["profile"];
if (profile) {
diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h
index 0761099b7f..9bb96fd4f7 100644
--- a/protocols/ICQ-WIM/src/stdafx.h
+++ b/protocols/ICQ-WIM/src/stdafx.h
@@ -102,7 +102,6 @@
bool IsChat(const CMStringW &aimid);
void RefreshGroups(void);
-int StatusFromString(const CMStringW&);
char* time2text(time_t time);
extern bool g_bSecureIM, g_bMessageState;
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index 1204cbfb53..fc3eaf0ecb 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -270,25 +270,24 @@ bool IsChat(const CMStringW &aimid)
return aimid.Right(11) == "@chat.agent";
}
-int StatusFromString(const CMStringW &wszStatus)
-{
- if (wszStatus == L"online")
- return ID_STATUS_ONLINE;
- if (wszStatus == L"n/a")
- return ID_STATUS_NA;
- if (wszStatus == L"away")
- return ID_STATUS_AWAY;
- if (wszStatus == L"occupied")
- return ID_STATUS_OCCUPIED;
- if (wszStatus == L"dnd")
- return ID_STATUS_DND;
-
- return ID_STATUS_OFFLINE;
-}
-
int CIcqProto::StatusFromPresence(const JSONNode &presence, MCONTACT hContact)
{
- int iStatus = StatusFromString(presence["state"].as_mstring());
+ CMStringW wszStatus = presence["state"].as_mstring();
+ int iStatus;
+ if (wszStatus == L"online")
+ iStatus = ID_STATUS_ONLINE;
+ if (wszStatus == L"offline")
+ iStatus = ID_STATUS_OFFLINE;
+ else if (wszStatus == L"n/a")
+ iStatus = ID_STATUS_NA;
+ else if (wszStatus == L"away")
+ iStatus = ID_STATUS_AWAY;
+ else if (wszStatus == L"occupied")
+ iStatus = ID_STATUS_OCCUPIED;
+ else if (wszStatus == L"dnd")
+ iStatus = ID_STATUS_DND;
+ else
+ iStatus = -1;
int iLastSeen = presence["lastseen"].as_int();
if (iLastSeen != 0)