summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dropbox/src/dropbox_utils.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp35
1 files changed, 13 insertions, 22 deletions
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);
}