From 7cb1539b0dbcf585472dd2341129adf174bb0bb5 Mon Sep 17 00:00:00 2001 From: aunsane Date: Sun, 14 Jan 2018 22:02:44 +0300 Subject: Steam: refactoring pt.2 --- protocols/Steam/src/api/app_info.h | 12 +++++++ protocols/Steam/src/api/authorization.h | 2 +- protocols/Steam/src/api/enums.h | 38 ++++++++++++++++++++-- protocols/Steam/src/api/friend.h | 26 ++++++++++++++- protocols/Steam/src/api/friend_list.h | 39 +++++++++++++++++++++++ protocols/Steam/src/api/history.h | 15 +++++++++ protocols/Steam/src/api/login.h | 15 +++++++++ protocols/Steam/src/api/pending.h | 18 ++++------- protocols/Steam/src/api/poll.h | 56 +++++++++++++++++++++++++++++++++ protocols/Steam/src/api/rsa_key.h | 5 +-- protocols/Steam/src/api/search.h | 16 ++++++++-- protocols/Steam/src/api/session.h | 11 +++++-- 12 files changed, 227 insertions(+), 26 deletions(-) (limited to 'protocols/Steam/src/api') diff --git a/protocols/Steam/src/api/app_info.h b/protocols/Steam/src/api/app_info.h index b08a3f38d6..7aeb26f9d4 100644 --- a/protocols/Steam/src/api/app_info.h +++ b/protocols/Steam/src/api/app_info.h @@ -11,6 +11,18 @@ public: << CHAR_PARAM("access_token", token) << CHAR_PARAM("appIds", appIds); } + + //{ + // "apps": [ + // { + // "appid": 271590, + // "name" : "Grand Theft Auto V", + // "iconurl" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/271590/1e72f87eb927fa1485e68aefaff23c7fd7178251.jpg", + // "logourl" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/271590/e447e82f8b0c67f9e001498503c62f2a187bc609.jpg", + // "logosmallurl" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/271590/e447e82f8b0c67f9e001498503c62f2a187bc609_thumb.jpg" + // } + // ] + //} }; #endif //_STEAM_REQUEST_APP_INFO_H_ diff --git a/protocols/Steam/src/api/authorization.h b/protocols/Steam/src/api/authorization.h index 3d02c5deb5..b2ba2639c0 100644 --- a/protocols/Steam/src/api/authorization.h +++ b/protocols/Steam/src/api/authorization.h @@ -25,7 +25,7 @@ public: << CHAR_PARAM("captcha_text", captchaText) << CHAR_PARAM("rsatimestamp", timestamp) << BOOL_PARAM("rememberlogin", false) - << INT64_PARAM("donotcache", time(NULL)); + << INT64_PARAM("donotcache", now()); } }; diff --git a/protocols/Steam/src/api/enums.h b/protocols/Steam/src/api/enums.h index a24ce48b34..1a1643a15d 100644 --- a/protocols/Steam/src/api/enums.h +++ b/protocols/Steam/src/api/enums.h @@ -1,6 +1,15 @@ #ifndef _STEAM_ENUMS_H_ #define _STEAM_ENUMS_H_ +enum VisibilityState +{ + Private = 1, + FriendsOnly = 2, + FriendsOfFriends = 3, + UsersOnly = 4, + Public = 5, +}; + enum PersonaState { Offline = 0, @@ -10,10 +19,19 @@ enum PersonaState Snooze = 4, LookingToTrade = 5, LookingToPlay = 6, - Max = 7, }; -enum StatusFlags +enum PersonaStateFlag +{ + None = 0, + HasRichPresence = 1, + InJoinableGame = 2, + OnlineUsingWeb = 256, + OnlineUsingMobile = 512, + OnlineUsingBigPicture = 1024, +}; + +enum PersonaStatusFlag { Status = 1, PlayerName = 2, @@ -27,6 +45,20 @@ enum StatusFlags GameDataBlob = 512, ClanTag = 1024, Facebook = 2048, -} +}; + +enum PersonaRelationshipAction +{ + // friend removed from contact list + Remove = 0, + // friend added you to ignore list + Ignore = 1, + // friend requested auth + AuthRequest = 2, + // friend added you to contact list + AddToList = 3, + // friend got (or approved?) your auth request + AuthRequested = 4, +}; #endif //_STEAM_ENUMS_H_ diff --git a/protocols/Steam/src/api/friend.h b/protocols/Steam/src/api/friend.h index 191e0b93fa..0997d42b0f 100644 --- a/protocols/Steam/src/api/friend.h +++ b/protocols/Steam/src/api/friend.h @@ -5,12 +5,36 @@ class GetUserSummariesRequest : public HttpRequest { public: GetUserSummariesRequest(const char *token, const char *steamIds) : - HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0002") { Uri << CHAR_PARAM("access_token", token) << CHAR_PARAM("steamids", steamIds); } + + //{ + // "players": [ + // { + // "steamid": "76561197960435530", + // "communityvisibilitystate" : 3, + // "profilestate" : 1, + // "personaname" : "Robin", + // "lastlogoff" : 1514966746, + // "profileurl" : "http://steamcommunity.com/id/robinwalker/", + // "avatar" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4.jpg", + // "avatarmedium" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_medium.jpg", + // "avatarfull" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_full.jpg", + // "personastate" : 0, + // "realname" : "Robin Walker", + // "primaryclanid" : "103582791429521412", + // "timecreated" : 1063407589, + // "personastateflags" : 0, + // "loccountrycode" : "US", + // "locstatecode" : "WA", + // "loccityid" : 3961 + // } + // ] + //} }; #endif //_STEAM_REQUEST_FRIEND_H_ diff --git a/protocols/Steam/src/api/friend_list.h b/protocols/Steam/src/api/friend_list.h index 604e797a2d..50c9a7b5bc 100644 --- a/protocols/Steam/src/api/friend_list.h +++ b/protocols/Steam/src/api/friend_list.h @@ -12,6 +12,17 @@ public: << CHAR_PARAM("steamid", steamId) << CHAR_PARAM("relationship", relationship); } + + //{ + // "friends": [ + // { + // "steamid": "XXXXXXXXXXXXXXXXX", + // "relationship" : "friend", + // "friend_since" : 1514314629 + // } + // ] + //} + }; class AddFriendRequest : public HttpRequest @@ -32,6 +43,12 @@ public: << CHAR_PARAM("sessionID", sessionId) << CHAR_PARAM("steamid", who); } + + // "true" + + // {"invited":["XXXXXXXXXXXXXXXXX"], "success" : 1} + + // {"failed_invites":["XXXXXXXXXXXXXXXXX"], "failed_invites_result" : [24], "success" : 1} }; class BlockFriendRequest : public HttpRequest @@ -55,6 +72,28 @@ public: } }; +class UnblockFriendRequest : public HttpRequest +{ +public: + UnblockFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : + HttpRequest(HttpPost, STEAM_WEB_URL "/actions/BlockUserAjax") + { + char login[MAX_PATH]; + mir_snprintf(login, "%s||oauth:%s", steamId, token); + + char cookie[MAX_PATH]; + mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); + + Headers << CHAR_PARAM("Cookie", cookie); + + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("steamid", who) + << CHAR_PARAM("action", "unignore") + << INT_PARAM("block", 0); + } +}; + class RemoveFriendRequest : public HttpRequest { public: diff --git a/protocols/Steam/src/api/history.h b/protocols/Steam/src/api/history.h index f825622953..0eaea38fb1 100644 --- a/protocols/Steam/src/api/history.h +++ b/protocols/Steam/src/api/history.h @@ -9,6 +9,21 @@ public: { Uri << CHAR_PARAM("access_token", token); } + + //{ + // "response": { + // "message_sessions": [ + // { + // "accountid_friend": XXXXXXXXX, + // "last_message" : 1514975719, + // "last_view" : 1514975719, + // "unread_message_count" : 0 + // } + // ] + // , + // "timestamp": 1515007542 + // } + //} }; class GetHistoryMessagesRequest : public HttpRequest diff --git a/protocols/Steam/src/api/login.h b/protocols/Steam/src/api/login.h index 3479ae75ff..e061d4236c 100644 --- a/protocols/Steam/src/api/login.h +++ b/protocols/Steam/src/api/login.h @@ -14,6 +14,17 @@ public: << CHAR_PARAM("access_token", token) << CHAR_PARAM("ui_mode", "web"); } + + //{ + // "steamid": "XXXXXXXXXXXXXXXXX", + // "error" : "OK", + // "umqid" : "XXXXXXXXXXXXXXXXXXX", + // "timestamp" : 16955891, + // "utc_timestamp" : 1514974537, + // "message" : 1, + // "push" : 0 + //} + }; class LogoffRequest : public HttpRequest @@ -26,6 +37,10 @@ public: << CHAR_PARAM("access_token", token) << CHAR_PARAM("umqid", umqId); } + + //{ + // "error": "OK" + //} }; #endif //_STEAM_REQUEST_LOGIN_H_ diff --git a/protocols/Steam/src/api/pending.h b/protocols/Steam/src/api/pending.h index a808fd172c..9aeed4e182 100644 --- a/protocols/Steam/src/api/pending.h +++ b/protocols/Steam/src/api/pending.h @@ -7,11 +7,9 @@ public: ApprovePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { - char login[MAX_PATH]; - mir_snprintf(login, "%s||oauth:%s", steamId, token); - char cookie[MAX_PATH]; - mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); + mir_snprintf(cookie, "steamLogin=%s||oauth:%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", + steamId, token, sessionId); Headers << CHAR_PARAM("Cookie", cookie); @@ -32,11 +30,9 @@ public: IgnorePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { - char login[MAX_PATH]; - mir_snprintf(login, "%s||oauth:%s", steamId, token); - char cookie[MAX_PATH]; - mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); + mir_snprintf(cookie, "steamLogin=%s||oauth:%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", + steamId, token, sessionId); Headers << CHAR_PARAM("Cookie", cookie); @@ -57,11 +53,9 @@ public: BlockPendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { - char login[MAX_PATH]; - mir_snprintf(login, "%s||oauth:%s", steamId, token); - char cookie[MAX_PATH]; - mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); + mir_snprintf(cookie, "steamLogin=%s||oauth:%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", + steamId, token, sessionId); Headers << CHAR_PARAM("Cookie", cookie); diff --git a/protocols/Steam/src/api/poll.h b/protocols/Steam/src/api/poll.h index 278dfb0439..6336b212e9 100644 --- a/protocols/Steam/src/api/poll.h +++ b/protocols/Steam/src/api/poll.h @@ -19,6 +19,62 @@ public: << INT_PARAM("secidletime", idleSeconds) << INT_PARAM("sectimeout", STEAM_API_TIMEOUT); } + + //{ + // "pollid": 0, + // "sectimeout" : 30, + // "error" : "Timeout" + //} + + //{ + // "pollid": 0, + // "messages": [ + // { + // "type": "typing", + // "timestamp": 17276041, + // "utc_timestamp": 1514974857, + // "steamid_from": "XXXXXXXXXXXXXXXXX", + // "text": "" + // }, + // { + // "type": "saytext", + // "timestamp" : 17380133, + // "utc_timestamp" : 1514974961, + // "steamid_from" : "XXXXXXXXXXXXXXXXX", + // "text" : "message" + // }, + // { + // "type": "personarelationship", + // "timestamp" : 7732750, + // "utc_timestamp" : 1515187192, + // "steamid_from" : "XXXXXXXXXXXXXXXXX", + // "status_flags" : 1, + // "persona_state" : 2 + // }, + // { + // "type": "personastate", + // "timestamp" : 366860, + // "utc_timestamp" : 1515007523, + // "steamid_from" : "XXXXXXXXXXXXXXXXX", + // "status_flags" : 9055, + // "persona_state" : 1, + // "persona_name" : "nickname" + // }, + // { + // "type": "notificationcountupdate", + // "timestamp" : 11605105, + // "utc_timestamp" : 1515191064 + // } + // ] + // , + // "messagelast": 4, + // "timestamp": 17276041, + // "utc_timestamp": 1514974857, + // "messagebase": 3, + // "sectimeout": 14, + // "error": "OK" + //} + }; #endif //_STEAM_REQUEST_POLL_H_ diff --git a/protocols/Steam/src/api/rsa_key.h b/protocols/Steam/src/api/rsa_key.h index 27a002b717..a0369f4db4 100644 --- a/protocols/Steam/src/api/rsa_key.h +++ b/protocols/Steam/src/api/rsa_key.h @@ -9,12 +9,9 @@ public: { flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; - CMStringA data; - data.AppendFormat("username=%s&donotcache=%lld", ptrA(mir_urlEncode(username)), time(NULL)); - Content = new FormUrlEncodedContent(this) << CHAR_PARAM("username", username) - << INT64_PARAM("donotcache", time(NULL)); + << INT64_PARAM("donotcache", now()); } }; diff --git a/protocols/Steam/src/api/search.h b/protocols/Steam/src/api/search.h index a34c2e8398..4484af4ba8 100644 --- a/protocols/Steam/src/api/search.h +++ b/protocols/Steam/src/api/search.h @@ -10,11 +10,23 @@ public: Uri << CHAR_PARAM("access_token", token) << CHAR_PARAM("keywords", text) - << INT_PARAM("offset=%d", offset) - << INT_PARAM("count=%d", count) + << INT_PARAM("offset", offset) + << INT_PARAM("count", count) << CHAR_PARAM("targets", "users") << CHAR_PARAM("fields", "all"); } + + //{ + // "count": 1, + // "total" : 336, + // "success" : true, + // "results" : [ + // { + // "steamid": "XXXXXXXXXXXXXXXXX", + // "type" : "user" + // } + // ] + //} }; #endif //_STEAM_REQUEST_SEARCH_H_ diff --git a/protocols/Steam/src/api/session.h b/protocols/Steam/src/api/session.h index d4e91721cb..dec2e0aa0a 100644 --- a/protocols/Steam/src/api/session.h +++ b/protocols/Steam/src/api/session.h @@ -26,10 +26,15 @@ public: class GetSessionRequest2 : public HttpRequest { public: - GetSessionRequest2() : - HttpRequest(HttpGet, STEAM_WEB_URL) + GetSessionRequest2(const char *token, const char *steamId) : + HttpRequest(HttpGet, STEAM_WEB_URL "/mobilesettings/GetManifest/v0001") { - flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; + flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPHEADERS; + + char cookie[MAX_PATH]; + mir_snprintf(cookie, "steamLogin=%s||oauth:%s", steamId, token); + + Headers << CHAR_PARAM("Cookie", cookie); } }; -- cgit v1.2.3