diff options
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 8 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 5a87f0af89..6de8c1e60d 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -370,14 +370,8 @@ HANDLE CIcqProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t **ppszFile pTransfer->pfts.currentFileSize = pTransfer->pfts.totalBytes = statbuf.st_size; pTransfer->m_fileId = iFileId; - wchar_t *pwszFileName = wcsrchr(ppszFiles[0], '\\'); - if (pwszFileName != nullptr) - pwszFileName++; - else - pwszFileName = ppszFiles[0]; - auto *pReq = new AsyncHttpRequest(CONN_NONE, REQUEST_GET, "https://files.icq.com/files/init", &CIcqProto::OnFileInit); - pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << CHAR_PARAM("fileName", mir_urlEncode(T2Utf(pwszFileName))) + pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << CHAR_PARAM("fileName", mir_urlEncode(T2Utf(pTransfer->m_wszShortName))) << CHAR_PARAM("k", ICQ_APP_ID) << INT_PARAM("size", statbuf.st_size) << INT_PARAM("ts", time(0)); CalcHash(pReq); pReq->pUserInfo = pTransfer; diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 77bc9d5268..a83fc60646 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -81,6 +81,13 @@ struct IcqFileTransfer : public MZeroedObject pfts.flags = PFTS_UNICODE | PFTS_SENDING; pfts.hContact = hContact; pfts.szCurrentFile.w = m_wszFileName.GetBuffer(); + + const wchar_t *p = wcsrchr(pfts.szCurrentFile.w, '\\'); + if (pwszFileName != nullptr) + p++; + else + p = pfts.szCurrentFile.w; + m_wszShortName = p; } ~IcqFileTransfer() @@ -90,20 +97,21 @@ struct IcqFileTransfer : public MZeroedObject } int m_fileId = -1; - CMStringW m_wszFileName; CMStringA m_szHost; + CMStringW m_wszFileName; + const wchar_t *m_wszShortName; PROTOFILETRANSFERSTATUS pfts; void FillHeaders(AsyncHttpRequest *pReq) { pReq->AddHeader("Content-Type", "application/octet-stream"); - pReq->AddHeader("Content-Disposition", CMStringA(FORMAT, "attachment; filename=\"%s\"", T2Utf(m_wszFileName))); + pReq->AddHeader("Content-Disposition", CMStringA(FORMAT, "attachment; filename=\"%s\"", T2Utf(m_wszShortName))); DWORD dwPortion = pfts.currentFileSize - pfts.currentFileProgress; if (dwPortion > 1000000) dwPortion = 1000000; - pReq->AddHeader("Content-Range", CMStringA(FORMAT, "bytes %d-%d/%d", pfts.currentFileProgress, pfts.currentFileProgress + dwPortion - 1, pfts.currentFileSize)); + pReq->AddHeader("Content-Range", CMStringA(FORMAT, "bytes %lld-%lld/%lld", pfts.currentFileProgress, pfts.currentFileProgress + dwPortion - 1, pfts.currentFileSize)); pReq->AddHeader("Content-Length", CMStringA(FORMAT, "%d", dwPortion)); pReq->dataLength = dwPortion; |