]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
subscription: cleanup the subscription messages
authorJaroslav Kysela <perex@perex.cz>
Wed, 1 Apr 2015 08:22:32 +0000 (10:22 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 1 Apr 2015 08:22:32 +0000 (10:22 +0200)
src/subscriptions.c

index 34f76cbf8723dc72be38b21ddcc77e6a8a8ae79a..938513fffdb504b9efa11aa9241f4f61f10fe752 100644 (file)
@@ -163,36 +163,73 @@ subscription_sort(th_subscription_t *a, th_subscription_t *b)
   return b->ths_weight - a->ths_weight;
 }
 
-
 static void
 subscription_show_none(th_subscription_t *s)
 {
-  channel_t *ch = s->ths_channel;
-  tvhlog(LOG_NOTICE, "subscription",
-        "%04X: No input source available for subscription \"%s\" "
-        "to channel \"%s\"",
-          shortid(s), s->ths_title, ch ? channel_get_name(ch) : "none");
+  char buf[256], buf2[128];
+  size_t l = 0;
+
+  tvh_strlcatf2(buf, sizeof(buf), l,
+                "No input source available for subscription \"%s\"",
+               s->ths_title);
+  if (s->ths_channel)
+    tvh_strlcatf2(buf, sizeof(buf), l, " to channel \"%s\"",
+                  s->ths_channel ? channel_get_name(s->ths_channel) : "none");
+#if ENABLE_MPEGTS
+  else if (s->ths_raw_service) {
+    mpegts_service_t *ms = (mpegts_service_t *)s->ths_raw_service;
+    mpegts_mux_nice_name(ms->s_dvb_mux, buf2, sizeof(buf2));
+    tvh_strlcatf2(buf, sizeof(buf), l, " to mux \"%s\"", buf2);
+  }
+#endif
+  else {
+    tvh_strlcatf2(buf, sizeof(buf), l, " to service \"%s\"",
+                  s->ths_service ? s->ths_service->s_nicename : "none");
+#if ENABLE_MPEGTS
+    if (idnode_is_instance(&s->ths_service->s_id, &mpegts_service_class)) {
+      mpegts_service_t *ms = (mpegts_service_t *)s->ths_service;
+      mpegts_mux_nice_name(ms->s_dvb_mux, buf2, sizeof(buf2));
+      tvh_strlcatf2(buf, sizeof(buf), l, " in mux \"%s\"", buf2);
+    }
+#endif
+  }
+  tvhlog(LOG_NOTICE, "subscription", "%04X: %s", shortid(s), buf);
 }
 
 static void
 subscription_show_info(th_subscription_t *s)
 {
   char buf[512];
-  channel_t *ch = s->ths_channel;
   source_info_t si;
   size_t l = 0;
+  int mux = 0, service = 0;
 
   s->ths_service->s_setsourceinfo(s->ths_service, &si);
-  tvh_strlcatf2(buf, sizeof(buf), l,
-          "\"%s\" subscribing on \"%s\", weight: %d, adapter: \"%s\", "
-          "network: \"%s\", mux: \"%s\", provider: \"%s\", service: \"%s\"",
-          s->ths_title, ch ? channel_get_name(ch) : "none", s->ths_weight,
-          si.si_adapter  ?: "<N/A>",
-          si.si_network  ?: "<N/A>",
-          si.si_mux      ?: "<N/A>",
-          si.si_provider ?: "<N/A>",
-          si.si_service  ?: "<N/A>");
-  service_source_info_free(&si);
+  tvh_strlcatf2(buf, sizeof(buf), l, "\"%s\" subscribing", s->ths_title);
+  if (s->ths_channel) {
+    tvh_strlcatf2(buf, sizeof(buf), l, " on channel \"%s\"",
+                  s->ths_channel ? channel_get_name(s->ths_channel) : "none");
+#if ENABLE_MPEGTS
+  } else if (s->ths_raw_service && si.si_mux) {
+    tvh_strlcatf2(buf, sizeof(buf), l, " to mux \"%s\"", si.si_mux);
+    mux = 1;
+#endif
+  } else {
+    tvh_strlcatf2(buf, sizeof(buf), l, " to service \"%s\"",
+                  s->ths_service ? s->ths_service->s_nicename : "none");
+    service = 1;
+  }
+  tvh_strlcatf2(buf, sizeof(buf), l, ", weight: %d", s->ths_weight);
+  if (si.si_adapter)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", adapter: \"%s\"", si.si_adapter);
+  if (si.si_network)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", network: \"%s\"", si.si_network);
+  if (!mux && si.si_mux)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", mux: \"%s\"", si.si_mux);
+  if (si.si_provider)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", provider: \"%s\"", si.si_provider);
+  if (!service && si.si_service)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", service: \"%s\"", si.si_service);
 
   if (s->ths_prch && s->ths_prch->prch_pro)
     tvh_strlcatf2(buf, sizeof(buf), l,
@@ -200,11 +237,11 @@ subscription_show_info(th_subscription_t *s)
                        s->ths_prch->prch_pro->pro_name ?: "");
 
   if (s->ths_hostname)
-    tvh_strlcatf2(buf, sizeof(buf), l,
-             ", hostname=\"%s\", username=\"%s\", client=\"%s\"",
-             s->ths_hostname ?: "<N/A>",
-             s->ths_username ?: "<N/A>",
-             s->ths_client   ?: "<N/A>");
+    tvh_strlcatf2(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
+  if (s->ths_username)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
+  if (s->ths_client)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", client=\"%s\"", s->ths_client);
 
   tvhlog(LOG_INFO, "subscription", "%04X: %s", shortid(s), buf);
 }
@@ -526,11 +563,11 @@ subscription_unsubscribe(th_subscription_t *s, int quiet)
   }
 
   if (s->ths_hostname)
-    tvh_strlcatf2(buf, sizeof(buf), l,
-             ", hostname=\"%s\", username=\"%s\", client=\"%s\"",
-             s->ths_hostname ?: "<N/A>",
-             s->ths_username ?: "<N/A>",
-             s->ths_client   ?: "<N/A>");
+    tvh_strlcatf2(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname);
+  if (s->ths_username)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_username);
+  if (s->ths_client)
+    tvh_strlcatf2(buf, sizeof(buf), l, ", username=\"%s\"", s->ths_client);
   tvhlog(quiet ? LOG_TRACE : LOG_INFO, "subscription", "%04X: %s", shortid(s), buf);
 
   if (t) {