channel tag: export public URL for icons
This commit is contained in:
parent
ec231ac12a
commit
8d1eb5b6c6
4 changed files with 49 additions and 6 deletions
|
@ -535,7 +535,7 @@ channel_get_number ( channel_t *ch )
|
|||
const char *
|
||||
channel_get_icon ( channel_t *ch )
|
||||
{
|
||||
static __thread char buf[512], buf2[512];
|
||||
static char buf[512], buf2[512];
|
||||
channel_service_mapping_t *csm;
|
||||
const char *picon = config_get_picon_path(),
|
||||
*icon = ch->ch_icon;
|
||||
|
@ -570,7 +570,6 @@ channel_get_icon ( channel_t *ch )
|
|||
/* Lookup imagecache ID */
|
||||
if ((id = imagecache_get_id(icon))) {
|
||||
snprintf(buf, sizeof(buf), "imagecache/%d", id);
|
||||
|
||||
} else {
|
||||
strncpy(buf, icon, sizeof(buf));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
@ -877,6 +876,24 @@ channel_tag_save(channel_tag_t *ct)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const char *
|
||||
channel_tag_get_icon(channel_tag_t *ct)
|
||||
{
|
||||
static char buf[64];
|
||||
const char *icon = ct->ct_icon;
|
||||
uint32_t id;
|
||||
|
||||
/* Lookup imagecache ID */
|
||||
if ((id = imagecache_get_id(icon))) {
|
||||
snprintf(buf, sizeof(buf), "imagecache/%d", id);
|
||||
return buf;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
/* **************************************************************************
|
||||
* Channel Tag Class definition
|
||||
* **************************************************************************/
|
||||
|
@ -900,6 +917,20 @@ channel_tag_class_get_title (idnode_t *self)
|
|||
return ct->ct_name ?: "";
|
||||
}
|
||||
|
||||
static void
|
||||
channel_tag_class_icon_notify ( void *obj )
|
||||
{
|
||||
(void)channel_tag_get_icon(obj);
|
||||
}
|
||||
|
||||
static const void *
|
||||
channel_tag_class_get_icon ( void *obj )
|
||||
{
|
||||
static const char *s;
|
||||
s = channel_tag_get_icon(obj);
|
||||
return &s;
|
||||
}
|
||||
|
||||
/* exported for others */
|
||||
htsmsg_t *
|
||||
channel_tag_class_get_list(void *o)
|
||||
|
@ -942,6 +973,14 @@ const idclass_t channel_tag_class = {
|
|||
.id = "icon",
|
||||
.name = "Icon (full URL)",
|
||||
.off = offsetof(channel_tag_t, ct_icon),
|
||||
.notify = channel_tag_class_icon_notify,
|
||||
},
|
||||
{
|
||||
.type = PT_STR,
|
||||
.id = "icon_public_url",
|
||||
.name = "Icon URL",
|
||||
.get = channel_tag_class_get_icon,
|
||||
.opts = PO_RDONLY | PO_NOSAVE | PO_HIDDEN,
|
||||
},
|
||||
{
|
||||
.type = PT_BOOL,
|
||||
|
|
|
@ -171,6 +171,8 @@ void channel_tag_save(channel_tag_t *ct);
|
|||
|
||||
htsmsg_t * channel_tag_class_get_list(void *o);
|
||||
|
||||
const char * channel_tag_get_icon(channel_tag_t *ct);
|
||||
|
||||
int channel_access(channel_t *ch, struct access *a, const char *username);
|
||||
|
||||
int channel_tag_map(channel_t *ch, channel_tag_t *ct);
|
||||
|
|
|
@ -651,7 +651,7 @@ htsp_build_tag(channel_tag_t *ct, const char *method, int include_channels)
|
|||
htsmsg_add_u32(out, "tagId", htsp_channel_tag_get_identifier(ct));
|
||||
|
||||
htsmsg_add_str(out, "tagName", ct->ct_name);
|
||||
htsmsg_add_str(out, "tagIcon", ct->ct_icon);
|
||||
htsmsg_add_str(out, "tagIcon", channel_tag_get_icon(ct));
|
||||
htsmsg_add_u32(out, "tagTitledIcon", ct->ct_titled_icon);
|
||||
|
||||
if(members != NULL) {
|
||||
|
|
|
@ -451,9 +451,11 @@ imagecache_get_id ( const char *url )
|
|||
if (!i) {
|
||||
i = imagecache_skel;
|
||||
i->url = strdup(url);
|
||||
i->id = ++imagecache_id;
|
||||
j = RB_INSERT_SORTED(&imagecache_by_id, i, id_link, id_cmp);
|
||||
assert(!j);
|
||||
do {
|
||||
i->id = ++imagecache_id % INT_MAX;
|
||||
if (!i->id) i->id = ++imagecache_id % INT_MAX;
|
||||
j = RB_INSERT_SORTED(&imagecache_by_id, i, id_link, id_cmp);
|
||||
} while (j);
|
||||
SKEL_USED(imagecache_skel);
|
||||
#if ENABLE_IMAGECACHE
|
||||
imagecache_image_add(i);
|
||||
|
|
Loading…
Add table
Reference in a new issue