[calls] dbus: Add hint property



commit cde517096b1dbf54bbe9dcba6ed478a28d5f85e6
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Tue Feb 1 10:54:07 2022 +0100

    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 1b4a84f0..4e2cf191 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 7fe45429..972e7e5c 100644
--- a/src/dbus/org.gnome.Calls.Call.xml
+++ b/src/dbus/org.gnome.Calls.Call.xml
@@ -147,5 +147,19 @@
         </doc:description>
       </doc:doc>
     </property>
+
+    <!--
+        Hints:
+
+        Additional property dictionary with hints.
+        "ui-active" hints whether the UI should be shown or not.
+    -->
+    <property name="Hints" type="a{sv}" access="read">
+      <doc:doc>
+        <doc:description>
+          <doc:para>Additional hints about this call</doc:para>
+        </doc:description>
+      </doc:doc>
+    </property>
   </interface>
 </node>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]