diff options
-rw-r--r-- | protocols/Gadu-Gadu/core.cpp | 45 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/filetransfer.cpp | 33 | ||||
-rw-r--r-- | protocols/IRCG/commandmonitor.cpp | 2 | ||||
-rw-r--r-- | protocols/IcqOscarJ/icq_filerequests.cpp | 45 | ||||
-rw-r--r-- | protocols/IcqOscarJ/oscar_filetransfer.cpp | 33 | ||||
-rw-r--r-- | protocols/Yahoo/file_transfer.cpp | 57 |
6 files changed, 94 insertions, 121 deletions
diff --git a/protocols/Gadu-Gadu/core.cpp b/protocols/Gadu-Gadu/core.cpp index 5ed36c8eaf..48662e00df 100644 --- a/protocols/Gadu-Gadu/core.cpp +++ b/protocols/Gadu-Gadu/core.cpp @@ -1020,33 +1020,24 @@ retry: //////////////////////////////////////////////////
// Add file recv request
- {
- CCSDATA ccs;
- PROTORECVEVENT pre;
- char *szBlob;
- char *szFilename = (char*)dcc7->filename;
- char *szMsg = (char*)dcc7->filename;
- netlog("gg_mainthread(%x): Client: %d, File ack filename \"%s\" size %d.", this, dcc7->peer_uin,
- dcc7->filename, dcc7->size);
- // Make new ggtransfer struct
- szBlob = (char *)malloc(sizeof(DWORD) + strlen(szFilename) + strlen(szMsg) + 2);
- // Store current dcc
- *(PDWORD)szBlob = (DWORD)dcc7;
- // Store filename
- strcpy(szBlob + sizeof(DWORD), szFilename);
- // Store description
- strcpy(szBlob + sizeof(DWORD) + strlen(szFilename) + 1, szMsg);
- ccs.szProtoService = PSR_FILE;
- ccs.hContact = dcc7->contact;
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)⪯
- pre.flags = 0;
- pre.timestamp = time(NULL);
- pre.szMessage = szBlob;
- pre.lParam = 0;
- CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
- free(szBlob);
- }
+
+ netlog("gg_mainthread(%x): Client: %d, File ack filename \"%s\" size %d.", this, dcc7->peer_uin,
+ dcc7->filename, dcc7->size);
+
+ TCHAR* filenameT = mir_utf8decodeT((char*)dcc7->filename);
+
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = filenameT;
+ pre.ptszFiles = &filenameT;
+ pre.lParam = (LPARAM)dcc7;
+
+ CCSDATA ccs = { dcc7->contact, PSR_FILE, 0, (LPARAM)&pre };
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
+
+ mir_free(filenameT);
e->event.dcc7_new = NULL;
}
break;
diff --git a/protocols/Gadu-Gadu/filetransfer.cpp b/protocols/Gadu-Gadu/filetransfer.cpp index 0637273ddb..e7560e16a2 100644 --- a/protocols/Gadu-Gadu/filetransfer.cpp +++ b/protocols/Gadu-Gadu/filetransfer.cpp @@ -355,31 +355,22 @@ void __cdecl GGPROTO::dccmainthread(void*) //////////////////////////////////////////////////
// Add file recv request
{
- CCSDATA ccs;
- PROTORECVEVENT pre;
- char *szBlob;
- char *szFilename = (char*)dcc->file_info.filename;
- char *szMsg = (char*)dcc->file_info.filename;
-
// Make new ggtransfer struct
dcc->contact = getcontact(dcc->peer_uin, 0, 0, NULL);
- szBlob = (char *)malloc(sizeof(DWORD) + strlen(szFilename) + strlen(szMsg) + 2);
- // Store current dcc
- *(PDWORD)szBlob = (DWORD)dcc;
- // Store filename
- strcpy(szBlob + sizeof(DWORD), szFilename);
- // Store description
- strcpy(szBlob + sizeof(DWORD) + strlen(szFilename) + 1, szMsg);
- ccs.szProtoService = PSR_FILE;
- ccs.hContact = dcc->contact;
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)⪯
- pre.flags = 0;
+ TCHAR* filenameT = mir_utf8decodeT((char*)dcc->file_info.filename);
+
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
pre.timestamp = time(NULL);
- pre.szMessage = szBlob;
- pre.lParam = 0;
+ pre.tszDescription = filenameT;
+ pre.ptszFiles = &filenameT;
+ pre.lParam = (LPARAM)dcc7;
+
+ CCSDATA ccs = { dcc7->contact, PSR_FILE, 0, (LPARAM)&pre };
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
- free(szBlob);
+
+ mir_free(filenameT);
}
break;
diff --git a/protocols/IRCG/commandmonitor.cpp b/protocols/IRCG/commandmonitor.cpp index 5ec96c61e6..842db74ea1 100644 --- a/protocols/IRCG/commandmonitor.cpp +++ b/protocols/IRCG/commandmonitor.cpp @@ -1185,7 +1185,7 @@ bool CIrcProto::IsCTCP( const CIrcMessage* pmsg ) ccs.szProtoService = PSR_FILE;
ccs.hContact = hContact;
ccs.lParam = (LPARAM) & pre;
- CallService( MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs );
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
} } }
// end type == "send"
}
diff --git a/protocols/IcqOscarJ/icq_filerequests.cpp b/protocols/IcqOscarJ/icq_filerequests.cpp index af9e0f3bd7..7560f613e5 100644 --- a/protocols/IcqOscarJ/icq_filerequests.cpp +++ b/protocols/IcqOscarJ/icq_filerequests.cpp @@ -124,13 +124,8 @@ filetransfer* CIcqProto::CreateFileTransfer(HANDLE hContact, DWORD dwUin, int nV // buf points to the first data after the string
void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCookie, DWORD dwID1, DWORD dwID2, char* pszDescription, int nVersion, BOOL bDC)
{
- char *pszFileName = NULL;
- DWORD dwFileSize;
- WORD wFilenameLength;
BOOL bEmptyDesc = FALSE;
-
- if (strlennull(pszDescription) == 0)
- {
+ if (strlennull(pszDescription) == 0) {
pszDescription = Translate("No description given");
bEmptyDesc = TRUE;
}
@@ -140,22 +135,21 @@ void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCoo wLen -= 4;
// Filename
+ WORD wFilenameLength;
unpackLEWord(&buf, &wFilenameLength);
- if (wFilenameLength > 0)
- {
- pszFileName = (char*)_alloca(wFilenameLength + 1);
- unpackString(&buf, pszFileName, wFilenameLength);
- pszFileName[wFilenameLength] = '\0';
- }
- else
- {
+ if (!wFilenameLength) {
NetLog_Direct("Ignoring malformed file send request");
return;
}
+
+ char *pszFileName = (char*)_alloca(wFilenameLength + 1);
+ unpackString(&buf, pszFileName, wFilenameLength);
+ pszFileName[wFilenameLength] = '\0';
wLen = wLen - 2 - wFilenameLength;
// Total filesize
+ DWORD dwFileSize;
unpackLEDWord(&buf, &dwFileSize);
wLen -= 4;
@@ -174,17 +168,16 @@ void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCoo ft->bDC = bDC;
ft->bEmptyDesc = bEmptyDesc;
- // Send chain event
- char *szBlob = (char*)_alloca(sizeof(DWORD) + strlennull(pszFileName) + strlennull(pszDescription) + 2);
- *(PDWORD)szBlob = 0;
- strcpy(szBlob + sizeof(DWORD), pszFileName);
- strcpy(szBlob + sizeof(DWORD) + strlennull(pszFileName) + 1, pszDescription);
+ // Send chain event
+ TCHAR* ptszFileName = mir_a2t(pszFileName);
- PROTORECVEVENT pre;
- pre.flags = 0;
- pre.timestamp = time(NULL);
- pre.szMessage = szBlob;
- pre.lParam = (LPARAM)ft;
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = mir_a2t(pszDescription);
+ pre.ptszFiles = &ptszFileName;
+ pre.lParam = (LPARAM)ft;
CCSDATA ccs;
ccs.szProtoService = PSR_FILE;
@@ -192,8 +185,10 @@ void CIcqProto::handleFileRequest(PBYTE buf, WORD wLen, DWORD dwUin, DWORD dwCoo ccs.wParam = 0;
ccs.lParam = (LPARAM)⪯
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
-}
+ mir_free(pre.tszDescription);
+ mir_free(ptszFileName);
+}
void CIcqProto::handleDirectCancel(directconnect *dc, PBYTE buf, WORD wLen, WORD wCommand, DWORD dwCookie, WORD wMessageType, WORD wStatus, WORD wFlags, char* pszText)
{
diff --git a/protocols/IcqOscarJ/oscar_filetransfer.cpp b/protocols/IcqOscarJ/oscar_filetransfer.cpp index 8a0db9a6f3..a1f516d363 100644 --- a/protocols/IcqOscarJ/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/oscar_filetransfer.cpp @@ -515,19 +515,15 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz else // or empty directory name
pszFileName = "";
- { // apply Filename / Directory Name encoding
- oscar_tlv* charset = chain->getTLV(0x2712, 1);
-
- if (charset)
- {
- char* szEnc = (char*)_alloca(charset->wLen + 1);
-
- null_strcpy(szEnc, (char*)charset->pData, charset->wLen);
- pszFileName = ApplyEncoding(pszFileName, szEnc);
- }
- else
- pszFileName = ansi_to_utf8(pszFileName);
+ // apply Filename / Directory Name encoding
+ oscar_tlv* charset = chain->getTLV(0x2712, 1);
+ if (charset) {
+ char* szEnc = (char*)_alloca(charset->wLen + 1);
+ null_strcpy(szEnc, (char*)charset->pData, charset->wLen);
+ pszFileName = ApplyEncoding(pszFileName, szEnc);
}
+ else pszFileName = ansi_to_utf8(pszFileName);
+
if (ft->wFilesCount == 1)
{ // Filename - use for DB event
char *szFileName = (char*)_alloca(strlennull(pszFileName) + 1);
@@ -570,10 +566,14 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz strcpy(szBlob + sizeof(DWORD), pszFileName);
strcpy(szBlob + sizeof(DWORD) + strlennull(pszFileName) + 1, pszDescription);
- PROTORECVEVENT pre;
- pre.flags = PREF_UTF;
+ TCHAR* ptszFileName = mir_a2t(pszFileName);
+
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
pre.timestamp = time(NULL);
- pre.szMessage = szBlob;
+ pre.tszDescription = mir_a2t(pszDescription);
+ pre.ptszFiles = &ptszFileName;
pre.lParam = (LPARAM)ft;
CCSDATA ccs;
@@ -582,6 +582,9 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, WORD wLen, DWORD dwUin, char *sz ccs.wParam = 0;
ccs.lParam = (LPARAM)⪯
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
+
+ mir_free(pre.tszDescription);
+ mir_free(ptszFileName);
}
else if (wAckType == 2)
{ // First attempt failed, reverse requested
diff --git a/protocols/Yahoo/file_transfer.cpp b/protocols/Yahoo/file_transfer.cpp index 85f091b81c..be896a4363 100644 --- a/protocols/Yahoo/file_transfer.cpp +++ b/protocols/Yahoo/file_transfer.cpp @@ -480,19 +480,13 @@ void __cdecl CYahooProto::recv_filethread(void *psf) void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize, const char *ft_token, int y7)
{
- HANDLE hContact;
- char *szBlob;
- y_filetransfer *ft;
- char fn[1024];
- struct yahoo_file_info *fi;
- YList *files=NULL;
-
LOG(("[ext_yahoo_got_file] ident:%s, who: %s, url: %s, expires: %lu, msg: %s, fname: %s, fsize: %lu ftoken: %s y7: %d", me, who, url, expires, msg, fname, fesize, ft_token == NULL ? "NULL" : ft_token, y7));
- hContact = getbuddyH(who);
+ HANDLE hContact = getbuddyH(who);
if (hContact == NULL)
hContact = add_buddy(who, who, 0 /* NO FT for other IMs */, PALF_TEMPORARY);
+ char fn[1024];
ZeroMemory(fn, 1024);
if (fname != NULL)
@@ -513,28 +507,27 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, lstrcpyA(fn, "filename.ext");
}
- fi = y_new(struct yahoo_file_info,1);
+ yahoo_file_info *fi = y_new(struct yahoo_file_info,1);
fi->filename = strdup(fn);
fi->filesize = fesize;
- files = y_list_append(files, fi);
+ YList *files = NULL;
+ y_list_append(files, fi);
- ft = new_ft(this, m_id, hContact, who, msg, url, ft_token, y7, files, 0 /* downloading */);
+ y_filetransfer *ft = new_ft(this, m_id, hContact, who, msg, url, ft_token, y7, files, 0 /* downloading */);
if (ft == NULL) {
DebugLog("SF IS NULL!!!");
return;
}
- // blob is DWORD(*ft), ASCIIZ(filenames), ASCIIZ(description)
- szBlob = (char *) malloc(sizeof(DWORD) + lstrlenA(fn) + lstrlenA(ft->msg) + 2);
- *((PDWORD) szBlob) = 0;
- strcpy(szBlob + sizeof(DWORD), fn);
- strcpy(szBlob + sizeof(DWORD) + lstrlenA(fn) + 1, ft->msg);
+ TCHAR* ptszFileName = mir_a2t(fn);
- PROTORECVEVENT pre;
- pre.flags = PREF_UTF;
- pre.timestamp = (DWORD)time(NULL);
- pre.szMessage = szBlob;
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = mir_a2t(msg);
+ pre.ptszFiles = &ptszFileName;
pre.lParam = (LPARAM)ft;
CCSDATA ccs;
@@ -543,13 +536,14 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, ccs.wParam = 0;
ccs.lParam = (LPARAM) & pre;
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) & ccs);
- free(szBlob);
+
+ mir_free(pre.tszDescription);
+ mir_free(ptszFileName);
}
void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_token, int y7, YList* files)
{
HANDLE hContact;
- char *szBlob;
y_filetransfer *ft;
YList *f;
char fn[4096];
@@ -582,16 +576,14 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ }
- // blob is DWORD(*ft), ASCIIZ(filenames), ASCIIZ(description)
- szBlob = (char *) malloc(sizeof(DWORD) + lstrlenA(fn) + 2);
- *((PDWORD) szBlob) = 0;
- strcpy(szBlob + sizeof(DWORD), fn);
- strcpy(szBlob + sizeof(DWORD) + lstrlenA(fn) + 1, "");
+ TCHAR* ptszFileName = mir_a2t(fn);
- PROTORECVEVENT pre;
- pre.flags = PREF_UTF;
- pre.timestamp = (DWORD)time(NULL);
- pre.szMessage = szBlob;
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = _T("");
+ pre.ptszFiles = &ptszFileName;
pre.lParam = (LPARAM)ft;
CCSDATA ccs;
@@ -600,7 +592,8 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ ccs.wParam = 0;
ccs.lParam = (LPARAM)⪯
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) & ccs);
- free(szBlob);
+
+ mir_free(ptszFileName);
}
void CYahooProto::ext_got_file7info(const char *me, const char *who, const char *url, const char *fname, const char *ft_token)
|