mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(core): Add error parsing for Tox_Err_File_Send_Chunk
This commit is contained in:
parent
978bcde572
commit
6c9c380915
|
@ -502,7 +502,9 @@ void CoreFile::onFileDataCallback(Tox* tox, uint32_t friendId, uint32_t fileId,
|
||||||
qWarning("onFileDataCallback: Failed to read from file");
|
qWarning("onFileDataCallback: Failed to read from file");
|
||||||
file->status = ToxFile::CANCELED;
|
file->status = ToxFile::CANCELED;
|
||||||
emit coreFile->fileTransferCancelled(*file);
|
emit coreFile->fileTransferCancelled(*file);
|
||||||
tox_file_send_chunk(tox, friendId, fileId, pos, nullptr, 0, nullptr);
|
Tox_Err_File_Send_Chunk err;
|
||||||
|
tox_file_send_chunk(tox, friendId, fileId, pos, nullptr, 0, &err);
|
||||||
|
PARSE_ERR(err);
|
||||||
coreFile->removeFile(friendId, fileId);
|
coreFile->removeFile(friendId, fileId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -510,8 +512,9 @@ void CoreFile::onFileDataCallback(Tox* tox, uint32_t friendId, uint32_t fileId,
|
||||||
file->hashGenerator->addData(reinterpret_cast<const char*>(data.get()), length);
|
file->hashGenerator->addData(reinterpret_cast<const char*>(data.get()), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tox_file_send_chunk(tox, friendId, fileId, pos, data.get(), nread, nullptr)) {
|
Tox_Err_File_Send_Chunk err;
|
||||||
qWarning("onFileDataCallback: Failed to send data chunk");
|
tox_file_send_chunk(tox, friendId, fileId, pos, data.get(), nread, &err);
|
||||||
|
if (!PARSE_ERR(err)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file->fileKind != TOX_FILE_KIND_AVATAR) {
|
if (file->fileKind != TOX_FILE_KIND_AVATAR) {
|
||||||
|
|
|
@ -53,4 +53,5 @@ namespace ToxcoreErrorParser {
|
||||||
bool parseErr(Tox_Err_File_Control error, int line);
|
bool parseErr(Tox_Err_File_Control error, int line);
|
||||||
bool parseErr(Tox_Err_File_Get error, int line);
|
bool parseErr(Tox_Err_File_Get error, int line);
|
||||||
bool parseErr(Tox_Err_File_Send error, int line);
|
bool parseErr(Tox_Err_File_Send error, int line);
|
||||||
|
bool parseErr(Tox_Err_File_Send_Chunk error, int line);
|
||||||
} // namespace ToxcoreErrorParser
|
} // namespace ToxcoreErrorParser
|
||||||
|
|
|
@ -501,3 +501,45 @@ bool ToxcoreErrorParser::parseErr(Tox_Err_File_Send error, int line)
|
||||||
qCritical() << line << "Unknown Tox_Err_File_Send error code:" << error;
|
qCritical() << line << "Unknown Tox_Err_File_Send error code:" << error;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToxcoreErrorParser::parseErr(Tox_Err_File_Send_Chunk error, int line)
|
||||||
|
{
|
||||||
|
switch (error) {
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_OK:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_NULL:
|
||||||
|
qCritical() << line << ": The length parameter was non-zero, but data was NULL.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_FRIEND_NOT_FOUND:
|
||||||
|
qCritical() << line << ": The friend_number passed did not designate a valid friend.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_FRIEND_NOT_CONNECTED:
|
||||||
|
qCritical() << line << ": This client is currently not connected to the friend.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_NOT_FOUND:
|
||||||
|
qCritical() << line << ": No file transfer with the given file number was found for the given friend.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_NOT_TRANSFERRING:
|
||||||
|
qCritical() << line << ": File transfer was found but isn't in a transferring state.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_INVALID_LENGTH:
|
||||||
|
qCritical() << line << ": Attempted to send more or less data than requested.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_SENDQ:
|
||||||
|
qCritical() << line << ": Packet queue is full.";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case TOX_ERR_FILE_SEND_CHUNK_WRONG_POSITION:
|
||||||
|
qCritical() << line << ": Position parameter was wrong.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qCritical() << line << "Unknown Tox_Err_File_Send_Chunk error code:" << error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user