summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2010-08-26 15:09:11 -0400
committerDavid Zeuthen <davidz@redhat.com>2010-08-26 15:15:29 -0400
commitbab39d31db875a7359cd3e02e7f57ce264db65da (patch)
treeddb92ef4f9bff11178072c9b08a3ad7675ffadc0
parentdf1106526a224a67b61c8f6b4815663a64515155 (diff)
Use new ::g-properties-changed-emitted signal in gdbus-codegen(1)
This allows us to also emit changes on the manager object. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--data/org.freedesktop.UDisks.xml8
-rw-r--r--src/linuxdaemon.c38
2 files changed, 45 insertions, 1 deletions
diff --git a/data/org.freedesktop.UDisks.xml b/data/org.freedesktop.UDisks.xml
index 6b72892..5f1e0e3 100644
--- a/data/org.freedesktop.UDisks.xml
+++ b/data/org.freedesktop.UDisks.xml
@@ -822,6 +822,10 @@
<doc:doc><doc:summary>Object path of device that was added.</doc:summary></doc:doc>
</arg>
+ <arg name="properties" type="a{sa{sv}}">
+ <doc:doc><doc:summary>Properties for the interfaces for the device that was added.</doc:summary></doc:doc>
+ </arg>
+
<doc:doc>
<doc:description>
<doc:para>
@@ -854,6 +858,10 @@
<doc:doc><doc:summary>Object path of device that was changed.</doc:summary></doc:doc>
</arg>
+ <arg name="changed_properties" type="a{sa{sv}}">
+ <doc:doc><doc:summary>The properties that changed.</doc:summary></doc:doc>
+ </arg>
+
<doc:doc>
<doc:description>
<doc:para>
diff --git a/src/linuxdaemon.c b/src/linuxdaemon.c
index 7c720ee..ffa4db8 100644
--- a/src/linuxdaemon.c
+++ b/src/linuxdaemon.c
@@ -231,7 +231,15 @@ static void
emit_added (LinuxDaemon *daemon,
LinuxDevice *device)
{
- daemon_emit_device_added (DAEMON (daemon), linux_device_get_object_path (device));
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sa{sv}}"));
+ g_variant_builder_add (&builder,
+ "{s@a{sv}}",
+ device_interface_info ()->name,
+ device_properties (DEVICE (device)));
+ daemon_emit_device_added (DAEMON (daemon),
+ linux_device_get_object_path (device),
+ g_variant_builder_end (&builder));
}
static void
@@ -241,6 +249,25 @@ emit_removed (LinuxDaemon *daemon,
daemon_emit_device_removed (DAEMON (daemon), linux_device_get_object_path (device));
}
+static gboolean
+on_properties_changed_emitted (LinuxDevice *exported_object,
+ GVariant *changed_properties,
+ const gchar* const *invalidated_properties,
+ gpointer user_data)
+{
+ LinuxDaemon *daemon = LINUX_DAEMON (user_data);
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sa{sv}}"));
+ g_variant_builder_add (&builder,
+ "{s@a{sv}}",
+ device_interface_info ()->name,
+ changed_properties);
+ daemon_emit_device_changed (DAEMON (daemon),
+ linux_device_get_object_path (LINUX_DEVICE (exported_object)),
+ g_variant_builder_end (&builder));
+ return FALSE; /* don't consume the signal */
+}
+
static void
handle_device_uevent (LinuxDaemon *daemon,
const gchar *action,
@@ -258,6 +285,10 @@ handle_device_uevent (LinuxDaemon *daemon,
if (maybe_export_unexport_object (daemon, device, FALSE))
emit_removed (daemon, device);
+ g_warn_if_fail (g_signal_handlers_disconnect_by_func (device,
+ G_CALLBACK (on_properties_changed_emitted),
+ daemon) == 1);
+
g_hash_table_remove (daemon->priv->map_sysfs_path_to_object, sysfs_path);
g_print ("removed object with sysfs path `%s'\n", sysfs_path);
}
@@ -290,6 +321,11 @@ handle_device_uevent (LinuxDaemon *daemon,
object_path = linux_device_get_object_path (device);
visible = linux_device_get_visible (device);
+ g_signal_connect (device,
+ "g-properties-changed-emitted",
+ G_CALLBACK (on_properties_changed_emitted),
+ daemon);
+
g_hash_table_insert (daemon->priv->map_sysfs_path_to_object,
g_strdup (sysfs_path),
device);