diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-02-09 17:54:33 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-02-09 17:54:33 +0000 |
commit | c2c68d35470d448194aecf3cc4bedee5b1487f5a (patch) | |
tree | 2ddb75b961059e69b6b4fdc1a706883eebe1027a /protocols/Tox/src/tox_transfer.cpp | |
parent | 10c51cd21b16232beb4492f045b6b43ae25edea6 (diff) |
Tox:
- enabled profile import dialog
- added global lock on file sending
- updated tox core
git-svn-id: http://svn.miranda-ng.org/main/trunk@12071 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_transfer.cpp')
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index a8643d16ea..1ae16c2455 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -44,7 +44,7 @@ HANDLE __cdecl CToxProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const P // stupid fix
TCHAR fullPath[MAX_PATH];
mir_sntprintf(fullPath, SIZEOF(fullPath), _T("%s\\%s"), transfer->pfts.tszWorkingDir, transfer->pfts.tszCurrentFile);
- transfer->Rename(fullPath);
+ transfer->ChangeName(fullPath);
if (!ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (HANDLE)transfer, (LPARAM)&transfer->pfts))
{
@@ -78,7 +78,7 @@ int __cdecl CToxProto::FileResume(HANDLE hTransfer, int *action, const PROTOCHAR switch (*action)
{
case FILERESUME_RENAME:
- transfer->Rename(*szFilename);
+ transfer->ChangeName(*szFilename);
result = transfer->OpenFile(_T("wb"));
break;
@@ -214,8 +214,6 @@ void CToxProto::SendFileAsync(void *arg) while (transfer->status == STARTED && transfer->hFile != NULL && fileProgress < fileSize)
{
- mir_cslockfull locker(transfer->fileLock);
-
if (dataSize == 0)
{
dataSize = min(chunkSize, fileSize - fileProgress);
@@ -229,9 +227,13 @@ void CToxProto::SendFileAsync(void *arg) }
}
- if (tox_file_send_data(tox, transfer->friendNumber, transfer->fileNumber, data, dataSize) == TOX_ERROR)
+ int sendResult = TOX_ERROR;
+ {
+ mir_cslock lock(toxLock);
+ sendResult = tox_file_send_data(tox, transfer->friendNumber, transfer->fileNumber, data, dataSize);
+ }
+ if (sendResult == TOX_ERROR)
{
- locker.unlock();
Sleep(100);
continue;
}
@@ -300,19 +302,13 @@ void CToxProto::OnFileRequest(Tox *tox, int32_t friendNumber, uint8_t receive_se break;
case TOX_FILECONTROL_PAUSE:
- {
- mir_cslock locker(transfer->fileLock);
-
transfer->status = PAUSED;
- }
- break;
+ break;
case TOX_FILECONTROL_RESUME_BROKEN:
// receiver asked to resume transfer
if (receive_send == 1)
{
- mir_cslock locker(transfer->fileLock);
-
uint64_t progress = *(uint64_t*)data;
if (progress >= transfer->pfts.currentFileSize || length != sizeof(uint64_t))
{
@@ -345,10 +341,7 @@ void CToxProto::OnFileRequest(Tox *tox, int32_t friendNumber, uint8_t receive_se break;
case TOX_FILECONTROL_KILL:
- {
- mir_cslock locker(transfer->fileLock);
- transfer->status = CANCELED;
- }
+ transfer->status = CANCELED;
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)transfer, 0);
proto->transfers->Remove(transfer);
break;
@@ -357,10 +350,7 @@ void CToxProto::OnFileRequest(Tox *tox, int32_t friendNumber, uint8_t receive_se {
proto->debugLogA("CToxProto::SendFileAsync: finish the transfer of file (%d)", transfer->fileNumber);
bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
- {
- mir_cslock locker(transfer->fileLock);
- transfer->status = isFileFullyTransfered ? FINISHED : FAILED;
- }
+ transfer->status = isFileFullyTransfered ? FINISHED : FAILED;
if (!isFileFullyTransfered)
{
proto->debugLogA("CToxProto::SendFileAsync: file (%d) is transferred not completely", transfer->fileNumber);
|