diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-07-03 15:03:31 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-10-16 17:09:21 +0000 |
commit | 2b85d27fc00ccbe34a2dc9e2c679fa273967c7cb (patch) | |
tree | 64f7dc97126abced0ffaf0d7b42856d6c347b570 /src | |
parent | b2d859e37084099295cb96725e7e9f03b81dc84f (diff) | |
download | ModemManager-2b85d27fc00ccbe34a2dc9e2c679fa273967c7cb.tar.gz |
iface-modem-voice: simplify reporting new incoming calls
Allow creating a new incoming call object also when we receive +CLIP,
so that we can have the remote caller number as soon as the object is
created.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-modem.c | 22 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.c | 44 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.h | 9 |
3 files changed, 13 insertions, 62 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index ddbb8205e..92c87e456 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -6928,7 +6928,7 @@ ring_received (MMPortSerialAt *port, MMBroadbandModem *self) { mm_dbg ("Ringing"); - mm_iface_modem_voice_incoming_call (MM_IFACE_MODEM_VOICE (self)); + mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL); } static void @@ -6936,7 +6936,6 @@ cring_received (MMPortSerialAt *port, GMatchInfo *info, MMBroadbandModem *self) { - /* The match info gives us in which storage the index applies */ gchar *str; /* We could have "VOICE" or "DATA". Now consider only "VOICE" */ @@ -6945,7 +6944,7 @@ cring_received (MMPortSerialAt *port, mm_dbg ("Ringing (%s)", str); g_free (str); - mm_iface_modem_voice_incoming_call (MM_IFACE_MODEM_VOICE (self)); + mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL); } static void @@ -6953,24 +6952,11 @@ clip_received (MMPortSerialAt *port, GMatchInfo *info, MMBroadbandModem *self) { - /* The match info gives us in which storage the index applies */ gchar *str; str = mm_get_string_unquoted_from_match_info (info, 1); - - if (str) { - guint validity = 0; - guint type = 0; - - mm_get_uint_from_match_info (info, 2, &type); - mm_get_uint_from_match_info (info, 3, &validity); - - mm_dbg ("Caller ID received: number '%s', type '%d', validity '%d'", str, type, validity); - - mm_iface_modem_voice_update_incoming_call_number (MM_IFACE_MODEM_VOICE (self), str, type, validity); - - g_free (str); - } + mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), str); + g_free (str); } static void diff --git a/src/mm-iface-modem-voice.c b/src/mm-iface-modem-voice.c index 2ba9d5d36..e27889943 100644 --- a/src/mm-iface-modem-voice.c +++ b/src/mm-iface-modem-voice.c @@ -72,7 +72,8 @@ create_outgoing_call_from_properties (MMIfaceModemVoice *self, /*****************************************************************************/ void -mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self) +mm_iface_modem_voice_report_incoming_call (MMIfaceModemVoice *self, + const gchar *number) { MMBaseCall *call = NULL; MMCallList *list = NULL; @@ -88,15 +89,17 @@ mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self) call = mm_call_list_get_first_ringing_in_call (list); - /* If call exists already, refresh its validity */ + /* If call exists already, refresh its validity and set number if it wasn't set */ if (call) { + if (number && !mm_gdbus_call_get_number (MM_GDBUS_CALL (call))) + mm_gdbus_call_set_number (MM_GDBUS_CALL (call), number); mm_base_call_incoming_refresh (call); g_object_unref (list); return; } mm_dbg ("Creating new incoming call..."); - call = create_incoming_call (self, NULL); + call = create_incoming_call (self, number); /* Set the state as ringing in */ mm_base_call_change_state (call, MM_CALL_STATE_RINGING_IN, MM_CALL_STATE_REASON_INCOMING_NEW); @@ -111,41 +114,6 @@ mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self) g_object_unref (list); } -gboolean -mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *self, - gchar *number, - guint type, - guint validity) -{ - 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_in_call (list); - - if (call) { - mm_gdbus_call_set_number (MM_GDBUS_CALL (call), number); - - /* - * TODO: Maybe also this parameters should be used: - * - type - * - validity - */ - - updated = TRUE; - } else { - mm_dbg ("Incoming call does not exist yet"); - } - } - - return updated; -} - /*****************************************************************************/ typedef struct { diff --git a/src/mm-iface-modem-voice.h b/src/mm-iface-modem-voice.h index df3d399fe..86f1333fc 100644 --- a/src/mm-iface-modem-voice.h +++ b/src/mm-iface-modem-voice.h @@ -118,12 +118,9 @@ void mm_iface_modem_voice_shutdown (MMIfaceModemVoice *self); void mm_iface_modem_voice_bind_simple_status (MMIfaceModemVoice *self, MMSimpleStatus *status); -/* CALL creation */ -void mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self); -gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *self, - gchar *number, - guint type, - guint validity); +/* Incoming call management */ +void mm_iface_modem_voice_report_incoming_call (MMIfaceModemVoice *self, + const gchar *number); /* Look for a new valid multipart reference */ guint8 mm_iface_modem_voice_get_local_multipart_reference (MMIfaceModemVoice *self, |