summaryrefslogtreecommitdiff
path: root/plugins/Dropbox
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-02-26 11:29:17 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-02-26 11:29:17 +0000
commit987ceba57a977c691977a0f5aa8005678fcbc7e7 (patch)
tree1e52b2b0aafc60d0365034f28394cfb2dee0e587 /plugins/Dropbox
parenta16909cbcbf6d18ab622ac5bbb05a8d743a93db3 (diff)
Dropbox:
- added ability to intercept transfers from other protocols - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@16344 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox')
-rw-r--r--plugins/Dropbox/res/resource.rc49
-rw-r--r--plugins/Dropbox/src/dropbox.cpp18
-rw-r--r--plugins/Dropbox/src/dropbox.h2
-rw-r--r--plugins/Dropbox/src/dropbox_options.cpp85
-rw-r--r--plugins/Dropbox/src/dropbox_options.h21
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp12
-rw-r--r--plugins/Dropbox/src/resource.h7
-rw-r--r--plugins/Dropbox/src/version.h2
8 files changed, 167 insertions, 29 deletions
diff --git a/plugins/Dropbox/res/resource.rc b/plugins/Dropbox/res/resource.rc
index 616ebafb3c..caa067d7b2 100644
--- a/plugins/Dropbox/res/resource.rc
+++ b/plugins/Dropbox/res/resource.rc
@@ -60,33 +60,42 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
// Dialog
//
-IDD_OPTIONS_MAIN DIALOGEX 0, 0, 323, 256
+IDD_OPTIONS_MAIN DIALOGEX 0, 0, 307, 234
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Authorization",IDC_STATIC,5,5,313,103
+ GROUPBOX "Authorization",IDC_STATIC,5,5,297,103
LTEXT "To allow Miranda NG access in your Dropbox account:",IDC_STATIC,15,18,270,10
- CONTROL "Go to this link",IDC_GETAUTH,"Hyperlink",WS_GROUP | WS_TABSTOP | 0x1,144,35,169,8
+ CONTROL "Go to this link",IDC_GETAUTH,"Hyperlink",WS_GROUP | WS_TABSTOP | 0x1,144,35,153,8
LTEXT "1.",IDC_STATIC,21,35,8,8
LTEXT "Allow access to app folder",IDC_STATIC,29,35,109,16
LTEXT "2.",IDC_STATIC,21,53,8,8
LTEXT "Enter authorization code",IDC_STATIC,29,53,109,16
- EDITTEXT IDC_REQUEST_CODE,144,51,169,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_REQUEST_CODE,144,51,153,13,ES_AUTOHSCROLL
LTEXT "3.",IDC_STATIC,21,71,8,8
LTEXT "Initiate authorization",IDC_STATIC,29,71,109,16
- PUSHBUTTON "Authorize",IDC_AUTHORIZE,144,68,169,14,BS_CENTER | WS_DISABLED
- GROUPBOX "Download link",IDC_STATIC,5,111,313,70
- CONTROL "Use shortened download links",IDC_URL_USE_SHORT,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,125,298,10
+ PUSHBUTTON "Authorize",IDC_AUTHORIZE,144,68,153,14,BS_CENTER | WS_DISABLED
+ GROUPBOX "Download link",IDC_STATIC,5,111,297,70
+ CONTROL "Use shortened download links",IDC_URL_USE_SHORT,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,125,282,10
LTEXT "4.",IDC_STATIC,22,89,8,8
- LTEXT "Check status of authorization",IDC_STATIC,30,89,109,17
- CTEXT "",IDC_AUTH_STATUS,145,89,169,8
+ LTEXT "Check status of authorization",IDC_STATIC,30,89,108,17
+ CTEXT "",IDC_AUTH_STATUS,144,89,153,8
CONTROL "Autosend download link to contact",IDC_URL_AUTOSEND,
- "Button",BS_AUTORADIOBUTTON,15,138,298,10
+ "Button",BS_AUTORADIOBUTTON,15,138,282,10
CONTROL "Paste download link into message input area",IDC_URL_COPYTOMIA,
- "Button",BS_AUTORADIOBUTTON,15,151,298,10
+ "Button",BS_AUTORADIOBUTTON,15,151,282,10
CONTROL "Copy download link to clipboard",IDC_URL_COPYTOCB,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,164,298,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,164,282,10
+END
+
+IDD_OPTIONS_INTERCEPTION DIALOGEX 0, 0, 308, 234
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_ACCOUNTS,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,5,34,298,195
+ LTEXT "Here you can choose the protocols in which dropbox will be used instead of regular file transfers (sending), used by this protocol.",IDC_STATIC,5,5,298,24
END
@@ -101,7 +110,7 @@ BEGIN
IDD_OPTIONS_MAIN, DIALOG
BEGIN
LEFTMARGIN, 5
- RIGHTMARGIN, 318
+ RIGHTMARGIN, 302
VERTGUIDE, 15
VERTGUIDE, 21
VERTGUIDE, 29
@@ -109,9 +118,19 @@ BEGIN
VERTGUIDE, 96
VERTGUIDE, 138
VERTGUIDE, 144
- VERTGUIDE, 313
+ VERTGUIDE, 297
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 229
+ END
+
+ IDD_OPTIONS_INTERCEPTION, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 303
TOPMARGIN, 5
- BOTTOMMARGIN, 251
+ BOTTOMMARGIN, 229
+ HORZGUIDE, 29
+ HORZGUIDE, 34
END
END
#endif // APSTUDIO_INVOKED
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp
index 46d8d5fa8c..d9a47c1e04 100644
--- a/plugins/Dropbox/src/dropbox.cpp
+++ b/plugins/Dropbox/src/dropbox.cpp
@@ -2,12 +2,6 @@
CDropbox::CDropbox() : transfers(1, HandleKeySortT)
{
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = MODULE;
- pd.type = PROTOTYPE_VIRTUAL;
- Proto_RegisterModule(&pd);
-
HookEvent(ME_PROTO_ACK, OnProtoAck);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
HookEventObj(ME_SYSTEM_MODULESLOADED, GlobalEvent<&CDropbox::OnModulesLoaded>, this);
@@ -16,6 +10,12 @@ CDropbox::CDropbox() : transfers(1, HandleKeySortT)
CreateServiceFunctionObj(MS_DROPBOX_SEND_FILE, GlobalService<&CDropbox::SendFileToDropbox>, this);
+ PROTOCOLDESCRIPTOR pd = { 0 };
+ pd.cbSize = sizeof(pd);
+ pd.szName = MODULE;
+ pd.type = PROTOTYPE_VIRTUAL;
+ Proto_RegisterModule(&pd);
+
CreateProtoServiceFunction(MODULE, PS_GETCAPS, ProtoGetCaps);
CreateProtoServiceFunction(MODULE, PS_GETNAME, ProtoGetName);
CreateProtoServiceFunction(MODULE, PS_LOADICON, ProtoLoadIcon);
@@ -25,6 +25,12 @@ CDropbox::CDropbox() : transfers(1, HandleKeySortT)
CreateProtoServiceFunctionObj(PSS_MESSAGE, GlobalService<&CDropbox::ProtoSendMessage>, this);
CreateProtoServiceFunction(MODULE, PSR_MESSAGE, ProtoReceiveMessage);
+ pd.szName = MODULE"Inteceptor";
+ pd.type = PROTOTYPE_FILTER;
+ Proto_RegisterModule(&pd);
+
+ CreateServiceFunctionObj(MODULE"Inteceptor"PSS_FILE, GlobalService<&CDropbox::ProtoSendFileInterceptor>, this);
+
InitializeMenus();
hFileProcess = hMessageProcess = 1;
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h
index 5ad332b168..dba4681042 100644
--- a/plugins/Dropbox/src/dropbox.h
+++ b/plugins/Dropbox/src/dropbox.h
@@ -64,6 +64,8 @@ private:
INT_PTR ProtoSendMessage(WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoReceiveMessage(WPARAM wParam, LPARAM lParam);
+ INT_PTR ProtoSendFileInterceptor(WPARAM wParam, LPARAM lParam);
+
INT_PTR SendFileToDropbox(WPARAM wParam, LPARAM lParam);
// commands
diff --git a/plugins/Dropbox/src/dropbox_options.cpp b/plugins/Dropbox/src/dropbox_options.cpp
index 2ae67aecb6..047e59b006 100644
--- a/plugins/Dropbox/src/dropbox_options.cpp
+++ b/plugins/Dropbox/src/dropbox_options.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
-CDropboxOptionsMain::CDropboxOptionsMain(CDropbox *instance, int idDialog)
- : CDropboxDlgBase(instance, idDialog),
+CDropboxOptionsMain::CDropboxOptionsMain(CDropbox *instance)
+ : CDropboxDlgBase(instance, IDD_OPTIONS_MAIN),
m_auth(this, IDC_GETAUTH, DROPBOX_WWW_URL "/oauth2/authorize?response_type=code&client_id=" DROPBOX_APP_KEY),
m_requestCode(this, IDC_REQUEST_CODE), m_authorize(this, IDC_AUTHORIZE), m_authStatus(this, IDC_AUTH_STATUS),
m_useShortUrl(this, IDC_USE_SHORT_LINKS), m_urlAutoSend(this, IDC_URL_AUTOSEND),
@@ -51,6 +51,81 @@ void CDropboxOptionsMain::Authorize_OnClick(CCtrlBase*)
/////////////////////////////////////////////////////////////////////////////////
+CDropboxOptionsInterception::CDropboxOptionsInterception(CDropbox *instance)
+ : CDropboxDlgBase(instance, IDD_OPTIONS_INTERCEPTION),
+ m_accounts(this, IDC_ACCOUNTS), isAccountListInit(false)
+{
+}
+
+void CDropboxOptionsInterception::OnInitDialog()
+{
+ CDropboxDlgBase::OnInitDialog();
+
+ m_accounts.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP);
+
+ m_accounts.AddColumn(0, _T("Account name"), 50);
+ m_accounts.AddColumn(1, _T("Protocol"), 50);
+
+ int count;
+ PROTOACCOUNT** accounts;
+ Proto_EnumAccounts(&count, &accounts);
+ const char* interceptedProtos = db_get_sa(NULL, MODULE, "InterceptedProtos");
+ for (int i = 0; i < count; i++) {
+ PROTOACCOUNT *acc = accounts[i];
+ if (strstr(acc->szProtoName, MODULE) || strstr(acc->szProtoName, "Meta"))
+ continue;
+ int iItem = m_accounts.AddItem(mir_tstrdup(acc->tszAccountName), -1, (LPARAM)acc);
+ m_accounts.SetItem(iItem, 1, mir_a2t(acc->szProtoName));
+ if (interceptedProtos && strstr(interceptedProtos, acc->szModuleName))
+ m_accounts.SetCheckState(iItem, TRUE);
+ }
+
+ m_accounts.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
+ m_accounts.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
+
+ isAccountListInit = true;
+}
+
+INT_PTR CDropboxOptionsInterception::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnmHdr = (LPNMHDR)lParam;
+ if (lpnmHdr->idFrom == (UINT_PTR)m_accounts.GetCtrlId() && lpnmHdr->code == LVN_ITEMCHANGED)
+ {
+ LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
+ if (pnmv->uChanged & LVIF_STATE && pnmv->uNewState & LVIS_STATEIMAGEMASK)
+ {
+ if (isAccountListInit)
+ NotifyChange();
+ }
+ }
+ }
+ break;
+ }
+
+ return CDlgBase::DlgProc(msg, wParam, lParam);
+}
+
+void CDropboxOptionsInterception::OnApply()
+{
+ CMStringA interceptedProtos;
+ int count = m_accounts.GetItemCount();
+ for (int iItem = 0; iItem < count; iItem++)
+ {
+ TCHAR proto[MAX_PATH];
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)m_accounts.GetItemData(iItem);
+ if (m_accounts.GetCheckState(iItem))
+ interceptedProtos.AppendFormat("%s\t", acc->szModuleName);
+ interceptedProtos.TrimRight();
+ }
+ db_set_s(NULL, MODULE, "InterceptedProtos", interceptedProtos);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+
int CDropbox::OnOptionsInitialized(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
@@ -58,9 +133,13 @@ int CDropbox::OnOptionsInitialized(WPARAM wParam, LPARAM)
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
odp.ptszGroup = LPGENT("Network");
- odp.ptszTab = _T("Dropbox");
+ odp.ptszTab = _T("General");
odp.pDialog = CDropboxOptionsMain::CreateOptionsPage(this);
Options_AddPage(wParam, &odp);
+ odp.ptszTab = _T("Interception");
+ odp.pDialog = CDropboxOptionsInterception::CreateOptionsPage(this);
+ Options_AddPage(wParam, &odp);
+
return 0;
}
diff --git a/plugins/Dropbox/src/dropbox_options.h b/plugins/Dropbox/src/dropbox_options.h
index d216a5b546..7c68ece9d5 100644
--- a/plugins/Dropbox/src/dropbox_options.h
+++ b/plugins/Dropbox/src/dropbox_options.h
@@ -22,9 +22,26 @@ protected:
void Authorize_OnClick(CCtrlBase*);
public:
- CDropboxOptionsMain(CDropbox *instance, int idDialog);
+ CDropboxOptionsMain(CDropbox *instance);
- static CDlgBase *CreateOptionsPage(void *param) { return new CDropboxOptionsMain((CDropbox*)param, IDD_OPTIONS_MAIN); }
+ static CDlgBase *CreateOptionsPage(void *param) { return new CDropboxOptionsMain((CDropbox*)param); }
+};
+
+class CDropboxOptionsInterception : public CDropboxDlgBase
+{
+private:
+ bool isAccountListInit;
+ CCtrlListView m_accounts;
+
+protected:
+ void OnInitDialog();
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+ void OnApply();
+
+public:
+ CDropboxOptionsInterception(CDropbox *instance);
+
+ static CDlgBase *CreateOptionsPage(void *param) { return new CDropboxOptionsInterception((CDropbox*)param); }
};
#endif //_DROPBOX_OPTIONS_H_ \ No newline at end of file
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index d679059c43..92f7a5abae 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -74,6 +74,18 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
return fileId;
}
+INT_PTR CDropbox::ProtoSendFileInterceptor(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+
+ const char *proto = GetContactProto(pccsd->hContact);
+ const char *interceptedProtos = db_get_sa(NULL, MODULE, "InterceptedProtos");
+ if (interceptedProtos == NULL || strstr(interceptedProtos, proto) == NULL)
+ return CALLSERVICE_NOTFOUND;
+
+ return ProtoSendFile(wParam, lParam);
+}
+
INT_PTR CDropbox::ProtoCancelFile(WPARAM, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA*)lParam;
diff --git a/plugins/Dropbox/src/resource.h b/plugins/Dropbox/src/resource.h
index 314d82c2b3..a01728b502 100644
--- a/plugins/Dropbox/src/resource.h
+++ b/plugins/Dropbox/src/resource.h
@@ -1,10 +1,11 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by e:\Projects\C++\MirandaNG\plugins\Dropbox\res\resource.rc
+// Used by d:\Projects\MirandaNG\plugins\Dropbox\res\resource.rc
//
#define IDI_DROPBOX 102
#define IDI_UPLOAD 103
#define IDD_OPTIONS_MAIN 109
+#define IDD_OPTIONS_INTERCEPTION 110
#define IDC_REQUEST_CODE 1001
#define IDC_AUTHORIZE 1002
#define IDC_CHECK2 1004
@@ -14,6 +15,8 @@
#define IDC_GET_AUTH_LINK 1006
#define IDC_URL_COPYTOCB 1009
#define IDC_CHECK1 1010
+#define IDC_PROTOCOLS 1011
+#define IDC_ACCOUNTS 1011
#define IDC_URL_COPYTOML 1029
#define IDC_URL_COPYTOMIA 1029
#define IDC_URL_AUTOSEND 1030
@@ -25,7 +28,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1011
+#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h
index d629b60900..a54c801dad 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 1
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>