From: Jaroslav Kysela Date: Tue, 5 May 2015 18:32:12 +0000 (+0200) Subject: epg: add change notifications for extjs X-Git-Tag: v4.1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fdbaafa68780f42b711b98aaecf5c920cce20ad;p=thirdparty%2Ftvheadend.git epg: add change notifications for extjs --- diff --git a/src/epg.c b/src/epg.c index 471d926b0..9db121801 100644 --- 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); } diff --git a/src/epg.h b/src/epg.h index a93e64b68..e7c1b8ff1 100644 --- 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 * ***********************************************************************/ diff --git a/src/epgdb.c b/src/epgdb.c index f30e13dcb..694aff6b2 100644 --- a/src/epgdb.c +++ b/src/epgdb.c @@ -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);