htsp: filter out the profiles and dvr configs without granted access

This commit is contained in:
Jaroslav Kysela 2014-10-19 21:46:23 +02:00
parent 5e98c69d85
commit 0fa68f751d
3 changed files with 32 additions and 6 deletions

View file

@ -1299,16 +1299,29 @@ static htsmsg_t *
htsp_method_getDvrConfigs(htsp_connection_t *htsp, htsmsg_t *in)
{
htsmsg_t *out, *l, *c;
htsmsg_field_t *f;
dvr_config_t *cfg;
const char *uuid, *s;
l = htsmsg_create_list();
LIST_FOREACH(cfg, &dvrconfigs, config_link)
if (cfg->dvr_enabled) {
uuid = idnode_uuid_as_str(&cfg->dvr_id);
if (htsp->htsp_granted_access->aa_dvrcfgs) {
HTSMSG_FOREACH(f, htsp->htsp_granted_access->aa_dvrcfgs) {
if (!(s = htsmsg_field_get_str(f)))
continue;
if (strcmp(s, uuid) == 0)
break;
}
if (f == NULL)
continue;
}
c = htsmsg_create_map();
htsmsg_add_str(c, "uuid", idnode_uuid_as_str(&cfg->dvr_id));
htsmsg_add_str(c, "name", cfg->dvr_config_name);
htsmsg_add_str(c, "comment", cfg->dvr_comment);
htsmsg_add_str(c, "name", cfg->dvr_config_name ?: "");
htsmsg_add_str(c, "comment", cfg->dvr_comment ?: "");
htsmsg_add_msg(l, NULL, c);
}
@ -2163,7 +2176,7 @@ htsp_method_getProfiles(htsp_connection_t *htsp, htsmsg_t *in)
htsmsg_t *out, *l;
l = htsmsg_create_list();
profile_get_htsp_list(l);
profile_get_htsp_list(l, htsp->htsp_granted_access->aa_profiles);
out = htsmsg_create_map();

View file

@ -395,15 +395,28 @@ profile_class_get_list(void *o)
*
*/
void
profile_get_htsp_list(htsmsg_t *array)
profile_get_htsp_list(htsmsg_t *array, htsmsg_t *filter)
{
profile_t *pro;
htsmsg_t *m;
htsmsg_field_t *f;
const char *uuid, *s;
TAILQ_FOREACH(pro, &profiles, pro_link) {
if (pro->pro_work) {
uuid = idnode_uuid_as_str(&pro->pro_id);
if (filter) {
HTSMSG_FOREACH(f, filter) {
if (!(s = htsmsg_field_get_str(f)))
continue;
if (strcmp(s, uuid) == 0)
break;
}
if (f == NULL)
continue;
}
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(&pro->pro_id));
htsmsg_add_str(m, "uuid", uuid);
htsmsg_add_str(m, "name", pro->pro_name ?: "");
htsmsg_add_str(m, "comment", pro->pro_comment ?: "");
htsmsg_add_msg(array, NULL, m);

View file

@ -116,7 +116,7 @@ const char *profile_get_name(profile_t *pro);
static inline muxer_container_type_t profile_get_mc(profile_t *pro)
{ return pro->pro_get_mc(pro); }
void profile_get_htsp_list(htsmsg_t *array);
void profile_get_htsp_list(htsmsg_t *array, htsmsg_t *filter);
void profile_init(void);
void profile_done(void);