diff options
author | Robert Pösel <robyer@seznam.cz> | 2017-08-20 13:18:06 +0200 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2017-08-20 13:18:06 +0200 |
commit | de78aa477e08a177b1abd3c28869ed434374223c (patch) | |
tree | 96f4f6f0226bffbd523965ee636a5dba9c01c867 /protocols/Steam | |
parent | 1279ffffeaadbac1e57073b61bf2da05577af23b (diff) |
Rework ProcessContact method
Diffstat (limited to 'protocols/Steam')
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 17 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 4 |
2 files changed, 8 insertions, 13 deletions
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index c1f2bc68d3..6815af9f59 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -378,19 +378,13 @@ MCONTACT CSteamProto::AddContact(const char *steamId, bool isTemporary) return hContact; } -void CSteamProto::ProcessContact(std::map<std::string, JSONNode*>::iterator *it, MCONTACT hContact) +void CSteamProto::UpdateContactRelationship(MCONTACT hContact, JSONNode *data) { - std::string steamId = (*it)->first; - JSONNode *child = (*it)->second; - - if (!hContact) - hContact = AddContact(steamId.c_str()); - - JSONNode *node = json_get(child, "friend_since"); + JSONNode *node = json_get(data, "friend_since"); if (node) db_set_dw(hContact, "UserInfo", "ContactAddTime", json_as_int(node)); - node = json_get(child, "relationship"); + node = json_get(data, "relationship"); if (node == NULL) return; @@ -457,7 +451,7 @@ void CSteamProto::OnGotFriendList(const HttpResponse *response) if (it != friends.end()) { // Contact is on server-list, update (and eventually notify) it - ProcessContact(&it, hContact); + UpdateContactRelationship(hContact, it->second); steamIds.append(",").append(it->first); friends.erase(it); @@ -473,7 +467,8 @@ void CSteamProto::OnGotFriendList(const HttpResponse *response) for (std::map<std::string, JSONNode*>::iterator it = friends.begin(); it != friends.end();) { // Contact is on server-list, but not in database, add (but not notify) it - ProcessContact(&it, NULL); + MCONTACT hContact = AddContact(it->first.c_str()); + UpdateContactRelationship(hContact, it->second); steamIds.append(",").append(it->first); it = friends.erase(it); diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 249fd7a9de..4a2aff8d47 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -138,8 +138,8 @@ protected: MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
void UpdateContactDetails(MCONTACT hContact, JSONNode *data);
- void ProcessContact(std::map<std::string, JSONNode*>::iterator *it, MCONTACT hContact);
-
+ void UpdateContactRelationship(MCONTACT hContact, JSONNode *data);
+
void ContactIsRemoved(MCONTACT hContact);
void ContactIsFriend(MCONTACT hContact);
void ContactIsIgnored(MCONTACT hContact);
|