diff options
author | Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com> | 2016-03-29 11:45:46 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2016-03-29 23:40:30 +0200 |
commit | 27464af5298683996dbc48ddb8ad244f228b1b2f (patch) | |
tree | 91003bf80cb1e74c01475f7de7966bc2b35d850a | |
parent | 6d6598c0e32f3cbd0b3a168612847a78ef0db78c (diff) | |
download | neard-27464af5298683996dbc48ddb8ad244f228b1b2f.tar.gz |
ndef: Handle multi-record messages
A special care is taken of SmartPoster and Handover messages,
since they are multi-record.
Currently they are supported only in the single record mode
of the tag.write() method.
-rw-r--r-- | src/ndef.c | 40 |
1 files changed, 29 insertions, 11 deletions
@@ -3725,6 +3725,23 @@ again: return found; } +static struct near_ndef_message *build_multi_record_message( + DBusMessageIter *iter, const char *type) +{ + struct near_ndef_message *ndef = NULL; + + DBG(""); + + if (g_strcmp0(type, "SmartPoster") == 0) + ndef = build_sp_record(iter); + else if (g_strcmp0(type, "Handover") == 0) + ndef = build_ho_record(RECORD_TYPE_WKT_HANDOVER_REQUEST, iter); + else if (g_strcmp0(type, "StaticHandover") == 0) + ndef = build_ho_record(RECORD_TYPE_WKT_HANDOVER_SELECT, iter); + + return ndef; +} + static struct near_ndef_message *ndef_build_from_record(DBusMessageIter *msg, bool begin, bool end) { @@ -3762,20 +3779,21 @@ static struct near_ndef_message *ndef_build_from_record(DBusMessageIter *msg, } else if (g_strcmp0(value, "URI") == 0) { ndef = build_uri_record(msg); break; - } else if (g_strcmp0(value, "SmartPoster") == 0) { - ndef = build_sp_record(msg); - break; - } else if (g_strcmp0(value, "Handover") == 0) { - ndef = build_ho_record( - RECORD_TYPE_WKT_HANDOVER_REQUEST, msg); - break; - } else if (g_strcmp0(value, "StaticHandover") == 0) { - ndef = build_ho_record( - RECORD_TYPE_WKT_HANDOVER_SELECT, msg); - break; } else if (g_strcmp0(value, "MIME") == 0) { ndef = build_mime_record(msg); break; + } else if ((begin && end) && + (g_strcmp0(value, "SmartPoster") == 0 || + g_strcmp0(value, "Handover") == 0 || + g_strcmp0(value, "StaticHandover") + == 0)) { + /* + * Currently SmartPoster and Handover messages + * are supported only in the single record mode + * of the tag.write() method. + */ + ndef = build_multi_record_message(msg, value); + break; } else { near_error("%s not supported", value); ndef = NULL; |