mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 04:15:32 +00:00
ui-call-data: Store origin id and adapt to changes
This commit is contained in:
parent
16b86c29b2
commit
30c4e90499
5 changed files with 53 additions and 7 deletions
|
@ -243,12 +243,14 @@ static void
|
|||
add_call (CallsManager *self, CallsCall *call, CallsOrigin *origin)
|
||||
{
|
||||
CallsUiCallData *call_data;
|
||||
g_autofree char *origin_id = NULL;
|
||||
|
||||
g_return_if_fail (CALLS_IS_MANAGER (self));
|
||||
g_return_if_fail (CALLS_IS_ORIGIN (origin));
|
||||
g_return_if_fail (CALLS_IS_CALL (call));
|
||||
|
||||
call_data = calls_ui_call_data_new (call);
|
||||
origin_id = calls_origin_get_id (origin);
|
||||
call_data = calls_ui_call_data_new (call, origin_id);
|
||||
g_hash_table_insert (self->calls, call, call_data);
|
||||
|
||||
/* TODO get rid of SIGNAL_CALL_ADD signal */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
enum {
|
||||
PROP_0,
|
||||
PROP_CALL,
|
||||
PROP_ORIGIN_ID,
|
||||
PROP_INBOUND,
|
||||
PROP_PROTOCOL,
|
||||
PROP_DISPLAY_NAME,
|
||||
|
@ -66,6 +67,7 @@ struct _CallsUiCallData
|
|||
guint timer_id;
|
||||
|
||||
CuiCallState state;
|
||||
char *origin_id;
|
||||
gboolean silenced;
|
||||
|
||||
gboolean ui_active; /* whether a UI should be shown (or the ringer should ring) */
|
||||
|
@ -420,6 +422,10 @@ calls_ui_call_data_set_property (GObject *object,
|
|||
set_call_data (self, g_value_dup_object (value));
|
||||
break;
|
||||
|
||||
case PROP_ORIGIN_ID:
|
||||
self->origin_id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -441,6 +447,10 @@ calls_ui_call_data_get_property (GObject *object,
|
|||
g_value_set_object (value, self->call);
|
||||
break;
|
||||
|
||||
case PROP_ORIGIN_ID:
|
||||
g_value_set_string (value, calls_ui_call_data_get_origin_id (self));
|
||||
break;
|
||||
|
||||
case PROP_INBOUND:
|
||||
g_value_set_boolean (value, calls_ui_call_data_get_inbound (self));
|
||||
break;
|
||||
|
@ -498,6 +508,8 @@ calls_ui_call_data_dispose (GObject *object)
|
|||
g_clear_object (&self->call);
|
||||
g_clear_object (&self->best_match);
|
||||
|
||||
g_clear_pointer (&self->origin_id, g_free);
|
||||
|
||||
g_clear_handle_id (&self->timer_id, g_source_remove);
|
||||
g_clear_pointer (&self->timer, g_timer_destroy);
|
||||
|
||||
|
@ -529,6 +541,16 @@ calls_ui_call_data_class_init (CallsUiCallDataClass *klass)
|
|||
|
||||
g_object_class_install_property (object_class, PROP_CALL, props[PROP_CALL]);
|
||||
|
||||
props[PROP_ORIGIN_ID] =
|
||||
g_param_spec_string ("origin-id",
|
||||
"Origin ID",
|
||||
"ID of the origin used for the call",
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ORIGIN_ID, props[PROP_ORIGIN_ID]);
|
||||
|
||||
props[PROP_INBOUND] =
|
||||
g_param_spec_boolean ("inbound",
|
||||
"Inbound",
|
||||
|
@ -606,9 +628,13 @@ calls_ui_call_data_class_init (CallsUiCallDataClass *klass)
|
|||
}
|
||||
|
||||
CallsUiCallData *
|
||||
calls_ui_call_data_new (CallsCall *call)
|
||||
calls_ui_call_data_new (CallsCall *call,
|
||||
const char *origin_id)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_UI_CALL_DATA, "call", call, NULL);
|
||||
return g_object_new (CALLS_TYPE_UI_CALL_DATA,
|
||||
"call", call,
|
||||
"origin-id", origin_id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -673,6 +699,21 @@ calls_ui_call_data_get_call_type (CallsUiCallData *self)
|
|||
return calls_call_get_call_type (self->call);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_ui_call_data_get_origin_id:
|
||||
* @self: a #CallsUiCallData
|
||||
*
|
||||
* Returns: (transfer none): The id of the origin this call was placed from
|
||||
* or %NULL, if unknown.
|
||||
*/
|
||||
const char *
|
||||
calls_ui_call_data_get_origin_id (CallsUiCallData *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_UI_CALL_DATA (self), NULL);
|
||||
|
||||
return self->origin_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_call_state_to_cui_call_state:
|
||||
* @state: A #CallsCallState
|
||||
|
|
|
@ -35,11 +35,13 @@ G_BEGIN_DECLS
|
|||
|
||||
G_DECLARE_FINAL_TYPE (CallsUiCallData, calls_ui_call_data, CALLS, UI_CALL_DATA, GObject)
|
||||
|
||||
CallsUiCallData *calls_ui_call_data_new (CallsCall *call);
|
||||
CallsUiCallData *calls_ui_call_data_new (CallsCall *call,
|
||||
const char *origin_id);
|
||||
void calls_ui_call_data_silence_ring (CallsUiCallData *self);
|
||||
gboolean calls_ui_call_data_get_silenced (CallsUiCallData *self);
|
||||
gboolean calls_ui_call_data_get_ui_active (CallsUiCallData *self);
|
||||
CallsCallType calls_ui_call_data_get_call_type (CallsUiCallData *self);
|
||||
const char *calls_ui_call_data_get_origin_id (CallsUiCallData *self);
|
||||
|
||||
CuiCallState calls_call_state_to_cui_call_state (CallsCallState state);
|
||||
|
||||
|
|
|
@ -190,9 +190,9 @@ setup_test_data (void **state)
|
|||
data->manager = calls_manager_get_default ();
|
||||
data->ringer = calls_ringer_new ();
|
||||
data->call_one = calls_mock_call_new ();
|
||||
data->ui_call_one = calls_ui_call_data_new (CALLS_CALL (data->call_one));
|
||||
data->ui_call_one = calls_ui_call_data_new (CALLS_CALL (data->call_one), NULL);
|
||||
data->call_two = calls_mock_call_new ();
|
||||
data->ui_call_two = calls_ui_call_data_new (CALLS_CALL (data->call_two));
|
||||
data->ui_call_two = calls_ui_call_data_new (CALLS_CALL (data->call_two), NULL);
|
||||
data->loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
*state = data;
|
||||
|
|
|
@ -53,11 +53,12 @@ test_cui_call_properties (void)
|
|||
|
||||
g_assert_true (CALLS_IS_CALL (mock_call));
|
||||
call = CALLS_CALL (mock_call);
|
||||
ui_call = calls_ui_call_data_new (call);
|
||||
ui_call = calls_ui_call_data_new (call, "test-id");
|
||||
|
||||
g_assert_true (CUI_IS_CALL (ui_call));
|
||||
cui_call = CUI_CALL (ui_call);
|
||||
|
||||
g_assert_cmpstr (calls_ui_call_data_get_origin_id (ui_call), ==, "test-id");
|
||||
g_assert_true (calls_call_get_id (call) == cui_call_get_id (cui_call));
|
||||
g_assert_true (calls_call_get_name (call) == cui_call_get_display_name (cui_call));
|
||||
g_assert_true (calls_call_state_to_cui_call_state (calls_call_get_state (call)) ==
|
||||
|
|
Loading…
Reference in a new issue