Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
subscription: cleanup the subscription messages
  • Loading branch information
perexg committed Apr 1, 2015
1 parent 3b92536 commit 4eeecb2
Showing 1 changed file with 64 additions and 27 deletions.
91 changes: 64 additions & 27 deletions src/subscriptions.c
Expand Up @@ -163,48 +163,85 @@ 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,
", profile=\"%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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4eeecb2

Please sign in to comment.