summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-03-20 16:46:51 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-03-20 16:46:51 +0000
commitc5b775b6feaadaf210ab45d98cfc0018fb7d59ae (patch)
tree557cb69f9e42e8081cfbc03fcd290c6ab91bc23b
parent0c3557210c245072ddecbcb67fa6d790fce672f0 (diff)
git-svn-id: http://svn.miranda-ng.org/main/trunk@16515 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/VKontakte/src/misc.cpp66
1 files changed, 29 insertions, 37 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index d2731d64e7..5ce894bd1b 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -583,38 +583,40 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform)
MirVer = _T("QIP 2012 VKontakte");
break;
case 1:
- MirVer = _T("VKontakte (mobile)");
+ MirVer = _T("VKontakte (Mobile)");
break;
case 3087106: // iPhone
case 3140623:
case 2:
- MirVer = _T("VKontakte (iphone)");
+ MirVer = _T("VKontakte (iPhone)");
break;
case 3682744: // iPad
case 3:
- MirVer = _T("VKontakte (ipad)");
+ MirVer = _T("VKontakte (iPad)");
break;
case 2685278: // Android - Kate
+ MirVer = _T("Kate Mobile (Android)");
+ break;
case 2890984: // Android
case 2274003:
case 4:
- MirVer = _T("VKontakte (android)");
+ MirVer = _T("VKontakte (Android)");
break;
case 3059453: // Windows Phone
case 2424737:
case 3502561:
case 5:
- MirVer = _T("VKontakte (wphone)");
+ MirVer = _T("VKontakte (WPhone)");
break;
case 3584591: // Windows 8.x
case 6:
- MirVer = _T("VKontakte (windows)");
+ MirVer = _T("VKontakte (Windows)");
break;
case 7:
- MirVer = _T("VKontakte (website)");
+ MirVer = _T("VKontakte (Website)");
break;
default:
- MirVer = _T("VKontakte (other)");
+ MirVer = _T("VKontakte (Other)");
bSetFlag = OldMirVer.IsEmpty();
}
@@ -1275,46 +1277,36 @@ 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);
-
- 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;
+
+ CMString tszHTMLPath(FORMAT, _T("%s\\miranda_captcha.html"), tszTempDir);
- tszFHTML.Replace(_T(".png"), _T(".html"));
- if (!(GetFileAttributes(tszFHTML) < 0xFFFFFFF)) {
- FILE *pFile = _tfopen(tszFHTML, _T("w"));
+ if (!(GetFileAttributes(tszHTMLPath) < 0xFFFFFFF)) {
+ FILE *pFile = _tfopen(tszHTMLPath, _T("w"));
if (pFile == NULL)
return;
- CMStringA szHTML("<html><body><img src=\"miranda_captcha.png\" /></body></html>");
+ FIBITMAP *dib = fii->FI_CreateDIBFromHBITMAP(hBitmap);
+ FIMEMORY *hMem = fii->FI_OpenMemory(nullptr, 0);
+ fii->FI_SaveToMemory(FIF_PNG, dib, hMem, 0);
+
+ BYTE *buf = nullptr;
+ 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