diff options
-rw-r--r-- | protocols/Steam/Steam_12.vcxproj | 3 | ||||
-rw-r--r-- | protocols/Steam/Steam_12.vcxproj.filters | 5 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/authorization.h | 39 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/friend_list.h | 34 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/pending.h (renamed from protocols/Steam/src/Steam/invitation.h) | 39 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/session.h | 55 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/steam.h | 7 | ||||
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 13 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 33 | ||||
-rw-r--r-- | protocols/Steam/src/steam_dialogs.cpp | 2 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 5 |
11 files changed, 197 insertions, 38 deletions
diff --git a/protocols/Steam/Steam_12.vcxproj b/protocols/Steam/Steam_12.vcxproj index e62e575c30..64d49fd8d1 100644 --- a/protocols/Steam/Steam_12.vcxproj +++ b/protocols/Steam/Steam_12.vcxproj @@ -199,10 +199,11 @@ <ClInclude Include="src\Steam\crypto.h" />
<ClInclude Include="src\Steam\friend.h" />
<ClInclude Include="src\Steam\friend_list.h" />
- <ClInclude Include="src\Steam\invitation.h" />
+ <ClInclude Include="src\Steam\pending.h" />
<ClInclude Include="src\Steam\login.h" />
<ClInclude Include="src\Steam\message.h" />
<ClInclude Include="src\Steam\poll.h" />
+ <ClInclude Include="src\Steam\session.h" />
<ClInclude Include="src\Steam\steam.h" />
<ClInclude Include="src\steam_proto.h" />
<ClInclude Include="src\version.h" />
diff --git a/protocols/Steam/Steam_12.vcxproj.filters b/protocols/Steam/Steam_12.vcxproj.filters index ee476ff7c2..434d1adc74 100644 --- a/protocols/Steam/Steam_12.vcxproj.filters +++ b/protocols/Steam/Steam_12.vcxproj.filters @@ -98,7 +98,10 @@ <ClInclude Include="src\common.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\Steam\invitation.h">
+ <ClInclude Include="src\Steam\pending.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\session.h">
<Filter>Header Files\Steam</Filter>
</ClInclude>
</ItemGroup>
diff --git a/protocols/Steam/src/Steam/authorization.h b/protocols/Steam/src/Steam/authorization.h index 2269167bd3..baa5d2c93f 100644 --- a/protocols/Steam/src/Steam/authorization.h +++ b/protocols/Steam/src/Steam/authorization.h @@ -16,6 +16,8 @@ namespace SteamWebApi std::string token;
std::string cookie;
+ std::string sessionid;
+
std::string emailauth;
std::string emaildomain;
std::string emailsteamid;
@@ -41,6 +43,7 @@ namespace SteamWebApi const char *GetSteamid() const { return steamid.c_str(); }
const char *GetToken() const { return token.c_str(); }
const char *GetCookie() const { return cookie.c_str(); }
+ const char *GetSessionId() const { return sessionid.c_str(); }
const char *GetAuthId() const { return emailauth.c_str(); }
const char *GetAuthCode() const { return emailsteamid.c_str(); }
const char *GetEmailDomain() const { return emaildomain.c_str(); }
@@ -68,14 +71,15 @@ namespace SteamWebApi char data[1024];
mir_snprintf(data, SIZEOF(data),
- "username=%s&password=%s&emailauth=%s&emailsteamid=%s&captchagid=%s&captcha_text=%s&rsatimestamp=%s&oauth_client_id=DE45CD61",
+ "username=%s&password=%s&emailauth=%s&emailsteamid=%s&captchagid=%s&captcha_text=%s&rsatimestamp=%s&donotcache=%ld&remember_login=true&oauth_client_id=DE45CD61&oauth_scope=read_profile write_profile read_client write_client",
base64Username,
ptrA(mir_urlEncode(password)),
ptrA(mir_urlEncode(authResult->emailauth.c_str())),
authResult->emailsteamid.c_str(),
authResult->captchagid.c_str(),
ptrA(mir_urlEncode(authResult->captcha_text.c_str())),
- timestamp);
+ timestamp,
+ time(NULL));
SecureHttpPostRequest request(hConnection, STEAM_COM_URL "/mobilelogin/dologin");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -135,8 +139,35 @@ namespace SteamWebApi node = json_get(root, "oauth_token");
authResult->token = ptrA(mir_u2a(json_as_string(node)));
- /*node = json_get(root, "webcookie");
- authResult->cookie = ptrA(mir_u2a(json_as_string(node)));*/
+ node = json_get(root, "webcookie");
+ authResult->cookie = ptrA(mir_u2a(json_as_string(node)));
+
+ mir_snprintf(data, SIZEOF(data),
+ "oauth_token=%s&steamid=%s&webcookie=%s",
+ authResult->token.c_str(),
+ authResult->steamid.c_str(),
+ authResult->cookie.c_str());
+
+ SecureHttpPostRequest second_request(hConnection, STEAM_COM_URL "/mobileloginsucceeded");
+ second_request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ second_request.ResetFlags(NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP);
+ second_request.SetData(data, strlen(data));
+
+ response = second_request.Send();
+ if (!response)
+ return;
+
+ for (int i = 0; i < response->headersCount; i++)
+ {
+ if (lstrcmpiA(response->headers[i].szName, "Set-Cookie"))
+ continue;
+
+ std::string cookies = response->headers[i].szValue;
+ size_t start = cookies.find("sessionid=") + 10;
+ size_t end = cookies.substr(start).find(';');
+ authResult->sessionid = cookies.substr(start, end - start + 10);
+ break;
+ }
authResult->success = true;
authResult->captcha_needed = false;
diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h index dc8b78cf0d..78a30333a0 100644 --- a/protocols/Steam/src/Steam/friend_list.h +++ b/protocols/Steam/src/Steam/friend_list.h @@ -94,45 +94,63 @@ namespace SteamWebApi friendList->success = true;
}
- static void AddFriend(HANDLE hConnection, const char *sessionId, const char *steamId, Result *result)
+ static void AddFriend(HANDLE hConnection, const char *token, const char *sessionId, const char *steamId, const char *who, Result *result)
{
result->success = false;
+ 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),
- "steamid=%s&sessionID=%s",
+ "sessionID=%s&steamid=%s",
sessionId,
- steamId);
+ who);
SecureHttpPostRequest request(hConnection, STEAM_COM_URL "/actions/AddFriendAjax");
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.AddHeader("Cookie", cookie);
+ request.SetData(data, strlen(data));
mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
if (!response)
return;
- if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK)
+ if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK || lstrcmpiA(response->pData, "true"))
return;
result->success = true;
}
- static void RemoveFriend(HANDLE hConnection, const char *sessionId, const char *steamId, Result *result)
+ static void RemoveFriend(HANDLE hConnection, const char *token, const char *sessionId, const char *steamId, const char *who, Result *result)
{
result->success = false;
+ 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),
- "steamid=%s&sessionID=%s",
+ "sessionID=%s&steamid=%s",
sessionId,
- steamId);
+ who);
SecureHttpPostRequest request(hConnection, STEAM_COM_URL "/actions/RemoveFriendAjax");
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.AddHeader("Cookie", cookie);
+ request.SetData(data, strlen(data));
mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
if (!response)
return;
- if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK)
+ if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK || lstrcmpiA(response->pData, "true"))
return;
result->success = true;
diff --git a/protocols/Steam/src/Steam/invitation.h b/protocols/Steam/src/Steam/pending.h index defe721fa8..d010e6982b 100644 --- a/protocols/Steam/src/Steam/invitation.h +++ b/protocols/Steam/src/Steam/pending.h @@ -1,9 +1,9 @@ -#ifndef _STEAM_INVITATION_H_
-#define _STEAM_INVITATION_H_
+#ifndef _STEAM_PENDING_H_
+#define _STEAM_PENDING_H_
namespace SteamWebApi
{
- class InvitationApi : public BaseApi
+ class PendingApi : public BaseApi
{
public:
static void Accept(HANDLE hConnection, const char *token, const char *sessionId, const char *steamId, const char *who, Result *result)
@@ -14,15 +14,16 @@ namespace SteamWebApi mir_snprintf(login, SIZEOF(login), "%s||oauth:%s", steamId, token);
char cookie[MAX_PATH];
- mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s; sessionid=%s", login, sessionId);
+ mir_snprintf(cookie, SIZEOF(cookie), "steamLogin=%s;sessionid=%s;forceMobile=1", login, sessionId);
char url[MAX_PATH];
- mir_snprintf(url, SIZEOF(url), "%s/profiles/%s/home_process", STEAM_COM_URL, steamId);
+ mir_snprintf(url, SIZEOF(url), STEAM_COM_URL "/profiles/%s/home_process", steamId);
char data[MAX_PATH];
- mir_snprintf(data, SIZEOF(data), "sessionID=%s&id=%s&perform=accept&action=approvePending&itype=friend&json=1&xml=1", sessionId, who);
+ mir_snprintf(data, SIZEOF(data), "sessionID=%s&id=%s&perform=accept&action=approvePending&itype=friend&json=1&xml=0", sessionId, who);
SecureHttpPostRequest request(hConnection, url);
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Cookie", cookie);
request.SetData(data, strlen(data));
@@ -36,17 +37,25 @@ namespace SteamWebApi result->success = true;
}
- static void Ignore(HANDLE hConnection, const char *sessionId, const char *steamId, const char *who, Result *result)
+ static void Ignore(HANDLE hConnection, const char *token, const char *sessionId, const char *steamId, const char *who, Result *result)
{
result->success = false;
+ 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 url[MAX_PATH];
- mir_snprintf(url, SIZEOF(url), "%s/profiles/%s/home_process", STEAM_COM_URL, steamId);
+ mir_snprintf(url, SIZEOF(url), STEAM_COM_URL "/profiles/%s/home_process", steamId);
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);
SecureHttpPostRequest request(hConnection, url);
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.AddHeader("Cookie", cookie);
request.SetData(data, strlen(data));
mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
@@ -59,17 +68,25 @@ namespace SteamWebApi result->success = true;
}
- static void Block(HANDLE hConnection, const char *sessionId, const char *steamId, const char *who, Result *result)
+ static void Block(HANDLE hConnection, const char *token, const char *sessionId, const char *steamId, const char *who, Result *result)
{
result->success = false;
+ 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 url[MAX_PATH];
- mir_snprintf(url, SIZEOF(url), "%s/profiles/%s/home_process", STEAM_COM_URL, steamId);
+ mir_snprintf(url, SIZEOF(url), STEAM_COM_URL "/profiles/%s/home_process", steamId);
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);
SecureHttpPostRequest request(hConnection, url);
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.AddHeader("Cookie", cookie);
request.SetData(data, strlen(data));
mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
@@ -84,4 +101,4 @@ namespace SteamWebApi };
}
-#endif //_STEAM_INVITATION_H_
\ No newline at end of file +#endif //_STEAM_PENDING_H_
\ No newline at end of file diff --git a/protocols/Steam/src/Steam/session.h b/protocols/Steam/src/Steam/session.h new file mode 100644 index 0000000000..cad2f96dbf --- /dev/null +++ b/protocols/Steam/src/Steam/session.h @@ -0,0 +1,55 @@ +#ifndef _STEAM_SESSION_H_
+#define _STEAM_SESSION_H_
+
+namespace SteamWebApi
+{
+ class SessionApi : public BaseApi
+ {
+ public:
+ class SessionId : public Result
+ {
+ friend SessionApi;
+
+ private:
+ std::string sessionid;
+
+ public:
+
+ const char *GetSessionId() { return sessionid.c_str(); }
+ };
+
+ static void GetSessionId(HANDLE hConnection, const char *token, const char *steamId, SessionId *sessionId)
+ {
+ sessionId->success = false;
+
+ 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", ptrA(mir_urlEncode(login)));
+
+ SecureHttpGetRequest request(hConnection, STEAM_COM_URL "/mobilesettings/GetManifest/v0001");
+ request.AddHeader("Cookie", cookie);
+
+ mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
+ if (!response)
+ return;
+
+ for (int i = 0; i < response->headersCount; i++)
+ {
+ if (lstrcmpiA(response->headers[i].szName, "Set-Cookie"))
+ continue;
+
+ std::string cookies = response->headers[i].szValue;
+ size_t start = cookies.find("sessionid=") + 10;
+ size_t end = cookies.substr(start).find(';');
+ sessionId->sessionid = cookies.substr(start, end - start + 10);
+ break;
+ }
+
+ sessionId->success = true;
+ }
+ };
+}
+
+#endif //_STEAM_SESSION_H_
\ No newline at end of file diff --git a/protocols/Steam/src/Steam/steam.h b/protocols/Steam/src/Steam/steam.h index 52de0e5441..66d9068100 100644 --- a/protocols/Steam/src/Steam/steam.h +++ b/protocols/Steam/src/Steam/steam.h @@ -7,7 +7,7 @@ namespace SteamWebApi #define STEAM_COM_URL "https://steamcommunity.com"
class FriendListApi;
- class InvitationApi;
+ class PendingApi;
class BaseApi
{
@@ -15,7 +15,7 @@ namespace SteamWebApi class Result
{
friend FriendListApi;
- friend InvitationApi;
+ friend PendingApi;
protected:
bool success;
@@ -33,8 +33,9 @@ namespace SteamWebApi #include "Steam\rsa_key.h"
#include "Steam\authorization.h"
#include "Steam\login.h"
+#include "Steam\session.h"
#include "Steam\friend_list.h"
-#include "Steam\invitation.h"
+#include "Steam\pending.h"
#include "Steam\friend.h"
#include "Steam\poll.h"
#include "Steam\message.h"
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index 90062d7375..0335d40b1d 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -146,8 +146,9 @@ void CSteamProto::LogInThread(void* param) token = mir_strdup(authResult.GetToken());
setString("TokenSecret", token);
- //setString("Cookie", authResult.GetCookie());
+ setString("Cookie", authResult.GetCookie());
setString("SteamID", authResult.GetSteamid());
+ setString("SessionID", authResult.GetSessionId());
}
SteamWebApi::LoginApi::LoginResult loginResult;
@@ -179,6 +180,16 @@ void CSteamProto::LogInThread(void* param) m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus);
+ ptrA sessionId(getStringA("SessionID"));
+ if (!sessionId || lstrlenA(sessionId) == 0)
+ {
+ SteamWebApi::SessionApi::SessionId result;
+ debugLogA("CSteamProto::LogInThread: call SteamWebApi::SessionApi::GetSessionId");
+ SteamWebApi::SessionApi::GetSessionId(m_hNetlibUser, token, loginResult.GetSteamId(), &result);
+ if (result.IsSuccess())
+ setString("SessionID", result.GetSessionId());
+ }
+
// load contact list
LoadContactListThread(NULL);
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 3936d4f742..2f3018a873 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -267,14 +267,23 @@ void CSteamProto::AuthAllowThread(void *arg) ptrA steamId(getStringA("SteamID"));
ptrA who(getStringA(hContact, "SteamID"));
- SteamWebApi::InvitationApi::Result result;
- debugLogA("CSteamProto::AuthAllowThread: call SteamWebApi::InvitationApi::Accept");
- SteamWebApi::InvitationApi::Accept(m_hNetlibUser, token, sessionId, steamId, who, &result);
+ SteamWebApi::PendingApi::Result result;
+ debugLogA("CSteamProto::AuthAllowThread: call SteamWebApi::PendingApi::Accept");
+ SteamWebApi::PendingApi::Accept(m_hNetlibUser, token, sessionId, steamId, who, &result);
if (result.IsSuccess())
{
delSetting(hContact, "Auth");
delSetting(hContact, "Grant");
+
+ /*SteamWebApi::FriendApi::Summaries summaries;
+ debugLogA("CSteamProto::AuthAllowThread: call SteamWebApi::FriendApi::LoadSummaries");
+ SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, who, &summaries);
+
+ if (summaries.IsSuccess())
+ {
+ UpdateContact(hContact, summaries.GetAt(0));
+ }*/
}
}
@@ -284,13 +293,14 @@ void CSteamProto::AuthDenyThread(void *arg) if (!hContact)
return;
+ ptrA token(getStringA("TokenSecret"));
ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
ptrA who(getStringA(hContact, "SteamID"));
- SteamWebApi::InvitationApi::Result result;
- debugLogA("CSteamProto::AuthDenyThread: call SteamWebApi::InvitationApi::Ignore");
- SteamWebApi::InvitationApi::Ignore(m_hNetlibUser, sessionId, steamId, who, &result);
+ SteamWebApi::PendingApi::Result result;
+ debugLogA("CSteamProto::AuthDenyThread: call SteamWebApi::PendingApi::Ignore");
+ SteamWebApi::PendingApi::Ignore(m_hNetlibUser, token, sessionId, steamId, who, &result);
}
void CSteamProto::AddContactThread(void *arg)
@@ -299,6 +309,17 @@ void CSteamProto::AddContactThread(void *arg) void CSteamProto::RemoveContactThread(void *arg)
{
+ if (!arg)
+ return;
+
+ ptrA token(getStringA("TokenSecret"));
+ ptrA sessionId(getStringA("SessionID"));
+ ptrA steamId(getStringA("SteamID"));
+ ptrA who((char*)arg);
+
+ SteamWebApi::FriendListApi::Result result;
+ debugLogA("CSteamProto::RemoveContactThread: call SteamWebApi::FriendListApi::RemoveFriend");
+ SteamWebApi::FriendListApi::RemoveFriend(m_hNetlibUser, token, sessionId, steamId, who, &result);
}
void CSteamProto::LoadContactListThread(void*)
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index 0b7711262a..2e672fff92 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -17,7 +17,7 @@ INT_PTR CALLBACK CSteamProto::GuardProc(HWND hwnd, UINT message, WPARAM wParam, SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(iconName, 16));
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(iconName, 32));
}
- Utils_RestoreWindowPositionNoSize(hwnd, 0, "STEAM", "GuardWindow");
+ Utils_RestoreWindowPosition(hwnd, NULL, "STEAM", "GuardWindow");
return TRUE;
case WM_CLOSE:
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 8040a1b226..73dd62791b 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -277,8 +277,9 @@ int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM /*case EV_PROTO_ONOPTIONS:
return this->OnOptionsInit(wParam, lParam);*/
- /*case EV_PROTO_ONCONTACTDELETED:
- return this->OnContactDeleted(wParam, lParam);*/
+ case EV_PROTO_ONCONTACTDELETED:
+ ForkThread(&CSteamProto::RemoveContactThread, (void*)getStringA(wParam, "SteamID"));
+ return 0;
/*case EV_PROTO_ONMENU:
this->OnInitStatusMenu();
|