diff options
author | aunsane <aunsane@gmail.com> | 2018-02-19 00:00:03 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-02-19 00:00:20 +0300 |
commit | 46e398c0d295f3d33fe4c0450c36e1fc45a95616 (patch) | |
tree | 727617421cce4e6cc7f0863b4c4fcf367e135a10 /plugins/CloudFile/src/oauth.cpp | |
parent | 66c4ae72a70a6e155c4a2a6d14c91c532cdb3974 (diff) |
CloudFile: added support for the usual accounts system(#1144)
Diffstat (limited to 'plugins/CloudFile/src/oauth.cpp')
-rw-r--r-- | plugins/CloudFile/src/oauth.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/plugins/CloudFile/src/oauth.cpp b/plugins/CloudFile/src/oauth.cpp index 7815c27771..1f837f021d 100644 --- a/plugins/CloudFile/src/oauth.cpp +++ b/plugins/CloudFile/src/oauth.cpp @@ -1,16 +1,52 @@ #include "stdafx.h" COAuthDlg::COAuthDlg(CCloudService *service, const char *authUrl, pThreadFuncOwner requestAccessTokenThread) - : CDlgBase(hInstance, IDD_OAUTH), m_service(service), + : CDlgBase(hInstance, IDD_OAUTH), + m_service(service), m_authUrl(authUrl), m_requestAccessTokenThread(requestAccessTokenThread), - m_auth(this, IDC_OAUTH_AUTHORIZE, authUrl), + m_authorize(this, IDC_OAUTH_AUTHORIZE), m_code(this, IDC_OAUTH_CODE), m_ok(this, IDOK) { m_autoClose = CLOSE_ON_CANCEL; + m_authorize.OnClick = Callback(this, &COAuthDlg::Auth_OnClick); m_code.OnChange = Callback(this, &COAuthDlg::Code_OnChange); m_ok.OnClick = Callback(this, &COAuthDlg::Ok_OnClick); } +void COAuthDlg::OnInitDialog() +{ + /*CCtrlBase *ctrl = 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);*/ +} + +void COAuthDlg::Auth_OnClick(CCtrlButton*) +{ + if (SUCCEEDED(OleInitialize(NULL))) { + CComPtr<IWebBrowser2> browser; + if (SUCCEEDED(CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)&browser))) { + VARIANT empty; + VariantInit(&empty); + BSTR url = SysAllocString(_A2T(m_authUrl)); + if (SUCCEEDED(browser->Navigate(url, &empty, &empty, &empty, &empty))) { + browser->put_AddressBar(VARIANT_FALSE); + browser->put_MenuBar(VARIANT_FALSE); + browser->put_ToolBar(VARIANT_FALSE); + browser->put_StatusBar(VARIANT_FALSE); + //browser->put_Resizable(VARIANT_FALSE); + browser->put_Visible(VARIANT_TRUE); + } + else + browser->Quit(); + SysFreeString(url); + browser.Release(); + } + OleUninitialize(); + } +} + void COAuthDlg::Code_OnChange(CCtrlBase*) { ptrA requestToken(m_code.GetTextA()); |