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.
This commit is contained in:
Aleksander Morgado
2018-07-03 15:03:31 +02:00
committed by Dan Williams
parent b2d859e370
commit 2b85d27fc0
3 changed files with 13 additions and 62 deletions

View File

@@ -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);
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), str);
g_free (str);
}
}
static void

View File

@@ -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 {

View File

@@ -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,