]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
bouquet: move 'rescan' trigger from table to toolbar button
authorJaroslav Kysela <perex@perex.cz>
Wed, 1 Jun 2016 12:42:26 +0000 (14:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 1 Jun 2016 12:42:26 +0000 (14:42 +0200)
src/api/api_bouquet.c
src/api/api_mpegts.c
src/bouquet.c
src/bouquet.h
src/webui/static/app/cteditor.js

index 6ed798f6892a390da19ee95887e9b8d4c654cdd1..21ab504d4fbd896a894a424f2afce61ebb9bee1e 100644 (file)
@@ -81,6 +81,41 @@ 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[] = {
@@ -88,6 +123,7 @@ void api_bouquet_init ( void )
     { "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 },
   };
index 348e3e43335679a0ba8d53ff3354a35fc726a45d..cfd684fb33fc7620ba87ba49928aeb82f94bc43e 100644 (file)
@@ -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;
index 20a355fc786691bfe1f79d92fa836d7fe67388f1..aa9379409f33f24a879b69e7d9113a5ac44a126f 100644 (file)
@@ -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
  * **************************************************************************/
@@ -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);
 }
 
@@ -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",
index cf4cdb3de50d480387ec1e6d31d4e67d1c3b9573..900637e0bd954e9779f11aa362386841545ec53b 100644 (file)
@@ -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);
 
index d33f4a7c851c10daf3b6e889f542a88e2d64d4b2..f90dcbebeba5b5904e15b5c0100c1ce7e9324043 100644 (file)
@@ -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 },
@@ -61,6 +95,7 @@ tvheadend.bouquet = function(panel, index)
         },
         del: true,
         edit: { params: { list: elist } },
+        selected: selected,
         sort: {
           field: 'name',
           direction: 'ASC'