diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-call-list.c | 54 | ||||
-rw-r--r-- | src/mm-call-list.h | 2 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.c | 62 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.h | 2 |
4 files changed, 107 insertions, 13 deletions
diff --git a/src/mm-call-list.c b/src/mm-call-list.c index aa650058..c241a0be 100644 --- a/src/mm-call-list.c +++ b/src/mm-call-list.c @@ -114,7 +114,32 @@ MMBaseCall* mm_call_list_get_new_incoming(MMCallList *self) return call; } -MMBaseCall* mm_call_list_get_first_non_terminated_call(MMCallList *self) +MMBaseCall* mm_call_list_get_first_ringing_call(MMCallList *self) +{ + MMBaseCall *call = NULL; + GList *l; + guint i; + + for (i = 0, l = self->priv->list; l && !call; l = g_list_next (l)) { + + MMCallState state; + + g_object_get (MM_BASE_CALL (l->data), + "state" , &state, + NULL); + + if( state == MM_CALL_STATE_RINGING_IN || + state == MM_CALL_STATE_RINGING_OUT ) { + + call = MM_BASE_CALL (l->data); + break; + } + } + + return call; +} + +MMBaseCall* mm_call_list_get_first_outgoing_dialing_call(MMCallList *self) { MMBaseCall *call = NULL; GList *l; @@ -123,15 +148,38 @@ MMBaseCall* mm_call_list_get_first_non_terminated_call(MMCallList *self) for (i = 0, l = self->priv->list; l && !call; l = g_list_next (l)) { MMCallState state; - MMCallStateReason reason; MMCallDirection direct; g_object_get (MM_BASE_CALL (l->data), "state" , &state, - "state-reason", &reason, "direction" , &direct, NULL); + if( direct == MM_CALL_DIRECTION_OUTGOING && + state == MM_CALL_STATE_DIALING ) { + + call = MM_BASE_CALL (l->data); + break; + } + } + + return call; +} + +MMBaseCall* mm_call_list_get_first_non_terminated_call(MMCallList *self) +{ + MMBaseCall *call = NULL; + GList *l; + guint i; + + for (i = 0, l = self->priv->list; l && !call; l = g_list_next (l)) { + + MMCallState state; + + g_object_get (MM_BASE_CALL (l->data), + "state" , &state, + NULL); + if( state != MM_CALL_STATE_TERMINATED ) { call = MM_BASE_CALL (l->data); break; diff --git a/src/mm-call-list.h b/src/mm-call-list.h index 7d47e49c..197bb592 100644 --- a/src/mm-call-list.h +++ b/src/mm-call-list.h @@ -73,6 +73,8 @@ gboolean mm_call_list_delete_call_finish (MMCallList *self, GError **error); MMBaseCall* mm_call_list_get_new_incoming (MMCallList *self); +MMBaseCall* mm_call_list_get_first_ringing_call (MMCallList *self); +MMBaseCall* mm_call_list_get_first_outgoing_dialing_call(MMCallList *self); MMBaseCall* mm_call_list_get_first_non_terminated_call (MMCallList *self); #endif /* MM_CALL_LIST_H */ diff --git a/src/mm-iface-modem-voice.c b/src/mm-iface-modem-voice.c index 6b896dbd..36cb82f7 100644 --- a/src/mm-iface-modem-voice.c +++ b/src/mm-iface-modem-voice.c @@ -118,7 +118,7 @@ gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *se return updated; } -gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self) +gboolean mm_iface_modem_voice_call_dialing_to_ringing(MMIfaceModemVoice *self) { gboolean updated = FALSE; MMBaseCall *call = NULL; @@ -130,19 +130,61 @@ gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self) if( list ) { - call = mm_call_list_get_first_non_terminated_call(list); + call = mm_call_list_get_first_outgoing_dialing_call(list); if( call ) { - //BASCETTA:TODO: Hang this call! - g_object_set (call, - "state", MM_CALL_STATE_TERMINATED, - "state-reason", MM_CALL_STATE_REASON_TERMINATED, - NULL); - mm_gdbus_call_set_state(MM_GDBUS_CALL (call), MM_CALL_STATE_TERMINATED); - mm_gdbus_call_set_state_reason(MM_GDBUS_CALL (call), MM_CALL_STATE_REASON_TERMINATED); + mm_base_call_change_state(call, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED); + updated = TRUE; + } else { + mm_dbg("[%s:%d] Incoming call does not exist yet", __func__, __LINE__); + } + } - //BASCETTA:TODO: I have to signal state change... + return updated; +} +gboolean mm_iface_modem_voice_call_ringing_to_active(MMIfaceModemVoice *self) +{ + gboolean updated = FALSE; + MMBaseCall *call = NULL; + MMCallList *list = NULL; + + g_object_get (MM_BASE_MODEM (self), + MM_IFACE_MODEM_VOICE_CALL_LIST, &list, + NULL); + + if( list ) { + + call = mm_call_list_get_first_ringing_call(list); + if( call ) { + mm_base_call_change_state(call, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED); + + updated = TRUE; + } else { + mm_dbg("[%s:%d] Incoming call does not exist yet", __func__, __LINE__); + } + } + + return updated; +} + +gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self) +{ + gboolean updated = FALSE; + MMBaseCall *call = NULL; + MMCallList *list = NULL; + + g_object_get (MM_BASE_MODEM (self), + MM_IFACE_MODEM_VOICE_CALL_LIST, &list, + NULL); + + if( list ) { + + call = mm_call_list_get_first_non_terminated_call(list); + if( call ) { + mm_base_call_change_state(call, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED); + + updated = TRUE; } else { mm_dbg("[%s:%d] Incoming call does not exist yet", __func__, __LINE__); } diff --git a/src/mm-iface-modem-voice.h b/src/mm-iface-modem-voice.h index 65e5a1e4..c3b2f1e5 100644 --- a/src/mm-iface-modem-voice.h +++ b/src/mm-iface-modem-voice.h @@ -123,6 +123,8 @@ gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoi gchar *number, guint type, guint validity); +gboolean mm_iface_modem_voice_call_dialing_to_ringing (MMIfaceModemVoice *self); +gboolean mm_iface_modem_voice_call_ringing_to_active (MMIfaceModemVoice *self); gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self); /* Look for a new valid multipart reference */ |