[calls] util: Add API to query call icon names



commit abdb601afa2e06e58fc2a16bc320c0ca616f0d24
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Tue Dec 7 10:59:37 2021 +0100

    util: Add API to query call icon names
    
    This can later be used in the call history or in the call details
    instead of always constructing the name repeatedly in private functions.

 src/util.c | 25 +++++++++++++++++++++++++
 src/util.h |  2 ++
 2 files changed, 27 insertions(+)
---
diff --git a/src/util.c b/src/util.c
index fcc1a977..c356e15d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -273,3 +273,28 @@ dtmf_tone_key_is_valid (gchar key)
     ||  key == '#';
 }
 
+
+static const char * const type_icon_name[] = {
+  "call-arrow-outgoing-symbolic",
+  "call-arrow-outgoing-missed-symbolic",
+  "call-arrow-incoming-symbolic",
+  "call-arrow-incoming-missed-symbolic",
+};
+
+/**
+ * get_call_icon_type_name:
+ * @inbound: Whether the call was inbound
+ * @missed: Whether the call was missed
+ *
+ * Returns: (transfer null): The icon symbolic name to use in the history, etc
+ */
+const char *
+get_call_icon_symbolic_name (gboolean inbound,
+                             gboolean missed)
+{
+  guint index = 0;
+
+  index = ((inbound) << 1) + missed;
+
+  return type_icon_name[index];
+}
diff --git a/src/util.h b/src/util.h
index 2d381197..efc791e9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -142,6 +142,8 @@ const char* get_protocol_from_address (const char *target);
 const char* get_protocol_from_address_with_fallback (const char *target);
 
 gboolean dtmf_tone_key_is_valid (char key);
+const char *get_call_icon_symbolic_name (gboolean inbound,
+                                         gboolean missed);
 
 G_END_DECLS
 


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