return &s;
}
-static int
-channel_class_set_name ( void *o, const void *p )
+static const void *
+channel_class_get_number ( void *p )
{
- return channel_set_name(o, p);
+ static int i;
+ i = channel_get_number(p);
+ return &i;
}
const idclass_t channel_class = {
.name = "Name",
.off = offsetof(channel_t, ch_name),
.get = channel_class_get_name,
- .set = channel_class_set_name,
},
{
.type = PT_INT,
.id = "number",
.name = "Number",
.off = offsetof(channel_t, ch_number),
+ .get = channel_class_get_number,
},
{
.type = PT_STR,
static const char *blank = "";
const char *s;
channel_service_mapping_t *csm;
-
- if (ch->ch_name) return ch->ch_name;
+ if (ch->ch_name && *ch->ch_name) return ch->ch_name;
LIST_FOREACH(csm, &ch->ch_services, csm_chn_link)
if ((s = service_get_channel_name(csm->csm_svc)))
return s;
}
int
-channel_set_name ( channel_t *ch, const char *s )
+channel_get_number ( channel_t *ch )
{
- if (!s || !*s) {
- if (ch->ch_name) {
- free(ch->ch_name);
- ch->ch_name = NULL;
- }
- return 1; // NOTE: we always return this, else UI gets confused
- // if user see's generated name clears to "" and tries to set
- // and nosave is returned (so UI doesn't update)
- }
-
- if (!ch->ch_name || strcmp(ch->ch_name, s)) {
- free(ch->ch_name);
- ch->ch_name = strdup(s);
- return 1;
- }
-
+ int n;
+ channel_service_mapping_t *csm;
+ if (ch->ch_number) return ch->ch_number;
+ LIST_FOREACH(csm, &ch->ch_services, csm_chn_link)
+ if ((n = service_get_channel_number(csm->csm_svc)))
+ return n;
return 0;
}
const char *channel_get_name ( channel_t *ch );
int channel_set_name ( channel_t *ch, const char *s );
+int channel_get_number ( channel_t *ch );
+
+const char *channel_get_icon ( channel_t *ch );
+
#define channel_get_uuid(ch) idnode_uuid_as_str(&ch->ch_id)
#define channel_get_id(ch) idnode_get_short_uuid((&ch->ch_id))
htsmsg_t *services = htsmsg_create_list();
htsmsg_add_u32(out, "channelId", channel_get_id(ch));
- htsmsg_add_u32(out, "channelNumber", ch->ch_number);
+ htsmsg_add_u32(out, "channelNumber", channel_get_number(ch));
htsmsg_add_str(out, "channelName", channel_get_name(ch));
if(ch->ch_icon != NULL) {
int save = 0;
const idclass_t *idc = self->in_class;
save = idnode_class_write_values(self, idc, c, optmask);
- if (save && dosave) {
+ if (save && dosave)
idnode_savefn(self);
+ if (dosave)
idnode_notify(self, NULL, 0, 0);
- }
+ // Note: always output event if "dosave", reason is that UI updates on
+ // these, but there are some subtle cases where it will expect
+ // an update and not get one. This include fields being set for
+ // which there is user-configurable value and auto fallback so
+ // the UI state might not atually reflect the user config
return save;
}
return r;
}
+/*
+ * Get number for service
+ */
+int
+service_get_channel_number ( service_t *s )
+{
+ if (s->s_channel_number) return s->s_channel_number(s);
+ return 0;
+}
+
/**
* Get the encryption CAID from a service
* only the first CA stream in a service is returned
void sort_elementary_streams(service_t *t);
const char *service_get_channel_name (service_t *s);
+int service_get_channel_number (service_t *s);
#endif // SERVICE_H__
" icon = %s\n\n",
ch->ch_refcount,
ch->ch_zombie,
- ch->ch_number,
+ channel_get_number(ch),
ch->ch_icon ?: "<none set>");
}
}