1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-13 16:07:36 +00:00

emergency-calls-manager: Add support for dialing emergency numbers

We just pick the first matching provider.
This commit is contained in:
Guido Günther 2023-04-07 15:00:55 +02:00 committed by Evangelos Ribeiro Tzaras
parent b58be993a6
commit e5a4d899f8

View file

@ -67,9 +67,34 @@ handle_call_emergency_contact (CallsDBusEmergencyCalls *object,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
const gchar *arg_id) const gchar *arg_id)
{ {
g_debug ("Calling %s", arg_id); CallsEmergencyCallsManger *self = CALLS_EMERGENCY_CALLS_MANAGER (object);
g_debug ("Looking for emergency number %s", arg_id);
g_return_val_if_fail (CALLS_IS_EMERGENCY_CALLS_MANAGER (self), FALSE);
/* Pick the first origin that supports the given emergency number */
for (int i = 0; i < g_list_model_get_n_items (self->origins); i++) {
g_autoptr (CallsOrigin) origin = g_list_model_get_item (self->origins, i);
g_auto (GStrv) emergency_numbers = NULL;
emergency_numbers = calls_origin_get_emergency_numbers (origin);
if (!emergency_numbers)
continue;
for (int j = 0; j < g_strv_length (emergency_numbers); j++) {
if (g_strcmp0 (arg_id, emergency_numbers[j]) == 0) {
g_debug ("Dialing %s via %s", arg_id, calls_origin_get_name (origin));
calls_origin_dial (origin, arg_id);
calls_dbus_emergency_calls_complete_call_emergency_contact (object, invocation); calls_dbus_emergency_calls_complete_call_emergency_contact (object, invocation);
goto done;
}
}
}
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_NOT_SUPPORTED,
"%s not a known emergency number", arg_id);
done:
return TRUE; return TRUE;
} }