Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wizard: implement mapping / add channels dialogs
  • Loading branch information
perexg committed Jan 20, 2016
1 parent 565f564 commit 98e106b
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/api/api_wizard.c
Expand Up @@ -120,6 +120,8 @@ api_wizard_init ( void )
{ "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/channels/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_channels },
{ "wizard/channels/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_channels },
{ "wizard/start", ACCESS_ADMIN, wizard_start, NULL },
{ "wizard/cancel", ACCESS_ADMIN, wizard_cancel, NULL },
{ NULL },
Expand Down
2 changes: 1 addition & 1 deletion src/service_mapper.c
Expand Up @@ -59,7 +59,7 @@ service_mapper_status ( void )
/*
* Start a new mapping
*/
static void
void
service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids )
{
int e, tr, qd = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/service_mapper.h
Expand Up @@ -51,6 +51,9 @@ extern service_mapper_t service_mapper_conf;
void service_mapper_init ( void );
void service_mapper_done ( void );

// Start service mapper
void service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids );

// Stop pending services (remove from Q)
void service_mapper_stop ( void );

Expand Down
1 change: 1 addition & 0 deletions src/webui/static/app/mpegts.js
Expand Up @@ -308,6 +308,7 @@ tvheadend.services = function(panel, index)
conf.selected = null;
}
tvheadend.idnode_grid(panel, {
id: 'services',
url: 'api/mpegts/service',
titleS: _('Service'),
titleP: _('Services'),
Expand Down
9 changes: 5 additions & 4 deletions src/webui/static/app/wizard.js
Expand Up @@ -12,7 +12,8 @@ tvheadend.wizard_start = function(page) {
network: 'tvadapters',
muxes: 'mpegts_network',
status: 'status_streams',
mapping: 'channels',
mapping: 'services',
channels: 'channels'
}

function cancel(conf) {
Expand Down Expand Up @@ -165,9 +166,9 @@ tvheadend.wizard_start = function(page) {

tvheadend.wizard = page;

if (tvheadend.wizard_delayed_activation == null) {
tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask(activate_tab);
tvheadend.wizard_delayed_activation.delay(1000);
if (tvheadend.wizard_delayed_activation == null)
tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask();
tvheadend.wizard_delayed_activation.delay(1000, activate_tab);

tvheadend.Ajax({
url: 'api/wizard/' + page + '/load',
Expand Down
121 changes: 98 additions & 23 deletions src/wizard.c
Expand Up @@ -22,6 +22,7 @@
#include "settings.h"
#include "input.h"
#include "input/mpegts/iptv/iptv_private.h"
#include "service_mapper.h"
#include "wizard.h"

/*
Expand Down Expand Up @@ -103,21 +104,6 @@ static wizard_page_t *page_init
return page;
}

/*
*
*/

static const void *hello_get_network(void *o)
{
strcpy(prop_sbuf, "Test123");
return &prop_sbuf_ptr;
}

static int hello_set_network(void *o, const void *v)
{
return 0;
}

/*
* Hello
*/
Expand Down Expand Up @@ -994,29 +980,118 @@ wizard_page_t *wizard_status(const char *lang)
* Service Mapping
*/

typedef struct wizard_mapping {
int mapall;
int provtags;
int nettags;
} wizard_mapping_t;

static void mapping_save(idnode_t *in)
{
wizard_page_t *p = (wizard_page_t *)in;
wizard_mapping_t *w = p->aux;
service_mapper_conf_t conf;

if (!w->mapall)
return;
memset(&conf, 0, sizeof(conf));
conf.type_tags = 1;
conf.encrypted = 1;
conf.provider_tags = w->provtags;
conf.network_tags = w->nettags;
service_mapper_start(&conf, NULL);
}

#define MAPPING_FCN(name) \
static const void *mapping_get_##name(void *o) \
{ \
static int n; \
wizard_page_t *p = o; \
wizard_mapping_t *w = p->aux; \
n = w->name; \
return &n; \
} \
static int mapping_set_##name(void *o, const void *v) \
{ \
wizard_page_t *p = o; \
wizard_mapping_t *w = p->aux; \
w->name = *(int *)v; \
return 1; \
}

MAPPING_FCN(mapall)
MAPPING_FCN(provtags)
MAPPING_FCN(nettags)

DESCRIPTION_FCN(mapping, N_("\
Do the service mapping to channels.\
Map all discovered services to channels.\n\
Note: You may ommit this step (do not check the map all services) and\
do the service to channel mapping manually.\n\
"))


wizard_page_t *wizard_mapping(const char *lang)
{
static const property_t props[] = {
{
.type = PT_STR,
.id = "pnetwork",
.name = N_("Select network"),
.desc = N_("Select a Network."),
.get = hello_get_network,
.set = hello_set_network,
.type = PT_BOOL,
.id = "mapall",
.name = N_("Map all services"),
.get = mapping_get_mapall,
.set = mapping_set_mapall,
},
{
.type = PT_BOOL,
.id = "provtags",
.name = N_("Create provider tags"),
.get = mapping_get_provtags,
.set = mapping_set_provtags,
},
{
.type = PT_BOOL,
.id = "nettags",
.name = N_("Create network tags"),
.get = mapping_get_nettags,
.set = mapping_set_nettags,
},
ICON(),
DESCRIPTION(mapping),
PREV_BUTTON(status),
NEXT_BUTTON(channels),
LAST_BUTTON(),
{}
};
wizard_page_t *page = page_init("mapping", "wizard_mapping", N_("Service mapping"));
idclass_t *ic = (idclass_t *)page->idnode.in_class;
wizard_mapping_t *w;
ic->ic_properties = props;
ic->ic_save = mapping_save;
page->aux = w = calloc(1, sizeof(wizard_mapping_t));
w->provtags = service_mapper_conf.d.provider_tags;
w->nettags = service_mapper_conf.d.network_tags;
return page;
}

/*
* Discovered channels
*/

DESCRIPTION_FCN(channels, N_("\
You are finished now.\n\
You may further customize your settings by editing channel numbers etc.\
"))


wizard_page_t *wizard_channels(const char *lang)
{
static const property_t props[] = {
ICON(),
DESCRIPTION(channels),
PREV_BUTTON(mapping),
LAST_BUTTON(),
{}
};
wizard_page_t *page = page_init("mapping", "wizard_service_map", N_("Service mapping"));
wizard_page_t *page = page_init("channels", "wizard_channels", N_("Service mapping"));
idclass_t *ic = (idclass_t *)page->idnode.in_class;
ic->ic_properties = props;
return page;
Expand Down
1 change: 1 addition & 0 deletions src/wizard.h
Expand Up @@ -37,5 +37,6 @@ wizard_page_t *wizard_network(const char *lang);
wizard_page_t *wizard_muxes(const char *lang);
wizard_page_t *wizard_status(const char *lang);
wizard_page_t *wizard_mapping(const char *lang);
wizard_page_t *wizard_channels(const char *lang);

#endif /* __TVH_WIZARD_H__ */

0 comments on commit 98e106b

Please sign in to comment.