Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [WORKAROUND BlueZ 3/3] gdbus: Add fallback to PropertyChanged
Date: Mon,  8 Oct 2012 10:11:24 +0200	[thread overview]
Message-ID: <1349683884-22251-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1349683884-22251-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds a fallback for PropertyChanged signal when it is not implemented.
---
 gdbus/object.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index 8f6cbed..609378c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1587,6 +1587,41 @@ gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
 							name, type, args);
 }
 
+static void fallback_property_changed(struct generic_data *data,
+						struct interface_data *iface,
+						GDBusPropertyTable *p)
+{
+	DBusMessage *signal;
+	DBusMessageIter iter, value;
+	const GDBusSignalTable *s;
+
+	for (s = iface->signals; s && s->name; s++) {
+		/* Skip if PropertyChanged is present in the signals */
+		if (g_str_equal(s->name, "PropertyChanged") == 0)
+			return;
+	}
+
+	signal = dbus_message_new_signal(data->path, iface->name,
+							"PropertyChanged");
+	if (signal == NULL) {
+		error("Unable to allocate new %s.PropertyChanged signal",
+								iface->name);
+		return;
+	}
+
+	dbus_message_iter_init_append(signal, &iter);
+
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &p->name);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, p->type,
+								&value);
+
+	p->get(p, &value, iface->user_data);
+
+	dbus_message_iter_close_container(&iter, &value);
+
+	g_dbus_send_message(data->conn, signal);
+}
+
 static void process_properties_from_interface(struct generic_data *data,
 						struct interface_data *iface)
 {
@@ -1624,6 +1659,8 @@ static void process_properties_from_interface(struct generic_data *data,
 			continue;
 
 		append_property(iface, p, &dict);
+
+		fallback_property_changed(data, iface, p);
 	}
 
 	dbus_message_iter_close_container(&iter, &dict);
-- 
1.7.11.4


  parent reply	other threads:[~2012-10-08  8:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08  8:11 [WORKAROUND BlueZ 1/3] gdbus: Add fallback to GetProperties Luiz Augusto von Dentz
2012-10-08  8:11 ` [WORKAROUND BlueZ 2/3] gdbus: Add fallback to SetProperty Luiz Augusto von Dentz
2012-10-08  8:11 ` Luiz Augusto von Dentz [this message]
2012-10-08 13:43 ` [WORKAROUND BlueZ 1/3] gdbus: Add fallback to GetProperties Marcel Holtmann
2012-10-08 14:25   ` Luiz Augusto von Dentz
2012-10-08 14:29     ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349683884-22251-3-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox