Use int for tag IDs

This commit is contained in:
Andreas Öman 2009-02-28 16:31:33 +00:00
parent 202aac3b69
commit c61205b9fd
4 changed files with 14 additions and 13 deletions

View file

@ -324,7 +324,7 @@ channel_save(channel_t *ch)
tags = htsmsg_create_array();
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link)
htsmsg_add_str(tags, NULL, ctm->ctm_tag->ct_identifier);
htsmsg_add_u32(tags, NULL, ctm->ctm_tag->ct_identifier);
htsmsg_add_msg(m, "tags", tags);
@ -622,10 +622,12 @@ channel_tag_find(const char *id, int create)
channel_tag_t *ct;
char buf[20];
static int tally;
uint32_t u32;
if(id != NULL) {
u32 = atoi(id);
TAILQ_FOREACH(ct, &channel_tags, ct_link)
if(!strcmp(ct->ct_identifier, id))
if(ct->ct_identifier == u32)
return ct;
}
@ -641,7 +643,7 @@ channel_tag_find(const char *id, int create)
tally = MAX(atoi(id), tally);
}
ct->ct_identifier = strdup(id);
ct->ct_identifier = atoi(id);
ct->ct_name = strdup("New tag");
ct->ct_comment = strdup("");
ct->ct_icon = strdup("");
@ -682,7 +684,6 @@ channel_tag_destroy(channel_tag_t *ct)
if(ct->ct_enabled && !ct->ct_internal)
htsp_tag_delete(ct);
free(ct->ct_identifier);
free(ct->ct_name);
free(ct->ct_comment);
free(ct->ct_icon);
@ -705,7 +706,7 @@ channel_tag_record_build(channel_tag_t *ct)
htsmsg_add_str(e, "name", ct->ct_name);
htsmsg_add_str(e, "comment", ct->ct_comment);
htsmsg_add_str(e, "icon", ct->ct_icon);
htsmsg_add_str(e, "id", ct->ct_identifier);
htsmsg_add_u32(e, "id", ct->ct_identifier);
return e;
}

View file

@ -71,10 +71,10 @@ typedef struct channel_tag {
int ct_enabled;
int ct_internal;
int ct_titled_icon;
int ct_identifier;
char *ct_name;
char *ct_comment;
char *ct_icon;
char *ct_identifier;
struct channel_tag_mapping_list ct_ctms;
struct dvr_autorec_entry_list ct_autorecs;

10
htsp.c
View file

@ -262,7 +262,7 @@ htsp_build_channel(channel_t *ch, const char *method)
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
ct = ctm->ctm_tag;
if(ct->ct_enabled && !ct->ct_internal)
htsmsg_add_str(tags, NULL, ct->ct_identifier);
htsmsg_add_u32(tags, NULL, ct->ct_identifier);
}
htsmsg_add_msg(out, "tags", tags);
@ -278,10 +278,10 @@ static htsmsg_t *
htsp_build_tag(channel_tag_t *ct, const char *method, int include_channels)
{
channel_tag_mapping_t *ctm;
htsmsg_t *out = htsmsg_create();
htsmsg_t *members = include_channels ? htsmsg_create_array() : NULL;
htsmsg_t *out = htsmsg_create();
htsmsg_t *members = include_channels ? htsmsg_create_array() : NULL;
htsmsg_add_str(out, "tagId", ct->ct_identifier);
htsmsg_add_u32(out, "tagId", ct->ct_identifier);
htsmsg_add_str(out, "tagName", ct->ct_name);
htsmsg_add_str(out, "tagIcon", ct->ct_icon);
@ -891,7 +891,7 @@ void
htsp_tag_delete(channel_tag_t *ct)
{
htsmsg_t *m = htsmsg_create();
htsmsg_add_str(m, "tagId", ct->ct_identifier);
htsmsg_add_u32(m, "tagId", ct->ct_identifier);
htsmsg_add_str(m, "method", "tagDelete");
htsp_async_send(m);
}

View file

@ -699,7 +699,7 @@ extjs_channel(http_connection_t *hc, const char *remain, void *opaque)
buf[0] = 0;
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"%s%s", strlen(buf) == 0 ? "" : ",",
"%s%d", strlen(buf) == 0 ? "" : ",",
ctm->ctm_tag->ct_identifier);
}
htsmsg_add_str(r, "tags", buf);
@ -895,7 +895,7 @@ extjs_channeltags(http_connection_t *hc, const char *remain, void *opaque)
continue;
e = htsmsg_create();
htsmsg_add_str(e, "identifier", ct->ct_identifier);
htsmsg_add_u32(e, "identifier", ct->ct_identifier);
htsmsg_add_str(e, "name", ct->ct_name);
htsmsg_add_msg(array, NULL, e);
}