-
-#include "tvhead.h"
-#include "http.h"
-#include "ajaxui.h"
-#include "channels.h"
-#include "dvb.h"
-#include "dvb_support.h"
-#include "dvb_muxconfig.h"
-#include "psi.h"
-#include "transports.h"
-#include "dispatch.h"
-
-#include "ajaxui_mailbox.h"
-
-
-static void
-add_option(htsbuf_queue_t *tq, int bol, const char *name)
-{
- if(bol)
- htsbuf_qprintf(tq, "", name);
-}
-
-/**
- *
- */
-static const char *
-nicenum(unsigned int v)
-{
- static char buf[4][30];
- static int ptr;
- char *x;
- ptr = (ptr + 1) & 3;
- x = buf[ptr];
-
- if(v < 1000)
- snprintf(x, 30, "%d", v);
- else if(v < 1000000)
- snprintf(x, 30, "%d,%03d", v / 1000, v % 1000);
- else if(v < 1000000000)
- snprintf(x, 30, "%d,%03d,%03d",
- v / 1000000, (v % 1000000) / 1000, v % 1000);
- else
- snprintf(x, 30, "%d,%03d,%03d,%03d",
- v / 1000000000, (v % 1000000000) / 1000000,
- (v % 1000000) / 1000, v % 1000);
- return x;
-}
-
-
-
-static void
-tdmi_displayname(th_dvb_mux_instance_t *tdmi, char *buf, size_t len)
-{
- int f = tdmi->tdmi_fe_params.frequency;
-
- if(tdmi->tdmi_adapter->tda_type == FE_QPSK) {
- snprintf(buf, len, "%s kHz %s", nicenum(f),
- dvb_polarisation_to_str(tdmi->tdmi_polarisation));
- } else {
- snprintf(buf, len, "%s kHz", nicenum(f / 1000));
- }
-}
-
-/*
- * Adapter summary
- */
-static int
-ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *tda;
- char dispname[20];
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- snprintf(dispname, sizeof(dispname), "%s", tda->tda_displayname);
- strcpy(dispname + sizeof(dispname) - 4, "...");
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, dispname);
-
- htsbuf_qprintf(tq, "Device:
"
- "%s
",
- tda->tda_rootpath ?: "Not present");
- htsbuf_qprintf(tq, "Type:
"
- "%s
",
- dvb_adaptertype_to_str(tda->tda_type));
-
- htsbuf_qprintf(tq, "", tda->tda_identifier);
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-
-/**
- * DVB configuration
- */
-int
-ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *tda;
-
- htsbuf_qprintf(tq, "");
-
- if(TAILQ_FIRST(&dvb_adapters) == NULL) {
- htsbuf_qprintf(tq, "
"
- "No adapters found
");
- }
-
-
- TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) {
-
- htsbuf_qprintf(tq, "
",
- tda->tda_identifier);
-
- ajax_js(tq, "new Ajax.Updater('summary_%s', "
- "'/ajax/dvbadaptersummary/%s', {method: 'get'})",
- tda->tda_identifier, tda->tda_identifier);
-
- }
- htsbuf_qprintf(tq, "
");
- htsbuf_qprintf(tq, "");
- http_output_html(hc, hr);
- return 0;
-}
-
-
-
-/**
- * DVB adapter editor pane
- */
-static int
-ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *tda, *tda2;
- const char *s;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL);
-
- htsbuf_qprintf(tq,
- "%s
",
- tda->tda_identifier, tda->tda_displayname);
-
- ajax_box_end(tq, AJAX_BOX_FILLED);
-
- /* Type */
-
- htsbuf_qprintf(tq, "");
-
- htsbuf_qprintf(tq, "
");
-
- htsbuf_qprintf(tq, "
Model:
"
- "
%s (%s)
",
- tda->tda_fe_info ? tda->tda_fe_info->name : "
",
- dvb_adaptertype_to_str(tda->tda_type));
-
-
-
- if(tda->tda_fe_info != NULL) {
-
- s = tda->tda_type == FE_QPSK ? "kHz" : "Hz";
- htsbuf_qprintf(tq, "Freq. Range:
"
- "%s - %s %s, in steps of %s %s
",
- nicenum(tda->tda_fe_info->frequency_min),
- nicenum(tda->tda_fe_info->frequency_max),
- s,
- nicenum(tda->tda_fe_info->frequency_stepsize),
- s);
-
-
- if(tda->tda_fe_info->symbol_rate_min) {
- htsbuf_qprintf(tq, "Symbolrate:
"
- "%s - %s Baud
",
- nicenum(tda->tda_fe_info->symbol_rate_min),
- nicenum(tda->tda_fe_info->symbol_rate_max));
- }
- /* Capabilities */
- // htsbuf_qprintf(tq, "Capabilities:
");
- }
-
- htsbuf_qprintf(tq, "");
-
- htsbuf_qprintf(tq, "
");
-
- htsbuf_qprintf(tq, "
");
-
- htsbuf_qprintf(tq,
- "",
- tda->tda_identifier, tda->tda_displayname);
-
- if(tda->tda_rootpath == NULL) {
- htsbuf_qprintf(tq,
- "",
- tda->tda_identifier, tda->tda_displayname);
- }
-
- // htsbuf_qprintf(tq, "
");
-
- /* Clone adapter */
-
- // htsbuf_qprintf(tq, "
");
- htsbuf_qprintf(tq,
- "
");
- htsbuf_qprintf(tq, "
");
-
- htsbuf_qprintf(tq, "
");
-
- htsbuf_qprintf(tq, "");
-
- /* Muxes and transports */
-
-
- htsbuf_qprintf(tq, "");
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
-
- htsbuf_qprintf(tq, "
",
- tda->tda_identifier);
-
- ajax_js(tq,
- "new Ajax.Updater('dvbmuxlist_%s', "
- "'/ajax/dvbadaptermuxlist/%s', {method: 'get', evalScripts: true})",
- tda->tda_identifier, tda->tda_identifier);
-
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- htsbuf_qprintf(tq, "
");
-
- /* Div for displaying services */
-
- htsbuf_qprintf(tq, "");
- htsbuf_qprintf(tq, "
");
-
- http_output_html(hc, hr);
- return 0;
-}
-
-
-/**
- * DVB adapter add mux
- */
-static int
-ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *tda;
- int caps;
- int fetype;
- char params[400];
- int n, type;
- const char *networkname;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if(tda->tda_fe_info == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- caps = tda->tda_fe_info->caps;
- fetype = tda->tda_fe_info->type;
-
- snprintf(params, sizeof(params), "Add new %s mux on \"%s\"",
- dvb_adaptertype_to_str(tda->tda_fe_info->type),
- tda->tda_displayname);
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, params);
-
- /* Manual configuration */
-
- htsbuf_qprintf(tq,
- ""
- "Manual configuartion
");
-
- htsbuf_qprintf(tq,
- ""
- "
Frequency (%s):
"
- "
"
- ""
- "
",
- fetype == FE_QPSK ? "kHz" : "Hz");
-
- snprintf(params, sizeof(params),
- "freq: $F('freq')");
-
- /* Symbolrate */
-
- if(fetype == FE_QAM || fetype == FE_QPSK) {
-
- htsbuf_qprintf(tq,
- ""
- "
Symbolrate:
"
- "
"
- ""
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", symrate: $F('symrate')");
- }
-
- /* Bandwidth */
-
- if(fetype == FE_OFDM) {
- htsbuf_qprintf(tq,
- ""
- "
Bandwidth:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", bw: $F('bw')");
- }
-
-
- /* Constellation */
-
-
- if(fetype == FE_QAM || fetype == FE_OFDM) {
- htsbuf_qprintf(tq,
- ""
- "
Constellation:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", const: $F('const')");
- }
-
-
- /* FEC */
-
- if(fetype == FE_QAM || fetype == FE_QPSK) {
- htsbuf_qprintf(tq,
- ""
- "
FEC:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", fec: $F('fec')");
- }
-
- if(fetype == FE_QPSK) {
- htsbuf_qprintf(tq,
- ""
- "
Polarisation:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", pol: $F('pol')");
-
-
- }
-
-
- if(fetype == FE_OFDM) {
- htsbuf_qprintf(tq,
- ""
- "
Transmission mode:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", tmode: $F('tmode')");
-
- htsbuf_qprintf(tq,
- ""
- "
Guard interval:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", guard: $F('guard')");
-
-
-
- htsbuf_qprintf(tq,
- ""
- "
Hierarchy:
"
- "
");
-
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", hier: $F('hier')");
-
-
-
- htsbuf_qprintf(tq,
- ""
- "
FEC Hi:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", fechi: $F('fechi')");
-
-
- htsbuf_qprintf(tq,
- ""
- "
FEC Low:
"
- "
");
-
- snprintf(params + strlen(params), sizeof(params) - strlen(params),
- ", feclo: $F('feclo')");
- }
-
- htsbuf_qprintf(tq,
- "
"
- ""
- ""
- "
", tda->tda_identifier, params);
-
- /*
- * Preconfigured
- */
-
- htsbuf_qprintf(tq,
- "
"
- ""
- "Preconfigured network
");
-
- htsbuf_qprintf(tq,
- ""
- "
");
-
- htsbuf_qprintf(tq,
- "");
-
- htsbuf_qprintf(tq,
- "
"
- ""
- ""
- "
", tda->tda_identifier, params);
-
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-/**
- * DVB adapter create mux (come here on POST after addmux query)
- */
-static int
-ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq;
- th_dvb_adapter_t *tda;
- const char *v;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- v = dvb_mux_create_str(tda,
- "65535",
- NULL,
- http_arg_get(&hc->hc_req_args, "freq"),
- http_arg_get(&hc->hc_req_args, "symrate"),
- http_arg_get(&hc->hc_req_args, "const"),
- http_arg_get(&hc->hc_req_args, "fec"),
- http_arg_get(&hc->hc_req_args, "fechi"),
- http_arg_get(&hc->hc_req_args, "feclo"),
- http_arg_get(&hc->hc_req_args, "bw"),
- http_arg_get(&hc->hc_req_args, "tmode"),
- http_arg_get(&hc->hc_req_args, "guard"),
- http_arg_get(&hc->hc_req_args, "hier"),
- http_arg_get(&hc->hc_req_args, "pol"),
- http_arg_get(&hc->hc_req_args, "port"), 1);
-
-
- tq = &hr->hr_q;
-
- if(v != NULL)
- htsbuf_qprintf(tq, "alert('%s');\r\n", v);
-
- htsbuf_qprintf(tq,
- "$('servicepane').innerHTML='';\r\n");
-
- htsbuf_qprintf(tq,
- "new Ajax.Updater('dvbmuxlist_%s', "
- "'/ajax/dvbadaptermuxlist/%s', "
- "{method: 'get', evalScripts: true});\r\n",
- tda->tda_identifier, tda->tda_identifier);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-/**
- * Return a list of all muxes on the given adapter
- */
-static int
-ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- ajax_table_t ta;
- th_dvb_mux_instance_t *tdmi;
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *tda;
- char buf[200];
- int fetype, n, m;
- th_transport_t *t;
- int nmuxes = 0;
- char **selvector;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- fetype = tda->tda_type;
-
- /* List of muxes */
-
- nmuxes = tda->tda_muxes.entries;
-
- if(nmuxes == 0) {
- htsbuf_qprintf(tq, ""
- "No muxes configured
");
- } else {
-
-
- selvector = alloca(sizeof(char *) * (nmuxes + 1));
- n = 0;
- RB_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link)
- selvector[n++] = tdmi->tdmi_identifier;
- selvector[n] = NULL;
-
- ajax_generate_select_functions(tq, "mux", selvector);
-
- ajax_table_top(&ta, hc, tq,
- (const char *[])
- {"Freq", "Status", "Quality", "State", "Name", "Services", "", NULL},
- (int[])
- {16,12,7,8,16,8,2});
-
- RB_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) {
-
- tdmi_displayname(tdmi, buf, sizeof(buf));
-
- ajax_table_row_start(&ta, tdmi->tdmi_identifier);
-
- ajax_table_cell(&ta, NULL,
- "%s",
- tdmi->tdmi_identifier, buf);
-
- ajax_table_cell(&ta, "status", "%s", dvb_mux_status(tdmi, 0));
- ajax_table_cell(&ta, "qual", "%d%%",
- dvb_quality_to_percent(tdmi->tdmi_quality));
- ajax_table_cell(&ta, "state", "%s", dvb_mux_state(tdmi));
- ajax_table_cell(&ta, "name", "%s", tdmi->tdmi_network ?: "Unknown");
-
- n = m = 0;
- LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
- n++;
- if(transport_is_available(t))
- m++;
- }
- ajax_table_cell(&ta, "nsvc", "%d / %d", m, n);
- ajax_table_cell_checkbox(&ta);
- }
-
- ajax_table_row_start(&ta, NULL);
-
- ajax_table_cell(&ta, NULL,
- "All", tda->tda_identifier);
-
- ajax_table_bottom(&ta);
-
- htsbuf_qprintf(tq, "
");
-
- 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);
- htsbuf_qprintf(tq, "
\r\n");
- }
- if(tda->tda_fe_info != NULL) {
- htsbuf_qprintf(tq, "
");
-
- ajax_button(tq, "Add new mux...",
- "new Ajax.Updater('servicepane', "
- "'/ajax/dvbadapteraddmux/%s', "
- "{method: 'get', evalScripts: true})\"",
- tda->tda_identifier);
- htsbuf_qprintf(tq, "
\r\n");
- }
- http_output_html(hc, hr);
- return 0;
-}
-
-/**
- *
- */
-static int
-dvbsvccmp(th_transport_t *a, th_transport_t *b)
-{
- if(a->tht_dvb_mux_instance == b->tht_dvb_mux_instance)
- return a->tht_dvb_service_id - b->tht_dvb_service_id;
-
- return a->tht_dvb_mux_instance->tdmi_fe_params.frequency -
- b->tht_dvb_mux_instance->tdmi_fe_params.frequency;
-}
-
-/**
- * Display detailes about a mux
- */
-static int
-ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_dvb_mux_instance_t *tdmi;
- htsbuf_queue_t *tq = &hr->hr_q;
- char buf[1000];
- th_transport_t *t;
- struct th_transport_tree tree;
- int n = 0;
-
- if(remain == NULL || (tdmi = dvb_mux_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- tdmi_displayname(tdmi, buf, sizeof(buf));
-
- RB_INIT(&tree);
-
- LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
- if(transport_is_available(t)) {
- RB_INSERT_SORTED(&tree, t, tht_tmp_link, dvbsvccmp);
- n++;
- }
- }
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, buf);
- ajax_transport_build_list(hc, tq, &tree, n);
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-/**
- * Display all transports on an adapter
- */
-static int
-ajax_dvbmuxall(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_dvb_adapter_t *tda;
- th_dvb_mux_instance_t *tdmi;
- htsbuf_queue_t *tq = &hr->hr_q;
- th_transport_t *t;
- struct th_transport_tree tree;
- int n = 0;
- char buf[100];
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- snprintf(buf, sizeof(buf), "All services on %s\n", tda->tda_displayname);
-
- RB_INIT(&tree);
-
- RB_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) {
- LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
- if(transport_is_available(t)) {
- RB_INSERT_SORTED(&tree, t, tht_tmp_link, dvbsvccmp);
- n++;
- }
- }
- }
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, buf);
- ajax_transport_build_list(hc, tq, &tree, n);
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-
-/**
- * Delete muxes on an adapter
- */
-static int
-ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_dvb_adapter_t *tda;
- th_dvb_mux_instance_t *tdmi;
- htsbuf_queue_t *tq = &hr->hr_q;
- http_arg_t *ra;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
- if(strcmp(ra->val, "selected"))
- continue;
-
- if((tdmi = dvb_mux_find_by_identifier(ra->key)) == NULL)
- continue;
-
- dvb_mux_destroy(tdmi);
- }
-
- htsbuf_qprintf(tq,
- "new Ajax.Updater('dvbadaptereditor', "
- "'/ajax/dvbadaptereditor/%s', "
- "{method: 'get', evalScripts: true});",
- tda->tda_identifier);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-/**
- * Rename adapter
- */
-static int
-ajax_adapterrename(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_dvb_adapter_t *tda;
-
- htsbuf_queue_t *tq = &hr->hr_q;
- const char *s;
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((s = http_arg_get(&hc->hc_req_args, "newname")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- free(tda->tda_displayname);
- tda->tda_displayname = strdup(s);
- dvb_tda_save(tda);
-
- htsbuf_qprintf(tq,
- "$('adaptername_%s').innerHTML='%s';",
- tda->tda_identifier, tda->tda_displayname);
-
- htsbuf_qprintf(tq,
- "new Ajax.Updater('summary_%s', "
- "'/ajax/dvbadaptersummary/%s', {method: 'get'})",
- tda->tda_identifier, tda->tda_identifier);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-/**
- * Rename adapter
- */
-static int
-ajax_dvbnetworkinfo(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- 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)
- htsbuf_qprintf(tq, "%s", s);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-
-
-
-/**
- * Rename adapter
- */
-static int
-ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- const char *s;
- th_dvb_adapter_t *tda;
-
-
- if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((s = http_arg_get(&hc->hc_req_args, "network")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
-
- dvb_mux_preconf_add(tda, atoi(s));
-
- htsbuf_qprintf(tq,
- "$('servicepane').innerHTML='';\r\n");
-
- htsbuf_qprintf(tq,
- "new Ajax.Updater('dvbmuxlist_%s', "
- "'/ajax/dvbadaptermuxlist/%s', "
- "{method: 'get', evalScripts: true});\r\n",
- tda->tda_identifier, tda->tda_identifier);
-
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-/**
- * Clone adapter
- */
-static int
-ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- th_dvb_adapter_t *src, *dst;
- const char *s;
-
- if(remain == NULL || (dst = dvb_adapter_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((s = http_arg_get(&hc->hc_req_args, "source")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- if((src = dvb_adapter_find_by_identifier(s)) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- printf("Clone from %s to %s\n", src->tda_displayname, dst->tda_displayname);
-
- dvb_tda_clone(dst, src);
-
- htsbuf_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
- "'/ajax/dvbadaptereditor/%s', "
- "{method: 'get', evalScripts: true});\r\n",
- dst->tda_identifier);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-/**
- * Delete adapter
- */
-static int
-ajax_dvbadapterdelete(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- 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;
-
- htsbuf_qprintf(tq, "var o = $('summary_%s'); o.parentNode.removeChild(o);\r\n",
- tda->tda_identifier);
- htsbuf_qprintf(tq, "$('dvbadaptereditor').innerHTML ='';\r\n");
-
- dvb_tda_destroy(tda);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-/**
- *
- */
-void
-ajax_config_dvb_init(void)
-{
- http_path_add("/ajax/dvbadaptermuxlist" , NULL, ajax_adaptermuxlist,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadaptersummary" , NULL, ajax_adaptersummary,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapterrename" , NULL, ajax_adapterrename,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadaptereditor", NULL, ajax_adaptereditor,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapteraddmux", NULL, ajax_adapteraddmux,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapterdelmux", NULL, ajax_adapterdelmux,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadaptercreatemux", NULL, ajax_adaptercreatemux,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbmuxeditor", NULL, ajax_dvbmuxeditor,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbmuxall", NULL, ajax_dvbmuxall,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbnetworkinfo", NULL, ajax_dvbnetworkinfo,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapteraddnetwork", NULL, ajax_dvbadapteraddnetwork,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapterclone", NULL, ajax_dvbadapterclone,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/dvbadapterdelete", NULL, ajax_dvbadapterdelete,
- AJAX_ACCESS_CONFIG);
-
-}
diff --git a/ajaxui/ajaxui_config_transport.c b/ajaxui/ajaxui_config_transport.c
deleted file mode 100644
index a6f357a3..00000000
--- a/ajaxui/ajaxui_config_transport.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * tvheadend, AJAX / HTML user interface
- * Copyright (C) 2008 Andreas Öman
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#define _GNU_SOURCE
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "tvhead.h"
-#include "http.h"
-#include "ajaxui.h"
-#include "channels.h"
-#include "psi.h"
-#include "transports.h"
-#include "serviceprobe.h"
-
-
-/**
- *
- */
-int
-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;
-
- htsbuf_qprintf(tq, "\r\n");
-
- /* Top */
-
- htsbuf_qprintf(tq, "");
- return 0;
-}
-
-/**
- * Rename of unmapped channel
- */
-static int
-ajax_transport_rename_channel(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_transport_t *t;
- const char *newname;
- htsbuf_queue_t *tq = &hr->hr_q;
-
- if(remain == NULL || (t = transport_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((newname = http_arg_get(&hc->hc_req_args, "newname")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- free((void *)t->tht_chname);
- t->tht_chname = strdup(newname);
-
- ajax_a_jsfuncf(tq, newname,
- "tentative_chname('chname_%s', "
- "'/ajax/transport_rename_channel/%s', '%s')",
- t->tht_identifier, t->tht_identifier, newname);
-
- http_output_html(hc, hr);
- t->tht_config_change(t);
- return 0;
-}
-
-
-/**
- *
- */
-void
-ajax_transport_build_mapper_state(char *buf, size_t siz, th_transport_t *t,
- int mapped)
-{
- if(mapped) {
- snprintf(buf, siz,
- "$('chname_%s').innerHTML='%s';\n\r"
- "$('map_%s').src='/gfx/mapped.png';\n\r",
- t->tht_identifier, t->tht_ch->ch_name,
- t->tht_identifier);
- } else {
- snprintf(buf, siz,
- "$('chname_%s').innerHTML='"
- "%s"
- "';\n\r"
- "$('map_%s').src='/gfx/unmapped.png';\n\r",
- t->tht_identifier, t->tht_identifier, t->tht_identifier,
- t->tht_chname, t->tht_chname, t->tht_identifier);
- }
-}
-
-
-/**
- *
- */
-static void
-ajax_map_unmap_channel(th_transport_t *t, htsbuf_queue_t *tq, int map)
-{
- char buf[1000];
-
- if(map)
- transport_map_channel(t, NULL);
- else
- transport_unmap_channel(t);
-
- ajax_transport_build_mapper_state(buf, sizeof(buf), t, map);
- htsbuf_qprintf(tq, "%s", buf);
-}
-
-
-/**
- *
- */
-static int
-ajax_transport_op(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_transport_t *t;
- htsbuf_queue_t *tq = &hr->hr_q;
- const char *op = remain;
- http_arg_t *ra;
-
- if(op == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
- if(strcmp(ra->val, "selected"))
- continue;
-
- if((t = transport_find_by_identifier(ra->key)) == NULL)
- continue;
-
- if(!strcmp(op, "toggle")) {
- ajax_map_unmap_channel(t, tq, t->tht_ch ? 0 : 1);
- } else if(!strcmp(op, "map") && t->tht_ch == NULL) {
- ajax_map_unmap_channel(t, tq, 1);
- } else if(!strcmp(op, "unmap") && t->tht_ch != NULL) {
- ajax_map_unmap_channel(t, tq, 0);
- } else if(!strcmp(op, "probe")) {
- serviceprobe_add(t);
- continue;
- }
- t->tht_config_change(t);
- }
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
-
- return 0;
-}
-
-
-/**
- *
- */
-static int
-ajax_transport_chdisable(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- th_transport_t *t;
- const char *s;
-
- if(remain == NULL || (t = transport_find_by_identifier(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((s = http_arg_get(&hc->hc_req_args, "enabled")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- t->tht_disabled = !strcasecmp(s, "false");
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- t->tht_config_change(t);
- return 0;
-}
-
-
-/**
- *
- */
-void
-ajax_config_transport_init(void)
-{
- http_path_add("/ajax/transport_rename_channel", NULL,
- ajax_transport_rename_channel,
- AJAX_ACCESS_CONFIG);
-
- http_path_add("/ajax/transport_op", NULL,
- ajax_transport_op,
- AJAX_ACCESS_CONFIG);
-
- http_path_add("/ajax/transport_chdisable", NULL,
- ajax_transport_chdisable,
- AJAX_ACCESS_CONFIG);
-
-}
diff --git a/ajaxui/ajaxui_config_xmltv.c b/ajaxui/ajaxui_config_xmltv.c
deleted file mode 100644
index d5f96e14..00000000
--- a/ajaxui/ajaxui_config_xmltv.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * tvheadend, AJAX / HTML user interface
- * Copyright (C) 2008 Andreas Öman
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#define _GNU_SOURCE
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "tvhead.h"
-#include "http.h"
-#include "ajaxui.h"
-#include "channels.h"
-#include "epg_xmltv.h"
-#include "psi.h"
-#include "transports.h"
-
-#include "ajaxui_mailbox.h"
-
-
-
-/**
- * XMLTV configuration
- */
-int
-ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
-{
- htsbuf_queue_t *tq = &hr->hr_q;
- xmltv_grabber_t *xg;
- int ngrabbers = 0;
- ajax_table_t ta;
-
- htsbuf_qprintf(tq, "");
-
- switch(xmltv_globalstatus) {
- default:
- htsbuf_qprintf(tq, "
"
- "XMLTV subsystem is not yet fully initialized, please retry "
- "in a few seconds
");
- http_output_html(hc, hr);
- return 0;
-
- case XMLTVSTATUS_FIND_GRABBERS_NOT_FOUND:
- htsbuf_qprintf(tq, ""
- "XMLTV subsystem can not initialize
"
- ""
- "Make sure that the 'tv_find_grabbers' executable is in "
- "the system path
");
- http_output_html(hc, hr);
- return 0;
-
- case XMLTVSTATUS_RUNNING:
- break;
- }
-
- htsbuf_qprintf(tq, "");
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "XMLTV grabbers");
-
- LIST_FOREACH(xg, &xmltv_grabbers, xg_link)
- ngrabbers++;
-
- ajax_table_top(&ta, hc, tq,
- (const char *[]){"Grabber", "Status", NULL},
- (int[]){4,2});
-
- LIST_FOREACH(xg, &xmltv_grabbers, xg_link) {
-
- ajax_table_row_start(&ta, xg->xg_identifier);
- ajax_table_cell(&ta, NULL,
- "
%s", xg->xg_identifier, xg->xg_title);
-
- ajax_table_cell(&ta, "status", xmltv_grabber_status(xg));
- }
- ajax_table_bottom(&ta);
-
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
-
- htsbuf_qprintf(tq, "
"
- ""
- "
");
-
- htsbuf_qprintf(tq, "");
- http_output_html(hc, hr);
- return 0;
-}
-
-/**
- * Generate displaylisting
- */
-static void
-xmltv_grabber_chlist(htsbuf_queue_t *tq, xmltv_grabber_t *xg)
-{
- xmltv_channel_t *xc;
- channel_group_t *tcg;
- channel_t *ch;
-
- htsbuf_qprintf(tq,
- "");
-
- TAILQ_FOREACH(xc, &xg->xg_channels, xc_link) {
-
- htsbuf_qprintf(tq,
- "
");
-
- htsbuf_qprintf(tq, "
");
- if(xc->xc_icon_url != NULL) {
- htsbuf_qprintf(tq,
- "

",
- xc->xc_icon_url);
- } else {
- htsbuf_qprintf(tq,
- "
"
- "No icon
");
- }
- htsbuf_qprintf(tq, "
"); /* iconbackdrop */
-
-
- htsbuf_qprintf(tq,
- "
Name:
"
- "
%s (%s)
", xc->xc_displayname, xc->xc_name);
-
- htsbuf_qprintf(tq,
- "
Auto mapper:
"
- "
%s
", xc->xc_bestmatch ?: "(no channel)");
-
- htsbuf_qprintf(tq,
- "
Channel:
"
- "
");
- htsbuf_qprintf(tq, "
\r\n");
- }
- htsbuf_qprintf(tq, "
");
-}
-
-
-/**
- * Display detailes about a grabber
- */
-static int
-ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- xmltv_grabber_t *xg;
- htsbuf_queue_t *tq = &hr->hr_q;
-
-
- if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, xg->xg_title);
-
- htsbuf_qprintf(tq,"", xg->xg_identifier);
-
- if(xg->xg_enabled == 0) {
- htsbuf_qprintf(tq,
- "
This grabber is currently not enabled, click "
- "here "
- "to enable it
");
- } else if(xg->xg_status == XMLTV_GRAB_OK) {
- xmltv_grabber_chlist(tq, xg);
- } else {
- htsbuf_qprintf(tq, "
%s
", xmltv_grabber_status_long(xg));
- }
-
- htsbuf_qprintf(tq,"
");
-
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- http_output_html(hc, hr);
- return 0;
-}
-
-
-
-/**
- * Enable / Disable a grabber
- */
-static int
-ajax_xmltvgrabbermode(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- xmltv_grabber_t *xg;
- 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);
-
- htsbuf_qprintf(tq,"$('details_%s').innerHTML='Please wait...';",
- xg->xg_identifier);
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-
-/**
- * Enable / Disable a grabber
- */
-static int
-ajax_xmltvgrabberlist(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- xmltv_grabber_t *xg;
- htsbuf_queue_t *tq = &hr->hr_q;
-
- if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- xmltv_grabber_chlist(tq, xg);
-
- http_output_html(hc, hr);
- return 0;
-}
-
-
-/**
- * Change mapping of a channel for a grabber
- */
-static int
-ajax_xmltvgrabberchmap(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- xmltv_grabber_t *xg;
- xmltv_channel_t *xc;
- const char *xmltvname;
- const char *chname;
- channel_t *ch;
- // htsbuf_queue_t *tq = &hr->hr_tq;
-
- if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- if((xmltvname = http_arg_get(&hc->hc_req_args, "xmltvch")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- if((chname = http_arg_get(&hc->hc_req_args, "channel")) == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- TAILQ_FOREACH(xc, &xg->xg_channels, xc_link)
- if(!strcmp(xc->xc_name, xmltvname))
- break;
-
- if(xc == NULL)
- return HTTP_STATUS_BAD_REQUEST;
-
- pthread_mutex_lock(&xg->xg_mutex);
-
- free(xc->xc_channel);
- xc->xc_channel = NULL;
- xc->xc_disabled = 0;
-
- if(!strcmp(chname, "none")) {
- xc->xc_disabled = 1;
- } else if(!strcmp(chname, "auto")) {
- } else if((ch = channel_by_tag(atoi(chname))) != NULL) {
- xc->xc_disabled = 0;
- xc->xc_channel = strdup(ch->ch_name);
- }
- pthread_mutex_unlock(&xg->xg_mutex);
-
- xmltv_config_save();
-
- http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
- return 0;
-}
-
-
-
-/**
- *
- */
-void
-ajax_config_xmltv_init(void)
-{
- http_path_add("/ajax/xmltvgrabber" , NULL, ajax_xmltvgrabber,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/xmltvgrabbermode" , NULL, ajax_xmltvgrabbermode,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/xmltvgrabberlist" , NULL, ajax_xmltvgrabberlist,
- AJAX_ACCESS_CONFIG);
- http_path_add("/ajax/xmltvgrabberchmap" , NULL, ajax_xmltvgrabberchmap,
- AJAX_ACCESS_CONFIG);
-
-}
diff --git a/ajaxui/ajaxui_mailbox.c b/ajaxui/ajaxui_mailbox.c
deleted file mode 100644
index f43203c2..00000000
--- a/ajaxui/ajaxui_mailbox.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * tvheadend, AJAX / HTML Mailboxes
- * Copyright (C) 2008 Andreas Öman
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "tvhead.h"
-#include "dispatch.h"
-#include "http.h"
-#include "ajaxui.h"
-#include "transports.h"
-#include "epg_xmltv.h"
-#include "dvb_support.h"
-#include "ajaxui_mailbox.h"
-#include "cwc.h"
-
-#define MAILBOX_UNUSED_TIMEOUT 15
-#define MAILBOX_EMPTY_REPLY_TIMEOUT 10
-
-
-//#define mbdebug(fmt...) printf(fmt);
-#define mbdebug(fmt...)
-
-
-static LIST_HEAD(, ajaxui_mailbox) mailboxes;
-
-int mailbox_tally;
-
-TAILQ_HEAD(ajaxui_letter_queue, ajaxui_letter);
-
-typedef struct ajaxui_letter {
- TAILQ_ENTRY(ajaxui_letter) al_link;
- char *al_payload_a;
- char *al_payload_b;
-} ajaxui_letter_t;
-
-
-typedef struct ajaxui_mailbox {
- LIST_ENTRY(ajaxui_mailbox) amb_link;
-
- char *amb_boxid; /* an md5hash */
-
- dtimer_t amb_timer;
-
- http_reply_t *amb_hr; /* Pending request */
-
- struct ajaxui_letter_queue amb_letters;
-
-} ajaxui_mailbox_t;
-
-
-/**
- *
- */
-static void
-al_destroy(ajaxui_mailbox_t *amb, ajaxui_letter_t *al)
-{
- TAILQ_REMOVE(&amb->amb_letters, al, al_link);
- free(al->al_payload_a);
- free(al->al_payload_b);
- free(al);
-}
-
-
-/**
- *
- */
-static void
-amb_destroy(ajaxui_mailbox_t *amb)
-{
- ajaxui_letter_t *al;
-
- mbdebug("mailbox[%s]: destroyed\n", amb->amb_boxid);
-
- while((al = TAILQ_FIRST(&amb->amb_letters)) != NULL)
- al_destroy(amb, al);
-
- LIST_REMOVE(amb, amb_link);
-
- dtimer_disarm(&amb->amb_timer);
-
- free(amb->amb_boxid);
- free(amb);
-}
-
-
-
-/**
- *
- */
-static void
-ajax_mailbox_unused(void *opaque, int64_t now)
-{
- ajaxui_mailbox_t *amb = opaque;
- assert(amb->amb_hr == NULL);
- amb_destroy(amb);
-}
-
-/**
- *
- */
-static void
-ajax_mailbox_connection_lost(http_reply_t *hr, void *opaque)
-{
- ajaxui_mailbox_t *amb = opaque;
- assert(hr == amb->amb_hr);
- amb_destroy(amb);
-}
-
-
-
-/**
- *
- */
-static ajaxui_mailbox_t *
-ajax_mailbox_create(const char *id)
-{
- ajaxui_mailbox_t *amb = calloc(1, sizeof(ajaxui_mailbox_t));
-
- amb->amb_boxid = strdup(id);
-
- mailbox_tally++;
-
- LIST_INSERT_HEAD(&mailboxes, amb, amb_link);
-
- TAILQ_INIT(&amb->amb_letters);
-
- dtimer_arm(&amb->amb_timer, ajax_mailbox_unused, amb,
- MAILBOX_UNUSED_TIMEOUT);
- return amb;
-}
-
-/**
- *
- */
-void
-ajax_mailbox_start(htsbuf_queue_t *hq)
-{
- struct timeval tv;
- uint8_t sum[16];
- char id[33];
- int i;
- struct AVMD5 *ctx;
-
- ctx = alloca(av_md5_size);
-
- gettimeofday(&tv, NULL);
-
- av_md5_init(ctx);
- av_md5_update(ctx, (void *)&tv, sizeof(tv));
- av_md5_update(ctx, (void *)&mailbox_tally, sizeof(uint32_t));
- av_md5_final(ctx, sum);
-
- for(i = 0; i < 16; i++) {
- id[i * 2 + 0] = "0123456789abcdef"[sum[i] >> 4];
- id[i * 2 + 1] = "0123456789abcdef"[sum[i] & 15];
- }
- id[32] = 0;
-
- mbdebug("Generated mailbox %s\n", id);
-
- ajax_mailbox_create(id);
- ajax_js(hq, "mailboxquery('%s')", id);
-}
-
-
-/**
- *
- */
-static void
-ajax_mailbox_reply(ajaxui_mailbox_t *amb, http_reply_t *hr)
-{
- ajaxui_letter_t *al;
-
- /* Modify the hidden element (as described in ajax_mailbox_start()),
- if this div no longer exist, the rest of the javascript will bail
- out and we will not be reloaded */
-
- mbdebug("mailbox[%s]: sending reply\n", amb->amb_boxid);
-
- while((al = TAILQ_FIRST(&amb->amb_letters)) != NULL) {
- 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 ?: "");
-
- htsbuf_qprintf(&hr->hr_q, "}\r\n"
- "catch(err) {}\r\n");
- al_destroy(amb, al);
- }
-
- 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;
-
- /* Arm a timer in case the browser won't call back */
- dtimer_arm(&amb->amb_timer, ajax_mailbox_unused, amb,
- MAILBOX_UNUSED_TIMEOUT);
-}
-
-/**
- *
- */
-static void
-ajax_mailbox_empty_reply(void *opaque, int64_t now)
-{
- ajaxui_mailbox_t *amb = opaque;
- http_reply_t *hr = amb->amb_hr;
-
- ajax_mailbox_reply(amb, hr);
- http_continue(hr->hr_connection);
-}
-
-
-/**
- * Poll callback
- *
- * Prepare the mailbox for reply
- */
-static int
-ajax_mailbox_poll(http_connection_t *hc, http_reply_t *hr,
- const char *remain, void *opaque)
-{
- ajaxui_mailbox_t *amb;
-
- if(remain == NULL)
- return HTTP_STATUS_NOT_FOUND;
-
- mbdebug("mailbox[%s]: Incomming request ... ", remain);
-
- LIST_FOREACH(amb, &mailboxes, amb_link)
- if(!strcmp(amb->amb_boxid, remain))
- break;
-
- if(amb == NULL) {
- amb = ajax_mailbox_create(remain);
- mbdebug("creating mailbox ... ");
- }
-
- if(amb->amb_hr != NULL) {
- mbdebug("mailbox already processing\n");
- return 409;
- }
- if(TAILQ_FIRST(&amb->amb_letters) != NULL) {
- /* Pending letters, direct reply */
- mbdebug("direct reply\n");
- ajax_mailbox_reply(amb, hr);
- return 0;
- }
-
- mbdebug("nothing in queue, waiting\n");
-
- amb->amb_hr = hr;
-
- hr->hr_opaque = amb;
- hr->hr_destroy = ajax_mailbox_connection_lost;
-
- dtimer_arm(&amb->amb_timer, ajax_mailbox_empty_reply, amb,
- MAILBOX_EMPTY_REPLY_TIMEOUT);
- return 0;
-}
-
-
-/**
- *
- */
-void
-ajax_mailbox_init(void)
-{
- http_path_add("/ajax/mailbox", NULL, ajax_mailbox_poll,
- ACCESS_WEB_INTERFACE);
-}
-
-
-/**
- * Delayed delivery of mailbox replies
- */
-static void
-ajax_mailbox_deliver(void *opaque, int64_t now)
-{
- ajaxui_mailbox_t *amb = opaque;
- http_connection_t *hc;
-
- hc = amb->amb_hr->hr_connection;
- ajax_mailbox_reply(amb, amb->amb_hr);
- http_continue(hc);
-}
-
-/**
- *
- */
-static void
-ajax_mailbox_add_to_subscription(const char *subscription,
- const char *content_a, const char *content_b)
-{
- ajaxui_mailbox_t *amb;
- ajaxui_letter_t *al;
-
- LIST_FOREACH(amb, &mailboxes, amb_link) {
-
- /* Avoid inserting the same message twice */
-
- TAILQ_FOREACH(al, &amb->amb_letters, al_link) {
- if(!strcmp(al->al_payload_a, content_a))
- break;
- }
-
- if(al == NULL) {
-
- al = malloc(sizeof(ajaxui_letter_t));
- al->al_payload_a = strdup(content_a);
- } else {
- /* Already exist, just move to tail */
-
- TAILQ_REMOVE(&amb->amb_letters, al, al_link);
- free(al->al_payload_b);
- }
-
- al->al_payload_b = content_b ? strdup(content_b) : NULL;
-
- TAILQ_INSERT_TAIL(&amb->amb_letters, al, al_link);
-
- if(amb->amb_hr != NULL)
- dtimer_arm_hires(&amb->amb_timer, ajax_mailbox_deliver, amb,
- getclock_hires() + 100000);
- }
-}
-
-
-
-/**
- *
- */
-static void
-ajax_mailbox_update_div(const char *subscription, const char *prefix,
- const char *postfix, const char *content)
-{
- char buf_a[500];
- char buf_b[500];
-
- content = ajaxui_escape_apostrophe(content);
-
- snprintf(buf_a, sizeof(buf_a), "$('%s_%s').innerHTML=", prefix, postfix);
- snprintf(buf_b, sizeof(buf_b), "'%s';\n\r", content);
-
- ajax_mailbox_add_to_subscription(subscription, buf_a, buf_b);
-}
-
-
-
-static void
-ajax_mailbox_reload_div(const char *subscription, const char *prefix,
- const char *postfix, const char *url)
-{
- char buf[1000];
-
- snprintf(buf, sizeof(buf), "new Ajax.Updater('%s_%s', '%s', "
- "{method: 'get', evalScripts: true});\r\n",
- prefix, postfix, url);
-
- ajax_mailbox_add_to_subscription(subscription, buf, NULL);
-}
-
-
-
-void
-ajax_mailbox_tdmi_state_change(th_dvb_mux_instance_t *tdmi)
-{
- ajax_mailbox_update_div(tdmi->tdmi_adapter->tda_identifier,
- "state", tdmi->tdmi_identifier,
- dvb_mux_state(tdmi));
-}
-
-void
-ajax_mailbox_tdmi_qual_change(th_dvb_mux_instance_t *tdmi)
-{
- char buf[10];
- snprintf(buf, sizeof(buf), "%d%%",
- dvb_quality_to_percent(tdmi->tdmi_quality));
- ajax_mailbox_update_div(tdmi->tdmi_adapter->tda_identifier,
- "qual", tdmi->tdmi_identifier,
- buf);
-}
-
-
-void
-ajax_mailbox_tdmi_name_change(th_dvb_mux_instance_t *tdmi)
-{
- ajax_mailbox_update_div(tdmi->tdmi_adapter->tda_identifier,
- "name", tdmi->tdmi_identifier,
- tdmi->tdmi_network ?: "");
-}
-
-
-void
-ajax_mailbox_tdmi_status_change(th_dvb_mux_instance_t *tdmi)
-{
- ajax_mailbox_update_div(tdmi->tdmi_adapter->tda_identifier,
- "status", tdmi->tdmi_identifier,
- tdmi->tdmi_last_status);
-}
-
-void
-ajax_mailbox_tdmi_services_change(th_dvb_mux_instance_t *tdmi)
-{
- th_transport_t *t;
- char buf[20];
- int n, m;
-
- n = m = 0;
- LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
- n++;
- if(transport_is_available(t))
- m++;
- }
- snprintf(buf, sizeof(buf), "%d / %d", m, n);
-
- ajax_mailbox_update_div(tdmi->tdmi_adapter->tda_identifier,
- "nsvc", tdmi->tdmi_identifier,
- buf);
-}
-
-
-void
-ajax_mailbox_tda_change(th_dvb_adapter_t *tda)
-{
- char buf[500];
-
- snprintf(buf, sizeof(buf), "/ajax/dvbadaptermuxlist/%s",
- tda->tda_identifier);
-
- ajax_mailbox_reload_div(tda->tda_identifier,
- "dvbmuxlist", tda->tda_identifier,
- buf);
-}
-
-
-void
-ajax_mailbox_xmltv_grabber_status_change(xmltv_grabber_t *xg)
-{
- char buf[500];
-
- ajax_mailbox_update_div("xmltvgrabbers",
- "status", xg->xg_identifier,
- xmltv_grabber_status(xg));
-
-
- if(xg->xg_status == XMLTV_GRAB_OK) {
- snprintf(buf, sizeof(buf), "/ajax/xmltvgrabberlist/%s", xg->xg_identifier);
- ajax_mailbox_reload_div("xmltvgrabbers",
- "details", xg->xg_identifier,
- buf);
- } else {
- ajax_mailbox_update_div(xg->xg_identifier,
- "details", xg->xg_identifier,
- xmltv_grabber_status_long(xg));
- }
-}
-
-
-
-void
-ajax_mailbox_transport_status_change(struct th_transport *t)
-{
- ajax_mailbox_update_div("xmltvgrabbers",
- "status", t->tht_identifier,
- transport_status_to_text(t->tht_last_status));
-}
-
-
-
-
-void
-ajax_mailbox_cwc_status_change(struct cwc *cwc)
-{
- char id[20];
- snprintf(id, sizeof(id), "cwc_%d", cwc->cwc_id);
-
- ajax_mailbox_update_div("cwc", "status", id, cwc_status_to_text(cwc));
-}
diff --git a/ajaxui/ajaxui_mailbox.h b/ajaxui/ajaxui_mailbox.h
deleted file mode 100644
index 5bf3a992..00000000
--- a/ajaxui/ajaxui_mailbox.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * tvheadend, AJAX user interface
- * Copyright (C) 2007 Andreas Öman
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef AJAXUI_MAILBOX_H_
-#define AJAXUI_MAILBOX_H_
-
-#include
-
-void ajax_mailbox_tdmi_state_change(th_dvb_mux_instance_t *tdmi);
-
-void ajax_mailbox_tdmi_qual_change(th_dvb_mux_instance_t *tdmi);
-
-void ajax_mailbox_tdmi_name_change(th_dvb_mux_instance_t *tdmi);
-
-void ajax_mailbox_tdmi_status_change(th_dvb_mux_instance_t *tdmi);
-
-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(htsbuf_queue_t *hq);
-
-struct xmltv_grabber;
-
-void ajax_mailbox_xmltv_grabber_status_change(struct xmltv_grabber *xg);
-
-struct th_transport;
-void ajax_mailbox_transport_status_change(struct th_transport *t);
-
-struct cwc;
-void ajax_mailbox_cwc_status_change(struct cwc *cwc);
-
-#endif /* AJAXUI_MAILBOX_H_ */
diff --git a/ajaxui/images/mapped.png b/ajaxui/images/mapped.png
deleted file mode 100644
index a4494940..00000000
Binary files a/ajaxui/images/mapped.png and /dev/null differ
diff --git a/ajaxui/images/sbbody_l.gif b/ajaxui/images/sbbody_l.gif
deleted file mode 100644
index a7adf2d3..00000000
Binary files a/ajaxui/images/sbbody_l.gif and /dev/null differ
diff --git a/ajaxui/images/sbbody_r.gif b/ajaxui/images/sbbody_r.gif
deleted file mode 100644
index 51c4b9fe..00000000
Binary files a/ajaxui/images/sbbody_r.gif and /dev/null differ
diff --git a/ajaxui/images/sbhead_l.gif b/ajaxui/images/sbhead_l.gif
deleted file mode 100644
index 1f4ab9b8..00000000
Binary files a/ajaxui/images/sbhead_l.gif and /dev/null differ
diff --git a/ajaxui/images/sbhead_r.gif b/ajaxui/images/sbhead_r.gif
deleted file mode 100644
index 2401d2a9..00000000
Binary files a/ajaxui/images/sbhead_r.gif and /dev/null differ
diff --git a/ajaxui/images/unmapped.png b/ajaxui/images/unmapped.png
deleted file mode 100644
index 0f2f7388..00000000
Binary files a/ajaxui/images/unmapped.png and /dev/null differ
diff --git a/ajaxui/prototype/prototype.js b/ajaxui/prototype/prototype.js
deleted file mode 100644
index 33ec9d9e..00000000
--- a/ajaxui/prototype/prototype.js
+++ /dev/null
@@ -1,4236 +0,0 @@
-/* Prototype JavaScript framework, version 1.6.0.2
- * (c) 2005-2007 Sam Stephenson
- *
- * Prototype is freely distributable under the terms of an MIT-style license.
- * For details, see the Prototype web site: http://www.prototypejs.org/
- *
- *--------------------------------------------------------------------------*/
-
-var Prototype = {
- Version: '1.6.0.2',
-
- Browser: {
- IE: !!(window.attachEvent && !window.opera),
- Opera: !!window.opera,
- WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
- Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
- MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
- },
-
- BrowserFeatures: {
- XPath: !!document.evaluate,
- ElementExtensions: !!window.HTMLElement,
- SpecificElementExtensions:
- document.createElement('div').__proto__ &&
- document.createElement('div').__proto__ !==
- document.createElement('form').__proto__
- },
-
- ScriptFragment: '