From 3bdbd608284853f05acdf137013de71efd915499 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 9 Mar 2014 20:23:19 +0000 Subject: Dropbox: - added MS_DROPBOX_SEND_FILE service - added new behaviors for download links - attempt to fix tabsrmm button behavior git-svn-id: http://svn.miranda-ng.org/main/trunk@8527 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_services.cpp | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'plugins/Dropbox/src/dropbox_services.cpp') diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index 84c9f6b5b7..3755299199 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -172,6 +172,72 @@ INT_PTR CDropbox::ProtoReceiveMessage(void *obj, WPARAM, LPARAM lParam) return 0; } +INT_PTR CDropbox::SendFileToDropbox(void *obj, WPARAM hContact, LPARAM lParam) +{ + CDropbox *instance = (CDropbox*)obj; + + const char *filePath = (char*)lParam; + const char *fileName = strrchr(filePath, '\\') + 1; + + FILE *file = fopen(filePath, "rb"); + if (file != NULL) + { + fseek(file, 0, SEEK_END); + DWORD fileSize = ftell(file); + fseek(file, 0, SEEK_SET); + + int chunkSize = DROPBOX_FILE_CHUNK_SIZE; + if (fileSize <= (DROPBOX_FILE_CHUNK_SIZE)) + { + char *data = new char[fileSize + 1]; + int count = (int)fread(data, sizeof(char), fileSize, file); + + instance->SendFile(fileName, data, fileSize); + } + else + { + int offset = 0; + bool error = false; + char *uploadId = new char[32]; + + while (!feof(file) && !ferror(file)) + { + char *data = new char[chunkSize + 1]; + int count = (int)fread(data, sizeof(char), chunkSize, file); + + if (!offset) + { + if (instance->SendFileChunkedFirst(data, count, uploadId, offset)) + { + error = true; + break; + } + } + else + { + if (instance->SendFileChunkedNext(data, count, uploadId, offset)) + { + error = true; + break; + } + } + } + + fclose(file); + + if (!error) + { + if (instance->SendFileChunkedLast(fileName, uploadId)) + { + error = true; + } + } + } + } + + return 0; +} + INT_PTR CDropbox::SendFilesToDropbox(void *obj, WPARAM hContact, LPARAM) { CDropbox *instance = (CDropbox*)obj; @@ -182,5 +248,12 @@ INT_PTR CDropbox::SendFilesToDropbox(void *obj, WPARAM hContact, LPARAM) instance->dcftp[hwnd] = hContact; + BBButton bbd = { sizeof(bbd) }; + bbd.pszModuleName = MODULE; + bbd.dwButtonID = BBB_ID_FILE_SEND; + bbd.bbbFlags = BBSF_DISABLED; + + CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd); + return 0; } \ No newline at end of file -- cgit v1.2.3