Switch to buffer management framework in libhts
This commit is contained in:
parent
f3305cf6f0
commit
feb9cddc65
20 changed files with 585 additions and 725 deletions
166
ajaxui/ajaxui.c
166
ajaxui/ajaxui.c
|
@ -80,35 +80,35 @@ ajaxui_escape_apostrophe(const char *content)
|
|||
*
|
||||
*/
|
||||
void
|
||||
ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
|
||||
ajax_generate_select_functions(htsbuf_queue_t *hq, const char *fprefix,
|
||||
char **selvector)
|
||||
{
|
||||
int n;
|
||||
|
||||
tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
|
||||
htsbuf_qprintf(hq, "<script type=\"text/javascript\">\r\n"
|
||||
"//<![CDATA[\r\n");
|
||||
|
||||
/* Select all */
|
||||
tcp_qprintf(tq, "%s_sel_all = function() {\r\n", fprefix);
|
||||
htsbuf_qprintf(hq, "%s_sel_all = function() {\r\n", fprefix);
|
||||
for(n = 0; selvector[n] != NULL; n++)
|
||||
tcp_qprintf(tq, "$('sel_%s').checked = true;\r\n", selvector[n]);
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(hq, "$('sel_%s').checked = true;\r\n", selvector[n]);
|
||||
htsbuf_qprintf(hq, "}\r\n");
|
||||
|
||||
/* Select none */
|
||||
tcp_qprintf(tq, "%s_sel_none = function() {\r\n", fprefix);
|
||||
htsbuf_qprintf(hq, "%s_sel_none = function() {\r\n", fprefix);
|
||||
for(n = 0; selvector[n] != NULL; n++)
|
||||
tcp_qprintf(tq, "$('sel_%s').checked = false;\r\n", selvector[n]);
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(hq, "$('sel_%s').checked = false;\r\n", selvector[n]);
|
||||
htsbuf_qprintf(hq, "}\r\n");
|
||||
|
||||
/* Invert selection */
|
||||
tcp_qprintf(tq, "%s_sel_invert = function() {\r\n", fprefix);
|
||||
htsbuf_qprintf(hq, "%s_sel_invert = function() {\r\n", fprefix);
|
||||
for(n = 0; selvector[n] != NULL; n++)
|
||||
tcp_qprintf(tq, "$('sel_%s').checked = !$('sel_%s').checked;\r\n",
|
||||
htsbuf_qprintf(hq, "$('sel_%s').checked = !$('sel_%s').checked;\r\n",
|
||||
selvector[n], selvector[n]);
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(hq, "}\r\n");
|
||||
|
||||
/* Invoke AJAX call containing all selected elements */
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"%s_sel_do = function(op, arg1, arg2, check) {\r\n"
|
||||
"if(check == true && !confirm(\"Are you sure?\")) {return;}\r\n"
|
||||
"var h = new Hash();\r\n"
|
||||
|
@ -117,13 +117,13 @@ ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
|
|||
);
|
||||
|
||||
for(n = 0; selvector[n] != NULL; n++)
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"if($('sel_%s').checked) {h.set('%s', 'selected') }\r\n",
|
||||
selvector[n], selvector[n]);
|
||||
tcp_qprintf(tq, " new Ajax.Request('/ajax/' + op, "
|
||||
htsbuf_qprintf(hq, " new Ajax.Request('/ajax/' + op, "
|
||||
"{parameters: h});\r\n");
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq, "}\r\n");
|
||||
htsbuf_qprintf(hq,
|
||||
"\r\n//]]>\r\n"
|
||||
"</script>\r\n");
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
|
|||
* AJAX table
|
||||
*/
|
||||
void
|
||||
ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq,
|
||||
ajax_table_top(ajax_table_t *t, http_connection_t *hc, htsbuf_queue_t *hq,
|
||||
const char *names[], int weights[])
|
||||
{
|
||||
int n = 0, i, tw = 0;
|
||||
|
@ -147,19 +147,19 @@ ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq,
|
|||
|
||||
memset(t, 0, sizeof(ajax_table_t));
|
||||
|
||||
t->tq = tq;
|
||||
t->hq = hq;
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
t->csize[i] = 100 * weights[i] / tw;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"padding-right: 20px\">");
|
||||
htsbuf_qprintf(hq, "<div style=\"padding-right: 20px\">");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%%\">");
|
||||
htsbuf_qprintf(hq, "<div style=\"overflow: auto; width: 100%%\">");
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: %d%%\">%s</div>",
|
||||
htsbuf_qprintf(hq, "<div style=\"float: left; width: %d%%\">%s</div>",
|
||||
t->csize[i], *names[i] ? names[i]: " ");
|
||||
tcp_qprintf(tq, "</div></div><hr><div class=\"normaltable\">\r\n");
|
||||
htsbuf_qprintf(hq, "</div></div><hr><div class=\"normaltable\">\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ ajax_table_row_start(ajax_table_t *t, const char *id)
|
|||
{
|
||||
t->rowid = id;
|
||||
t->rowcol = !t->rowcol;
|
||||
tcp_qprintf(t->tq, "%s<div style=\"%soverflow: auto; width: 100%\">",
|
||||
htsbuf_qprintf(t->hq, "%s<div style=\"%soverflow: auto; width: 100%\">",
|
||||
t->inrow ? "</div>\r\n" : "",
|
||||
t->rowcol ? "background: #fff; " : "");
|
||||
t->inrow = 1;
|
||||
|
@ -183,7 +183,7 @@ ajax_table_row_start(ajax_table_t *t, const char *id)
|
|||
void
|
||||
ajax_table_subrow_start(ajax_table_t *t)
|
||||
{
|
||||
tcp_qprintf(t->tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(t->hq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
t->curcol = 0;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ ajax_table_subrow_start(ajax_table_t *t)
|
|||
void
|
||||
ajax_table_subrow_end(ajax_table_t *t)
|
||||
{
|
||||
tcp_qprintf(t->tq, "</div>");
|
||||
htsbuf_qprintf(t->hq, "</div>");
|
||||
t->curcol = 0;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ ajax_table_details_start(ajax_table_t *t)
|
|||
assert(t->inrow == 1);
|
||||
t->inrow = 0;
|
||||
/* Extra info */
|
||||
tcp_qprintf(t->tq, "</div><div id=\"details_%s\" style=\"%sdisplay: none\">",
|
||||
htsbuf_qprintf(t->hq, "</div><div id=\"details_%s\" style=\"%sdisplay: none\">",
|
||||
t->rowid, t->rowcol ? "background: #fff; " : "");
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ void
|
|||
ajax_table_details_end(ajax_table_t *t)
|
||||
{
|
||||
/* Extra info */
|
||||
tcp_qprintf(t->tq, "</div>");
|
||||
htsbuf_qprintf(t->hq, "</div>");
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,23 +233,23 @@ ajax_table_cell(ajax_table_t *t, const char *id, const char *fmt, ...)
|
|||
va_start(ap, fmt);
|
||||
|
||||
if(t->rowid && id) {
|
||||
tcp_qprintf(t->tq, "<div id=\"%s_%s\"", id, t->rowid);
|
||||
htsbuf_qprintf(t->hq, "<div id=\"%s_%s\"", id, t->rowid);
|
||||
} else {
|
||||
tcp_qprintf(t->tq, "<div");
|
||||
htsbuf_qprintf(t->hq, "<div");
|
||||
}
|
||||
tcp_qprintf(t->tq,
|
||||
htsbuf_qprintf(t->hq,
|
||||
" style=\"float: left; width: %d%%\">", t->csize[t->curcol]);
|
||||
t->curcol++;
|
||||
if(t->curcol == 20)
|
||||
abort();
|
||||
|
||||
if(fmt == NULL)
|
||||
tcp_qprintf(t->tq, " ");
|
||||
htsbuf_qprintf(t->hq, " ");
|
||||
else
|
||||
tcp_qvprintf(t->tq, fmt, ap);
|
||||
htsbuf_vqprintf(t->hq, fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
tcp_qprintf(t->tq, "</div>");
|
||||
htsbuf_qprintf(t->hq, "</div>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,14 +282,14 @@ ajax_table_cell_checkbox(ajax_table_t *t)
|
|||
void
|
||||
ajax_table_bottom(ajax_table_t *t)
|
||||
{
|
||||
tcp_qprintf(t->tq, "%s</div>", t->inrow ? "</div>" : "");
|
||||
htsbuf_qprintf(t->hq, "%s</div>", t->inrow ? "</div>" : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX box start
|
||||
*/
|
||||
void
|
||||
ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
||||
ajax_box_begin(htsbuf_queue_t *hq, ajax_box_t type,
|
||||
const char *id, const char *style, const char *title)
|
||||
{
|
||||
char id0[100], style0[100];
|
||||
|
@ -307,7 +307,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
|||
|
||||
switch(type) {
|
||||
case AJAX_BOX_SIDEBOX:
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<div class=\"sidebox\">"
|
||||
"<div class=\"boxhead\"><h2>%s</h2></div>\r\n"
|
||||
" <div class=\"boxbody\" %s%s>",
|
||||
|
@ -315,7 +315,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
|||
break;
|
||||
|
||||
case AJAX_BOX_FILLED:
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<div style=\"margin: 3px\">"
|
||||
"<b class=\"filledbox\">"
|
||||
"<b class=\"filledbox1\"><b></b></b>"
|
||||
|
@ -328,7 +328,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
|||
break;
|
||||
|
||||
case AJAX_BOX_BORDER:
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<div style=\"margin: 3px\">"
|
||||
"<b class=\"borderbox\">"
|
||||
"<b class=\"borderbox1\"><b></b></b>"
|
||||
|
@ -345,15 +345,15 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
|||
* AJAX box end
|
||||
*/
|
||||
void
|
||||
ajax_box_end(tcp_queue_t *tq, ajax_box_t type)
|
||||
ajax_box_end(htsbuf_queue_t *hq, ajax_box_t type)
|
||||
{
|
||||
switch(type) {
|
||||
case AJAX_BOX_SIDEBOX:
|
||||
tcp_qprintf(tq,"</div></div>");
|
||||
htsbuf_qprintf(hq,"</div></div>");
|
||||
break;
|
||||
|
||||
case AJAX_BOX_FILLED:
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"</div>"
|
||||
"<b class=\"filledbox\">"
|
||||
"<b class=\"filledbox5\"></b>"
|
||||
|
@ -365,7 +365,7 @@ ajax_box_end(tcp_queue_t *tq, ajax_box_t type)
|
|||
break;
|
||||
|
||||
case AJAX_BOX_BORDER:
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"</div>"
|
||||
"<b class=\"borderbox\">"
|
||||
"<b class=\"borderbox3\"></b>"
|
||||
|
@ -381,19 +381,19 @@ ajax_box_end(tcp_queue_t *tq, ajax_box_t type)
|
|||
*
|
||||
*/
|
||||
void
|
||||
ajax_js(tcp_queue_t *tq, const char *fmt, ...)
|
||||
ajax_js(htsbuf_queue_t *hq, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<script type=\"text/javascript\">\r\n"
|
||||
"//<![CDATA[\r\n");
|
||||
|
||||
va_start(ap, fmt);
|
||||
tcp_qvprintf(tq, fmt, ap);
|
||||
htsbuf_vqprintf(hq, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"\r\n//]]>\r\n"
|
||||
"</script>\r\n");
|
||||
}
|
||||
|
@ -404,22 +404,22 @@ ajax_js(tcp_queue_t *tq, const char *fmt, ...)
|
|||
* Based on the given char[] array, generate a menu bar
|
||||
*/
|
||||
void
|
||||
ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name,
|
||||
ajax_menu_bar_from_array(htsbuf_queue_t *hq, const char *name,
|
||||
const char **vec, int num, int cur)
|
||||
{
|
||||
int i;
|
||||
|
||||
tcp_qprintf(tq, "<ul class=\"menubar\">");
|
||||
htsbuf_qprintf(hq, "<ul class=\"menubar\">");
|
||||
|
||||
for(i = 0; i < num; i++) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<li%s>"
|
||||
"<a href=\"javascript:switchtab('%s', '%d')\">%s</a>"
|
||||
"</li>",
|
||||
cur == i ? " style=\"font-weight:bold;\"" : "", name,
|
||||
i, vec[i]);
|
||||
}
|
||||
tcp_qprintf(tq, "</ul>");
|
||||
htsbuf_qprintf(hq, "</ul>");
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,29 +427,29 @@ ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name,
|
|||
*
|
||||
*/
|
||||
void
|
||||
ajax_a_jsfuncf(tcp_queue_t *tq, const char *innerhtml, const char *fmt, ...)
|
||||
ajax_a_jsfuncf(htsbuf_queue_t *hq, const char *innerhtml, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
tcp_qprintf(tq, "<a href=\"javascript:void(0)\" onClick=\"javascript:");
|
||||
tcp_qvprintf(tq, fmt, ap);
|
||||
tcp_qprintf(tq, "\">%s</a>", innerhtml);
|
||||
htsbuf_qprintf(hq, "<a href=\"javascript:void(0)\" onClick=\"javascript:");
|
||||
htsbuf_vqprintf(hq, fmt, ap);
|
||||
htsbuf_qprintf(hq, "\">%s</a>", innerhtml);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void
|
||||
ajax_button(tcp_queue_t *tq, const char *caption, const char *code, ...)
|
||||
ajax_button(htsbuf_queue_t *hq, const char *caption, const char *code, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, code);
|
||||
|
||||
tcp_qprintf(tq, "<input type=\"button\" value=\"%s\" onClick=\"",
|
||||
htsbuf_qprintf(hq, "<input type=\"button\" value=\"%s\" onClick=\"",
|
||||
caption);
|
||||
tcp_qvprintf(tq, code, ap);
|
||||
tcp_qprintf(tq, "\">");
|
||||
htsbuf_vqprintf(hq, code, ap);
|
||||
htsbuf_qprintf(hq, "\">");
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,7 +464,7 @@ ajax_page_titlebar(http_connection_t *hc, http_reply_t *hr,
|
|||
if(remain == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
||||
ajax_menu_bar_from_array(&hr->hr_tq, "top",
|
||||
ajax_menu_bar_from_array(&hr->hr_q, "top",
|
||||
ajax_tabnames, AJAX_TABS, atoi(remain));
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -478,16 +478,16 @@ ajax_page_titlebar(http_connection_t *hc, http_reply_t *hr,
|
|||
static int
|
||||
ajax_about_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
|
||||
tcp_qprintf(tq, "<center>");
|
||||
tcp_qprintf(tq, "<div style=\"padding: auto; width: 400px\">");
|
||||
htsbuf_qprintf(hq, "<center>");
|
||||
htsbuf_qprintf(hq, "<div style=\"padding: auto; width: 400px\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "About");
|
||||
ajax_box_begin(hq, AJAX_BOX_SIDEBOX, NULL, NULL, "About");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center\">");
|
||||
htsbuf_qprintf(hq, "<div style=\"text-align: center\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<p>HTS / Tvheadend</p>"
|
||||
"<p>(c) 2006-2008 Andreas \303\226man</p>"
|
||||
"<p>Latest release and information is available at:</p>"
|
||||
|
@ -504,10 +504,10 @@ ajax_about_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
"<p><a href=\"http://www.ffmpeg.org/\">FFmpeg</a></p>"
|
||||
);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
tcp_qprintf(tq, "</div>");
|
||||
tcp_qprintf(tq, "</center>");
|
||||
htsbuf_qprintf(hq, "</div>");
|
||||
ajax_box_end(hq, AJAX_BOX_SIDEBOX);
|
||||
htsbuf_qprintf(hq, "</div>");
|
||||
htsbuf_qprintf(hq, "</center>");
|
||||
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -556,9 +556,9 @@ static int
|
|||
ajax_page_root(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n"
|
||||
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
||||
/*
|
||||
|
@ -589,13 +589,13 @@ ajax_page_root(http_connection_t *hc, http_reply_t *hr,
|
|||
"<body>");
|
||||
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(hq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: 100%\">");
|
||||
htsbuf_qprintf(hq, "<div style=\"float: left; width: 100%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL);
|
||||
ajax_box_begin(hq, AJAX_BOX_FILLED, NULL, NULL, NULL);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<div style=\"width: 100%%; overflow: hidden\">"
|
||||
"<div style=\"float: left; width: 30%%\">"
|
||||
"Tvheadend (%s)"
|
||||
|
@ -607,20 +607,20 @@ ajax_page_root(http_connection_t *hc, http_reply_t *hr,
|
|||
"</div>",
|
||||
htsversion);
|
||||
|
||||
ajax_mailbox_start(tq);
|
||||
ajax_mailbox_start(hq);
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_FILLED);
|
||||
ajax_box_end(hq, AJAX_BOX_FILLED);
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"topdeck\"></div>");
|
||||
htsbuf_qprintf(hq, "<div id=\"topdeck\"></div>");
|
||||
|
||||
ajax_js(tq, "switchtab('top', '0')");
|
||||
ajax_js(hq, "switchtab('top', '0')");
|
||||
#if 0
|
||||
tcp_qprintf(tq, "</div><div style=\"float: left; width: 20%\">");
|
||||
htsbuf_qprintf(hq, "</div><div style=\"float: left; width: 20%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, "statusbox", NULL, "System status");
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
ajax_box_begin(hq, AJAX_BOX_SIDEBOX, "statusbox", NULL, "System status");
|
||||
ajax_box_end(hq, AJAX_BOX_SIDEBOX);
|
||||
#endif
|
||||
tcp_qprintf(tq, "</div></div></body></html>");
|
||||
htsbuf_qprintf(hq, "</div></div></body></html>");
|
||||
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
|
|
@ -32,10 +32,10 @@ typedef enum {
|
|||
} ajax_box_t;
|
||||
|
||||
|
||||
void ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
|
||||
void ajax_box_begin(htsbuf_queue_t *q, ajax_box_t type,
|
||||
const char *id, const char *style, const char *title);
|
||||
|
||||
void ajax_box_end(tcp_queue_t *tq, ajax_box_t type);
|
||||
void ajax_box_end(htsbuf_queue_t *q, ajax_box_t type);
|
||||
|
||||
|
||||
|
||||
|
@ -47,11 +47,11 @@ typedef struct {
|
|||
const char *rowid;
|
||||
|
||||
int csize[20];
|
||||
tcp_queue_t *tq;
|
||||
htsbuf_queue_t *hq;
|
||||
int rowcol;
|
||||
} ajax_table_t;
|
||||
|
||||
void ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq,
|
||||
void ajax_table_top(ajax_table_t *t, http_connection_t *hc, htsbuf_queue_t *q,
|
||||
const char *names[], int weights[]);
|
||||
void ajax_table_row_start(ajax_table_t *t, const char *id);
|
||||
void ajax_table_cell(ajax_table_t *t, const char *id, const char *fmt, ...);
|
||||
|
@ -66,7 +66,7 @@ void ajax_table_subrow_end(ajax_table_t *t);
|
|||
|
||||
|
||||
|
||||
void ajax_js(tcp_queue_t *tq, const char *fmt, ...);
|
||||
void ajax_js(htsbuf_queue_t *q, const char *fmt, ...);
|
||||
|
||||
|
||||
TAILQ_HEAD(ajax_menu_entry_queue, ajax_menu_entry);
|
||||
|
@ -83,7 +83,7 @@ void ajaxui_start(void);
|
|||
void ajax_channels_init(void);
|
||||
void ajax_config_init(void);
|
||||
|
||||
void ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name,
|
||||
void ajax_menu_bar_from_array(htsbuf_queue_t *q, const char *name,
|
||||
const char **vec, int num, int cur);
|
||||
|
||||
int ajax_channelgroup_tab(http_connection_t *hc, http_reply_t *hr);
|
||||
|
@ -106,18 +106,19 @@ void ajax_config_cwc_init(void);
|
|||
|
||||
void ajax_config_transport_init(void);
|
||||
|
||||
int ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq,
|
||||
int ajax_transport_build_list(http_connection_t *hc, htsbuf_queue_t *q,
|
||||
struct th_transport_tree *tlist,
|
||||
int ntransports);
|
||||
|
||||
const char *ajaxui_escape_apostrophe(const char *content);
|
||||
void ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
|
||||
void ajax_generate_select_functions(htsbuf_queue_t *q, const char *fprefix,
|
||||
char **selvector);
|
||||
|
||||
void ajax_a_jsfuncf(tcp_queue_t *tq, const char *innerhtml,
|
||||
void ajax_a_jsfuncf(htsbuf_queue_t *q, const char *innerhtml,
|
||||
const char *fmt, ...);
|
||||
|
||||
void ajax_button(tcp_queue_t *tq, const char *caption, const char *code, ...);
|
||||
void ajax_button(htsbuf_queue_t *q,
|
||||
const char *caption, const char *code, ...);
|
||||
|
||||
void ajax_transport_build_mapper_state(char *buf, size_t siz,
|
||||
th_transport_t *t, int mapped);
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
#include "epg.h"
|
||||
|
||||
static void
|
||||
ajax_channelgroupmenu_content(tcp_queue_t *tq, int current)
|
||||
ajax_channelgroupmenu_content(htsbuf_queue_t *tq, int current)
|
||||
{
|
||||
channel_group_t *tcg;
|
||||
|
||||
tcp_qprintf(tq, "<ul class=\"menubar\">");
|
||||
htsbuf_qprintf(tq, "<ul class=\"menubar\">");
|
||||
|
||||
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
|
||||
if(tcg->tcg_hidden)
|
||||
|
@ -48,14 +48,14 @@ ajax_channelgroupmenu_content(tcp_queue_t *tq, int current)
|
|||
if(current < 1)
|
||||
current = tcg->tcg_tag;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<li%s>"
|
||||
"<a href=\"javascript:switchtab('channelgroup', '%d')\">%s</a>"
|
||||
"</li>",
|
||||
current == tcg->tcg_tag ? " style=\"font-weight:bold;\"" : "",
|
||||
tcg->tcg_tag, tcg->tcg_name);
|
||||
}
|
||||
tcp_qprintf(tq, "</ul>");
|
||||
htsbuf_qprintf(tq, "</ul>");
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ static int
|
|||
ajax_channelgroup_menu(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(remain == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
@ -78,36 +78,36 @@ ajax_channelgroup_menu(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
|
||||
static void
|
||||
ajax_output_event(tcp_queue_t *tq, event_t *e, int flags, int color)
|
||||
ajax_output_event(htsbuf_queue_t *tq, event_t *e, int flags, int color)
|
||||
{
|
||||
struct tm a, b;
|
||||
time_t stop;
|
||||
|
||||
tcp_qprintf(tq, "<div class=\"fullrow\"%s>",
|
||||
htsbuf_qprintf(tq, "<div class=\"fullrow\"%s>",
|
||||
color ? "style=\"background: #fff\" " : "");
|
||||
|
||||
localtime_r(&e->e_start, &a);
|
||||
stop = e->e_start + e->e_duration;
|
||||
localtime_r(&stop, &b);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"compact\" style=\"width: 35%%\">"
|
||||
"%02d:%02d-%02d:%02d"
|
||||
"</div>",
|
||||
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"compact\" style=\"width: 65%%\">"
|
||||
"%s"
|
||||
"</div>",
|
||||
e->e_title);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ajax_list_events(tcp_queue_t *tq, channel_t *ch, int lines)
|
||||
ajax_list_events(htsbuf_queue_t *tq, channel_t *ch, int lines)
|
||||
{
|
||||
event_t *e;
|
||||
int i;
|
||||
|
@ -131,7 +131,7 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
channel_group_t *tcg;
|
||||
char dispname[20];
|
||||
|
@ -147,7 +147,7 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
nchs++;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float:left; width: 25%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float:left; width: 25%%\">");
|
||||
|
||||
snprintf(dispname, sizeof(dispname), "%s", ch->ch_name);
|
||||
strcpy(dispname + sizeof(dispname) - 4, "...");
|
||||
|
@ -156,43 +156,43 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
/* inner */
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"width: 100%%; overflow: hidden; height:36px\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"float: left; height:32px; width:32px; "
|
||||
"margin: 2px\">");
|
||||
|
||||
if(ch->ch_icon != NULL) {
|
||||
tcp_qprintf(tq, "<img src=\"%s\" style=\"width:32px\">",
|
||||
htsbuf_qprintf(tq, "<img src=\"%s\" style=\"width:32px\">",
|
||||
ch->ch_icon);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float:left; text-align: right\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float:left; text-align: right\">");
|
||||
|
||||
si = (struct sockaddr_in *)&hc->hc_tcp_session.tcp_self_addr;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<a href=\"rtsp://%s:%d/%s\">Stream</a>",
|
||||
inet_ntoa(si->sin_addr), ntohs(si->sin_port),
|
||||
ch->ch_sname);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"events%d\" style=\"height:42px\">", ch->ch_tag);
|
||||
htsbuf_qprintf(tq, "<div id=\"events%d\" style=\"height:42px\">", ch->ch_tag);
|
||||
ajax_list_events(tq, ch, 3);
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
}
|
||||
|
||||
if(nchs == 0)
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
|
||||
"No channels in this group</div>");
|
||||
|
||||
http_output_html(hc, hr);
|
||||
|
@ -211,14 +211,14 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
|
|||
int
|
||||
ajax_channelgroup_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_FILLED, "channelgroupmenu", NULL, NULL);
|
||||
ajax_box_end(tq, AJAX_BOX_FILLED);
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"channelgroupdeck\"></div>");
|
||||
htsbuf_qprintf(tq, "<div id=\"channelgroupdeck\"></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<script type=\"text/javascript\">"
|
||||
"switchtab('channelgroup', '0')"
|
||||
"</script>");
|
||||
|
|
|
@ -52,7 +52,7 @@ static int
|
|||
ajax_config_menu(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(remain == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
@ -109,18 +109,18 @@ ajax_config_dispatch(http_connection_t *hc, http_reply_t *hr,
|
|||
int
|
||||
ajax_config_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_FILLED, "configmenu", NULL, NULL);
|
||||
ajax_box_end(tq, AJAX_BOX_FILLED);
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"configdeck\"></div>");
|
||||
htsbuf_qprintf(tq, "<div id=\"configdeck\"></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<script type=\"text/javascript\">"
|
||||
"switchtab('config', '0')"
|
||||
"</script>");
|
||||
|
||||
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -51,26 +51,26 @@ static struct strtab accesstypetab[] = {
|
|||
int
|
||||
ajax_config_access_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(access_verify(hc->hc_username, hc->hc_password,
|
||||
(struct sockaddr *)&hc->hc_tcp_session.tcp_peer_addr,
|
||||
AJAX_ACCESS_ACCESSCTRL))
|
||||
return HTTP_STATUS_UNAUTHORIZED;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Access control");
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"alist\"></div>");
|
||||
htsbuf_qprintf(tq, "<div id=\"alist\"></div>");
|
||||
|
||||
ajax_js(tq,
|
||||
"new Ajax.Updater('alist', '/ajax/accesslist', "
|
||||
"{method: 'get', evalScripts: true});");
|
||||
|
||||
tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"height: 20px;\">"
|
||||
"<div style=\"float: left; margin-right: 4px\">"
|
||||
"<input type=\"text\" id=\"newuser\">"
|
||||
|
@ -80,11 +80,11 @@ ajax_config_access_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
"</div>"
|
||||
"</div>");
|
||||
|
||||
tcp_qprintf(tq, "</div>\r\n");
|
||||
htsbuf_qprintf(tq, "</div>\r\n");
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ static int
|
|||
ajax_accesslist(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
access_entry_t *ae;
|
||||
ajax_table_t ta;
|
||||
char id[100];
|
||||
|
@ -173,23 +173,23 @@ static int
|
|||
ajax_accessadd(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
access_entry_t *ae;
|
||||
const char *t;
|
||||
|
||||
if((t = http_arg_get(&hc->hc_req_args, "name")) == NULL)
|
||||
return HTTP_STATUS_BAD_REQUEST;
|
||||
|
||||
tcp_qprintf(tq, "$('newuser').clear();\r\n");
|
||||
htsbuf_qprintf(tq, "$('newuser').clear();\r\n");
|
||||
|
||||
if(t == NULL || strlen(t) < 1 || strchr(t, '\'') || strchr(t, '"')) {
|
||||
tcp_qprintf(tq, "alert('Invalid username');\r\n");
|
||||
htsbuf_qprintf(tq, "alert('Invalid username');\r\n");
|
||||
} else {
|
||||
ae = access_add(t);
|
||||
if(ae == NULL) {
|
||||
tcp_qprintf(tq, "alert('Invalid prefix');\r\n");
|
||||
htsbuf_qprintf(tq, "alert('Invalid prefix');\r\n");
|
||||
} else {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('alist', '/ajax/accesslist', "
|
||||
"{method: 'get', evalScripts: true});\r\n");
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ static int
|
|||
ajax_accesschange(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
// tcp_queue_t *tq = &hr->hr_tq;
|
||||
// htsbuf_queue_t *tq = &hr->hr_tq;
|
||||
access_entry_t *ae;
|
||||
const char *e, *c;
|
||||
int bit;
|
||||
|
@ -246,7 +246,7 @@ static int
|
|||
ajax_accessdel(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
access_entry_t *ae;
|
||||
const char *e;
|
||||
|
||||
|
@ -258,7 +258,7 @@ ajax_accessdel(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
access_delete(ae);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('alist', '/ajax/accesslist', "
|
||||
"{method: 'get', evalScripts: true});\r\n");
|
||||
|
||||
|
@ -275,7 +275,7 @@ static int
|
|||
ajax_accesssetpw(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
access_entry_t *ae;
|
||||
const char *e;
|
||||
|
||||
|
@ -290,7 +290,7 @@ ajax_accesssetpw(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
access_save();
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('password_%d').innerHTML= '"
|
||||
"<a href=\"javascript:void(0)\" "
|
||||
"onClick=\"makedivinput(\\'password_%d\\', "
|
||||
|
|
|
@ -34,15 +34,15 @@
|
|||
* Render a channel group widget
|
||||
*/
|
||||
static void
|
||||
ajax_chgroup_build(tcp_queue_t *tq, channel_group_t *tcg)
|
||||
ajax_chgroup_build(htsbuf_queue_t *tq, channel_group_t *tcg)
|
||||
{
|
||||
tcp_qprintf(tq, "<li id=\"chgrp_%d\">", tcg->tcg_tag);
|
||||
htsbuf_qprintf(tq, "<li id=\"chgrp_%d\">", tcg->tcg_tag);
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"float: left; width: 60%\">"
|
||||
"<a href=\"javascript:void(0)\" "
|
||||
"onClick=\"$('cheditortab').innerHTML=''; "
|
||||
|
@ -54,7 +54,7 @@ ajax_chgroup_build(tcp_queue_t *tq, channel_group_t *tcg)
|
|||
|
||||
|
||||
if(tcg != defgroup) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"float: left; width: 40%\" "
|
||||
"class=\"chgroupaction\">"
|
||||
"<a href=\"javascript:void(0)\" "
|
||||
|
@ -64,9 +64,9 @@ ajax_chgroup_build(tcp_queue_t *tq, channel_group_t *tcg)
|
|||
}
|
||||
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
ajax_box_end(tq, AJAX_BOX_BORDER);
|
||||
tcp_qprintf(tq, "</li>");
|
||||
htsbuf_qprintf(tq, "</li>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ ajax_chgroup_updateorder(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
channel_group_t *tcg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
http_arg_t *ra;
|
||||
|
||||
TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
|
||||
|
@ -91,7 +91,7 @@ ajax_chgroup_updateorder(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
channel_group_settings_write();
|
||||
|
||||
tcp_qprintf(tq, "<span id=\"updatedok\">Updated on server</span>");
|
||||
htsbuf_qprintf(tq, "<span id=\"updatedok\">Updated on server</span>");
|
||||
ajax_js(tq, "Effect.Fade('updatedok')");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -107,7 +107,7 @@ ajax_chgroup_add(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
channel_group_t *tcg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *name;
|
||||
|
||||
if((name = http_arg_get(&hc->hc_req_args, "name")) != NULL) {
|
||||
|
@ -147,7 +147,7 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
channel_group_t *tcg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *id;
|
||||
|
||||
if((id = http_arg_get(&hc->hc_req_args, "id")) == NULL)
|
||||
|
@ -156,7 +156,7 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr,
|
|||
if((tcg = channel_group_by_tag(atoi(id))) == NULL)
|
||||
return HTTP_STATUS_BAD_REQUEST;
|
||||
|
||||
tcp_qprintf(tq, "$('chgrp_%d').remove();", tcg->tcg_tag);
|
||||
htsbuf_qprintf(tq, "$('chgrp_%d').remove();", tcg->tcg_tag);
|
||||
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
|
||||
|
||||
channel_group_destroy(tcg);
|
||||
|
@ -171,18 +171,18 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr,
|
|||
int
|
||||
ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_group_t *tcg;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: 30%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width: 30%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, "channelgroups",
|
||||
NULL, "Channel groups");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"height:15px; text-align:center\" "
|
||||
htsbuf_qprintf(tq, "<div style=\"height:15px; text-align:center\" "
|
||||
"id=\"list-info\"></div>");
|
||||
|
||||
tcp_qprintf(tq, "<ul id=\"channelgrouplist\" class=\"draglist\">");
|
||||
htsbuf_qprintf(tq, "<ul id=\"channelgrouplist\" class=\"draglist\">");
|
||||
|
||||
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
|
||||
if(tcg->tcg_hidden)
|
||||
|
@ -190,7 +190,7 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
ajax_chgroup_build(tq, tcg);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</ul>");
|
||||
htsbuf_qprintf(tq, "</ul>");
|
||||
|
||||
ajax_js(tq, "Sortable.create(\"channelgrouplist\", "
|
||||
"{onUpdate:function(){updatelistonserver("
|
||||
|
@ -203,11 +203,11 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
* Add new group
|
||||
*/
|
||||
|
||||
tcp_qprintf(tq, "<hr>");
|
||||
htsbuf_qprintf(tq, "<hr>");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"height: 25px\">"
|
||||
"<div style=\"float: left\">"
|
||||
"<input type=\"text\" id=\"newchgrp\">"
|
||||
|
@ -221,13 +221,13 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
ajax_box_end(tq, AJAX_BOX_BORDER);
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div id=\"groupeditortab\" "
|
||||
"style=\"overflow: auto; float: left; width: 30%\"></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div id=\"cheditortab\" "
|
||||
"style=\"overflow: auto; float: left; width: 40%\"></div>");
|
||||
|
||||
|
@ -242,7 +242,7 @@ static int
|
|||
ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
channel_group_t *tcg, *tcg2;
|
||||
th_transport_t *t;
|
||||
|
@ -253,49 +253,49 @@ ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr,
|
|||
if(remain == NULL || (tcg = channel_group_by_tag(atoi(remain))) == NULL)
|
||||
return HTTP_STATUS_BAD_REQUEST;
|
||||
|
||||
tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
|
||||
htsbuf_qprintf(tq, "<script type=\"text/javascript\">\r\n"
|
||||
"//<![CDATA[\r\n");
|
||||
|
||||
/* Select all */
|
||||
tcp_qprintf(tq, "select_all = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_all = function() {\r\n");
|
||||
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%d').checked = true;\r\n",
|
||||
ch->ch_tag);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Select none */
|
||||
tcp_qprintf(tq, "select_none = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_none = function() {\r\n");
|
||||
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%d').checked = false;\r\n",
|
||||
ch->ch_tag);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Invert selection */
|
||||
tcp_qprintf(tq, "select_invert = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_invert = function() {\r\n");
|
||||
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%d').checked = !$('sel_%d').checked;\r\n",
|
||||
ch->ch_tag, ch->ch_tag);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Invert selection */
|
||||
tcp_qprintf(tq, "select_sources = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_sources = function() {\r\n");
|
||||
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%d').checked = %s;\r\n",
|
||||
ch->ch_tag, LIST_FIRST(&ch->ch_transports) ? "true" : "false");
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
|
||||
|
||||
/* Invoke AJAX call containing all selected elements */
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"select_do = function(op, arg1, arg2, check) {\r\n"
|
||||
"if(check == true && !confirm(\"Are you sure?\")) {return;}\r\n"
|
||||
"var h = new Hash();\r\n"
|
||||
|
@ -304,17 +304,17 @@ ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr,
|
|||
);
|
||||
|
||||
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"if($('sel_%d').checked) {h.set('%d', 'selected') }\r\n",
|
||||
ch->ch_tag, ch->ch_tag);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, " new Ajax.Request('/ajax/chop/' + op, "
|
||||
htsbuf_qprintf(tq, " new Ajax.Request('/ajax/chop/' + op, "
|
||||
"{parameters: h});\r\n");
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"\r\n//]]>\r\n"
|
||||
"</script>\r\n");
|
||||
|
||||
|
@ -345,41 +345,41 @@ ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr,
|
|||
}
|
||||
ajax_table_bottom(&ta);
|
||||
|
||||
tcp_qprintf(tq, "<hr>\r\n");
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center; "
|
||||
htsbuf_qprintf(tq, "<hr>\r\n");
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center; "
|
||||
"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq, "Select all", "select_all()");
|
||||
ajax_button(tq, "Select none", "select_none()");
|
||||
ajax_button(tq, "Invert selection", "select_invert()");
|
||||
ajax_button(tq, "Select channels with sources", "select_sources()");
|
||||
tcp_qprintf(tq, "</div>\r\n");
|
||||
htsbuf_qprintf(tq, "</div>\r\n");
|
||||
|
||||
tcp_qprintf(tq, "<hr>\r\n");
|
||||
htsbuf_qprintf(tq, "<hr>\r\n");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center; "
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center; "
|
||||
"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq,
|
||||
"Delete all selected...",
|
||||
"select_do('delete', '%d', 0, true);", tcg->tcg_tag);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<select id=\"movetarget\" "
|
||||
"onChange=\"select_do('changegroup', "
|
||||
"$('movetarget').value, '%d', false)\">", tcg->tcg_tag);
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<option value="">Move selected channels to group:</option>");
|
||||
|
||||
TAILQ_FOREACH(tcg2, &all_channel_groups, tcg_global_link) {
|
||||
if(tcg2->tcg_hidden || tcg == tcg2)
|
||||
continue;
|
||||
tcp_qprintf(tq, "<option value=\"%d\">%s</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"%d\">%s</option>",
|
||||
tcg2->tcg_tag, tcg2->tcg_name);
|
||||
}
|
||||
tcp_qprintf(tq, "</select></div>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</select></div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
|
||||
|
||||
|
@ -412,7 +412,7 @@ static int
|
|||
ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch, *ch2;
|
||||
channel_group_t *chg;
|
||||
th_transport_t *t;
|
||||
|
@ -425,25 +425,25 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
|
|||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, ch->ch_name);
|
||||
|
||||
if(ch->ch_icon != NULL) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"width: 100%; text-align:center\">"
|
||||
"<img src=\"%s\"></div>", ch->ch_icon);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<div>Sources:</div>");
|
||||
htsbuf_qprintf(tq, "<div>Sources:</div>");
|
||||
|
||||
LIST_FOREACH(t, &ch->ch_transports, tht_ch_link) {
|
||||
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: 13%%\">%s</div>",
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width: 13%%\">%s</div>",
|
||||
val2str(t->tht_type, sourcetypetab) ?: "???");
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: 87%%\">\"%s\"%s</div>",
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width: 87%%\">\"%s\"%s</div>",
|
||||
t->tht_svcname, t->tht_scrambled ? " - (scrambled)" : "");
|
||||
s = t->tht_sourcename ? t->tht_sourcename(t) : NULL;
|
||||
|
||||
tcp_qprintf(tq, "</div><div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "</div><div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"float: left; width: 13%%\">"
|
||||
"<input %stype=\"checkbox\" class=\"nicebox\" "
|
||||
"onClick=\"new Ajax.Request('/ajax/transport_chdisable/%s', "
|
||||
|
@ -452,49 +452,49 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
|
|||
t->tht_identifier);
|
||||
|
||||
if(s != NULL)
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width: 87%%\">%s</div>",
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width: 87%%\">%s</div>",
|
||||
s);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_BORDER);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<hr>\r\n");
|
||||
htsbuf_qprintf(tq, "<hr>\r\n");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<input type=\"button\" value=\"Rename...\" "
|
||||
"onClick=\"channel_rename('%d', '%s')\">",
|
||||
ch->ch_tag, ch->ch_name);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<input type=\"button\" value=\"Delete...\" "
|
||||
"onClick=\"channel_delete('%d', '%s')\">",
|
||||
ch->ch_tag, ch->ch_name);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<select "
|
||||
"onChange=\"channel_merge('%d', this.value);\">",
|
||||
ch->ch_tag);
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"n\">Merge to channel:</option>");
|
||||
htsbuf_qprintf(tq, "<option value=\"n\">Merge to channel:</option>");
|
||||
|
||||
|
||||
TAILQ_FOREACH(chg, &all_channel_groups, tcg_global_link) {
|
||||
TAILQ_FOREACH(ch2, &chg->tcg_channels, ch_group_link) {
|
||||
if(ch2 != ch)
|
||||
tcp_qprintf(tq, "<option value=\"%d\">%s</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"%d\">%s</option>",
|
||||
ch2->ch_tag, ch2->ch_name);
|
||||
}
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</select>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
tcp_qprintf(tq, "<hr>\r\n");
|
||||
htsbuf_qprintf(tq, "</select>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "<hr>\r\n");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"infoprefixwidewidefat\">"
|
||||
"Commercial detection:</div>"
|
||||
"<div>"
|
||||
|
@ -504,13 +504,13 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
|
|||
ch->ch_tag);
|
||||
|
||||
for(i = 0; i < sizeof(cdlongname) / sizeof(cdlongname[0]); i++) {
|
||||
tcp_qprintf(tq, "<option %svalue=%d>%s</option>",
|
||||
htsbuf_qprintf(tq, "<option %svalue=%d>%s</option>",
|
||||
cdlongname[i].val == ch->ch_commercial_detection ?
|
||||
"selected " : "",
|
||||
cdlongname[i].val, cdlongname[i].str);
|
||||
}
|
||||
tcp_qprintf(tq, "</select></div>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</select></div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
|
@ -525,7 +525,7 @@ static int
|
|||
ajax_changegroup(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
channel_group_t *tcg;
|
||||
http_arg_t *ra;
|
||||
|
@ -550,7 +550,7 @@ ajax_changegroup(http_connection_t *hc, http_reply_t *hr,
|
|||
channel_set_group(ch, tcg);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('cheditortab').innerHTML=''; "
|
||||
"new Ajax.Updater('groupeditortab', "
|
||||
"'/ajax/chgroup_editor/%s', "
|
||||
|
@ -591,7 +591,7 @@ static int
|
|||
ajax_chrename(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
const char *s;
|
||||
|
||||
|
@ -602,15 +602,15 @@ ajax_chrename(http_connection_t *hc, http_reply_t *hr,
|
|||
return HTTP_STATUS_BAD_REQUEST;
|
||||
|
||||
if(channel_rename(ch, s)) {
|
||||
tcp_qprintf(tq, "alert('Channel already exist');");
|
||||
htsbuf_qprintf(tq, "alert('Channel already exist');");
|
||||
} else {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('groupeditortab', "
|
||||
"'/ajax/chgroup_editor/%d', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
ch->ch_group->tcg_tag);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('cheditortab', "
|
||||
"'/ajax/cheditor/%d', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
|
@ -629,7 +629,7 @@ static int
|
|||
ajax_chdelete(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
channel_group_t *tcg;
|
||||
|
||||
|
@ -640,13 +640,13 @@ ajax_chdelete(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
channel_delete(ch);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('groupeditortab', "
|
||||
"'/ajax/chgroup_editor/%d', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
tcg->tcg_tag);
|
||||
|
||||
tcp_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
|
||||
htsbuf_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
|
||||
|
||||
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
|
||||
return 0;
|
||||
|
@ -659,7 +659,7 @@ static int
|
|||
ajax_chmerge(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *src, *dst;
|
||||
channel_group_t *tcg;
|
||||
const char *s;
|
||||
|
@ -676,13 +676,13 @@ ajax_chmerge(http_connection_t *hc, http_reply_t *hr,
|
|||
tcg = src->ch_group;
|
||||
channel_merge(dst, src);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('groupeditortab', "
|
||||
"'/ajax/chgroup_editor/%d', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
tcg->tcg_tag);
|
||||
|
||||
tcp_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
|
||||
htsbuf_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
|
||||
|
||||
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
|
||||
return 0;
|
||||
|
@ -695,7 +695,7 @@ static int
|
|||
ajax_chdeletemulti(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
channel_t *ch;
|
||||
http_arg_t *ra;
|
||||
const char *curgrp;
|
||||
|
@ -711,7 +711,7 @@ ajax_chdeletemulti(http_connection_t *hc, http_reply_t *hr,
|
|||
channel_delete(ch);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('cheditortab').innerHTML=''; "
|
||||
"new Ajax.Updater('groupeditortab', "
|
||||
"'/ajax/chgroup_editor/%s', "
|
||||
|
|
|
@ -35,26 +35,26 @@
|
|||
int
|
||||
ajax_config_cwc_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *q = &hr->hr_q;
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Code-word Client");
|
||||
ajax_box_begin(q, AJAX_BOX_SIDEBOX, NULL, NULL, "Code-word Client");
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"cwclist\"></div>");
|
||||
htsbuf_qprintf(q, "<div id=\"cwclist\"></div>");
|
||||
|
||||
ajax_js(tq,
|
||||
ajax_js(q,
|
||||
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
|
||||
"{method: 'get', evalScripts: true});");
|
||||
|
||||
tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(q, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<div class=\"cell_100\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Hostname:</div>"
|
||||
"<div>"
|
||||
"<input type=\"text\" size=40 id=\"hostname\">"
|
||||
"</div></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<div class=\"cell_100\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Port:</div>"
|
||||
"<div>"
|
||||
|
@ -62,28 +62,28 @@ ajax_config_cwc_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
"</div></div>");
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<div class=\"cell_100\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Username:</div>"
|
||||
"<div>"
|
||||
"<input type=\"text\" id=\"username\">"
|
||||
"</div></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<div class=\"cell_100\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Password:</div>"
|
||||
"<div>"
|
||||
"<input type=\"password\" id=\"password\">"
|
||||
"</div></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<div class=\"cell_100\">"
|
||||
"<div class=\"infoprefixwidewidefat\">DES-key:</div>"
|
||||
"<div>"
|
||||
"<input type=\"text\" size=50 id=\"deskey\">"
|
||||
"</div></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"<br>"
|
||||
"<input type=\"button\" value=\"Add new server entry\" "
|
||||
"onClick=\"new Ajax.Request('/ajax/cwcadd', "
|
||||
|
@ -96,11 +96,11 @@ ajax_config_cwc_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
"}})"
|
||||
"\">");
|
||||
|
||||
tcp_qprintf(tq, "</div>\r\n");
|
||||
htsbuf_qprintf(q, "</div>\r\n");
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
ajax_box_end(q, AJAX_BOX_SIDEBOX);
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(q, "</div>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ static int
|
|||
ajax_cwclist(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *q = &hr->hr_q;
|
||||
ajax_table_t ta;
|
||||
cwc_t *cwc;
|
||||
char id[20];
|
||||
|
||||
ajax_table_top(&ta, hc, tq,
|
||||
ajax_table_top(&ta, hc, q,
|
||||
(const char *[]){"Code-word Server",
|
||||
"Username",
|
||||
"Enabled",
|
||||
|
@ -166,7 +166,7 @@ static int
|
|||
ajax_cwcadd(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *q = &hr->hr_q;
|
||||
const char *errtxt;
|
||||
|
||||
errtxt = cwc_add(http_arg_get(&hc->hc_req_args, "hostname"),
|
||||
|
@ -177,15 +177,15 @@ ajax_cwcadd(http_connection_t *hc, http_reply_t *hr,
|
|||
"1", 1, 1);
|
||||
|
||||
if(errtxt != NULL) {
|
||||
tcp_qprintf(tq, "alert('%s');", errtxt);
|
||||
htsbuf_qprintf(q, "alert('%s');", errtxt);
|
||||
} else {
|
||||
|
||||
tcp_qprintf(tq, "$('hostname').clear();\r\n");
|
||||
tcp_qprintf(tq, "$('port').clear();\r\n");
|
||||
tcp_qprintf(tq, "$('username').clear();\r\n");
|
||||
tcp_qprintf(tq, "$('password').clear();\r\n");
|
||||
tcp_qprintf(tq, "$('deskey').clear();\r\n");
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q, "$('hostname').clear();\r\n");
|
||||
htsbuf_qprintf(q, "$('port').clear();\r\n");
|
||||
htsbuf_qprintf(q, "$('username').clear();\r\n");
|
||||
htsbuf_qprintf(q, "$('password').clear();\r\n");
|
||||
htsbuf_qprintf(q, "$('deskey').clear();\r\n");
|
||||
htsbuf_qprintf(q,
|
||||
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
|
||||
"{method: 'get', evalScripts: true});");
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ static int
|
|||
ajax_cwcdel(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *q = &hr->hr_q;
|
||||
const char *txt;
|
||||
cwc_t *cwc;
|
||||
|
||||
|
@ -213,7 +213,7 @@ ajax_cwcdel(http_connection_t *hc, http_reply_t *hr,
|
|||
return HTTP_STATUS_BAD_REQUEST;
|
||||
|
||||
cwc_delete(cwc);
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(q,
|
||||
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
|
||||
"{method: 'get', evalScripts: true});");
|
||||
|
||||
|
@ -228,7 +228,7 @@ static int
|
|||
ajax_cwcchange(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
// tcp_queue_t *tq = &hr->hr_tq;
|
||||
// htsbuf_queue_t *q = &hr->hr_q;
|
||||
const char *txt;
|
||||
cwc_t *cwc;
|
||||
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
|
||||
|
||||
static void
|
||||
add_option(tcp_queue_t *tq, int bol, const char *name)
|
||||
add_option(htsbuf_queue_t *tq, int bol, const char *name)
|
||||
{
|
||||
if(bol)
|
||||
tcp_qprintf(tq, "<option>%s</option>", name);
|
||||
htsbuf_qprintf(tq, "<option>%s</option>", name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ static int
|
|||
ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda;
|
||||
char dispname[20];
|
||||
|
||||
|
@ -108,14 +108,14 @@ ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, dispname);
|
||||
|
||||
tcp_qprintf(tq, "<div class=\"infoprefix\">Device:</div>"
|
||||
htsbuf_qprintf(tq, "<div class=\"infoprefix\">Device:</div>"
|
||||
"<div>%s</div>",
|
||||
tda->tda_rootpath ?: "<b><i>Not present</i></b>");
|
||||
tcp_qprintf(tq, "<div class=\"infoprefix\">Type:</div>"
|
||||
htsbuf_qprintf(tq, "<div class=\"infoprefix\">Type:</div>"
|
||||
"<div>%s</div>",
|
||||
dvb_adaptertype_to_str(tda->tda_type));
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center\">"
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center\">"
|
||||
"<a href=\"javascript:void(0);\" "
|
||||
"onClick=\"new Ajax.Updater('dvbadaptereditor', "
|
||||
"'/ajax/dvbadaptereditor/%s', "
|
||||
|
@ -134,20 +134,20 @@ ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
|
|||
int
|
||||
ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
if(TAILQ_FIRST(&dvb_adapters) == NULL) {
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
|
||||
"No adapters found</div>");
|
||||
}
|
||||
|
||||
|
||||
TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) {
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"summary_%s\" "
|
||||
htsbuf_qprintf(tq, "<div id=\"summary_%s\" "
|
||||
"style=\"float:left; width: 250px\"></div>",
|
||||
tda->tda_identifier);
|
||||
|
||||
|
@ -156,8 +156,8 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
tda->tda_identifier, tda->tda_identifier);
|
||||
|
||||
}
|
||||
tcp_qprintf(tq, "</div>");
|
||||
tcp_qprintf(tq, "<div id=\"dvbadaptereditor\"></div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "<div id=\"dvbadaptereditor\"></div>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ static int
|
|||
ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda, *tda2;
|
||||
const char *s;
|
||||
|
||||
|
@ -180,7 +180,7 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div id=\"adaptername_%s\" "
|
||||
"style=\"text-align: center; font-weight: bold\">%s</div>",
|
||||
tda->tda_identifier, tda->tda_displayname);
|
||||
|
@ -189,11 +189,11 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
/* Type */
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width:45%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width:45%%\">");
|
||||
|
||||
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Model:</div>"
|
||||
htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Model:</div>"
|
||||
"<div>%s (%s)</div>",
|
||||
tda->tda_fe_info ? tda->tda_fe_info->name : "<Unknown>",
|
||||
dvb_adaptertype_to_str(tda->tda_type));
|
||||
|
@ -203,7 +203,7 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
|||
if(tda->tda_fe_info != NULL) {
|
||||
|
||||
s = tda->tda_type == FE_QPSK ? "kHz" : "Hz";
|
||||
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
|
||||
htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
|
||||
"<div>%s - %s %s, in steps of %s %s</div>",
|
||||
nicenum(tda->tda_fe_info->frequency_min),
|
||||
nicenum(tda->tda_fe_info->frequency_max),
|
||||
|
@ -213,70 +213,70 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
|
||||
if(tda->tda_fe_info->symbol_rate_min) {
|
||||
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
|
||||
htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
|
||||
"<div>%s - %s Baud</div>",
|
||||
nicenum(tda->tda_fe_info->symbol_rate_min),
|
||||
nicenum(tda->tda_fe_info->symbol_rate_max));
|
||||
}
|
||||
/* Capabilities */
|
||||
// tcp_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
|
||||
// htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width:55%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width:55%%\">");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<input type=\"button\" value=\"Rename adapter...\" "
|
||||
"onClick=\"dvb_adapter_rename('%s', '%s');\">",
|
||||
tda->tda_identifier, tda->tda_displayname);
|
||||
|
||||
if(tda->tda_rootpath == NULL) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<input type=\"button\" value=\"Delete adapter...\" "
|
||||
"onClick=\"dvb_adapter_delete('%s', '%s');\">",
|
||||
tda->tda_identifier, tda->tda_displayname);
|
||||
}
|
||||
|
||||
// tcp_qprintf(tq, "</div>");
|
||||
// htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
/* Clone adapter */
|
||||
|
||||
// tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
tcp_qprintf(tq,
|
||||
// htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
|
||||
htsbuf_qprintf(tq,
|
||||
"<select "
|
||||
"onChange=\"new Ajax.Request('/ajax/dvbadapterclone/%s', "
|
||||
"{parameters: { source: this.value }})\">",
|
||||
tda->tda_identifier);
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"n\">Clone settings from adapter:</option>");
|
||||
htsbuf_qprintf(tq, "<option value=\"n\">Clone settings from adapter:</option>");
|
||||
|
||||
TAILQ_FOREACH(tda2, &dvb_adapters, tda_global_link) {
|
||||
if(tda2 == tda || tda2->tda_type != tda->tda_type)
|
||||
continue;
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"%s\">%s (%s)</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"%s\">%s (%s)</option>",
|
||||
tda2->tda_identifier, tda2->tda_displayname,
|
||||
tda2->tda_rootpath ?: "not present");
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</select></div>");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</select></div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
/* Muxes and transports */
|
||||
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width:45%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width:45%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"dvbmuxlist_%s\"></div>",
|
||||
htsbuf_qprintf(tq, "<div id=\"dvbmuxlist_%s\"></div>",
|
||||
tda->tda_identifier);
|
||||
|
||||
ajax_js(tq,
|
||||
|
@ -285,12 +285,12 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
|
|||
tda->tda_identifier, tda->tda_identifier);
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
/* Div for displaying services */
|
||||
|
||||
tcp_qprintf(tq, "<div id=\"servicepane\" style=\"float: left; width:55%\">");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "<div id=\"servicepane\" style=\"float: left; width:55%\">");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -304,7 +304,7 @@ static int
|
|||
ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda;
|
||||
int caps;
|
||||
int fetype;
|
||||
|
@ -329,11 +329,11 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
/* Manual configuration */
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"text-align: center; font-weight: bold\">"
|
||||
"Manual configuartion</div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Frequency (%s):</div>"
|
||||
"<div>"
|
||||
|
@ -348,7 +348,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
if(fetype == FE_QAM || fetype == FE_QPSK) {
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Symbolrate:</div>"
|
||||
"<div>"
|
||||
|
@ -362,7 +362,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
/* Bandwidth */
|
||||
|
||||
if(fetype == FE_OFDM) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Bandwidth:</div>"
|
||||
"<div><select id=\"bw\">");
|
||||
|
@ -371,7 +371,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, 1 , "8MHz");
|
||||
add_option(tq, 1 , "7MHz");
|
||||
add_option(tq, 1 , "6MHz");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", bw: $F('bw')");
|
||||
|
@ -382,7 +382,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
|
||||
if(fetype == FE_QAM || fetype == FE_OFDM) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Constellation:</div>"
|
||||
"<div><select id=\"const\">");
|
||||
|
@ -395,7 +395,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, caps & FE_CAN_QAM_128, "QAM128");
|
||||
add_option(tq, caps & FE_CAN_QAM_256, "QAM256");
|
||||
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", const: $F('const')");
|
||||
|
@ -405,7 +405,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
/* FEC */
|
||||
|
||||
if(fetype == FE_QAM || fetype == FE_QPSK) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">FEC:</div>"
|
||||
"<div><select id=\"fec\">");
|
||||
|
@ -419,21 +419,21 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
|
||||
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
|
||||
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", fec: $F('fec')");
|
||||
}
|
||||
|
||||
if(fetype == FE_QPSK) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Polarisation:</div>"
|
||||
"<div><select id=\"pol\">");
|
||||
|
||||
add_option(tq, 1, "Vertical");
|
||||
add_option(tq, 1, "Horizontal");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", pol: $F('pol')");
|
||||
|
@ -443,7 +443,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
|
||||
if(fetype == FE_OFDM) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Transmission mode:</div>"
|
||||
"<div><select id=\"tmode\">");
|
||||
|
@ -451,12 +451,12 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, caps & FE_CAN_TRANSMISSION_MODE_AUTO, "AUTO");
|
||||
add_option(tq, 1 , "2k");
|
||||
add_option(tq, 1 , "8k");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", tmode: $F('tmode')");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Guard interval:</div>"
|
||||
"<div><select id=\"guard\">");
|
||||
|
@ -466,14 +466,14 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, 1 , "1/16");
|
||||
add_option(tq, 1 , "1/8");
|
||||
add_option(tq, 1 , "1/4");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", guard: $F('guard')");
|
||||
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">Hierarchy:</div>"
|
||||
"<div><select id=\"hier\">");
|
||||
|
@ -483,7 +483,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, 1 , "2");
|
||||
add_option(tq, 1 , "4");
|
||||
add_option(tq, 1 , "NONE");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
|
@ -491,7 +491,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">FEC Hi:</div>"
|
||||
"<div><select id=\"fechi\">");
|
||||
|
@ -505,13 +505,13 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
|
||||
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
|
||||
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", fechi: $F('fechi')");
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_50\">"
|
||||
"<div class=\"infoprefixwidewidefat\">FEC Low:</div>"
|
||||
"<div><select id=\"feclo\">");
|
||||
|
@ -525,13 +525,13 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
|
||||
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
|
||||
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
|
||||
tcp_qprintf(tq, "</select></div></div>");
|
||||
htsbuf_qprintf(tq, "</select></div></div>");
|
||||
|
||||
snprintf(params + strlen(params), sizeof(params) - strlen(params),
|
||||
", feclo: $F('feclo')");
|
||||
}
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<br>"
|
||||
"<div style=\"text-align: center\">"
|
||||
"<input type=\"button\" value=\"Add manually configured mux\" "
|
||||
|
@ -544,33 +544,33 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
|
|||
* Preconfigured
|
||||
*/
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<hr>"
|
||||
"<div style=\"text-align: center; font-weight: bold\">"
|
||||
"Preconfigured network</div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"text-align: center\">"
|
||||
"<select id=\"network\" "
|
||||
"onChange=\"new Ajax.Updater('networkinfo', "
|
||||
"'/ajax/dvbnetworkinfo/' + this.value)\""
|
||||
">");
|
||||
|
||||
tcp_qprintf(tq, "<option>Select a network</option>");
|
||||
htsbuf_qprintf(tq, "<option>Select a network</option>");
|
||||
|
||||
n = 0;
|
||||
while((type = dvb_mux_preconf_get(n, &networkname, NULL)) >= 0) {
|
||||
|
||||
if(type == fetype)
|
||||
tcp_qprintf(tq, "<option value=%d>%s</option>", n, networkname);
|
||||
htsbuf_qprintf(tq, "<option value=%d>%s</option>", n, networkname);
|
||||
n++;
|
||||
}
|
||||
tcp_qprintf(tq, "</select></div>");
|
||||
htsbuf_qprintf(tq, "</select></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"cell_100_center\" id=\"networkinfo\"></div>");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<br>"
|
||||
"<div style=\"text-align: center\">"
|
||||
"<input type=\"button\" value=\"Add preconfigured network\" "
|
||||
|
@ -594,7 +594,7 @@ static int
|
|||
ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq;
|
||||
htsbuf_queue_t *tq;
|
||||
th_dvb_adapter_t *tda;
|
||||
const char *v;
|
||||
|
||||
|
@ -618,15 +618,15 @@ ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr,
|
|||
http_arg_get(&hc->hc_req_args, "port"), 1);
|
||||
|
||||
|
||||
tq = &hr->hr_tq;
|
||||
tq = &hr->hr_q;
|
||||
|
||||
if(v != NULL)
|
||||
tcp_qprintf(tq, "alert('%s');\r\n", v);
|
||||
htsbuf_qprintf(tq, "alert('%s');\r\n", v);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('servicepane').innerHTML='';\r\n");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('dvbmuxlist_%s', "
|
||||
"'/ajax/dvbadaptermuxlist/%s', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
|
@ -646,7 +646,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
ajax_table_t ta;
|
||||
th_dvb_mux_instance_t *tdmi;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda;
|
||||
char buf[200];
|
||||
int fetype, n, m;
|
||||
|
@ -664,7 +664,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
|
|||
nmuxes = tda->tda_muxes.entries;
|
||||
|
||||
if(nmuxes == 0) {
|
||||
tcp_qprintf(tq, "<div style=\"text-align: center\">"
|
||||
htsbuf_qprintf(tq, "<div style=\"text-align: center\">"
|
||||
"No muxes configured</div>");
|
||||
} else {
|
||||
|
||||
|
@ -724,24 +724,24 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
ajax_table_bottom(&ta);
|
||||
|
||||
tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq, "Select all", "mux_sel_all()");
|
||||
ajax_button(tq, "Select none", "mux_sel_none()");
|
||||
ajax_button(tq, "Delete selected...",
|
||||
"mux_sel_do('dvbadapterdelmux/%s', '', '', true)",
|
||||
tda->tda_identifier);
|
||||
tcp_qprintf(tq, "</div>\r\n");
|
||||
htsbuf_qprintf(tq, "</div>\r\n");
|
||||
}
|
||||
if(tda->tda_fe_info != NULL) {
|
||||
tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq, "Add new mux...",
|
||||
"new Ajax.Updater('servicepane', "
|
||||
"'/ajax/dvbadapteraddmux/%s', "
|
||||
"{method: 'get', evalScripts: true})\"",
|
||||
tda->tda_identifier);
|
||||
tcp_qprintf(tq, "</div>\r\n");
|
||||
htsbuf_qprintf(tq, "</div>\r\n");
|
||||
}
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -768,7 +768,7 @@ ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
th_dvb_mux_instance_t *tdmi;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
char buf[1000];
|
||||
th_transport_t *t;
|
||||
struct th_transport_tree tree;
|
||||
|
@ -805,7 +805,7 @@ ajax_dvbmuxall(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
th_dvb_adapter_t *tda;
|
||||
th_dvb_mux_instance_t *tdmi;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_transport_t *t;
|
||||
struct th_transport_tree tree;
|
||||
int n = 0;
|
||||
|
@ -845,7 +845,7 @@ ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
th_dvb_adapter_t *tda;
|
||||
th_dvb_mux_instance_t *tdmi;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
http_arg_t *ra;
|
||||
|
||||
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
|
||||
|
@ -861,7 +861,7 @@ ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr,
|
|||
dvb_mux_destroy(tdmi);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('dvbadaptereditor', "
|
||||
"'/ajax/dvbadaptereditor/%s', "
|
||||
"{method: 'get', evalScripts: true});",
|
||||
|
@ -880,7 +880,7 @@ ajax_adapterrename(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
th_dvb_adapter_t *tda;
|
||||
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *s;
|
||||
|
||||
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
|
||||
|
@ -893,11 +893,11 @@ ajax_adapterrename(http_connection_t *hc, http_reply_t *hr,
|
|||
tda->tda_displayname = strdup(s);
|
||||
dvb_tda_save(tda);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('adaptername_%s').innerHTML='%s';",
|
||||
tda->tda_identifier, tda->tda_displayname);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('summary_%s', "
|
||||
"'/ajax/dvbadaptersummary/%s', {method: 'get'})",
|
||||
tda->tda_identifier, tda->tda_identifier);
|
||||
|
@ -914,14 +914,14 @@ static int
|
|||
ajax_dvbnetworkinfo(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *s;
|
||||
|
||||
if(remain == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
||||
if(dvb_mux_preconf_get(atoi(remain), NULL, &s) >= 0)
|
||||
tcp_qprintf(tq, "%s", s);
|
||||
htsbuf_qprintf(tq, "%s", s);
|
||||
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
@ -937,7 +937,7 @@ static int
|
|||
ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *s;
|
||||
th_dvb_adapter_t *tda;
|
||||
|
||||
|
@ -951,10 +951,10 @@ ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
dvb_mux_preconf_add(tda, atoi(s));
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('servicepane').innerHTML='';\r\n");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"new Ajax.Updater('dvbmuxlist_%s', "
|
||||
"'/ajax/dvbadaptermuxlist/%s', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
|
@ -972,7 +972,7 @@ static int
|
|||
ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *src, *dst;
|
||||
const char *s;
|
||||
|
||||
|
@ -989,7 +989,7 @@ ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
dvb_tda_clone(dst, src);
|
||||
|
||||
tcp_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
|
||||
htsbuf_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
|
||||
"'/ajax/dvbadaptereditor/%s', "
|
||||
"{method: 'get', evalScripts: true});\r\n",
|
||||
dst->tda_identifier);
|
||||
|
@ -1006,15 +1006,15 @@ static int
|
|||
ajax_dvbadapterdelete(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
th_dvb_adapter_t *tda;
|
||||
|
||||
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
||||
tcp_qprintf(tq, "var o = $('summary_%s'); o.parentNode.removeChild(o);\r\n",
|
||||
htsbuf_qprintf(tq, "var o = $('summary_%s'); o.parentNode.removeChild(o);\r\n",
|
||||
tda->tda_identifier);
|
||||
tcp_qprintf(tq, "$('dvbadaptereditor').innerHTML ='';\r\n");
|
||||
htsbuf_qprintf(tq, "$('dvbadaptereditor').innerHTML ='';\r\n");
|
||||
|
||||
dvb_tda_destroy(tda);
|
||||
|
||||
|
|
|
@ -38,84 +38,84 @@
|
|||
*
|
||||
*/
|
||||
int
|
||||
ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq,
|
||||
ajax_transport_build_list(http_connection_t *hc, htsbuf_queue_t *tq,
|
||||
struct th_transport_tree *tlist, int numtransports)
|
||||
{
|
||||
th_transport_t *t;
|
||||
ajax_table_t ta;
|
||||
|
||||
tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
|
||||
htsbuf_qprintf(tq, "<script type=\"text/javascript\">\r\n"
|
||||
"//<![CDATA[\r\n");
|
||||
|
||||
/* Select all */
|
||||
tcp_qprintf(tq, "select_all = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_all = function() {\r\n");
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%s').checked = true;\r\n",
|
||||
t->tht_identifier);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Select none */
|
||||
tcp_qprintf(tq, "select_none = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_none = function() {\r\n");
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%s').checked = false;\r\n",
|
||||
t->tht_identifier);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Invert selection */
|
||||
tcp_qprintf(tq, "select_invert = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_invert = function() {\r\n");
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%s').checked = !$('sel_%s').checked;\r\n",
|
||||
t->tht_identifier, t->tht_identifier);
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Select TV transports */
|
||||
tcp_qprintf(tq, "select_tv = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_tv = function() {\r\n");
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%s').checked = %s;\r\n",
|
||||
t->tht_identifier,
|
||||
transport_is_tv(t) ? "true" : "false");
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Select unscrambled TV transports */
|
||||
tcp_qprintf(tq, "select_tv_nocrypt = function() {\r\n");
|
||||
htsbuf_qprintf(tq, "select_tv_nocrypt = function() {\r\n");
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"$('sel_%s').checked = %s;\r\n",
|
||||
t->tht_identifier,
|
||||
transport_is_tv(t) && !t->tht_scrambled ? "true" : "false");
|
||||
}
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
/* Perform the given op on all transprots */
|
||||
tcp_qprintf(tq, "selected_do = function(op) {\r\n"
|
||||
htsbuf_qprintf(tq, "selected_do = function(op) {\r\n"
|
||||
"var h = new Hash();\r\n"
|
||||
);
|
||||
|
||||
RB_FOREACH(t, tlist, tht_tmp_link) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"if($('sel_%s').checked) {h.set('%s', 'selected') }\r\n",
|
||||
t->tht_identifier, t->tht_identifier);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, " new Ajax.Request('/ajax/transport_op/' + op, "
|
||||
htsbuf_qprintf(tq, " new Ajax.Request('/ajax/transport_op/' + op, "
|
||||
"{parameters: h});\r\n");
|
||||
tcp_qprintf(tq, "}\r\n");
|
||||
htsbuf_qprintf(tq, "}\r\n");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"\r\n//]]>\r\n"
|
||||
"</script>\r\n");
|
||||
|
||||
/* Top */
|
||||
|
||||
tcp_qprintf(tq, "<form id=\"transports\">");
|
||||
htsbuf_qprintf(tq, "<form id=\"transports\">");
|
||||
|
||||
ajax_table_top(&ta, hc, tq,
|
||||
(const char *[]){"Last status", "Crypto",
|
||||
|
@ -158,22 +158,22 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq,
|
|||
|
||||
ajax_table_bottom(&ta);
|
||||
|
||||
tcp_qprintf(tq, "<hr>\r\n");
|
||||
htsbuf_qprintf(tq, "<hr>\r\n");
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq, "Select all", "select_all()");
|
||||
ajax_button(tq, "Select none", "select_none()");
|
||||
|
||||
// tcp_qprintf(tq, "</div>\r\n");
|
||||
//tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
// htsbuf_qprintf(tq, "</div>\r\n");
|
||||
//htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
ajax_button(tq, "Map selected", "selected_do('map');");
|
||||
ajax_button(tq, "Unmap selected", "selected_do('unmap');");
|
||||
ajax_button(tq, "Test and map selected", "selected_do('probe');");
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
|
||||
tcp_qprintf(tq, "</form>");
|
||||
htsbuf_qprintf(tq, "</form>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ ajax_transport_rename_channel(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
th_transport_t *t;
|
||||
const char *newname;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(remain == NULL || (t = transport_find_by_identifier(remain)) == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
@ -239,7 +239,7 @@ ajax_transport_build_mapper_state(char *buf, size_t siz, th_transport_t *t,
|
|||
*
|
||||
*/
|
||||
static void
|
||||
ajax_map_unmap_channel(th_transport_t *t, tcp_queue_t *tq, int map)
|
||||
ajax_map_unmap_channel(th_transport_t *t, htsbuf_queue_t *tq, int map)
|
||||
{
|
||||
char buf[1000];
|
||||
|
||||
|
@ -249,7 +249,7 @@ ajax_map_unmap_channel(th_transport_t *t, tcp_queue_t *tq, int map)
|
|||
transport_unmap_channel(t);
|
||||
|
||||
ajax_transport_build_mapper_state(buf, sizeof(buf), t, map);
|
||||
tcp_qprintf(tq, "%s", buf);
|
||||
htsbuf_qprintf(tq, "%s", buf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,7 +261,7 @@ ajax_transport_op(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
th_transport_t *t;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
const char *op = remain;
|
||||
http_arg_t *ra;
|
||||
|
||||
|
|
|
@ -43,23 +43,23 @@
|
|||
int
|
||||
ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
xmltv_grabber_t *xg;
|
||||
int ngrabbers = 0;
|
||||
ajax_table_t ta;
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
|
||||
|
||||
switch(xmltv_globalstatus) {
|
||||
default:
|
||||
tcp_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
|
||||
htsbuf_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
|
||||
"XMLTV subsystem is not yet fully initialized, please retry "
|
||||
"in a few seconds</p></div>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
|
||||
case XMLTVSTATUS_FIND_GRABBERS_NOT_FOUND:
|
||||
tcp_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
|
||||
htsbuf_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
|
||||
"XMLTV subsystem can not initialize</p>"
|
||||
"<p style=\"text-align: center\">"
|
||||
"Make sure that the 'tv_find_grabbers' executable is in "
|
||||
|
@ -71,7 +71,7 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
break;
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<div style=\"float: left; width:45%\">");
|
||||
htsbuf_qprintf(tq, "<div style=\"float: left; width:45%\">");
|
||||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "XMLTV grabbers");
|
||||
|
||||
|
@ -97,11 +97,11 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
|
||||
tcp_qprintf(tq, "</div>"
|
||||
htsbuf_qprintf(tq, "</div>"
|
||||
"<div id=\"grabberpane\" style=\"float: left; width:55%\">"
|
||||
"</div>");
|
||||
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,52 +110,52 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
|
|||
* Generate displaylisting
|
||||
*/
|
||||
static void
|
||||
xmltv_grabber_chlist(tcp_queue_t *tq, xmltv_grabber_t *xg)
|
||||
xmltv_grabber_chlist(htsbuf_queue_t *tq, xmltv_grabber_t *xg)
|
||||
{
|
||||
xmltv_channel_t *xc;
|
||||
channel_group_t *tcg;
|
||||
channel_t *ch;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"overflow: auto; height: 450px\">");
|
||||
|
||||
TAILQ_FOREACH(xc, &xg->xg_channels, xc_link) {
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"overflow: auto; width: 100%%\">");
|
||||
|
||||
tcp_qprintf(tq, "<div class=\"iconbackdrop\">");
|
||||
htsbuf_qprintf(tq, "<div class=\"iconbackdrop\">");
|
||||
if(xc->xc_icon_url != NULL) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<img style=\"border: 0px;\" src=\"%s\" height=62px\">",
|
||||
xc->xc_icon_url);
|
||||
} else {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div style=\"margin-top: 20px; text-align: center\">"
|
||||
"No icon</div>");
|
||||
}
|
||||
tcp_qprintf(tq, "</div>"); /* iconbackdrop */
|
||||
htsbuf_qprintf(tq, "</div>"); /* iconbackdrop */
|
||||
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"infoprefixwide\">Name:</div>"
|
||||
"<div>%s (%s)</div>", xc->xc_displayname, xc->xc_name);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"infoprefixwide\">Auto mapper:</div>"
|
||||
"<div>%s</div>", xc->xc_bestmatch ?: "(no channel)");
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<div class=\"infoprefixwidefat\">Channel:</div>"
|
||||
"<select class=\"textinput\" "
|
||||
"onChange=\"new Ajax.Request('/ajax/xmltvgrabberchmap/%s', "
|
||||
"{parameters: { xmltvch: '%s', channel: this.value }})\">",
|
||||
xg->xg_identifier, xc->xc_name);
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"auto\">Automatic mapper</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"auto\">Automatic mapper</option>",
|
||||
!xc->xc_disabled && xc->xc_channel == NULL ? " selected" : "");
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"none\"%s>No channel</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"none\"%s>No channel</option>",
|
||||
xc->xc_disabled ? " selected" : "");
|
||||
|
||||
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
|
||||
|
@ -166,16 +166,16 @@ xmltv_grabber_chlist(tcp_queue_t *tq, xmltv_grabber_t *xg)
|
|||
if(LIST_FIRST(&ch->ch_transports) == NULL)
|
||||
continue;
|
||||
|
||||
tcp_qprintf(tq, "<option value=\"%d\"%s>%s</option>",
|
||||
htsbuf_qprintf(tq, "<option value=\"%d\"%s>%s</option>",
|
||||
ch->ch_tag,
|
||||
!strcmp(ch->ch_name, xc->xc_channel ?: "")
|
||||
? " selected " : "", ch->ch_name);
|
||||
}
|
||||
}
|
||||
tcp_qprintf(tq, "</select>");
|
||||
tcp_qprintf(tq, "</div><hr>\r\n");
|
||||
htsbuf_qprintf(tq, "</select>");
|
||||
htsbuf_qprintf(tq, "</div><hr>\r\n");
|
||||
}
|
||||
tcp_qprintf(tq, "</div>");
|
||||
htsbuf_qprintf(tq, "</div>");
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,7 +187,7 @@ ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
xmltv_grabber_t *xg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
|
||||
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
|
||||
|
@ -195,10 +195,10 @@ ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, xg->xg_title);
|
||||
|
||||
tcp_qprintf(tq,"<div id=\"details_%s\">", xg->xg_identifier);
|
||||
htsbuf_qprintf(tq,"<div id=\"details_%s\">", xg->xg_identifier);
|
||||
|
||||
if(xg->xg_enabled == 0) {
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(tq,
|
||||
"<p>This grabber is currently not enabled, click "
|
||||
"<a href=\"javascript:void(0);\" "
|
||||
"onClick=\"new Ajax.Request('/ajax/xmltvgrabbermode/%s', "
|
||||
|
@ -207,10 +207,10 @@ ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *hr,
|
|||
} else if(xg->xg_status == XMLTV_GRAB_OK) {
|
||||
xmltv_grabber_chlist(tq, xg);
|
||||
} else {
|
||||
tcp_qprintf(tq, "<p>%s</p>", xmltv_grabber_status_long(xg));
|
||||
htsbuf_qprintf(tq, "<p>%s</p>", xmltv_grabber_status_long(xg));
|
||||
}
|
||||
|
||||
tcp_qprintf(tq,"</div>");
|
||||
htsbuf_qprintf(tq,"</div>");
|
||||
|
||||
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
|
||||
http_output_html(hc, hr);
|
||||
|
@ -227,14 +227,14 @@ ajax_xmltvgrabbermode(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
xmltv_grabber_t *xg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
||||
xmltv_grabber_enable(xg);
|
||||
|
||||
tcp_qprintf(tq,"$('details_%s').innerHTML='Please wait...';",
|
||||
htsbuf_qprintf(tq,"$('details_%s').innerHTML='Please wait...';",
|
||||
xg->xg_identifier);
|
||||
|
||||
http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
|
||||
|
@ -251,7 +251,7 @@ ajax_xmltvgrabberlist(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *remain, void *opaque)
|
||||
{
|
||||
xmltv_grabber_t *xg;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *tq = &hr->hr_q;
|
||||
|
||||
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
@ -275,7 +275,7 @@ ajax_xmltvgrabberchmap(http_connection_t *hc, http_reply_t *hr,
|
|||
const char *xmltvname;
|
||||
const char *chname;
|
||||
channel_t *ch;
|
||||
// tcp_queue_t *tq = &hr->hr_tq;
|
||||
// htsbuf_queue_t *tq = &hr->hr_tq;
|
||||
|
||||
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
|
||||
return HTTP_STATUS_NOT_FOUND;
|
||||
|
|
|
@ -155,7 +155,7 @@ ajax_mailbox_create(const char *id)
|
|||
*
|
||||
*/
|
||||
void
|
||||
ajax_mailbox_start(tcp_queue_t *tq)
|
||||
ajax_mailbox_start(htsbuf_queue_t *hq)
|
||||
{
|
||||
struct timeval tv;
|
||||
uint8_t sum[16];
|
||||
|
@ -181,7 +181,7 @@ ajax_mailbox_start(tcp_queue_t *tq)
|
|||
mbdebug("Generated mailbox %s\n", id);
|
||||
|
||||
ajax_mailbox_create(id);
|
||||
ajax_js(tq, "mailboxquery('%s')", id);
|
||||
ajax_js(hq, "mailboxquery('%s')", id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,16 +200,17 @@ ajax_mailbox_reply(ajaxui_mailbox_t *amb, http_reply_t *hr)
|
|||
mbdebug("mailbox[%s]: sending reply\n", amb->amb_boxid);
|
||||
|
||||
while((al = TAILQ_FIRST(&amb->amb_letters)) != NULL) {
|
||||
tcp_qprintf(&hr->hr_tq, "try {\r\n");
|
||||
tcp_qprintf(&hr->hr_tq, "%s%s", al->al_payload_a, al->al_payload_b ?: "");
|
||||
htsbuf_qprintf(&hr->hr_q, "try {\r\n");
|
||||
htsbuf_qprintf(&hr->hr_q, "%s%s",
|
||||
al->al_payload_a, al->al_payload_b ?: "");
|
||||
mbdebug("\t%s%s", al->al_payload_a, al->al_payload_b ?: "");
|
||||
|
||||
tcp_qprintf(&hr->hr_tq, "}\r\n"
|
||||
htsbuf_qprintf(&hr->hr_q, "}\r\n"
|
||||
"catch(err) {}\r\n");
|
||||
al_destroy(amb, al);
|
||||
}
|
||||
|
||||
tcp_qprintf(&hr->hr_tq, "mailboxquery('%s');\r\n", amb->amb_boxid);
|
||||
htsbuf_qprintf(&hr->hr_q, "mailboxquery('%s');\r\n", amb->amb_boxid);
|
||||
|
||||
http_output(hr->hr_connection, hr, "text/javascript", NULL, 0);
|
||||
amb->amb_hr = NULL;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef AJAXUI_MAILBOX_H_
|
||||
#define AJAXUI_MAILBOX_H_
|
||||
|
||||
#include "tcp.h"
|
||||
#include <libhts/htsbuf.h>
|
||||
|
||||
void ajax_mailbox_tdmi_state_change(th_dvb_mux_instance_t *tdmi);
|
||||
|
||||
|
@ -33,7 +33,7 @@ void ajax_mailbox_tdmi_services_change(th_dvb_mux_instance_t *tdmi);
|
|||
|
||||
void ajax_mailbox_tda_change(th_dvb_adapter_t *tda);
|
||||
|
||||
void ajax_mailbox_start(tcp_queue_t *tq);
|
||||
void ajax_mailbox_start(htsbuf_queue_t *hq);
|
||||
|
||||
struct xmltv_grabber;
|
||||
|
||||
|
|
2
cwc.c
2
cwc.c
|
@ -316,7 +316,7 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid)
|
|||
buf[0] = (len - 2) >> 8;
|
||||
buf[1] = len - 2;
|
||||
|
||||
tcp_send_msg(ses, &ses->tcp_q_hi, buf, len);
|
||||
tcp_send_msg(ses, 0, buf, len);
|
||||
|
||||
/* Expect a response within 4 seconds */
|
||||
dtimer_arm(&cwc->cwc_idle_timer, cwc_timeout, cwc, 4);
|
||||
|
|
11
htsp.c
11
htsp.c
|
@ -51,17 +51,18 @@ int
|
|||
htsp_send_msg(htsp_t *htsp, htsmsg_t *m, int media)
|
||||
{
|
||||
tcp_session_t *tcp = &htsp->htsp_tcp_session;
|
||||
tcp_queue_t *tq;
|
||||
htsbuf_queue_t *hq;
|
||||
void *data;
|
||||
size_t datalen;
|
||||
int hiprio = !media;
|
||||
int max, r = -1;
|
||||
|
||||
tq = media ? &tcp->tcp_q_low : &tcp->tcp_q_hi;
|
||||
|
||||
max = tq->tq_maxdepth - tq->tq_depth; /* max size we are able to enqueue */
|
||||
hq = &tcp->tcp_q[hiprio];
|
||||
|
||||
max = hq->hq_maxsize - hq->hq_size; /* max size we are able to enqueue */
|
||||
|
||||
if(htsmsg_binary_serialize(m, &data, &datalen, max) == 0)
|
||||
r = tcp_send_msg(tcp, tq, data, datalen);
|
||||
r = tcp_send_msg(tcp, hiprio, data, datalen);
|
||||
|
||||
htsmsg_destroy(m);
|
||||
return r;
|
||||
|
|
26
http.c
26
http.c
|
@ -156,7 +156,7 @@ http_destroy_reply(http_connection_t *hc, http_reply_t *hr)
|
|||
|
||||
TAILQ_REMOVE(&hc->hc_replies, hr, hr_link);
|
||||
free(hr->hr_location);
|
||||
tcp_flush_queue(&hr->hr_tq);
|
||||
htsbuf_queue_flush(&hr->hr_q);
|
||||
free(hr);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ http_send_reply(http_connection_t *hc, http_reply_t *hr)
|
|||
{
|
||||
struct tm tm0, *tm;
|
||||
time_t t;
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
int r;
|
||||
|
||||
if(hr->hr_version >= HTTP_VERSION_1_0) {
|
||||
|
@ -219,12 +219,14 @@ http_send_reply(http_connection_t *hc, http_reply_t *hr)
|
|||
"Content-Type: %s\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"\r\n",
|
||||
hr->hr_content, tq->tq_depth);
|
||||
hr->hr_content, hq->hq_size);
|
||||
}
|
||||
tcp_output_queue(&hc->hc_tcp_session, NULL, tq);
|
||||
|
||||
tcp_output_queue(&hc->hc_tcp_session, 0, hq);
|
||||
|
||||
r = !hr->hr_keep_alive;
|
||||
|
||||
|
||||
http_destroy_reply(hc, hr);
|
||||
return r;
|
||||
}
|
||||
|
@ -267,11 +269,11 @@ void
|
|||
http_error(http_connection_t *hc, http_reply_t *hr, int error)
|
||||
{
|
||||
const char *errtxt = http_rc2str(error);
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
|
||||
tcp_flush_queue(tq);
|
||||
htsbuf_queue_flush(hq);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
|
||||
"<HTML><HEAD>\r\n"
|
||||
"<TITLE>%d %s</TITLE>\r\n"
|
||||
|
@ -318,9 +320,9 @@ http_output_html(http_connection_t *hc, http_reply_t *hr)
|
|||
void
|
||||
http_redirect(http_connection_t *hc, http_reply_t *hr, const char *location)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
|
||||
"<HTML><HEAD>\r\n"
|
||||
"<TITLE>Redirect</TITLE>\r\n"
|
||||
|
@ -349,7 +351,7 @@ http_exec(http_connection_t *hc, http_path_t *hp, char *remain, int err)
|
|||
/* Insert reply in order */
|
||||
TAILQ_INSERT_TAIL(&hc->hc_replies, hr, hr_link);
|
||||
|
||||
tcp_init_queue(&hr->hr_tq, -1);
|
||||
htsbuf_queue_init(&hr->hr_q, INT32_MAX);
|
||||
hr->hr_connection = hc;
|
||||
hr->hr_version = hc->hc_version;
|
||||
hr->hr_keep_alive = hc->hc_keep_alive;
|
||||
|
@ -590,7 +592,7 @@ http_con_parse(void *aux, char *buf)
|
|||
int n, v;
|
||||
char *argv[3], *c;
|
||||
|
||||
//printf("HTTP INPUT: %s\n", buf);
|
||||
// printf("HTTP INPUT: %s\n", buf);
|
||||
|
||||
switch(hc->hc_state) {
|
||||
case HTTP_CON_WAIT_REQUEST:
|
||||
|
@ -918,7 +920,7 @@ deliver_resource(http_connection_t *hc, http_reply_t *hr,
|
|||
{
|
||||
http_resource_t *hres = opaque;
|
||||
|
||||
tcp_qput(&hr->hr_tq, hres->data, hres->len);
|
||||
htsbuf_append(&hr->hr_q, hres->data, hres->len);
|
||||
http_output(hc, hr, hres->content, hres->encoding, 15);
|
||||
return 0;
|
||||
}
|
||||
|
|
2
http.h
2
http.h
|
@ -63,7 +63,7 @@ typedef struct http_reply {
|
|||
const char *hr_encoding;
|
||||
const char *hr_content;
|
||||
|
||||
tcp_queue_t hr_tq;
|
||||
htsbuf_queue_t hr_q;
|
||||
|
||||
} http_reply_t;
|
||||
|
||||
|
|
236
tcp.c
236
tcp.c
|
@ -35,82 +35,6 @@
|
|||
|
||||
static void tcp_client_reconnect_timeout(void *aux, int64_t now);
|
||||
|
||||
|
||||
/*
|
||||
* vprintf data on a TCP queue
|
||||
*/
|
||||
void
|
||||
tcp_qvprintf(tcp_queue_t *tq, const char *fmt, va_list ap)
|
||||
{
|
||||
char buf[5000];
|
||||
void *out;
|
||||
tcp_data_t *td;
|
||||
|
||||
td = malloc(sizeof(tcp_data_t));
|
||||
td->td_offset = 0;
|
||||
|
||||
td->td_datalen = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
out = malloc(td->td_datalen);
|
||||
memcpy(out, buf, td->td_datalen);
|
||||
td->td_data = out;
|
||||
TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
|
||||
tq->tq_depth += td->td_datalen;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* printf data on a TCP queue
|
||||
*/
|
||||
void
|
||||
tcp_qprintf(tcp_queue_t *tq, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
tcp_qvprintf(tq, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Put data on a TCP queue
|
||||
*/
|
||||
void
|
||||
tcp_qput(tcp_queue_t *tq, const uint8_t *buf, size_t len)
|
||||
{
|
||||
tcp_data_t *td;
|
||||
void *out;
|
||||
|
||||
td = malloc(sizeof(tcp_data_t));
|
||||
td->td_offset = 0;
|
||||
td->td_datalen = len;
|
||||
|
||||
out = malloc(td->td_datalen);
|
||||
memcpy(out, buf, td->td_datalen);
|
||||
td->td_data = out;
|
||||
TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
|
||||
tq->tq_depth += td->td_datalen;
|
||||
}
|
||||
|
||||
/*
|
||||
* printfs data on a TCP connection
|
||||
*/
|
||||
void
|
||||
tcp_printf(tcp_session_t *ses, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[5000];
|
||||
void *out;
|
||||
int l;
|
||||
|
||||
va_start(ap, fmt);
|
||||
l = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
out = malloc(l);
|
||||
memcpy(out, buf, l);
|
||||
|
||||
tcp_send_msg(ses, &ses->tcp_q_hi, out, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read max 'n' bytes of data from line parser. Used to consume binary data
|
||||
* for mixed line / binary protocols (HTTP)
|
||||
|
@ -186,34 +110,6 @@ tcp_line_read(tcp_session_t *ses, tcp_line_input_t *callback)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create an output queue
|
||||
*/
|
||||
void
|
||||
tcp_init_queue(tcp_queue_t *tq, int maxdepth)
|
||||
{
|
||||
TAILQ_INIT(&tq->tq_messages);
|
||||
tq->tq_depth = 0;
|
||||
tq->tq_maxdepth = maxdepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flusing all pending data from a queue
|
||||
*/
|
||||
void
|
||||
tcp_flush_queue(tcp_queue_t *tq)
|
||||
{
|
||||
tcp_data_t *td;
|
||||
|
||||
while((td = TAILQ_FIRST(&tq->tq_messages)) != NULL) {
|
||||
TAILQ_REMOVE(&tq->tq_messages, td, td_link);
|
||||
free((void *)td->td_data);
|
||||
free(td);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transmit data from any of the queues
|
||||
* Select hi-pri queue first if possible, but always stick on the same
|
||||
|
@ -222,23 +118,23 @@ tcp_flush_queue(tcp_queue_t *tq)
|
|||
static void
|
||||
tcp_transmit(tcp_session_t *ses)
|
||||
{
|
||||
tcp_queue_t *q = ses->tcp_q_current;
|
||||
tcp_data_t *hd;
|
||||
htsbuf_queue_t *hq = ses->tcp_q_current;
|
||||
htsbuf_data_t *hd;
|
||||
int r;
|
||||
|
||||
again:
|
||||
if(q == NULL) {
|
||||
if(ses->tcp_q_hi.tq_depth)
|
||||
q = &ses->tcp_q_hi;
|
||||
if(ses->tcp_q_low.tq_depth)
|
||||
q = &ses->tcp_q_low;
|
||||
if(hq == NULL) {
|
||||
if(ses->tcp_q[1].hq_size)
|
||||
hq = &ses->tcp_q[1];
|
||||
else if(ses->tcp_q[0].hq_size)
|
||||
hq = &ses->tcp_q[0];
|
||||
}
|
||||
|
||||
while(q != NULL) {
|
||||
hd = TAILQ_FIRST(&q->tq_messages);
|
||||
while(hq != NULL) {
|
||||
hd = TAILQ_FIRST(&hq->hq_q);
|
||||
|
||||
r = write(ses->tcp_fd, hd->td_data + hd->td_offset,
|
||||
hd->td_datalen - hd->td_offset);
|
||||
r = write(ses->tcp_fd, hd->hd_data + hd->hd_data_off,
|
||||
hd->hd_data_len - hd->hd_data_off);
|
||||
|
||||
if(r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||
r = 0;
|
||||
|
@ -250,19 +146,17 @@ tcp_transmit(tcp_session_t *ses)
|
|||
tcp_disconnect(ses, errno);
|
||||
return;
|
||||
}
|
||||
q->tq_depth -= r;
|
||||
hd->td_offset += r;
|
||||
|
||||
if(hd->td_offset == hd->td_datalen) {
|
||||
TAILQ_REMOVE(&q->tq_messages, hd, td_link);
|
||||
free((void *)hd->td_data);
|
||||
free(hd);
|
||||
q = NULL;
|
||||
hq->hq_size -= r;
|
||||
hd->hd_data_off += r;
|
||||
|
||||
if(hd->hd_data_off == hd->hd_data_len) {
|
||||
htsbuf_data_free(hq, hd);
|
||||
hq = NULL;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
if(q == NULL) {
|
||||
if(hq == NULL) {
|
||||
if(ses->tcp_blocked) {
|
||||
dispatch_clr(ses->tcp_dispatch_handle, DISPATCH_WRITE);
|
||||
ses->tcp_blocked = 0;
|
||||
|
@ -273,7 +167,7 @@ tcp_transmit(tcp_session_t *ses)
|
|||
ses->tcp_blocked = 1;
|
||||
}
|
||||
}
|
||||
ses->tcp_q_current = q;
|
||||
ses->tcp_q_current = hq;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,25 +175,22 @@ tcp_transmit(tcp_session_t *ses)
|
|||
* being sent.
|
||||
*/
|
||||
int
|
||||
tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
|
||||
size_t len)
|
||||
tcp_send_msg(tcp_session_t *ses, int hiprio, void *data, size_t len)
|
||||
{
|
||||
tcp_data_t *td;
|
||||
htsbuf_queue_t *hq = &ses->tcp_q[!!hiprio];
|
||||
htsbuf_data_t *hd;
|
||||
|
||||
if(tq == NULL)
|
||||
tq = &ses->tcp_q_low;
|
||||
|
||||
if(len > tq->tq_maxdepth - tq->tq_depth) {
|
||||
free((void *)data);
|
||||
if(len > hq->hq_maxsize - hq->hq_size) {
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
td = malloc(sizeof(tcp_data_t));
|
||||
td->td_offset = 0;
|
||||
td->td_datalen = len;
|
||||
td->td_data = data;
|
||||
TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
|
||||
tq->tq_depth += td->td_datalen;
|
||||
hd = malloc(sizeof(htsbuf_data_t));
|
||||
hd->hd_data_off = 0;
|
||||
hd->hd_data_len = len;
|
||||
hd->hd_data = data;
|
||||
TAILQ_INSERT_TAIL(&hq->hq_q, hd, hd_link);
|
||||
hq->hq_size += len;
|
||||
|
||||
if(!ses->tcp_blocked)
|
||||
tcp_transmit(ses);
|
||||
|
@ -307,6 +198,21 @@ tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void
|
||||
tcp_printf(tcp_session_t *ses, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
htsbuf_vqprintf(&ses->tcp_q[0], fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if(!ses->tcp_blocked)
|
||||
tcp_transmit(ses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a tcp queue onto a session
|
||||
|
@ -314,47 +220,21 @@ tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
|
|||
* Coalesce smaller chunks into bigger ones for more efficient I/O
|
||||
*/
|
||||
void
|
||||
tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src)
|
||||
tcp_output_queue(tcp_session_t *ses, int hiprio, htsbuf_queue_t *src)
|
||||
{
|
||||
tcp_data_t *sd;
|
||||
tcp_data_t *dd;
|
||||
int l, s;
|
||||
htsbuf_data_t *hd;
|
||||
htsbuf_queue_t *dst = &ses->tcp_q[!!hiprio];
|
||||
|
||||
if(dst == NULL)
|
||||
dst = &ses->tcp_q_low;
|
||||
while((hd = TAILQ_FIRST(&src->hq_q)) != NULL) {
|
||||
TAILQ_REMOVE(&src->hq_q, hd, hd_link);
|
||||
TAILQ_INSERT_TAIL(&dst->hq_q, hd, hd_link);
|
||||
|
||||
while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) {
|
||||
|
||||
l = 4096;
|
||||
if(sd->td_datalen > l)
|
||||
l = sd->td_datalen;
|
||||
|
||||
dd = malloc(sizeof(tcp_data_t));
|
||||
dd->td_offset = 0;
|
||||
dd->td_data = malloc(l);
|
||||
|
||||
s = 0; /* accumulated size */
|
||||
while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) {
|
||||
|
||||
if(sd->td_datalen + s > l)
|
||||
break;
|
||||
|
||||
memcpy((char *)dd->td_data + s, sd->td_data, sd->td_datalen);
|
||||
s += sd->td_datalen;
|
||||
TAILQ_REMOVE(&src->tq_messages, sd, td_link);
|
||||
free((void *)sd->td_data);
|
||||
free(sd);
|
||||
}
|
||||
|
||||
dd->td_datalen = s;
|
||||
TAILQ_INSERT_TAIL(&dst->tq_messages, dd, td_link);
|
||||
dst->tq_depth += s;
|
||||
dst->hq_size += hd->hd_data_len;
|
||||
}
|
||||
src->hq_size = 0;
|
||||
|
||||
if(ses != NULL && !ses->tcp_blocked)
|
||||
if(!ses->tcp_blocked)
|
||||
tcp_transmit(ses);
|
||||
|
||||
src->tq_depth = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,8 +243,8 @@ tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src)
|
|||
void
|
||||
tcp_disconnect(tcp_session_t *ses, int err)
|
||||
{
|
||||
tcp_flush_queue(&ses->tcp_q_low);
|
||||
tcp_flush_queue(&ses->tcp_q_hi);
|
||||
htsbuf_queue_flush(&ses->tcp_q[0]);
|
||||
htsbuf_queue_flush(&ses->tcp_q[1]);
|
||||
|
||||
ses->tcp_callback(TCP_DISCONNECT, ses);
|
||||
|
||||
|
@ -433,8 +313,8 @@ tcp_start_session(tcp_session_t *ses)
|
|||
val = 1;
|
||||
setsockopt(ses->tcp_fd, SOL_TCP, TCP_NODELAY, &val, sizeof(val));
|
||||
|
||||
tcp_init_queue(&ses->tcp_q_hi, 20 * 1000 * 1000);
|
||||
tcp_init_queue(&ses->tcp_q_low, 20 * 1000 * 1000);
|
||||
htsbuf_queue_init(&ses->tcp_q[0], 20 * 1000 * 1000);
|
||||
htsbuf_queue_init(&ses->tcp_q[1], 20 * 1000 * 1000);
|
||||
|
||||
snprintf(ses->tcp_peer_txt, sizeof(ses->tcp_peer_txt), "%s:%d",
|
||||
inet_ntoa(si->sin_addr), ntohs(si->sin_port));
|
||||
|
|
37
tcp.h
37
tcp.h
|
@ -19,20 +19,7 @@
|
|||
#ifndef TCP_H_
|
||||
#define TCP_H_
|
||||
|
||||
TAILQ_HEAD(tcp_data_queue, tcp_data);
|
||||
|
||||
typedef struct tcp_data {
|
||||
TAILQ_ENTRY(tcp_data) td_link;
|
||||
const void *td_data;
|
||||
unsigned int td_datalen;
|
||||
int td_offset;
|
||||
} tcp_data_t;
|
||||
|
||||
typedef struct tcp_queue {
|
||||
struct tcp_data_queue tq_messages;
|
||||
int tq_depth;
|
||||
int tq_maxdepth;
|
||||
} tcp_queue_t;
|
||||
#include <libhts/htsbuf.h>
|
||||
|
||||
typedef enum {
|
||||
TCP_CONNECT,
|
||||
|
@ -74,10 +61,9 @@ typedef struct tcp_session {
|
|||
/* Output queueing */
|
||||
|
||||
int tcp_blocked;
|
||||
tcp_queue_t tcp_q_hi;
|
||||
tcp_queue_t tcp_q_low;
|
||||
htsbuf_queue_t tcp_q[2];
|
||||
|
||||
tcp_queue_t *tcp_q_current;
|
||||
htsbuf_queue_t *tcp_q_current;
|
||||
|
||||
/* Input line parser */
|
||||
|
||||
|
@ -86,10 +72,6 @@ typedef struct tcp_session {
|
|||
|
||||
} tcp_session_t;
|
||||
|
||||
void tcp_init_queue(tcp_queue_t *tq, int maxdepth);
|
||||
|
||||
void tcp_flush_queue(tcp_queue_t *tq);
|
||||
|
||||
void tcp_disconnect(tcp_session_t *ses, int err);
|
||||
|
||||
void tcp_create_server(int port, size_t session_size, const char *name,
|
||||
|
@ -101,18 +83,9 @@ int tcp_line_drain(tcp_session_t *ses, void *buf, int n);
|
|||
|
||||
#define tcp_logname(ses) ((ses)->tcp_peer_txt)
|
||||
|
||||
int tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
|
||||
size_t len);
|
||||
|
||||
void tcp_printf(tcp_session_t *ses, const char *fmt, ...);
|
||||
|
||||
void tcp_qprintf(tcp_queue_t *tq, const char *fmt, ...);
|
||||
|
||||
void tcp_qvprintf(tcp_queue_t *tq, const char *fmt, va_list ap);
|
||||
|
||||
void tcp_qput(tcp_queue_t *tq, const uint8_t *buf, size_t len);
|
||||
|
||||
void tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src);
|
||||
void tcp_output_queue(tcp_session_t *ses, int hiprio, htsbuf_queue_t *src);
|
||||
|
||||
void *tcp_create_client(const char *hostname, int port, size_t session_size,
|
||||
const char *name, tcp_callback_t *cb, int enabled);
|
||||
|
@ -121,4 +94,6 @@ void tcp_destroy_client(tcp_session_t *ses);
|
|||
|
||||
void tcp_enable_disable(tcp_session_t *ses, int enabled);
|
||||
|
||||
int tcp_send_msg(tcp_session_t *ses, int hiprio, void *data, size_t len);
|
||||
|
||||
#endif /* TCP_H_ */
|
||||
|
|
110
webui/webui.c
110
webui/webui.c
|
@ -121,7 +121,7 @@ static int
|
|||
page_simple(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
const char *s = http_arg_get(&hc->hc_req_args, "s");
|
||||
struct event_list events;
|
||||
event_t *e, **ev;
|
||||
|
@ -131,18 +131,18 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
pvr_rec_t *pvrr, **pv;
|
||||
const char *rstatus;
|
||||
|
||||
tcp_qprintf(tq, "<html>");
|
||||
tcp_qprintf(tq, "<body>");
|
||||
htsbuf_qprintf(hq, "<html>");
|
||||
htsbuf_qprintf(hq, "<body>");
|
||||
|
||||
tcp_qprintf(tq, "<form>");
|
||||
tcp_qprintf(tq, "Event: <input type=\"text\" ");
|
||||
htsbuf_qprintf(hq, "<form>");
|
||||
htsbuf_qprintf(hq, "Event: <input type=\"text\" ");
|
||||
if(s != NULL)
|
||||
tcp_qprintf(tq, "value=\"%s\" ", s);
|
||||
htsbuf_qprintf(hq, "value=\"%s\" ", s);
|
||||
|
||||
tcp_qprintf(tq, "name=\"s\">");
|
||||
tcp_qprintf(tq, "<input type=\"submit\" value=\"Search\">");
|
||||
htsbuf_qprintf(hq, "name=\"s\">");
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" value=\"Search\">");
|
||||
|
||||
tcp_qprintf(tq, "</form><hr>");
|
||||
htsbuf_qprintf(hq, "</form><hr>");
|
||||
|
||||
if(s != NULL) {
|
||||
|
||||
|
@ -150,12 +150,12 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
c = epg_search(&events, s, NULL, NULL, NULL);
|
||||
|
||||
if(c == -1) {
|
||||
tcp_qprintf(tq, "<b>Event title: Regular expression syntax error</b>");
|
||||
htsbuf_qprintf(hq, "<b>Event title: Regular expression syntax error</b>");
|
||||
} else if(c == 0) {
|
||||
tcp_qprintf(tq, "<b>No matching entries found</b>");
|
||||
htsbuf_qprintf(hq, "<b>No matching entries found</b>");
|
||||
} else {
|
||||
|
||||
tcp_qprintf(tq, "<b>%d entries found", c);
|
||||
htsbuf_qprintf(hq, "<b>%d entries found", c);
|
||||
|
||||
ev = alloca(c * sizeof(event_t *));
|
||||
c = 0;
|
||||
|
@ -166,10 +166,10 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
|
||||
if(c > 25) {
|
||||
c = 25;
|
||||
tcp_qprintf(tq, ", %d entries shown", c);
|
||||
htsbuf_qprintf(hq, ", %d entries shown", c);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</b>");
|
||||
htsbuf_qprintf(hq, "</b>");
|
||||
|
||||
memset(&day, -1, sizeof(struct tm));
|
||||
for(k = 0; k < c; k++) {
|
||||
|
@ -182,7 +182,7 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
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) {
|
||||
memcpy(&day, &a, sizeof(struct tm));
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<br><i>%s, %d/%d</i><br>",
|
||||
days[day.tm_wday], day.tm_mday, day.tm_mon + 1);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
rstatus = pvrr != NULL ? val2str(pvrr->pvrr_status,
|
||||
recstatustxt) : NULL;
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"<a href=\"/eventinfo/%d\">"
|
||||
"%02d:%02d-%02d:%02d %s%s%s</a><br>",
|
||||
e->e_tag,
|
||||
|
@ -200,17 +200,17 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
rstatus ? " " : "", rstatus ?: "");
|
||||
}
|
||||
}
|
||||
tcp_qprintf(tq, "<hr>");
|
||||
htsbuf_qprintf(hq, "<hr>");
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<b>Recorder log:</b><br>\n");
|
||||
htsbuf_qprintf(hq, "<b>Recorder log:</b><br>\n");
|
||||
|
||||
c = 0;
|
||||
LIST_FOREACH(pvrr, &pvrr_global_list, pvrr_global_link)
|
||||
c++;
|
||||
|
||||
if(c == 0) {
|
||||
tcp_qprintf(tq, "No entries<br>");
|
||||
htsbuf_qprintf(hq, "No entries<br>");
|
||||
}
|
||||
|
||||
pv = alloca(c * sizeof(pvr_rec_t *));
|
||||
|
@ -232,25 +232,25 @@ page_simple(http_connection_t *hc, http_reply_t *hr,
|
|||
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) {
|
||||
memcpy(&day, &a, sizeof(struct tm));
|
||||
tcp_qprintf(tq, "<br><i>%s, %d/%d</i><br>",
|
||||
htsbuf_qprintf(hq, "<br><i>%s, %d/%d</i><br>",
|
||||
days[day.tm_wday], day.tm_mday, day.tm_mon + 1);
|
||||
}
|
||||
|
||||
rstatus = val2str(pvrr->pvrr_status, recstatustxt);
|
||||
|
||||
|
||||
tcp_qprintf(tq, "<a href=\"/pvrinfo/%d\">", pvrr->pvrr_ref);
|
||||
htsbuf_qprintf(hq, "<a href=\"/pvrinfo/%d\">", pvrr->pvrr_ref);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"%02d:%02d-%02d:%02d %s",
|
||||
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min, pvrr->pvrr_title);
|
||||
|
||||
tcp_qprintf(tq, "</a>");
|
||||
htsbuf_qprintf(hq, "</a>");
|
||||
|
||||
tcp_qprintf(tq, "<br>(%s)<br><br>", rstatus);
|
||||
htsbuf_qprintf(hq, "<br>(%s)<br><br>", rstatus);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</body></html>");
|
||||
htsbuf_qprintf(hq, "</body></html>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static int
|
|||
page_einfo(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
event_t *e;
|
||||
struct tm a, b;
|
||||
time_t stop;
|
||||
|
@ -284,55 +284,55 @@ page_einfo(http_connection_t *hc, http_reply_t *hr,
|
|||
pvr_abort(pvrr);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<html>");
|
||||
tcp_qprintf(tq, "<body>");
|
||||
htsbuf_qprintf(hq, "<html>");
|
||||
htsbuf_qprintf(hq, "<body>");
|
||||
|
||||
localtime_r(&e->e_start, &a);
|
||||
stop = e->e_start + e->e_duration;
|
||||
localtime_r(&stop, &b);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"%s, %d/%d %02d:%02d - %02d:%02d<br>",
|
||||
days[a.tm_wday], a.tm_mday, a.tm_mon + 1,
|
||||
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
|
||||
|
||||
tcp_qprintf(tq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
|
||||
htsbuf_qprintf(hq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
|
||||
e->e_channel->ch_name, e->e_title);
|
||||
|
||||
pvrstatus = pvrr != NULL ? pvrr->pvrr_status : HTSTV_PVR_STATUS_NONE;
|
||||
|
||||
if((rstatus = val2str(pvrstatus, recstatustxt)) != NULL)
|
||||
tcp_qprintf(tq, "Recording status: %s<br>", rstatus);
|
||||
htsbuf_qprintf(hq, "Recording status: %s<br>", rstatus);
|
||||
|
||||
tcp_qprintf(tq, "<form method=\"post\" action=\"/eventinfo/%d\">", e->e_tag);
|
||||
htsbuf_qprintf(hq, "<form method=\"post\" action=\"/eventinfo/%d\">", e->e_tag);
|
||||
|
||||
switch(pvrstatus) {
|
||||
case HTSTV_PVR_STATUS_SCHEDULED:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"clear\" value=\"Remove from schedule\">");
|
||||
break;
|
||||
|
||||
case HTSTV_PVR_STATUS_RECORDING:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"cancel\" value=\"Cancel recording\">");
|
||||
break;
|
||||
|
||||
case HTSTV_PVR_STATUS_NONE:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"rec\" value=\"Record\">");
|
||||
break;
|
||||
|
||||
default:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"clear\" value=\"Clear error status\">");
|
||||
break;
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</form>");
|
||||
tcp_qprintf(tq, "%s", e->e_desc);
|
||||
htsbuf_qprintf(hq, "</form>");
|
||||
htsbuf_qprintf(hq, "%s", e->e_desc);
|
||||
|
||||
tcp_qprintf(tq, "<hr><a href=\"/simple.html\">New search</a><br>");
|
||||
tcp_qprintf(tq, "</body></html>");
|
||||
htsbuf_qprintf(hq, "<hr><a href=\"/simple.html\">New search</a><br>");
|
||||
htsbuf_qprintf(hq, "</body></html>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ static int
|
|||
page_pvrinfo(http_connection_t *hc, http_reply_t *hr,
|
||||
const char *remain, void *opaque)
|
||||
{
|
||||
tcp_queue_t *tq = &hr->hr_tq;
|
||||
htsbuf_queue_t *hq = &hr->hr_q;
|
||||
struct tm a, b;
|
||||
time_t stop;
|
||||
pvr_rec_t *pvrr = NULL;
|
||||
|
@ -364,56 +364,56 @@ page_pvrinfo(http_connection_t *hc, http_reply_t *hr,
|
|||
pvr_abort(pvrr);
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "<html>");
|
||||
tcp_qprintf(tq, "<body>");
|
||||
htsbuf_qprintf(hq, "<html>");
|
||||
htsbuf_qprintf(hq, "<body>");
|
||||
|
||||
localtime_r(&pvrr->pvrr_start, &a);
|
||||
stop = pvrr->pvrr_start + pvrr->pvrr_stop;
|
||||
localtime_r(&stop, &b);
|
||||
|
||||
tcp_qprintf(tq,
|
||||
htsbuf_qprintf(hq,
|
||||
"%s, %d/%d %02d:%02d - %02d:%02d<br>",
|
||||
days[a.tm_wday], a.tm_mday, a.tm_mon + 1,
|
||||
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
|
||||
|
||||
tcp_qprintf(tq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
|
||||
htsbuf_qprintf(hq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
|
||||
pvrr->pvrr_channel->ch_name, pvrr->pvrr_title);
|
||||
|
||||
pvrstatus = pvrr->pvrr_status;
|
||||
|
||||
if((rstatus = val2str(pvrstatus, recstatustxt)) != NULL)
|
||||
tcp_qprintf(tq, "Recording status: %s<br>", rstatus);
|
||||
htsbuf_qprintf(hq, "Recording status: %s<br>", rstatus);
|
||||
|
||||
tcp_qprintf(tq, "<form method=\"post\" action=\"/pvrinfo/%d\">",
|
||||
htsbuf_qprintf(hq, "<form method=\"post\" action=\"/pvrinfo/%d\">",
|
||||
pvrr->pvrr_ref);
|
||||
|
||||
switch(pvrstatus) {
|
||||
case HTSTV_PVR_STATUS_SCHEDULED:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"clear\" value=\"Remove from schedule\">");
|
||||
break;
|
||||
|
||||
case HTSTV_PVR_STATUS_RECORDING:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"cancel\" value=\"Cancel recording\">");
|
||||
break;
|
||||
|
||||
case HTSTV_PVR_STATUS_DONE:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"clear\" value=\"Remove from log\">");
|
||||
break;
|
||||
|
||||
default:
|
||||
tcp_qprintf(tq, "<input type=\"submit\" "
|
||||
htsbuf_qprintf(hq, "<input type=\"submit\" "
|
||||
"name=\"clear\" value=\"Clear error status\">");
|
||||
break;
|
||||
}
|
||||
|
||||
tcp_qprintf(tq, "</form>");
|
||||
tcp_qprintf(tq, "%s", pvrr->pvrr_desc);
|
||||
htsbuf_qprintf(hq, "</form>");
|
||||
htsbuf_qprintf(hq, "%s", pvrr->pvrr_desc);
|
||||
|
||||
tcp_qprintf(tq, "<hr><a href=\"/simple.html\">New search</a><br>");
|
||||
tcp_qprintf(tq, "</body></html>");
|
||||
htsbuf_qprintf(hq, "<hr><a href=\"/simple.html\">New search</a><br>");
|
||||
htsbuf_qprintf(hq, "</body></html>");
|
||||
http_output_html(hc, hr);
|
||||
return 0;
|
||||
}
|
||||
|
|
22
xbmsp.c
22
xbmsp.c
|
@ -55,7 +55,7 @@ xbmsp_output_file(void *opaque)
|
|||
tffm_fifo_t *tf = xs->xs_fifo;
|
||||
xbmsp_t *xbmsp = xs->xs_xbmsp;
|
||||
uint32_t msgid = xs->xs_pending_read_msgid;
|
||||
tcp_queue_t tq;
|
||||
htsbuf_queue_t hq;
|
||||
int rem, tlen, len = xs->xs_pending_read_size;
|
||||
uint8_t buf[13];
|
||||
tffm_fifo_pkt_t *pkt, *n;
|
||||
|
@ -79,8 +79,8 @@ xbmsp_output_file(void *opaque)
|
|||
buf[11] = len >> 8;
|
||||
buf[12] = len;
|
||||
|
||||
tcp_init_queue(&tq, -1);
|
||||
tcp_qput(&tq, buf, 13);
|
||||
htsbuf_queue_init(&hq, 0);
|
||||
htsbuf_append(&hq, buf, 13);
|
||||
|
||||
while(len > 0) {
|
||||
pkt = TAILQ_FIRST(&tf->tf_pktq);
|
||||
|
@ -88,10 +88,10 @@ xbmsp_output_file(void *opaque)
|
|||
|
||||
if(len >= pkt->tfp_pktsize) {
|
||||
/* Consume entire packet */
|
||||
tcp_qput(&tq, pkt->tfp_buf, pkt->tfp_pktsize);
|
||||
htsbuf_append(&hq, pkt->tfp_buf, pkt->tfp_pktsize);
|
||||
} else {
|
||||
/* Partial, create new packet at front with remaining data */
|
||||
tcp_qput(&tq, pkt->tfp_buf, len);
|
||||
htsbuf_append(&hq, pkt->tfp_buf, len);
|
||||
rem = pkt->tfp_pktsize - len;
|
||||
n = malloc(sizeof(tffm_fifo_pkt_t) + rem);
|
||||
n->tfp_pktsize = rem;
|
||||
|
@ -108,7 +108,7 @@ xbmsp_output_file(void *opaque)
|
|||
|
||||
xs->xs_pending_read_size = 0;
|
||||
xs->xs_pending_read_msgid = 0;
|
||||
tcp_output_queue(&xbmsp->xbmsp_tcp_session, NULL, &tq);
|
||||
tcp_output_queue(&xbmsp->xbmsp_tcp_session, 0, &hq);
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,7 +379,7 @@ xbmsp_send_msg(xbmsp_t *xbmsp, uint8_t type, uint32_t msgid,
|
|||
uint8_t *payload, int payloadlen)
|
||||
{
|
||||
uint8_t buf[9];
|
||||
tcp_queue_t tq;
|
||||
htsbuf_queue_t hq;
|
||||
|
||||
int tlen = payloadlen + 5;
|
||||
|
||||
|
@ -393,16 +393,16 @@ xbmsp_send_msg(xbmsp_t *xbmsp, uint8_t type, uint32_t msgid,
|
|||
buf[7] = msgid >> 8;
|
||||
buf[8] = msgid;
|
||||
|
||||
tcp_init_queue(&tq, -1);
|
||||
tcp_qput(&tq, buf, 9);
|
||||
htsbuf_queue_init(&hq, 0);
|
||||
htsbuf_append(&hq, buf, 9);
|
||||
if(payloadlen > 0) {
|
||||
if(payload == NULL) {
|
||||
payload = alloca(payloadlen);
|
||||
memset(payload, 0, payloadlen);
|
||||
}
|
||||
tcp_qput(&tq, payload, payloadlen);
|
||||
htsbuf_append(&hq, payload, payloadlen);
|
||||
}
|
||||
tcp_output_queue(&xbmsp->xbmsp_tcp_session, NULL, &tq);
|
||||
tcp_output_queue(&xbmsp->xbmsp_tcp_session, 0, &hq);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue