diff options
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 31 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 6 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 32 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 9 |
4 files changed, 40 insertions, 38 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index d76cf4df18..80ab30fd3d 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -108,7 +108,7 @@ void CIcqProto::ProcessDiff(const JSONNode &ev) if (bDeleted) continue; - MCONTACT hContact = ParseBuddyInfo(buddy); + MCONTACT hContact = ParseBuddyInfo(buddy, true); if (hContact == INVALID_CONTACT_ID) continue; @@ -325,23 +325,24 @@ void CIcqProto::ProcessPresence(const JSONNode &ev) return; int iNewStatus = StatusFromPresence(ev, pCache->m_hContact); - 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 (iNewStatus == -1) + iNewStatus = ID_STATUS_OFFLINE; + + // 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); } + // 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"); + Json2string(pCache->m_hContact, ev, "friendly", "Nick", true); CheckAvatarChange(pCache->m_hContact, ev); } diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 1326120f80..eec5793b6d 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -270,9 +270,9 @@ class CIcqProto : public PROTO<CIcqProto> void CheckAvatarChange(MCONTACT hContact, const JSONNode&); IcqFileInfo* CheckFile(MCONTACT hContact, CMStringW &wszFileName, bool &bIsFile); void CheckLastId(MCONTACT hContact, const JSONNode&); - void Json2int(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting); - void Json2string(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting); - MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = INVALID_CONTACT_ID); + void Json2int(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting, bool bIsPartial); + void Json2string(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting, bool bIsPartial); + MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = INVALID_CONTACT_ID, bool bIsPartial = false); void ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &msg, bool bCreateRead, bool bLocalTime); int StatusFromPresence(const JSONNode &presence, MCONTACT hContact); diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index e25272a0af..2b41b5aee7 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -282,7 +282,7 @@ void CIcqProto::MarkAsRead(MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////////////// -MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact) +MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact, bool bIsPartial) { // user chat? CMStringW wszId(buddy["aimId"].as_mstring()); @@ -357,15 +357,15 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact) Contact_PutOnList(hContact); } - Json2string(hContact, buddy, "emailId", "Email"); - Json2string(hContact, buddy, "cellNumber", "Cellular"); - Json2string(hContact, buddy, "phoneNumber", "Phone"); - Json2string(hContact, buddy, "workNumber", "CompanyPhone"); + Json2string(hContact, buddy, "emailId", "Email", bIsPartial); + Json2string(hContact, buddy, "cellNumber", "Cellular", bIsPartial); + Json2string(hContact, buddy, "phoneNumber", "Phone", bIsPartial); + Json2string(hContact, buddy, "workNumber", "CompanyPhone", bIsPartial); - Json2int(hContact, buddy, "official", "Official"); - Json2int(hContact, buddy, "onlineTime", DB_KEY_ONLINETS); - Json2int(hContact, buddy, "idleTime", "IdleTS"); - Json2int(hContact, buddy, "memberSince", DB_KEY_MEMBERSINCE); + Json2int(hContact, buddy, "official", "Official", bIsPartial); + Json2int(hContact, buddy, "onlineTime", DB_KEY_ONLINETS, bIsPartial); + Json2int(hContact, buddy, "idleTime", "IdleTS", bIsPartial); + Json2int(hContact, buddy, "memberSince", DB_KEY_MEMBERSINCE, bIsPartial); int iStatus = StatusFromPresence(buddy, hContact); if (iStatus > 0) @@ -373,10 +373,10 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact) const JSONNode &profile = buddy["profile"]; if (profile) { - Json2string(hContact, profile, "friendlyName", DB_KEY_ICQNICK); - Json2string(hContact, profile, "firstName", "FirstName"); - Json2string(hContact, profile, "lastName", "LastName"); - Json2string(hContact, profile, "aboutMe", DB_KEY_ABOUT); + Json2string(hContact, profile, "friendlyName", DB_KEY_ICQNICK, bIsPartial); + Json2string(hContact, profile, "firstName", "FirstName", bIsPartial); + Json2string(hContact, profile, "lastName", "LastName", bIsPartial); + Json2string(hContact, profile, "aboutMe", DB_KEY_ABOUT, bIsPartial); ptrW wszNick(getWStringA(hContact, "Nick")); if (!wszNick) { @@ -404,9 +404,9 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact) } for (auto &it : profile["homeAddress"]) { - Json2string(hContact, it, "city", "City"); - Json2string(hContact, it, "state", "State"); - Json2string(hContact, it, "country", "Country"); + Json2string(hContact, it, "city", "City", bIsPartial); + Json2string(hContact, it, "state", "State", bIsPartial); + Json2string(hContact, it, "country", "Country", bIsPartial); } } diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index fc3eaf0ecb..4bd51e050c 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -117,16 +117,16 @@ void CIcqProto::CalcHash(AsyncHttpRequest *pReq) ///////////////////////////////////////////////////////////////////////////////////////// -void CIcqProto::Json2int(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting) +void CIcqProto::Json2int(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting, bool bIsPartial) { const JSONNode &var = node[szJson]; if (var) setDword(hContact, szSetting, var.as_int()); - else + else if (!bIsPartial) delSetting(hContact, szSetting); } -void CIcqProto::Json2string(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting) +void CIcqProto::Json2string(MCONTACT hContact, const JSONNode &node, const char *szJson, const char *szSetting, bool bIsPartial) { const JSONNode &var = node[szJson]; if (var) { @@ -137,7 +137,8 @@ void CIcqProto::Json2string(MCONTACT hContact, const JSONNode &node, const char } else setWString(hContact, szSetting, wszStr); } - else delSetting(hContact, szSetting); + else if (!bIsPartial) + delSetting(hContact, szSetting); } ///////////////////////////////////////////////////////////////////////////////////////// |