/* Check if channels match */
int epggrab_channel_match ( epggrab_channel_t *ec, channel_t *ch )
{
+ const char *chid, *s;
+ htsmsg_field_t *f;
+
if (!ec || !ch || !ch->ch_epgauto || !ch->ch_enabled || !ec->enabled) return 0;
if (LIST_FIRST(&ec->channels)) return 0; // ignore already paired
- if (ec->name && !strcmp(ec->name, channel_get_epgid(ch))) return 1;
+ chid = channel_get_epgid(ch);
+ if (ec->name && !strcmp(ec->name, chid)) return 1;
+ if (ec->names)
+ HTSMSG_FOREACH(f, ec->names)
+ if ((s = htsmsg_field_get_str(f)) != NULL)
+ if (!strcmp(s, chid)) return 1;
if (ec->lcn && ec->lcn == channel_get_number(ch)) return 1;
return 0;
}
channel_t *ch;
int save = 0;
if (!ec || !name) return 0;
- if (!ec->name || strcmp(ec->name, name)) {
+ if (!ec->newnames && (!ec->name || strcmp(ec->name, name))) {
if (ec->name) free(ec->name);
ec->name = strdup(name);
if (epggrab_conf.channel_rename) {
}
save = 1;
}
+ if (ec->newnames == NULL)
+ ec->newnames = htsmsg_create_list();
+ htsmsg_add_str(ec->newnames, NULL, name);
return save;
}
hts_settings_remove("epggrab/%s/channels/%s",
ec->mod->saveid, idnode_uuid_as_sstr(&ec->idnode));
+ htsmsg_destroy(ec->newnames);
+ htsmsg_destroy(ec->names);
free(ec->comment);
free(ec->name);
free(ec->icon);
epggrab_channel_destroy(ec, delconf);
}
+void epggrab_channel_begin_scan ( epggrab_module_t *mod )
+{
+ epggrab_channel_t *ec;
+ lock_assert(&global_lock);
+ RB_FOREACH(ec, &mod->channels, link)
+ if (ec->newnames) {
+ htsmsg_destroy(ec->newnames);
+ ec->newnames = NULL;
+ }
+}
+
+void epggrab_channel_end_scan ( epggrab_module_t *mod )
+{
+ epggrab_channel_t *ec;
+ lock_assert(&global_lock);
+ RB_FOREACH(ec, &mod->channels, link)
+ if (ec->newnames) {
+ htsmsg_destroy(ec->names);
+ ec->names = ec->newnames;
+ ec->newnames = NULL;
+ }
+}
+
/* **************************************************************************
* Global routines
* *************************************************************************/
return &prop_sbuf_ptr;
}
+static const void *
+epggrab_channel_class_names_get ( void *obj )
+{
+ epggrab_channel_t *ec = obj;
+ char *s = ec->names ? htsmsg_list_2_csv(ec->names, ',', 0) : NULL;
+ snprintf(prop_sbuf, PROP_SBUF_LEN, "%s", s ?: "");
+ free(s);
+ return &prop_sbuf_ptr;
+}
+
+static int
+epggrab_channel_class_names_set ( void *obj, const void *p )
+{
+ htsmsg_t *m = htsmsg_csv_2_list(p, ',');
+ epggrab_channel_t *ec = obj;
+ if (htsmsg_cmp(ec->names, m)) {
+ htsmsg_destroy(ec->names);
+ ec->names = m;
+ } else {
+ htsmsg_destroy(m);
+ }
+ return 0;
+}
+
static const void *
epggrab_channel_class_channels_get ( void *obj )
{
.name = N_("Name"),
.off = offsetof(epggrab_channel_t, name),
},
+ {
+ .type = PT_STR,
+ .id = "names",
+ .name = N_("Names"),
+ .get = epggrab_channel_class_names_get,
+ .set = epggrab_channel_class_names_set,
+ },
{
.type = PT_S64,
.intsplit = CHANNEL_SPLIT,
return dst;
}
+/**
+ *
+ */
+int
+htsmsg_cmp(htsmsg_t *m1, htsmsg_t *m2)
+{
+ htsmsg_field_t *f1, *f2;
+
+ if (m1 == NULL && m2 == NULL)
+ return 0;
+ if (m1 == NULL || m2 == NULL)
+ return 1;
+
+ f2 = TAILQ_FIRST(&m2->hm_fields);
+ TAILQ_FOREACH(f1, &m1->hm_fields, hmf_link) {
+
+ if (f1->hmf_type != f2->hmf_type)
+ return 1;
+ if (strcmp(f1->hmf_name ?: "", f2->hmf_name ?: ""))
+ return 1;
+
+ switch(f1->hmf_type) {
+
+ case HMF_MAP:
+ case HMF_LIST:
+ if (htsmsg_cmp(&f1->hmf_msg, &f2->hmf_msg))
+ return 1;
+ break;
+
+ case HMF_STR:
+ if (strcmp(f1->hmf_str, f2->hmf_str))
+ return 1;
+ break;
+
+ case HMF_S64:
+ if (f1->hmf_s64 != f2->hmf_s64)
+ return 1;
+ break;
+
+ case HMF_BOOL:
+ if (f1->hmf_bool != f2->hmf_bool)
+ return 1;
+ break;
+
+ case HMF_BIN:
+ if (f1->hmf_binsize != f2->hmf_binsize)
+ return 1;
+ if (memcmp(f1->hmf_bin, f2->hmf_bin, f1->hmf_binsize))
+ return 1;
+ break;
+
+ case HMF_DBL:
+ if (f1->hmf_dbl != f2->hmf_dbl)
+ return 1;
+ break;
+ }
+
+ f2 = TAILQ_NEXT(f2, hmf_link);
+ }
+
+ if (f2)
+ return 1;
+ return 0;
+}
+
/**
*
*/
if (human) {
sep[0] = delim;
sep[1] = ' ';
- sep[2] = '\0';
- ssep = "\"";
+ ssep = "";
} else {
sep[0] = delim;
sep[1] = '\0';
- ssep = "";
+ ssep = "\"";
}
HTSMSG_FOREACH(f, m) {
if (f->hmf_type == HMF_STR) {