From d24d1c8c59f279b63905e7717936a02c2d738ea8 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Tue, 8 Feb 2022 14:03:58 +0100 Subject: [PATCH] manager: Implement lookup_origin_by_id() This function is used in the activate callback for the per protocol dial actions to choose the correct origin to place a call from. If an origin cannot be found it will return NULL which will lead to the fallback "app.dial" action being invoked. --- src/calls-manager.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/calls-manager.c b/src/calls-manager.c index 31ee485..d34c82b 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -157,6 +157,23 @@ static CallsOrigin * lookup_origin_by_id (CallsManager *self, const char *origin_id) { + uint n_origins; + + g_assert (CALLS_IS_MANAGER (self)); + + if (!origin_id || !*origin_id) + goto out; + + n_origins = g_list_model_get_n_items (G_LIST_MODEL (self->origins)); + for (uint i = 0; i < n_origins; i++) { + g_autoptr (CallsOrigin) origin = + g_list_model_get_item (G_LIST_MODEL (self->origins), i); + g_autofree char *id = calls_origin_get_id (origin); + + if (g_strcmp0 (id, origin_id) == 0) + return origin; + } + out: return NULL; }