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

fix(chatform): Add ability to cancel call

Fix #4016.
This commit is contained in:
Diadlo 2017-01-10 00:29:06 +03:00
parent dd8ae8109e
commit 320099faf8
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 27 additions and 5 deletions

View File

@ -168,6 +168,26 @@ 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
@ -175,7 +195,7 @@ bool CoreAV::anyActiveCalls() const
*/
bool CoreAV::isCallActive(const Friend* f) const
{
return f && calls.contains(f->getFriendId())
return isCallStarted(f)
? !(calls[f->getFriendId()].inactive)
: false;
}
@ -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;
}

View File

@ -49,6 +49,8 @@ public:
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;

View File

@ -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());
}
@ -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))