Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bouquet: move 'rescan' trigger from table to toolbar button
  • Loading branch information
perexg committed Jun 1, 2016
1 parent b65beb3 commit 8e637f9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 43 deletions.
36 changes: 36 additions & 0 deletions src/api/api_bouquet.c
Expand Up @@ -81,13 +81,49 @@ api_bouquet_create
return 0;
}

static int
api_bouquet_scan
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
htsmsg_field_t *f;
htsmsg_t *uuids;
bouquet_t *bq;
const char *uuid;

if (!(f = htsmsg_field_find(args, "uuid")))
return -EINVAL;
if ((uuids = htsmsg_field_get_list(f))) {
HTSMSG_FOREACH(f, uuids) {
if (!(uuid = htsmsg_field_get_str(f))) continue;
pthread_mutex_lock(&global_lock);
bq = bouquet_find_by_uuid(uuid);
if (bq)
bouquet_scan(bq);
pthread_mutex_unlock(&global_lock);
}
} else if ((uuid = htsmsg_field_get_str(f))) {
pthread_mutex_lock(&global_lock);
bq = bouquet_find_by_uuid(uuid);
if (bq)
bouquet_scan(bq);
pthread_mutex_unlock(&global_lock);
if (!bq)
return -ENOENT;
} else {
return -EINVAL;
}

return 0;
}

void api_bouquet_init ( void )
{
static api_hook_t ah[] = {
{ "bouquet/list", ACCESS_ADMIN, api_bouquet_list, NULL },
{ "bouquet/class", ACCESS_ADMIN, api_idnode_class, (void*)&bouquet_class },
{ "bouquet/grid", ACCESS_ADMIN, api_idnode_grid, api_bouquet_grid },
{ "bouquet/create", ACCESS_ADMIN, api_bouquet_create, NULL },
{ "bouquet/scan", ACCESS_ADMIN, api_bouquet_scan, NULL },

{ NULL },
};
Expand Down
16 changes: 7 additions & 9 deletions src/api/api_mpegts.c
Expand Up @@ -151,21 +151,19 @@ api_mpegts_network_scan
if ((uuids = htsmsg_field_get_list(f))) {
HTSMSG_FOREACH(f, uuids) {
if (!(uuid = htsmsg_field_get_str(f))) continue;
pthread_mutex_lock(&global_lock);
mn = mpegts_network_find(uuid);
if (mn) {
pthread_mutex_lock(&global_lock);
if (mn)
mpegts_network_scan(mn);
pthread_mutex_unlock(&global_lock);
}
pthread_mutex_unlock(&global_lock);
}
} else if ((uuid = htsmsg_field_get_str(f))) {
pthread_mutex_lock(&global_lock);
mn = mpegts_network_find(uuid);
if (mn) {
pthread_mutex_lock(&global_lock);
if (mn)
mpegts_network_scan(mn);
pthread_mutex_unlock(&global_lock);
}
else
pthread_mutex_unlock(&global_lock);
if (!mn)
return -ENOENT;
} else {
return -EINVAL;
Expand Down
53 changes: 19 additions & 34 deletions src/bouquet.c
Expand Up @@ -609,6 +609,24 @@ bouquet_change_comment ( bouquet_t *bq, const char *comment, int replace )
bq->bq_saveflag = 1;
}

/*
*
*/
void
bouquet_scan ( bouquet_t *bq )
{
void mpegts_mux_bouquet_rescan ( const char *src, const char *extra );
void iptv_bouquet_trigger_by_uuid( const char *uuid );
#if ENABLE_IPTV
if (bq->bq_src && strncmp(bq->bq_src, "iptv-network://", 15) == 0)
return iptv_bouquet_trigger_by_uuid(bq->bq_src + 15);
#endif
if (bq->bq_src && strncmp(bq->bq_src, "exturl://", 9) == 0)
return bouquet_download_trigger(bq);
mpegts_mux_bouquet_rescan(bq->bq_src, bq->bq_comment);
bq->bq_rescan = 0;
}

/* **************************************************************************
* Class definition
* **************************************************************************/
Expand Down Expand Up @@ -654,37 +672,13 @@ bouquet_class_get_list(void *o, const char *lang)
return m;
}

static void
bouquet_class_rescan_notify0 ( bouquet_t *bq, const char *lang )
{
void mpegts_mux_bouquet_rescan ( const char *src, const char *extra );
void iptv_bouquet_trigger_by_uuid( const char *uuid );
#if ENABLE_IPTV
if (bq->bq_src && strncmp(bq->bq_src, "iptv-network://", 15) == 0)
return iptv_bouquet_trigger_by_uuid(bq->bq_src + 15);
#endif
if (bq->bq_src && strncmp(bq->bq_src, "exturl://", 9) == 0)
return bouquet_download_trigger(bq);
mpegts_mux_bouquet_rescan(bq->bq_src, bq->bq_comment);
bq->bq_rescan = 0;
}

static void
bouquet_class_rescan_notify ( void *obj, const char *lang )
{
bouquet_t *bq = obj;

if (bq->bq_rescan)
bouquet_class_rescan_notify0(bq, lang);
}

static void
bouquet_class_enabled_notify ( void *obj, const char *lang )
{
bouquet_t *bq = obj;

if (bq->bq_enabled)
bouquet_class_rescan_notify0(bq, lang);
bouquet_scan(bq);
bouquet_map_to_channels(bq);
}

Expand Down Expand Up @@ -976,15 +970,6 @@ const idclass_t bouquet_class = {
.off = offsetof(bouquet_t, bq_enabled),
.notify = bouquet_class_enabled_notify,
},
{
.type = PT_BOOL,
.id = "rescan",
.name = N_("Rescan"),
.desc = N_("Rescan the mux for changes to the bouquet."),
.off = offsetof(bouquet_t, bq_rescan),
.notify = bouquet_class_rescan_notify,
.opts = PO_NOSAVE,
},
{
.type = PT_BOOL,
.id = "maptoch",
Expand Down
1 change: 1 addition & 0 deletions src/bouquet.h
Expand Up @@ -102,6 +102,7 @@ void bouquet_notify_channels(bouquet_t *bq);
void bouquet_add_service(bouquet_t *bq, service_t *s, uint64_t lcn, const char *tag);
void bouquet_completed(bouquet_t *bq, uint32_t seen);
void bouquet_change_comment(bouquet_t *bq, const char *comment, int replace);
void bouquet_scan(bouquet_t *bq);

uint64_t bouquet_get_channel_number(bouquet_t *bq, service_t *t);

Expand Down
35 changes: 35 additions & 0 deletions src/webui/static/app/cteditor.js
Expand Up @@ -35,12 +35,46 @@ tvheadend.bouquet = function(panel, index)
var elist = 'enabled,rescan,ext_url,' + list0;
var alist = 'enabled,ext_url,' + list0;

var scanButton = {
name: 'scan',
builder: function() {
return new Ext.Toolbar.Button({
tooltip: _('Rescan the mux for changes to the bouquet.'),
iconCls: 'find',
text: _('Force Scan'),
disabled: true
});
},
callback: function(conf, e, store, select) {
var r = select.getSelections();
if (r && r.length > 0) {
var uuids = [];
for (var i = 0; i < r.length; i++)
uuids.push(r[i].id);
tvheadend.Ajax({
url: 'api/bouquet/scan',
params: {
uuid: Ext.encode(uuids)
},
success: function(d) {
store.reload();
}
});
}
}
};

function selected(s, abuttons) {
abuttons.scan.setDisabled(!s || s.length <= 0);
}

tvheadend.idnode_grid(panel, {
url: 'api/bouquet',
titleS: _('Bouquet'),
titleP: _('Bouquets'),
iconCls: 'bouquets',
tabIndex: index,
tbar: [scanButton],
columns: {
enabled: { width: 50 },
rescan: { width: 50 },
Expand All @@ -61,6 +95,7 @@ tvheadend.bouquet = function(panel, index)
},
del: true,
edit: { params: { list: elist } },
selected: selected,
sort: {
field: 'name',
direction: 'ASC'
Expand Down

0 comments on commit 8e637f9

Please sign in to comment.