From d65338c0720ec3303e4ca7497cd62d53d9228cf1 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 18 May 2012 16:52:00 +0100 Subject: [PATCH] Added some of the simpleui back in, some additions to epg_broadcast. --- src/epg.c | 17 +++++++++++++++++ src/epg.h | 1 + src/webui/simpleui.c | 39 ++++++++++++++++++++++----------------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/epg.c b/src/epg.c index 7fd851b9..054313f5 100644 --- a/src/epg.c +++ b/src/epg.c @@ -561,6 +561,8 @@ int epg_episode_get_number_onscreen * Broadcast * *************************************************************************/ +static int _epg_broadcast_idx = 0; + // Note: will find broadcast playing at this time (not necessarily // one that starts at this time) // @@ -580,6 +582,7 @@ epg_broadcast_t* epg_broadcast_find_by_time skel->eb_channel = channel; skel->eb_start = start; skel->eb_stop = stop; + skel->eb_id = _epg_broadcast_idx; /* Find */ if ( !create ) { @@ -591,12 +594,26 @@ epg_broadcast_t* epg_broadcast_find_by_time if ( eb == NULL ) { eb = skel; skel = NULL; + _epg_broadcast_idx++; } } return eb; } +epg_broadcast_t *epg_broadcast_find_by_id ( int id ) +{ + // TODO: do this properly + epg_channel_t *ec; + epg_broadcast_t *ebc; + RB_FOREACH(ec, &epg_channels, ec_link) { + RB_FOREACH(ebc, &ec->ec_schedule, eb_slink) { + if (ebc->eb_id == id) return ebc; + } + } + return NULL; +} + int epg_broadcast_set_episode ( epg_broadcast_t *broadcast, epg_episode_t *episode, int u ) { diff --git a/src/epg.h b/src/epg.h index fe64852c..3fcb71e5 100644 --- a/src/epg.h +++ b/src/epg.h @@ -217,6 +217,7 @@ typedef struct epg_broadcast /* Lookup */ epg_broadcast_t *epg_broadcast_find_by_time ( epg_channel_t *ch, time_t start, time_t stop, int create ); +epg_broadcast_t *epg_broadcast_find_by_id ( int id ); /* Mutators */ int epg_broadcast_set_episode ( epg_broadcast_t *b, epg_episode_t *e, int u ) diff --git a/src/webui/simpleui.c b/src/webui/simpleui.c index 44e1b56a..d4f34b8c 100644 --- a/src/webui/simpleui.c +++ b/src/webui/simpleui.c @@ -58,15 +58,14 @@ static int page_simple(http_connection_t *hc, const char *remain, void *opaque) { -#if TODO htsbuf_queue_t *hq = &hc->hc_reply; const char *s = http_arg_get(&hc->hc_req_args, "s"); - event_t *e; + epg_broadcast_t *e; int c, k, i; struct tm a, b, day; dvr_entry_t *de; dvr_query_result_t dqr; - const char *rstatus; + const char *rstatus = NULL; epg_query_result_t eqr; htsbuf_qprintf(hq, ""); @@ -109,8 +108,8 @@ page_simple(http_connection_t *hc, for(k = 0; k < c; k++) { e = eqr.eqr_array[k]; - localtime_r(&e->e_start, &a); - localtime_r(&e->e_stop, &b); + localtime_r(&e->eb_start, &a); + localtime_r(&e->eb_stop, &b); if(a.tm_wday != day.tm_wday || a.tm_mday != day.tm_mday || a.tm_mon != day.tm_mon || a.tm_year != day.tm_year) { @@ -120,16 +119,18 @@ page_simple(http_connection_t *hc, days[day.tm_wday], day.tm_mday, day.tm_mon + 1); } +#if TODO_DVR de = dvr_entry_find_by_event(e); rstatus = de != NULL ? val2str(de->de_sched_state, recstatustxt) : NULL; +#endif htsbuf_qprintf(hq, "" "%02d:%02d-%02d:%02d %s%s%s
", - e->e_id, + e->eb_id, a.tm_hour, a.tm_min, b.tm_hour, b.tm_min, - e->e_title, + e->eb_episode->ee_title, rstatus ? " " : "", rstatus ?: ""); } } @@ -185,7 +186,6 @@ page_simple(http_connection_t *hc, htsbuf_qprintf(hq, ""); http_output_html(hc); -#endif return 0; } @@ -195,9 +195,8 @@ page_simple(http_connection_t *hc, static int page_einfo(http_connection_t *hc, const char *remain, void *opaque) { -#if TODO htsbuf_queue_t *hq = &hc->hc_reply; - event_t *e; + epg_broadcast_t *e; struct tm a, b; dvr_entry_t *de; const char *rstatus; @@ -205,11 +204,12 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque) pthread_mutex_lock(&global_lock); - if(remain == NULL || (e = epg_event_find_by_id(atoi(remain))) == NULL) { + if(remain == NULL || (e = epg_broadcast_find_by_id(atoi(remain))) == NULL) { pthread_mutex_unlock(&global_lock); return 404; } +#if TODO_DVR de = dvr_entry_find_by_event(e); if((http_arg_get(&hc->hc_req_args, "rec")) != NULL) { @@ -218,20 +218,22 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque) } else if(de != NULL && (http_arg_get(&hc->hc_req_args, "cancel")) != NULL) { de = dvr_entry_cancel(de); } +#endif htsbuf_qprintf(hq, ""); htsbuf_qprintf(hq, ""); - localtime_r(&e->e_start, &a); - localtime_r(&e->e_stop, &b); + localtime_r(&e->eb_start, &a); + localtime_r(&e->eb_stop, &b); htsbuf_qprintf(hq, "%s, %d/%d %02d:%02d - %02d:%02d
", days[a.tm_wday], a.tm_mday, a.tm_mon + 1, a.tm_hour, a.tm_min, b.tm_hour, b.tm_min); + // TODO: use real channel? htsbuf_qprintf(hq, "
\"%s\": \"%s\"

", - e->e_channel->ch_name, e->e_title); + e->eb_channel->ec_name, e->eb_episode->ee_title); dvr_status = de != NULL ? de->de_sched_state : DVR_NOSTATE; @@ -239,7 +241,7 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque) htsbuf_qprintf(hq, "Recording status: %s
", rstatus); htsbuf_qprintf(hq, "
", - e->e_id); + e->eb_id); switch(dvr_status) { case DVR_SCHEDULED: @@ -263,14 +265,17 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque) } htsbuf_qprintf(hq, "
"); - htsbuf_qprintf(hq, "%s", e->e_desc); + if ( e->eb_episode->ee_description ) + htsbuf_qprintf(hq, "%s", e->eb_episode->ee_description); + else if ( e->eb_episode->ee_summary ) + htsbuf_qprintf(hq, "%s", e->eb_episode->ee_summary); + pthread_mutex_unlock(&global_lock); htsbuf_qprintf(hq, "
To main page
"); htsbuf_qprintf(hq, ""); http_output_html(hc); -#endif return 0; }