diff options
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r-- | protocols/Steam/src/main.cpp | 1 | ||||
-rw-r--r-- | protocols/Steam/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 24 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.h | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_server.cpp | 21 |
5 files changed, 31 insertions, 18 deletions
diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp index 5c4df55a31..b72fc2a36f 100644 --- a/protocols/Steam/src/main.cpp +++ b/protocols/Steam/src/main.cpp @@ -139,6 +139,7 @@ void CMPlugin::InitSteamServices() messageHandlers[EMsg::ClientLogOnResponse] = ServiceResponseHandler(&CSteamProto::OnClientLogon);
messageHandlers[EMsg::ClientFriendsList] = ServiceResponseHandler(&CSteamProto::OnGotFriendList);
messageHandlers[EMsg::ClientPersonaState] = ServiceResponseHandler(&CSteamProto::OnGotFriendInfo);
+ messageHandlers[EMsg::ClientPICSProductInfoResponse] = ServiceResponseHandler(&CSteamProto::OnGotAppInfo);
// services from steammessages_auth.steamclient.proto
services["Authentication"] = &authentication__descriptor;
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 48b7ac38d1..a966f38da0 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -7,6 +7,7 @@ #include <time.h>
#include <map>
+#include <regex>
#include <vector>
#include <string>
#include <algorithm>
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 901ea8d771..61f8feeff4 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -173,8 +173,14 @@ void CSteamProto::OnGotFriendInfo(const CMsgClientPersonaState &reply, const CMs setString(hContact, "ServerIP", serverIP); CMStringW message(gameInfo); - if (gameId && message.IsEmpty()) - SendAppInfoRequest(gameId); + if (gameId && message.IsEmpty()) { + CMStringA szSetting(FORMAT, "AppInfo_%d", gameId); + ptrW szName(getWStringA(szSetting)); + if (szName) + message = szName; + else + SendAppInfoRequest(gameId); + } else { if (!gameId) message.Append(TranslateT(" (Non-Steam)")); @@ -335,20 +341,6 @@ void CSteamProto::UpdateContactRelationship(MCONTACT hContact, FriendRelationshi } } -void CSteamProto::OnGotAppInfo(const JSONNode &root, void *arg) -{ - MCONTACT hContact = (UINT_PTR)arg; - - for (auto &app : root["apps"]) { - uint32_t gameId = app["appid"].as_int(); - CMStringW message = app["name"].as_mstring(); - - setDword(hContact, "XStatusId", gameId); - setWString(hContact, "XStatusName", TranslateT("Playing")); - setWString(hContact, "XStatusMsg", message); - } -} - void CSteamProto::OnGotFriendList(const CMsgClientFriendsList &reply, const CMsgProtoBufHeader &hdr) { if (hdr.failed()) diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 14d03366b2..de2670a376 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -172,6 +172,7 @@ class CSteamProto : public PROTO<CSteamProto> void OnBeginSession(const CAuthenticationBeginAuthSessionViaCredentialsResponse &pResponse, const CMsgProtoBufHeader &hdr);
void OnClientLogon(const CMsgClientLogonResponse &pResponse, const CMsgProtoBufHeader &hdr);
void OnClientLogoff(const CMsgClientLoggedOff &pResponse, const CMsgProtoBufHeader &hdr);
+ void OnGotAppInfo(const CMsgClientPICSProductInfoResponse &pResponse, const CMsgProtoBufHeader &hdr);
void OnGotRsaKey(const CAuthenticationGetPasswordRSAPublicKeyResponse &pResponse, const CMsgProtoBufHeader &hdr);
void OnGotConfirmationCode(const CAuthenticationUpdateAuthSessionWithSteamGuardCodeResponse &pResponse, const CMsgProtoBufHeader &hdr);
void OnPollSession(const CAuthenticationPollAuthSessionStatusResponse &pResponse, const CMsgProtoBufHeader &hdr);
@@ -204,7 +205,6 @@ class CSteamProto : public PROTO<CSteamProto> MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
void UpdateContactRelationship(MCONTACT hContact, FriendRelationship);
- void OnGotAppInfo(const JSONNode &root, void *arg);
void ContactIsRemoved(MCONTACT hContact);
void ContactIsFriend(MCONTACT hContact);
diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp index 40789e9a22..e3150a4499 100644 --- a/protocols/Steam/src/steam_server.cpp +++ b/protocols/Steam/src/steam_server.cpp @@ -41,10 +41,29 @@ void CSteamProto::SendAppInfoRequest(uint32_t appId) CMsgClientPICSProductInfoRequest request; request.n_apps = 1; request.apps = &pInfo; - request.has_meta_data_only = request.meta_data_only = true; WSSend(EMsg::ClientPICSProductInfoRequest, request); } +void CSteamProto::OnGotAppInfo(const CMsgClientPICSProductInfoResponse &reply, const CMsgProtoBufHeader &) +{ + for (int i = 0; i < reply.n_apps; i++) { + auto *pApp = reply.apps[i]; + + if (pApp->buffer.len) { + std::regex regex("\"name\"[\\s*]\"(.+?)\""); + std::smatch match; + std::string content((char *)pApp->buffer.data, pApp->buffer.len); + if (std::regex_search(content, match, regex)) { + std::string szName = match[1]; + CMStringA szSetting(FORMAT, "AppInfo_%d", pApp->appid); + setString(szSetting, szName.c_str()); + + for (auto &cc : AccContacts()) { + if (getDword(cc, "XStatusId") == pApp->appid) { + setWString(cc, "XStatusName", TranslateT("Playing")); + setUString(cc, "XStatusMsg", szName.c_str()); +} } } } } } + ///////////////////////////////////////////////////////////////////////////////////////// void CSteamProto::SendPersonaStatus(int status) |