diff options
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;
}
|