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/misc.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/misc.cpp')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index fb13fa8ee4..d22fa90ad8 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1277,46 +1277,33 @@ CMString CVkProto::RemoveBBC(CMString& tszSrc) return tszRes;
}
-CMString CVkProto::SaveImage(HBITMAP hBitmap)
+void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap)
{
TCHAR tszTempDir[MAX_PATH];
-
if (!GetEnvironmentVariable(_T("TEMP"), tszTempDir, MAX_PATH))
- return CMString();
-
- CMString tszImgFileName(FORMAT, _T("%s\\miranda_captcha.png"), tszTempDir);
+ return;
- IMGSRVC_INFO isi = { sizeof(isi) };
- isi.tszName = mir_tstrdup(tszImgFileName);
- isi.hbm = hBitmap;
- isi.dwMask = IMGI_HBITMAP;
- isi.fif = FREE_IMAGE_FORMAT::FIF_PNG;
-
- if (CallService(MS_IMG_SAVE, (WPARAM)&isi, IMGL_TCHAR))
- return tszImgFileName;
+ CMString tszHTMLPath(FORMAT, _T("%s\\miranda_captcha.html"), tszTempDir);
- return CMString();
-}
-
-void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap)
-{
- CMString tszFHTML = SaveImage(hBitmap);
-
- if (tszFHTML.IsEmpty())
+ FILE *pFile = _tfopen(tszHTMLPath, _T("w"));
+ if (pFile == NULL)
return;
-
- tszFHTML.Replace(_T(".png"), _T(".html"));
- if (!(GetFileAttributes(tszFHTML) < 0xFFFFFFF)) {
- FILE *pFile = _tfopen(tszFHTML, _T("w"));
- if (pFile == NULL)
- return;
+ FIBITMAP *dib = fii->FI_CreateDIBFromHBITMAP(hBitmap);
+ FIMEMORY *hMem = fii->FI_OpenMemory(nullptr, 0);
+ fii->FI_SaveToMemory(FIF_PNG, dib, hMem, 0);
- CMStringA szHTML("<html><body><img src=\"miranda_captcha.png\" /></body></html>");
- fwrite(szHTML, 1, szHTML.GetLength(), pFile);
- fclose(pFile);
- }
+ BYTE *buf = NULL;
+ DWORD bufLen;
+ fii->FI_AcquireMemory(hMem, &buf, &bufLen);
+ ptrA base64(mir_base64_encode(buf, bufLen));
+ fii->FI_CloseMemory(hMem);
+
+
+ CMStringA szHTML(FORMAT, "<html><body><img src=\"data:image/png;base64,%s\" /></body></html>", base64);
+ fwrite(szHTML, 1, szHTML.GetLength(), pFile);
+ fclose(pFile);
- tszFHTML = _T("file://") + tszFHTML;
- Utils_OpenUrlT(tszFHTML);
+ tszHTMLPath = _T("file://") + tszHTMLPath;
+ Utils_OpenUrlT(tszHTMLPath);
}
\ No newline at end of file |