summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2016-03-18 08:39:23 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2016-03-18 08:39:23 +0000
commita1728bef4efb06742b792f9f5b4aab48d1d7bb48 (patch)
tree43bb17c0b27f92d47a831cab62a01861b660ac2e /protocols/VKontakte/src/misc.cpp
parentc00fd13ea14bdafd1d18c19fef9df9b3907130a4 (diff)
VKontakte:
add ‘Open in browser’ button to captcha form add hidden option ‘AlwaysOpenCaptchaInBrowser’ (BYTE) git-svn-id: http://svn.miranda-ng.org/main/trunk@16495 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index b9d33b2328..d2731d64e7 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1273,4 +1273,48 @@ CMString CVkProto::RemoveBBC(CMString& tszSrc)
}
return tszRes;
+}
+
+CMString CVkProto::SaveImage(HBITMAP hBitmap)
+{
+ TCHAR tszTempDir[MAX_PATH];
+
+ if (!GetEnvironmentVariable(_T("TEMP"), tszTempDir, MAX_PATH))
+ return CMString();
+
+ CMString tszImgFileName(FORMAT, _T("%s\\miranda_captcha.png"), tszTempDir);
+
+ 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;
+
+ return CMString();
+}
+
+void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap)
+{
+ CMString tszFHTML = SaveImage(hBitmap);
+
+ if (tszFHTML.IsEmpty())
+ return;
+
+ tszFHTML.Replace(_T(".png"), _T(".html"));
+
+ if (!(GetFileAttributes(tszFHTML) < 0xFFFFFFF)) {
+ FILE *pFile = _tfopen(tszFHTML, _T("w"));
+ if (pFile == NULL)
+ return;
+
+ CMStringA szHTML("<html><body><img src=\"miranda_captcha.png\" /></body></html>");
+ fwrite(szHTML, 1, szHTML.GetLength(), pFile);
+ fclose(pFile);
+ }
+
+ tszFHTML = _T("file://") + tszFHTML;
+ Utils_OpenUrlT(tszFHTML);
} \ No newline at end of file