From 3e9e349a53492e5377154b8518803058d72e37ed Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 13 May 2015 19:32:08 +0000 Subject: Dropbox: moved to core ui git-svn-id: http://svn.miranda-ng.org/main/trunk@13574 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_options.cpp | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plugins/Dropbox/src/dropbox_options.cpp (limited to 'plugins/Dropbox/src/dropbox_options.cpp') diff --git a/plugins/Dropbox/src/dropbox_options.cpp b/plugins/Dropbox/src/dropbox_options.cpp new file mode 100644 index 0000000000..5dacc24535 --- /dev/null +++ b/plugins/Dropbox/src/dropbox_options.cpp @@ -0,0 +1,66 @@ +#include "stdafx.h" + +CDropboxOptionsMain::CDropboxOptionsMain(CDropbox *instance, int idDialog) + : CDropboxDlgBase(instance, idDialog), + m_auth(NULL, IDC_GETAUTH, DROPBOX_WWW_URL DROPBOX_API_VER "/oauth2/authorize?response_type=code&client_id=" DROPBOX_APP_KEY), + m_requestCode(NULL, IDC_REQUEST_CODE), m_authorize(NULL, IDC_AUTHORIZE), m_authStatus(NULL, IDC_AUTH_STATUS), + m_useShortUrl(this, IDC_USE_SHORT_LINKS), m_urlAutoSend(this, IDC_URL_AUTOSEND), + m_urlPasteToMessageInputArea(this, IDC_URL_COPYTOMIA), m_urlCopyToClipboard(this, IDC_URL_COPYTOCB) +{ + CreateLink(m_useShortUrl, "UseSortLinks", DBVT_BYTE, 1); + CreateLink(m_urlAutoSend, "UrlAutoSend", DBVT_BYTE, 1); + CreateLink(m_urlPasteToMessageInputArea, "UrlPasteToMessageInputArea", DBVT_BYTE, 0); + CreateLink(m_urlCopyToClipboard, "UrlCopyToClipboard", DBVT_BYTE, 0); + + //m_auth.OnClick = Callback(this, &CDropboxOptionsMain::Auth_OnClick); + m_requestCode.OnChange = Callback(this, &CDropboxOptionsMain::RequestCode_OnChange); + m_authorize.OnClick = Callback(this, &CDropboxOptionsMain::Authorize_OnClick); +} + +void CDropboxOptionsMain::OnInitDialog() +{ + CDropboxDlgBase::OnInitDialog(); + + LOGFONT lf; + HFONT hFont = (HFONT)m_authStatus.SendMsg(WM_GETFONT, 0, 0); + GetObject(hFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + m_authStatus.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0); + + if (m_instance->HasAccessToken()) + m_authStatus.SetText(TranslateT("you are already authorized")); + else + m_authStatus.SetText(TranslateT("you are not authorized yet")); +} + +void CDropboxOptionsMain::Auth_OnClick(CCtrlBase*) +{ + SetFocus(m_requestCode.GetHwnd()); +} + +void CDropboxOptionsMain::RequestCode_OnChange(CCtrlBase*) +{ + ptrA requestToken(m_requestCode.GetTextA()); + EnableWindow(m_authorize.GetHwnd(), mir_strlen(requestToken) != 0); +} + +void CDropboxOptionsMain::Authorize_OnClick(CCtrlBase*) +{ + mir_forkthreadowner(CDropbox::RequestAccessTokenAsync, m_instance, m_hwnd, 0); +} + +///////////////////////////////////////////////////////////////////////////////// + +int CDropbox::OnOptionsInitialized(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.ptszTitle = _T(MODULE); + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; + odp.ptszGroup = LPGENT("Network"); + + odp.ptszTab = LPGENT("Dropbox"); + odp.pDialog = CDropboxOptionsMain::CreateOptionsPage(this); + Options_AddPage(wParam, &odp); + + return 0; +} -- cgit v1.2.3