origin: Allow to fetch country code

This is an optional method as not all origins might support this
(e.g. SIP).
This commit is contained in:
Guido Günther
2022-12-21 19:13:22 +01:00
committed by Evangelos Ribeiro Tzaras
parent d598acd96b
commit 6cdae3fd40
3 changed files with 27 additions and 3 deletions

View File

@@ -229,3 +229,24 @@ calls_origin_supports_protocol (CallsOrigin *self,
return iface->supports_protocol (self, protocol);
}
/**
* calls_origin_get_country_code:
* @self: A #CallsOrigin
*
* Returns: (nullable): The iso country code
*/
const char *
calls_origin_get_country_code (CallsOrigin *self)
{
CallsOriginInterface *iface;
g_return_val_if_fail (CALLS_IS_ORIGIN (self), FALSE);
iface = CALLS_ORIGIN_GET_IFACE (self);
/* country code is optional */
if (iface->get_country_code == NULL)
return NULL;
return iface->get_country_code (self);
}

View File

@@ -43,6 +43,7 @@ struct _CallsOriginInterface {
const char *number);
gboolean (*supports_protocol) (CallsOrigin *self,
const char *protocol);
const char * (*get_country_code) (CallsOrigin *self);
};
typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, CallsOrigin* origin);
@@ -58,6 +59,7 @@ void calls_origin_dial (CallsOrigin *self,
gboolean calls_origin_supports_protocol (CallsOrigin *self,
const char *protocol);
GStrv calls_origin_get_emergency_numbers (CallsOrigin *self);
const char * calls_origin_get_country_code (CallsOrigin *self);
G_END_DECLS