diff options
author | George Hazan <ghazan@miranda.im> | 2023-04-09 16:14:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-04-09 16:14:34 +0300 |
commit | b0e95185fa4295d2a52c2b00d9da2291e28746b2 (patch) | |
tree | 6df687e57766f0b0837097d7d1ceb5366e5df3e3 | |
parent | cf96e2854c811a6f9a8da53c7115ac30222dd3c5 (diff) |
fixes #3477 (ICQ: it's not possible to send 2 or more files at a time)
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 8ee9b60d8b..de1f05f3f3 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -447,35 +447,38 @@ HANDLE CIcqProto::SearchBasic(const wchar_t *pszSearch) HANDLE CIcqProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles)
{
- // we can't send more than one file at a time
- if (ppszFiles[1] != 0)
- return nullptr;
+ IcqFileTransfer *pTransfer = nullptr;
- struct _stat statbuf;
- if (_wstat(ppszFiles[0], &statbuf)) {
- debugLogW(L"'%s' is an invalid filename", ppszFiles[0]);
- return nullptr;
- }
+ for (int i = 0; ; i++) {
+ if (ppszFiles[i] == nullptr)
+ break;
- int iFileId = _wopen(ppszFiles[0], _O_RDONLY | _O_BINARY, _S_IREAD);
- if (iFileId < 0)
- return nullptr;
+ struct _stat statbuf;
+ if (_wstat(ppszFiles[0], &statbuf)) {
+ debugLogW(L"'%s' is an invalid filename", ppszFiles[i]);
+ continue;
+ }
- auto *pTransfer = new IcqFileTransfer(hContact, ppszFiles[0]);
- pTransfer->pfts.totalFiles = 1;
- pTransfer->pfts.currentFileSize = pTransfer->pfts.totalBytes = statbuf.st_size;
- pTransfer->m_fileId = iFileId;
- if (mir_wstrlen(szDescription))
- pTransfer->m_wszDescr = szDescription;
-
- 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") << WCHAR_PARAM("filename", pTransfer->m_wszShortName)
- << CHAR_PARAM("k", appId()) << INT_PARAM("size", statbuf.st_size) << INT_PARAM("ts", TS());
- CalcHash(pReq);
- pReq->pUserInfo = pTransfer;
- Push(pReq);
+ int iFileId = _wopen(ppszFiles[0], _O_RDONLY | _O_BINARY, _S_IREAD);
+ if (iFileId < 0)
+ continue;
+
+ pTransfer = new IcqFileTransfer(hContact, ppszFiles[i]);
+ pTransfer->pfts.totalFiles = 1;
+ pTransfer->pfts.currentFileSize = pTransfer->pfts.totalBytes = statbuf.st_size;
+ pTransfer->m_fileId = iFileId;
+ if (mir_wstrlen(szDescription))
+ pTransfer->m_wszDescr = szDescription;
+
+ 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") << WCHAR_PARAM("filename", pTransfer->m_wszShortName)
+ << CHAR_PARAM("k", appId()) << INT_PARAM("size", statbuf.st_size) << INT_PARAM("ts", TS());
+ CalcHash(pReq);
+ pReq->pUserInfo = pTransfer;
+ Push(pReq);
+ }
- return pTransfer; // Failure
+ return pTransfer; // Success, if at least one file was sent
}
////////////////////////////////////////////////////////////////////////////////////////
|