static void callback_opt(void *opaque, prop_event_t event, ...) { setting_t *s = opaque; prop_callback_string_t *cb; prop_t *c; va_list ap; va_start(ap, event); cb = s->s_callback; if(event != PROP_SELECT_CHILD) return; c = va_arg(ap, prop_t *); if(cb) cb(s->s_opaque, c ? prop_get_name(c) : NULL); if(s->s_store && s->s_saver) { htsmsg_delete_field(s->s_store, s->s_id); if(c != NULL) htsmsg_add_str(s->s_store, s->s_id, prop_get_name(c)); s->s_saver(s->s_saver_opaque, s->s_store); } }
static void callback_opt(void *opaque, prop_event_t event, ...) { setting_t *s = opaque; prop_callback_string_t *cb; prop_t *c; rstr_t *name; va_list ap; va_start(ap, event); cb = s->s_callback; if(event != PROP_SELECT_CHILD) return; c = va_arg(ap, prop_t *); name = c ? prop_get_name(c) : NULL; va_end(ap); if(cb != NULL) cb(s->s_opaque, rstr_get(name)); if(s->s_store != NULL && s->s_saver != NULL) { htsmsg_delete_field(s->s_store, s->s_id); if(name != NULL) htsmsg_add_str(s->s_store, s->s_id, rstr_get(name)); s->s_saver(s->s_saver_opaque, s->s_store); } rstr_release(name); }
void settings_multiopt_initiate(setting_t *s, prop_callback_string_t *cb, void *opaque, prop_courier_t *pc, htsmsg_t *store, settings_saver_t *saver, void *saver_opaque) { const char *str = store ? htsmsg_get_str(store, s->s_id) : NULL; prop_t *o = str ? prop_find(s->s_val, str, NULL) : NULL; if(o == NULL && s->s_initial_value != NULL) o = prop_find(s->s_val, s->s_initial_value, NULL); if(o == NULL && s->s_first != NULL) o = prop_find(s->s_val, s->s_first, NULL); if(o != NULL) { prop_select(o); rstr_t *name = prop_get_name(o); cb(opaque, rstr_get(name)); rstr_release(name); prop_ref_dec(o); } s->s_callback = cb; s->s_opaque = opaque; mystrset(&s->s_initial_value, NULL); s->s_sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE, PROP_TAG_CALLBACK, callback_opt, s, PROP_TAG_ROOT, s->s_val, PROP_TAG_COURIER, pc, NULL); s->s_store = store; s->s_saver = saver; s->s_saver_opaque = saver_opaque; }