1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

style(corefile): Small style fixes

This commit is contained in:
Diadlo 2016-10-18 23:57:58 +03:00
parent 624441f71e
commit 0a0db25f68
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 26 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright © 2015 by The qTox Project
Copyright © 2015-2016 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
@ -124,6 +124,7 @@ void CoreFile::sendFile(Core* core, uint32_t friendId, QString filename, QString
{
qWarning() << QString("sendFile: Can't open file, error: %1").arg(file.file->errorString());
}
addFile(friendId, fileNum, file);
emit core->fileSendStarted(file);
@ -150,7 +151,9 @@ void CoreFile::pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileI
tox_file_control(core->tox, file->friendId, file->fileNum, TOX_FILE_CONTROL_RESUME, nullptr);
}
else
{
qWarning() << "pauseResumeFileSend: File is stopped";
}
}
void CoreFile::pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileId)
@ -174,7 +177,9 @@ void CoreFile::pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileI
tox_file_control(core->tox, file->friendId, file->fileNum, TOX_FILE_CONTROL_RESUME, nullptr);
}
else
{
qWarning() << "pauseResumeFileRecv: File is stopped or broken";
}
}
void CoreFile::cancelFileSend(Core* core, uint32_t friendId, uint32_t fileId)
@ -185,6 +190,7 @@ void CoreFile::cancelFileSend(Core* core, uint32_t friendId, uint32_t fileId)
qWarning("cancelFileSend: No such file in queue");
return;
}
file->status = ToxFile::STOPPED;
emit core->fileTransferCancelled(*file);
tox_file_control(core->tox, file->friendId, file->fileNum, TOX_FILE_CONTROL_CANCEL, nullptr);
@ -240,27 +246,33 @@ void CoreFile::acceptFileRecvRequest(Core* core, uint32_t friendId, uint32_t fil
ToxFile* CoreFile::findFile(uint32_t friendId, uint32_t fileId)
{
uint64_t key = ((uint64_t)friendId<<32) + (uint64_t)fileId;
if (!fileMap.contains(key))
uint64_t key = getFriendKey(friendId, fileId);
if (fileMap.contains(key))
{
qWarning() << "findFile: File transfer with ID "<<friendId<<':'<<fileId<<" doesn't exist";
return nullptr;
}
else
return &fileMap[key];
}
qWarning() << "findFile: File transfer with ID" << friendId << ':'
<< fileId << "doesn't exist";
return nullptr;
}
void CoreFile::addFile(uint32_t friendId, uint32_t fileId, const ToxFile& file)
{
uint64_t key = ((uint64_t)friendId<<32) + (uint64_t)fileId;
uint64_t key = getFriendKey(friendId, fileId);
if (fileMap.contains(key))
qWarning() << "addFile: Overwriting existing file transfer with same ID "<<friendId<<':'<<fileId;
{
qWarning() << "addFile: Overwriting existing file transfer with same ID"
<< friendId << ':' << fileId;
}
fileMap.insert(key, file);
}
void CoreFile::removeFile(uint32_t friendId, uint32_t fileId)
{
uint64_t key = ((uint64_t)friendId<<32) + (uint64_t)fileId;
uint64_t key = getFriendKey(friendId, fileId);
if (!fileMap.contains(key))
{
qWarning() << "removeFile: No such file in queue";

View File

@ -56,6 +56,10 @@ private:
static void addFile(uint32_t friendId, uint32_t fileId, const ToxFile& file);
static void removeFile(uint32_t friendId, uint32_t fileId);
static unsigned corefileIterationInterval();
static constexpr uint64_t getFriendKey(uint32_t friendId, uint32_t fileId)
{
return (static_cast<std::uint64_t>(friendId) << 32) + fileId;
}
private:
static void onFileReceiveCallback(Tox*, uint32_t friendnumber, uint32_t fileId, uint32_t kind,