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/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 },
};
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;
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
* **************************************************************************/
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);
}
.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",
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);
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 },
},
del: true,
edit: { params: { list: elist } },
+ selected: selected,
sort: {
field: 'name',
direction: 'ASC'