summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_transfers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/src/tox_transfers.cpp')
-rw-r--r--protocols/Tox/src/tox_transfers.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/protocols/Tox/src/tox_transfers.cpp b/protocols/Tox/src/tox_transfers.cpp
index b15ac1838f..51bab8aac3 100644
--- a/protocols/Tox/src/tox_transfers.cpp
+++ b/protocols/Tox/src/tox_transfers.cpp
@@ -1,27 +1,44 @@
#include "common.h"
-int CToxProto::FileSendQueueCompare(const CFile* p1, const CFile* p2)
+void CToxProto::SendFileAsync(void* arg)
{
- return 0;
+ CFile *file = (CFile*)arg;
+ const CFileTransfer *transfer = file->GetTransfer();
+ CToxProto *proto = (CToxProto*)transfer->GetProtoInstance();
}
void CToxProto::SendFilesAsync(void* arg)
{
- CFileTransfer *ftp = (CFileTransfer*)arg;
+ CFileTransfer *transfer = (CFileTransfer*)arg;
- std::string toxId(getStringA(ftp->pfts.hContact, TOX_SETTINGS_ID));
+ std::string toxId(getStringA(transfer->GetContactHandle(), TOX_SETTINGS_ID));
std::vector<uint8_t> clientId = HexStringToData(toxId);
uint32_t number = tox_get_friend_number(tox, clientId.data());
- for (int i = 0; ftp->GetFileCount(); i++)
+ for (int i = 0; transfer->GetFileCount(); i++)
{
- CFile *file = ftp->GetFileAt(i);
+ CFile *file = transfer->GetFileAt(i);
+
int hFile = tox_new_file_sender(tox, number, file->GetSize(), (uint8_t*)file->GetName(), strlen(file->GetName()));
if (hFile < 0)
{
debugLogA("CToxProto::SendFilesAsync: cannot send file");
}
- file->SetHandle((HANDLE)hFile);
+ file->SetNumber(hFile);
+
+ transfer->Wait();
+ }
+}
+
+CFileTransfer *CToxProto::GetFileTransferByFileNumber(int fileNumber)
+{
+ for (int i = 0; fileTransfers.getCount(); i++)
+ {
+ if (fileTransfers[i]->HasFile(fileNumber))
+ {
+ return fileTransfers[i];
+ }
}
+ return NULL;
} \ No newline at end of file