]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
htsp server: allow to update the DVR config for DVR/auto/time entries, fixes #3497
authorJaroslav Kysela <perex@perex.cz>
Tue, 9 Feb 2016 10:15:51 +0000 (11:15 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 9 Feb 2016 10:15:51 +0000 (11:15 +0100)
src/dvr/dvr.h
src/dvr/dvr_db.c
src/htsp_server.c

index 47e9ce2c35406cfdd3b000b7f3a7b09a0d232041..e8caa1a54aad16c93404097f6f142676d2497852 100644 (file)
@@ -532,7 +532,8 @@ dvr_entry_create_htsp( int enabled, const char *dvr_config_uuid,
                        const char *comment );
 
 dvr_entry_t *
-dvr_entry_update( dvr_entry_t *de, int enabled, channel_t *ch,
+dvr_entry_update( dvr_entry_t *de, int enabled,
+                  const char *dvr_config_uuid, channel_t *ch,
                   const char *title, const char *subtitle,
                   const char *desc, const char *lang,
                   time_t start, time_t stop,
index b2860d186ddec0ed4bdd09b9c42a39248c39001c..95c437b6ea2d0c4cdfa2b8acc7411a390ecee6fb 100644 (file)
@@ -1481,10 +1481,11 @@ dvr_timer_remove_files(void *aux)
 #define DVR_UPDATED_EID          (1<<14)
 #define DVR_UPDATED_BROADCAST    (1<<15)
 #define DVR_UPDATED_EPISODE      (1<<16)
+#define DVR_UPDATED_CONFIG       (1<<17)
 
 static char *dvr_updated_str(char *buf, size_t buflen, int flags)
 {
-  static const char *x = "ecoOsStumdpgrviBE";
+  static const char *x = "ecoOsStumdpgrviBEC";
   const char *p = x;
   char *w = buf, *end = buf + buflen;
 
@@ -1502,7 +1503,8 @@ static char *dvr_updated_str(char *buf, size_t buflen, int flags)
  *
  */
 static dvr_entry_t *_dvr_entry_update
-  ( dvr_entry_t *de, int enabled, epg_broadcast_t *e, channel_t *ch,
+  ( dvr_entry_t *de, int enabled, const char *dvr_config_uuid,
+    epg_broadcast_t *e, channel_t *ch,
     const char *title, const char *subtitle, const char *desc,
     const char *lang, time_t start, time_t stop,
     time_t start_extra, time_t stop_extra,
@@ -1537,6 +1539,12 @@ static dvr_entry_t *_dvr_entry_update
     goto dosave;
   }
 
+  /* Configuration */
+  if (dvr_config_uuid) {
+    de->de_config = dvr_config_find_by_name_default(dvr_config_uuid);
+    save |= DVR_UPDATED_CONFIG;
+  }
+
   /* Channel */
   if (ch && (ch != de->de_channel)) {
     de->de_channel = ch;
@@ -1664,14 +1672,16 @@ dosave:
  */
 dvr_entry_t * 
 dvr_entry_update
-  ( dvr_entry_t *de, int enabled, channel_t *ch,
+  ( dvr_entry_t *de, int enabled,
+    const char *dvr_config_uuid, channel_t *ch,
     const char *title, const char *subtitle,
     const char *desc, const char *lang,
     time_t start, time_t stop,
     time_t start_extra, time_t stop_extra,
     dvr_prio_t pri, int retention, int removal )
 {
-  return _dvr_entry_update(de, enabled, NULL, ch, title, subtitle, desc, lang,
+  return _dvr_entry_update(de, enabled, dvr_config_uuid,
+                           NULL, ch, title, subtitle, desc, lang,
                            start, stop, start_extra, stop_extra,
                            pri, retention, removal);
 }
@@ -1730,7 +1740,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e)
                    epg_broadcast_get_title(e2, NULL),
                    channel_get_name(ch),
                    e2->start, e2->stop);
-          _dvr_entry_update(de, -1, e2, NULL, NULL, NULL, NULL, NULL,
+          _dvr_entry_update(de, -1, NULL, e2, NULL, NULL, NULL, NULL, NULL,
                             0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0);
           return;
         }
@@ -1773,7 +1783,7 @@ void dvr_event_updated(epg_broadcast_t *e)
   LIST_FOREACH(de, &e->channel->ch_dvrs, de_channel_link) {
     if (de->de_bcast != e)
       continue;
-    _dvr_entry_update(de, -1, e, NULL, NULL, NULL, NULL,
+    _dvr_entry_update(de, -1, NULL, e, NULL, NULL, NULL, NULL,
                       NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0);
     found++;
   }
@@ -1790,7 +1800,7 @@ void dvr_event_updated(epg_broadcast_t *e)
                  epg_broadcast_get_title(e, NULL),
                  channel_get_name(e->channel),
                  e->start, e->stop);
-        _dvr_entry_update(de, -1, e, NULL, NULL, NULL, NULL,
+        _dvr_entry_update(de, -1, NULL, e, NULL, NULL, NULL, NULL,
                           NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0);
         break;
       }
index ebb90ce7d70bf344b938052a8e9850105f03d62b..731f9d144300401b84d03b4830b76f3f3e7937cb 100644 (file)
@@ -641,6 +641,12 @@ serierec_convert(htsp_connection_t *htsp, htsmsg_t *in, channel_t *ch, int autor
     htsmsg_add_str(conf, "config_name", str ?: "");
     htsmsg_add_str(conf, "owner",   htsp->htsp_granted_access->aa_username ?: "");
     htsmsg_add_str(conf, "creator", htsp->htsp_granted_access->aa_representative ?: "");
+  } else {
+    str = htsmsg_get_str(in, "configName");
+    if (str) {
+      str = htsp_dvr_config_name(htsp, str);
+      htsmsg_add_str(conf, "config_name", str ?: "");
+    }
   }
 
   /* Weekdays only if present */
@@ -1881,7 +1887,7 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
   uint32_t u32;
   dvr_entry_t *de;
   time_t start, stop, start_extra, stop_extra, priority, retention, removal;
-  const char *title, *subtitle, *desc, *lang;
+  const char *dvr_config_name, *title, *subtitle, *desc, *lang;
   channel_t *channel = NULL;
   int enabled;
 
@@ -1899,6 +1905,7 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
     return htsp_error("User does not have access to channel");
 
   enabled     = htsmsg_get_s64_or_default(in, "enabled",    -1);
+  dvr_config_name = htsp_dvr_config_name(htsp, htsmsg_get_str(in, "configName"));
   start       = htsmsg_get_s64_or_default(in, "start",      0);
   stop        = htsmsg_get_s64_or_default(in, "stop",       0);
   start_extra = htsmsg_get_s64_or_default(in, "startExtra", 0);
@@ -1911,8 +1918,9 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
   desc        = htsmsg_get_str(in, "description");
   lang        = htsmsg_get_str(in, "language") ?: htsp->htsp_language;
 
-  de = dvr_entry_update(de, enabled, channel, title, subtitle, desc, lang, start, stop,
-                        start_extra, stop_extra, priority, retention, removal);
+  de = dvr_entry_update(de, enabled, dvr_config_name, channel, title, subtitle,
+                        desc, lang, start, stop, start_extra, stop_extra,
+                        priority, retention, removal);
 
   return htsp_success();
 }