aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-12-21 19:26:39 -0200
committerJohan Hedberg <johan.hedberg@nokia.com>2010-12-23 10:32:25 +0200
commitadbfb31ab2d8448fd8b184fd65ce314a4174bb68 (patch)
tree446b56fb3f45d90c690a7acf9bffb6d42cfdd457 /attrib/client.c
parent87b140440a9b03b139c8dfa2168c277f20fa9f88 (diff)
downloadbluez-adbfb31ab2d8448fd8b184fd65ce314a4174bb68.tar.gz
bluez-adbfb31ab2d8448fd8b184fd65ce314a4174bb68.tar.xz
bluez-adbfb31ab2d8448fd8b184fd65ce314a4174bb68.zip
Add GetProperties method the Service Interface
For now this interface just includes the path that each characteristic is registered at.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/attrib/client.c b/attrib/client.c
index e717eaad..10bbf7d9 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -941,12 +941,51 @@ static DBusMessage *discover_char(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct primary *prim = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ GSList *l;
+ char **chars;
+ int i;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ 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);
+
+ chars = g_new0(char *, g_slist_length(prim->chars) + 1);
+
+ for (i = 0, l = prim->chars; l; l = l->next, i++) {
+ struct characteristic *chr = l->data;
+ chars[i] = chr->path;
+ }
+
+ dict_append_array(&dict, "Characteristics", DBUS_TYPE_OBJECT_PATH,
+ &chars, i);
+ g_free(chars);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
static GDBusMethodTable prim_methods[] = {
{ "Discover", "", "", discover_char },
{ "RegisterCharacteristicsWatcher", "o", "",
register_watcher },
{ "UnregisterCharacteristicsWatcher", "o", "",
unregister_watcher },
+ { "GetProperties", "", "a{sv}",prim_get_properties },
{ }
};