diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-05-26 19:15:20 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-05-26 19:15:20 +0000 |
commit | ab75f8e4a3968c956425844415237a4fa6fcee63 (patch) | |
tree | df2c209dd0197dc3085546606b0581d63f9114ad /protocols/Steam/src/api | |
parent | 4e9e885747b2037c81ce809f7f6505f8bc8b0e2f (diff) |
Steam: merge new api
git-svn-id: http://svn.miranda-ng.org/main/trunk@13850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/api')
-rw-r--r-- | protocols/Steam/src/api/authorization.h | 59 | ||||
-rw-r--r-- | protocols/Steam/src/api/avatar.h | 14 | ||||
-rw-r--r-- | protocols/Steam/src/api/captcha.h | 14 | ||||
-rw-r--r-- | protocols/Steam/src/api/friend.h | 15 | ||||
-rw-r--r-- | protocols/Steam/src/api/friend_list.h | 88 | ||||
-rw-r--r-- | protocols/Steam/src/api/login.h | 32 | ||||
-rw-r--r-- | protocols/Steam/src/api/message.h | 22 | ||||
-rw-r--r-- | protocols/Steam/src/api/pending.h | 67 | ||||
-rw-r--r-- | protocols/Steam/src/api/poll.h | 28 | ||||
-rw-r--r-- | protocols/Steam/src/api/rsa_key.h | 16 | ||||
-rw-r--r-- | protocols/Steam/src/api/search.h | 17 | ||||
-rw-r--r-- | protocols/Steam/src/api/session.h | 24 |
12 files changed, 396 insertions, 0 deletions
diff --git a/protocols/Steam/src/api/authorization.h b/protocols/Steam/src/api/authorization.h new file mode 100644 index 0000000000..e7b2ee8c39 --- /dev/null +++ b/protocols/Steam/src/api/authorization.h @@ -0,0 +1,59 @@ +#ifndef _STEAM_REQUEST_AUTHORIZATION_H_
+#define _STEAM_REQUEST_AUTHORIZATION_H_
+
+class AuthorizationRequest : public HttpRequest
+{
+public:
+ AuthorizationRequest(const char *username, const char *password, const char *timestamp) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
+ {
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
+
+ char data[1024];
+ mir_snprintf(data, SIZEOF(data),
+ "username=%s&password=%s&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&captchagid=-1&rsatimestamp=%s",
+ ptrA(mir_urlEncode(username)),
+ ptrA(mir_urlEncode(password)),
+ timestamp);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+
+ AuthorizationRequest(const char *username, const char *password, const char *timestamp, const char *guardCode) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
+ {
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
+
+ char data[1024];
+ mir_snprintf(data, SIZEOF(data),
+ "username=%s&password=%s&emailauth=%s&loginfriendlyname=MirandaNG&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&captchagid=-1&rsatimestamp=%s",
+ ptrA(mir_urlEncode(username)),
+ ptrA(mir_urlEncode(password)),
+ guardCode,
+ timestamp);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+
+ AuthorizationRequest(const char *username, const char *password, const char *timestamp, const char *captchaId, const char *captchaText) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
+ {
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
+
+ char data[1024];
+ mir_snprintf(data, SIZEOF(data),
+ "username=%s&password=%s&emailauth=&captchagid=%s&captcha_text=%s&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&rsatimestamp=%s",
+ ptrA(mir_urlEncode(username)),
+ ptrA(mir_urlEncode(password)),
+ captchaId,
+ ptrA(mir_urlEncode(captchaText)),
+ timestamp);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_AUTHORIZATION_H_
diff --git a/protocols/Steam/src/api/avatar.h b/protocols/Steam/src/api/avatar.h new file mode 100644 index 0000000000..ef4fcdfcf5 --- /dev/null +++ b/protocols/Steam/src/api/avatar.h @@ -0,0 +1,14 @@ +#ifndef _STEAM_REQUEST_AVATAR_H_
+#define _STEAM_REQUEST_AVATAR_H_
+
+class GetAvatarRequest : public HttpRequest
+{
+public:
+ GetAvatarRequest(const char *url) :
+ HttpRequest(REQUEST_GET, url)
+ {
+ flags = NLHRF_HTTP11 | NLHRF_NODUMP;
+ }
+};
+
+#endif //_STEAM_REQUEST_AVATAR_H_
diff --git a/protocols/Steam/src/api/captcha.h b/protocols/Steam/src/api/captcha.h new file mode 100644 index 0000000000..b61dca89d6 --- /dev/null +++ b/protocols/Steam/src/api/captcha.h @@ -0,0 +1,14 @@ +#ifndef _STEAM_REQUEST_CAPTCHA_H_
+#define _STEAM_REQUEST_CAPTCHA_H_
+
+class GetCaptchaRequest : public HttpRequest
+{
+public:
+ GetCaptchaRequest(const char *captchaId) :
+ HttpRequest(REQUEST_GET, FORMAT, STEAM_WEB_URL "/public/captcha.php?gid=%s", captchaId)
+ {
+ flags = NLHRF_HTTP11 | NLHRF_NODUMP;
+ }
+};
+
+#endif //_STEAM_REQUEST_CAPTCHA_H_
diff --git a/protocols/Steam/src/api/friend.h b/protocols/Steam/src/api/friend.h new file mode 100644 index 0000000000..d0fd70fa22 --- /dev/null +++ b/protocols/Steam/src/api/friend.h @@ -0,0 +1,15 @@ +#ifndef _STEAM_REQUEST_FRIEND_H_
+#define _STEAM_REQUEST_FRIEND_H_
+
+class GetUserSummariesRequest : public HttpRequest
+{
+public:
+ GetUserSummariesRequest(const char *token, const char *steamIds) :
+ HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001")
+ {
+ AddParameter("access_token", token);
+ AddParameter("steamids", steamIds);
+ }
+};
+
+#endif //_STEAM_REQUEST_FRIEND_H_
diff --git a/protocols/Steam/src/api/friend_list.h b/protocols/Steam/src/api/friend_list.h new file mode 100644 index 0000000000..4c1d6f8ef2 --- /dev/null +++ b/protocols/Steam/src/api/friend_list.h @@ -0,0 +1,88 @@ +#ifndef _STEAM_REQUEST_FRIEND_LIST_H_
+#define _STEAM_REQUEST_FRIEND_LIST_H_
+
+class GetFriendListRequest : public HttpRequest
+{
+public:
+ GetFriendListRequest(const char *token, const char *steamId, const char *relationship = "friend,ignoredfriend,requestrecipient") :
+ HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001")
+ {
+ AddParameter("access_token", token);
+ AddParameter("steamid", steamId);
+ AddParameter("relationship", relationship);
+ }
+};
+
+class AddFriendRequest : public HttpRequest
+{
+public:
+ AddFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/AddFriendAjax")
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[128];
+ mir_snprintf(data, SIZEOF(data),
+ "sessionID=%s&steamid=%s",
+ sessionId,
+ who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+class BlockFriendRequest : public HttpRequest
+{
+public:
+ BlockFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/BlockUserAjax")
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[128];
+ mir_snprintf(data, SIZEOF(data),
+ "sessionID=%s&action=ignore&steamid=%s",
+ sessionId,
+ who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+class RemoveFriendRequest : public HttpRequest
+{
+public:
+ RemoveFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/RemoveFriendAjax")
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[128];
+ mir_snprintf(data, SIZEOF(data),
+ "sessionID=%s&steamid=%s",
+ sessionId,
+ who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_FRIEND_LIST_H_
diff --git a/protocols/Steam/src/api/login.h b/protocols/Steam/src/api/login.h new file mode 100644 index 0000000000..64b41f07cb --- /dev/null +++ b/protocols/Steam/src/api/login.h @@ -0,0 +1,32 @@ +#ifndef _STEAM_REQUEST_LOGIN_H_
+#define _STEAM_REQUEST_LOGIN_H_
+
+class LogonRequest : public HttpRequest
+{
+public:
+ LogonRequest(const char *token) :
+ HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logon/v0001")
+ {
+ char data[256];
+ mir_snprintf(data, SIZEOF(data), "access_token=%s&ui_mode=web", token);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+class LogoffRequest : public HttpRequest
+{
+public:
+ LogoffRequest(const char *token, const char *umqId) :
+ HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logoff/v0001")
+ {
+ char data[256];
+ mir_snprintf(data, SIZEOF(data), "access_token=%s&umqid=%s", token, umqId);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_LOGIN_H_
diff --git a/protocols/Steam/src/api/message.h b/protocols/Steam/src/api/message.h new file mode 100644 index 0000000000..cb3a1f0590 --- /dev/null +++ b/protocols/Steam/src/api/message.h @@ -0,0 +1,22 @@ +#ifndef _STEAM_REQUEST_MESSAGE_H_
+#define _STEAM_REQUEST_MESSAGE_H_
+
+class SendMessageRequest : public HttpRequest
+{
+public:
+ SendMessageRequest(const char *token, const char *umqId, const char *steamId, const char *text) :
+ HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001")
+ {
+ CMStringA data;
+ data.AppendFormat("access_token=%s&umqid=%s&steamid_dst=%s&type=saytext&text=%s",
+ token,
+ umqId,
+ steamId,
+ ptrA(mir_urlEncode(text)));
+
+ SetData(data, data.GetLength());
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_MESSAGE_H_
diff --git a/protocols/Steam/src/api/pending.h b/protocols/Steam/src/api/pending.h new file mode 100644 index 0000000000..f9965d341f --- /dev/null +++ b/protocols/Steam/src/api/pending.h @@ -0,0 +1,67 @@ +#ifndef _STEAM_REQUEST_PENDING_H_
+#define _STEAM_REQUEST_PENDING_H_
+
+class ApprovePendingRequest : public HttpRequest
+{
+public:
+ ApprovePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[MAX_PATH];
+ mir_snprintf(data, SIZEOF(data), "sessionID=%s&id=%s&perform=accept&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+class IgnorePendingRequest : public HttpRequest
+{
+public:
+ IgnorePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[MAX_PATH];
+ mir_snprintf(data, SIZEOF(data), "sessionID=%s&id=%s&perform=ignore&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+class BlockPendingRequest : public HttpRequest
+{
+public:
+ BlockPendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
+ HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId)
+ {
+ char login[MAX_PATH];
+ mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
+
+ char cookie[MAX_PATH];
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
+
+ char data[MAX_PATH];
+ mir_snprintf(data, SIZEOF(data), "sessionID=%s&id=%s&perform=block&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);
+
+ SetData(data, strlen(data));
+ AddHeader("Cookie", cookie);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_PENDING_H_
diff --git a/protocols/Steam/src/api/poll.h b/protocols/Steam/src/api/poll.h new file mode 100644 index 0000000000..fec71c98e4 --- /dev/null +++ b/protocols/Steam/src/api/poll.h @@ -0,0 +1,28 @@ +#ifndef _STEAM_REQUEST_POLL_H_ +#define _STEAM_REQUEST_POLL_H_ + +class PollRequest : public HttpRequest +{ +public: + PollRequest(const char *token, const char *umqId, UINT32 messageId, int idleSeconds) : + HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001") + { + timeout = (STEAM_API_TIMEOUT + 5) * 1000; + flags |= NLHRF_PERSISTENT; + + CMStringA data; + data.AppendFormat("access_token=%s&umqid=%s&message=%u&secidletime=%d§imeout=%d", + token, + umqId, + messageId, + idleSeconds, + STEAM_API_TIMEOUT); + + SetData(data, data.GetLength()); + + AddHeader("Connection", "keep-alive"); + AddHeader("Content-Type", "application/x-www-form-urlencoded"); + } +}; + +#endif //_STEAM_REQUEST_POLL_H_ diff --git a/protocols/Steam/src/api/rsa_key.h b/protocols/Steam/src/api/rsa_key.h new file mode 100644 index 0000000000..6b938a48ef --- /dev/null +++ b/protocols/Steam/src/api/rsa_key.h @@ -0,0 +1,16 @@ +#ifndef _STEAM_REQUEST_RSA_KEY_H_
+#define _STEAM_REQUEST_RSA_KEY_H_
+
+class RsaKeyRequest : public HttpRequest
+{
+public:
+ RsaKeyRequest(const char *username) :
+ HttpRequest(REQUEST_GET, STEAM_WEB_URL "/mobilelogin/getrsakey")
+ {
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
+
+ AddParameter("username", (char*)username);
+ }
+};
+
+#endif //_STEAM_REQUEST_RSA_KEY_H_
diff --git a/protocols/Steam/src/api/search.h b/protocols/Steam/src/api/search.h new file mode 100644 index 0000000000..ed1b0420eb --- /dev/null +++ b/protocols/Steam/src/api/search.h @@ -0,0 +1,17 @@ +#ifndef _STEAM_REQUEST_SEARCH_H_
+#define _STEAM_REQUEST_SEARCH_H_
+
+class SearchRequest : public HttpRequest
+{
+public:
+ SearchRequest(const char *token, const char *text) :
+ HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/Search/v0001")
+ {
+ AddParameter("access_token", token);
+ AddParameter("keywords", ptrA(mir_urlEncode(text)));
+ // todo: may need to load all results (15 first at now)
+ AddParameter("offset=0&count=15&targets=users&fields=all");
+ }
+};
+
+#endif //_STEAM_REQUEST_SEARCH_H_
diff --git a/protocols/Steam/src/api/session.h b/protocols/Steam/src/api/session.h new file mode 100644 index 0000000000..3e13a2e418 --- /dev/null +++ b/protocols/Steam/src/api/session.h @@ -0,0 +1,24 @@ +#ifndef _STEAM_REQUEST_SESSION_H_
+#define _STEAM_REQUEST_SESSION_H_
+
+class GetSessionRequest : public HttpRequest
+{
+public:
+ GetSessionRequest(const char *token, const char *steamId, const char *cookie) :
+ HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobileloginsucceeded")
+ {
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
+
+ char data[512];
+ mir_snprintf(data, SIZEOF(data),
+ "oauth_token=%s&steamid=%s&webcookie=%s",
+ token,
+ steamId,
+ cookie);
+
+ SetData(data, strlen(data));
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+};
+
+#endif //_STEAM_REQUEST_SESSION_H_
|