diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-06-18 15:53:28 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-06-18 15:53:28 +0000 |
commit | 712eac88f619b057d335bbe11426292f033a6f49 (patch) | |
tree | 7eb68a78c6a79a8e84e4feb46d7751bb2f6b8024 /protocols/Steam | |
parent | ed71ff438fb48e32346480bda3b7214b9f2f487b (diff) |
Steam: captcha support
git-svn-id: http://svn.miranda-ng.org/main/trunk@9537 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r-- | protocols/Steam/res/Resource.rc | 12 | ||||
-rw-r--r-- | protocols/Steam/src/resource.h | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 21 | ||||
-rw-r--r-- | protocols/Steam/src/steam_dialogs.cpp | 14 |
4 files changed, 32 insertions, 19 deletions
diff --git a/protocols/Steam/res/Resource.rc b/protocols/Steam/res/Resource.rc index 5ae4a382f5..512af64348 100644 --- a/protocols/Steam/res/Resource.rc +++ b/protocols/Steam/res/Resource.rc @@ -106,14 +106,14 @@ BEGIN LTEXT "Default group:",-1,15,61,69,8
END
-IDD_CAPTCHA DIALOGEX 0, 0, 274, 91
+IDD_CAPTCHA DIALOGEX 0, 0, 143, 81
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Captcha"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- EDITTEXT IDC_TEXT,7,51,260,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "OK",IDOK,164,70,50,14
- PUSHBUTTON "Cancel",IDCANCEL,217,70,50,14
+ EDITTEXT IDC_TEXT,7,40,129,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,31,60,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,86,60,50,14
END
IDD_GUARD DIALOGEX 0, 0, 193, 93
@@ -162,9 +162,9 @@ BEGIN IDD_CAPTCHA, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 267
+ RIGHTMARGIN, 136
TOPMARGIN, 7
- BOTTOMMARGIN, 84
+ BOTTOMMARGIN, 74
END
IDD_GUARD, DIALOG
diff --git a/protocols/Steam/src/resource.h b/protocols/Steam/src/resource.h index 3432481021..f2817e7d20 100644 --- a/protocols/Steam/src/resource.h +++ b/protocols/Steam/src/resource.h @@ -23,6 +23,8 @@ #define IDC_GROUP 1021
#define IDC_BM_LIST 1064
#define IDC_TEXT 1082
+#define IDC_CUSTOM1 1083
+#define IDC_BUTTON1 1084
#define IDC_OPENDOMAIN 1200
#define IDC_GETDOMAIN 1200
@@ -32,7 +34,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 120
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1083
+#define _APS_NEXT_CONTROL_VALUE 1085
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index f05741f0bd..70f1c561d4 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -102,7 +102,7 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) new SteamWebApi::AuthorizationRequest(username, base64RsaEncryptedPassword, timestamp, guardId, guard.code),
&CSteamProto::OnAuthorization);
}
-
+
node = json_get(root, "captcha_needed");
if (json_as_bool(node) > 0)
{
@@ -117,8 +117,6 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) NETLIBHTTPREQUEST *response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)request);
delete request;
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)url);
-
CaptchaParam captcha = { 0 };
captcha.size = response->dataLength;
captcha.data = (BYTE*)mir_alloc(captcha.size);
@@ -126,13 +124,20 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
- if (DialogBoxParam(
+ int res = DialogBoxParam(
g_hInstance,
MAKEINTRESOURCE(IDD_CAPTCHA),
NULL,
CSteamProto::CaptchaProc,
- (LPARAM)&captcha) != 1)
+ (LPARAM)&captcha);
+
+ mir_free(captcha.data);
+
+ if (res != 1)
+ {
+ SetStatus(ID_STATUS_OFFLINE);
return;
+ }
ptrA username(mir_urlEncode(ptrA(mir_utf8encodeW(getWStringA("Username")))));
ptrA base64RsaEncryptedPassword(getStringA("EncryptedPassword"));
@@ -143,12 +148,16 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) &CSteamProto::OnAuthorization);
}
+ SetStatus(ID_STATUS_OFFLINE);
return;
}
-
+
node = json_get(root, "login_complete");
if (!json_as_bool(node))
+ {
+ SetStatus(ID_STATUS_OFFLINE);
return;
+ }
node = json_get(root, "oauth");
root = json_parse(ptrA(mir_u2a(json_as_string(node))));
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index 4df9192d81..882a30b70a 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -83,18 +83,20 @@ INT_PTR CALLBACK CSteamProto::CaptchaProc(HWND hwnd, UINT message, WPARAM wParam return 0;
}
- FIMEMORY *memory = fei->FI_OpenMemory(captcha->data, captcha->size);
- FIBITMAP *bitmap = fei->FI_LoadFromMemory(FIF_PNG, memory, PNG_DEFAULT);
- fei->FI_CloseMemory(memory);
+ FIMEMORY *stream = fei->FI_OpenMemory(captcha->data, captcha->size);
+ FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeFromMemory(stream, 0);
+ FIBITMAP *bitmap = fei->FI_LoadFromMemory(fif, stream, 0);
+ fei->FI_CloseMemory(stream);
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hwnd, &ps);
- SetStretchBltMode(hDC, COLORONCOLOR);
+ //SetStretchBltMode(hDC, COLORONCOLOR);
StretchDIBits(
hDC,
- 0, 0,
- 206, 40,
+ 11, 11,
+ fei->FI_GetWidth(bitmap) - 13,
+ fei->FI_GetHeight(bitmap),
0, 0,
fei->FI_GetWidth(bitmap),
fei->FI_GetHeight(bitmap),
|