]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epg: add change notifications for extjs
authorJaroslav Kysela <perex@perex.cz>
Tue, 5 May 2015 18:32:12 +0000 (20:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 5 May 2015 18:37:53 +0000 (20:37 +0200)
src/epg.c
src/epg.h
src/epgdb.c

index 471d926b0be04d474c83bfb92e344377dd542ca3..9db12180106318aa29b4572be210d8d2e3b02013 100644 (file)
--- a/src/epg.c
+++ b/src/epg.c
@@ -34,6 +34,7 @@
 #include "htsp_server.h"
 #include "epggrab.h"
 #include "imagecache.h"
+#include "notify.h"
 
 /* Broadcast hashing */
 #define EPG_HASH_WIDTH 1024
@@ -52,6 +53,8 @@ epg_object_tree_t epg_serieslinks;
 epg_object_list_t epg_object_unref;
 epg_object_list_t epg_object_updated;
 
+int epg_in_load;
+
 /* Global counter */
 static uint32_t _epg_object_idx    = 0;
 
@@ -1559,7 +1562,13 @@ void epg_channel_unlink ( channel_t *ch )
 static void _epg_broadcast_destroy ( void *eo )
 {
   epg_broadcast_t *ebc = eo;
-  if (ebc->created)     htsp_event_delete(ebc);
+  char id[16];
+
+  if (ebc->created) {
+    htsp_event_delete(ebc);
+    snprintf(id, sizeof(id), "%u", ebc->id);
+    notify_delayed(id, "epg", "delete");
+  }
   if (ebc->episode)     _epg_episode_rem_broadcast(ebc->episode, ebc);
   if (ebc->serieslink)  _epg_serieslink_rem_broadcast(ebc->serieslink, ebc);
   if (ebc->summary)     lang_str_destroy(ebc->summary);
@@ -1571,10 +1580,20 @@ static void _epg_broadcast_destroy ( void *eo )
 static void _epg_broadcast_updated ( void *eo )
 {
   epg_broadcast_t *ebc = eo;
-  if (ebc->created)
-    htsp_event_update(eo);
+  char id[16];
+
+  if (!epg_in_load)
+    snprintf(id, sizeof(id), "%u", ebc->id);
   else
+    id[0] = '\0';
+
+  if (ebc->created) {
+    htsp_event_update(eo);
+    notify_delayed(id, "epg", "update");
+  } else {
     htsp_event_add(eo);
+    notify_delayed(id, "epg", "create");
+  }
   dvr_event_updated(eo);
   dvr_autorec_check_event(eo);
 }
index a93e64b6896f113543fc9b1c68670c140667cd3f..e7c1b8ff15ce1dd28a15fc1b2005decae594426a 100644 (file)
--- a/src/epg.h
+++ b/src/epg.h
@@ -54,6 +54,8 @@ typedef struct epg_episode         epg_episode_t;
 typedef struct epg_broadcast       epg_broadcast_t;
 typedef struct epg_serieslink      epg_serieslink_t;
 
+extern int epg_in_load;
+
 /* ************************************************************************
  * Genres
  * ***********************************************************************/
index f30e13dcbe08d019cbd4f220d213a448e9024220..694aff6b29d24f02d4d81dc543eceb4e92d02951 100644 (file)
@@ -186,6 +186,7 @@ void epg_init ( void )
   }
 
   /* Process */
+  epg_in_load = 1;
   memset(&stats, 0, sizeof(stats));
   while ( remain > 4 ) {
 
@@ -222,6 +223,7 @@ void epg_init ( void )
     /* Cleanup */
     htsmsg_destroy(m);
   }
+  epg_in_load = 0;
 
   free(sect);