From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: linux-bluetooth@vger.kernel.org
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Subject: [PATCH BlueZ 3/5] gdbus: Implement DBus.Properties.GetAll method
Date: Thu, 19 Jul 2012 00:20:06 -0300 [thread overview]
Message-ID: <1342668008-5522-4-git-send-email-lucas.demarchi@profusion.mobi> (raw)
In-Reply-To: <1342668008-5522-1-git-send-email-lucas.demarchi@profusion.mobi>
---
gdbus/object.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index 543e61c..6daaa81 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -562,7 +562,61 @@ static DBusMessage *properties_get(DBusConnection *connection,
static DBusMessage *properties_get_all(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
- return NULL;
+ struct generic_data *data = user_data;
+ struct interface_data *iface;
+ const GDBusPropertyTable *p;
+ const char *interface_name;
+ DBusMessageIter iter, dict;
+ DBusMessage *reply;
+
+ if (!dbus_message_get_args(message, NULL,
+ DBUS_TYPE_STRING, &interface_name,
+ DBUS_TYPE_INVALID))
+ return NULL;
+
+ iface = find_interface(data->interfaces, interface_name);
+ if (iface == NULL)
+ return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
+ "No such interface '%s'", interface_name);
+
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ for (p = iface->properties; p && p->name; p++) {
+ DBusMessageIter entry, value;
+
+ if (p->get == NULL)
+ continue;
+
+ if (p->exists != NULL && !p->exists(p, iface->user_data))
+ continue;
+
+ dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
+ NULL, &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
+ p->name);
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+ p->type, &value);
+
+ if (!p->get(p, &value, iface->user_data)) {
+ dbus_message_unref(reply);
+ return NULL;
+ }
+
+ dbus_message_iter_close_container(&entry, &value);
+ dbus_message_iter_close_container(&dict, &entry);
+ }
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
}
static DBusMessage *properties_set(DBusConnection *connection,
--
1.7.11.2
next prev parent reply other threads:[~2012-07-19 3:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 3:20 [PATCH BlueZ 0/5] DBus.Properties Lucas De Marchi
2012-07-19 3:20 ` [PATCH BlueZ 1/5] gdbus: Add skeleton of DBus.Properties interface Lucas De Marchi
2012-07-19 8:03 ` Marcel Holtmann
2012-07-19 8:19 ` Lucas De Marchi
2012-07-19 8:49 ` Marcel Holtmann
2012-07-19 3:20 ` [PATCH BlueZ 2/5] gdbus: Implement DBus.Properties.Get method Lucas De Marchi
2012-07-19 3:20 ` Lucas De Marchi [this message]
2012-07-19 3:20 ` [PATCH BlueZ 4/5] gdbus: Implement DBus.Properties.Set method Lucas De Marchi
2012-07-19 3:20 ` [PATCH BlueZ 5/5] gdbus: Add properties into Introspectable interface Lucas De Marchi
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=1342668008-5522-4-git-send-email-lucas.demarchi@profusion.mobi \
--to=lucas.demarchi@profusion.mobi \
--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;
as well as URLs for NNTP newsgroup(s).