idnode prop: added support for str_enum

This allows classes to define enumerated types, such as required for the
DVB FE configuration.
This commit is contained in:
Adam Sutton 2013-06-10 13:42:28 +01:00
parent 587400971b
commit 691b249776
2 changed files with 11 additions and 0 deletions

View file

@ -164,6 +164,15 @@ prop_add_params_to_msg(void *obj, const property_t *p, htsmsg_t *msg)
htsmsg_add_u32(m, "rdonly", 1);
if (p->options & PO_NOSAVE)
htsmsg_add_u32(m, "nosave", 1);
if (p[i].type == PT_STR && p[i].str_enum) {
htsmsg_t *l = htsmsg_create_list();
const char **e = p[i].str_enum(obj);
while (*e) {
htsmsg_add_str(l, NULL, *e);
e++;
}
htsmsg_add_msg(m, "enum", l);
}
if (obj)
prop_read_value(obj, p+i, m, "value");
htsmsg_add_msg(msg, NULL, m);

View file

@ -14,6 +14,7 @@ typedef enum {
#define PO_NONE 0x0
#define PO_RDONLY 0x1 // Note: if this is changed, change PROPDEF2
#define PO_NOSAVE 0x2
#define PO_WRONCE 0x4
typedef struct property {
const char *id;
@ -24,6 +25,7 @@ typedef struct property {
const char *(*str_get)(void *ptr);
void (*str_set)(void *ptr, const char *str);
const char **(*str_enum)(void *ptr);
void (*notify)(void *ptr);