#include "redblack.h"
#include "access.h"
-#define TVH_API_VERSION 18
+#define TVH_API_VERSION 19
/*
* Command hook
int api_idnode_save_simple
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp );
+void api_idnode_create
+ ( htsmsg_t **resp, idnode_t *in );
+
+void api_idnode_create_list
+ ( htsmsg_t **resp, htsmsg_t *list );
+
/*
* Service mapper
*/
pthread_mutex_lock(&global_lock);
if ((pw = passwd_entry_create(NULL, conf)) != NULL)
- idnode_changed(&pw->pw_id);
+ api_idnode_create(resp, &pw->pw_id);
pthread_mutex_unlock(&global_lock);
return 0;
pthread_mutex_lock(&global_lock);
if ((ib = ipblock_entry_create(NULL, conf)) != NULL)
- idnode_changed(&ib->ib_id);
+ api_idnode_create(resp, &ib->ib_id);
pthread_mutex_unlock(&global_lock);
return 0;
pthread_mutex_lock(&global_lock);
if ((ae = access_entry_create(NULL, conf)) != NULL)
- idnode_changed(&ae->ae_id);
+ api_idnode_create(resp, &ae->ae_id);
pthread_mutex_unlock(&global_lock);
return 0;
pthread_mutex_lock(&global_lock);
bq = bouquet_create(NULL, conf, NULL, NULL);
if (bq)
- idnode_changed(&bq->bq_id);
+ api_idnode_create(resp, &bq->bq_id);
pthread_mutex_unlock(&global_lock);
return 0;
int err = 0;
const char *clazz;
htsmsg_t *conf;
+ caclient_t *cac;
if (!(clazz = htsmsg_get_str(args, "class")))
return EINVAL;
htsmsg_set_str(conf, "class", clazz);
pthread_mutex_lock(&global_lock);
- if (caclient_create(NULL, conf, 1) == NULL)
+ cac = caclient_create(NULL, conf, 1);
+ if (cac)
+ api_idnode_create(resp, &cac->cac_id);
+ else
err = -EINVAL;
pthread_mutex_unlock(&global_lock);
pthread_mutex_lock(&global_lock);
ch = channel_create(NULL, conf, NULL);
if (ch)
- idnode_changed(&ch->ch_id);
+ api_idnode_create(resp, &ch->ch_id);
pthread_mutex_unlock(&global_lock);
return 0;
pthread_mutex_lock(&global_lock);
ct = channel_tag_create(NULL, conf);
if (ct)
- idnode_changed(&ct->ct_id);
+ api_idnode_create(resp, &ct->ct_id);
pthread_mutex_unlock(&global_lock);
return 0;
pthread_mutex_lock(&global_lock);
if ((cfg = dvr_config_create(NULL, NULL, conf))) {
- idnode_changed(&cfg->dvr_id);
+ api_idnode_create(resp, &cfg->dvr_id);
dvr_config_changed(cfg);
}
pthread_mutex_unlock(&global_lock);
htsmsg_add_msg(conf, "subtitle", m);
}
if ((de = dvr_entry_create(NULL, conf, 0)))
- idnode_changed(&de->de_id);
+ api_idnode_create(resp, &de->de_id);
res = 0;
free(lang);
dvr_entry_t *de;
const char *config_uuid, *comment;
epg_broadcast_t *e;
- htsmsg_t *entries, *entries2 = NULL, *m;
+ htsmsg_t *entries, *entries2 = NULL, *m, *l = NULL;
htsmsg_field_t *f;
const char *s;
int count = 0, enabled;
perm->aa_representative,
NULL, DVR_PRIO_NORMAL, DVR_RET_REM_DVRCONFIG,
DVR_RET_REM_DVRCONFIG, comment);
- if (de)
+ if (de) {
+ if (l == NULL)
+ l = htsmsg_create_list();
+ htsmsg_add_str(l, NULL, idnode_uuid_as_str(&de->de_id, ubuf));
idnode_changed(&de->de_id);
+ }
}
}
pthread_mutex_unlock(&global_lock);
htsmsg_destroy(entries2);
+ api_idnode_create_list(resp, l);
+
return !count ? EINVAL : 0;
}
htsmsg_set_str(conf, "config_name", idnode_uuid_as_str(&cfg->dvr_id, ubuf));
dae = dvr_autorec_create(NULL, conf);
if (dae) {
- idnode_changed(&dae->dae_id);
+ api_idnode_create(dae, &dae->dae_id);
dvr_autorec_changed(dae, 0);
dvr_autorec_completed(dae, 0);
}
{
dvr_autorec_entry_t *dae;
epg_broadcast_t *e;
- htsmsg_t *entries, *entries2 = NULL, *m;
+ htsmsg_t *entries, *entries2 = NULL, *m, *l = NULL;
htsmsg_field_t *f;
const char *config_uuid, *s;
int count = 0;
perm->aa_username,
perm->aa_representative,
"Created from EPG query");
- if (dae)
+ if (dae) {
+ if (l == NULL)
+ l = htsmsg_create_list();
+ htsmsg_add_str(l, NULL, idnode_uuid_as_str(&dae->dae_id, ubuf));
idnode_changed(&dae->dae_id);
+ }
}
}
pthread_mutex_unlock(&global_lock);
htsmsg_destroy(entries2);
+ api_idnode_create_list(resp, l);
+
return !count ? EINVAL : 0;
}
pthread_mutex_lock(&global_lock);
dte = dvr_timerec_create(NULL, conf);
if (dte) {
- idnode_changed(&dte->dte_id);
+ api_idnode_create(resp, &dte->dte_id);
dvr_timerec_check(dte);
}
pthread_mutex_unlock(&global_lock);
esfilter_class_t cls )
{
htsmsg_t *conf;
+ esfilter_t *esf;
if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;
pthread_mutex_lock(&global_lock);
- esfilter_create(cls, NULL, conf, 1);
+ esf = esfilter_create(cls, NULL, conf, 1);
+ if (esf)
+ api_idnode_create(resp, &esf->esf_id);
pthread_mutex_unlock(&global_lock);
return 0;
return api_idnode_handler(perm, args, resp, api_idnode_movedown_, "movedown", 0);
}
+static void
+api_idnode_create( htsmsg_t **resp, idnode_t *in )
+{
+ char ubuf[UUID_HEX_SIZE];
+
+ idnode_changed(in);
+ if (*resp == NULL)
+ *resp = htsmsg_create_map();
+ htsmsg_add_str(*resp, "uuid", idnode_uuid_as_str(in, ubuf));
+}
+
+static void
+api_idnode_create_list( htsmsg_t **resp, htsmsg_t *list )
+{
+ if (list == NULL)
+ return;
+ if (*resp == NULL)
+ *resp = htsmsg_create_map();
+ htsmsg_add_str(*resp, "uuid", list);
+}
+
void api_idnode_init ( void )
{
/*
mn = mpegts_network_build(class, conf);
if (mn) {
err = 0;
- *resp = htsmsg_create_map();
- idnode_changed(&mn->mn_id);
+ api_idnode_create(resp, &mn->mn_id);
} else {
err = EINVAL;
}
if (!(mm = mn->mn_mux_create2(mn, conf)))
goto exit;
- idnode_changed(&mm->mm_id);
+ api_idnode_create(resp, &mm->mm_id);
err = 0;
exit:
mms = mpegts_mux_sched_create(NULL, conf);
if (mms) {
err = 0;
- *resp = htsmsg_create_map();
- idnode_changed(&mms->mms_id);
+ api_idnode_create(resp, &mms->mms_id);
} else {
err = EINVAL;
}
int err = 0;
const char *clazz;
htsmsg_t *conf;
+ profile_t *pro;
if (!(clazz = htsmsg_get_str(args, "class")))
return EINVAL;
htsmsg_set_str(conf, "class", clazz);
pthread_mutex_lock(&global_lock);
- if (profile_create(NULL, conf, 1) == NULL)
+ pro = profile_create(NULL, conf, 1);
+ if (pro)
+ api_idnode_create(resp, &pro->pro_id);
+ else
err = -EINVAL;
pthread_mutex_unlock(&global_lock);