This is not a mandatory field and is only valid for
Smart Posters carrying a URI record.
- byte Action [readonly]
+ string Action [readonly]
- Can exist in SmartPoster(Action) record. It suggests
- a course of action that the device should do with the
- content.
+ The suggested course of action.
- Example:
- 0 - Do the action.
- 1 - Save for later.
- 2 - Open for editing.
+ This one is only valid for Smart Posters and is a
+ suggestion only. It can be ignored, and the possible
+ values are "Do" (for example launch the browser),
+ "Save" (for example save the URI in the bookmarks folder,
+ or "Edit" (for example open the URI in an URI editor for
+ the user to modify it.
#define RECORD_TNF_UNKNOWN 0x05
#define RECORD_TNF_UNCHANGED 0x06
+#define RECORD_ACTION_DO 0x00
+#define RECORD_ACTION_SAVE 0x01
+#define RECORD_ACTION_EDIT 0x02
+
#define RECORD_MB_BIT(val) ((val & 0x80) >> 7)
#define RECORD_ME_BIT(val) ((val & 0x40) >> 6)
#define RECORD_CF_BIT(val) ((val & 0x20) >> 5)
};
struct near_ndef_sp_record {
- uint8_t action;
-
struct near_ndef_uri_record *uri;
uint8_t number_of_title_records;
uint32_t size; /* from Size record*/
char *type; /* from Type record*/
+ char *action;
/* TODO add icon and other records fields*/
};
if (sp == NULL || dict == NULL)
return;
- near_dbus_dict_append_basic(dict, "Action", DBUS_TYPE_BYTE,
+ if (sp->action != NULL)
+ near_dbus_dict_append_basic(dict, "Action", DBUS_TYPE_STRING,
&(sp->action));
if (sp->uri != NULL)
g_free(sp->title_records);
g_free(sp->type);
+ g_free(sp->action);
g_free(sp);
sp = NULL;
free_ndef_record(record);
}
+static char * action_to_string(uint8_t action)
+{
+ switch (action) {
+ case RECORD_ACTION_DO:
+ return "Do";
+ case RECORD_ACTION_SAVE:
+ return "Save";
+ case RECORD_ACTION_EDIT:
+ return "Edit";
+ default:
+ near_error("Unknown action 0x%x", action);
+ return NULL;
+ }
+}
+
/**
* @brief returns record type
* Validate type name format, type and type length and returns
if (payload_length != 1)
goto fail;
- sp_record->action = ndef_data[t_offset];
+ sp_record->action =
+ g_strdup(action_to_string(ndef_data[t_offset]));
+
break;
}