diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-03-21 07:22:23 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-03-21 07:22:23 +0000 |
commit | 2e2455779068f117e25bbb600d22f9f84aeb90a0 (patch) | |
tree | 456152f5ad4bf8b8d515db98164591ef430eb480 /protocols/VKontakte/src/vk_captcha.cpp | |
parent | 3290e01656f52149b1c0c871a84357ec53510e26 (diff) |
VKontakte:
captcha sent to browser as data:image/png;base64 (patсh by MikalaiR, edited)
add 'UseCaptchaAssistant' hidden option (BYTE)
git-svn-id: http://svn.miranda-ng.org/main/trunk@16520 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_captcha.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_captcha.cpp | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp index 9e7913443d..fdc450911d 100644 --- a/protocols/VKontakte/src/vk_captcha.cpp +++ b/protocols/VKontakte/src/vk_captcha.cpp @@ -42,6 +42,9 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see"));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params);
+ if (!params->proto)
+ EnableWindow(GetDlgItem(hwndDlg,IDOPENBROWSER), false);
+
return TRUE;
}
case WM_CTLCOLORSTATIC:
@@ -54,7 +57,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam return NULL;
case WM_PAINT:
- if (params) {
+ if (params && params->proto) {
PAINTSTRUCT ps;
HDC hdc, hdcMem;
RECT rc;
@@ -84,7 +87,8 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam return TRUE;
case IDOPENBROWSER:
- params->proto->ShowCaptchaInBrowser(params->bmp);
+ if (params->proto)
+ params->proto->ShowCaptchaInBrowser(params->bmp);
break;
case IDOK:
@@ -111,33 +115,42 @@ bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result) debugLogA("CVkProto::RunCaptchaForm: reading picture from %s", szUrl);
result.Empty();
- NETLIBHTTPREQUEST req = { sizeof(req) };
- req.requestType = REQUEST_GET;
- req.szUrl = (LPSTR)szUrl;
- req.flags = VK_NODUMPHEADERS;
+ CAPTCHA_FORM_PARAMS param = { 0 };
+ if (getBool("UseCaptchaAssistant", false)) {
+ CMStringA szCaptchaAssistant(FORMAT, "http://ca.tiflohelp.ru/?link=%s", ptrA(ExpUrlEncode(szUrl)));
+ Utils_OpenUrl(szCaptchaAssistant);
+ param.proto = NULL;
+ }
+ else {
+ NETLIBHTTPREQUEST req = { sizeof(req) };
+ req.requestType = REQUEST_GET;
+ req.szUrl = (LPSTR)szUrl;
+ req.flags = VK_NODUMPHEADERS;
+
+ NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ if (reply == NULL)
+ return false;
+
+ if (reply->resultCode != 200) {
+ debugLogA("CVkProto::RunCaptchaForm: failed with code %d", reply->resultCode);
+ return false;
+ }
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
- if (reply == NULL)
- return false;
- if (reply->resultCode != 200) {
- debugLogA("CVkProto::RunCaptchaForm: failed with code %d", reply->resultCode);
- return false;
- }
+ IMGSRVC_MEMIO memio = { 0 };
+ memio.iLen = reply->dataLength;
+ memio.pBuf = reply->pData;
+ memio.fif = FIF_UNKNOWN; /* detect */
+ param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);
- CAPTCHA_FORM_PARAMS param = { 0 };
+ BITMAP bmp = { 0 };
+ GetObject(param.bmp, sizeof(bmp), &bmp);
+ param.w = bmp.bmWidth;
+ param.h = bmp.bmHeight;
+ param.proto = this;
+
+ }
- IMGSRVC_MEMIO memio = { 0 };
- memio.iLen = reply->dataLength;
- memio.pBuf = reply->pData;
- memio.fif = FIF_UNKNOWN; /* detect */
- param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);
-
- BITMAP bmp = { 0 };
- GetObject(param.bmp, sizeof(bmp), &bmp);
- param.w = bmp.bmWidth;
- param.h = bmp.bmHeight;
- param.proto = this;
int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CAPTCHAFORM), NULL, CaptchaFormDlgProc, (LPARAM)¶m);
if (res == 0)
return false;
|