[calls/master] mm: call: Check call direction when mapping waiting state



commit b2b4910ecd76212010f56f1c4309d1ea826c4ffc
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Aug 5 11:11:52 2022 +0200

    mm: call: Check call direction when mapping waiting state
    
    MM_CALL_STATE_WAITING may also be used on outgoing calls,
    so we need to check the call direction.
    
    Fixes #465

 plugins/provider/mm/calls-mm-call.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/plugins/provider/mm/calls-mm-call.c b/plugins/provider/mm/calls-mm-call.c
index 941dccd9..5953d61b 100644
--- a/plugins/provider/mm/calls-mm-call.c
+++ b/plugins/provider/mm/calls-mm-call.c
@@ -128,7 +128,6 @@ static const struct CallsMMCallStateMap STATE_MAP[] = {
   row (RINGING_IN,  INCOMING),
   row (ACTIVE,      ACTIVE),
   row (HELD,        HELD),
-  row (WAITING,     INCOMING),
   row (TERMINATED,  DISCONNECTED),
 
 #undef row
@@ -146,6 +145,7 @@ state_changed_cb (CallsMMCall      *self,
   const struct CallsMMCallStateReasonMap *reason_map_row;
   const char *state_str = "state unmatched";
   const char *reason_str = "reason unmatched";
+  CallsCallState call_state = CALLS_CALL_STATE_UNKNOWN;
 
   if (new_state == MM_CALL_STATE_TERMINATED)
     set_disconnect_reason (self, reason);
@@ -154,10 +154,20 @@ state_changed_cb (CallsMMCall      *self,
   for (state_map_row = STATE_MAP; state_map_row->mm != -1; state_map_row++) {
     if (state_map_row->mm == new_state) {
       state_str = state_map_row->desc;
+      call_state = state_map_row->calls;
       break;
     }
   }
-  g_assert_cmpint (state_map_row->mm, !=, -1);
+
+  if (state_map_row->mm == -1 &&
+      new_state == MM_CALL_STATE_WAITING) {
+  MMCallDirection direction = mm_call_get_direction(self->mm_call);
+  gboolean outgoing = direction == MM_CALL_DIRECTION_OUTGOING;
+
+  call_state = outgoing ? CALLS_CALL_STATE_ALERTING : CALLS_CALL_STATE_INCOMING;
+  }
+
+  g_assert_cmpint (call_state, !=, CALLS_CALL_STATE_UNKNOWN);
 
   for (reason_map_row = STATE_REASON_MAP; reason_map_row->value != -1; reason_map_row++) {
     if (reason_map_row->value == reason) {
@@ -171,7 +181,7 @@ state_changed_cb (CallsMMCall      *self,
            mm_call_get_path (self->mm_call),
            state_str,
            reason_str);
-  calls_call_set_state (CALLS_CALL (self), state_map_row->calls);
+  calls_call_set_state (CALLS_CALL (self), call_state);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]