mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-09-28 14:55:26 +00:00
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:
parent
d598acd96b
commit
6cdae3fd40
3 changed files with 27 additions and 3 deletions
|
@ -23,8 +23,8 @@ test_dummy_origin_object (OriginFixture *fixture,
|
|||
|
||||
|
||||
static void
|
||||
test_dummy_origin_get_name (OriginFixture *fixture,
|
||||
gconstpointer user_data)
|
||||
test_dummy_origin_getters (OriginFixture *fixture,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
CallsOrigin *origin;
|
||||
g_autofree char *name = NULL;
|
||||
|
@ -34,6 +34,7 @@ test_dummy_origin_get_name (OriginFixture *fixture,
|
|||
name = calls_origin_get_name (origin);
|
||||
g_assert_nonnull (name);
|
||||
g_assert_cmpstr (name, ==, TEST_ORIGIN_NAME);
|
||||
g_assert_null (calls_origin_get_country_code (origin));
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +85,7 @@ main (gint argc,
|
|||
#define add_test(name) add_calls_test(Origin, origin, name)
|
||||
|
||||
add_test(object);
|
||||
add_test(get_name);
|
||||
add_test(getters);
|
||||
add_test(calls);
|
||||
|
||||
#undef add_test
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue