diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-04-09 17:48:27 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-04-09 17:48:27 +0000 |
commit | b80be7b3bbfae105935f49c34e9e64f1760ad08e (patch) | |
tree | ab36197cad44be4c7c2bc05b8da60e95becb5279 /protocols/Steam/src | |
parent | 2068cf47f49397ba35a5501c7949a1c3ce6342ff (diff) |
Steam: fixed contacts loading
git-svn-id: http://svn.miranda-ng.org/main/trunk@8903 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r-- | protocols/Steam/src/Steam/friend_list.h | 8 | ||||
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 30 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 2 |
3 files changed, 29 insertions, 11 deletions
diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h index 59df8918b0..160e3a0df5 100644 --- a/protocols/Steam/src/Steam/friend_list.h +++ b/protocols/Steam/src/Steam/friend_list.h @@ -11,12 +11,12 @@ namespace SteamWebApi friend FriendListApi;
private:
- std::vector<std::string> friendIds;
+ std::vector<std::string> items;
public:
- int GetCount() const { return friendIds.size(); }
+ int GetItemCount() const { return items.size(); }
- const char * operator[](int idx) const { return friendIds.at(idx).c_str(); }
+ const char *GetAt(int idx) const { return items.at(idx).c_str(); }
};
static void Load(HANDLE hConnection, const char *token, const char *steamId, FriendList *friendList)
@@ -47,7 +47,7 @@ namespace SteamWebApi break;
node = json_get(child, "steamid");
- friendList->friendIds
+ friendList->items
.push_back((char*)ptrA(mir_u2a(json_as_string(node))));
}
}
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index 812b9a75b5..523c5f09f2 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -171,15 +171,31 @@ void CSteamProto::LogInThread(void* param) if (friendList.IsSuccess())
{
- for (int i = 0; i < friendList.GetCount(); i++)
+ CMStringA newContacts;
+ for (int i = 0; i < friendList.GetItemCount(); i++)
{
- if (!FindContact(friendList[i]))
+ const char * steamId = friendList.GetAt(i);
+ if (!FindContact(steamId))
{
- // todo
- /*SteamWebApi::FriendApi::Friend rFriend;
- SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, friendList[i], &rFriend);
- if (!rFriend.IsSuccess()) continue;
- AddContact(rFriend);*/
+ if (newContacts.IsEmpty())
+ newContacts.Append(steamId);
+ else
+ newContacts.AppendFormat(",%s", steamId);
+ }
+ }
+
+ if (!newContacts.IsEmpty())
+ {
+ SteamWebApi::FriendApi::Summaries summaries;
+ SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, newContacts, &summaries);
+
+ if (summaries.IsSuccess())
+ {
+ for (int i = 0; i < summaries.GetItemCount(); i++)
+ {
+ const SteamWebApi::FriendApi::Summary *summary = summaries.GetAt(i);
+ AddContact(summary);
+ }
}
}
}
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 6038ca029c..3aba838dfc 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -105,6 +105,8 @@ MCONTACT CSteamProto::AddContact(const SteamWebApi::FriendApi::Summary *contact) hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)this->m_szModuleName);
+ setString(hContact, "SteamID", contact->GetSteamId());
+
// update info
UpdateContact(hContact, contact);
|