From 3b951d20f4ae2d6d11b6e7a7485b013aadde050c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 26 Oct 2017 10:20:37 -0500 Subject: [PATCH] voicecall: expand synthesize_outgoing_call synthethize_outgoing_call was only used once from dial_handle_result. So move all the logic of registering the call to D-Bus and adding it to the voicecalls list to that function. This will allow synthethize_outgoing_call to be used from other callbacks where the dial callback is guaranteed to return before any call state notifications, e.g. in the case of +BLDN. --- src/voicecall.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index e5b9f505..a8a2bcde 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -1354,15 +1354,16 @@ static ofono_bool_t clir_string_to_clir(const char *clirstr, } } -static struct ofono_call *synthesize_outgoing_call(struct ofono_voicecall *vc, - const char *number) +static struct voicecall *synthesize_outgoing_call(struct ofono_voicecall *vc, + const char *number) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); struct ofono_call *call; + struct voicecall *v; call = g_try_new0(struct ofono_call, 1); if (call == NULL) - return call; + return NULL; call->id = __ofono_modem_callid_next(modem); @@ -1381,7 +1382,20 @@ static struct ofono_call *synthesize_outgoing_call(struct ofono_voicecall *vc, call->status = CALL_STATUS_DIALING; call->clip_validity = CLIP_VALIDITY_VALID; - return call; + v = voicecall_create(vc, call); + if (v == NULL) { + g_free(call); + return NULL; + } + + v->detect_time = time(NULL); + + DBG("Registering new call: %d", call->id); + voicecall_dbus_register(v); + + vc->call_list = g_slist_insert_sorted(vc->call_list, v, call_compare); + + return v; } static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, @@ -1391,7 +1405,6 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, { GSList *l; struct voicecall *v; - struct ofono_call *call; *need_to_emit = FALSE; @@ -1424,22 +1437,10 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, goto handled; } - call = synthesize_outgoing_call(vc, number); - if (call == NULL) + v = synthesize_outgoing_call(vc, number); + if (!v) return NULL; - v = voicecall_create(vc, call); - if (v == NULL) - return NULL; - - v->detect_time = time(NULL); - - DBG("Registering new call: %d", call->id); - voicecall_dbus_register(v); - - vc->call_list = g_slist_insert_sorted(vc->call_list, v, - call_compare); - *need_to_emit = TRUE; handled: