summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Dropbox/src/dropbox.h8
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp2
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp2
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp29
-rw-r--r--plugins/Dropbox/src/file_transfer.h14
5 files changed, 40 insertions, 15 deletions
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h
index dba4681042..5f9ff2e6b5 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);
- void PasteToInputArea(MCONTACT hContact, const char* data);
- void PasteToClipboard(const char* data);
- void Report(MCONTACT hContact, const char* data);
+ 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);
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 92f7a5abae..c539855398 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -57,6 +57,8 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
ftp->hContact = (hTransferContact) ? hTransferContact : pccsd->hContact;
hTransferContact = 0;
+ ftp->SetDescription((TCHAR*)pccsd->wParam);
+
TCHAR **paths = (TCHAR**)pccsd->lParam;
ftp->SetWorkingDirectory(paths[0]);
for (int i = 0; paths[i]; i++) {
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index f094f7814b..2a0b713ec8 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -164,7 +164,7 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
for (int i = 0; i < ftp->urls.getCount(); i++)
urls.AppendFormat("%s\r\n", ftp->urls[i]);
- instance->Report(ftp->hContact, urls.GetBuffer());
+ instance->Report(ftp->hContact, urls.GetBuffer(), ftp->description);
}
instance->transfers.remove(ftp);
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index c6f029be0d..6f110c5928 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -80,7 +80,7 @@ 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)
+void CDropbox::SendToContact(MCONTACT hContact, const char *data, const TCHAR *description)
{
if (hContact == GetDefaultContact()) {
char *message = mir_utf8encode(data);
@@ -102,13 +102,17 @@ void CDropbox::SendToContact(MCONTACT hContact, const char* data)
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);
AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message);
}
}
-void CDropbox::PasteToInputArea(MCONTACT hContact, const char* data)
+void CDropbox::PasteToInputArea(MCONTACT hContact, const char *data, const TCHAR *description)
{
MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
mwid.hContact = hContact;
@@ -119,21 +123,26 @@ void CDropbox::PasteToInputArea(MCONTACT hContact, const char* data)
HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
- ptrT text(mir_utf8decodeT(data));
+ 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);
}
}
-void CDropbox::PasteToClipboard(const char* data)
+void CDropbox::PasteToClipboard(const char *data, const TCHAR *description)
{
if (OpenClipboard(NULL)) {
EmptyClipboard();
- size_t size = sizeof(TCHAR) * (mir_strlen(data) + 1);
+
+ 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);
HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
if (hClipboardData) {
TCHAR *pchData = (TCHAR*)GlobalLock(hClipboardData);
if (pchData) {
- memcpy(pchData, (TCHAR*)data, size);
+ memcpy(pchData, (TCHAR*)text, size);
GlobalUnlock(hClipboardData);
SetClipboardData(CF_TEXT, hClipboardData);
}
@@ -142,14 +151,14 @@ void CDropbox::PasteToClipboard(const char* data)
}
}
-void CDropbox::Report(MCONTACT hContact, const char* data)
+void CDropbox::Report(MCONTACT hContact, const char *data, const TCHAR *description)
{
if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
- SendToContact(hContact, data);
+ SendToContact(hContact, data, description);
if (db_get_b(NULL, MODULE, "UrlPasteToMessageInputArea", 0))
- PasteToInputArea(hContact, data);
+ PasteToInputArea(hContact, data, description);
if (db_get_b(NULL, MODULE, "UrlCopyToClipboard", 0))
- PasteToClipboard(data);
+ PasteToClipboard(data, description);
}
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h
index f63483d46f..24c4735f6e 100644
--- a/plugins/Dropbox/src/file_transfer.h
+++ b/plugins/Dropbox/src/file_transfer.h
@@ -14,6 +14,8 @@ struct FileTransferParam
LIST<char> urls;
+ TCHAR *description;
+
FileTransferParam() : urls(1)
{
hFile = NULL;
@@ -38,6 +40,8 @@ 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,6 +65,16 @@ struct FileTransferParam
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)