From f2012eefa5b5793527b92482fd3839076fd355e3 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 18 May 2012 17:05:39 +0100 Subject: [PATCH] Add some HTSP support back in. --- src/epg.c | 11 +++++++-- src/epg.h | 9 +++++-- src/htsp.c | 62 +++++++++++++++++++++++------------------------ src/webui/extjs.c | 20 +++++++-------- 4 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/epg.c b/src/epg.c index 054313f5..3f070d08 100644 --- a/src/epg.c +++ b/src/epg.c @@ -697,8 +697,9 @@ static void _eqr_add_channel } } -void epg_query(epg_query_result_t *eqr, const char *channel, const char *tag, - const char *contentgroup, const char *title) +void epg_query0 + ( epg_query_result_t *eqr, channel_t *channel, channel_tag_t *tag, + uint8_t contentgroup, const char *title ) { // TODO: will need some real code here epg_channel_t *ec; @@ -712,6 +713,12 @@ void epg_query(epg_query_result_t *eqr, const char *channel, const char *tag, return; } +void epg_query(epg_query_result_t *eqr, const char *channel, const char *tag, + const char *contentgroup, const char *title) +{ + epg_query0(eqr, NULL, NULL, 0, title); +} + void epg_query_free(epg_query_result_t *eqr) { free(eqr->eqr_array); diff --git a/src/epg.h b/src/epg.h index 3fcb71e5..8a5ca3c8 100644 --- a/src/epg.h +++ b/src/epg.h @@ -263,12 +263,17 @@ typedef struct epg_query_result { int eqr_alloced; } epg_query_result_t; +void epg_query_free(epg_query_result_t *eqr); + +/* Sorting */ +// TODO: comparator function input? +void epg_query_sort(epg_query_result_t *eqr); + +/* Query routines */ void epg_query0(epg_query_result_t *eqr, channel_t *ch, channel_tag_t *ct, uint8_t type, const char *title); void epg_query(epg_query_result_t *eqr, const char *channel, const char *tag, const char *contentgroup, const char *title); -void epg_query_free(epg_query_result_t *eqr); -void epg_query_sort(epg_query_result_t *eqr); /* ************************************************************************ diff --git a/src/htsp.c b/src/htsp.c index b7141c1a..5aee796f 100644 --- a/src/htsp.c +++ b/src/htsp.c @@ -307,7 +307,7 @@ htsp_build_channel(channel_t *ch, const char *method) if(ch->ch_icon != NULL) htsmsg_add_str(out, "channelIcon", ch->ch_icon); -#if TODO +#if TODO_EPG_CHANNEL htsmsg_add_u32(out, "eventId", ch->ch_epg_current != NULL ? ch->ch_epg_current->e_id : 0); htsmsg_add_u32(out, "nextEventId", @@ -525,7 +525,7 @@ htsp_method_getTicket(htsp_connection_t *htsp, htsmsg_t *in) static htsmsg_t * htsp_method_addDvrEntry(htsp_connection_t *htsp, htsmsg_t *in) { -#if TODO +#if TODO_DVR htsmsg_t *out; uint32_t eventid; event_t *e; @@ -700,7 +700,6 @@ htsp_method_deleteDvrEntry(htsp_connection_t *htsp, htsmsg_t *in) static htsmsg_t * htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in) { -#if TODO htsmsg_t *out, *eventIds; const char *query; int c, i; @@ -730,7 +729,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in) if( c ) { eventIds = htsmsg_create_list(); for(i = 0; i < c; ++i) { - htsmsg_add_u32(eventIds, NULL, eqr.eqr_array[i]->e_id); + htsmsg_add_u32(eventIds, NULL, eqr.eqr_array[i]->eb_id); } htsmsg_add_msg(out, "eventIds", eventIds); } @@ -738,52 +737,58 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in) epg_query_free(&eqr); return out; -#endif - return NULL; } /** * */ -#if 0 static htsmsg_t * -htsp_build_event(event_t *e) +htsp_build_event(epg_broadcast_t *e) { htsmsg_t *out; - event_t *n; + epg_broadcast_t *n; +#if TODO_DVR dvr_entry_t *de; +#endif out = htsmsg_create_map(); - htsmsg_add_u32(out, "eventId", e->e_id); + htsmsg_add_u32(out, "eventId", e->eb_id); +#if TODO_EPG_CHANNEL htsmsg_add_u32(out, "channelId", e->e_channel->ch_id); - htsmsg_add_u32(out, "start", e->e_start); - htsmsg_add_u32(out, "stop", e->e_stop); - if(e->e_title != NULL) - htsmsg_add_str(out, "title", e->e_title); - if(e->e_desc != NULL) - htsmsg_add_str(out, "description", e->e_desc); +#endif + htsmsg_add_u32(out, "start", e->eb_start); + htsmsg_add_u32(out, "stop", e->eb_stop); + if(e->eb_episode->ee_title != NULL) + htsmsg_add_str(out, "title", e->eb_episode->ee_title); + if(e->eb_episode->ee_description != NULL) + htsmsg_add_str(out, "description", e->eb_episode->ee_description); + else if(e->eb_episode->ee_summary != NULL) + htsmsg_add_str(out, "description", e->eb_episode->ee_summary); +#if TODO_REMOVE_THESE if(e->e_ext_desc != NULL) htsmsg_add_str(out, "ext_desc", e->e_ext_desc); if(e->e_ext_item != NULL) htsmsg_add_str(out, "ext_item", e->e_ext_item); if(e->e_ext_text != NULL) htsmsg_add_str(out, "ext_text", e->e_ext_text); +#endif - if(e->e_content_type) - htsmsg_add_u32(out, "contentType", e->e_content_type); + if(e->eb_episode->ee_genre) + htsmsg_add_u32(out, "contentType", e->eb_episode->ee_genre); +#if TODO_DVR if((de = dvr_entry_find_by_event(e)) != NULL) { htsmsg_add_u32(out, "dvrId", de->de_id); } +#endif - n = RB_NEXT(e, e_channel_link); + n = RB_NEXT(e, eb_slink); if(n != NULL) - htsmsg_add_u32(out, "nextEventId", n->e_id); + htsmsg_add_u32(out, "nextEventId", n->eb_id); return out; } -#endif /** * Get information about the given event + @@ -792,10 +797,9 @@ htsp_build_event(event_t *e) static htsmsg_t * htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in) { -#if TODO uint32_t eventid, numFollowing; htsmsg_t *out, *events; - event_t *e; + epg_broadcast_t *e; if(htsmsg_get_u32(in, "eventId", &eventid)) return htsp_error("Missing argument 'eventId'"); @@ -803,7 +807,7 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in) if(htsmsg_get_u32(in, "numFollowing", &numFollowing)) return htsp_error("Missing argument 'numFollowing'"); - if((e = epg_event_find_by_id(eventid)) == NULL) { + if((e = epg_broadcast_find_by_id(eventid)) == NULL) { return htsp_error("Event does not exist"); } @@ -812,7 +816,7 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in) htsmsg_add_msg(events, NULL, htsp_build_event(e)); while( numFollowing-- > 0 ) { - e = RB_NEXT(e, e_channel_link); + e = RB_NEXT(e, eb_slink); if( e == NULL ) break; htsmsg_add_msg(events, NULL, htsp_build_event(e)); @@ -820,8 +824,6 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in) htsmsg_add_msg(out, "events", events); return out; -#endif - return NULL; } @@ -831,20 +833,18 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in) static htsmsg_t * htsp_method_getEvent(htsp_connection_t *htsp, htsmsg_t *in) { -#if TODO uint32_t eventid; - event_t *e; + epg_broadcast_t *e; htsmsg_t *out; if(htsmsg_get_u32(in, "eventId", &eventid)) return htsp_error("Missing argument 'eventId'"); - if((e = epg_event_find_by_id(eventid)) == NULL) + if((e = epg_broadcast_find_by_id(eventid)) == NULL) return htsp_error("Event does not exist"); out = htsp_build_event(e); return out; -#endif return NULL; } diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 6dbec0a8..18728cef 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -325,7 +325,7 @@ extjs_channels_update(htsmsg_t *in) if((s = htsmsg_get_str(c, "name")) != NULL) channel_rename(ch, s); -#if TODO_XMLTV +#if TODO_XMLTV_REMOVE_THIS if((s = htsmsg_get_str(c, "xmltvsrc")) != NULL) channel_set_xmltv_source(ch, xmltv_channel_find_by_displayname(s)); #endif @@ -379,7 +379,7 @@ extjs_channels(http_connection_t *hc, const char *remain, void *opaque) htsmsg_add_str(c, "name", ch->ch_name); htsmsg_add_u32(c, "chid", ch->ch_id); -#if TODO_XMLTV +#if TODO_XMLTV_REMOVE_THIS if(ch->ch_xc != NULL) htsmsg_add_str(c, "xmltvsrc", ch->ch_xc->xc_displayname); #endif @@ -428,7 +428,7 @@ extjs_ecglist(http_connection_t *hc, const char *remain, void *opaque) { htsbuf_queue_t *hq = &hc->hc_reply; htsmsg_t *out, *array;//TODO:, *c; -#if TODO +#if TODO_GENRE const char *s; int i; #endif @@ -436,7 +436,7 @@ extjs_ecglist(http_connection_t *hc, const char *remain, void *opaque) out = htsmsg_create_map(); array = htsmsg_create_list(); -#if TODO +#if TODO_GENRE for(i = 0; i < 16; i++) { if((s = epg_content_group_get_name(i)) == NULL) continue; @@ -479,7 +479,7 @@ json_single_record(htsmsg_t *rec, const char *root) static int extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque) { -#if TODO_EPGGRAB +#if TODO_EPGGRAB_CONFIG htsbuf_queue_t *hq = &hc->hc_reply; const char *op = http_arg_get(&hc->hc_req_args, "op"); xmltv_channel_t *xc; @@ -746,9 +746,7 @@ extjs_epg(http_connection_t *hc, const char *remain, void *opaque) htsmsg_add_str(m, "ext_text", e->e_ext_text); #endif -#if TODO_ARE_WE_JUNKING_THIS - htsmsg_add_u32(m, "id", e->e_id); -#endif + htsmsg_add_u32(m, "id", e->eb_id); htsmsg_add_u32(m, "start", e->eb_start); htsmsg_add_u32(m, "end", e->eb_stop); htsmsg_add_u32(m, "duration", e->eb_stop - e->eb_start); @@ -806,7 +804,7 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque) if(!strcmp(op, "recordEvent")) { -#if TODO +#if TODO_DVR const char *config_name = http_arg_get(&hc->hc_req_args, "config_name"); s = http_arg_get(&hc->hc_req_args, "eventId"); @@ -894,7 +892,7 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque) htsmsg_add_u32(out, "success", 1); } else if(!strcmp(op, "createAutoRec")) { -#if TODO +#if TODO_DVR const char *cgrp = http_arg_get(&hc->hc_req_args, "contentgrp"); @@ -1072,7 +1070,7 @@ extjs_dvrlist(http_connection_t *hc, const char *remain, void *opaque) if(de->de_desc != NULL) htsmsg_add_str(m, "description", de->de_desc); -#if TODO +#if TODO_DVR if(de->de_episode.ee_onscreen) htsmsg_add_str(m, "episode", de->de_episode.ee_onscreen); #endif