[calls] manager: Implement lookup_origin_by_id()



commit d24d1c8c59f279b63905e7717936a02c2d738ea8
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Tue Feb 8 14:03:58 2022 +0100

    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 31ee4856..d34c82ba 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;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]