diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-26 18:15:28 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-26 18:15:28 +0000 |
commit | 134773092963feea383ea315604bd1b996cdc6c5 (patch) | |
tree | 95ff0a97ebb7eaffee495e815004ea20f3537c79 /plugins | |
parent | bac49aec1a9a616cd3393048419e68ce176eee5f (diff) |
Dropbox: fixed folder sending
git-svn-id: http://svn.miranda-ng.org/main/trunk@16350 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Dropbox/src/dropbox.h | 8 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_services.cpp | 4 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_transfers.cpp | 20 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_utils.cpp | 35 | ||||
-rw-r--r-- | plugins/Dropbox/src/file_transfer.h | 46 |
5 files changed, 52 insertions, 61 deletions
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index 5f9ff2e6b5..ee17d2e070 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -120,10 +120,10 @@ private: static MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD cbBlob, PBYTE pBlob);
- void SendToContact(MCONTACT hContact, const char *data, const TCHAR *description = NULL);
- void PasteToInputArea(MCONTACT hContact, const char *data, const TCHAR *description = NULL);
- void PasteToClipboard(const char *data, const TCHAR *description = NULL);
- void Report(MCONTACT hContact, const char *data, const TCHAR *description = NULL);
+ void SendToContact(MCONTACT hContact, const TCHAR *data);
+ void PasteToInputArea(MCONTACT hContact, const TCHAR *data);
+ void PasteToClipboard(const TCHAR *data);
+ void Report(MCONTACT hContact, const TCHAR *data);
template<int(CDropbox::*Event)(WPARAM, LPARAM)>
static int GlobalEvent(void *obj, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index c539855398..7469521487 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -57,7 +57,9 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam) ftp->hContact = (hTransferContact) ? hTransferContact : pccsd->hContact;
hTransferContact = 0;
- ftp->SetDescription((TCHAR*)pccsd->wParam);
+ const TCHAR *description = (TCHAR*)pccsd->wParam;
+ if (description && description[0])
+ ftp->AppendFormatData(_T("%s\r\n"), (TCHAR*)pccsd->wParam);
TCHAR **paths = (TCHAR**)pccsd->lParam;
ftp->SetWorkingDirectory(paths[0]);
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 2a0b713ec8..6956bcb3ab 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -96,6 +96,14 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) FileTransferParam *ftp = (FileTransferParam*)arg;
try {
+ if (ftp->directoryName) {
+ char path[MAX_PATH], url[MAX_PATH];
+ PreparePath(ftp->directoryName, path);
+ instance->CreateFolder(path);
+ instance->CreateDownloadUrl(path, url);
+ ftp->AppendFormatData(_T("%s\r\n"), ptrT(mir_utf8decodeT(url)));
+ }
+
ftp->FirstFile();
do
{
@@ -138,7 +146,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) if (!_tcschr(fileName, L'\\')) {
char url[MAX_PATH];
instance->CreateDownloadUrl(path, url);
- ftp->AddUrl(url);
+ ftp->AppendFormatData(_T("%s\r\n"), ptrT(mir_utf8decodeT(url)));
}
} while (ftp->NextFile());
}
@@ -159,13 +167,7 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg) int res = SendFilesAsync(owner, arg);
if (res == ACKRESULT_SUCCESS)
- {
- CMStringA urls;
- for (int i = 0; i < ftp->urls.getCount(); i++)
- urls.AppendFormat("%s\r\n", ftp->urls[i]);
-
- instance->Report(ftp->hContact, urls.GetBuffer(), ftp->description);
- }
+ instance->Report(ftp->hContact, ftp->data);
instance->transfers.remove(ftp);
delete ftp;
@@ -183,7 +185,7 @@ UINT CDropbox::SendFilesAndEventAsync(void *owner, void *arg) TRANSFERINFO ti = { 0 };
ti.hProcess = ftp->hProcess;
ti.status = res;
- ti.data = ftp->urls.getArray();
+ //ti.data = T2Utf(data);
NotifyEventHooks(instance->hFileSentEventHook, ftp->hContact, (LPARAM)&ti);
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp index 6f110c5928..c1db7705d6 100644 --- a/plugins/Dropbox/src/dropbox_utils.cpp +++ b/plugins/Dropbox/src/dropbox_utils.cpp @@ -80,10 +80,10 @@ MEVENT CDropbox::AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD c return db_event_add(hContact, &dbei);
}
-void CDropbox::SendToContact(MCONTACT hContact, const char *data, const TCHAR *description)
+void CDropbox::SendToContact(MCONTACT hContact, const TCHAR *data)
{
if (hContact == GetDefaultContact()) {
- char *message = mir_utf8encode(data);
+ char *message = mir_utf8encodeT(data);
AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF, (DWORD)mir_strlen(message), (PBYTE)message);
return;
}
@@ -95,24 +95,20 @@ void CDropbox::SendToContact(MCONTACT hContact, const char *data, const TCHAR *d GCEVENT gce = { sizeof(gce), &gcd };
gce.bIsMe = TRUE;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = mir_utf8decodeT(data);
+ gce.ptszText = mir_tstrdup(data);
gce.time = time(NULL);
CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
mir_free((void*)gce.ptszText);
return;
}
- if (description != NULL && CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)T2Utf(description)) != ACKRESULT_FAILED) {
- char *message = mir_utf8encodeT(description);
- AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message);
- }
if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)data) != ACKRESULT_FAILED) {
- char *message = mir_utf8encode(data);
+ char *message = mir_utf8encodeT(data);
AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message);
}
}
-void CDropbox::PasteToInputArea(MCONTACT hContact, const char *data, const TCHAR *description)
+void CDropbox::PasteToInputArea(MCONTACT hContact, const TCHAR *data)
{
MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
mwid.hContact = hContact;
@@ -123,26 +119,21 @@ void CDropbox::PasteToInputArea(MCONTACT hContact, const char *data, const TCHAR HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
- TCHAR text[4096] = {0};
- mir_sntprintf(text, _T("%s%s%s"), description, description == NULL ? _T("") : _T("\r\n"), ptrT(mir_utf8decodeT(data)));
- SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)text);
+ SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)data);
}
}
-void CDropbox::PasteToClipboard(const char *data, const TCHAR *description)
+void CDropbox::PasteToClipboard(const TCHAR *data)
{
if (OpenClipboard(NULL)) {
EmptyClipboard();
- TCHAR text[4096] = { 0 };
- mir_sntprintf(text, _T("%s%s%s"), description, description == NULL ? _T("") : _T("\r\n"), _A2T(data));
-
- size_t size = sizeof(TCHAR) * (mir_tstrlen(text) + 1);
+ size_t size = sizeof(TCHAR) * (mir_tstrlen(data) + 1);
HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
if (hClipboardData) {
TCHAR *pchData = (TCHAR*)GlobalLock(hClipboardData);
if (pchData) {
- memcpy(pchData, (TCHAR*)text, size);
+ memcpy(pchData, (TCHAR*)data, size);
GlobalUnlock(hClipboardData);
SetClipboardData(CF_TEXT, hClipboardData);
}
@@ -151,14 +142,14 @@ void CDropbox::PasteToClipboard(const char *data, const TCHAR *description) }
}
-void CDropbox::Report(MCONTACT hContact, const char *data, const TCHAR *description)
+void CDropbox::Report(MCONTACT hContact, const TCHAR *data)
{
if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
- SendToContact(hContact, data, description);
+ SendToContact(hContact, data);
if (db_get_b(NULL, MODULE, "UrlPasteToMessageInputArea", 0))
- PasteToInputArea(hContact, data, description);
+ PasteToInputArea(hContact, data);
if (db_get_b(NULL, MODULE, "UrlCopyToClipboard", 0))
- PasteToClipboard(data, description);
+ PasteToClipboard(data);
}
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h index 24c4735f6e..ec81ded7b0 100644 --- a/plugins/Dropbox/src/file_transfer.h +++ b/plugins/Dropbox/src/file_transfer.h @@ -10,13 +10,12 @@ struct FileTransferParam bool isTerminated;
+ const TCHAR* directoryName;
int relativePathStart;
- LIST<char> urls;
+ CMString data;
- TCHAR *description;
-
- FileTransferParam() : urls(1)
+ FileTransferParam()
{
hFile = NULL;
hProcess = NULL;
@@ -24,6 +23,7 @@ struct FileTransferParam isTerminated = false;
+ directoryName = NULL;
relativePathStart = 0;
pfts.cbSize = sizeof(this->pfts);
@@ -40,8 +40,6 @@ struct FileTransferParam pfts.ptszFiles[pfts.totalFiles] = NULL;
pfts.tszWorkingDir = NULL;
pfts.tszCurrentFile = NULL;
-
- description = NULL;
ProtoBroadcastAck(MODULE, pfts.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, hProcess, 0);
}
@@ -61,28 +59,23 @@ struct FileTransferParam }
mir_free(pfts.pszFiles);
}
-
- for (int i = 0; i < urls.getCount(); i++)
- mir_free(urls[i]);
- urls.destroy();
-
- if (description)
- mir_free(description);
- }
-
- void SetDescription(const TCHAR *text)
- {
- if (text[0] == 0)
- return;
- description = mir_tstrdup(text);
}
void SetWorkingDirectory(const TCHAR *path)
{
relativePathStart = _tcsrchr(path, '\\') - path + 1;
- pfts.tszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * relativePathStart);
- mir_tstrncpy(pfts.tszWorkingDir, path, relativePathStart);
- pfts.tszWorkingDir[relativePathStart - 1] = '\0';
+ if (PathIsDirectory(path))
+ {
+ size_t length = mir_tstrlen(path) + 1;
+ pfts.tszWorkingDir = (TCHAR*)mir_calloc(sizeof(TCHAR) * length);
+ mir_tstrncpy(pfts.tszWorkingDir, path, length);
+ directoryName = _tcsrchr(pfts.tszWorkingDir, '\\') + 1;
+ }
+ else
+ {
+ pfts.tszWorkingDir = (TCHAR*)mir_calloc(sizeof(TCHAR) * relativePathStart);
+ mir_tstrncpy(pfts.tszWorkingDir, path, relativePathStart);
+ }
}
void AddFile(const TCHAR *path)
@@ -99,9 +92,12 @@ struct FileTransferParam }
}
- void AddUrl(const char *url)
+ void AppendFormatData(const TCHAR *format, ...)
{
- urls.insert(mir_strdup(url));
+ va_list args;
+ va_start(args, format);
+ data.AppendFormatV(format, args);
+ va_end(args);
}
const TCHAR* GetCurrentFilePath() const
|