From 095b02026b6135626973778bb31e9bd2359ae2bc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 5 Jun 2015 19:27:43 +0000 Subject: icq ask auth window -> UI Utils git-svn-id: http://svn.miranda-ng.org/main/trunk@14018 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/askauthentication.cpp | 87 ++++++++++++--------------- protocols/IcqOscarJ/src/stdafx.h | 1 + 2 files changed, 39 insertions(+), 49 deletions(-) (limited to 'protocols/IcqOscarJ/src') diff --git a/protocols/IcqOscarJ/src/askauthentication.cpp b/protocols/IcqOscarJ/src/askauthentication.cpp index 1e8927ae12..f47a215514 100644 --- a/protocols/IcqOscarJ/src/askauthentication.cpp +++ b/protocols/IcqOscarJ/src/askauthentication.cpp @@ -25,68 +25,57 @@ #include "stdafx.h" -struct AskAuthParam +class AskAuthProcDlg : public CProtoDlgBase { - CIcqProto* ppro; - MCONTACT hContact; -}; - -static INT_PTR CALLBACK AskAuthProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - AskAuthParam* dat = (AskAuthParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + MCONTACT m_hContact; - switch (msg) { - case WM_INITDIALOG: - dat = (AskAuthParam*)lParam; - if (!dat->hContact || !dat->ppro->icqOnline()) - EndDialog(hwndDlg, 0); + CCtrlEdit m_auth; + CCtrlButton m_btnOk; - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - SendDlgItemMessage(hwndDlg, IDC_EDITAUTH, EM_LIMITTEXT, (WPARAM)255, 0); - SetDlgItemText(hwndDlg, IDC_EDITAUTH, TranslateT("Please authorize me to add you to my contact list.")); - return TRUE; +public: + AskAuthProcDlg(CIcqProto *_ppro, MCONTACT _hContact) : + CProtoDlgBase(_ppro, IDD_ASKAUTH, false), + m_hContact(_hContact), + m_auth(this, IDC_EDITAUTH), + m_btnOk(this, IDOK) + { + m_autoClose = CLOSE_ON_CANCEL; // let onOk() to close window manually + m_btnOk.OnClick = Callback(this, &AskAuthProcDlg::onOk); + } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - if (dat->ppro->icqOnline()) - { - DWORD dwUin; - uid_str szUid; - if ( dat->ppro->getContactUid(dat->hContact, &dwUin, &szUid)) - return TRUE; // Invalid contact + virtual void OnInitDialog() + { + if (!m_hContact || !m_proto->icqOnline()) + EndDialog(m_hwnd, 0); - char* szReason = GetDlgItemTextUtf(hwndDlg, IDC_EDITAUTH); - dat->ppro->icq_sendAuthReqServ(dwUin, szUid, szReason); - SAFE_FREE((void**)&szReason); + m_auth.SendMsg(EM_LIMITTEXT, 255, 0); + m_auth.SetText(TranslateT("Please authorize me to add you to my contact list.")); + } - // auth bug fix (thx Bio) - if (dat->ppro->m_bSsiEnabled && dwUin) - dat->ppro->resetServContactAuthState(dat->hContact); + void onOk(CCtrlButton*) + { + if (!m_proto->icqOnline()) + return; - EndDialog(hwndDlg, 0); - } - return TRUE; + DWORD dwUin; + uid_str szUid; + if (m_proto->getContactUid(m_hContact, &dwUin, &szUid)) + return; // Invalid contact - case IDCANCEL: - EndDialog(hwndDlg, 0); - return TRUE; - } + char *szReason = GetWindowTextUtf(m_auth.GetHwnd()); + m_proto->icq_sendAuthReqServ(dwUin, szUid, szReason); + SAFE_FREE((void**)&szReason); - break; + // auth bug fix (thx Bio) + if (m_proto->m_bSsiEnabled && dwUin) + m_proto->resetServContactAuthState(m_hContact); - case WM_CLOSE: - EndDialog(hwndDlg,0); - return TRUE; + EndDialog(m_hwnd, 0); } - - return FALSE; -} +}; INT_PTR CIcqProto::RequestAuthorization(WPARAM wParam, LPARAM) { - AskAuthParam param = { this, wParam }; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ASKAUTH), NULL, AskAuthProc, (LPARAM)¶m); + AskAuthProcDlg(this, wParam).DoModal(); return 0; } diff --git a/protocols/IcqOscarJ/src/stdafx.h b/protocols/IcqOscarJ/src/stdafx.h index d06acbb89a..431c4dcf10 100644 --- a/protocols/IcqOscarJ/src/stdafx.h +++ b/protocols/IcqOscarJ/src/stdafx.h @@ -81,6 +81,7 @@ #include #include #include +#include // Project resources #include "resource.h" -- cgit v1.2.3