diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-09-07 15:28:49 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-09-28 12:48:15 +0300 |
commit | 22cd0ab4e1490a62441c78711be7522b6fcb23ec (patch) | |
tree | 7c874dbadbfc1871946610a97b8bdb3457f6de1e | |
parent | 1e8db631e787d4a25d2c1634a42d92bfd1a0e0ff (diff) | |
download | obexd-22cd0ab4e1490a62441c78711be7522b6fcb23ec.tar.gz |
client: Add MessageAccess.ListFilterFields
-rw-r--r-- | client/map.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/map.c b/client/map.c index 6d1b0f2..cf3d8ed 100644 --- a/client/map.c +++ b/client/map.c @@ -1011,6 +1011,41 @@ static DBusMessage *map_list_messages(DBusConnection *connection, return get_message_listing(map, message, folder, apparam); } +static gchar **get_filter_strs(uint64_t filter, gint *size) +{ + gchar **list, **item; + gint i; + + list = g_malloc0(sizeof(gchar **) * (FILTER_BIT_MAX + 2)); + + item = list; + + for (i = 0; filter_list[i] != NULL; i++) + if (filter & (1ULL << i)) + *(item++) = g_strdup(filter_list[i]); + + *item = NULL; + *size = item - list; + return list; +} + +static DBusMessage *map_list_filter_fields(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + gchar **filters = NULL; + gint size; + DBusMessage *reply; + + filters = get_filter_strs(FILTER_ALL, &size); + reply = dbus_message_new_method_return(message); + dbus_message_append_args(reply, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING, &filters, size, + DBUS_TYPE_INVALID); + + g_strfreev(filters); + return reply; +} + static const GDBusMethodTable map_methods[] = { { GDBUS_ASYNC_METHOD("SetFolder", GDBUS_ARGS({ "name", "s" }), NULL, @@ -1023,6 +1058,10 @@ static const GDBusMethodTable map_methods[] = { GDBUS_ARGS({ "folder", "s" }, { "filter", "a{sv}" }), GDBUS_ARGS({ "messages", "a{oa{sv}}" }), map_list_messages) }, + { GDBUS_METHOD("ListFilterFields", + NULL, + GDBUS_ARGS({ "fields", "as" }), + map_list_filter_fields) }, { } }; |