diff options
Diffstat (limited to 'protocols/CloudFile/src/oauth.cpp')
-rw-r--r-- | protocols/CloudFile/src/oauth.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/protocols/CloudFile/src/oauth.cpp b/protocols/CloudFile/src/oauth.cpp new file mode 100644 index 0000000000..e62629fcd8 --- /dev/null +++ b/protocols/CloudFile/src/oauth.cpp @@ -0,0 +1,33 @@ +#include "stdafx.h" + +COAuthDlg::COAuthDlg(CCloudService *service, const char *authUrl, CCloudService::MyThreadFunc requestAccessTokenThread) + : CDlgBase(g_plugin, IDD_OAUTH), m_service(service), + m_requestAccessTokenThread(requestAccessTokenThread), + m_authorize(this, IDC_OAUTH_AUTHORIZE, authUrl), + m_code(this, IDC_OAUTH_CODE), m_ok(this, IDOK) +{ + m_autoClose = CLOSE_ON_CANCEL; + m_code.OnChange = Callback(this, &COAuthDlg::Code_OnChange); + m_ok.OnClick = Callback(this, &COAuthDlg::Ok_OnClick); +} + +bool COAuthDlg::OnInitDialog() +{ + CCtrlLabel &ctrl = *(CCtrlLabel*)FindControl(IDC_AUTH_TEXT); + ptrW format(ctrl.GetText()); + wchar_t text[MAX_PATH]; + mir_snwprintf(text, (const wchar_t*)format, m_service->GetUserName()); + ctrl.SetText(text); + return true; +} + +void COAuthDlg::Code_OnChange(CCtrlBase*) +{ + ptrA requestToken(m_code.GetTextA()); + m_ok.Enable(mir_strlen(requestToken) != 0); +} + +void COAuthDlg::Ok_OnClick(CCtrlButton*) +{ + m_service->ForkThread(m_requestAccessTokenThread, m_hwnd); +}
\ No newline at end of file |