mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-14 00:17:35 +00:00
ui-call-data: Provide API to get the name of the origin used
This will be used as a fallback when displaying the call details (see #222).
This commit is contained in:
parent
d24d1c8c59
commit
7e538d736e
4 changed files with 55 additions and 26 deletions
|
@ -153,31 +153,6 @@ update_state_flags (CallsManager *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_dial_protocol_activated (GSimpleAction *action,
|
on_dial_protocol_activated (GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
|
@ -189,7 +164,7 @@ on_dial_protocol_activated (GSimpleAction *action,
|
||||||
g_autofree char *origin_id = NULL;
|
g_autofree char *origin_id = NULL;
|
||||||
|
|
||||||
g_variant_get (parameter, "(ss)", &target, &origin_id);
|
g_variant_get (parameter, "(ss)", &target, &origin_id);
|
||||||
origin = lookup_origin_by_id (self, origin_id);
|
origin = calls_manager_get_origin_by_id (self, origin_id);
|
||||||
|
|
||||||
if (origin) {
|
if (origin) {
|
||||||
calls_origin_dial (origin, target);
|
calls_origin_dial (origin, target);
|
||||||
|
@ -1132,3 +1107,32 @@ calls_manager_get_settings (CallsManager *self)
|
||||||
|
|
||||||
return self->settings;
|
return self->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls_manager_get_origin_by_id:
|
||||||
|
* @self: The #CallsManager
|
||||||
|
* @origin_id: The id to use for the lookup
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #CallsOrigin if found, %NULL otherwise
|
||||||
|
*/
|
||||||
|
CallsOrigin *
|
||||||
|
calls_manager_get_origin_by_id (CallsManager *self,
|
||||||
|
const char *origin_id)
|
||||||
|
{
|
||||||
|
uint n_origins;
|
||||||
|
|
||||||
|
g_return_val_if_fail (CALLS_IS_MANAGER (self), NULL);
|
||||||
|
g_return_val_if_fail (origin_id && *origin_id, NULL);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ GListModel *calls_manager_get_origins (CallsManager *sel
|
||||||
GList *calls_manager_get_calls (CallsManager *self);
|
GList *calls_manager_get_calls (CallsManager *self);
|
||||||
GListModel *calls_manager_get_suitable_origins (CallsManager *self,
|
GListModel *calls_manager_get_suitable_origins (CallsManager *self,
|
||||||
const char *target);
|
const char *target);
|
||||||
|
CallsOrigin *calls_manager_get_origin_by_id (CallsManager *self,
|
||||||
|
const char *origin_id);
|
||||||
const gchar *calls_manager_get_contact_name (CallsCall *call);
|
const gchar *calls_manager_get_contact_name (CallsCall *call);
|
||||||
gboolean calls_manager_has_active_call (CallsManager *self);
|
gboolean calls_manager_has_active_call (CallsManager *self);
|
||||||
void calls_manager_hang_up_all_calls (CallsManager *self);
|
void calls_manager_hang_up_all_calls (CallsManager *self);
|
||||||
|
|
|
@ -714,6 +714,28 @@ calls_ui_call_data_get_origin_id (CallsUiCallData *self)
|
||||||
return self->origin_id;
|
return self->origin_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls_ui_call_data_dup_origin_name:
|
||||||
|
* @self: a #CallsUiCallData
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The name of the origin this call was placed from
|
||||||
|
* or %NULL, if unknown.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
calls_ui_call_data_dup_origin_name (CallsUiCallData *self)
|
||||||
|
{
|
||||||
|
CallsOrigin *origin;
|
||||||
|
g_return_val_if_fail (CALLS_IS_UI_CALL_DATA (self), NULL);
|
||||||
|
|
||||||
|
origin = calls_manager_get_origin_by_id (calls_manager_get_default (),
|
||||||
|
self->origin_id);
|
||||||
|
|
||||||
|
if (origin)
|
||||||
|
return calls_origin_get_name (origin);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calls_call_state_to_cui_call_state:
|
* calls_call_state_to_cui_call_state:
|
||||||
* @state: A #CallsCallState
|
* @state: A #CallsCallState
|
||||||
|
|
|
@ -42,6 +42,7 @@ gboolean calls_ui_call_data_get_silenced (CallsUiCallData *
|
||||||
gboolean calls_ui_call_data_get_ui_active (CallsUiCallData *self);
|
gboolean calls_ui_call_data_get_ui_active (CallsUiCallData *self);
|
||||||
CallsCallType calls_ui_call_data_get_call_type (CallsUiCallData *self);
|
CallsCallType calls_ui_call_data_get_call_type (CallsUiCallData *self);
|
||||||
const char *calls_ui_call_data_get_origin_id (CallsUiCallData *self);
|
const char *calls_ui_call_data_get_origin_id (CallsUiCallData *self);
|
||||||
|
char *calls_ui_call_data_dup_origin_name (CallsUiCallData *self);
|
||||||
|
|
||||||
CuiCallState calls_call_state_to_cui_call_state (CallsCallState state);
|
CuiCallState calls_call_state_to_cui_call_state (CallsCallState state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue