summaryrefslogtreecommitdiff
path: root/plugins/Dropbox
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-12 20:24:43 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-12 20:24:43 +0000
commitb3742e87f4003a80c13ece74264397b6c137096b (patch)
tree486df2f52bb840eb8524055e5fb12c2e5ee1ab24 /plugins/Dropbox
parentee0a6f7683054bdb680bb9efffb16c68d87bec5a (diff)
Dropbox: attempt to terminate upload on cancel
git-svn-id: http://svn.miranda-ng.org/main/trunk@13563 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox')
-rw-r--r--plugins/Dropbox/src/dropbox.cpp5
-rw-r--r--plugins/Dropbox/src/dropbox.h5
-rw-r--r--plugins/Dropbox/src/dropbox_dialogs.cpp2
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp79
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp155
-rw-r--r--plugins/Dropbox/src/file_transfer.h22
-rw-r--r--plugins/Dropbox/src/version.h2
7 files changed, 163 insertions, 107 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp
index 27ab42cf8a..52fd2314ac 100644
--- a/plugins/Dropbox/src/dropbox.cpp
+++ b/plugins/Dropbox/src/dropbox.cpp
@@ -1,6 +1,6 @@
#include "stdafx.h"
-CDropbox::CDropbox()
+CDropbox::CDropbox() : transfers(1, HandleKeySortT)
{
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
pd.szName = MODULE;
@@ -21,6 +21,7 @@ CDropbox::CDropbox()
CreateProtoServiceFunction(MODULE, PS_GETSTATUS, ProtoGetStatus);
CreateProtoServiceFunctionObj(PS_SETSTATUS, ProtoSetStatus, this);
CreateProtoServiceFunctionObj(PSS_FILEW, ProtoSendFile, this);
+ CreateProtoServiceFunctionObj(PSS_FILECANCEL, ProtoCancelFile, this);
CreateProtoServiceFunctionObj(PSS_MESSAGE, ProtoSendMessage, this);
CreateProtoServiceFunctionObj(PSR_MESSAGE, ProtoReceiveMessage, this);
@@ -171,7 +172,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
requestToken);
HttpRequest *request = new HttpRequest(instance->hNetlibConnection, REQUEST_POST, DROPBOX_API_URL "/oauth2/token");
- request->AddBasicAuthHeader(DROPBOX_API_KEY, DROPBOX_API_SECRET);
+ request->AddBasicAuthHeader(DROPBOX_APP_KEY, DROPBOX_API_SECRET);
request->AddHeader("Content-Type", "application/x-www-form-urlencoded");
request->pData = mir_strdup(data);
request->dataLength = (int)strlen(data);
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h
index 6da80d85f4..c8e38234ba 100644
--- a/plugins/Dropbox/src/dropbox.h
+++ b/plugins/Dropbox/src/dropbox.h
@@ -10,7 +10,7 @@
#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_API_KEY "fa8du7gkf2q8xzg"
+#define DROPBOX_APP_KEY "fa8du7gkf2q8xzg"
#include "..\..\..\miranda-private-keys\Dropbox\secret_key.h"
#define DROPBOX_FILE_CHUNK_SIZE 4 * 1024 * 1024 //4 MB
@@ -50,6 +50,8 @@ private:
HGENMENU contactMenuItems[CMI_MAX];
+ LIST<FileTransferParam> transfers;
+
// hooks
static int OnProtoAck(void *obj, WPARAM wParam, LPARAM lParam);
static int OnPreShutdown(void *obj, WPARAM wParam, LPARAM lParam);
@@ -71,6 +73,7 @@ private:
static INT_PTR ProtoGetStatus(WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoSetStatus(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoSendFile(void *obj, WPARAM wParam, LPARAM lParam);
+ static INT_PTR ProtoCancelFile(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoSendMessage(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoReceiveMessage(void *obj, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Dropbox/src/dropbox_dialogs.cpp b/plugins/Dropbox/src/dropbox_dialogs.cpp
index 8fe9f93f5e..1bbc71326e 100644
--- a/plugins/Dropbox/src/dropbox_dialogs.cpp
+++ b/plugins/Dropbox/src/dropbox_dialogs.cpp
@@ -37,7 +37,7 @@ INT_PTR CALLBACK CDropbox::MainOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam
switch (LOWORD(wParam))
{
case IDC_GETAUTH:
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)DROPBOX_WWW_URL DROPBOX_API_VER "/oauth2/authorize?response_type=code&client_id=" DROPBOX_API_KEY);
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)DROPBOX_WWW_URL DROPBOX_API_VER "/oauth2/authorize?response_type=code&client_id=" DROPBOX_APP_KEY);
SetFocus(GetDlgItem(hwndDlg, IDC_REQUEST_CODE));
break;
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index 46fd7fa985..059d92036b 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -12,7 +12,8 @@ HANDLE CDropbox::CreateProtoServiceFunctionObj(const char *szService, MIRANDASER
INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM)
{
- switch (wParam) {
+ switch (wParam)
+ {
case PFLAGNUM_1:
return PF1_IM | PF1_FILESEND;
case PFLAGNUM_2:
@@ -26,7 +27,8 @@ INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM)
INT_PTR CDropbox::ProtoGetName(WPARAM wParam, LPARAM lParam)
{
- if (lParam) {
+ if (lParam)
+ {
mir_strncpy((char *)lParam, MODULE, wParam);
return 0;
}
@@ -48,9 +50,11 @@ INT_PTR CDropbox::ProtoSetStatus(void *obj, WPARAM wp, LPARAM)
{
CDropbox *instance = (CDropbox*)obj;
int nStatus = wp;
- if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus)) {
+ if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus))
+ {
int nOldStatus = g_nStatus;
- if (nStatus != g_nStatus) {
+ if (nStatus != g_nStatus)
+ {
g_nStatus = nStatus;
MCONTACT hContact = instance->GetDefaultContact();
@@ -79,38 +83,44 @@ INT_PTR CDropbox::ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
TCHAR **paths = (TCHAR**)pccsd->lParam;
- for (int i = 0; paths[i]; i++) {
+ for (int i = 0; paths[i]; i++)
+ {
if (PathIsDirectory(paths[i]))
ftp->totalFolders++;
else
ftp->pfts.totalFiles++;
}
- ftp->pwszFolders = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->totalFolders + 1));
- ftp->pwszFolders[ftp->totalFolders] = NULL;
+ ftp->ptszFolders = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->totalFolders + 1));
+ ftp->ptszFolders[ftp->totalFolders] = NULL;
ftp->pfts.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->pfts.totalFiles + 1));
ftp->pfts.ptszFiles[ftp->pfts.totalFiles] = NULL;
- for (int i = 0, j = 0, k = 0; paths[i]; i++) {
- if (PathIsDirectory(paths[i])) {
- if (!ftp->relativePathStart) {
+ for (int i = 0, j = 0, k = 0; paths[i]; i++)
+ {
+ if (PathIsDirectory(paths[i]))
+ {
+ if (!ftp->relativePathStart)
+ {
TCHAR *rootFolder = paths[j];
TCHAR *relativePath = wcsrchr(rootFolder, '\\') + 1;
ftp->relativePathStart = relativePath - rootFolder;
}
- ftp->pwszFolders[j] = mir_wstrdup(&paths[i][ftp->relativePathStart]);
+ ftp->ptszFolders[j] = mir_tstrdup(&paths[i][ftp->relativePathStart]);
j++;
}
- else {
- if (!ftp->pfts.wszWorkingDir) {
+ else
+ {
+ if (!ftp->pfts.tszWorkingDir)
+ {
TCHAR *path = paths[j];
int length = wcsrchr(path, '\\') - path;
- ftp->pfts.wszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
- mir_tstrncpy(ftp->pfts.wszWorkingDir, paths[j], length + 1);
- ftp->pfts.wszWorkingDir[length] = '\0';
+ ftp->pfts.tszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
+ mir_tstrncpy(ftp->pfts.tszWorkingDir, paths[j], length + 1);
+ ftp->pfts.tszWorkingDir[length] = '\0';
}
@@ -129,12 +139,31 @@ INT_PTR CDropbox::ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
ULONG fileId = InterlockedIncrement(&instance->hFileProcess);
ftp->hProcess = (HANDLE)fileId;
+ instance->transfers.insert(ftp);
mir_forkthreadowner(CDropbox::SendFilesAndReportAsync, obj, ftp, 0);
return fileId;
}
+INT_PTR CDropbox::ProtoCancelFile(void *obj, WPARAM, LPARAM lParam)
+{
+ CDropbox *instance = (CDropbox*)obj;
+ if (!instance->HasAccessToken())
+ return ACKRESULT_FAILED;
+
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+
+ HANDLE hTransfer = (HANDLE)pccsd->wParam;
+ FileTransferParam *ftp = instance->transfers.find((FileTransferParam*)&hTransfer);
+ if (ftp == NULL)
+ return 0;
+
+ ftp->isTerminated = true;
+
+ return 0;
+}
+
INT_PTR CDropbox::ProtoSendMessage(void *obj, WPARAM, LPARAM lParam)
{
CDropbox *instance = (CDropbox*)obj;
@@ -154,7 +183,8 @@ INT_PTR CDropbox::ProtoSendMessage(void *obj, WPARAM, LPARAM lParam)
dbei.flags = DBEF_SENT | DBEF_READ | DBEF_UTF;
db_event_add(pccsd->hContact, &dbei);
- if (message[0] && message[0] == '/') {
+ if (message[0] && message[0] == '/')
+ {
// parse commands
char *sep = strchr(message, ' ');
if (sep != NULL) *sep = 0;
@@ -172,8 +202,10 @@ INT_PTR CDropbox::ProtoSendMessage(void *obj, WPARAM, LPARAM lParam)
{ "delete", &CDropbox::CommandDelete }
};
- for (int i = 0; i < SIZEOF(commands); i++) {
- if (!strcmp(message + 1, commands[i].szCommand)) {
+ for (int i = 0; i < SIZEOF(commands); i++)
+ {
+ if (!strcmp(message + 1, commands[i].szCommand))
+ {
ULONG messageId = InterlockedIncrement(&instance->hMessageProcess);
CommandParam *param = new CommandParam();
@@ -192,6 +224,7 @@ INT_PTR CDropbox::ProtoSendMessage(void *obj, WPARAM, LPARAM lParam)
char help[1024];
mir_snprintf(help, SIZEOF(help), Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), message);
CallContactService(instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)help);
+
return 0;
}
@@ -230,10 +263,10 @@ INT_PTR CDropbox::SendFileToDropbox(void *obj, WPARAM hContact, LPARAM lParam)
ftp->hContact = (instance->hTransferContact) ? instance->hTransferContact : hContact;
instance->hTransferContact = 0;
- int length = wcsrchr(filePath, '\\') - filePath;
- ftp->pfts.wszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
- mir_tstrncpy(ftp->pfts.wszWorkingDir, filePath, length + 1);
- ftp->pfts.wszWorkingDir[length] = '\0';
+ int length = _tcsrchr(filePath, '\\') - filePath;
+ ftp->pfts.tszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
+ mir_tstrncpy(ftp->pfts.tszWorkingDir, filePath, length + 1);
+ ftp->pfts.tszWorkingDir[length] = '\0';
ftp->pfts.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->pfts.totalFiles + 1));
ftp->pfts.ptszFiles[0] = mir_wstrdup(filePath);
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index 8c520c69c3..f9bcce0bb4 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -1,27 +1,27 @@
#include "stdafx.h"
-/*void CDropbox::SendFile(const char *fileName, const char *data, int length)
+void CDropbox::SendFile(const char *fileName, const char *data, int length)
{
-CMStringA url(FORMAT, DROPBOX_APICONTENT_URL "/files_put/%s/%s", DROPBOX_API_ROOT, ptrA(mir_utf8encode(fileName)));
-url.Replace('\\', '/');
+ CMStringA url(FORMAT, DROPBOX_APICONTENT_URL "/files_put/%s/%s", DROPBOX_API_ROOT, ptrA(mir_utf8encode(fileName)));
+ url.Replace('\\', '/');
-HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_PUT, DROPBOX_APICONTENT_URL "/files_put");
-request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
-request->pData = (char*)mir_alloc(sizeof(char)* length);
-memcpy(request->pData, data, length);
-request->dataLength = length;
+ HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_PUT, DROPBOX_APICONTENT_URL "/files_put");
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
+ request->pData = (char*)mir_alloc(sizeof(char)* length);
+ memcpy(request->pData, data, length);
+ request->dataLength = length;
-mir_ptr<NETLIBHTTPREQUEST> response(request->Send());
+ mir_ptr<NETLIBHTTPREQUEST> response(request->Send());
-delete request;
+ delete request;
-HandleHttpResponseError(hNetlibConnection, response);
-}*/
+ HandleHttpResponseError(response);
+}
void CDropbox::SendFileChunkedFirst(const char *data, int length, char *uploadId, size_t &offset)
{
HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_PUT, DROPBOX_APICONTENT_URL "/chunked_upload");
- request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
request->AddHeader("Content-Type", "application/octet-stream");
request->pData = (char*)mir_alloc(sizeof(char)* length);
memcpy(request->pData, data, length);
@@ -50,7 +50,7 @@ void CDropbox::SendFileChunkedNext(const char *data, int length, const char *upl
url.AppendFormat("?upload_id=%s&offset=%i", uploadId, offset);
HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_PUT, url);
- request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
request->AddHeader("Content-Type", "application/octet-stream");
request->pData = (char*)mir_alloc(sizeof(char)* length);
memcpy(request->pData, data, length);
@@ -75,13 +75,13 @@ void CDropbox::SendFileChunkedLast(const char *fileName, const char *uploadId)
CMStringA url(FORMAT, "%s/commit_chunked_upload/%s/%s", DROPBOX_APICONTENT_URL, DROPBOX_API_ROOT, fileName);
url.Replace('\\', '/');
- CMStringA param = CMStringA("upload_id=") + uploadId;
+ CMStringA data(FORMAT, "upload_id=%s", uploadId);
HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_POST, url);
- request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
request->AddHeader("Content-Type", "application/x-www-form-urlencoded");
- request->pData = mir_strdup(param);
- request->dataLength = param.GetLength();
+ request->pData = data.GetBuffer();
+ request->dataLength = data.GetLength();
mir_ptr<NETLIBHTTPREQUEST> response(request->Send());
@@ -95,13 +95,13 @@ void CDropbox::CreateFolder(const char *folderName)
CMStringA folder(folderName);
folder.Replace('\\', '/');
- CMStringA param(FORMAT, "root=%s&path=%s", DROPBOX_API_ROOT, folder);
+ CMStringA data(FORMAT, "root=%s&path=%s", DROPBOX_API_ROOT, folder);
HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_POST, DROPBOX_API_URL "/fileops/create_folder");
- request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
request->AddHeader("Content-Type", "application/x-www-form-urlencoded");
- request->pData = mir_strdup(param);
- request->dataLength = param.GetLength();
+ request->pData = data.GetBuffer();
+ request->dataLength = data.GetLength();
mir_ptr<NETLIBHTTPREQUEST> response(request->Send());
@@ -123,7 +123,7 @@ void CDropbox::CreateDownloadUrl(const char *path, char *url)
api_url += "?short_url=false";
HttpRequest *request = new HttpRequest(hNetlibConnection, REQUEST_POST, api_url);
- request->AddBearerAuthHeader(db_get_sa(NULL, MODULE, "TokenSecret"));
+ request->AddBearerAuthHeader(ptrA(db_get_sa(NULL, MODULE, "TokenSecret")));
mir_ptr<NETLIBHTTPREQUEST> response(request->Send());
@@ -135,7 +135,7 @@ void CDropbox::CreateDownloadUrl(const char *path, char *url)
if (root)
{
JSONNODE *node = json_get(root, "url");
- mir_strcpy(url, _T2A(json_as_string(node)));
+ mir_strcpy(url, ptrA(mir_urlEncode(_T2A(json_as_string(node)))));
}
}
@@ -148,11 +148,14 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
try
{
- if (ftp->pwszFolders)
+ if (ftp->ptszFolders)
{
- for (int i = 0; ftp->pwszFolders[i]; i++)
+ for (int i = 0; ftp->ptszFolders[i]; i++)
{
- ptrA utf8_folderName(mir_utf8encodeW(ftp->pwszFolders[i]));
+ if(ftp->isTerminated)
+ throw TransferException("Transfer was terminated");
+
+ ptrA utf8_folderName(mir_utf8encodeW(ftp->ptszFolders[i]));
instance->CreateFolder(utf8_folderName);
if (!strchr(utf8_folderName, '\\'))
@@ -166,6 +169,9 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
for (int i = 0; ftp->pfts.ptszFiles[i]; i++)
{
+ if (ftp->isTerminated)
+ throw TransferException("Transfer was terminated");
+
FILE *hFile = _tfopen(ftp->pfts.ptszFiles[i], _T("rb"));
if (hFile == NULL)
throw TransferException("Unable to open file");
@@ -183,7 +189,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
ftp->pfts.currentFileNumber = i;
ftp->pfts.currentFileSize = fileSize;
ftp->pfts.currentFileProgress = 0;
- ftp->pfts.wszCurrentFile = wcsrchr(ftp->pfts.ptszFiles[i], '\\') + 1;
+ ftp->pfts.tszCurrentFile = wcsrchr(ftp->pfts.ptszFiles[i], '\\') + 1;
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftp->hProcess, (LPARAM)&ftp->pfts);
@@ -202,6 +208,9 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
if (ferror(hFile))
throw TransferException("Error while file sending");
+ if (ftp->isTerminated)
+ throw TransferException("Transfer was terminated");
+
char *data = new char[chunkSize + 1];
int count = (int)fread(data, sizeof(char), chunkSize, hFile);
@@ -226,7 +235,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
{
char url[MAX_PATH];
instance->CreateDownloadUrl(utf8_fileName, url);
- ftp->AddUrl(url);
+ ftp->AddUrl(url);
}
ftp->pfts.currentFileProgress = ftp->pfts.currentFileSize;
@@ -239,7 +248,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
{
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ftp->hProcess, 0);
- return 0;
+ return ACKRESULT_FAILED;
}
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ftp->hProcess, 0);
@@ -253,35 +262,27 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
FileTransferParam *ftp = (FileTransferParam*)arg;
int res = SendFilesAsync(owner, arg);
- if (!res)
+ if (res)
{
- CMStringA urls;
- for (int i = 0; i < ftp->urlList.getCount(); i++)
- urls.AppendFormat("%s\r\n", ftp->urlList[i]);
- char *data = urls.GetBuffer();
+ instance->transfers.remove(ftp);
+ delete ftp;
+ return res;
+ }
+
+ CMStringA urls;
+ for (int i = 0; i < ftp->urlList.getCount(); i++)
+ urls.AppendFormat("%s\r\n", ftp->urlList[i]);
+ char *data = urls.GetBuffer();
- if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
+ if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
+ {
+ char *message = mir_utf8encode(data);
+ if (ftp->hContact != instance->GetDefaultContact())
{
- char *message = mir_utf8encode(data);
- if (ftp->hContact != instance->GetDefaultContact())
- {
- if (CallContactService(ftp->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)message) != ACKRESULT_FAILED)
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.flags = DBEF_UTF | DBEF_SENT/* | DBEF_READ*/;
- dbei.szModule = MODULE;
- dbei.timestamp = time(NULL);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (int)mir_strlen(data);
- dbei.pBlob = (PBYTE)message;
- db_event_add(ftp->hContact, &dbei);
- }
- else CallServiceSync(MS_MSG_SENDMESSAGEW, (WPARAM)ftp->hContact, (LPARAM)data);
- }
- else
+ if (CallContactService(ftp->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)message) != ACKRESULT_FAILED)
{
DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.flags = DBEF_UTF;
+ dbei.flags = DBEF_UTF | DBEF_SENT/* | DBEF_READ*/;
dbei.szModule = MODULE;
dbei.timestamp = time(NULL);
dbei.eventType = EVENTTYPE_MESSAGE;
@@ -289,33 +290,46 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
dbei.pBlob = (PBYTE)message;
db_event_add(ftp->hContact, &dbei);
}
+ else CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)ftp->hContact, (LPARAM)data);
+ }
+ else
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.flags = DBEF_UTF;
+ dbei.szModule = MODULE;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.cbBlob = (int)mir_strlen(data);
+ dbei.pBlob = (PBYTE)message;
+ db_event_add(ftp->hContact, &dbei);
}
+ }
- if (db_get_b(NULL, MODULE, "UrlPasteToMessageInputArea", 0))
- CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)ftp->hContact, (LPARAM)data);
+ if (db_get_b(NULL, MODULE, "UrlPasteToMessageInputArea", 0))
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)ftp->hContact, (LPARAM)data);
- if (db_get_b(NULL, MODULE, "UrlCopyToClipboard", 0))
+ if (db_get_b(NULL, MODULE, "UrlCopyToClipboard", 0))
+ {
+ if (OpenClipboard(NULL))
{
- if (OpenClipboard(NULL))
+ EmptyClipboard();
+ size_t size = sizeof(TCHAR) * (urls.GetLength() + 1);
+ HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
+ if (hClipboardData)
{
- EmptyClipboard();
- size_t size = sizeof(TCHAR) * (urls.GetLength() + 1);
- HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
- if (hClipboardData)
+ TCHAR *pchData = (TCHAR*)GlobalLock(hClipboardData);
+ if (pchData)
{
- TCHAR *pchData = (TCHAR*)GlobalLock(hClipboardData);
- if (pchData)
- {
- memcpy(pchData, (TCHAR*)data, size);
- GlobalUnlock(hClipboardData);
- SetClipboardData(CF_TEXT, hClipboardData);
- }
+ memcpy(pchData, (TCHAR*)data, size);
+ GlobalUnlock(hClipboardData);
+ SetClipboardData(CF_TEXT, hClipboardData);
}
- CloseClipboard();
}
+ CloseClipboard();
}
}
+ instance->transfers.remove(ftp);
delete ftp;
return res;
@@ -335,6 +349,7 @@ UINT CDropbox::SendFilesAndEventAsync(void *owner, void *arg)
NotifyEventHooks(instance->hFileSentEventHook, ftp->hContact, (LPARAM)&ti);
+ instance->transfers.remove(ftp);
delete ftp;
return res;
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h
index 3def765d3e..8afb1b4ec3 100644
--- a/plugins/Dropbox/src/file_transfer.h
+++ b/plugins/Dropbox/src/file_transfer.h
@@ -23,8 +23,10 @@ struct FileTransferParam
MCONTACT hContact;
PROTOFILETRANSFERSTATUS pfts;
+ bool isTerminated;
+
int totalFolders;
- TCHAR **pwszFolders;
+ TCHAR **ptszFolders;
int relativePathStart;
LIST<char> urlList;
@@ -32,9 +34,11 @@ struct FileTransferParam
FileTransferParam() : urlList(1)
{
totalFolders = 0;
- pwszFolders = NULL;
+ ptszFolders = NULL;
relativePathStart = 0;
+ isTerminated = false;
+
pfts.cbSize = sizeof(this->pfts);
pfts.flags = PFTS_TCHAR;
pfts.currentFileNumber = 0;
@@ -45,13 +49,13 @@ struct FileTransferParam
pfts.totalProgress = 0;
pfts.pszFiles = NULL;
pfts.tszWorkingDir = NULL;
- pfts.wszCurrentFile = NULL;
+ pfts.tszCurrentFile = NULL;
}
~FileTransferParam()
{
- if (pfts.wszWorkingDir)
- mir_free(pfts.wszWorkingDir);
+ if (pfts.tszWorkingDir)
+ mir_free(pfts.tszWorkingDir);
if (pfts.pszFiles)
{
@@ -62,13 +66,13 @@ struct FileTransferParam
mir_free(pfts.pszFiles);
}
- if (pwszFolders)
+ if (ptszFolders)
{
- for (int i = 0; pwszFolders[i]; i++)
+ for (int i = 0; ptszFolders[i]; i++)
{
- if (pwszFolders[i]) mir_free(pwszFolders[i]);
+ if (ptszFolders[i]) mir_free(ptszFolders[i]);
}
- mir_free(pwszFolders);
+ mir_free(ptszFolders);
}
for (int i = 0; i < urlList.getCount(); i++)
diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h
index 5f8154e315..27323bf19e 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 1
+#define __BUILD_NUM 2
#include <stdver.h>