From abdb601afa2e06e58fc2a16bc320c0ca616f0d24 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Tue, 7 Dec 2021 10:59:37 +0100 Subject: [PATCH] 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 fcc1a97..c356e15 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 2d38119..efc791e 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