From 8ac9310505c563b30490115f20b97ba6207d5f41 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 10 Jul 2012 19:58:02 +0100 Subject: [PATCH] Add initial priority information, currently unused. --- src/epg.c | 39 +++++++++++++++++++++++++++++++++++++++ src/epg.h | 23 +++++++++++++++++++++-- src/epggrab.h | 1 + 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/epg.c b/src/epg.c index 15c146a6..9dda892d 100644 --- a/src/epg.c +++ b/src/epg.c @@ -263,6 +263,17 @@ static int _epg_object_set_u16 return save; } +static int _epg_object_set_grabber + ( void *o, epggrab_module_t *grab, int *save ) +{ + epg_object_t *eo = o; + if ( eo->grabber != grab && grab->priority > eo->grabber->priority ) { + eo->grabber = grab; + *save = 1; + } + return grab == eo->grabber; +} + /* ************************************************************************** * Brand * *************************************************************************/ @@ -340,6 +351,13 @@ int epg_brand_set_season_count ( epg_brand_t *brand, uint16_t count ) return _epg_object_set_u16(brand, &brand->season_count, count); } +int epg_brand_set_grabber + ( epg_brand_t *brand, epggrab_module_t *grab, int *save ) +{ + if (!brand || !grab) return 0; + return _epg_object_set_grabber(brand, grab, save); +} + static void _epg_brand_add_season ( epg_brand_t *brand, epg_season_t *season ) { @@ -506,6 +524,13 @@ int epg_season_set_brand ( epg_season_t *season, epg_brand_t *brand, int u ) return save; } +int epg_season_set_grabber + ( epg_season_t *season, epggrab_module_t *grab, int *save ) +{ + if (!season || !grab) return 0; + return _epg_object_set_grabber(season, grab, save); +} + static void _epg_season_add_episode ( epg_season_t *season, epg_episode_t *episode ) { @@ -805,6 +830,13 @@ static void _epg_episode_add_broadcast LIST_INSERT_SORTED(&episode->broadcasts, broadcast, ep_link, _ebc_start_cmp); } +int epg_episode_set_grabber + ( epg_episode_t *episode, epggrab_module_t *grab, int *save ) +{ + if (!episode || !grab) return 0; + return _epg_object_set_grabber(episode, grab, save); +} + static void _epg_episode_rem_broadcast ( epg_episode_t *episode, epg_broadcast_t *broadcast ) { @@ -1233,6 +1265,13 @@ int epg_broadcast_set_is_repeat ( epg_broadcast_t *b, uint8_t r ) return _epg_object_set_u8(b, &b->is_repeat, r); } +int epg_broadcast_set_grabber + ( epg_broadcast_t *broadcast, epggrab_module_t *grab, int *save ) +{ + if (!broadcast || !grab) return 0; + return _epg_object_set_grabber(broadcast, grab, save); +} + epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast ) { if ( !broadcast ) return NULL; diff --git a/src/epg.h b/src/epg.h index e04365b5..cd412f5e 100644 --- a/src/epg.h +++ b/src/epg.h @@ -1,6 +1,6 @@ /* * Electronic Program Guide - Common functions - * Copyright (C) 2007 Andreas Öman + * Copyright (C) 2012 Adam Sutton * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,11 @@ #include "settings.h" /* - * Forward decls + * External forward decls */ struct channel; struct channel_tag; +struct epggrab_module; /* * Map/List types @@ -117,6 +118,8 @@ struct epg_object int refcount; ///< Reference counting // Note: could use LIST_ENTRY field to determine this! + struct epggrab_module *grabber; ///< Originating grabber + void (*getref) ( void *o ); ///< Get a reference void (*putref) ( void *o ); ///< Release a reference void (*destroy) ( void *o ); ///< Delete the object @@ -157,6 +160,10 @@ int epg_brand_set_season_count ( epg_brand_t *b, uint16_t season_count ) int epg_brand_set_image ( epg_brand_t *b, const char *i ) __attribute__((warn_unused_result)); +int epg_brand_set_grabber + ( epg_brand_t *b, struct epggrab_module *grab, int *save ) + __attribute__((warn_unused_result)); + /* Serialization */ htsmsg_t *epg_brand_serialize ( epg_brand_t *b ); epg_brand_t *epg_brand_deserialize ( htsmsg_t *m, int create, int *save ); @@ -201,6 +208,10 @@ int epg_season_set_brand ( epg_season_t *s, epg_brand_t *b, int u ) int epg_season_set_image ( epg_season_t *s, const char *image ) __attribute__((warn_unused_result)); +int epg_season_set_grabber + ( epg_season_t *s, struct epggrab_module *grab, int *save ) + __attribute__((warn_unused_result)); + /* Serialization */ htsmsg_t *epg_season_serialize ( epg_season_t *b ); epg_season_t *epg_season_deserialize ( htsmsg_t *m, int create, int *save ); @@ -282,6 +293,10 @@ int epg_episode_set_image ( epg_episode_t *e, const char *i ) int epg_episode_set_is_bw ( epg_episode_t *b, uint8_t bw ) __attribute__((warn_unused_result)); +int epg_episode_set_grabber + ( epg_episode_t *e, struct epggrab_module *grab, int *save ) + __attribute__((warn_unused_result)); + // Note: this does NOT strdup the text field void epg_episode_get_epnum ( epg_episode_t *e, epg_episode_num_t *epnum ); @@ -376,6 +391,10 @@ int epg_broadcast_set_is_new ( epg_broadcast_t *b, uint8_t n ) int epg_broadcast_set_is_repeat ( epg_broadcast_t *b, uint8_t r ) __attribute__((warn_unused_result)); +int epg_broadcast_set_grabber + ( epg_broadcast_t *b, struct epggrab_module *grab, int *save ) + __attribute__((warn_unused_result)); + /* Accessors */ epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *b ); diff --git a/src/epggrab.h b/src/epggrab.h index ead00f65..9583e0ad 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -120,6 +120,7 @@ struct epggrab_module const char *id; ///< Module identifier const char *name; ///< Module name (for display) uint8_t enabled; ///< Whether the module is enabled + int priority; ///< Priority of the module epggrab_channel_tree_t *channels; ///< Channel list /* Enable/Disable */