]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
comet events - an attempt to clean them
authorJaroslav Kysela <perex@perex.cz>
Tue, 2 Sep 2014 16:16:18 +0000 (18:16 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Sep 2014 14:48:59 +0000 (16:48 +0200)
29 files changed:
src/access.c
src/channels.c
src/dvr/dvr.h
src/dvr/dvr_autorec.c
src/dvr/dvr_db.c
src/dvr/dvr_inotify.c
src/dvr/dvr_rec.c
src/esfilter.c
src/htsmsg.c
src/htsmsg.h
src/idnode.c
src/idnode.h
src/input.c
src/input/mpegts/dvb_psi.c
src/input/mpegts/linuxdvb/linuxdvb_adapter.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/mpegts_input.c
src/input/mpegts/mpegts_network_scan.c
src/input/mpegts/mpegts_service.c
src/input/mpegts/satip/satip_satconf.c
src/service.c
src/webui/static/app/acleditor.js
src/webui/static/app/chconf.js
src/webui/static/app/comet.js
src/webui/static/app/dvr.js
src/webui/static/app/esfilter.js
src/webui/static/app/idnode.js
src/webui/static/app/mpegts.js
src/webui/static/app/tvadapters.js

index fa8ec0a8522c7770d1e3b8f590ca797d42ceea55..442eb4ab67ae94c5a3b34ea089892e875c261bee 100644 (file)
@@ -912,6 +912,7 @@ access_entry_dvr_config_get(void *o)
 const idclass_t access_entry_class = {
   .ic_class      = "access",
   .ic_caption    = "Access",
+  .ic_event      = "access",
   .ic_save       = access_entry_class_save,
   .ic_get_title  = access_entry_class_get_title,
   .ic_delete     = access_entry_class_delete,
index 3dc23f4becbdc98f7cfdd24a785e5c41b61609f2..a8921116d072c85d608d7c4b43f36de294070134 100644 (file)
@@ -275,6 +275,7 @@ channel_class_epggrab_list ( void *o )
 const idclass_t channel_class = {
   .ic_class      = "channel",
   .ic_caption    = "Channel",
+  .ic_event      = "channel",
   .ic_save       = channel_class_save,
   .ic_get_title  = channel_class_get_title,
   .ic_delete     = channel_class_delete,
@@ -846,6 +847,7 @@ channel_tag_class_get_list(void *o)
 const idclass_t channel_tag_class = {
   .ic_class      = "channeltag",
   .ic_caption    = "Channel Tag",
+  .ic_event      = "channeltag",
   .ic_save       = channel_tag_class_save,
   .ic_get_title  = channel_tag_class_get_title,
   .ic_delete     = channel_tag_class_delete,
index b01b4b7305622f94da1010f93f6c0149ec855e87..dbbe8f19d555d6fcf70df71b1f1155a43fb4e405 100644 (file)
@@ -312,8 +312,6 @@ void dvr_config_save(dvr_config_t *cfg);
 
 int dvr_entry_get_mc( dvr_entry_t *de);
 
-void dvr_entry_notify(dvr_entry_t *de);
-
 void dvr_entry_save(dvr_entry_t *de);
 
 const char *dvr_entry_status(dvr_entry_t *de);
index bc736652591e9bad9327dd885acef2e3cda2072f..077547fd7669474fbe12b819be6307518276a9eb 100644 (file)
@@ -31,7 +31,6 @@
 #include "tvheadend.h"
 #include "settings.h"
 #include "dvr.h"
-#include "notify.h"
 #include "dtable.h"
 #include "epg.h"
 
@@ -683,6 +682,7 @@ dvr_autorec_entry_class_content_type_list(void *o)
 const idclass_t dvr_autorec_entry_class = {
   .ic_class      = "dvrautorec",
   .ic_caption    = "DVR Auto-Record Entry",
+  .ic_event      = "dvrautorec",
   .ic_save       = dvr_autorec_entry_class_save,
   .ic_get_title  = dvr_autorec_entry_class_get_title,
   .ic_delete     = dvr_autorec_entry_class_delete,
@@ -921,15 +921,9 @@ void
 autorec_destroy_by_channel(channel_t *ch, int delconf)
 {
   dvr_autorec_entry_t *dae;
-  htsmsg_t *m;
 
   while((dae = LIST_FIRST(&ch->ch_autorecs)) != NULL)
     autorec_entry_destroy(dae, delconf);
-
-  /* Notify web clients that we have messed with the tables */
-  m = htsmsg_create_map();
-  htsmsg_add_u32(m, "reload", 1);
-  notify_by_msg("autorec", m);
 }
 
 /*
@@ -939,17 +933,12 @@ void
 autorec_destroy_by_channel_tag(channel_tag_t *ct, int delconf)
 {
   dvr_autorec_entry_t *dae;
-  htsmsg_t *m;
 
   while((dae = LIST_FIRST(&ct->ct_autorecs)) != NULL) {
     LIST_REMOVE(dae, dae_channel_tag_link);
     dae->dae_channel_tag = NULL;
+    idnode_notify_simple(&dae->dae_id);
     if (delconf)
       dvr_autorec_save(dae);
   }
-
-  /* Notify web clients that we have messed with the tables */
-  m = htsmsg_create_map();
-  htsmsg_add_u32(m, "reload", 1);
-  notify_by_msg("autorec", m);
 }
index dae4f84de4ca34cc068444af97985566ab19a740..b0744586eafcc086d4425c3bbf983ce7281da439 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "tvheadend.h"
 #include "dvr.h"
-#include "notify.h"
 #include "htsp_server.h"
 #include "streaming.h"
 #include "intlconv.h"
@@ -209,22 +208,6 @@ dvr_entry_schedstatus(dvr_entry_t *de)
   }
 }
 
-/**
- *
- */
-void
-dvr_entry_notify(dvr_entry_t *de)
-{
-  htsmsg_t *m = htsmsg_create_map();
-
-  htsmsg_add_u32(m, "updateEntry", 1);
-  htsmsg_add_str(m, "uuid", idnode_uuid_as_str(&de->de_id));
-  htsmsg_add_str(m, "status", dvr_entry_status(de));
-  htsmsg_add_str(m, "schedstate", dvr_entry_schedstatus(de));
-  notify_by_msg("dvrdb", m);
-}
-
-
 /**
  *
  */
@@ -809,9 +792,8 @@ static dvr_entry_t *_dvr_entry_update
 
   /* Save changes */
   if (save) {
-    dvr_entry_save(de);
+    idnode_changed(&de->de_id);
     htsp_dvr_entry_update(de);
-    dvr_entry_notify(de);
     tvhlog(LOG_INFO, "dvr", "\"%s\" on \"%s\": Updated Timer",
            lang_str_get(de->de_title, NULL), DVR_CH_NAME(de));
   }
@@ -920,7 +902,7 @@ void dvr_event_updated ( epg_broadcast_t *e )
  *
  */
 static void
-dvr_stop_recording(dvr_entry_t *de, int stopcode, int delconf)
+dvr_stop_recording(dvr_entry_t *de, int stopcode, int saveconf)
 {
   dvr_config_t *cfg = de->de_config;
 
@@ -936,10 +918,12 @@ dvr_stop_recording(dvr_entry_t *de, int stopcode, int delconf)
         lang_str_get(de->de_title, NULL), DVR_CH_NAME(de),
         dvr_entry_status(de));
 
-  if (delconf)
+  if (saveconf)
+    idnode_changed(&de->de_id);
+  else
+    idnode_notify_simple(&de->de_id);
     dvr_entry_save(de);
   htsp_dvr_entry_update(de);
-  dvr_entry_notify(de);
 
   gtimer_arm_abs(&de->de_timer, dvr_timer_expire, de, 
                 de->de_stop + cfg->dvr_retention_days * 86400);
@@ -971,7 +955,7 @@ dvr_timer_start_recording(void *aux)
   tvhlog(LOG_INFO, "dvr", "\"%s\" on \"%s\" recorder starting",
         lang_str_get(de->de_title, NULL), DVR_CH_NAME(de));
 
-  dvr_entry_notify(de);
+  idnode_changed(&de->de_id);
   htsp_dvr_entry_update(de);
   dvr_rec_subscribe(de);
 
@@ -1570,6 +1554,7 @@ dvr_entry_class_content_type_list(void *o)
 const idclass_t dvr_entry_class = {
   .ic_class     = "dvrentry",
   .ic_caption   = "DVR Entry",
+  .ic_event     = "dvrentry",
   .ic_save      = dvr_entry_class_save,
   .ic_get_title = dvr_entry_class_get_title,
   .ic_delete    = dvr_entry_class_delete,
@@ -2079,7 +2064,6 @@ dvr_config_class_charset_list(void *o)
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "type",  "api");
   htsmsg_add_str(m, "uri",   "intlconv/charsets");
-  htsmsg_add_str(m, "event", "charsets");
   return m;
 }
 
@@ -2099,6 +2083,7 @@ dvr_config_class_cache_list(void *o)
 const idclass_t dvr_config_class = {
   .ic_class      = "dvrconfig",
   .ic_caption    = "DVR Configuration Profile",
+  .ic_event      = "dvrconfig",
   .ic_save       = dvr_config_class_save,
   .ic_get_title  = dvr_config_class_get_title,
   .ic_delete     = dvr_config_class_delete,
index ba439f969f12c91b22b72f763b57d64044d9a681..b2226b52e9f0fb1414e88497fc10fbefc331610e 100644 (file)
@@ -211,7 +211,7 @@ _dvr_inotify_moved
     dvr_inotify_del(de);
   
   htsp_dvr_entry_update(de);
-  dvr_entry_notify(de);
+  idnode_notify_simple(&de->de_id);
 }
 
 /*
@@ -239,7 +239,7 @@ _dvr_inotify_moved_all
 
   while ((de = LIST_FIRST(&die->entries))) {
     htsp_dvr_entry_update(de);
-    dvr_entry_notify(de);
+    idnode_notify_simple(&de->de_id);
     dvr_inotify_del(de);
   }
 }
index 45146f1077f7344bd41bddd7025b1a6c5ba4ccfb..814ea59e4a10ee1e521e8e70b33919569f1ed73b 100644 (file)
@@ -300,7 +300,7 @@ dvr_rec_set_state(dvr_entry_t *de, dvr_rs_state_t newstate, int error)
       de->de_errors++;
   }
   if (notify)
-    dvr_entry_notify(de);
+    idnode_notify_simple(&de->de_id);
 }
 
 /**
@@ -521,9 +521,8 @@ dvr_thread(void *aux)
         dvr_rec_set_state(de, DVR_RS_WAIT_PROGRAM_START, 0);
         if(dvr_rec_start(de, sm->sm_data) == 0) {
           started = 1;
-          dvr_entry_notify(de);
+          idnode_changed(&de->de_id);
           htsp_dvr_entry_update(de);
-          dvr_entry_save(de);
         }
         pthread_mutex_unlock(&global_lock);
       } 
index ed4f6d02c979d7125147e864b6f457accef59ff8..2a5f1f55eda519472a0fad0956479fbfa1adb3f9 100644 (file)
@@ -587,6 +587,7 @@ esfilter_class_action_enum(void *o)
 const idclass_t esfilter_class = {
   .ic_class      = "esfilter",
   .ic_caption    = "Elementary Stream Filter",
+  .ic_event      = "esfilter",
   .ic_save       = esfilter_class_save,
   .ic_get_title  = esfilter_class_get_title,
   .ic_delete     = esfilter_class_delete,
index 6ef0259ac0072aa3ce101b0f799fcec54aed74c9..1f9744f9d396e793313e34447274b4cf440ae2de 100644 (file)
@@ -261,6 +261,25 @@ htsmsg_add_str(htsmsg_t *msg, const char *name, const char *str)
   f->hmf_str = strdup(str);
 }
 
+/*
+ *
+ */
+int
+htsmsg_set_str(htsmsg_t *msg, const char *name, const char *str)
+{
+  htsmsg_field_t *f = htsmsg_field_find(msg, name);
+  if (!f)
+    f = htsmsg_field_add(msg, name, HMF_STR, HMF_ALLOCED | HMF_NAME_ALLOCED);
+  else {
+    if (f->hmf_type != HMF_STR)
+      return 1;
+    if(f->hmf_flags & HMF_ALLOCED)
+      free((void *)f->hmf_str);
+  }
+  f->hmf_str = strdup(str);
+  return 0;
+}
+
 /*
  *
  */
index fb0e0d604102bf81ff8fa72992524397a2b36e5c..479a39a31bd6ac558ba8306c3e9bdfac7826bfe8 100644 (file)
@@ -135,6 +135,11 @@ void htsmsg_add_s64(htsmsg_t *msg, const char *name,  int64_t s64);
  */
 void htsmsg_add_str(htsmsg_t *msg, const char *name, const char *str);
 
+/**
+ * Add/update a string field
+ */
+int  htsmsg_set_str(htsmsg_t *msg, const char *name, const char *str);
+
 /**
  * Add an field where source is a list or map message.
  */
index 0ab8e0b0650265955a93b9023f02bb1fb0d65672..1fa741b2190cc806f152d29171a04d555f329352 100644 (file)
@@ -155,7 +155,7 @@ idnode_insert(idnode_t *in, const char *uuid, const idclass_t *class, int flags)
   idclass_register(class); // Note: we never actually unregister
 
   /* Fire event */
-  idnode_notify(in, NULL, 0, 1);
+  idnode_notify_simple(in);
 
   return 0;
 }
@@ -169,7 +169,7 @@ idnode_unlink(idnode_t *in)
   lock_assert(&global_lock);
   RB_REMOVE(&idnodes, in, in_link);
   tvhtrace("idnode", "unlink node %s", idnode_uuid_as_str(in));
-  idnode_notify(in, NULL, 0, 1);
+  idnode_notify_simple(in);
 }
 
 /**
@@ -826,7 +826,7 @@ idnode_write0 ( idnode_t *self, htsmsg_t *c, int optmask, int dosave )
   if (save && dosave)
     idnode_savefn(self);
   if (dosave)
-    idnode_notify(self, NULL, 0, 0);
+    idnode_notify_simple(self);
   // Note: always output event if "dosave", reason is that UI updates on
   //       these, but there are some subtle cases where it will expect
   //       an update and not get one. This include fields being set for
@@ -835,6 +835,13 @@ idnode_write0 ( idnode_t *self, htsmsg_t *c, int optmask, int dosave )
   return save;
 }
 
+void
+idnode_changed( idnode_t *self )
+{
+  idnode_notify_simple(self);
+  idnode_savefn(self);
+}
+
 /* **************************************************************************
  * Read
  * *************************************************************************/
@@ -902,6 +909,17 @@ idclass_get_class (const idclass_t *idc)
   return NULL;
 }
 
+static const char *
+idclass_get_event (const idclass_t *idc)
+{
+  while (idc) {
+    if (idc->ic_event)
+      return idc->ic_event;
+    idc = idc->ic_super;
+  }
+  return NULL;
+}
+
 static const char *
 idclass_get_order (const idclass_t *idc)
 {
@@ -992,6 +1010,8 @@ idclass_serialize0(const idclass_t *idc, htsmsg_t *list, int optmask)
     htsmsg_add_str(m, "caption", s);
   if ((s = idclass_get_class(idc)))
     htsmsg_add_str(m, "class", s);
+  if ((s = idclass_get_event(idc)))
+    htsmsg_add_str(m, "event", s);
   if ((s = idclass_get_order(idc)))
     htsmsg_add_str(m, "order", s);
   if ((p = idclass_get_property_groups(idc)))
@@ -1022,6 +1042,8 @@ idnode_serialize0(idnode_t *self, htsmsg_t *list, int optmask)
     htsmsg_add_str(m, "caption", s);
   if ((s = idclass_get_class(idc)))
     htsmsg_add_str(m, "class", s);
+  if ((s = idclass_get_event(idc)))
+    htsmsg_add_str(m, "event", s);
 
   htsmsg_add_msg(m, "params", idnode_params(idc, self, list, optmask));
 
@@ -1029,9 +1051,23 @@ idnode_serialize0(idnode_t *self, htsmsg_t *list, int optmask)
 }
 
 /* **************************************************************************
- * Notifcation
+ * Notification
  * *************************************************************************/
 
+/**
+ * Delayed notification
+ */
+static void
+idnode_notify_delayed ( idnode_t *in, const char *uuid, const char *event )
+{
+  pthread_mutex_lock(&idnode_mutex);
+  if (!idnode_queue)
+    idnode_queue = htsmsg_create_map();
+  htsmsg_set_str(idnode_queue, uuid, event);
+  pthread_cond_signal(&idnode_cond);
+  pthread_mutex_unlock(&idnode_mutex);
+}
+
 /**
  * Update internal event pipes
  */
@@ -1041,11 +1077,8 @@ idnode_notify_event ( idnode_t *in )
   const idclass_t *ic = in->in_class;
   const char *uuid = idnode_uuid_as_str(in);
   while (ic) {
-    if (ic->ic_event) {
-      htsmsg_t *m = htsmsg_create_map();
-      htsmsg_add_str(m, "uuid", uuid);
-      notify_by_msg(ic->ic_event, m);
-    }
+    if (ic->ic_event)
+      idnode_notify_delayed(in, uuid, ic->ic_event);
     ic = ic->ic_super;
   }
 }
@@ -1055,38 +1088,37 @@ idnode_notify_event ( idnode_t *in )
  */
 void
 idnode_notify
-  (idnode_t *in, const char *chn, int force, int event)
+  (idnode_t *in, int event)
 {
   const char *uuid = idnode_uuid_as_str(in);
 
   if (!tvheadend_running)
     return;
 
-  /* Forced */
-  if (chn || force) {
-    htsmsg_t *m = htsmsg_create_map();
-    htsmsg_add_str(m, "uuid", uuid);
-    notify_by_msg(chn ?: "idnodeUpdated", m);
+  /* Immediate */
+  if (!event) {
+
+    const idclass_t *ic = in->in_class;
+
+    while (ic) {
+      if (ic->ic_event) {
+        htsmsg_t *m = htsmsg_create_map();
+        htsmsg_add_str(m, "uuid", uuid);
+        notify_by_msg(ic->ic_event, m);
+      }
+      ic = ic->ic_super;
+    }
   
   /* Rate-limited */
   } else {
-    pthread_mutex_lock(&idnode_mutex);
-    if (!idnode_queue)
-      idnode_queue = htsmsg_create_map();
-    htsmsg_set_u32(idnode_queue, uuid, 1);
-    pthread_cond_signal(&idnode_cond);
-    pthread_mutex_unlock(&idnode_mutex);
-  }
-
-  /* Send event */
-  if (event)
     idnode_notify_event(in);
+  }
 }
 
 void
 idnode_notify_simple (void *in)
 {
-  idnode_notify(in, NULL, 0, 0);
+  idnode_notify(in, 1);
 }
 
 void
@@ -1095,7 +1127,7 @@ idnode_notify_title_changed (void *in)
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "uuid", idnode_uuid_as_str(in));
   htsmsg_add_str(m, "text", idnode_get_title(in));
-  notify_by_msg("idnodeUpdated", m);
+  notify_by_msg("title", m);
   idnode_notify_event(in);
 }
 
@@ -1108,6 +1140,7 @@ idnode_thread ( void *p )
   idnode_t *node;
   htsmsg_t *m, *q = NULL;
   htsmsg_field_t *f;
+  const char *event;
 
   pthread_mutex_lock(&idnode_mutex);
 
@@ -1126,13 +1159,13 @@ idnode_thread ( void *p )
     pthread_mutex_lock(&global_lock);
 
     HTSMSG_FOREACH(f, q) {
-      node = idnode_find(f->hmf_name, NULL);
-      m    = htsmsg_create_map();
+      node  = idnode_find(f->hmf_name, NULL);
+      event = htsmsg_field_get_str(f);
+      m     = htsmsg_create_map();
       htsmsg_add_str(m, "uuid", f->hmf_name);
-      if (node)
-        notify_by_msg("idnodeUpdated", m);
-      else
-        notify_by_msg("idnodeDeleted", m);      
+      if (!node)
+        htsmsg_add_u32(m, "removed", 1);
+      notify_by_msg(event, m);
     }
     
     /* Finished */
index 4a016d39b8dcf24f3923c2c2ff1ea86259b735d5..82c70245bfcc5e5d017bf631437de7a3eeddc0ba 100644 (file)
@@ -141,12 +141,13 @@ void          idnode_delete       (idnode_t *in);
 void          idnode_moveup       (idnode_t *in);
 void          idnode_movedown     (idnode_t *in);
 
+void          idnode_changed      (idnode_t *in);
+
 void         *idnode_find    (const char *uuid, const idclass_t *idc);
 idnode_set_t *idnode_find_all(const idclass_t *idc);
 
-#define idnode_updated(in) idnode_notify(in, NULL, 0, 0)
-void idnode_notify
-  (idnode_t *in, const char *chn, int force, int event);
+
+void idnode_notify (idnode_t *in, int event);
 void idnode_notify_simple (void *in);
 void idnode_notify_title_changed (void *in);
 
index b6f1eceba12de320e6ca6dce2507b3ae06dc3b85..7952cf2fecd4d6a91855763c38006ac941f3070d 100644 (file)
@@ -43,9 +43,6 @@ tvh_hardware_create0
   /* Load config */
   if (conf)
     idnode_load(&th->th_id, conf);
-
-  /* Update */
-  notify_reload("hardware");
   
   return o;
 }
@@ -60,7 +57,6 @@ tvh_hardware_delete ( tvh_hardware_t *th )
   // TODO
   LIST_REMOVE(th, th_link);
   idnode_unlink(&th->th_id);
-  notify_reload("hardware");
 }
 
 /*
index 79204e17a09be0590c3d547a698190396135ac53..90e4a7f020da7c261ed8e76e1982537c685c94ac 100644 (file)
@@ -989,8 +989,7 @@ dvb_sdt_callback
 
     /* Save details */
     if (save) {
-      idnode_updated(&s->s_id);
-      s->s_config_save((service_t*)s);
+      idnode_changed(&s->s_id);
       service_refresh_channel((service_t*)s);
     }
   }
index 1f5d8e705564af1abaeaad8e7c1f35a85efabc62..5c610fbfd8975701207aa31f4980f6fc6ea56f2d 100644 (file)
@@ -72,6 +72,7 @@ const idclass_t linuxdvb_adapter_class =
 {
   .ic_class      = "linuxdvb_adapter",
   .ic_caption    = "LinuxDVB Adapter",
+  .ic_event      = "linuxdvb_adapter",
   .ic_save       = linuxdvb_adapter_class_save,
   .ic_get_childs = linuxdvb_adapter_class_get_childs,
   .ic_get_title  = linuxdvb_adapter_class_get_title,
index 39fa40c939a9f56ee10ee0e02307827cffd1b74f..b89ae72d42af7b2a1a7c6bfc34a40f6f6f0d007a 100644 (file)
@@ -211,6 +211,7 @@ const idclass_t linuxdvb_satconf_class =
 {
   .ic_class      = "linuxdvb_satconf",
   .ic_caption    = "DVB-S Satconf",
+  .ic_event      = "linuxdvb_satconf",
   .ic_get_title  = linuxdvb_satconf_class_get_title,
   .ic_save       = linuxdvb_satconf_class_save,
   .ic_properties = (const property_t[]) {
@@ -1020,6 +1021,7 @@ const idclass_t linuxdvb_satconf_ele_class =
 {
   .ic_class      = "linuxdvb_satconf_ele",
   .ic_caption    = "Satconf",
+  .ic_event      = "linuxdvb_satconf_ele",
   .ic_get_title  = linuxdvb_satconf_ele_class_get_title,
   .ic_get_childs = linuxdvb_satconf_ele_class_get_childs,
   .ic_save       = linuxdvb_satconf_ele_class_save,
@@ -1205,6 +1207,7 @@ const idclass_t linuxdvb_diseqc_class =
 {
   .ic_class       = "linuxdvb_diseqc",
   .ic_caption     = "DiseqC",
+  .ic_event       = "linuxdvb_diseqc",
   .ic_get_title   = linuxdvb_diseqc_class_get_title,
   .ic_save        = linuxdvb_diseqc_class_save,
 };
index 96b2c176d531740e2329ad81078979a1fdeffd77..292c81a4e9963dca899215a9c7708cef13a9c793 100644 (file)
@@ -142,6 +142,7 @@ const idclass_t mpegts_input_class =
 {
   .ic_class      = "mpegts_input",
   .ic_caption    = "MPEGTS Input",
+  .ic_event      = "mpegts_input",
   .ic_get_title  = mpegts_input_class_get_title,
   .ic_properties = (const property_t[]){
     {
index 664db417469c1f15e42068873bb6e9add79dd8ff..94646ecd4e5521c9a24d8b1a6c71730d5aa09543 100644 (file)
@@ -27,8 +27,8 @@
 static void
 mpegts_network_scan_notify ( mpegts_mux_t *mm )
 {
-  idnode_updated(&mm->mm_id);
-  idnode_updated(&mm->mm_network->mn_id);
+  idnode_notify_simple(&mm->mm_id);
+  idnode_notify_simple(&mm->mm_network->mn_id);
 }
 
 static int
index 57c882e900c734497d30b6faaedeaeff45bdec6b..9b2310f2fac19d3d862787050629b21fa664ba94 100644 (file)
@@ -423,7 +423,9 @@ mpegts_service_create0
 {
   int r;
   char buf[256];
-  service_create0((service_t*)s, class, uuid, S_MPEG_TS, conf);
+
+  if (service_create0((service_t*)s, class, uuid, S_MPEG_TS, conf) == NULL)
+    return NULL;
 
   /* Create */
   sbuf_init(&s->s_tsbuf);
@@ -457,8 +459,8 @@ mpegts_service_create0
   tvhlog(LOG_DEBUG, "mpegts", "%s - add service %04X %s", buf, s->s_dvb_service_id, s->s_dvb_svcname);
 
   /* Notification */
-  idnode_updated(&mm->mm_id);
-  idnode_updated(&mm->mm_network->mn_id);
+  idnode_notify_simple(&mm->mm_id);
+  idnode_notify_simple(&mm->mm_network->mn_id);
 
   return s;
 }
index 0271a2977a7894f39862e69f0d3d7f0dbc8a21d8..ea1ece1cd9ae9ed2b5fd0ac016e443214bd456b8 100644 (file)
@@ -169,6 +169,7 @@ const idclass_t satip_satconf_class =
 {
   .ic_class      = "satip_satconf",
   .ic_caption    = "Satconf",
+  .ic_event      = "satip_satconf",
   .ic_get_title  = satip_satconf_class_get_title,
   .ic_save       = satip_satconf_class_save,
   .ic_properties = (const property_t[]) {
index e7c91b423a7fe66076ccfb6b9ebb6c85d286c184..4d461feefb50d80c8282d1092901c7302e339455 100644 (file)
@@ -168,6 +168,7 @@ service_class_caid_get ( void *obj )
 const idclass_t service_class = {
   .ic_class      = "service",
   .ic_caption    = "Service",
+  .ic_event      = "service",
   .ic_save       = service_class_save,
   .ic_get_title  = service_class_get_title,
   .ic_properties = (const property_t[]){
index 2a546fba2885b072f2b8f4b9379712e95a7b269e..dffc28c11c1ed2b562ec14f89a3d0c092114d2ba 100644 (file)
@@ -18,7 +18,6 @@ tvheadend.acleditor = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/access/entry',
-        comet: 'acl_entries',
         titleS: 'Access Entry',
         titleP: 'Access Entries',
         columns: {
index f25baa91e250632590adecf4a57fa4ee7f98ede1..743209524e83bc145e1cae14cba7dcc6b81e0e00 100644 (file)
@@ -6,16 +6,9 @@ insertChannelTagsClearOption = function( scope, records, options ){
     scope.insert(0,new placeholder({key: '-1', val: '(Clear filter)'}));
 };
 
-tvheadend.channelTags = new Ext.data.JsonStore({
+tvheadend.channelTags = tvheadend.idnode_get_enum({
     url: 'api/channeltag/list',
-    root: 'entries',
-    fields: ['key', 'val'],
-    id: 'key',
-    autoLoad: true,
-    sortInfo: {
-        field: 'val',
-        direction: 'ASC',
-    },
+    event: 'channeltag',
     listeners: {
         'load': insertChannelTagsClearOption
     }
index 3b9493e60a65bb37f987595f9b6d63eaf337b06c..c7fc24c1154680673bb9cafa1482e0f928bfc9d4 100644 (file)
@@ -61,6 +61,7 @@ tvheadend.cometPoller = function() {
         for (x = 0; x < response.messages.length; x++) {
             m = response.messages[x];
             try {
+                console.log('comet:' + m.notificationClass);
                 tvheadend.comet.fireEvent(m.notificationClass, m);
             } catch (e) {
                 tvheadend.log('comet failure [e=' + e.message + ']');
index ec6132fa7fb1b99da5008efaa8b6421342eaf1b4..17f15b44387fe7fa1ba1987656023294da5c41cb 100644 (file)
@@ -85,7 +85,6 @@ tvheadend.dvr_upcoming = function(panel, index) {
     tvheadend.idnode_grid(panel, {
         url: 'api/dvr/entry',
         gridURL: 'api/dvr/entry/grid_upcoming',
-        comet: 'dvrentry',
         titleS: 'Upcoming Recording',
         titleP: 'Upcoming Recordings',
         iconCls: 'clock',
@@ -127,7 +126,6 @@ tvheadend.dvr_finished = function(panel, index) {
         url: 'api/dvr/entry',
         gridURL: 'api/dvr/entry/grid_finished',
         readonly: true,
-        comet: 'dvrentry',
         titleS: 'Finished Recording',
         titleP: 'Finished Recordings',
         iconCls: 'television',
@@ -172,8 +170,8 @@ tvheadend.dvr_failed = function(panel, index) {
     tvheadend.idnode_grid(panel, {
         url: 'api/dvr/entry',
         gridURL: 'api/dvr/entry/grid_failed',
-        readonly: true,
         comet: 'dvrentry',
+        readonly: true,
         titleS: 'Failed Recording',
         titleP: 'Failed Recordings',
         iconCls: 'exclamation',
@@ -234,7 +232,6 @@ tvheadend.autorec_editor = function(panel, index) {
 
     tvheadend.idnode_grid(panel, {
         url: 'api/dvr/autorec',
-        comet: 'dvrautorec',
         titleS: 'DVR AutoRec Entry',
         titleP: 'DVR AutoRec Entries',
         iconCls: 'wand',
index a7ed387334063ae616c37e1d91fe77a28126b203..84e9762620558399e5550f24e5da702058d47063 100644 (file)
@@ -6,7 +6,6 @@ tvheadend.esfilter_tab = function(panel)
 {
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/video',
-        comet: 'esfilter_video',
         titleS: 'Video Stream Filter',
         titleP: 'Video Stream Filters',
         tabIndex: 0,
@@ -23,7 +22,6 @@ tvheadend.esfilter_tab = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/audio',
-        comet: 'esfilter_audio',
         titleS: 'Audio Stream Filter',
         titleP: 'Audio Stream Filters',
         tabIndex: 1,
@@ -40,7 +38,6 @@ tvheadend.esfilter_tab = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/teletext',
-        comet: 'esfilter_teletext',
         titleS: 'Teletext Stream Filter',
         titleP: 'Teletext Stream Filters',
         tabIndex: 2,
@@ -57,7 +54,6 @@ tvheadend.esfilter_tab = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/subtit',
-        comet: 'esfilter_subtit',
         titleS: 'Subtitle Stream Filter',
         titleP: 'Subtitle Stream Filters',
         tabIndex: 3,
@@ -74,7 +70,6 @@ tvheadend.esfilter_tab = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/ca',
-        comet: 'esfilter_ca',
         titleS: 'CA Stream Filter',
         titleP: 'CA Stream Filters',
         tabIndex: 4,
@@ -91,7 +86,6 @@ tvheadend.esfilter_tab = function(panel)
 
     tvheadend.idnode_grid(panel, {
         url: 'api/esfilter/other',
-        comet: 'esfilter_other',
         titleS: 'Other Stream Filter',
         titleP: 'Other Stream Filters',
         tabIndex: 5,
index d889abb8f2e8392b96d7a78cfb725a96e9bb1151..e4e6cb0105329ca55efc3bb953af30dad430d5bd 100644 (file)
@@ -317,6 +317,7 @@ tvheadend.IdNode = function(conf)
      */
     this.clazz = conf.class;
     this.text = conf.caption || this.clazz;
+    this.event = conf.event;
     this.props = conf.props;
     this.order = [];
     this.groups = conf.groups;
@@ -1251,8 +1252,8 @@ tvheadend.idnode_grid = function(panel, conf)
         };
         if (conf.comet)
             tvheadend.comet.on(conf.comet, update);
-        tvheadend.comet.on('idnodeUpdated', update);
-        tvheadend.comet.on('idnodeDeleted', update);
+        if (idnode.event && idnode.event != conf.comet)
+            tvheadend.comet.on(idnode.event, update);
     }
 
     /* Request data */
@@ -1506,8 +1507,6 @@ tvheadend.idnode_form_grid = function(panel, conf)
     };
     if (conf.comet)
         tvheadend.comet.on(conf.comet, update);
-    tvheadend.comet.on('idnodeUpdated', update);
-    tvheadend.comet.on('idnodeDeleted', update);
 };
 
 /*
@@ -1516,6 +1515,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
 tvheadend.idnode_tree = function(conf)
 {
     var current = null;
+    var events = {};
     var params = conf.params || {};
     var loader = new Ext.tree.TreeLoader({
         dataUrl: conf.url,
@@ -1524,6 +1524,16 @@ tvheadend.idnode_tree = function(conf)
         nodeParameter: 'uuid'
     });
 
+    loader.on('load', function(l, n, r) {
+        if (n.uuid && n.event && !(n.event in events)) {
+          events[n.event] = 1;
+          tvheadend.comet.on(n.event, function(o) {
+            if (o.uuid)
+                tree.getRootNode().reload();
+          });
+        }
+    });
+
     var tree = new Ext.tree.TreePanel({
         loader: loader,
         flex: 1,
@@ -1556,8 +1566,7 @@ tvheadend.idnode_tree = function(conf)
         });
     }
 
-    // TODO: top-level reload
-    tvheadend.comet.on('idnodeUpdated', function(o) {
+    tvheadend.comet.on('title', function(o) {
         var n = tree.getNodeById(o.uuid);
         if (n) {
             if (o.text)
index a091b4eb05ce27262bd7bd0fe98aff9bdf0b4ab3..c2d7ec1e0537156dc415cc6b1af483b332a847f9 100644 (file)
@@ -29,7 +29,6 @@ tvheadend.networks = function(panel)
 {
     tvheadend.idnode_grid(panel, {
         url: 'api/mpegts/network',
-        comet: 'mpegts_network',
         titleS: 'Network',
         titleP: 'Networks',
         tabIndex: 1,
@@ -61,7 +60,6 @@ tvheadend.muxes = function(panel)
 {
     tvheadend.idnode_grid(panel, {
         url: 'api/mpegts/mux',
-        comet: 'mpegts_mux',
         titleS: 'Mux',
         titleP: 'Muxes',
         tabIndex: 2,
@@ -233,7 +231,6 @@ tvheadend.services = function(panel)
     });
     tvheadend.idnode_grid(panel, {
         url: 'api/mpegts/service',
-        comet: 'service',
         titleS: 'Service',
         titleP: 'Services',
         tabIndex: 3,
@@ -269,7 +266,6 @@ tvheadend.mux_sched = function(panel)
 {
     tvheadend.idnode_grid(panel, {
         url: 'api/mpegts/mux_sched',
-        comet: 'mpegts_mux_sched',
         titleS: 'Mux Scheduler',
         titleP: 'Mux Schedulers',
         tabIndex: 4,
index 50e32480e5947a32ee3a7782271f8793e6245b18..7a5330bec78459e2d8204b19585553b69b4cc0a7 100644 (file)
@@ -2,7 +2,6 @@ tvheadend.tvadapters = function() {
     return tvheadend.idnode_tree({
         url: 'api/hardware/tree',
         title: 'TV adapters',
-        comet: 'hardware',
         help: function() {
             new tvheadend.help('TV adapters', 'config_tvadapters.html');
         }