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

Commit

Permalink
fix(chatform): Add ability to cancel call
Browse files Browse the repository at this point in the history
Fix #4016.
  • Loading branch information
Diadlo committed Jan 28, 2017
1 parent dd8ae81 commit 320099f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/core/coreav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,34 @@ bool CoreAV::anyActiveCalls() const
return !calls.isEmpty();
}

/**
* @brief Checks the call status for a Tox friend.
* @param f the friend to check
* @return true, if call is started for the friend, false otherwise
*/
bool CoreAV::isCallStarted(const Friend* f) const
{
return f && calls.contains(f->getFriendId());
}

/**
* @brief Checks the call status for a Tox group.
* @param g the group to check
* @return true, if call is started for the group, false otherwise
*/
bool CoreAV::isCallStarted(const Group* g) const
{
return g && groupCalls.contains(g->getGroupId());
}

/**
* @brief Checks the call status for a Tox friend.
* @param f the friend to check
* @return true, if call is active for the friend, false otherwise
*/
bool CoreAV::isCallActive(const Friend* f) const
{
return f && calls.contains(f->getFriendId())
return isCallStarted(f)
? !(calls[f->getFriendId()].inactive)
: false;
}
Expand All @@ -187,14 +207,14 @@ bool CoreAV::isCallActive(const Friend* f) const
*/
bool CoreAV::isCallActive(const Group* g) const
{
return g && groupCalls.contains(g->getGroupId())
return isCallStarted(g)
? !(groupCalls[g->getGroupId()].inactive)
: false;
}

bool CoreAV::isCallVideoEnabled(const Friend* f) const
{
return f && calls.contains(f->getFriendId())
return isCallStarted(f)
? calls[f->getFriendId()].videoEnabled
: false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/coreav.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class CoreAV : public QObject
const ToxAV* getToxAv() const;

bool anyActiveCalls() const;
bool isCallStarted(const Friend* f) const;
bool isCallStarted(const Group* f) const;
bool isCallActive(const Friend* f) const;
bool isCallActive(const Group* g) const;
bool isCallVideoEnabled(const Friend* f) const;
Expand Down
4 changes: 2 additions & 2 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void ChatForm::onRejectCallTriggered()
void ChatForm::onCallTriggered()
{
CoreAV* av = Core::getInstance()->getAv();
if (av->isCallActive(f))
if (av->isCallStarted(f))
{
av->cancelCall(f->getFriendId());
}
Expand All @@ -481,7 +481,7 @@ void ChatForm::onCallTriggered()
void ChatForm::onVideoCallTriggered()
{
CoreAV* av = Core::getInstance()->getAv();
if (av->isCallActive(f))
if (av->isCallStarted(f))
{
// TODO: We want to activate video on the active call.
if (av->isCallVideoEnabled(f))
Expand Down

0 comments on commit 320099f

Please sign in to comment.