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

FileTransferInstance responce on broken filetransfer state

This commit is contained in:
apprb 2014-09-30 00:22:19 +07:00
parent 76f7df3135
commit 904de559e5
4 changed files with 30 additions and 0 deletions

View File

@ -442,6 +442,11 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
}
else if (receive_send == 0 && control_type == TOX_FILECONTROL_ACCEPT)
{
if (file->status == ToxFile::BROKEN)
{
emit static_cast<Core*>(core)->fileTransferBrokenUnbroken(*file, false);
file->status = ToxFile::TRANSMITTING;
}
emit static_cast<Core*>(core)->fileTransferRemotePausedUnpaused(*file, false);
}
else if ((receive_send == 0 || receive_send == 1) && control_type == TOX_FILECONTROL_PAUSE)
@ -464,6 +469,9 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
return;
}
file->status = ToxFile::TRANSMITTING;
emit static_cast<Core*>(core)->fileTransferBrokenUnbroken(*file, false);
file->bytesSent = resumePos;
tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_ACCEPT, nullptr, 0);
}

View File

@ -291,6 +291,12 @@ QString FileTransferInstance::getHtmlImage()
rightBtnImg = QImage(":/ui/fileTransferInstance/pauseGreyFileButton.png");
res = draw2ButtonsForm("silver", leftBtnImg, rightBtnImg);
} else if (state == tsBroken)
{
QImage leftBtnImg(":/ui/fileTransferInstance/stopFileButton.png");
QImage rightBtnImg(":/ui/fileTransferInstance/pauseGreyFileButton.png");
res = draw2ButtonsForm("red", leftBtnImg, rightBtnImg);
} else if (state == tsCanceled)
{
res = drawButtonlessForm("red");
@ -416,3 +422,16 @@ QImage FileTransferInstance::drawProgressBarImg(const double &part, int w, int h
return progressBar;
}
void FileTransferInstance::onFileTransferBrokenUnbroken(ToxFile File, bool broken)
{
if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
return;
if (broken)
state = tsBroken;
else
state = tsProcessing;
emit stateUpdated();
}

View File

@ -43,6 +43,7 @@ public slots:
void onFileTransferAccepted(ToxFile File);
void onFileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection Direction);
void onFileTransferRemotePausedUnpaused(ToxFile File, bool paused);
void onFileTransferBrokenUnbroken(ToxFile File, bool broken);
void pressFromHtml(QString);
signals:

View File

@ -119,6 +119,7 @@ void ChatForm::startFileSend(ToxFile file)
connect(Core::getInstance(), SIGNAL(fileTransferAccepted(ToxFile)), fileTrans, SLOT(onFileTransferAccepted(ToxFile)));
connect(Core::getInstance(), SIGNAL(fileTransferPaused(int,int,ToxFile::FileDirection)), fileTrans, SLOT(onFileTransferPaused(int,int,ToxFile::FileDirection)));
connect(Core::getInstance(), SIGNAL(fileTransferRemotePausedUnpaused(ToxFile,bool)), fileTrans, SLOT(onFileTransferRemotePausedUnpaused(ToxFile,bool)));
connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
QString name = Widget::getInstance()->getUsername();
if (name == previousName)
@ -142,6 +143,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
connect(Core::getInstance(), SIGNAL(fileTransferAccepted(ToxFile)), fileTrans, SLOT(onFileTransferAccepted(ToxFile)));
connect(Core::getInstance(), SIGNAL(fileTransferPaused(int,int,ToxFile::FileDirection)), fileTrans, SLOT(onFileTransferPaused(int,int,ToxFile::FileDirection)));
connect(Core::getInstance(), SIGNAL(fileTransferRemotePausedUnpaused(ToxFile,bool)), fileTrans, SLOT(onFileTransferRemotePausedUnpaused(ToxFile,bool)));
connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
Widget* w = Widget::getInstance();
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())