Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epg: add change notifications for extjs
  • Loading branch information
perexg committed May 5, 2015
1 parent f5fd889 commit 9fdbaaf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/epg.c
Expand Up @@ -34,6 +34,7 @@
#include "htsp_server.h"
#include "epggrab.h"
#include "imagecache.h"
#include "notify.h"

/* Broadcast hashing */
#define EPG_HASH_WIDTH 1024
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/epg.h
Expand Up @@ -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
* ***********************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions src/epgdb.c
Expand Up @@ -186,6 +186,7 @@ void epg_init ( void )
}

/* Process */
epg_in_load = 1;
memset(&stats, 0, sizeof(stats));
while ( remain > 4 ) {

Expand Down Expand Up @@ -222,6 +223,7 @@ void epg_init ( void )
/* Cleanup */
htsmsg_destroy(m);
}
epg_in_load = 0;

free(sect);

Expand Down

0 comments on commit 9fdbaaf

Please sign in to comment.