From cde517096b1dbf54bbe9dcba6ed478a28d5f85e6 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Tue, 1 Feb 2022 10:54:07 +0100 Subject: [PATCH] dbus: Add hint property This is a dictionary to allow for future extensibility. Currently we're only hinting if the UI should be shown for a given call. --- src/calls-dbus-manager.c | 38 +++++++++++++++++++++++++++++++ src/dbus/org.gnome.Calls.Call.xml | 14 ++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/calls-dbus-manager.c b/src/calls-dbus-manager.c index 1b4a84f..4e2cf19 100644 --- a/src/calls-dbus-manager.c +++ b/src/calls-dbus-manager.c @@ -202,6 +202,38 @@ on_handle_call_silence (CallsDBusCallsCall *skeleton, } +static GVariant * +build_hints (CallsUiCallData *call) +{ + GVariantDict dict; + + g_return_val_if_fail (CALLS_IS_UI_CALL_DATA (call), NULL); + + g_variant_dict_init (&dict, NULL); + + g_variant_dict_insert (&dict, "ui-active", "b", + calls_ui_call_data_get_ui_active (call)); + + return g_variant_dict_end (&dict); +} + + +static void +on_notify_update_hints (CallsUiCallData *call, + GParamSpec *unused, + CallsDBusCallsCall *iface) +{ + GVariant *hints; + + g_assert (CALLS_IS_UI_CALL_DATA (call)); + g_assert (CALLS_DBUS_IS_CALLS_CALL (iface)); + + hints = build_hints (call); + + calls_dbus_calls_call_set_hints (iface, hints); +} + + static void call_added_cb (CallsDBusManager *self, CuiCall *call) { @@ -241,6 +273,12 @@ call_added_cb (CallsDBusManager *self, CuiCall *call) /* TODO: once calls supports encryption */ calls_dbus_calls_call_set_encrypted (iface, FALSE); + g_signal_connect (call, + "notify::ui-active", + G_CALLBACK (on_notify_update_hints), + iface); + on_notify_update_hints (CALLS_UI_CALL_DATA (call), NULL, iface); + /* Export with properties bound to reduce DBus traffic: */ g_debug ("Exporting %p at %s", call, path); g_dbus_object_manager_server_export (self->object_manager, G_DBUS_OBJECT_SKELETON (object)); diff --git a/src/dbus/org.gnome.Calls.Call.xml b/src/dbus/org.gnome.Calls.Call.xml index 7fe4542..972e7e5 100644 --- a/src/dbus/org.gnome.Calls.Call.xml +++ b/src/dbus/org.gnome.Calls.Call.xml @@ -147,5 +147,19 @@ + + + + + + Additional hints about this call + + +