summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-13 19:32:08 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-13 19:32:08 +0000
commit3e9e349a53492e5377154b8518803058d72e37ed (patch)
tree4bc613530728ee890c0e521654c004efd581d799 /plugins/Dropbox/src
parentd333cb91eb0fb51faf34772258a5084e95f047d8 (diff)
Dropbox: moved to core ui
git-svn-id: http://svn.miranda-ng.org/main/trunk@13574 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src')
-rw-r--r--plugins/Dropbox/src/api/account.h3
-rw-r--r--plugins/Dropbox/src/dropbox.h18
-rw-r--r--plugins/Dropbox/src/dropbox_dialogs.cpp17
-rw-r--r--plugins/Dropbox/src/dropbox_dialogs.h24
-rw-r--r--plugins/Dropbox/src/dropbox_events.cpp17
-rw-r--r--plugins/Dropbox/src/dropbox_options.cpp66
-rw-r--r--plugins/Dropbox/src/dropbox_options.h30
-rw-r--r--plugins/Dropbox/src/stdafx.h33
-rw-r--r--plugins/Dropbox/src/version.h2
9 files changed, 168 insertions, 42 deletions
diff --git a/plugins/Dropbox/src/api/account.h b/plugins/Dropbox/src/api/account.h
index 4db79622d2..9c8bf20e7e 100644
--- a/plugins/Dropbox/src/api/account.h
+++ b/plugins/Dropbox/src/api/account.h
@@ -11,8 +11,7 @@ public:
AddHeader("Content-Type", "application/x-www-form-urlencoded");
CMStringA data(CMStringDataFormat::FORMAT, "grant_type=authorization_code&code=%s", requestToken);
- pData = data.GetBuffer();
- dataLength = data.GetLength();
+ SetData(data.GetBuffer(), data.GetLength());
}
};
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h
index 1036ff5e04..e8340d5fcd 100644
--- a/plugins/Dropbox/src/dropbox.h
+++ b/plugins/Dropbox/src/dropbox.h
@@ -1,22 +1,6 @@
#ifndef _DROPBOX_PROTO_H_
#define _DROPBOX_PROTO_H_
-#include "http_request.h"
-#include "file_transfer.h"
-
-#define DROPBOX_API_VER "1"
-#define DROPBOX_API_ROOT "sandbox"
-#define DROPBOX_WWW_URL "https://www.dropbox.com/"
-#define DROPBOX_API_URL "https://api.dropbox.com/" DROPBOX_API_VER
-#define DROPBOX_APICONTENT_URL "https://api-content.dropbox.com/" DROPBOX_API_VER
-
-#define DROPBOX_APP_KEY "fa8du7gkf2q8xzg"
-#include "..\..\..\miranda-private-keys\Dropbox\secret_key.h"
-
-#define DROPBOX_FILE_CHUNK_SIZE 4 * 1024 * 1024 //4 MB
-
-#define BBB_ID_FILE_SEND 10001
-
enum
{
CMI_SEND_FILES,
@@ -25,6 +9,8 @@ enum
class CDropbox : public MZeroedObject
{
+ friend CDropboxOptionsMain;
+
struct CommandParam
{
CDropbox *instance;
diff --git a/plugins/Dropbox/src/dropbox_dialogs.cpp b/plugins/Dropbox/src/dropbox_dialogs.cpp
index 1bbc71326e..0634fab398 100644
--- a/plugins/Dropbox/src/dropbox_dialogs.cpp
+++ b/plugins/Dropbox/src/dropbox_dialogs.cpp
@@ -1,5 +1,22 @@
#include "stdafx.h"
+CDropboxDlgBase::CDropboxDlgBase(CDropbox *instance, int idDialog)
+ : CDlgBase(g_hInstance, idDialog), m_instance(instance)
+{
+}
+
+void CDropboxDlgBase::CreateLink(CCtrlData& ctrl, const char *szSetting, BYTE type, DWORD iValue)
+{
+ ctrl.CreateDbLink(MODULE, szSetting, type, iValue);
+}
+
+void CDropboxDlgBase::CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szValue)
+{
+ ctrl.CreateDbLink(MODULE, szSetting, szValue);
+}
+
+/////////////////////////////////////////////////////////////
+
INT_PTR CALLBACK CDropbox::MainOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
CDropbox *instance = (CDropbox*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
diff --git a/plugins/Dropbox/src/dropbox_dialogs.h b/plugins/Dropbox/src/dropbox_dialogs.h
new file mode 100644
index 0000000000..c39e3e342a
--- /dev/null
+++ b/plugins/Dropbox/src/dropbox_dialogs.h
@@ -0,0 +1,24 @@
+#ifndef _DROPBOX_DIALOGS_H_
+#define _DROPBOX_DIALOGS_H_
+
+class CDropboxDlgBase : public CDlgBase
+{
+protected:
+ CDropbox *m_instance;
+
+public:
+ CDropboxDlgBase(CDropbox *instance, int idDialog);
+
+ void CreateLink(CCtrlData& ctrl, const char *szSetting, BYTE type, DWORD iValue);
+ void CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szValue);
+
+ template<class T>
+ __inline void CreateLink(CCtrlData& ctrl, CMOption<T> &option)
+ {
+ ctrl.CreateDbLink(new CMOptionLink<T>(option));
+ }
+
+ __inline CDropbox *GetInstance() { return m_instance; }
+};
+
+#endif //_DROPBOX_DIALOGS_H_ \ No newline at end of file
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp
index fa0e3d91a8..8673eb85b1 100644
--- a/plugins/Dropbox/src/dropbox_events.cpp
+++ b/plugins/Dropbox/src/dropbox_events.cpp
@@ -61,23 +61,6 @@ int CDropbox::OnContactDeleted(WPARAM hContact, LPARAM)
return 0;
}
-int CDropbox::OnOptionsInitialized(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = 100000000;
- odp.hInstance = g_hInstance;
- odp.flags = ODPF_BOLDGROUPS;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN);
- odp.pszGroup = LPGEN("Network");
- odp.pszTitle = "Dropbox";
- odp.pfnDlgProc = MainOptionsProc;
- odp.dwInitParam = (LPARAM)this;
-
- Options_AddPage(wParam, &odp);
-
- return 0;
-}
-
int CDropbox::OnSrmmWindowOpened(WPARAM, LPARAM lParam)
{
MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
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;
+}
diff --git a/plugins/Dropbox/src/dropbox_options.h b/plugins/Dropbox/src/dropbox_options.h
new file mode 100644
index 0000000000..d216a5b546
--- /dev/null
+++ b/plugins/Dropbox/src/dropbox_options.h
@@ -0,0 +1,30 @@
+#ifndef _DROPBOX_OPTIONS_H_
+#define _DROPBOX_OPTIONS_H_
+
+class CDropboxOptionsMain : public CDropboxDlgBase
+{
+private:
+ CCtrlHyperlink m_auth;
+ CCtrlEdit m_requestCode;
+ CCtrlButton m_authorize;
+ CCtrlBase m_authStatus;
+
+ CCtrlCheck m_useShortUrl;
+ CCtrlCheck m_urlAutoSend;
+ CCtrlCheck m_urlPasteToMessageInputArea;
+ CCtrlCheck m_urlCopyToClipboard;
+
+protected:
+ void OnInitDialog();
+
+ void Auth_OnClick(CCtrlBase*);
+ void RequestCode_OnChange(CCtrlBase*);
+ void Authorize_OnClick(CCtrlBase*);
+
+public:
+ CDropboxOptionsMain(CDropbox *instance, int idDialog);
+
+ static CDlgBase *CreateOptionsPage(void *param) { return new CDropboxOptionsMain((CDropbox*)param, IDD_OPTIONS_MAIN); }
+};
+
+#endif //_DROPBOX_OPTIONS_H_ \ No newline at end of file
diff --git a/plugins/Dropbox/src/stdafx.h b/plugins/Dropbox/src/stdafx.h
index c2eca7328b..c541f3ad4a 100644
--- a/plugins/Dropbox/src/stdafx.h
+++ b/plugins/Dropbox/src/stdafx.h
@@ -3,6 +3,7 @@
#include <windows.h>
#include <shlwapi.h>
+#include <commctrl.h>
#include <malloc.h>
#include <time.h>
@@ -11,6 +12,7 @@
#include <m_options.h>
#include <m_database.h>
+#include <m_netlib.h>
#include <m_clist.h>
#include <m_skin.h>
#include <m_icolib.h>
@@ -21,26 +23,45 @@
#include <m_message.h>
#include <m_string.h>
#include <m_msg_buttonsbar.h>
+#include <m_gui.h>
#include <m_protoint.h>
#include <m_protomod.h>
#include <m_protosvc.h>
-#include <m_netlib.h>
-
#include <m_dropbox.h>
-#include "dropbox.h"
-#include "api\account.h"
-#include "api\upload.h"
-#include "api\operations.h"
#include "version.h"
#include "resource.h"
+class CDropbox;
+
+#define DROPBOX_API_VER "1"
+#define DROPBOX_API_ROOT "sandbox"
+#define DROPBOX_WWW_URL "https://www.dropbox.com/"
+#define DROPBOX_API_URL "https://api.dropbox.com/" DROPBOX_API_VER
+#define DROPBOX_APICONTENT_URL "https://api-content.dropbox.com/" DROPBOX_API_VER
+
+#define DROPBOX_APP_KEY "fa8du7gkf2q8xzg"
+#include "..\..\..\miranda-private-keys\Dropbox\secret_key.h"
+
+#include "dropbox_dialogs.h"
+#include "dropbox_options.h"
+#include "http_request.h"
+#include "api\account.h"
+#include "api\upload.h"
+#include "api\operations.h"
+#include "file_transfer.h"
+#include "dropbox.h"
+
#define MODULE "Dropbox"
extern HINSTANCE g_hInstance;
+#define DROPBOX_FILE_CHUNK_SIZE 4 * 1024 * 1024 //4 MB
+
+#define BBB_ID_FILE_SEND 10001
+
// icons
void InitializeIcons();
HANDLE GetIconHandle(int iconId);
diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h
index f1cd12cd17..a8bcc19833 100644
--- a/plugins/Dropbox/src/version.h
+++ b/plugins/Dropbox/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 12
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>