diff --git a/src/prop.c b/src/prop.c index 18d235d3..48c8edaf 100644 --- a/src/prop.c +++ b/src/prop.c @@ -160,8 +160,10 @@ prop_add_params_to_msg(void *obj, const property_t *p, htsmsg_t *msg) htsmsg_add_str(m, "id", p[i].id); htsmsg_add_str(m, "caption", p[i].name); htsmsg_add_str(m, "type", val2str(p[i].type, typetab) ?: "unknown"); - if (p->rdonly) + if (p->options & PO_RDONLY) htsmsg_add_u32(m, "rdonly", 1); + if (p->options & PO_NOSAVE) + htsmsg_add_u32(m, "nosave", 1); if (obj) prop_read_value(obj, p+i, m, "value"); htsmsg_add_msg(msg, NULL, m); @@ -182,7 +184,7 @@ prop_seti(void *obj, const property_t *p, const char *value) uint16_t u16; const char *s; - if (p->rdonly) return 0; + if (p->options & PO_NOSAVE) return 0; void *val = obj + p->off; switch(p->type) { diff --git a/src/prop.h b/src/prop.h index ada7b74e..a0083c85 100644 --- a/src/prop.h +++ b/src/prop.h @@ -11,12 +11,16 @@ typedef enum { PT_U32, } prop_type_t; +#define PO_NONE 0x0 +#define PO_RDONLY 0x1 // Note: if this is changed, change PROPDEF2 +#define PO_NOSAVE 0x2 + typedef struct property { const char *id; const char *name; prop_type_t type; size_t off; - int rdonly; + int options; const char *(*str_get)(void *ptr); void (*str_set)(void *ptr, const char *str); @@ -39,6 +43,12 @@ int prop_update_all(void *obj, const property_t *p, const char *(*getvalue)(void *opaque, const char *key), void *opaque); +#define PROPDEF0(_i, _n, _t, _o)\ + .id = _i,\ + .name = _n,\ + .type = _t,\ + .options = _o + #define PROPDEF1(_i, _n, _t, _o, _v)\ .id = _i,\ .name = _n,\ @@ -50,5 +60,12 @@ int prop_update_all(void *obj, const property_t *p, .name = _n,\ .type = _t,\ .off = offsetof(_o, _v),\ - .rdonly = _r + .options = _r + +#define PROPDEF3(_i, _n, _t, _o, _v, _c)\ + .id = _i,\ + .name = _n,\ + .type = _t,\ + .off = offsetof(_o, _v),\ + .options = _c