#include "access.h"
#include "api.h"
#include "config.h"
+#include "input.h"
#include "wizard.h"
static int
return wizard_page("hello");
}
+static int
+wizard_status_progress
+ ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
+{
+ int64_t active = 0, total = 0, services = 0;
+ mpegts_service_t *s;
+ mpegts_mux_t *mm;
+ mpegts_network_t *mn;
+
+ LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) {
+ if (!mn->mn_wizard) continue;
+ LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link) {
+ total++;
+ if (mm->mm_scan_state != MM_SCAN_STATE_IDLE)
+ active++;
+ LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
+ services++;
+ }
+ }
+ *resp = htsmsg_create_map();
+ htsmsg_add_dbl(*resp, "progress", total ? ((double)1.0 - ((double)active / (double)total)) : 1);
+ htsmsg_add_s64(*resp, "muxes", total);
+ htsmsg_add_s64(*resp, "services", services);
+ return 0;
+}
+
void
api_wizard_init ( void )
{
{ "wizard/muxes/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_muxes },
{ "wizard/status/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_status },
{ "wizard/status/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_status },
+ { "wizard/status/progress", ACCESS_ADMIN, wizard_status_progress, NULL },
{ "wizard/mapping/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_mapping },
{ "wizard/mapping/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_mapping },
{ "wizard/start", ACCESS_ADMIN, wizard_start, NULL },
static const void *
mpegts_network_class_get_scanq_length ( void *ptr )
{
- static __thread int n;
+ static int n;
mpegts_mux_t *mm;
mpegts_network_t *mn = ptr;
tvheadend.wizard_start = function(page) {
- var w = null;
var tabMapping = {
hello: 'base_config',
login: 'access_entry',
buttons.splice(0, 0, prevBtn);
}
+ function progressupdate() {
+ var conf = this;
+ Ext.Ajax.request({
+ url: 'api/wizard/' + page + '/progress',
+ success: function(d) {
+ d = json_decode(d);
+ var t = conf.progress.initialConfig.text;
+ var i = d['progress'];
+ conf.progress.updateProgress(i, t + ' ' + Math.round(100*i) + '%');
+ conf.progress_task.delay(1000, progressupdate, conf);
+ for (var key in d)
+ if (key !== 'progress') {
+ var f = conf.form.findField(key);
+ if (f)
+ f.setValue(d[key]);
+ }
+ },
+ });
+ }
+
function pbuild(conf, panel) {
var data = conf.fullData;
var icon = getvalue(data, 'icon');
var text = getvalue(data, 'description');
+ var progress = getvalue(data, 'progress');
+ conf.form = panel.getForm();
var c = '';
if (icon)
c += '<img class="x-wizard-icon" src="' + icon + '"/>';
html: c
});
panel.insert(0, p);
+ if (progress) {
+ conf.progress = new Ext.ProgressBar({
+ text: progress,
+ style: 'margin: 5px 0 15px;'
+ });
+ panel.insert(1, conf.progress);
+ conf.progress_task = new Ext.util.DelayedTask(progressupdate, conf);
+ conf.progress_task.delay(1000);
+ }
}
function build(d) {
tvheadend.wizard = page;
- var delay = 1000;
if (tvheadend.wizard_delayed_activation == null) {
- tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask();
- delay = 1;
- }
- tvheadend.wizard_delayed_activation.delay(1000, activate_tab);
+ tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask(activate_tab);
+ tvheadend.wizard_delayed_activation.delay(1000);
tvheadend.Ajax({
url: 'api/wizard/' + page + '/load',
#define LAST_BUTTON() SPECIAL_PROP("page_last", empty_get)
#define ICON() SPECIAL_PROP("icon", icon_get)
#define DESCRIPTION(page) SPECIAL_PROP("description", wizard_description_##page)
+#define PROGRESS(fcn) SPECIAL_PROP("progress", fcn)
#define DESCRIPTION_FCN(page, desc) \
static const void *wizard_description_##page(void *o) \
*/
typedef struct wizard_muxes {
+ char lang [64];
property_t props [WIZARD_NETWORKS * 3 + 10];
char network [WIZARD_NETWORKS][64];
char networkid [WIZARD_NETWORKS][UUID_HEX_SIZE];
}
}
+static const void *muxes_progress_get(void *o)
+{
+ wizard_page_t *p = o;
+ wizard_muxes_t *w = p->aux;
+ snprintf(prop_sbuf, PROP_SBUF_LEN, "%s", tvh_gettext_lang(w->lang, N_("Scan progress")));
+ return &prop_sbuf_ptr;
+}
+
#define MUXES(num) { \
.type = PT_STR, \
.id = "network" STRINGIFY(num), \
ic->ic_properties = w->props;
ic->ic_save = muxes_save;
page->free = muxes_free;
+ snprintf(w->lang, sizeof(w->lang), "%s", lang ?: "");
for (idx = 0; idx < ARRAY_SIZE(props); idx++)
w->props[idx] = props[idx];
*/
DESCRIPTION_FCN(status, N_("\
-Show the scan status.\
+Show the scan status.\n\
+Please, wait until the scan finishes.\
"))
wizard_page_t *wizard_status(const char *lang)
{
+ static const property_group_t groups[] = {
+ {
+ .name = "",
+ .number = 1,
+ },
+ {}
+ };
static const property_t props[] = {
{
.type = PT_STR,
.id = "muxes",
.name = N_("Found muxes"),
.desc = N_("Number of muxes found."),
- .get = hello_get_network,
- .set = hello_set_network,
+ .get = empty_get,
+ .opts = PO_RDONLY,
+ .group = 1,
},
{
.type = PT_STR,
.id = "services",
.name = N_("Found services"),
.desc = N_("Total number of services found."),
- .get = hello_get_network,
- .set = hello_set_network,
+ .get = empty_get,
+ .opts = PO_RDONLY,
+ .group = 1,
},
+ PROGRESS(muxes_progress_get),
ICON(),
DESCRIPTION(status),
PREV_BUTTON(muxes),
wizard_page_t *page = page_init("status", "wizard_status", N_("Scan status"));
idclass_t *ic = (idclass_t *)page->idnode.in_class;
ic->ic_properties = props;
+ ic->ic_groups = groups;
return page;
}