diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-05 19:27:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-05 19:27:43 +0000 |
commit | 095b02026b6135626973778bb31e9bd2359ae2bc (patch) | |
tree | 4a8dd137afcec43f6673d2fd95a63bc4479e479c /protocols/IcqOscarJ/src/askauthentication.cpp | |
parent | 605fdc596a6725864255c9410731f218a16811e2 (diff) |
icq ask auth window -> UI Utils
git-svn-id: http://svn.miranda-ng.org/main/trunk@14018 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ/src/askauthentication.cpp')
-rw-r--r-- | protocols/IcqOscarJ/src/askauthentication.cpp | 87 |
1 files changed, 38 insertions, 49 deletions
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>
{
- 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<CIcqProto>(_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;
}
|