From 0bd7314a45df9f2b01aa2a1728fe46fe18c3cf67 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 17 Feb 2015 21:16:52 +0000 Subject: Tox: fix to simultaneous file transfer to different contacts git-svn-id: http://svn.miranda-ng.org/main/trunk@12171 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_transfer.h | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'protocols/Tox/src/tox_transfer.h') diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h index 643dc418f9..534565c09f 100644 --- a/protocols/Tox/src/tox_transfer.h +++ b/protocols/Tox/src/tox_transfer.h @@ -18,15 +18,17 @@ struct FileTransferParam PROTOFILETRANSFERSTATUS pfts; FILE_TRANSFER_STATUS status; FILE *hFile; - int friendNumber; - int fileNumber; + int32_t friendNumber; + uint8_t fileNumber; + int64_t transferNumber; - FileTransferParam(int friendNumber, int fileNumber, const TCHAR *fileName, uint64_t fileSize) + FileTransferParam(int32_t friendNumber, uint8_t fileNumber, const TCHAR *fileName, uint64_t fileSize) { status = NONE; hFile = NULL; this->friendNumber = friendNumber; this->fileNumber = fileNumber; + transferNumber = (((int64_t)friendNumber) << 32) | ((int64_t)fileNumber); pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS); pfts.flags = PFTS_TCHAR; @@ -76,7 +78,7 @@ struct FileTransferParam class CTransferList { private: - std::map transfers; + std::map transfers; public: size_t Count() const @@ -86,47 +88,49 @@ public: void Add(FileTransferParam *transfer) { - if (transfers.find(transfer->fileNumber) == transfers.end()) + if (transfers.find(transfer->transferNumber) == transfers.end()) { - transfers[transfer->fileNumber] = transfer; + transfers[transfer->transferNumber] = transfer; } } - FileTransferParam* Get(uint8_t fileNumber) + FileTransferParam* Get(int32_t friendNumber, uint8_t fileNumber) { - if (transfers.find(fileNumber) != transfers.end()) + int64_t transferNumber = (((int64_t)friendNumber) << 32) | ((int64_t)fileNumber); + if (transfers.find(transferNumber) != transfers.end()) { - return transfers.at(fileNumber); + return transfers.at(transferNumber); } return NULL; } - FileTransferParam* GetAt(size_t index) + FileTransferParam* GetAt(int64_t index) { if (index < Count()) { - std::map::iterator it = transfers.begin(); + std::map::iterator it = transfers.begin(); std::advance(it, index); return it->second; } return NULL; } - void Remove(uint8_t fileNumber) + void Remove(int32_t friendNumber, uint8_t fileNumber) { - if (transfers.find(fileNumber) != transfers.end()) + int64_t transferNumber = (((int64_t)friendNumber) << 32) | ((int64_t)fileNumber); + if (transfers.find(transferNumber) != transfers.end()) { - FileTransferParam *transfer = transfers.at(fileNumber); - transfers.erase(fileNumber); + FileTransferParam *transfer = transfers.at(transferNumber); + transfers.erase(transferNumber); delete transfer; } } void Remove(FileTransferParam *transfer) { - if (transfers.find(transfer->fileNumber) != transfers.end()) + if (transfers.find(transfer->transferNumber) != transfers.end()) { - transfers.erase(transfer->fileNumber); + transfers.erase(transfer->transferNumber); delete transfer; } } -- cgit v1.2.3