Removing service lists in epggrab channel. Currently its only used by pyepg and I hate the way its implemented, so going to get rid of it until I can be bothered to do it properly.
This commit is contained in:
parent
83701298fa
commit
50d26d2c3c
4 changed files with 14 additions and 178 deletions
|
@ -61,12 +61,18 @@ typedef struct epggrab_stats
|
|||
* Grabber Channels
|
||||
* *************************************************************************/
|
||||
|
||||
/*
|
||||
* Lists
|
||||
*/
|
||||
RB_HEAD(epggrab_channel_tree, epggrab_channel);
|
||||
typedef struct epggrab_channel_tree epggrab_channel_tree_t;
|
||||
|
||||
/*
|
||||
* Grab channel
|
||||
*/
|
||||
typedef struct epggrab_channel
|
||||
{
|
||||
RB_ENTRY(epggrab_channel) link; ///< Global link
|
||||
RB_ENTRY(epggrab_channel) link; ///< Global link
|
||||
epggrab_module_t *mod; ///< Linked module
|
||||
|
||||
char *id; ///< Grabber's ID
|
||||
|
@ -74,19 +80,10 @@ typedef struct epggrab_channel
|
|||
char *name; ///< Channel name
|
||||
char *icon; ///< Channel icon
|
||||
int number; ///< Channel number
|
||||
|
||||
char **sname; ///< Service name's
|
||||
uint16_t *sid; ///< Service ID's
|
||||
|
||||
|
||||
struct channel *channel; ///< Mapped channel
|
||||
} epggrab_channel_t;
|
||||
|
||||
/*
|
||||
* Channel list structure
|
||||
*/
|
||||
RB_HEAD(epggrab_channel_tree, epggrab_channel);
|
||||
typedef struct epggrab_channel_tree epggrab_channel_tree_t;
|
||||
|
||||
/*
|
||||
* Access functions
|
||||
*/
|
||||
|
@ -95,11 +92,9 @@ htsmsg_t* epggrab_channel_list ( void );
|
|||
/*
|
||||
* Mutators
|
||||
*/
|
||||
int epggrab_channel_set_name ( epggrab_channel_t *ch, const char *name );
|
||||
int epggrab_channel_set_icon ( epggrab_channel_t *ch, const char *icon );
|
||||
int epggrab_channel_set_number ( epggrab_channel_t *ch, int number );
|
||||
int epggrab_channel_set_sname ( epggrab_channel_t *ch, const char **sname );
|
||||
int epggrab_channel_set_sid ( epggrab_channel_t *ch, const uint16_t *sid );
|
||||
int epggrab_channel_set_name ( epggrab_channel_t *ch, const char *name );
|
||||
int epggrab_channel_set_icon ( epggrab_channel_t *ch, const char *icon );
|
||||
int epggrab_channel_set_number ( epggrab_channel_t *ch, int number );
|
||||
|
||||
/*
|
||||
* Updated/link
|
||||
|
|
|
@ -36,39 +36,13 @@
|
|||
// returns 1 if link made
|
||||
int epggrab_channel_link ( epggrab_channel_t *ec, channel_t *ch )
|
||||
{
|
||||
service_t *sv;
|
||||
int match = 0, i;
|
||||
int match = 0;
|
||||
|
||||
if (!ec || !ch) return 0;
|
||||
if (ec->channel) return 0;
|
||||
|
||||
if (ec->name && !strcmp(ec->name, ch->ch_name))
|
||||
match = 1;
|
||||
else {
|
||||
LIST_FOREACH(sv, &ch->ch_services, s_ch_link) {
|
||||
if (ec->sid) {
|
||||
i = 0;
|
||||
while (ec->sid[i]) {
|
||||
if (sv->s_dvb_service_id == ec->sid[i]) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!match && ec->sname) {
|
||||
i = 0;
|
||||
while (ec->sname[i]) {
|
||||
if (!strcmp(ec->sname[i], sv->s_svcname)) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (match) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
tvhlog(LOG_INFO, ec->mod->id, "linking %s to %s",
|
||||
|
@ -129,63 +103,6 @@ int epggrab_channel_set_number ( epggrab_channel_t *ec, int number )
|
|||
return save;
|
||||
}
|
||||
|
||||
/* Set service IDs */
|
||||
int epggrab_channel_set_sid
|
||||
( epggrab_channel_t *ec, const uint16_t *sid )
|
||||
{
|
||||
int save = 0, i;
|
||||
if ( !ec || !sid ) return 0;
|
||||
if (!ec->sid) save = 1;
|
||||
else {
|
||||
i = 0;
|
||||
while ( ec->sid[i] && sid[i] ) {
|
||||
if ( ec->sid[i] != sid[i] ) break;
|
||||
i++;
|
||||
}
|
||||
if (ec->sid[i] || sid[i]) save = 1;
|
||||
}
|
||||
if (save) {
|
||||
i = 0;
|
||||
while (ec->sid[i++]);
|
||||
if (ec->sid) free(ec->sid);
|
||||
ec->sid = calloc(i, sizeof(uint16_t));
|
||||
memcpy(ec->sid, sid, i * sizeof(uint16_t));
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
/* Set names */
|
||||
int epggrab_channel_set_sname ( epggrab_channel_t *ec, const char **sname )
|
||||
{
|
||||
int save = 0, i = 0;
|
||||
if ( !ec || !sname ) return 0;
|
||||
if (!ec->sname) save = 1;
|
||||
else {
|
||||
while ( ec->sname[i] && sname[i] ) {
|
||||
if (strcmp(ec->sname[i], sname[i])) break;
|
||||
i++;
|
||||
}
|
||||
if (ec->sname[i] || sname[i]) save = 1;
|
||||
}
|
||||
if (save) {
|
||||
if (ec->sname) {
|
||||
i = 0;
|
||||
while (ec->sname[i])
|
||||
free(ec->sname[i++]);
|
||||
free(ec->sname);
|
||||
}
|
||||
i = 0;
|
||||
while (sname[i++]);
|
||||
ec->sname = calloc(i+1, sizeof(char*));
|
||||
i = 0;
|
||||
while (sname[i]) {
|
||||
ec->sname[i] = strdup(sname[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
/* Channel settings updated */
|
||||
void epggrab_channel_updated ( epggrab_channel_t *ec )
|
||||
{
|
||||
|
|
|
@ -142,9 +142,7 @@ void epggrab_module_parse
|
|||
|
||||
void epggrab_module_ch_save ( void *_m, epggrab_channel_t *ch )
|
||||
{
|
||||
int i;
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_t *a;
|
||||
epggrab_module_t *mod = _m;
|
||||
|
||||
if (ch->name)
|
||||
|
@ -153,24 +151,6 @@ void epggrab_module_ch_save ( void *_m, epggrab_channel_t *ch )
|
|||
htsmsg_add_str(m, "icon", ch->icon);
|
||||
if (ch->channel)
|
||||
htsmsg_add_u32(m, "channel", ch->channel->ch_id);
|
||||
if (ch->sid) {
|
||||
a = htsmsg_create_list();
|
||||
i = 0;
|
||||
while (ch->sid[i]) {
|
||||
htsmsg_add_u32(a, NULL, ch->sid[i]);
|
||||
i++;
|
||||
}
|
||||
htsmsg_add_msg(m, "sid", a);
|
||||
}
|
||||
if (ch->sname) {
|
||||
a = htsmsg_create_list();
|
||||
i = 0;
|
||||
while (ch->sname[i]) {
|
||||
htsmsg_add_str(a, NULL, ch->sname[i]);
|
||||
i++;
|
||||
}
|
||||
htsmsg_add_msg(m, "sname", a);
|
||||
}
|
||||
if (ch->number)
|
||||
htsmsg_add_u32(m, "number", ch->number);
|
||||
|
||||
|
@ -210,11 +190,9 @@ void epggrab_module_ch_mod ( void *mod, channel_t *ch )
|
|||
static void _epggrab_module_channel_load
|
||||
( epggrab_module_t *mod, htsmsg_t *m, const char *id )
|
||||
{
|
||||
int save = 0, i;
|
||||
int save = 0;
|
||||
const char *str;
|
||||
uint32_t u32;
|
||||
htsmsg_t *a;
|
||||
htsmsg_field_t *f;
|
||||
|
||||
epggrab_channel_t *ch = epggrab_channel_find(mod->channels, id, 1, &save, mod);
|
||||
|
||||
|
@ -222,28 +200,6 @@ static void _epggrab_module_channel_load
|
|||
ch->name = strdup(str);
|
||||
if ((str = htsmsg_get_str(m, "icon")))
|
||||
ch->icon = strdup(str);
|
||||
if ((a = htsmsg_get_list(m, "sid"))) {
|
||||
i = 0;
|
||||
HTSMSG_FOREACH(f, a) i++;
|
||||
if (i) {
|
||||
ch->sid = calloc(i+1, sizeof(uint16_t));
|
||||
i = 0;
|
||||
HTSMSG_FOREACH(f, a) {
|
||||
ch->sid[i++] = (uint16_t)f->hmf_s64;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((a = htsmsg_get_list(m, "sname"))) {
|
||||
i = 0;
|
||||
HTSMSG_FOREACH(f, a) i++;
|
||||
if (i) {
|
||||
ch->sname = calloc(i+1, sizeof(char*));
|
||||
i = 0;
|
||||
HTSMSG_FOREACH(f, a) {
|
||||
ch->sname[i++] = strdup(f->hmf_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!htsmsg_get_u32(m, "number", &u32))
|
||||
ch->number = u32;
|
||||
|
||||
|
|
|
@ -65,13 +65,9 @@ static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
{
|
||||
int save = 0;
|
||||
epggrab_channel_t *ch;
|
||||
htsmsg_t *attr, *tags, *e;
|
||||
htsmsg_field_t *f;
|
||||
htsmsg_t *attr, *tags;
|
||||
const char *str;
|
||||
uint32_t u32;
|
||||
const char *sname[11];
|
||||
uint16_t sid[11];
|
||||
int sid_idx = 0, sname_idx = 0;
|
||||
|
||||
if ( data == NULL ) return 0;
|
||||
|
||||
|
@ -90,34 +86,6 @@ static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats )
|
|||
if ((!htsmsg_xml_get_cdata_u32(tags, "number", &u32)))
|
||||
save |= epggrab_channel_set_number(ch, u32);
|
||||
|
||||
HTSMSG_FOREACH(f, tags) {
|
||||
if (!strcmp(f->hmf_name, "sid")) {
|
||||
if (sid_idx < 10) {
|
||||
e = htsmsg_get_map_by_field(f);
|
||||
if (!htsmsg_get_u32(e, "cdata", &u32)) {
|
||||
sid[sid_idx] = (uint16_t)u32;
|
||||
sid_idx++;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(f->hmf_name, "sname")) {
|
||||
if (sname_idx < 10) {
|
||||
e = htsmsg_get_map_by_field(f);
|
||||
if ((str = htsmsg_get_str(e, "cdata"))) {
|
||||
sname[sname_idx] = str;
|
||||
sname_idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sid_idx) {
|
||||
sid[sid_idx] = 0;
|
||||
save |= epggrab_channel_set_sid(ch, sid);
|
||||
}
|
||||
if (sname_idx) {
|
||||
sname[sname_idx] = NULL;
|
||||
save |= epggrab_channel_set_sname(ch, sname);
|
||||
}
|
||||
|
||||
/* Update */
|
||||
if (save) {
|
||||
epggrab_channel_updated(ch);
|
||||
|
|
Loading…
Add table
Reference in a new issue