Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(video): Error message on call fail
Browse files Browse the repository at this point in the history
notifies user if call ended unexpectedly
  • Loading branch information
tWido committed Jul 23, 2017
1 parent 90910cb commit ac75f7b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/coreav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
if (state & TOXAV_FRIEND_CALL_STATE_ERROR) {
qWarning() << "Call with friend" << friendNum << "died of unnatural causes!";
calls.remove(friendNum);
emit self->avEnd(friendNum);
emit self->avEnd(friendNum, true);
} else if (state & TOXAV_FRIEND_CALL_STATE_FINISHED) {
qDebug() << "Call with friend" << friendNum << "finished quietly";
calls.remove(friendNum);
Expand Down
2 changes: 1 addition & 1 deletion src/core/coreav.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public slots:
signals:
void avInvite(uint32_t friendId, bool video);
void avStart(uint32_t friendId, bool video);
void avEnd(uint32_t friendId);
void avEnd(uint32_t friendId, bool error = false);

private slots:
static void callCallback(ToxAV* toxAV, uint32_t friendNum, bool audio, bool video, void* self);
Expand Down
11 changes: 7 additions & 4 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void ChatForm::onAvStart(uint32_t friendId, bool video)
startCounter();
}

void ChatForm::onAvEnd(uint32_t friendId)
void ChatForm::onAvEnd(uint32_t friendId, bool error)
{
if (friendId != f->getFriendId()) {
return;
Expand All @@ -392,7 +392,7 @@ void ChatForm::onAvEnd(uint32_t friendId)
}

updateCallButtons();
stopCounter();
stopCounter(error);
hideNetcam();
}

Expand Down Expand Up @@ -891,14 +891,17 @@ void ChatForm::startCounter()
callDuration->show();
}

void ChatForm::stopCounter()
void ChatForm::stopCounter(bool error)
{
if (!callDurationTimer) {
return;
}
QString dhms = secondsToDHMS(timeElapsed.elapsed() / 1000);
QString name = f->getDisplayedName();
addSystemInfoMessage(tr("Call with %1 ended. %2").arg(name, dhms), ChatMessage::INFO,
QString mess = error ? "Call with %1 ended unexpectedly. %2" : "Call with %1 ended. %2";
// TODO: add notification once notifications are implemented

addSystemInfoMessage(tr(mess.toStdString().c_str()).arg(name, dhms), ChatMessage::INFO,
QDateTime::currentDateTime());
callDurationTimer->stop();
callDuration->setText("");
Expand Down
4 changes: 2 additions & 2 deletions src/widget/form/chatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public slots:
void onFileRecvRequest(ToxFile file);
void onAvInvite(uint32_t friendId, bool video);
void onAvStart(uint32_t friendId, bool video);
void onAvEnd(uint32_t friendId);
void onAvEnd(uint32_t friendId, bool error);
void onAvatarChange(uint32_t friendId, const QPixmap& pic);
void onAvatarRemoved(uint32_t friendId);

Expand Down Expand Up @@ -108,7 +108,7 @@ private slots:
void retranslateUi();
void showOutgoingCall(bool video);
void startCounter();
void stopCounter();
void stopCounter(bool error = false);
void updateCallButtons();
void SendMessageStr(QString msg);

Expand Down

0 comments on commit ac75f7b

Please sign in to comment.