From a30b2689d14a4026af2f3ebd01764bf896aaeb59 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 17 Sep 2012 14:45:41 +0000 Subject: fix for the file transfer events git-svn-id: http://svn.miranda-ng.org/main/trunk@1590 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/icq_filerequests.cpp | 45 +++++++++++++----------------- protocols/IcqOscarJ/oscar_filetransfer.cpp | 33 ++++++++++++---------- 2 files changed, 38 insertions(+), 40 deletions(-) (limited to 'protocols/IcqOscarJ') 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 -- cgit v1.2.3