summaryrefslogtreecommitdiff
path: root/plugins/CloudFile
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-12-09 23:39:16 +0300
committeraunsane <aunsane@gmail.com>2017-12-09 23:39:16 +0300
commit6d27acd0a57bc6a228f1b6dd2ce451c02cc7419c (patch)
treea82b4c833eb6cec7ec81942d611ae708c0da0702 /plugins/CloudFile
parent15d04b366b37563254f914a41db97646730514b9 (diff)
CloudFile: realized MS_DROPBOX_UPLOAD
Diffstat (limited to 'plugins/CloudFile')
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.cpp42
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.h2
-rw-r--r--plugins/CloudFile/src/file_transfer.h27
-rw-r--r--plugins/CloudFile/src/version.h2
4 files changed, 67 insertions, 6 deletions
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp
index f1157a52b2..51e3c9a3c9 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.cpp
+++ b/plugins/CloudFile/src/Services/dropbox_service.cpp
@@ -4,6 +4,7 @@
CDropboxService::CDropboxService(HNETLIBUSER hConnection)
: CCloudService(hConnection)
{
+ CreateServiceFunctionObj(MS_DROPBOX_UPLOAD, &CDropboxService::UploadToDropbox, this);
}
const char* CDropboxService::GetModule() const
@@ -234,7 +235,14 @@ UINT CDropboxService::Upload(FileTransferParam *ftp)
mir_ptr<char>chunk((char*)mir_calloc(chunkSize));
char path[MAX_PATH];
- PreparePath(fileName, path);
+ const wchar_t *serverFolder = ftp->GetServerFolder();
+ if (serverFolder) {
+ char serverPath[MAX_PATH] = { 0 };
+ mir_snprintf(serverPath, "%s\\%s", T2Utf(serverFolder), fileName);
+ PreparePath(serverPath, path);
+ }
+ else
+ PreparePath(fileName, path);
if (chunkSize == fileSize)
{
@@ -293,3 +301,35 @@ UINT CDropboxService::Upload(FileTransferParam *ftp)
ftp->SetStatus(ACKRESULT_SUCCESS);
return ACKRESULT_SUCCESS;
}
+
+INT_PTR CDropboxService::UploadToDropbox(void *obj, WPARAM wParam, LPARAM lParam)
+{
+ CDropboxService *self = (CDropboxService*)obj;
+ DropboxUploadInfo *uploadInfo = (DropboxUploadInfo*)lParam;
+
+ FileTransferParam *ftp = new FileTransferParam(0);
+ 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 = self->Upload(ftp);
+ if (res == ACKRESULT_SUCCESS && wParam) {
+ char **data = (char**)wParam;
+ *data = mir_utf8encodeW(ftp->GetData());
+ }
+
+ Transfers.remove(ftp);
+ delete ftp;
+
+ return res;
+}
diff --git a/plugins/CloudFile/src/Services/dropbox_service.h b/plugins/CloudFile/src/Services/dropbox_service.h
index 90dc11d259..1f123d2d5c 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.h
+++ b/plugins/CloudFile/src/Services/dropbox_service.h
@@ -28,6 +28,8 @@ public:
void Logout();
UINT Upload(FileTransferParam *ftp);
+
+ static INT_PTR UploadToDropbox(void*, WPARAM wParam, LPARAM lParam);
};
#endif //_CLOUDSERVICE_DROPBOX_H_ \ No newline at end of file
diff --git a/plugins/CloudFile/src/file_transfer.h b/plugins/CloudFile/src/file_transfer.h
index cdf4475aeb..cbe928eda9 100644
--- a/plugins/CloudFile/src/file_transfer.h
+++ b/plugins/CloudFile/src/file_transfer.h
@@ -12,6 +12,8 @@ private:
bool isTerminated;
+ CMStringW serverFolder;
+
const wchar_t* folderName;
int relativePathStart;
@@ -85,6 +87,19 @@ public:
isTerminated = true;
}
+ void SetServerFolder(const wchar_t *path)
+ {
+ if (path)
+ serverFolder = path;
+ }
+
+ const wchar_t* GetServerFolder() const
+ {
+ if (serverFolder.IsEmpty())
+ return NULL;
+ return serverFolder;
+ }
+
void SetWorkingDirectory(const wchar_t *path)
{
relativePathStart = wcsrchr(path, '\\') - path + 1;
@@ -193,7 +208,8 @@ public:
{
pfts.currentFileProgress += count;
pfts.totalProgress += count;
- ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&pfts);
+ if (pfts.hContact)
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&pfts);
}
void FirstFile()
@@ -203,7 +219,8 @@ public:
pfts.currentFileNumber = 0;
pfts.currentFileProgress = 0;
pfts.tszCurrentFile = wcsrchr(pfts.ptszFiles[pfts.currentFileNumber], '\\') + 1;
- ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&pfts);
+ if (pfts.hContact)
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&pfts);
OpenCurrentFile();
CheckCurrentFile();
@@ -218,7 +235,8 @@ public:
pfts.currentFileProgress = 0;
pfts.tszCurrentFile = wcsrchr(pfts.ptszFiles[pfts.currentFileNumber], '\\') + 1;
- ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, (HANDLE)id, 0);
+ if (pfts.hContact)
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, (HANDLE)id, 0);
OpenCurrentFile();
CheckCurrentFile();
@@ -228,7 +246,8 @@ public:
void SetStatus(int status, LPARAM param = 0)
{
- ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, status, (HANDLE)id, param);
+ if (pfts.hContact)
+ ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, status, (HANDLE)id, param);
}
};
diff --git a/plugins/CloudFile/src/version.h b/plugins/CloudFile/src/version.h
index 7a5ce87b09..23b1f2094f 100644
--- a/plugins/CloudFile/src/version.h
+++ b/plugins/CloudFile/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>