From: Jaroslav Kysela Date: Wed, 14 Dec 2016 16:40:07 +0000 (+0100) Subject: ACL: reduce fields in the grid - merge streaming and DVR flags into combo X-Git-Tag: v4.2.1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b33bdaea3564c80602047b50861e675bd8f05a0;p=thirdparty%2Ftvheadend.git ACL: reduce fields in the grid - merge streaming and DVR flags into combo --- diff --git a/src/access.c b/src/access.c index dca749d85..0c72bd2b5 100644 --- a/src/access.c +++ b/src/access.c @@ -1488,6 +1488,103 @@ access_entry_class_change_set ( void *obj, const void *p ) return idnode_slist_set(obj, access_entry_class_change_slist, p); } + +static idnode_slist_t access_entry_class_streaming_slist[] = { + { + .id = "basic", + .name = N_("Basic"), + .off = offsetof(access_entry_t, ae_streaming), + }, + { + .id = "advanced", + .name = N_("Advanced"), + .off = offsetof(access_entry_t, ae_adv_streaming), + }, + { + .id = "htsp", + .name = N_("HTSP"), + .off = offsetof(access_entry_t, ae_htsp_streaming), + }, + {} +}; + +static htsmsg_t * +access_entry_class_streaming_enum ( void *obj, const char *lang ) +{ + return idnode_slist_enum(obj, access_entry_class_streaming_slist, lang); +} + +static const void * +access_entry_class_streaming_get ( void *obj ) +{ + return idnode_slist_get(obj, access_entry_class_streaming_slist); +} + +static char * +access_entry_class_streaming_rend ( void *obj, const char *lang ) +{ + return idnode_slist_rend(obj, access_entry_class_streaming_slist, lang); +} + +static int +access_entry_class_streaming_set ( void *obj, const void *p ) +{ + return idnode_slist_set(obj, access_entry_class_streaming_slist, p); +} + +static idnode_slist_t access_entry_class_dvr_slist[] = { + { + .id = "basic", + .name = N_("Basic"), + .off = offsetof(access_entry_t, ae_dvr), + }, + { + .id = "htsp", + .name = N_("HTSP"), + .off = offsetof(access_entry_t, ae_htsp_dvr), + }, + { + .id = "all", + .name = N_("View all"), + .off = offsetof(access_entry_t, ae_all_dvr), + }, + { + .id = "all_rw", + .name = N_("Manage all"), + .off = offsetof(access_entry_t, ae_all_rw_dvr), + }, + { + .id = "failed", + .name = N_("Failed view"), + .off = offsetof(access_entry_t, ae_failed_dvr), + }, + {} +}; + +static htsmsg_t * +access_entry_class_dvr_enum ( void *obj, const char *lang ) +{ + return idnode_slist_enum(obj, access_entry_class_dvr_slist, lang); +} + +static const void * +access_entry_class_dvr_get ( void *obj ) +{ + return idnode_slist_get(obj, access_entry_class_dvr_slist); +} + +static char * +access_entry_class_dvr_rend ( void *obj, const char *lang ) +{ + return idnode_slist_rend(obj, access_entry_class_dvr_slist, lang); +} + +static int +access_entry_class_dvr_set ( void *obj, const void *p ) +{ + return idnode_slist_set(obj, access_entry_class_dvr_slist, p); +} + CLASS_DOC(access_entry) PROP_DOC(viewlevel_access_entries) PROP_DOC(themes) @@ -1601,27 +1698,18 @@ const idclass_t access_entry_class = { .opts = PO_DOC_NLIST | PO_ADVANCED, }, { - .type = PT_BOOL, + .type = PT_INT, + .islist = 1, .id = "streaming", .name = N_("Streaming"), - .desc = N_("Allow/Disallow HTTP streaming."), - .off = offsetof(access_entry_t, ae_streaming), - }, - { - .type = PT_BOOL, - .id = "adv_streaming", - .name = N_("Advanced streaming"), - .desc = N_("Allow/Disallow advanced http streaming, " - "e.g, direct service or mux links."), - .off = offsetof(access_entry_t, ae_adv_streaming), - }, - { - .type = PT_BOOL, - .id = "htsp_streaming", - .name = N_("HTSP streaming"), - .desc = N_("Allow/Disallow HTSP protocol streaming, " - "e.g Kodi (via pvr.hts) or Movian."), - .off = offsetof(access_entry_t, ae_htsp_streaming), + .desc = N_("Streaming flags, allow/disallow HTTP streaming, " + "advanced HTTP streming (e.g, direct service or mux links), " + "HTSP protocol streaming (e.g, Kodi (via pvr.hts) or Movian."), + .list = access_entry_class_streaming_enum, + .get = access_entry_class_streaming_get, + .set = access_entry_class_streaming_set, + .rend = access_entry_class_streaming_rend, + .opts = PO_DOC_NLIST, }, { .type = PT_STR, @@ -1638,45 +1726,19 @@ const idclass_t access_entry_class = { .opts = PO_ADVANCED, }, { - .type = PT_BOOL, + .type = PT_INT, + .islist = 1, .id = "dvr", .name = N_("Video recorder"), - .desc = N_("Allow/Disallow access to video recorder " - "functionality (including Autorecs)."), - .off = offsetof(access_entry_t, ae_dvr), - }, - { - .type = PT_BOOL, - .id = "htsp_dvr", - .name = N_("HTSP DVR"), - .desc = N_("Allow/Disallow access to DVR via the HTSP " - "protocol."), - .off = offsetof(access_entry_t, ae_htsp_dvr), - }, - { - .type = PT_BOOL, - .id = "all_dvr", - .name = N_("View all DVR entries"), - .desc = N_("Allow/Disallow access to other users DVR entries " - "(read only)."), - .off = offsetof(access_entry_t, ae_all_dvr), - }, - { - .type = PT_BOOL, - .id = "all_rw_dvr", - .name = N_("All DVR (rw)"), - .desc = N_("Allow/Disallow read/write access to other users' " - "DVR entries."), - .off = offsetof(access_entry_t, ae_all_rw_dvr), - }, - { - .type = PT_BOOL, - .id = "failed_dvr", - .name = N_("Failed DVR"), - .desc = N_("Allow/disallow access to all failed DVR entries."), - .def.i = 1, - .off = offsetof(access_entry_t, ae_failed_dvr), - .opts = PO_EXPERT | PO_HIDDEN, + .desc = N_("Video recorder flags, allow/disallow access to video recorder " + "functionality (including Autorecs), allow/disallow users to " + "view other DVR entries, allow/disallow users to work with " + "DVR entries of other users (remove, edit) etc."), + .list = access_entry_class_dvr_enum, + .get = access_entry_class_dvr_get, + .set = access_entry_class_dvr_set, + .rend = access_entry_class_dvr_rend, + .opts = PO_DOC_NLIST, }, { .type = PT_BOOL, diff --git a/src/config.c b/src/config.c index 703b390ca..afbee1a38 100644 --- a/src/config.c +++ b/src/config.c @@ -1406,7 +1406,48 @@ config_migrate_v23 ( void ) config_migrate_v23_one("pyepg"); } +static void +config_migrate_v24_helper ( const char **list, htsmsg_t *e, const char *name ) +{ + htsmsg_t *l = htsmsg_create_list(); + const char **p = list; + for (p = list; *p; p += 2) + if (htsmsg_get_bool_or_default(e, p[0], 0)) + htsmsg_add_str(l, NULL, p[1]); + for (p = list; *p; p += 2) + htsmsg_delete_field(e, p[0]); + htsmsg_add_msg(e, name, l); +} +static void +config_migrate_v24 ( void ) +{ + htsmsg_t *c, *e; + htsmsg_field_t *f; + static const char *streaming_list[] = { + "streaming", "basic", + "adv_streaming", "advanced", + "htsp_streaming", "htsp", + NULL + }; + static const char *dvr_list[] = { + "dvr", "basic", + "htsp_dvr", "htsp", + "all_dvr", "all", + "all_rw_dvr", "all_rw", + "failed_dvr", "failed", + NULL + }; + if ((c = hts_settings_load("accesscontrol")) != NULL) { + HTSMSG_FOREACH(f, c) { + if (!(e = htsmsg_field_get_map(f))) continue; + config_migrate_v24_helper(streaming_list, e, "streaming"); + config_migrate_v24_helper(dvr_list, e, "dvr"); + hts_settings_save(e, "accesscontrol/%s", f->hmf_name); + } + htsmsg_destroy(c); + } +} /* * Perform backup @@ -1528,7 +1569,8 @@ static const config_migrate_t config_migrate_table[] = { config_migrate_v20, config_migrate_v21, config_migrate_v22, - config_migrate_v23 + config_migrate_v23, + config_migrate_v24 }; /* diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index e0be7fea2..25e78e36c 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -6,18 +6,14 @@ tvheadend.acleditor = function(panel, index) { var list = 'enabled,username,password,prefix,change,' + 'lang,webui,uilevel,uilevel_nochange,admin,' + - 'streaming,adv_streaming,htsp_streaming,' + - 'profile,conn_limit_type,conn_limit,' + - 'dvr,htsp_dvr,all_dvr,all_rw_dvr,' + - 'dvr_config,channel_min,channel_max,' + + 'streaming,profile,conn_limit_type,conn_limit,' + + 'dvr,dvr_config,channel_min,channel_max,' + 'channel_tag_exclude,channel_tag,comment'; var list2 = 'enabled,username,password,prefix,change,' + 'lang,webui,themeui,langui,uilevel,uilevel_nochange,admin,' + - 'streaming,adv_streaming,htsp_streaming,' + - 'profile,conn_limit_type,conn_limit,' + - 'dvr,htsp_dvr,all_dvr,all_rw_dvr,' + - 'failed_dvr,htsp_anonymize,dvr_config,' + + 'streaming,profile,conn_limit_type,conn_limit,' + + 'dvr,htsp_anonymize,dvr_config,' + 'channel_min,channel_max,channel_tag_exclude,' + 'channel_tag,comment'; @@ -33,13 +29,8 @@ tvheadend.acleditor = function(panel, index) password: { width: 250 }, prefix: { width: 350 }, change: { width: 350 }, - streaming: { width: 110 }, - adv_streaming: { width: 200 }, - htsp_streaming: { width: 200 }, - dvr: { width: 150 }, - htsp_dvr: { width: 150 }, - all_dvr: { width: 150 }, - all_rw_dvr: { width: 150 }, + streaming: { width: 350 }, + dvr: { width: 350 }, webui: { width: 140 }, admin: { width: 100 }, conn_limit_type:{ width: 160 },