Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
htsp: filter out the profiles and dvr configs without granted access
  • Loading branch information
perexg committed Oct 19, 2014
1 parent 5e98c69 commit 0fa68f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
19 changes: 16 additions & 3 deletions src/htsp_server.c
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();

Expand Down
17 changes: 15 additions & 2 deletions src/profile.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/profile.h
Expand Up @@ -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);
Expand Down

0 comments on commit 0fa68f7

Please sign in to comment.