Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
channel: cleanup the configuration tree
  <cfg>/channel/config
  <cfg>/channel/tag

Also use hts_settings_load() instead hts_settings_load_r() for
the appropriate places..
  • Loading branch information
perexg committed Sep 8, 2014
1 parent 2208332 commit 82f7f89
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/access.c
Expand Up @@ -967,7 +967,7 @@ access_init(int createdefault, int noacl)
TAILQ_INIT(&access_tickets);

/* Load */
if ((c = hts_settings_load_r(1, "accesscontrol")) != NULL) {
if ((c = hts_settings_load("accesscontrol")) != NULL) {
HTSMSG_FOREACH(f, c) {
if (!(m = htsmsg_field_get_map(f))) continue;
(void)access_entry_create(f->hmf_name, m);
Expand Down
12 changes: 6 additions & 6 deletions src/channels.c
Expand Up @@ -620,7 +620,7 @@ channel_delete ( channel_t *ch, int delconf )

/* Settings */
if (delconf)
hts_settings_remove("channel/%s", idnode_uuid_as_str(&ch->ch_id));
hts_settings_remove("channel/config/%s", idnode_uuid_as_str(&ch->ch_id));

/* Free memory */
RB_REMOVE(&channels, ch, ch_link);
Expand All @@ -638,7 +638,7 @@ channel_save ( channel_t *ch )
{
htsmsg_t *c = htsmsg_create_map();
idnode_save(&ch->ch_id, c);
hts_settings_save(c, "channel/%s", idnode_uuid_as_str(&ch->ch_id));
hts_settings_save(c, "channel/config/%s", idnode_uuid_as_str(&ch->ch_id));
htsmsg_destroy(c);
}

Expand All @@ -656,7 +656,7 @@ channel_init ( void )
channel_tag_init();

/* Channels */
if (!(c = hts_settings_load_r(1, "channel")))
if (!(c = hts_settings_load("channel/config")))
return;

HTSMSG_FOREACH(f, c) {
Expand Down Expand Up @@ -798,7 +798,7 @@ channel_tag_destroy(channel_tag_t *ct, int delconf)
channel_tag_mapping_destroy(ctm, CTM_DESTROY_UPDATE_CHANNEL);
channel_save(ch);
}
hts_settings_remove("channeltags/%s", idnode_uuid_as_str(&ct->ct_id));
hts_settings_remove("channel/tag/%s", idnode_uuid_as_str(&ct->ct_id));
}

if(ct->ct_enabled && !ct->ct_internal)
Expand All @@ -821,7 +821,7 @@ channel_tag_save(channel_tag_t *ct)
{
htsmsg_t *c = htsmsg_create_map();
idnode_save(&ct->ct_id, c);
hts_settings_save(c, "channeltags/%s", idnode_uuid_as_str(&ct->ct_id));
hts_settings_save(c, "channel/tag/%s", idnode_uuid_as_str(&ct->ct_id));
htsmsg_destroy(c);
}

Expand Down Expand Up @@ -946,7 +946,7 @@ channel_tag_init ( void )
htsmsg_field_t *f;

TAILQ_INIT(&channel_tags);
if ((c = hts_settings_load_r(1, "channeltags")) != NULL) {
if ((c = hts_settings_load("channel/tag")) != NULL) {
HTSMSG_FOREACH(f, c) {
if (!(m = htsmsg_field_get_map(f))) continue;
(void)channel_tag_create(f->hmf_name, m);
Expand Down
27 changes: 27 additions & 0 deletions src/config.c
Expand Up @@ -827,6 +827,32 @@ config_migrate_v9 ( void )
}
}

static void
config_migrate_move ( const char *dir,
const char *newdir )
{
htsmsg_t *c, *e;
htsmsg_field_t *f;

if (!(c = hts_settings_load(dir)))
return;

HTSMSG_FOREACH(f, c) {
if (!(e = htsmsg_field_get_map(f))) continue;
hts_settings_save(e, "%s/%s", newdir, f->hmf_name);
hts_settings_remove("%s/%s", dir, f->hmf_name);
}

htsmsg_destroy(c);
}

static void
config_migrate_v10 ( void )
{
config_migrate_move("channel", "channel/config");
config_migrate_move("channeltags", "channel/tag");
}

/*
* Migration table
*/
Expand All @@ -840,6 +866,7 @@ static const config_migrate_t config_migrate_table[] = {
config_migrate_v7,
config_migrate_v8,
config_migrate_v9,
config_migrate_v10,
};

/*
Expand Down
2 changes: 1 addition & 1 deletion src/esfilter.c
Expand Up @@ -1034,7 +1034,7 @@ esfilter_init(void)
for (i = 0; i <= ESF_CLASS_LAST; i++)
TAILQ_INIT(&esfilters[i]);

if (!(c = hts_settings_load_r(1, "esfilter")))
if (!(c = hts_settings_load("esfilter")))
return;
HTSMSG_FOREACH(f, c) {
if (!(e = htsmsg_field_get_map(f)))
Expand Down

0 comments on commit 82f7f89

Please sign in to comment.