prop: Added the concept of a RD-only property
Made use of the rd-only property for display only fields in the DVB hardware tree.
This commit is contained in:
parent
8b82a82901
commit
7b7652619f
9 changed files with 50 additions and 14 deletions
|
@ -252,6 +252,7 @@ idnode_serialize(struct idnode *self)
|
|||
m = c->ic_serialize(self);
|
||||
} else {
|
||||
m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "id", idnode_uuid_as_str(self));
|
||||
htsmsg_add_str(m, "text", idnode_get_title(self));
|
||||
|
||||
htsmsg_t *p = htsmsg_create_list();
|
||||
|
@ -259,7 +260,6 @@ idnode_serialize(struct idnode *self)
|
|||
|
||||
htsmsg_add_msg(m, "params", p);
|
||||
|
||||
htsmsg_add_str(m, "id", idnode_uuid_as_str(self));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ const idclass_t linuxdvb_hardware_class =
|
|||
PT_BOOL, linuxdvb_hardware_t, lh_enabled) },
|
||||
{ PROPDEF1("displayname", "Name",
|
||||
PT_STR, linuxdvb_hardware_t, lh_displayname) },
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -180,12 +181,13 @@ get_device_info ( device_info_t *di, int a )
|
|||
|
||||
/* Create ID */
|
||||
if (*di->di_path && di->di_dev) {
|
||||
snprintf(di->di_id, sizeof(di->di_id), "%s/%s/%04x:%04x",
|
||||
snprintf(buf, sizeof(buf), "%s/%s/%04x:%04x",
|
||||
devinfo_bus2str(di->di_bus), di->di_path,
|
||||
di->di_dev >> 16, di->di_dev & 0xFFFF);
|
||||
} else {
|
||||
snprintf(di->di_id, sizeof(di->di_id), "/dev/dvb/adapter%d", a);
|
||||
snprintf(buf, sizeof(buf), "/dev/dvb/adapter%d", a);
|
||||
}
|
||||
di->di_id = strdup(buf);
|
||||
}
|
||||
|
||||
const idclass_t linuxdvb_device_class =
|
||||
|
@ -194,6 +196,9 @@ const idclass_t linuxdvb_device_class =
|
|||
.ic_class = "linuxdvb_device",
|
||||
.ic_caption = "LinuxDVB Device",
|
||||
.ic_properties = (const property_t[]){
|
||||
{ PROPDEF2("devid", "Device ID",
|
||||
PT_STR, linuxdvb_device_t, ld_devid.di_id, 1) },
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -283,6 +288,9 @@ const idclass_t linuxdvb_adapter_class =
|
|||
.ic_class = "linuxdvb_adapter",
|
||||
.ic_caption = "LinuxDVB Adapter",
|
||||
.ic_properties = (const property_t[]){
|
||||
{ PROPDEF2("rootpath", "Device Path",
|
||||
PT_STR, linuxdvb_adapter_t, la_rootpath, 1) },
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -46,6 +46,13 @@ const idclass_t linuxdvb_frontend_class =
|
|||
.ic_caption = "Linux DVB Frontend",
|
||||
.ic_get_title = linuxdvb_frontend_class_get_title,
|
||||
.ic_properties = (const property_t[]) {
|
||||
{ PROPDEF2("fe_path", "Frontend Path",
|
||||
PT_STR, linuxdvb_frontend_t, lfe_fe_path, 1) },
|
||||
{ PROPDEF2("dvr_path", "Input Path",
|
||||
PT_STR, linuxdvb_frontend_t, lfe_dvr_path, 1) },
|
||||
{ PROPDEF2("dmx_path", "Demux Path",
|
||||
PT_STR, linuxdvb_frontend_t, lfe_dmx_path, 1) },
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,6 +62,7 @@ const idclass_t linuxdvb_frontend_dvbt_class =
|
|||
.ic_class = "linuxdvb_frontend_dvbt",
|
||||
.ic_caption = "Linux DVB-T Frontend",
|
||||
.ic_properties = (const property_t[]){
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -64,6 +72,7 @@ const idclass_t linuxdvb_frontend_dvbs_class =
|
|||
.ic_class = "linuxdvb_frontend_dvbs",
|
||||
.ic_caption = "Linux DVB-S Frontend",
|
||||
.ic_properties = (const property_t[]){
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -73,6 +82,7 @@ const idclass_t linuxdvb_frontend_dvbc_class =
|
|||
.ic_class = "linuxdvb_frontend_dvbc",
|
||||
.ic_caption = "Linux DVB-C Frontend",
|
||||
.ic_properties = (const property_t[]){
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -82,6 +92,7 @@ const idclass_t linuxdvb_frontend_atsc_class =
|
|||
.ic_class = "linuxdvb_frontend_atsc",
|
||||
.ic_caption = "Linux ATSC Frontend",
|
||||
.ic_properties = (const property_t[]){
|
||||
{}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef LIST_HEAD(,linuxdvb_hardware) linuxdvb_hardware_list_t;
|
|||
|
||||
typedef struct device_info
|
||||
{
|
||||
char di_id[256];
|
||||
char *di_id;
|
||||
char di_path[128];
|
||||
enum {
|
||||
BUS_NONE = 0,
|
||||
|
|
|
@ -56,6 +56,10 @@ prop_write_values(void *obj, const property_t *pl, htsmsg_t *m)
|
|||
fprintf(stderr, "Property %s unmappable\n", f->hmf_name);
|
||||
continue;
|
||||
}
|
||||
if (p->rdonly) {
|
||||
tvhlog(LOG_WARNING, "prop", "field %s is read-only", p->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
void *val = obj + p->off;
|
||||
switch(TO_FROM(p->type, f->hmf_type)) {
|
||||
|
@ -101,8 +105,9 @@ prop_read_value(void *obj, const property_t *p, htsmsg_t *m, const char *name)
|
|||
s = p->str_get(obj);
|
||||
else
|
||||
s = *(const char **)val;
|
||||
if(s != NULL)
|
||||
if(s != NULL) {
|
||||
htsmsg_add_str(m, name, s);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +150,8 @@ 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)
|
||||
htsmsg_add_u32(m, "rdonly", 1);
|
||||
prop_read_value(obj, p+i, m, "value");
|
||||
htsmsg_add_msg(msg, NULL, m);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ typedef struct property {
|
|||
const char *name;
|
||||
prop_type_t type;
|
||||
size_t off;
|
||||
int rdonly;
|
||||
|
||||
const char *(*str_get)(void *ptr);
|
||||
void (*str_set)(void *ptr, const char *str);
|
||||
|
@ -41,3 +42,10 @@ int prop_update_all(void *obj, const property_t *p,
|
|||
.type = _t,\
|
||||
.off = offsetof(_o, _v)
|
||||
|
||||
#define PROPDEF2(_i, _n, _t, _o, _v, _r)\
|
||||
.id = _i,\
|
||||
.name = _n,\
|
||||
.type = _t,\
|
||||
.off = offsetof(_o, _v),\
|
||||
.rdonly = _r
|
||||
|
||||
|
|
|
@ -2178,7 +2178,6 @@ extjs_get_idnode(http_connection_t *hc, const char *remain, void *opaque,
|
|||
out = htsmsg_create_list();
|
||||
idnode_t **v;
|
||||
|
||||
printf("get(%s)\n", s);
|
||||
if(!strcmp(s, "root")) {
|
||||
v = rootfn();
|
||||
} else {
|
||||
|
|
|
@ -27,9 +27,9 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) {
|
|||
dataIndex : 'id',
|
||||
width : 50,
|
||||
renderer : function(value, metadata, record, row, col, store) {
|
||||
url = 'stream/mux/' + value
|
||||
return '<a href="' + url + '">Play</a>'
|
||||
}, {
|
||||
url = 'stream/mux/' + value;
|
||||
return '<a href="' + url + '">Play</a>';
|
||||
}}, {
|
||||
header : "Network",
|
||||
dataIndex : 'network',
|
||||
width : 200
|
||||
|
@ -429,8 +429,8 @@ tvheadend.dvb_services = function(adapterData, satConfStore) {
|
|||
dataIndex : 'id',
|
||||
width : 50,
|
||||
renderer : function(value, metadata, record, row, col, store) {
|
||||
url = 'stream/service/' + value
|
||||
return '<a href="' + url + '">Play</a>'
|
||||
url = 'stream/service/' + value;
|
||||
return '<a href="' + url + '">Play</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -5,12 +5,14 @@ tvheadend.item_editor = function(item) {
|
|||
|
||||
for (var idx in item.params) {
|
||||
var f = item.params[idx];
|
||||
var d = f.rdonly || false;
|
||||
switch(f.type) {
|
||||
case 'str':
|
||||
fields.push({
|
||||
fieldLabel: f.caption,
|
||||
name: f.id,
|
||||
value: f.value
|
||||
value: f.value,
|
||||
disabled: d
|
||||
});
|
||||
break;
|
||||
|
||||
|
@ -19,14 +21,15 @@ tvheadend.item_editor = function(item) {
|
|||
xtype: 'checkbox',
|
||||
fieldLabel: f.caption,
|
||||
name: f.id,
|
||||
checked: f.value
|
||||
checked: f.value,
|
||||
disabled: d
|
||||
});
|
||||
break;
|
||||
|
||||
case 'separator':
|
||||
fields.push({
|
||||
xtype: 'label',
|
||||
fieldLabel: f.caption,
|
||||
fieldLabel: f.caption
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue