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

Core: emit TOX_FILECONTROL_RESUME_BROKEN request (base functionality)

This commit is contained in:
apprb 2014-09-29 23:14:19 +07:00
parent 4dfa5a45c4
commit 575cac1fc7
4 changed files with 34 additions and 4 deletions

View File

@ -291,6 +291,34 @@ void Core::onConnectionStatusChanged(Tox*/* tox*/, int friendId, uint8_t status,
emit static_cast<Core*>(core)->friendStatusChanged(friendId, friendStatus); emit static_cast<Core*>(core)->friendStatusChanged(friendId, friendStatus);
if (friendStatus == Status::Offline) { if (friendStatus == Status::Offline) {
static_cast<Core*>(core)->checkLastOnline(friendId); static_cast<Core*>(core)->checkLastOnline(friendId);
for (ToxFile& f : fileSendQueue)
{
if (f.friendId == friendId && f.status == ToxFile::TRANSMITTING)
{
qDebug() << "friendId: set broken";
f.status = ToxFile::BROKEN;
emit static_cast<Core*>(core)->fileTransferBrokenUnbroken(f, true);
}
}
for (ToxFile& f : fileRecvQueue)
{
if (f.friendId == friendId && f.status == ToxFile::TRANSMITTING)
{
qDebug() << "friendId: set broken";
f.status = ToxFile::BROKEN;
emit static_cast<Core*>(core)->fileTransferBrokenUnbroken(f, true);
}
}
} else {
for (ToxFile& f : fileRecvQueue)
{
if (f.friendId == friendId && f.status == ToxFile::BROKEN)
{
tox_file_send_control(static_cast<Core*>(core)->tox, friendId, 1, f.fileNum, TOX_FILECONTROL_RESUME_BROKEN, (const uint8_t*)(&f.bytesSent), sizeof(uint64_t));
emit static_cast<Core*>(core)->fileTransferBrokenUnbroken(f, false);
}
}
} }
} }
@ -424,7 +452,7 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
else if (receive_send == 1 && control_type == TOX_FILECONTROL_RESUME_BROKEN) else if (receive_send == 1 && control_type == TOX_FILECONTROL_RESUME_BROKEN)
{ {
qDebug() << "Core::onFileControlCallback: TOX_FILECONTROL_RESUME_BROKEN"; qDebug() << "Core::onFileControlCallback: TOX_FILECONTROL_RESUME_BROKEN";
uint64_t resumePos = *(uint64_t*)data; uint64_t resumePos = *(const uint64_t*)(data);
if (resumePos >= file->filesize) if (resumePos >= file->filesize)
{ {
@ -655,7 +683,7 @@ void Core::pauseResumeFileRecv(int friendId, int fileNum)
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0); tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0);
} }
else else
qWarning() << "Core::pauseResumeFileRecv: File is stopped"; qWarning() << "Core::pauseResumeFileRecv: File is stopped or broken";
} }
void Core::cancelFileSend(int friendId, int fileNum) void Core::cancelFileSend(int friendId, int fileNum)

1
core.h
View File

@ -150,6 +150,7 @@ signals:
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction); void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction); void fileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused); void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
void fileTransferBrokenUnbroken(ToxFile file, bool broken);
void fileSendFailed(int FriendId, const QString& fname); void fileSendFailed(int FriendId, const QString& fname);

View File

@ -50,7 +50,8 @@ struct ToxFile
{ {
STOPPED, STOPPED,
PAUSED, PAUSED,
TRANSMITTING TRANSMITTING,
BROKEN
}; };
enum FileDirection : bool enum FileDirection : bool

View File

@ -28,7 +28,7 @@ class FileTransferInstance : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled}; enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled, tsBroken};
public: public:
explicit FileTransferInstance(ToxFile File); explicit FileTransferInstance(ToxFile File);