diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-25 15:49:58 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-25 15:49:58 +0000 |
commit | 048e1f421b84529aa2b29da09027ce997573afd7 (patch) | |
tree | 230bde579a4622d6def27b4961639d3377f9cca3 /plugins | |
parent | 8bf03133314064ec052873b01647c79b69a5b681 (diff) |
Dropbox: reworked files sending
git-svn-id: http://svn.miranda-ng.org/main/trunk@16337 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Dropbox/src/api/upload.h | 27 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox.h | 10 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_commands.cpp | 15 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_services.cpp | 11 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_transfers.cpp | 152 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_utils.cpp | 24 | ||||
-rw-r--r-- | plugins/Dropbox/src/file_transfer.h | 109 | ||||
-rw-r--r-- | plugins/Dropbox/src/http_request.h | 1 | ||||
-rw-r--r-- | plugins/Dropbox/src/stdafx.h | 6 | ||||
-rw-r--r-- | plugins/Dropbox/src/version.h | 4 |
10 files changed, 220 insertions, 139 deletions
diff --git a/plugins/Dropbox/src/api/upload.h b/plugins/Dropbox/src/api/upload.h index e612046ba6..7e1c501297 100644 --- a/plugins/Dropbox/src/api/upload.h +++ b/plugins/Dropbox/src/api/upload.h @@ -10,11 +10,12 @@ public: AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/octet-stream");
- JSONNode root(JSON_NODE);
- root << JSONNode("path", path);
+ JSONNode params(JSON_NODE);
+ params
+ << JSONNode("path", path)
+ << JSONNode("mode", "overwrite");
- json_string params = root.write();
- AddHeader("Dropbox-API-Arg", params.c_str());
+ AddHeader("Dropbox-API-Arg", params.write().c_str());
SetData(data, size);
}
@@ -42,13 +43,12 @@ public: AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/octet-stream");
- JSONNode root(JSON_NODE);
- root
+ JSONNode params(JSON_NODE);
+ params
<< JSONNode("session_id", sessionId)
<< JSONNode("offset", (unsigned long)offset);
- json_string params = root.write();
- AddHeader("Dropbox-API-Arg", params.c_str());
+ AddHeader("Dropbox-API-Arg", params.write().c_str());
SetData(data, size);
}
@@ -71,15 +71,16 @@ public: JSONNode commit(JSON_NODE);
commit.set_name("commit");
- commit << JSONNode("path", path);
+ commit
+ << JSONNode("path", path)
+ << JSONNode("mode", "overwrite");
- JSONNode root(JSON_NODE);
- root
+ JSONNode params(JSON_NODE);
+ params
<< cursor
<< commit;
- json_string params = root.write();
- AddHeader("Dropbox-API-Arg", params.c_str());
+ AddHeader("Dropbox-API-Arg", params.write().c_str());
SetData(data, size);
}
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index 2331ed1922..5ad332b168 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -84,10 +84,10 @@ private: static void __cdecl RequestAccountInfo(void*);
// transfers
- void UploadFile(const char *path, const char *data, size_t size);
+ char* UploadFile(const char *data, size_t size, char *path);
void StartUploadSession(const char *data, size_t size, char *sessionId);
- void AppendToUploadSession(const char *data, size_t size, const char *sessionId, size_t &offset);
- void FinishUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, const char *path);
+ void AppendToUploadSession(const char *data, size_t size, const char *sessionId, size_t offset);
+ char* FinishUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, char *path);
void CreateFolder(const char *encodedPath);
@@ -110,8 +110,8 @@ private: static void DisableSrmmButton(MCONTACT hContact);
// utils
- static CMStringA PreparePath(const char *path);
- static CMStringA PreparePath(const TCHAR *path);
+ static char* PreparePath(const char *oldPath, char *newPath);
+ static char* PreparePath(const TCHAR *oldPath, char *newPath);
static char* HttpStatusToText(HTTP_STATUS status);
static void HandleJsonResponseError(NETLIBHTTPREQUEST *response);
diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp index 76c373ae80..b3bfc41da4 100644 --- a/plugins/Dropbox/src/dropbox_commands.cpp +++ b/plugins/Dropbox/src/dropbox_commands.cpp @@ -20,8 +20,9 @@ void CDropbox::CommandContent(void *arg) {
CommandParam *param = (CommandParam*)arg;
- CMStringA path = PreparePath((char*)param->data);
- if (path.IsEmpty()) {
+ char path[MAX_PATH];
+ PreparePath((char*)param->data, path);
+ if (path == NULL) {
CMStringA error(FORMAT, T2Utf(TranslateT("\"%s\" command has invalid parameter.\nUse \"/help\" for more info.")), "/share");
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer());
@@ -66,8 +67,9 @@ void CDropbox::CommandShare(void *arg) {
CommandParam *param = (CommandParam*)arg;
- CMStringA path = PreparePath((char*)param->data);
- if (path.IsEmpty()) {
+ char path[MAX_PATH];
+ PreparePath((char*)param->data, path);
+ if (path == NULL) {
CMStringA error(FORMAT, T2Utf(TranslateT("\"%s\" command has invalid parameter.\nUse \"/help\" for more info.")), "/share");
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer());
@@ -100,8 +102,9 @@ void CDropbox::CommandDelete(void *arg) {
CommandParam *param = (CommandParam*)arg;
- CMStringA path = PreparePath((char*)param->data);
- if (path.IsEmpty()) {
+ char path[MAX_PATH];
+ PreparePath((char*)param->data, path);
+ if (path == NULL) {
CMStringA error(FORMAT, T2Utf(TranslateT("\"%s\" command has invalid parameter.\nUse \"/help\" for more info.")), "/delete");
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer());
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index cece2a4bc3..81f77683ba 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -96,12 +96,11 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam) ftp->pfts.ptszFiles[k] = mir_wstrdup(paths[i]);
- FILE *file = _wfopen(paths[i], L"rb");
- if (file != NULL) {
- fseek(file, 0, SEEK_END);
- ftp->pfts.totalBytes += ftell(file);
- fseek(file, 0, SEEK_SET);
- fclose(file);
+ FILE *hFile = _wfopen(paths[i], L"rb");
+ if (hFile != NULL) {
+ _fseeki64(hFile, 0, SEEK_END);
+ ftp->pfts.totalBytes += _ftelli64(hFile);
+ fclose(hFile);
}
k++;
}
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index d46b0871ed..f97f6d2f01 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-void CDropbox::UploadFile(const char *path, const char *data, size_t size)
+char* CDropbox::UploadFile(const char *data, size_t size, char *path)
{
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
ptrA encodedPath(mir_utf8encode(path));
@@ -8,6 +8,14 @@ void CDropbox::UploadFile(const char *path, const char *data, size_t size) NLHR_PTR response(request.Send(hNetlibConnection));
HandleJsonResponseError(response);
+
+ JSONNode root = JSONNode::parse(response->pData);
+ if (!root.empty())
+ {
+ JSONNode node = root.at("path_lower");
+ mir_strcpy(path, node.as_string().c_str());
+ }
+ return path;
}
void CDropbox::StartUploadSession(const char *data, size_t size, char *sessionId)
@@ -26,28 +34,30 @@ void CDropbox::StartUploadSession(const char *data, size_t size, char *sessionId mir_strcpy(sessionId, node.as_string().c_str());
}
-void CDropbox::AppendToUploadSession(const char *data, size_t size, const char *sessionId, size_t &offset)
+void CDropbox::AppendToUploadSession(const char *data, size_t size, const char *sessionId, size_t offset)
{
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
AppendToUploadSessionRequest request(token, sessionId, offset, data, size);
NLHR_PTR response(request.Send(hNetlibConnection));
HandleJsonResponseError(response);
-
- JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- return;
-
- offset = root.at("offset").as_int();
}
-void CDropbox::FinishUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, const char *path)
+char* CDropbox::FinishUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, char *path)
{
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
FinishUploadSessionRequest request(token, sessionId, offset, path, data, size);
NLHR_PTR response(request.Send(hNetlibConnection));
HandleJsonResponseError(response);
+
+ JSONNode root = JSONNode::parse(response->pData);
+ if (!root.empty())
+ {
+ JSONNode node = root.at("path_lower");
+ mir_strcpy(path, node.as_string().c_str());
+ }
+ return path;
}
void CDropbox::CreateFolder(const char *path)
@@ -85,15 +95,14 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) CDropbox *instance = (CDropbox*)owner;
FileTransferParam *ftp = (FileTransferParam*)arg;
- ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ftp->hProcess, 0);
-
try {
if (ftp->ptszFolders) {
for (int i = 0; ftp->ptszFolders[i]; i++) {
if (ftp->isTerminated)
throw DropboxException("Transfer was terminated");
- CMStringA path = PreparePath(ftp->ptszFolders[i]);
+ char path[MAX_PATH];
+ PreparePath(ftp->ptszFolders[i], path);
instance->CreateFolder(path);
if (!strchr(path, '\\')) {
char url[MAX_PATH];
@@ -103,98 +112,58 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) }
}
- for (int i = 0; ftp->pfts.ptszFiles[i]; i++) {
- if (ftp->isTerminated)
- throw DropboxException("Transfer was terminated");
+ ftp->First();
+ do
+ {
+ const TCHAR *fileName = &ftp->GetCurrentFileName()[ftp->relativePathStart];
+ uint64_t fileSize = ftp->GetCurrentFileSize();
- FILE *hFile = _tfopen(ftp->pfts.ptszFiles[i], _T("rb"));
- if (hFile == NULL)
- throw DropboxException("Unable to open file");
+ int chunkSize = ftp->GetCurrentFileChunkSize();
+ char *data = (char*)mir_calloc(chunkSize);
+ size_t size = ftp->ReadCurrentFile(data, chunkSize);
- const TCHAR *fileName = NULL;
- if (!ftp->relativePathStart)
- fileName = _tcsrchr(ftp->pfts.ptszFiles[i], L'\\') + 1;
- else
- fileName = &ftp->pfts.ptszFiles[i][ftp->relativePathStart];
+ size_t offset = 0;
+ char sessionId[32];
+ instance->StartUploadSession(data, size, sessionId);
- _fseeki64(hFile, 0, SEEK_END);
- uint64_t fileSize = _ftelli64(hFile);
- rewind(hFile);
+ offset += size;
+ ftp->Progress(size);
- ftp->pfts.currentFileNumber = i;
- ftp->pfts.currentFileSize = fileSize;
- ftp->pfts.currentFileProgress = 0;
- ftp->pfts.tszCurrentFile = _tcsrchr(ftp->pfts.ptszFiles[i], '\\') + 1;
+ for (size_t chunk = 0, size = 0; chunk < (fileSize / chunkSize) - 1; chunk++, size = 0)
+ {
+ ftp->CheckCurrentFile();
- size_t offset = 0;
- char sessionId[32];
- int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4;
- if (fileSize < 1024 * 1024)
- chunkSize = DROPBOX_FILE_CHUNK_SIZE / 20;
- else if (fileSize > 20 * 1024 * 1024)
- chunkSize = DROPBOX_FILE_CHUNK_SIZE;
-
- char *data = (char*)mir_alloc(chunkSize);
- while (!feof(hFile) && fileSize != offset) {
- try {
- if (ferror(hFile))
- throw DropboxException("Error while file sending");
-
- if (ftp->isTerminated)
- throw DropboxException("Transfer was terminated");
-
- size_t size = fread(data, sizeof(char), chunkSize, hFile);
-
- if (offset == 0) {
- instance->StartUploadSession(data, size, sessionId);
- offset += size;
- }
- else
- instance->AppendToUploadSession(data, size, sessionId, offset);
-
- ftp->pfts.currentFileProgress += size;
- ftp->pfts.totalProgress += size;
- }
- catch (DropboxException&) {
- mir_free(data);
- fclose(hFile);
- throw;
- }
+ size = ftp->ReadCurrentFile(data, chunkSize);
+ instance->AppendToUploadSession(data, size, sessionId, offset);
- ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftp->hProcess, (LPARAM)&ftp->pfts);
+ offset += size;
+ ftp->Progress(size);
}
- mir_free(data);
- fclose(hFile);
- if (ftp->pfts.currentFileProgress < ftp->pfts.currentFileSize)
- throw DropboxException("Transfer was terminated");
+ if (offset < fileSize)
+ size = ftp->ReadCurrentFile(data, fileSize - offset);
- CMStringA path = PreparePath(fileName);
- instance->FinishUploadSession(0, 0, sessionId, offset, path);
+ char path[MAX_PATH];
+ PreparePath(fileName, path);
+ instance->FinishUploadSession(data, size, sessionId, offset, path);
+
+ ftp->Progress(size);
if (!_tcschr(fileName, L'\\')) {
char url[MAX_PATH];
instance->CreateDownloadUrl(path, url);
ftp->AddUrl(url);
}
-
- ftp->pfts.currentFileProgress = ftp->pfts.currentFileSize;
-
- if (i < ftp->pfts.totalFiles - 1)
- ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ftp->hProcess, 0);
- }
+ } while (ftp->Next());
}
catch (DropboxException &ex) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
- ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ftp->hProcess, 0);
+ ftp->SetStatus(ACKRESULT_FAILED);
return ACKRESULT_FAILED;
}
- ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ftp->hProcess, 0);
-
- mir_forkthread(&CDropbox::RequestAccountInfo, instance);
-
- return 0;
+ ftp->SetStatus(ACKRESULT_SUCCESS);
+ return ACKRESULT_SUCCESS;
}
UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
@@ -203,17 +172,14 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg) FileTransferParam *ftp = (FileTransferParam*)arg;
int res = SendFilesAsync(owner, arg);
- if (res) {
- 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]);
+ if (res == ACKRESULT_SUCCESS)
+ {
+ CMStringA urls;
+ for (int i = 0; i < ftp->urlList.getCount(); i++)
+ urls.AppendFormat("%s\r\n", ftp->urlList[i]);
- instance->Report(ftp->hContact, urls.GetBuffer());
+ instance->Report(ftp->hContact, urls.GetBuffer());
+ }
instance->transfers.remove(ftp);
delete ftp;
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp index fbc48ae395..c6f029be0d 100644 --- a/plugins/Dropbox/src/dropbox_utils.cpp +++ b/plugins/Dropbox/src/dropbox_utils.cpp @@ -1,19 +1,17 @@ #include "stdafx.h"
-CMStringA CDropbox::PreparePath(const char *path)
+char* CDropbox::PreparePath(const char *oldPath, char *newPath)
{
CMStringA result("/");
- result.Append(path);
+ result.Append(oldPath);
result.Replace("\\", "/");
- return result;
+ mir_strcpy(newPath, result);
+ return newPath;
}
-CMStringA CDropbox::PreparePath(const TCHAR *path)
+char* CDropbox::PreparePath(const TCHAR *oldPath, char *newPath)
{
- CMStringA result("/");
- result.Append(ptrA(mir_utf8encodeW(path)));
- result.Replace("\\", "/");
- return result;
+ return PreparePath(ptrA(mir_utf8encodeW(oldPath)), newPath);
}
char* CDropbox::HttpStatusToText(HTTP_STATUS status)
@@ -49,13 +47,19 @@ void CDropbox::HandleJsonResponseError(NETLIBHTTPREQUEST *response) if (response == NULL)
throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR));
- JSONNode root = JSONNode::parse(response->pData);
- if (root.empty()) {
+ if (response->resultCode == HTTP_STATUS_OK)
+ return;
+
+ if (response->resultCode != HTTP_STATUS_CONFLICT) {
if (response->dataLength)
throw DropboxException(response->pData);
throw DropboxException(HttpStatusToText((HTTP_STATUS)response->resultCode));
}
+ JSONNode root = JSONNode::parse(response->pData);
+ if (root.empty())
+ throw DropboxException(HttpStatusToText(HTTP_STATUS_ERROR));
+
JSONNode error = root.at("error_summary");
if (error.empty())
return;
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h index 0c5e592294..442f821f44 100644 --- a/plugins/Dropbox/src/file_transfer.h +++ b/plugins/Dropbox/src/file_transfer.h @@ -3,6 +3,7 @@ struct FileTransferParam
{
+ FILE *hFile;
HANDLE hProcess;
MCONTACT hContact;
PROTOFILETRANSFERSTATUS pfts;
@@ -17,6 +18,8 @@ struct FileTransferParam FileTransferParam() : urlList(1)
{
+ hFile = NULL;
+
totalFolders = 0;
ptszFolders = NULL;
relativePathStart = 0;
@@ -29,7 +32,7 @@ struct FileTransferParam pfts.cbSize = sizeof(this->pfts);
pfts.flags = PFTS_TCHAR | PFTS_SENDING;
pfts.hContact = NULL;
- pfts.currentFileNumber = 0;
+ pfts.currentFileNumber = -1;
pfts.currentFileProgress = 0;
pfts.currentFileSize = 0;
pfts.currentFileTime = 0;
@@ -39,10 +42,14 @@ struct FileTransferParam pfts.pszFiles = NULL;
pfts.tszWorkingDir = NULL;
pfts.tszCurrentFile = NULL;
+
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, hProcess, 0);
}
~FileTransferParam()
{
+ CloseCurrentFile();
+
if (pfts.tszWorkingDir)
mir_free(pfts.tszWorkingDir);
@@ -69,6 +76,106 @@ struct FileTransferParam urlList.destroy();
}
+ const TCHAR* GetCurrentFilePath() const
+ {
+ return pfts.ptszFiles[pfts.currentFileNumber];
+ }
+
+ const TCHAR* GetCurrentFileName() const
+ {
+ return _tcsrchr(pfts.ptszFiles[pfts.currentFileNumber], '\\') + 1;
+ }
+
+ void OpenCurrentFile()
+ {
+ hFile = _tfopen(GetCurrentFilePath(), _T("rb"));
+ if (!hFile)
+ throw DropboxException("Unable to open file");
+ _fseeki64(hFile, 0, SEEK_END);
+ pfts.currentFileSize = _ftelli64(hFile);
+ rewind(hFile);
+ }
+
+ size_t ReadCurrentFile(void *data, size_t count)
+ {
+ return fread(data, sizeof(char), count, hFile);
+ }
+
+ void CheckCurrentFile()
+ {
+ if (ferror(hFile))
+ throw DropboxException("Error while file sending");
+
+ if (isTerminated)
+ throw DropboxException("Transfer was terminated");
+ }
+
+ void CloseCurrentFile()
+ {
+ if (hFile != NULL)
+ {
+ fclose(hFile);
+ hFile = NULL;
+ }
+ }
+
+ const uint64_t GetCurrentFileSize() const
+ {
+ return pfts.currentFileSize;
+ }
+
+ const uint64_t GetCurrentFileChunkSize() const
+ {
+ int chunkSize = 1024 * 1024;
+ if (pfts.currentFileSize < chunkSize)
+ chunkSize = min(pfts.currentFileSize, chunkSize / 4);
+ else if (pfts.currentFileSize > 20 * chunkSize)
+ chunkSize = chunkSize * 4;
+ return chunkSize;
+ }
+
+ void Progress(size_t count)
+ {
+ pfts.currentFileProgress += count;
+ pfts.totalProgress += count;
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, hProcess, (LPARAM)&pfts);
+ }
+
+ void First()
+ {
+ CloseCurrentFile();
+
+ pfts.currentFileNumber = 0;
+ pfts.currentFileProgress = 0;
+ pfts.tszCurrentFile = _tcsrchr(pfts.ptszFiles[pfts.currentFileNumber], '\\') + 1;
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, hProcess, (LPARAM)&pfts);
+
+ OpenCurrentFile();
+ CheckCurrentFile();
+ }
+
+ bool Next()
+ {
+ CloseCurrentFile();
+
+ if (++pfts.currentFileNumber == pfts.totalFiles)
+ return false;
+
+ pfts.currentFileProgress = 0;
+ pfts.tszCurrentFile = _tcsrchr(pfts.ptszFiles[pfts.currentFileNumber], '\\') + 1;
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, hProcess, 0);
+
+ OpenCurrentFile();
+ CheckCurrentFile();
+
+ return true;
+ }
+
+ void SetStatus(int status, LPARAM param = 0)
+ {
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, status, hProcess, param);
+ }
+
void AddUrl(const char *url)
{
urlList.insert(mir_strdup(url));
diff --git a/plugins/Dropbox/src/http_request.h b/plugins/Dropbox/src/http_request.h index 9e50ac9f0c..3c11f99b17 100644 --- a/plugins/Dropbox/src/http_request.h +++ b/plugins/Dropbox/src/http_request.h @@ -10,6 +10,7 @@ enum HTTP_STATUS HTTP_STATUS_FORBIDDEN = 403,
HTTP_STATUS_NOT_FOUND = 404,
HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
+ HTTP_STATUS_CONFLICT = 409,
HTTP_STATUS_TOO_MANY_REQUESTS = 429,
HTTP_STATUS_SERVICE_UNAVAILABLE = 503,
HTTP_STATUS_INSUFICIENTE_STORAGE = 507
diff --git a/plugins/Dropbox/src/stdafx.h b/plugins/Dropbox/src/stdafx.h index e8117bd649..b83d80895b 100644 --- a/plugins/Dropbox/src/stdafx.h +++ b/plugins/Dropbox/src/stdafx.h @@ -61,6 +61,8 @@ public: }
};
+#define MODULE "Dropbox"
+
#include "dropbox_dialogs.h"
#include "dropbox_options.h"
#include "http_request.h"
@@ -70,11 +72,9 @@ public: #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 DROPBOX_FILE_CHUNK_SIZE 1024 * 1024 //1 MB
#define BBB_ID_FILE_SEND 10001
diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h index 38b5566b58..d629b60900 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 0
+#define __BUILD_NUM 1
#include <stdver.h>
@@ -11,4 +11,4 @@ #define __AUTHOR "Miranda NG Team"
#define __AUTHOREMAIL ""
#define __AUTHORWEB "http://miranda-ng.org/p/Dropbox/"
-#define __COPYRIGHT "© 2014-16 Miranda NG project"
+#define __COPYRIGHT "© 2014-16 Miranda NG project"
|