From 7ecd8955e8dc0442c27d31853714d0d596344697 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 15 Oct 2020 17:14:51 +0200 Subject: [PATCH] voicecall: Make is_emergency_number API available to drivers It will be needed by the qmimodem driver to decide which type of call to request to the modem. --- include/voicecall.h | 3 +++ src/voicecall.c | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/voicecall.h b/include/voicecall.h index a704b655..bb9ec385 100644 --- a/include/voicecall.h +++ b/include/voicecall.h @@ -182,6 +182,9 @@ void ofono_voicecall_ssn_mt_notify(struct ofono_voicecall *vc, unsigned int id, int code, int index, const struct ofono_phone_number *ph); +ofono_bool_t ofono_voicecall_is_emergency_number(struct ofono_voicecall *vc, + const char *number); + #ifdef __cplusplus } #endif diff --git a/src/voicecall.c b/src/voicecall.c index 93a92544..86a679c3 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -384,12 +384,6 @@ static void tone_request_finish(struct ofono_voicecall *vc, g_free(entry); } -static gboolean is_emergency_number(struct ofono_voicecall *vc, - const char *number) -{ - return g_hash_table_lookup_extended(vc->en_list, number, NULL, NULL); -} - static void append_voicecall_properties(struct voicecall *v, DBusMessageIter *dict) { @@ -459,7 +453,7 @@ static void append_voicecall_properties(struct voicecall *v, ofono_dbus_dict_append(dict, "Icon", DBUS_TYPE_BYTE, &v->icon_id); - if (is_emergency_number(v->vc, callerid) == TRUE) + if (ofono_voicecall_is_emergency_number(v->vc, callerid) == TRUE) emergency_call = TRUE; else emergency_call = FALSE; @@ -983,7 +977,7 @@ static void voicecall_set_call_lineid(struct voicecall *v, "LineIdentification", DBUS_TYPE_STRING, &lineid_str); - if (is_emergency_number(v->vc, lineid_str)) { + if (ofono_voicecall_is_emergency_number(v->vc, lineid_str)) { dbus_bool_t emergency_call = TRUE; ofono_dbus_signal_property_changed(conn, path, @@ -1473,7 +1467,7 @@ static void manager_dial_callback(const struct ofono_error *error, void *data) } else { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); - if (is_emergency_number(vc, number) == TRUE) + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) __ofono_modem_dec_emergency_mode(modem); reply = __ofono_error_failed(vc->pending); @@ -1517,7 +1511,7 @@ static int voicecall_dial(struct ofono_voicecall *vc, const char *number, if (voicecalls_have_active(vc) && voicecalls_have_held(vc)) return -EBUSY; - if (is_emergency_number(vc, number) == TRUE) + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) __ofono_modem_inc_emergency_mode(modem); string_to_phone_number(number, &ph); @@ -2363,7 +2357,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, voicecall_emit_disconnect_reason(call, reason); number = phone_number_to_string(&call->call->phone_number); - if (is_emergency_number(vc, number) == TRUE) + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) __ofono_modem_dec_emergency_mode(modem); voicecall_set_call_status(call, CALL_STATUS_DISCONNECTED); @@ -3515,7 +3509,7 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data) if (v == NULL) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); - if (is_emergency_number(vc, number) == TRUE) + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) __ofono_modem_dec_emergency_mode(modem); } @@ -3788,7 +3782,7 @@ static void dial_request_cb(const struct ofono_error *error, void *data) v = dial_handle_result(vc, error, number, &need_to_emit); if (v == NULL) { - if (is_emergency_number(vc, number) == TRUE) { + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); @@ -3823,7 +3817,7 @@ static void dial_request(struct ofono_voicecall *vc) { const char *number = phone_number_to_string(&vc->dial_req->ph); - if (is_emergency_number(vc, number) == TRUE) { + if (ofono_voicecall_is_emergency_number(vc, number) == TRUE) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); __ofono_modem_inc_emergency_mode(modem); @@ -4218,3 +4212,9 @@ void ofono_voicecall_ssn_mo_notify(struct ofono_voicecall *vc, break; } } + +ofono_bool_t ofono_voicecall_is_emergency_number(struct ofono_voicecall *vc, + const char *number) +{ + return g_hash_table_lookup_extended(vc->en_list, number, NULL, NULL); +}