2008-04-03 19:15:00 +00:00
|
|
|
|
/*
|
|
|
|
|
* tvheadend, AJAX / HTML user interface
|
|
|
|
|
* Copyright (C) 2008 Andreas <EFBFBD>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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "tvhead.h"
|
|
|
|
|
#include "http.h"
|
|
|
|
|
#include "ajaxui.h"
|
|
|
|
|
#include "channels.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define AJAX_CONFIG_TAB_CHANNELS 0
|
2008-04-07 15:57:20 +00:00
|
|
|
|
#define AJAX_CONFIG_TAB_DVB 1
|
2008-04-19 10:51:45 +00:00
|
|
|
|
#define AJAX_CONFIG_TAB_XMLTV 2
|
2008-04-29 06:53:21 +00:00
|
|
|
|
#define AJAX_CONFIG_TAB_ACCESS 3
|
|
|
|
|
#define AJAX_CONFIG_TABS 4
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
|
|
|
|
const char *ajax_config_tabnames[] = {
|
|
|
|
|
[AJAX_CONFIG_TAB_CHANNELS] = "Channels & Groups",
|
2008-04-07 15:57:20 +00:00
|
|
|
|
[AJAX_CONFIG_TAB_DVB] = "DVB adapters",
|
2008-04-19 10:51:45 +00:00
|
|
|
|
[AJAX_CONFIG_TAB_XMLTV] = "XML-TV",
|
2008-04-29 06:53:21 +00:00
|
|
|
|
[AJAX_CONFIG_TAB_ACCESS] = "Access control",
|
2008-04-03 19:15:00 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Titlebar AJAX page
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2008-04-14 18:59:31 +00:00
|
|
|
|
ajax_config_menu(http_connection_t *hc, http_reply_t *hr,
|
|
|
|
|
const char *remain, void *opaque)
|
2008-04-03 19:15:00 +00:00
|
|
|
|
{
|
2008-04-14 18:59:31 +00:00
|
|
|
|
tcp_queue_t *tq = &hr->hr_tq;
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
|
|
|
|
if(remain == NULL)
|
|
|
|
|
return HTTP_STATUS_NOT_FOUND;
|
|
|
|
|
|
2008-04-14 18:59:31 +00:00
|
|
|
|
ajax_menu_bar_from_array(tq, "config",
|
2008-04-03 19:15:00 +00:00
|
|
|
|
ajax_config_tabnames, AJAX_CONFIG_TABS,
|
|
|
|
|
atoi(remain));
|
2008-04-14 18:59:31 +00:00
|
|
|
|
http_output_html(hc, hr);
|
2008-04-03 19:15:00 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tab AJAX page
|
|
|
|
|
*
|
|
|
|
|
* Switch to different tabs
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2008-04-14 18:59:31 +00:00
|
|
|
|
ajax_config_dispatch(http_connection_t *hc, http_reply_t *hr,
|
|
|
|
|
const char *remain, void *opaque)
|
2008-04-03 19:15:00 +00:00
|
|
|
|
{
|
|
|
|
|
int tab;
|
|
|
|
|
|
|
|
|
|
if(remain == NULL)
|
|
|
|
|
return HTTP_STATUS_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
tab = atoi(remain);
|
|
|
|
|
|
|
|
|
|
switch(tab) {
|
|
|
|
|
case AJAX_CONFIG_TAB_CHANNELS:
|
2008-04-14 18:59:31 +00:00
|
|
|
|
return ajax_config_channels_tab(hc, hr);
|
2008-04-07 15:57:20 +00:00
|
|
|
|
case AJAX_CONFIG_TAB_DVB:
|
2008-04-14 18:59:31 +00:00
|
|
|
|
return ajax_config_dvb_tab(hc, hr);
|
2008-04-19 10:51:45 +00:00
|
|
|
|
case AJAX_CONFIG_TAB_XMLTV:
|
|
|
|
|
return ajax_config_xmltv_tab(hc, hr);
|
2008-04-29 06:53:21 +00:00
|
|
|
|
case AJAX_CONFIG_TAB_ACCESS:
|
|
|
|
|
return ajax_config_access_tab(hc, hr);
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return HTTP_STATUS_NOT_FOUND;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Config root menu AJAX page
|
|
|
|
|
*
|
|
|
|
|
* This is the top level menu for this c-file
|
|
|
|
|
*/
|
|
|
|
|
int
|
2008-04-14 18:59:31 +00:00
|
|
|
|
ajax_config_tab(http_connection_t *hc, http_reply_t *hr)
|
2008-04-03 19:15:00 +00:00
|
|
|
|
{
|
2008-04-14 18:59:31 +00:00
|
|
|
|
tcp_queue_t *tq = &hr->hr_tq;
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
2008-04-14 18:59:31 +00:00
|
|
|
|
ajax_box_begin(tq, AJAX_BOX_FILLED, "configmenu", NULL, NULL);
|
|
|
|
|
ajax_box_end(tq, AJAX_BOX_FILLED);
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
2008-04-14 18:59:31 +00:00
|
|
|
|
tcp_qprintf(tq, "<div id=\"configdeck\"></div>");
|
2008-04-03 19:15:00 +00:00
|
|
|
|
|
2008-04-14 18:59:31 +00:00
|
|
|
|
tcp_qprintf(tq,
|
2008-04-03 19:15:00 +00:00
|
|
|
|
"<script type=\"text/javascript\">"
|
|
|
|
|
"switchtab('config', '0')"
|
|
|
|
|
"</script>");
|
|
|
|
|
|
2008-04-14 18:59:31 +00:00
|
|
|
|
http_output_html(hc, hr);
|
2008-04-03 19:15:00 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
ajax_config_init(void)
|
|
|
|
|
{
|
2008-04-29 06:53:21 +00:00
|
|
|
|
http_path_add("/ajax/configmenu", NULL, ajax_config_menu,
|
|
|
|
|
AJAX_ACCESS_CONFIG);
|
|
|
|
|
http_path_add("/ajax/configtab", NULL, ajax_config_dispatch,
|
|
|
|
|
AJAX_ACCESS_CONFIG);
|
2008-04-07 15:57:20 +00:00
|
|
|
|
|
|
|
|
|
ajax_config_channels_init();
|
|
|
|
|
ajax_config_dvb_init();
|
2008-04-19 10:51:45 +00:00
|
|
|
|
ajax_config_xmltv_init();
|
2008-04-29 06:53:21 +00:00
|
|
|
|
ajax_config_access_init();
|
2008-04-03 19:15:00 +00:00
|
|
|
|
}
|