diff options
Diffstat (limited to 'protocols/FacebookRM/src/captcha.cpp')
-rw-r--r-- | protocols/FacebookRM/src/captcha.cpp | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp deleted file mode 100644 index 23226857c4..0000000000 --- a/protocols/FacebookRM/src/captcha.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - -Facebook plugin for Miranda Instant Messenger -_____________________________________________ - -Copyright © 2011-17 Robert Pösel, 2017-19 Miranda NG team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "stdafx.h" -#include "resource.h" - -///////////////////////////////////////////////////////////////////////////////////////// -// Captcha form - -struct CAPTCHA_FORM_PARAMS -{ - HBITMAP bmp; - int w, h; - char Result[100]; -}; - -static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CAPTCHA_FORM_PARAMS *params = (CAPTCHA_FORM_PARAMS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, Skin_GetIconHandle(SKINICON_OTHER_KEYS)); - params = (CAPTCHA_FORM_PARAMS*)lParam; - - SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see")); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params); - return TRUE; - - case WM_CTLCOLORSTATIC: - switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { - case IDC_WHITERECT: - case IDC_INSTRUCTION: - case IDC_TITLE: - return (INT_PTR)GetStockObject(WHITE_BRUSH); - } - return 0; - - case WM_PAINT: - if (params) { - PAINTSTRUCT ps; - HDC hdc, hdcMem; - RECT rc; - - GetClientRect(hwndDlg, &rc); - hdc = BeginPaint(hwndDlg, &ps); - hdcMem = CreateCompatibleDC(hdc); - HGDIOBJ hOld = SelectObject(hdcMem, params->bmp); - - int y = (rc.bottom + rc.top - params->h) / 2; - int x = (rc.right + rc.left - params->w) / 2; - BitBlt(hdc, x, y, params->w, params->h, hdcMem, 0, 0, SRCCOPY); - SelectObject(hdcMem, hOld); - DeleteDC(hdcMem); - - EndPaint(hwndDlg, &ps); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - - case IDOK: - GetDlgItemTextA(hwndDlg, IDC_VALUE, params->Result, _countof(params->Result)); - EndDialog(hwndDlg, 1); - return TRUE; - } - break; - - case WM_CLOSE: - EndDialog(hwndDlg, 0); - break; - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - break; - } - return FALSE; -} - -bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result) -{ - debugLogA(" RunCaptchaForm: reading picture from %s", captchaUrl.c_str()); - result.clear(); - - NETLIBHTTPREQUEST req = { sizeof(req) }; - req.requestType = REQUEST_GET; - req.szUrl = (char*)captchaUrl.c_str(); - req.flags = NLHRF_NODUMPHEADERS; - - NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(facy.handle_, &req); - if (reply == nullptr) - return false; - - if (reply->resultCode != HTTP_CODE_OK) { - debugLogA(" RunCaptchaForm: failed with code %d", reply->resultCode); - return false; - } - - CAPTCHA_FORM_PARAMS param = {}; - param.bmp = Image_LoadFromMem(reply->pData, reply->dataLength, FIF_UNKNOWN); - - BITMAP bmp = { 0 }; - GetObject(param.bmp, sizeof(bmp), &bmp); - param.w = bmp.bmWidth; - param.h = bmp.bmHeight; - int res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, CaptchaFormDlgProc, (LPARAM)¶m); - if (res == 0) - return false; - - debugLogA(" RunCaptchaForm: user entered text %s", param.Result); - result = param.Result; - return true; -} |