prop: added some extra options including defaults and advanced.
This commit is contained in:
parent
4f16c2eed5
commit
3c46df55e8
2 changed files with 49 additions and 9 deletions
39
src/prop.c
39
src/prop.c
|
@ -221,7 +221,8 @@ prop_read_value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
prop_read_values(void *obj, const property_t *pl, htsmsg_t *m, int optmask, htsmsg_t *inc)
|
prop_read_values
|
||||||
|
(void *obj, const property_t *pl, htsmsg_t *m, int optmask, htsmsg_t *inc)
|
||||||
{
|
{
|
||||||
if(pl == NULL)
|
if(pl == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -233,7 +234,8 @@ prop_read_values(void *obj, const property_t *pl, htsmsg_t *m, int optmask, htsm
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
prop_serialize(void *obj, const property_t *pl, htsmsg_t *msg, int optmask, htsmsg_t *inc)
|
prop_serialize
|
||||||
|
(void *obj, const property_t *pl, htsmsg_t *msg, int optmask, htsmsg_t *inc)
|
||||||
{
|
{
|
||||||
if(pl == NULL)
|
if(pl == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -253,13 +255,40 @@ prop_serialize(void *obj, const property_t *pl, htsmsg_t *msg, int optmask, htsm
|
||||||
if (pl->islist)
|
if (pl->islist)
|
||||||
htsmsg_add_u32(m, "list", 1);
|
htsmsg_add_u32(m, "list", 1);
|
||||||
|
|
||||||
|
/* Default */
|
||||||
|
// TODO: currently no support for list defaults
|
||||||
|
switch (pl->type) {
|
||||||
|
case PT_BOOL:
|
||||||
|
htsmsg_add_bool(m, "default", pl->def.i);
|
||||||
|
break;
|
||||||
|
case PT_INT:
|
||||||
|
htsmsg_add_u32(m, "default", pl->def.i);
|
||||||
|
break;
|
||||||
|
case PT_U16:
|
||||||
|
htsmsg_add_u32(m, "default", pl->def.u16);
|
||||||
|
break;
|
||||||
|
case PT_U32:
|
||||||
|
htsmsg_add_u32(m, "default", pl->def.u32);
|
||||||
|
break;
|
||||||
|
case PT_DBL:
|
||||||
|
htsmsg_add_dbl(m, "default", pl->def.d);
|
||||||
|
break;
|
||||||
|
case PT_STR:
|
||||||
|
htsmsg_add_str(m, "default", pl->def.s ?: "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
if (pl->opts & PO_RDONLY)
|
if (pl->opts & PO_RDONLY)
|
||||||
htsmsg_add_u32(m, "rdonly", 1);
|
htsmsg_add_bool(m, "rdonly", 1);
|
||||||
if (pl->opts & PO_NOSAVE)
|
if (pl->opts & PO_NOSAVE)
|
||||||
htsmsg_add_u32(m, "nosave", 1);
|
htsmsg_add_bool(m, "nosave", 1);
|
||||||
if (pl->opts & PO_WRONCE)
|
if (pl->opts & PO_WRONCE)
|
||||||
htsmsg_add_u32(m, "wronce", 1);
|
htsmsg_add_bool(m, "wronce", 1);
|
||||||
|
if (pl->opts & PO_ADVANCED)
|
||||||
|
htsmsg_add_bool(m, "advanced", 1);
|
||||||
|
if (pl->opts & PO_HIDDEN)
|
||||||
|
htsmsg_add_bool(m, "hidden", 1);
|
||||||
|
|
||||||
/* Enum list */
|
/* Enum list */
|
||||||
if (pl->list)
|
if (pl->list)
|
||||||
|
|
11
src/prop.h
11
src/prop.h
|
@ -43,6 +43,8 @@ typedef enum {
|
||||||
#define PO_RDONLY 0x01 // Property is read-only
|
#define PO_RDONLY 0x01 // Property is read-only
|
||||||
#define PO_NOSAVE 0x02 // Property is transient (not saved)
|
#define PO_NOSAVE 0x02 // Property is transient (not saved)
|
||||||
#define PO_WRONCE 0x04 // Property is write-once (i.e. on creation)
|
#define PO_WRONCE 0x04 // Property is write-once (i.e. on creation)
|
||||||
|
#define PO_ADVANCED 0x08 // Property is advanced
|
||||||
|
#define PO_HIDDEN 0x10 // Property is hidden (by default)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Property definition
|
* Property definition
|
||||||
|
@ -63,6 +65,15 @@ typedef struct property {
|
||||||
///< Lists should be CSV. This is used for
|
///< Lists should be CSV. This is used for
|
||||||
///< sorting and searching in UI API
|
///< sorting and searching in UI API
|
||||||
|
|
||||||
|
/* Default (for UI) */
|
||||||
|
union {
|
||||||
|
int i; // PT_BOOL/PT_INT
|
||||||
|
const char *s; // PR_STR
|
||||||
|
uint16_t u16; // PT_U16
|
||||||
|
uint32_t u32; // PR_U32
|
||||||
|
double d; // PT_DBL
|
||||||
|
} def;
|
||||||
|
|
||||||
/* Notification callback */
|
/* Notification callback */
|
||||||
void (*notify) (void *ptr);
|
void (*notify) (void *ptr);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue