Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: move to the idnode/simple node system
  • Loading branch information
perexg committed Sep 17, 2015
1 parent 9b91e06 commit a231130
Show file tree
Hide file tree
Showing 22 changed files with 526 additions and 860 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -28,7 +28,7 @@ LANGUAGES ?= bg cs de en en_GB es fa fr he hr hu it lv nl pl pt ru sv
# Common compiler flags
#

CFLAGS += -g -O2
CFLAGS += -g -Og
ifeq ($(CONFIG_W_UNUSED_RESULT),yes)
CFLAGS += -Wunused-result
endif
Expand Down
42 changes: 40 additions & 2 deletions src/api/api_epggrab.c
Expand Up @@ -35,11 +35,49 @@ api_epggrab_channel_list
return 0;
}

static int
api_epggrab_module_list
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
htsmsg_t *l = htsmsg_create_list(), *m;
epggrab_module_t *mod;
pthread_mutex_lock(&global_lock);
LIST_FOREACH(mod, &epggrab_modules, link) {
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_sstr(&mod->idnode));
htsmsg_add_str(m, "status", epggrab_module_get_status(mod));
htsmsg_add_str(m, "title", idnode_get_title(&mod->idnode, perm->aa_lang));
htsmsg_add_msg(l, NULL, m);
}
pthread_mutex_unlock(&global_lock);
*resp = htsmsg_create_map();
htsmsg_add_msg(*resp, "entries", l);
return 0;
}

static int
api_epggrab_ota_trigger
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
int32_t s32;
if (htsmsg_get_s32(args, "trigger", &s32))
return EINVAL;
if (s32 > 0) {
pthread_mutex_lock(&global_lock);
epggrab_ota_trigger(s32);
pthread_mutex_unlock(&global_lock);
}
return 0;
}

void api_epggrab_init ( void )
{
static api_hook_t ah[] = {
{ "epggrab/channel/list", ACCESS_ANONYMOUS,
api_epggrab_channel_list, NULL },
{ "epggrab/channel/list", ACCESS_ANONYMOUS, api_epggrab_channel_list, NULL },
{ "epggrab/module/list", ACCESS_ADMIN, api_epggrab_module_list, NULL },
{ "epggrab/config/load", ACCESS_ADMIN, api_idnode_load_simple, &epggrab_conf.idnode },
{ "epggrab/config/save", ACCESS_ADMIN, api_idnode_save_simple, &epggrab_conf.idnode },
{ "epggrab/ota/trigger", ACCESS_ADMIN, api_epggrab_ota_trigger, NULL },
{ NULL },
};

Expand Down
41 changes: 40 additions & 1 deletion src/config.c
Expand Up @@ -1284,6 +1284,44 @@ config_migrate_v20 ( void )
}
}

/*
* v20 -> v21 : epggrab changes
*/
static void
config_migrate_v21 ( void )
{
htsmsg_t *c, *m, *e, *a;
htsmsg_field_t *f;
const char *str;
int64_t s64;

if ((c = hts_settings_load_r(1, "epggrab/config")) != NULL) {
str = htsmsg_get_str(c, "module");
m = htsmsg_get_map(c, "mod_enabled");
e = htsmsg_create_map();
if (m) {
HTSMSG_FOREACH(f, m) {
s64 = 0;
htsmsg_field_get_s64(f, &s64);
if ((s64 || !strcmp(str ?: "", f->hmf_name)) &&
f->hmf_name && f->hmf_name[0]) {
a = htsmsg_create_map();
htsmsg_add_bool(a, "enabled", 1);
htsmsg_add_msg(e, f->hmf_name, a);
}
}
}
htsmsg_delete_field(c, "mod_enabled");
htsmsg_delete_field(c, "module");
htsmsg_add_msg(c, "modules", e);
hts_settings_save(c, "epggrab/config");
htsmsg_destroy(c);
}
}




/*
* Perform backup
*/
Expand Down Expand Up @@ -1400,7 +1438,8 @@ static const config_migrate_t config_migrate_table[] = {
config_migrate_v17,
config_migrate_v18,
config_migrate_v19,
config_migrate_v20
config_migrate_v20,
config_migrate_v21
};

/*
Expand Down
2 changes: 1 addition & 1 deletion src/cron.c
Expand Up @@ -163,7 +163,7 @@ cron_multi_t *
cron_multi_set ( const char *str )
{
char *s = str ? alloca(strlen(str) + 1) : NULL;
char *line, *sptr;
char *line, *sptr = NULL;
cron_t cron;
cron_multi_t *cm = NULL, *cm2;
int count = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/epgdb.c
Expand Up @@ -332,8 +332,9 @@ void epg_save ( void )

sbuf_init_fixed(sb, EPG_DB_ALLOC_STEP);

if (epggrab_epgdb_periodicsave)
gtimer_arm(&epggrab_save_timer, epg_save_callback, NULL, epggrab_epgdb_periodicsave);
if (epggrab_conf.epgdb_periodicsave)
gtimer_arm(&epggrab_save_timer, epg_save_callback, NULL,
epggrab_conf.epgdb_periodicsave);

memset(&stats, 0, sizeof(stats));
if ( _epg_write_sect(sb, "config") ) goto error;
Expand Down

0 comments on commit a231130

Please sign in to comment.