diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-03-04 16:59:35 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-03-04 16:59:35 +0000 |
commit | 6d02559b3c3cb05cfc6a0ade5c4815dda4427834 (patch) | |
tree | 1233d2f09a0c7e25c045ccae29edb6cc88e4efc4 | |
parent | 03c5cb9df33ae92ac85e045fd9c7c5b9adf294b3 (diff) |
Dropbox: removed old service
git-svn-id: http://svn.miranda-ng.org/main/trunk@16420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Dropbox/src/dropbox.cpp | 4 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox.h | 6 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_services.cpp | 25 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_transfers.cpp | 45 | ||||
-rw-r--r-- | plugins/Dropbox/src/file_transfer.h | 26 | ||||
-rw-r--r-- | plugins/Dropbox/src/stdafx.h | 3 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_dropbox.h | 24 |
7 files changed, 23 insertions, 110 deletions
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
{
diff --git a/plugins/ExternalAPI/m_dropbox.h b/plugins/ExternalAPI/m_dropbox.h index f67a781086..feeb37181b 100644 --- a/plugins/ExternalAPI/m_dropbox.h +++ b/plugins/ExternalAPI/m_dropbox.h @@ -1,32 +1,10 @@ #ifndef M_DROPBOX_H_
#define M_DROPBOX_H_
-// upload file on Dropbox
-// wParam = (MCONTACT)hContact - NULL to send to the Dropbox contact
-// lParam = (LPARAM)(const wchar_t*)path - full path to file
-// returns file htansfer handle or NULL on failure
-// returns immediately, without waiting for the send
-// note, that you can track progress by using ME_PROTO_ACK
-#define MS_DROPBOX_SEND_FILE "Dropbox/Send/File"
-
-// if you want to get download links of sent files
-// use ME_DROPBOX_SENT hook. you'll get:
-struct TRANSFERINFO
-{
- HANDLE hProcess; // hProcess
- int status; // status of transfer. 0 on success otherwise fail
- char** data; // NULL ended array of download links
-};
-
-// notifies a caller that file has been sent
-// wParam = (MCONTACT)hContact
-// lParam = (LPARAM)(TRANSFERINFO*)info - transfer info
-#define ME_DROPBOX_SENT "Dropbox/Sent/Event"
-
struct DropboxUploadInfo
{
const TCHAR *localPath; // local path
- const TCHAR *serverPath; // relative path on server (can be NULL)
+ const TCHAR *serverFolder; // server folder in witch file will be placed (can be NULL)
};
// upload file on Dropbox
|