From 7b7652619f0213a482d9b84a17791338c7c1ba92 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 24 May 2013 14:58:03 +0100 Subject: [PATCH] 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. --- src/idnode.c | 2 +- src/input/mpegts/linuxdvb/linuxdvb_adapter.c | 12 ++++++++++-- src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 11 +++++++++++ src/input/mpegts/linuxdvb/linuxdvb_private.h | 2 +- src/prop.c | 9 ++++++++- src/prop.h | 8 ++++++++ src/webui/extjs.c | 1 - src/webui/static/app/dvb.js | 10 +++++----- src/webui/static/app/dvb_networks.js | 9 ++++++--- 9 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/idnode.c b/src/idnode.c index 3ef95278..49475f14 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -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; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c index ef7553cb..8d7cf4dc 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c @@ -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) }, + {} } }; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 7259a3e7..1dba30e3 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -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[]){ + {} } }; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 7db6ec44..7a027608 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -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, diff --git a/src/prop.c b/src/prop.c index ac7a92c7..b025e6c9 100644 --- a/src/prop.c +++ b/src/prop.c @@ -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); } diff --git a/src/prop.h b/src/prop.h index 226616c8..d415f331 100644 --- a/src/prop.h +++ b/src/prop.h @@ -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 + diff --git a/src/webui/extjs.c b/src/webui/extjs.c index e1678b1f..b0bc66e9 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -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 { diff --git a/src/webui/static/app/dvb.js b/src/webui/static/app/dvb.js index 13d75fc4..45d3f47b 100644 --- a/src/webui/static/app/dvb.js +++ b/src/webui/static/app/dvb.js @@ -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 'Play' - }, { + url = 'stream/mux/' + value; + return 'Play'; + }}, { 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 'Play' + url = 'stream/service/' + value; + return 'Play'; } }, { diff --git a/src/webui/static/app/dvb_networks.js b/src/webui/static/app/dvb_networks.js index dea3b169..dc702a64 100644 --- a/src/webui/static/app/dvb_networks.js +++ b/src/webui/static/app/dvb_networks.js @@ -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; }