summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bascetta <marco.bascetta@sadel.it>2015-05-06 16:21:17 +0200
committerAleksander Morgado <aleksander@aleksander.es>2015-05-23 17:45:49 +0200
commit7ed0666000494f94c2f4598358d91c96d4ca2e46 (patch)
tree67dcdcf94ed9fae0d2395b70d9abf2b1a24e5aed
parentb71c5103094a2717d79643c9a167d9922136c427 (diff)
downloadModemManager-7ed0666000494f94c2f4598358d91c96d4ca2e46.tar.gz
huawei: handle voice call state changes
-rw-r--r--plugins/huawei/mm-broadband-modem-huawei.c15
-rw-r--r--src/mm-call-list.c54
-rw-r--r--src/mm-call-list.h2
-rw-r--r--src/mm-iface-modem-voice.c62
-rw-r--r--src/mm-iface-modem-voice.h2
5 files changed, 113 insertions, 22 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index ea9acd2ae..062dce4c3 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -2869,10 +2869,10 @@ huawei_voice_origination (MMPortSerialAt *port,
if (!mm_get_uint_from_match_info (match_info, 2, &call_type))
return;
- mm_dbg ("[%s:%d][^ORIG] Origination call id '%u' of type '%u'", __func__, __LINE__, call_x, call_type);
+ mm_dbg ("[%s:%d][^ORIG] Origination call id '%u' of type '%u'", __func__, __LINE__, call_x, call_type); //Entrambi
- //TODO: Handle this event
- //mm_iface_modem_voice_xxx (MM_IFACE_MODEM (self), ...);
+ //TODO: Handle multiple calls
+ //mm_iface_modem_voice_set_call_id(MM_IFACE_MODEM_VOICE(self));
}
static void
@@ -2887,8 +2887,7 @@ huawei_voice_ringback_tone (MMPortSerialAt *port,
mm_dbg ("[%s:%d][^CONF] Ringback tone from call id '%u'", __func__, __LINE__, call_x);
- //TODO: Handle this event
- //mm_iface_modem_voice_xxx (MM_IFACE_MODEM (self), ...);
+ mm_iface_modem_voice_call_dialing_to_ringing(MM_IFACE_MODEM_VOICE(self));
}
static void
@@ -2907,8 +2906,7 @@ huawei_voice_call_connection (MMPortSerialAt *port,
mm_dbg ("[%s:%d][^CONN] Call id '%u' of type '%u' connected", __func__, __LINE__, call_x, call_type);
- //TODO: Handle this event
- //mm_iface_modem_voice_xxx (MM_IFACE_MODEM (self), ...);
+ mm_iface_modem_voice_call_ringing_to_active(MM_IFACE_MODEM_VOICE(self));
}
static void
@@ -2935,8 +2933,7 @@ huawei_voice_call_end (MMPortSerialAt *port,
mm_dbg ("[%s:%d][^CEND] Call '%u' terminated with status '%u' and cause '%u'. Duration of call '%d'", __func__, __LINE__, call_x, end_status, cc_cause, duration);
- //TODO: Handle this event
- //mm_iface_modem_voice_xxx (MM_IFACE_MODEM (self), ...);
+ mm_iface_modem_voice_network_hangup(MM_IFACE_MODEM_VOICE(self));
}
diff --git a/src/mm-call-list.c b/src/mm-call-list.c
index aa650058d..c241a0be1 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 7d47e49c0..197bb592e 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 6b896dbde..36cb82f79 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 65e5a1e41..c3b2f1e58 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 */