From 38ad1fc342a5bd67414d3ec3dce661543ae243e8 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 23 Oct 2012 19:53:18 +0200 Subject: [PATCH] ndef: Add records raw data to a D-Bus iterator This will be needed by the NDEF agent raw data export routines. --- src/ndef.c | 20 ++++++++++++++++++++ src/near.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/ndef.c b/src/ndef.c index 7f806a5..0ea348e 100644 --- a/src/ndef.c +++ b/src/ndef.c @@ -248,6 +248,26 @@ uint8_t *__near_ndef_record_get_data(struct near_ndef_record *record, return record->data; } +void __near_ndef_append_records(DBusMessageIter *iter, GList *records) +{ + GList *list; + + DBG(""); + + for (list = records; list; list = list->next) { + struct near_ndef_record *record = list->data; + uint8_t *data; + size_t data_len; + + data = __near_ndef_record_get_data(record, &data_len); + if (data == NULL) + continue; + + dbus_message_iter_append_fixed_array(iter, DBUS_TYPE_BYTE, + &data, data_len); + } +} + static void append_text_payload(struct near_ndef_text_payload *text, DBusMessageIter *dict) { diff --git a/src/near.h b/src/near.h index 5c3f293..b3eae4c 100644 --- a/src/near.h +++ b/src/near.h @@ -107,6 +107,7 @@ void __near_ndef_record_free(struct near_ndef_record *record); char *__near_ndef_record_get_path(struct near_ndef_record *record); char *__near_ndef_record_get_type(struct near_ndef_record *record); uint8_t *__near_ndef_record_get_data(struct near_ndef_record *record, size_t *len); +void __near_ndef_append_records(DBusMessageIter *iter, GList *record); const char *__near_ndef_get_uri_prefix(uint8_t id); struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg); -- 2.7.4