diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-03-12 11:29:59 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-03-12 11:29:59 +0000 |
commit | d8d1baa7d5c286c907d18d278738331debc0aabd (patch) | |
tree | c6733298324026d6bd4ec0278bd3888a8f8b8be5 | |
parent | fcdaeaff6d96bf8a93c4f3c3426eff3146146d58 (diff) |
Dropbox:
- fixed message with download link
- fixed minor bug in file uploading
git-svn-id: http://svn.miranda-ng.org/main/trunk@8570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Dropbox/src/dropbox_events.cpp | 27 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_services.cpp | 19 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_transfers.cpp | 26 | ||||
-rw-r--r-- | plugins/Dropbox/src/file_transfer.h | 3 |
4 files changed, 52 insertions, 23 deletions
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp index 69397d8608..a10917c236 100644 --- a/plugins/Dropbox/src/dropbox_events.cpp +++ b/plugins/Dropbox/src/dropbox_events.cpp @@ -186,26 +186,31 @@ int CDropbox::OnSendSuccessed(void *obj, WPARAM hContact, LPARAM lParam) if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
{
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.flags = DBEF_UTF;
- dbei.szModule = MODULE;
- dbei.timestamp = time(NULL);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = wcslen(data);
- dbei.pBlob = (PBYTE)mir_utf8encodeW(data);
-
+ char *message = mir_utf8encodeW(data);
if (hContact != instance->GetDefaultContact())
{
- if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)data) != ACKRESULT_FAILED)
+ if (CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)message) != ACKRESULT_FAILED)
{
- dbei.flags = DBEF_SENT | DBEF_READ | DBEF_UTF;
- db_event_add(hContact, &dbei);
+ PROTORECVEVENT recv = { 0 };
+ recv.flags = PREF_CREATEREAD | DBEF_UTF;
+ recv.timestamp = time(NULL);
+ recv.szMessage = message;
+ ProtoChainRecvMsg(hContact, &recv);
}
else
CallServiceSync(MS_MSG_SENDMESSAGEW, (WPARAM)hContact, (LPARAM)data);
}
else
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.flags = DBEF_UTF;
+ dbei.szModule = MODULE;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.cbBlob = wcslen(data);
+ dbei.pBlob = (PBYTE)message;
db_event_add(hContact, &dbei);
+ }
}
CMString urls = data; urls += L"\r\n";
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index b91ce2de5c..c8ab1957f7 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -62,7 +62,7 @@ INT_PTR CDropbox::ProtoSendFile(void *obj, WPARAM, LPARAM lParam) if (!ftp->relativePathStart)
{
wchar_t *rootFolder = paths[j];
- wchar_t *relativePath = wcsrchr(rootFolder, L'\\') + 1;
+ wchar_t *relativePath = wcsrchr(rootFolder, '\\') + 1;
ftp->relativePathStart = relativePath - rootFolder;
}
@@ -72,6 +72,16 @@ INT_PTR CDropbox::ProtoSendFile(void *obj, WPARAM, LPARAM lParam) }
else
{
+ if (!ftp->pfts.wszWorkingDir)
+ {
+ wchar_t *path = paths[j];
+ int length = wcsrchr(path, '\\') - path;
+ ftp->pfts.wszWorkingDir = (wchar_t*)mir_alloc(sizeof(wchar_t) * (length + 1));
+ lstrcpyn(ftp->pfts.wszWorkingDir, paths[j], length + 1);
+ ftp->pfts.wszWorkingDir[length] = '\0';
+
+ }
+
ftp->pfts.pwszFiles[k] = mir_wstrdup(paths[i]);
FILE *file = _wfopen(paths[i], L"rb");
@@ -189,7 +199,7 @@ INT_PTR CDropbox::SendFileToDropbox(void *obj, WPARAM hContact, LPARAM lParam) if (!instance->HasAccessToken())
return 0;
- const wchar_t *filePath = (wchar_t*)lParam;
+ wchar_t *filePath = (wchar_t*)lParam;
FileTransferParam *ftp = new FileTransferParam();
ftp->withVisualisation = false;
@@ -199,6 +209,11 @@ INT_PTR CDropbox::SendFileToDropbox(void *obj, WPARAM hContact, LPARAM lParam) ftp->hContact = (instance->hTransferContact) ? instance->hTransferContact : hContact;
instance->hTransferContact = 0;
+ int length = wcsrchr(filePath, '\\') - filePath;
+ ftp->pfts.wszWorkingDir = (wchar_t*)mir_alloc(sizeof(wchar_t) * (length + 1));
+ lstrcpyn(ftp->pfts.wszWorkingDir, filePath, length + 1);
+ ftp->pfts.wszWorkingDir[length] = '\0';
+
ftp->pfts.pwszFiles = (wchar_t**)mir_alloc(sizeof(wchar_t*) * (ftp->pfts.totalFiles + 1));
ftp->pfts.pwszFiles[0] = mir_wstrdup(filePath);
ftp->pfts.pwszFiles[ftp->pfts.totalFiles] = NULL;
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 6cce51ce4e..8ba7773f4b 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -211,9 +211,6 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) FILE *file = _wfopen(ftp->pfts.pwszFiles[i], L"rb");
if (file)
{
- int offset = 0;
- char *uploadId = new char[32];
-
const wchar_t *fileName = NULL;
if (!ftp->relativePathStart)
fileName = wcsrchr(ftp->pfts.pwszFiles[i], L'\\') + 1;
@@ -221,7 +218,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) fileName = &ftp->pfts.pwszFiles[i][ftp->relativePathStart];
fseek(file, 0, SEEK_END);
- DWORD fileSize = ftell(file);
+ size_t fileSize = ftell(file);
fseek(file, 0, SEEK_SET);
if (ftp->withVisualisation)
@@ -234,13 +231,22 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftp->hProcess, (LPARAM)&ftp->pfts);
}
- while (!feof(file) && !ferror(file))
+ int offset = 0;
+ char *uploadId = new char[32];
+
+ int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4;
+ if (fileSize < 1024 * 1024)
+ chunkSize = DROPBOX_FILE_CHUNK_SIZE / 20;
+ else if (fileSize > 20 * 1024 * 1024)
+ chunkSize = DROPBOX_FILE_CHUNK_SIZE;
+
+ while (!feof(file) && fileSize != offset)
{
- int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4;
- if (fileSize < 1024 * 1024)
- chunkSize = DROPBOX_FILE_CHUNK_SIZE / 20;
- else if (fileSize > 20 * 1024 * 1024)
- chunkSize = DROPBOX_FILE_CHUNK_SIZE;
+ if (ferror(file))
+ {
+ error = true;
+ break;
+ }
char *data = new char[chunkSize + 1];
int count = (int)fread(data, sizeof(char), chunkSize, file);
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h index 9dbaf97073..35d18bbf08 100644 --- a/plugins/Dropbox/src/file_transfer.h +++ b/plugins/Dropbox/src/file_transfer.h @@ -36,6 +36,9 @@ struct FileTransferParam ~FileTransferParam()
{
+ if (pfts.wszWorkingDir)
+ mir_free(pfts.wszWorkingDir);
+
if (pfts.pszFiles)
{
for (int i = 0; pfts.pszFiles[i]; i++)
|