summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_services.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <Mataes2007@gmail.com>2017-11-30 08:28:00 +0300
committerKirill Volinsky <Mataes2007@gmail.com>2017-11-30 08:28:53 +0300
commit0a95d1c9e2791898c03eab04a06932ec65f3a934 (patch)
treed6da4343c1926c92d2ffe2b5600ce92047aca449 /plugins/Dropbox/src/dropbox_services.cpp
parent4c1b34caa7f00625b944b58ec9d69f4670cc4595 (diff)
Dropbox moved to deprecated (use CloudFile)
Diffstat (limited to 'plugins/Dropbox/src/dropbox_services.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp227
1 files changed, 0 insertions, 227 deletions
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
deleted file mode 100644
index 5457883d60..0000000000
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-#include "stdafx.h"
-
-INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM)
-{
- switch (wParam) {
- case PFLAGNUM_1:
- return PF1_IM | PF1_FILESEND;
- case PFLAGNUM_2:
- return PF2_ONLINE;
- case PFLAGNUM_4:
- return PF4_OFFLINEFILES;
- }
-
- return 0;
-}
-
-INT_PTR CDropbox::ProtoGetName(WPARAM wParam, LPARAM lParam)
-{
- if (lParam) {
- mir_strncpy((char *)lParam, MODULE, wParam);
- return 0;
- }
-
- return 1;
-}
-
-INT_PTR CDropbox::ProtoLoadIcon(WPARAM wParam, LPARAM)
-{
- return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx(IDI_DROPBOX)) : 0;
-}
-
-INT_PTR CDropbox::ProtoGetStatus(WPARAM, LPARAM)
-{
- return HasAccessToken() ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
-}
-
-INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- if (!HasAccessToken()) {
- ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, nullptr, (LPARAM)"You cannot send files when you are not authorized.");
- return 0;
- }
-
- FileTransferParam *ftp = new FileTransferParam(pccsd->hContact);
-
- const wchar_t *description = (wchar_t*)pccsd->wParam;
- if (description && description[0])
- ftp->AppendFormatData(L"%s\r\n", (wchar_t*)pccsd->wParam);
-
- wchar_t **paths = (wchar_t**)pccsd->lParam;
- ftp->SetWorkingDirectory(paths[0]);
- for (int i = 0; paths[i]; i++) {
- if (PathIsDirectory(paths[i]))
- continue;
- ftp->AddFile(paths[i]);
- }
-
- transfers.insert(ftp);
-
- mir_forkthreadowner(CDropbox::UploadAndReportProgress, this, ftp, nullptr);
-
- return ftp->GetId();
-}
-
-INT_PTR CDropbox::ProtoSendFileInterceptor(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- const char *proto = GetContactProto(pccsd->hContact);
- if (!IsAccountIntercepted(proto))
- {
- auto it = interceptedContacts.find(pccsd->hContact);
- if (it == interceptedContacts.end())
- return CALLSERVICE_NOTFOUND;
- }
-
- auto it = interceptedContacts.find(pccsd->hContact);
- if (it != interceptedContacts.end())
- interceptedContacts.erase(it);
-
- return ProtoSendFile(wParam, lParam);
-}
-
-INT_PTR CDropbox::ProtoCancelFile(WPARAM, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- HANDLE hTransfer = (HANDLE)pccsd->wParam;
- FileTransferParam *ftp = transfers.find((FileTransferParam*)&hTransfer);
- if (ftp == nullptr)
- return 0;
-
- ftp->Terminate();
-
- return 0;
-}
-
-INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- if (!HasAccessToken()) {
- ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, nullptr, (LPARAM)"You cannot send messages when you are not authorized.");
- return 0;
- }
-
- char *szMessage = (char*)pccsd->lParam;
- if (*szMessage == '/') {
- // parse commands
- char *sep = strchr(szMessage, ' ');
-
- struct
- {
- const char *szCommand;
- pThreadFunc pHandler;
- }
- static commands[] =
- {
- { "help", &CDropbox::CommandHelp },
- { "list", &CDropbox::CommandList },
- { "share", &CDropbox::CommandShare },
- { "search", &CDropbox::CommandSearch },
- { "delete", &CDropbox::CommandDelete }
- };
-
- char command[16] = {0};
- mir_strncpy(command, szMessage + 1, sep ? sep - szMessage : mir_strlen(szMessage));
- for (int i = 0; i < _countof(commands); i++) {
- if (!mir_strcmp(command, commands[i].szCommand)) {
- ULONG messageId = InterlockedIncrement(&hMessageProcess);
-
- CommandParam *param = new CommandParam();
- param->instance = this;
- param->hContact = pccsd->hContact;
- param->hProcess = (HANDLE)messageId;
- param->data = (sep ? sep + 1 : NULL);
-
- mir_forkthread(commands[i].pHandler, param);
-
- return messageId;
- }
- }
- }
-
- ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, nullptr, 0);
- char help[1024];
- mir_snprintf(help, Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), szMessage);
- ProtoChainSend(GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)help);
- return 0;
-}
-
-INT_PTR CDropbox::ProtoReceiveMessage(WPARAM, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- char *message = (char*)pccsd->lParam;
-
- DBEVENTINFO dbei = {};
- dbei.flags = DBEF_UTF;
- dbei.szModule = MODULE;
- dbei.timestamp = time(nullptr);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (int)mir_strlen(message);
- dbei.pBlob = (PBYTE)mir_strdup(message);
- db_event_add(pccsd->hContact, &dbei);
-
- return 0;
-}
-
-INT_PTR CDropbox::UploadToDropbox(WPARAM wParam, LPARAM lParam)
-{
- DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam;
-
- FileTransferParam *ftp = new FileTransferParam(GetDefaultContact());
- ftp->SetWorkingDirectory(uploadInfo->localPath);
- ftp->SetServerFolder(uploadInfo->serverFolder);
-
- if (PathIsDirectory(uploadInfo->localPath))
- {
- // temporary unsupported
-
- transfers.remove(ftp);
- delete ftp;
-
- return ACKRESULT_FAILED;
- }
- else
- ftp->AddFile(uploadInfo->localPath);
-
- int res = UploadToDropbox(this, ftp);
- if (res == ACKRESULT_SUCCESS && wParam) {
- char **data = (char**)wParam;
- *data = mir_utf8encodeW(ftp->GetData());
- }
-
- transfers.remove(ftp);
- delete ftp;
-
- return res;
-}
-
-INT_PTR CDropbox::UploadToDropboxAsync(WPARAM, LPARAM lParam)
-{
- DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam;
-
- FileTransferParam *ftp = new FileTransferParam(GetDefaultContact());
- ftp->SetWorkingDirectory(uploadInfo->localPath);
- ftp->SetServerFolder(uploadInfo->serverFolder);
-
- if (PathIsDirectory(uploadInfo->localPath))
- {
- // temporary unsupported
-
- transfers.remove(ftp);
- delete ftp;
-
- return NULL;
- }
- else
- ftp->AddFile(uploadInfo->localPath);
-
- mir_forkthreadowner(CDropbox::UploadAndRaiseEvent, this, ftp, nullptr);
-
- return ftp->GetId();
-} \ No newline at end of file