Skip to content
Snippets Groups Projects
Commit 2d0ce574 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Stepan Salenikovich
Browse files

call: add missing cases to Call::validStateTransition

MERROR was not permitted but it should always be the case.

Issue: #78119
Change-Id: I6591a0bda43ed81887cdfb6e546fa8108a01f725
parent 34789352
Branches
Tags
No related merge requests found
...@@ -93,33 +93,47 @@ Call::getState() const ...@@ -93,33 +93,47 @@ Call::getState() const
bool bool
Call::validStateTransition(CallState newState) Call::validStateTransition(CallState newState)
{ {
// Notice to developper:
// - list only permitted transition (return true)
// - let non permitted ones as default case (return false)
switch (callState_) { switch (callState_) {
case CallState::INACTIVE: case CallState::INACTIVE:
switch (newState) { switch (newState) {
case CallState::INACTIVE: case CallState::ACTIVE:
case CallState::HOLD: case CallState::BUSY:
return false; case CallState::MERROR:
default:
return true; return true;
default: // INACTIVE, HOLD
return false;
} }
case CallState::ACTIVE: case CallState::ACTIVE:
switch (newState) { switch (newState) {
case CallState::HOLD: case CallState::HOLD:
case CallState::MERROR:
return true; return true;
default: default: // INACTIVE, ACTIVE, BUSY
return false; return false;
} }
case CallState::HOLD: case CallState::HOLD:
switch (newState) { switch (newState) {
case CallState::ACTIVE: case CallState::ACTIVE:
case CallState::MERROR:
return true; return true;
default: default: // INACTIVE, HOLD, BUSY, MERROR
return false; return false;
} }
default: case CallState::BUSY:
switch (newState) {
case CallState::MERROR:
return true;
default: // INACTIVE, ACTIVE, HOLD, BUSY
return false;
}
default: // MERROR
return false; return false;
} }
} }
......
...@@ -77,6 +77,8 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> { ...@@ -77,6 +77,8 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
* *
* Audio should be transmitted when ConnectionState = Connected AND * Audio should be transmitted when ConnectionState = Connected AND
* CallState = Active. * CallState = Active.
*
* \note modify validStateTransition/getStateStr if this enum changes
*/ */
enum class ConnectionState : unsigned { enum class ConnectionState : unsigned {
DISCONNECTED, TRYING, PROGRESSING, RINGING, CONNECTED, COUNT__ DISCONNECTED, TRYING, PROGRESSING, RINGING, CONNECTED, COUNT__
...@@ -84,6 +86,8 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> { ...@@ -84,6 +86,8 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
/** /**
* The Call State. * The Call State.
*
* \note modify validStateTransition/getStateStr if this enum changes
*/ */
enum class CallState : unsigned { enum class CallState : unsigned {
INACTIVE, ACTIVE, HOLD, BUSY, MERROR, COUNT__ INACTIVE, ACTIVE, HOLD, BUSY, MERROR, COUNT__
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment