diff --git a/ajaxui/ajaxui.css b/ajaxui/ajaxui.css index c1821699..7490bdee 100644 --- a/ajaxui/ajaxui.css +++ b/ajaxui/ajaxui.css @@ -54,6 +54,21 @@ img { border: 0; } * Misc classes */ + +.cell_100_center { + margin-top: 2px; + margin-bottom: 2px; + width: 100%; + text-align: center; +} + +.cell_50 { + margin-top: 2px; + margin-bottom: 2px; + float: left; + width: 50%; +} + .normaltable { height: 300px; overflow: auto; diff --git a/ajaxui/ajaxui_config_dvb.c b/ajaxui/ajaxui_config_dvb.c index 92b75896..0c96944f 100644 --- a/ajaxui/ajaxui_config_dvb.c +++ b/ajaxui/ajaxui_config_dvb.c @@ -128,28 +128,6 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr) return 0; } -/** - * Generate the 'add new...' mux link if the adapter has backing hardware - * - * if result is set we add a fade out of a result from a previous op - */ -static void -dvb_make_add_link(tcp_queue_t *tq, th_dvb_adapter_t *tda, const char *result) -{ - if(tda->tda_fe_info != NULL) { - tcp_qprintf(tq, - "

Add new...

", tda->tda_identifier); - } - - if(result) { - tcp_qprintf(tq, "
%s
", result); - ajax_js(tq, "Effect.Fade('result')"); - } -} - /** * */ @@ -259,17 +237,12 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, "'/ajax/dvbadaptermuxlist/%s', {method: 'get', evalScripts: true})", tda->tda_identifier, tda->tda_identifier); - tcp_qprintf(tq, "
"); - dvb_make_add_link(tq, tda, NULL); - tcp_qprintf(tq, "
"); - ajax_box_end(tq, AJAX_BOX_SIDEBOX); tcp_qprintf(tq, ""); /* Div for displaying services */ - tcp_qprintf(tq, "
"); + tcp_qprintf(tq, "
"); tcp_qprintf(tq, "
"); http_output_html(hc, hr); @@ -289,6 +262,8 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, 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; @@ -299,30 +274,39 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, caps = tda->tda_fe_info->caps; fetype = tda->tda_fe_info->type; - tcp_qprintf(tq, "
" - "Add new %s mux
", - dvb_adaptertype_to_str(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 */ tcp_qprintf(tq, - "
Frequency (%s):
" + "
" + "Manual configuartion
"); + + tcp_qprintf(tq, + "
" + "
Frequency (%s):
" "
" "" - "
", + "
", fetype == FE_QPSK ? "kHz" : "Hz"); snprintf(params, sizeof(params), "freq: $F('freq')"); - /* Symbolrate */ if(fetype == FE_QAM || fetype == FE_QPSK) { tcp_qprintf(tq, - "
Symbolrate:
" + "
" + "
Symbolrate:
" "
" "" - "
"); + "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", symrate: $F('symrate')"); @@ -332,14 +316,15 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_OFDM) { tcp_qprintf(tq, - "
Bandwidth:
" + "
" + "
Bandwidth:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", bw: $F('bw')"); @@ -348,9 +333,11 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, /* Constellation */ + if(fetype == FE_QAM || fetype == FE_OFDM) { tcp_qprintf(tq, - "
Constellation:
" + "
" + "
Constellation:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", const: $F('const')"); @@ -372,7 +359,8 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_QAM || fetype == FE_QPSK) { tcp_qprintf(tq, - "
FEC:
" + "
" + "
FEC:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", fec: $F('fec')"); @@ -392,12 +380,13 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_QPSK) { tcp_qprintf(tq, - "
Polarisation:
" + "
" + "
Polarisation:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", pol: $F('pol')"); @@ -408,19 +397,21 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_OFDM) { tcp_qprintf(tq, - "
Transmission mode:
" + "
" + "
Transmission mode:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", tmode: $F('tmode')"); tcp_qprintf(tq, - "
Guard interval:
" + "
" + "
Guard interval:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", guard: $F('guard')"); @@ -436,7 +427,8 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, tcp_qprintf(tq, - "
Hierarchy:
" + "
" + "
Hierarchy:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), @@ -453,7 +445,8 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, tcp_qprintf(tq, - "
FEC Hi:
" + "
" + "
FEC Hi:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", fechi: $F('fechi')"); tcp_qprintf(tq, - "
FEC Low:
" + "
" + "
FEC Low:
" "
"); + tcp_qprintf(tq, "
"); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", feclo: $F('feclo')"); } tcp_qprintf(tq, + "
" "
" - "" "
", tda->tda_identifier, params); - http_output_html(hc, hr); - return 0; -} + /* + * Preconfigured + */ + + tcp_qprintf(tq, + "
" + "
" + "Add preconfigured network
"); + + tcp_qprintf(tq, + "
" + "
"); + + tcp_qprintf(tq, + "
"); + + tcp_qprintf(tq, + "
" + "
" + "" + "
", tda->tda_identifier, params); + + ajax_box_end(tq, AJAX_BOX_SIDEBOX); -/** - * - */ -static int -ajax_adaptercreatemux_fail(http_connection_t *hc, http_reply_t *hr, - th_dvb_adapter_t *tda, const char *errmsg) -{ - tcp_queue_t *tq = &hr->hr_tq; - dvb_make_add_link(tq, tda, errmsg); http_output_html(hc, hr); return 0; } @@ -546,18 +570,22 @@ ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr, http_arg_get(&hc->hc_req_args, "pol"), http_arg_get(&hc->hc_req_args, "port"), 1); - if(v != NULL) - return ajax_adaptercreatemux_fail(hc, hr, tda, v); tq = &hr->hr_tq; - dvb_make_add_link(tq, tda, "Successfully created"); - ajax_js(tq, - "new Ajax.Updater('dvbmuxlist_%s', " - "'/ajax/dvbadaptermuxlist/%s', {method: 'get', evalScripts: true})", - tda->tda_identifier, tda->tda_identifier); + if(v != NULL) + tcp_qprintf(tq, "alert('%s');\r\n", v); - http_output_html(hc, hr); + tcp_qprintf(tq, + "$('servicepane').innerHTML='';\r\n"); + + tcp_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; } @@ -653,7 +681,15 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr, tda->tda_identifier); tcp_qprintf(tq, "\r\n"); - + if(tda->tda_fe_info != NULL) { + tcp_qprintf(tq, "
"); + tcp_qprintf(tq, "
 
"); + ajax_a_jsfuncf(tq, "Add new...", + "new Ajax.Updater('servicepane', " + "'/ajax/dvbadapteraddmux/%s', " + "{method: 'get', evalScripts: true})\""); + tcp_qprintf(tq, "
\r\n"); + } } http_output_html(hc, hr); return 0; @@ -776,6 +812,65 @@ ajax_adapterrename(http_connection_t *hc, http_reply_t *hr, } +/** + * Rename adapter + */ +static int +ajax_dvbnetworkinfo(http_connection_t *hc, http_reply_t *hr, + const char *remain, void *opaque) +{ + tcp_queue_t *tq = &hr->hr_tq; + 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); + + 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) +{ + tcp_queue_t *tq = &hr->hr_tq; + 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)); + + tcp_qprintf(tq, + "$('servicepane').innerHTML='';\r\n"); + + tcp_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; +} + + /** * */ @@ -790,5 +885,7 @@ ajax_config_dvb_init(void) http_path_add("/ajax/dvbadapterdelmux", NULL, ajax_adapterdelmux); http_path_add("/ajax/dvbadaptercreatemux", NULL, ajax_adaptercreatemux); http_path_add("/ajax/dvbmuxeditor", NULL, ajax_dvbmuxeditor); + http_path_add("/ajax/dvbnetworkinfo", NULL, ajax_dvbnetworkinfo); + http_path_add("/ajax/dvbadapteraddnetwork", NULL, ajax_dvbadapteraddnetwork); } diff --git a/dvb_muxconfig.c b/dvb_muxconfig.c index 05bb9c2d..0969ec6f 100644 --- a/dvb_muxconfig.c +++ b/dvb_muxconfig.c @@ -260,164 +260,74 @@ dvb_mux_create_str(th_dvb_adapter_t *tda, } -#if 0 +#include "linuxtv_muxes.h" - -static void -dvb_t_config(const char *l) +int +dvb_mux_preconf_get(unsigned int n, const char **namep, const char **commentp) { - unsigned long freq; - char bw[20], fec[20], fec2[20], qam[20], mode[20], guard[20], hier[20]; - struct dvb_frontend_parameters f; - int r; + if(n >= sizeof(networks) / sizeof(networks[0])) + return -1; - r = sscanf(l, "%lu %10s %10s %10s %10s %10s %10s %10s", - &freq, bw, fec, fec2, qam, mode, guard, hier); + if(namep != NULL) + *namep = networks[n].name; - if(r != 8) - return; + if(commentp != NULL) + *commentp = networks[n].comment; - memset(&f, 0, sizeof(f)); - - f.inversion = INVERSION_AUTO; - f.frequency = freq; - f.u.ofdm.bandwidth = str2val(bw, bwtab); - f.u.ofdm.constellation = str2val(qam, qamtab); - f.u.ofdm.transmission_mode = str2val(mode, modetab); - f.u.ofdm.guard_interval = str2val(guard, guardtab); - f.u.ofdm.hierarchy_information = str2val(hier, hiertab); - - r = str2val(fec, fectab); - f.u.ofdm.code_rate_HP = r == FEC_NONE ? FEC_AUTO : r; - - r = str2val(fec2, fectab); - f.u.ofdm.code_rate_LP = r == FEC_NONE ? FEC_AUTO : r; - - dvb_add_mux(&f, FE_OFDM, 0); + return networks[n].type; } - - -static void -dvb_c_config(const char *l) +int +dvb_mux_preconf_add(th_dvb_adapter_t *tda, unsigned int n) { - unsigned long freq, symrate; - char fec[20], qam[20]; struct dvb_frontend_parameters f; - int r; + struct mux *m; + int i; + int polarisation, switchport; - r = sscanf(l, "%lu %lu %s %s", - &freq, &symrate, fec, qam); + if(n >= sizeof(networks) / sizeof(networks[0])) + return -1; - if(r != 4) - return; + m = networks[n].muxes; - memset(&f, 0, sizeof(f)); + for(i = 0; i < networks[n].nmuxes; i++) { + + polarisation = 0; + switchport = 0; + + memset(&f, 0, sizeof(f)); - f.inversion = INVERSION_AUTO; - f.frequency = freq; - f.u.qam.symbol_rate = symrate; - f.u.qam.fec_inner = str2val(fec, fectab); - f.u.qam.modulation = str2val(qam, qamtab); - - dvb_add_mux(&f, FE_QAM, 0); -} - - - -static void -dvb_s_config(const char *l) -{ - unsigned long freq, symrate; - char fec[20], polarisation; - struct dvb_frontend_parameters f; - int r; - - r = sscanf(l, "%lu %c %lu %s", - &freq, &polarisation, &symrate, fec); - - if(r != 4) - return; - - memset(&f, 0, sizeof(f)); - - f.inversion = INVERSION_AUTO; - f.frequency = freq; - f.u.qpsk.symbol_rate = symrate; - f.u.qpsk.fec_inner = str2val(fec, fectab); - - - switch(toupper(polarisation)) { - case 'V': - polarisation = POLARISATION_VERTICAL; - break; - case 'H': - polarisation = POLARISATION_HORIZONTAL; - break; - default: - return; - } - - dvb_add_mux(&f, FE_QPSK, polarisation); -} - - - - -static void -dvb_muxfile_add(const char *fname) -{ - FILE *fp; - char line[200]; - - fp = fopen(fname, "r"); - if(fp == NULL) { - syslog(LOG_ERR, "dvb: Unable to open file %s -- %s", - fname, strerror(errno)); - return; - } - - while(!feof(fp)) { - memset(line, 0, sizeof(line)); - - if(fgets(line, sizeof(line) - 1, fp) == NULL) + f.inversion = INVERSION_AUTO; + f.frequency = m->freq; + + switch(tda->tda_type) { + case FE_OFDM: + f.u.ofdm.bandwidth = m->bw; + f.u.ofdm.constellation = m->constellation; + f.u.ofdm.transmission_mode = m->tmode; + f.u.ofdm.guard_interval = m->guard; + f.u.ofdm.hierarchy_information = m->hierarchy; + f.u.ofdm.code_rate_HP = m->fechp; + f.u.ofdm.code_rate_LP = m->feclp; + break; + + case FE_QPSK: + f.u.qpsk.symbol_rate = m->symrate; + f.u.qpsk.fec_inner = m->fec; + polarisation = m->polarisation; break; - switch(line[0]) { - case '#': - break; - - case 'T': - dvb_t_config(line + 1); - break; - - case 'C': - dvb_c_config(line + 1); - break; - - case 'S': - dvb_s_config(line + 1); - break; - - default: + case FE_QAM: + f.u.qam.symbol_rate = m->symrate; + f.u.qam.modulation = m->constellation; + f.u.qam.fec_inner = m->fec; break; } + + dvb_mux_create(tda, &f, polarisation, switchport, 0, 0xffff, NULL); + m++; } + dvb_tda_save(tda); + return 0; } - - - - - -void -dvb_mux_setup(void) -{ - config_entry_t *ce; - - TAILQ_FOREACH(ce, &config_list, ce_link) - if(ce->ce_type == CFG_VALUE && !strcasecmp("dvbmuxfile", ce->ce_key)) - dvb_muxfile_add(ce->ce_value); -} - -#endif diff --git a/dvb_muxconfig.h b/dvb_muxconfig.h index d689cc18..91a62ee4 100644 --- a/dvb_muxconfig.h +++ b/dvb_muxconfig.h @@ -38,4 +38,9 @@ const char *dvb_mux_create_str(th_dvb_adapter_t *tda, const char *switchportstr, int save); +int dvb_mux_preconf_get(unsigned int n, const char **namep, + const char **commentp); + +int dvb_mux_preconf_add(th_dvb_adapter_t *tda, unsigned int n); + #endif /* DVB_MUXCONFIG_H */