]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Delete channel-bound autorecordings when a channel is destroyed.
authorAndreas Öman <andreas@lonelycoder.com>
Thu, 4 Jun 2009 06:13:45 +0000 (06:13 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Thu, 4 Jun 2009 06:13:45 +0000 (06:13 +0000)
src/channels.c
src/dtable.c
src/dtable.h
src/dvr/dvr.h
src/dvr/dvr_autorec.c

index b31ecb1416b7fc8e3446eff1e7e8ca3e28178a4a..bedaf091a9bface36407c4ab16d87fc884e4d7ca 100644 (file)
@@ -383,6 +383,8 @@ channel_delete(channel_t *ch)
   tvhlog(LOG_NOTICE, "channels", "Channel \"%s\" deleted",
         ch->ch_name);
 
+  autorec_destroy_by_channel(ch);
+
   dvr_destroy_by_channel(ch);
 
   while((t = LIST_FIRST(&ch->ch_transports)) != NULL) {
@@ -399,8 +401,6 @@ channel_delete(channel_t *ch)
 
   epg_unlink_from_channel(ch);
 
-  fprintf(stderr, "!!!!!//autorec_destroy_by_channel(ch);\n");
-
   hts_settings_remove("channels/%d", ch->ch_id);
 
   RB_REMOVE(&channel_name_tree, ch, ch_name_link);
index ddde35cfdcd7ba0b9e994b9ed03fbeae120dc0ed..72dc90205e21fc2de610c9ce32ef52c40507cdf2 100644 (file)
@@ -214,3 +214,13 @@ dtable_record_store(dtable_t *dt, const char *id, htsmsg_t *r)
 {
   hts_settings_save(r, "%s/%s", dt->dt_tablename, id);
 }
+
+
+/**
+ *
+ */
+void
+dtable_record_erase(dtable_t *dt, const char *id)
+{
+  hts_settings_remove("%s/%s", dt->dt_tablename, id);
+}
index 66b03c5b84ed05e4a4b11a27ae22c0dfaf82189f..53ad64c0e2b7b6efb5bb6abe7cd7ce1954bc1064 100644 (file)
@@ -72,4 +72,6 @@ htsmsg_t *dtable_record_get_all(dtable_t *dt);
 
 void dtable_record_store(dtable_t *dt, const char *id, htsmsg_t *r);
 
+void dtable_record_erase(dtable_t *dt, const char *id);
+
 #endif /* DTABLE_H__ */
index 06e73856701fa7c3c5877e0d7c6efe50d7071e26..a7f0e12bf12c8a8fa13fb77e37df7ebb640280e6 100644 (file)
@@ -175,4 +175,6 @@ void dvr_autorec_add(const char *title, const char *channel,
 
 void dvr_autorec_check(event_t *e);
 
+void autorec_destroy_by_channel(channel_t *ch);
+
 #endif /* DVR_H  */
index cad9780daafdf3c75bba77ad185b5b66518f6d03..933ebf9a5138d77c8700c4115c9cd5978511f94b 100644 (file)
@@ -35,6 +35,8 @@
 #include "dtable.h"
 #include "epg.h"
 
+dtable_t *autorec_dt;
+
 TAILQ_HEAD(dvr_autorec_entry_queue, dvr_autorec_entry);
 
 struct dvr_autorec_entry_queue autorec_entries;
@@ -256,7 +258,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
       LIST_REMOVE(dae, dae_channel_link);
       dae->dae_channel = NULL;
     }
-     if((ch = channel_find_by_name(s, 0)) != NULL) {
+    if((ch = channel_find_by_name(s, 0)) != NULL) {
       LIST_INSERT_HEAD(&ch->ch_autorecs, dae, dae_channel_link);
       dae->dae_channel = ch;
     }
@@ -333,11 +335,9 @@ static const dtable_class_t autorec_dtc = {
 void
 dvr_autorec_init(void)
 {
-  dtable_t *dt;
-
   TAILQ_INIT(&autorec_entries);
-  dt = dtable_create(&autorec_dtc, "autorec", NULL);
-  dtable_load(dt);
+  autorec_dt = dtable_create(&autorec_dtc, "autorec", NULL);
+  dtable_load(autorec_dt);
 }
 
 
@@ -442,3 +442,24 @@ dvr_autorec_check_just_enabled(dvr_autorec_entry_t *dae)
       autorec_schedule(ch->ch_epg_current, dae);
   }
 }
+
+
+/**
+ *
+ */
+void
+autorec_destroy_by_channel(channel_t *ch)
+{
+  dvr_autorec_entry_t *dae;
+  htsmsg_t *m;
+
+  while((dae = LIST_FIRST(&ch->ch_autorecs)) != NULL) {
+    dtable_record_erase(autorec_dt, dae->dae_id);
+    autorec_entry_destroy(dae);
+  }
+
+  /* Notify web clients that we have messed with the tables */
+  m = htsmsg_create_map();
+  htsmsg_add_u32(m, "asyncreload", 1);
+  notify_by_msg("autorec", m);
+}