idnode prop: tweak to get config to load in the right order.
This commit is contained in:
parent
6fc769e4ee
commit
5cb2ea0768
4 changed files with 23 additions and 34 deletions
18
src/idnode.c
18
src/idnode.c
|
@ -581,17 +581,24 @@ idnode_set_free ( idnode_set_t *is )
|
|||
* Write
|
||||
* *************************************************************************/
|
||||
|
||||
static int
|
||||
idnode_class_write_values
|
||||
( idnode_t *self, const idclass_t *idc, htsmsg_t *c, int optmask )
|
||||
{
|
||||
int save = 0;
|
||||
if (idc->ic_super)
|
||||
save |= idnode_class_write_values(self, idc->ic_super, c, optmask);
|
||||
save |= prop_write_values(self, idc->ic_properties, c, optmask, NULL);
|
||||
return save;
|
||||
}
|
||||
|
||||
int
|
||||
idnode_write0 ( idnode_t *self, htsmsg_t *c, int optmask, int dosave )
|
||||
{
|
||||
int save = 0;
|
||||
void (*savefn)(idnode_t*) = NULL;
|
||||
const idclass_t *idc = self->in_class;
|
||||
for (; idc; idc = idc->ic_super) {
|
||||
save |= prop_write_values(self, idc->ic_properties, c, optmask, NULL);
|
||||
if (!savefn && idc->ic_save)
|
||||
savefn = idc->ic_save;
|
||||
}
|
||||
save = idnode_class_write_values(self, idc, c, optmask);
|
||||
if (save && dosave) {
|
||||
if (savefn) savefn(self);
|
||||
idnode_notify(self, NULL, 0, 0);
|
||||
|
@ -731,7 +738,6 @@ idnode_notify_event ( idnode_t *in )
|
|||
if (ic->ic_event) {
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "uuid", uuid);
|
||||
printf("event = %s\n", ic->ic_event);
|
||||
notify_by_msg(ic->ic_event, m);
|
||||
}
|
||||
ic = ic->ic_super;
|
||||
|
|
|
@ -869,20 +869,6 @@ linuxdvb_frontend_create0
|
|||
if (!conf)
|
||||
return lfe;
|
||||
|
||||
/* TODO: this should be done differently */
|
||||
if ((str = htsmsg_get_str(conf, "network"))) {
|
||||
linuxdvb_network_t *ln = linuxdvb_network_find_by_uuid(str);
|
||||
if (ln) {
|
||||
if (ln->ln_type == lfe->lfe_info.type) {
|
||||
mpegts_input_set_network((mpegts_input_t*)lfe, (mpegts_network_t*)ln);
|
||||
} else
|
||||
tvhlog(LOG_WARNING, "linuxdvb",
|
||||
"attempt to add network %s of wrong type %s to %s (%s)",
|
||||
dvb_type2str(ln->ln_type), ln->mn_network_name,
|
||||
lfe->mi_displayname, dvb_type2str(lfe->lfe_info.type));
|
||||
}
|
||||
}
|
||||
|
||||
return lfe;
|
||||
}
|
||||
|
||||
|
|
|
@ -370,8 +370,6 @@ mpegts_input_create0
|
|||
htsmsg_t *c )
|
||||
{
|
||||
idnode_insert(&mi->mi_id, uuid, class);
|
||||
if (c)
|
||||
idnode_load(&mi->mi_id, c);
|
||||
|
||||
/* Defaults */
|
||||
mi->mi_is_enabled = mpegts_input_is_enabled;
|
||||
|
@ -388,7 +386,7 @@ mpegts_input_create0
|
|||
mi->mi_has_subscription = mpegts_input_has_subscription;
|
||||
|
||||
/* Index */
|
||||
mi->mi_instance = ++mpegts_input_idx;
|
||||
mi->mi_instance = ++mpegts_input_idx;
|
||||
|
||||
/* Init mutex */
|
||||
pthread_mutex_init(&mi->mi_delivery_mutex, NULL);
|
||||
|
@ -403,6 +401,10 @@ mpegts_input_create0
|
|||
/* Add to global list */
|
||||
LIST_INSERT_HEAD(&mpegts_input_all, mi, mi_global_link);
|
||||
|
||||
/* Load config */
|
||||
if (c)
|
||||
idnode_load(&mi->mi_id, c);
|
||||
|
||||
return mi;
|
||||
}
|
||||
|
||||
|
@ -418,8 +420,9 @@ mpegts_input_set_network ( mpegts_input_t *mi, mpegts_network_t *mn )
|
|||
char buf1[256], buf2[265];
|
||||
if (mi->mi_network == mn) return;
|
||||
*buf1 = *buf2 = 0;
|
||||
if (mi->mi_display_name)
|
||||
if (mi->mi_display_name) {
|
||||
mi->mi_display_name(mi, buf1, sizeof(buf1));
|
||||
}
|
||||
if (mi->mi_network) {
|
||||
mi->mi_network->mn_display_name(mi->mi_network, buf2, sizeof(buf2));
|
||||
LIST_REMOVE(mi, mi_network_link);
|
||||
|
|
14
src/prop.c
14
src/prop.c
|
@ -84,19 +84,13 @@ prop_write_values
|
|||
{
|
||||
int save, save2 = 0;
|
||||
htsmsg_field_t *f;
|
||||
const property_t *p;
|
||||
|
||||
if (!pl) return 0;
|
||||
|
||||
HTSMSG_FOREACH(f, m) {
|
||||
if(f->hmf_name == NULL)
|
||||
continue;
|
||||
|
||||
/* Find Property */
|
||||
const property_t *p = prop_find(pl, f->hmf_name);
|
||||
if(p == NULL) {
|
||||
//tvhwarn("prop", "invalid property %s", f->hmf_name);
|
||||
continue;
|
||||
}
|
||||
for (p = pl; p->id; p++) {
|
||||
f = htsmsg_field_find(m, p->id);
|
||||
if (!f) continue;
|
||||
|
||||
/* Ignore */
|
||||
if(p->opts & optmask) continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue