From 6d02559b3c3cb05cfc6a0ade5c4815dda4427834 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 4 Mar 2016 16:59:35 +0000 Subject: Dropbox: removed old service git-svn-id: http://svn.miranda-ng.org/main/trunk@16420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox.cpp | 4 +-- plugins/Dropbox/src/dropbox.h | 6 ----- plugins/Dropbox/src/dropbox_services.cpp | 25 ++--------------- plugins/Dropbox/src/dropbox_transfers.cpp | 45 ++++--------------------------- plugins/Dropbox/src/file_transfer.h | 26 +++++++++--------- plugins/Dropbox/src/stdafx.h | 3 +-- 6 files changed, 22 insertions(+), 87 deletions(-) (limited to 'plugins/Dropbox') diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index fa31010600..63b779c59c 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -6,10 +6,8 @@ CDropbox::CDropbox() : transfers(1, HandleKeySortT) HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); HookEventObj(ME_SYSTEM_MODULESLOADED, GlobalEvent<&CDropbox::OnModulesLoaded>, this); - hFileSentEventHook = CreateHookableEvent(ME_DROPBOX_SENT); hUploadedEventHook = CreateHookableEvent(ME_DROPBOX_UPLOADED); - CreateServiceFunctionObj(MS_DROPBOX_SEND_FILE, GlobalService<&CDropbox::SendFileToDropbox>, this); CreateServiceFunctionObj(MS_DROPBOX_UPLOAD, GlobalService<&CDropbox::UploadToDropbox>, this); CreateServiceFunctionObj(MS_DROPBOX_UPLOADASYNC, GlobalService<&CDropbox::UploadToDropboxAsync>, this); @@ -41,7 +39,7 @@ CDropbox::CDropbox() : transfers(1, HandleKeySortT) CDropbox::~CDropbox() { - DestroyHookableEvent(hFileSentEventHook); + DestroyHookableEvent(hUploadedEventHook); } MCONTACT CDropbox::GetDefaultContact() diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index aa83b795ea..1910731f18 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -29,7 +29,6 @@ private: HANDLE hNetlibConnection; ULONG hMessageProcess; - HANDLE hFileSentEventHook; HANDLE hUploadedEventHook; MCONTACT hDefaultContact; @@ -60,8 +59,6 @@ private: INT_PTR ProtoSendFileInterceptor(WPARAM wParam, LPARAM lParam); - INT_PTR SendFileToDropbox(WPARAM wParam, LPARAM lParam); - INT_PTR UploadToDropbox(WPARAM wParam, LPARAM lParam); INT_PTR UploadToDropboxAsync(WPARAM wParam, LPARAM lParam); @@ -95,9 +92,6 @@ private: static UINT UploadToDropbox(void *owner, void *arg); - static UINT SendFilesAndEventAsync(void *owner, void *arg); - static UINT SendFilesAndReportAsync(void *owner, void *arg); - static UINT UploadAndRaiseEvent(void *owner, void *arg); static UINT UploadAndReportProgress(void *owner, void *arg); diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index 853db24e00..8d21b72cc2 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -161,33 +161,13 @@ INT_PTR CDropbox::ProtoReceiveMessage(WPARAM, LPARAM lParam) return 0; } -INT_PTR CDropbox::SendFileToDropbox(WPARAM hContact, LPARAM lParam) -{ - if (!HasAccessToken()) - return 0; - - if (hContact == NULL) - hContact = GetDefaultContact(); - - TCHAR *filePath = (TCHAR*)lParam; - - FileTransferParam *ftp = new FileTransferParam(hContact); - ftp->SetWorkingDirectory(filePath); - ftp->AddFile(filePath); - - mir_forkthreadowner(CDropbox::SendFilesAndEventAsync, this, 0, 0); - - return ftp->GetId(); -} - INT_PTR CDropbox::UploadToDropbox(WPARAM, LPARAM lParam) { DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam; FileTransferParam *ftp = new FileTransferParam(GetDefaultContact()); - ftp->SetWorkingDirectory(uploadInfo->localPath); - ftp->SetServerPath(uploadInfo->serverPath); + ftp->SetServerFolder(uploadInfo->serverFolder); if (PathIsDirectory(uploadInfo->localPath)) { @@ -205,9 +185,8 @@ INT_PTR CDropbox::UploadToDropboxAsync(WPARAM, LPARAM lParam) DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam; FileTransferParam *ftp = new FileTransferParam(GetDefaultContact()); - ftp->SetWorkingDirectory(uploadInfo->localPath); - ftp->SetServerPath(uploadInfo->serverPath); + ftp->SetServerFolder(uploadInfo->serverFolder); if (PathIsDirectory(uploadInfo->localPath)) { diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 15fd919598..4b54e4cd55 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -144,9 +144,12 @@ UINT CDropbox::UploadToDropbox(void *owner, void *arg) size = 0; char path[MAX_PATH]; - const TCHAR *serverPath = ftp->GetServerPath(); - if (serverPath) + const TCHAR *serverFolder = ftp->GetServerFolder(); + if (serverFolder) { + TCHAR serverPath[MAX_PATH] = { 0 }; + mir_sntprintf(serverPath, _T("%s\\%s"), serverFolder, fileName); PreparePath(serverPath, path); + } else PreparePath(fileName, path); instance->FinishUploadSession(data, size, sessionId, offset, path); @@ -170,44 +173,6 @@ UINT CDropbox::UploadToDropbox(void *owner, void *arg) return ACKRESULT_SUCCESS; } -UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg) -{ - CDropbox *instance = (CDropbox*)owner; - FileTransferParam *ftp = (FileTransferParam*)arg; - - int res = UploadToDropbox(owner, arg); - if (res == ACKRESULT_SUCCESS) - instance->Report(ftp->GetHContact(), ftp->GetData()); - - instance->transfers.remove(ftp); - delete ftp; - - return res; -} - -UINT CDropbox::SendFilesAndEventAsync(void *owner, void *arg) -{ - CDropbox *instance = (CDropbox*)owner; - FileTransferParam *ftp = (FileTransferParam*)arg; - - int res = UploadToDropbox(owner, arg); - - T2Utf data(ftp->GetData()); - char *pdata = data; - - TRANSFERINFO ti = { 0 }; - ti.hProcess = (HANDLE)ftp->GetId(); - ti.status = res; - ti.data = &pdata; - - NotifyEventHooks(instance->hFileSentEventHook, ftp->GetHContact(), (LPARAM)&ti); - - instance->transfers.remove(ftp); - delete ftp; - - return res; -} - UINT CDropbox::UploadAndReportProgress(void *owner, void *arg) { CDropbox *instance = (CDropbox*)owner; diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h index fed277289c..2d9156bcae 100644 --- a/plugins/Dropbox/src/file_transfer.h +++ b/plugins/Dropbox/src/file_transfer.h @@ -15,7 +15,7 @@ private: const TCHAR* folderName; int relativePathStart; - CMString serverPath; + CMString serverFolder; CMString data; @@ -96,17 +96,17 @@ public: folderName = _tcsrchr(path, '\\') + 1; } - void SetServerPath(const TCHAR *path) + void SetServerFolder(const TCHAR *path) { if (path) - serverPath = path; + serverFolder = path; } - const TCHAR* GetServerPath() const + const TCHAR* GetServerFolder() const { - if (serverPath.IsEmpty()) + if (serverFolder.IsEmpty()) return NULL; - return serverPath; + return serverFolder; } const TCHAR* GetFolderName() const @@ -120,11 +120,11 @@ public: pfts.ptszFiles[pfts.totalFiles++] = mir_tstrdup(path); pfts.ptszFiles[pfts.totalFiles] = NULL; - FILE *hFile = _tfopen(path, L"rb"); - if (hFile != NULL) { - _fseeki64(hFile, 0, SEEK_END); - pfts.totalBytes += _ftelli64(hFile); - fclose(hFile); + FILE *file = _tfopen(path, L"rb"); + if (file != NULL) { + _fseeki64(file, 0, SEEK_END); + pfts.totalBytes += _ftelli64(file); + fclose(file); } } @@ -161,9 +161,9 @@ public: rewind(hFile); } - size_t ReadCurrentFile(void *data, size_t count) + size_t ReadCurrentFile(void *buffer, size_t count) { - return fread(data, sizeof(char), count, hFile); + return fread(buffer, sizeof(char), count, hFile); } void CheckCurrentFile() diff --git a/plugins/Dropbox/src/stdafx.h b/plugins/Dropbox/src/stdafx.h index 46534f9e08..b83d80895b 100644 --- a/plugins/Dropbox/src/stdafx.h +++ b/plugins/Dropbox/src/stdafx.h @@ -43,8 +43,7 @@ class CDropbox; #define DROPBOX_API_CU "https://content.dropboxapi.com/" DROPBOX_API_VER #define DROPBOX_APP_KEY "fa8du7gkf2q8xzg" -#define DROPBOX_API_SECRET "bb8zirh7nnk8fow" -//#include "..\..\..\miranda-private-keys\Dropbox\secret_key.h" +#include "..\..\..\miranda-private-keys\Dropbox\secret_key.h" class DropboxException { -- cgit v1.2.3