}
}
-static const char *
-access_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+access_entry_class_get_title
+ (idnode_t *self, const char *lang, char *buf, size_t dstsize)
{
access_entry_t *ae = (access_entry_t *)self;
- const char *s = ae->ae_username;
if (ae->ae_comment && ae->ae_comment[0] != '\0') {
if (ae->ae_username && ae->ae_username[0]) {
- snprintf(prop_sbuf, PROP_SBUF_LEN, "%s (%s)", ae->ae_username, ae->ae_comment);
- s = prop_sbuf;
+ snprintf(buf, dstsize, "%s (%s)", ae->ae_username, ae->ae_comment);
+ return;
} else {
- s = ae->ae_comment;
+ snprintf(buf, dstsize, "%s", ae->ae_comment);
+ return;
}
}
- if (s == NULL || *s == '\0')
- s = "";
- return s;
+ if (ae->ae_username && ae->ae_username[0] != '\0')
+ snprintf(buf, dstsize, "%s", ae->ae_username);
+ else
+ buf[0] = '\0';
}
static int
passwd_entry_destroy(pw, 1);
}
-static const char *
-passwd_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+passwd_entry_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
passwd_entry_t *pw = (passwd_entry_t *)self;
- if (pw->pw_comment && pw->pw_comment[0] != '\0')
- return pw->pw_comment;
- return pw->pw_username ?: "";
+ if (pw->pw_comment && pw->pw_comment[0] != '\0') {
+ snprintf(dst, dstsize, "%s", pw->pw_comment);
+ } else {
+ snprintf(dst, dstsize, "%s", pw->pw_username ?: "");
+ }
}
static int
return c;
}
-static const char *
-ipblock_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+ipblock_entry_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
ipblock_entry_t *ib = (ipblock_entry_t *)self;
if (ib->ib_comment && ib->ib_comment[0] != '\0')
- return ib->ib_comment;
- return N_("IP blocking");
+ snprintf(dst, dstsize, "%s", ib->ib_comment);
+ else
+ snprintf(dst, dstsize, "%s", tvh_gettext_lang(lang, N_("IP blocking")));
}
static void
{
caclient_t *cac;
htsmsg_t *l, *e;
- char ubuf[UUID_HEX_SIZE];
+ char ubuf[UUID_HEX_SIZE], buf[384];
l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
TAILQ_FOREACH(cac, &caclients, cac_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "uuid", idnode_uuid_as_str(&cac->cac_id, ubuf));
- htsmsg_add_str(e, "title", idnode_get_title(&cac->cac_id, perm->aa_lang_ui));
+ htsmsg_add_str(e, "title", idnode_get_title(&cac->cac_id, perm->aa_lang_ui, buf, sizeof(buf)));
htsmsg_add_str(e, "status", caclient_get_status(cac));
htsmsg_add_msg(l, NULL, e);
}
{
htsmsg_t *l = htsmsg_create_list(), *m;
epggrab_module_t *mod;
- char ubuf[UUID_HEX_SIZE];
+ char ubuf[UUID_HEX_SIZE], buf[384];
pthread_mutex_lock(&global_lock);
LIST_FOREACH(mod, &epggrab_modules, link) {
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(&mod->idnode, ubuf));
htsmsg_add_str(m, "status", epggrab_module_get_status(mod));
- htsmsg_add_str(m, "title", idnode_get_title(&mod->idnode, perm->aa_lang_ui));
+ htsmsg_add_str(m, "title", idnode_get_title(&mod->idnode, perm->aa_lang_ui, buf, sizeof(buf)));
htsmsg_add_msg(l, NULL, m);
}
pthread_mutex_unlock(&global_lock);
idnode_set_t *is;
idnode_t *in;
htsmsg_t *l, *e;
- char ubuf[UUID_HEX_SIZE];
+ char ubuf[UUID_HEX_SIZE], buf[384];
// TODO: this only works if pass as integer
_enum = htsmsg_get_bool_or_default(args, "enum", 0);
/* Name/UUID only */
if (_enum) {
e = htsmsg_create_key_val(idnode_uuid_as_str(in, ubuf),
- idnode_get_title(in, perm->aa_lang_ui));
+ idnode_get_title(in, perm->aa_lang_ui, buf, sizeof(buf)));
/* Full record */
} else {
bouquet_delete((bouquet_t *)self);
}
-static const char *
-bouquet_class_get_title (idnode_t *self, const char *lang)
+static void
+bouquet_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
bouquet_t *bq = (bouquet_t *)self;
if (bq->bq_comment && bq->bq_comment[0] != '\0')
- return bq->bq_comment;
- return bq->bq_name ?: "";
+ snprintf(dst, dstsize, "%s", bq->bq_comment);
+ else
+ snprintf(dst, dstsize, "%s", bq->bq_name ?: "");
}
/* exported for others */
return &prop_ptr;
}
-static const char *
-channel_class_get_title ( idnode_t *self, const char *lang )
+static void
+channel_class_get_title
+ ( idnode_t *self, const char *lang, char *dst, size_t dstsize )
{
- return channel_get_name((channel_t*)self, tvh_gettext_lang(lang, channel_blank_name));
+ const char *s = channel_get_name((channel_t*)self,
+ tvh_gettext_lang(lang, channel_blank_name));
+ snprintf(dst, dstsize, "%s", s);
}
/* exported for others */
channel_tag_destroy((channel_tag_t *)self, 1);
}
-static const char *
-channel_tag_class_get_title (idnode_t *self, const char *lang)
+static void
+channel_tag_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
channel_tag_t *ct = (channel_tag_t *)self;
- return ct->ct_name ?: "";
+ snprintf(dst, dstsize, "%s", ct->ct_name ?: "");
}
static void
return c;
}
-static const char *
-caclient_class_get_title ( idnode_t *in, const char *lang )
+static void
+caclient_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
caclient_t *cac = (caclient_t *)in;
- if (cac->cac_name && cac->cac_name[0])
- return cac->cac_name;
- snprintf(prop_sbuf, PROP_SBUF_LEN,
- tvh_gettext_lang(lang, N_("CA client %i")), cac->cac_index);
- return prop_sbuf;
+ if (cac->cac_name && cac->cac_name[0]) {
+ snprintf(dst, dstsize, "%s", cac->cac_name);
+ } else {
+ snprintf(dst, dstsize,
+ tvh_gettext_lang(lang, N_("CA client %i")), cac->cac_index);
+ }
}
static void
.name = N_("Client name"),
.desc = N_("Name of the client."),
.off = offsetof(caclient_t, cac_name),
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
},
{
.type = PT_STR,
pthread_t capmt_tid;
+ char capmt_name[128];
+
/* from capmt configuration */
char *capmt_sockfile;
int capmt_port;
static inline const char *
capmt_name(capmt_t *capmt)
{
- return idnode_get_title(&capmt->cac_id, NULL);
+ return idnode_get_title(&capmt->cac_id, NULL,
+ capmt->capmt_name, sizeof(capmt->capmt_name));
}
static inline int
d = 60;
}
- tvhinfo(LS_CAPMT, "%s: Automatic reconnection attempt in in %d seconds", idnode_get_title(&capmt->cac_id, NULL), d);
+ tvhinfo(LS_CAPMT, "%s: Automatic reconnection attempt in in %d seconds", capmt_name(capmt), d);
mono = mclk() + sec2mono(d);
do {
typedef struct constcw {
caclient_t;
+ char ccw_name[128];
+
/* From configuration */
uint16_t ccw_caid; /* CA ID */
uint32_t ccw_providerid; /* CA provider ID */
static const char *
constcw_name(constcw_t *ccw)
{
- return idnode_get_title(&ccw->cac_id, NULL);
+ return idnode_get_title(&ccw->cac_id, NULL,
+ ccw->ccw_name, sizeof(ccw->ccw_name));
}
/**
return 0;
}
-static const char *
-dvr_autorec_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+dvr_autorec_entry_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)self;
const char *s = "";
s = dae->dae_name;
else if (dae->dae_comment && dae->dae_comment[0] != '\0')
s = dae->dae_comment;
- return s;
+ snprintf(dst, dstsize, "%s", s);
}
static int
return NULL;
}
-static const char *
-dvr_config_class_get_title (idnode_t *self, const char *lang)
+static void
+dvr_config_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
dvr_config_t *cfg = (dvr_config_t *)self;
- if (!dvr_config_is_default(cfg))
- return cfg->dvr_config_name;
- return N_("(Default profile)");
+ if (!dvr_config_is_default(cfg)) {
+ snprintf(dst, dstsize, "%s", cfg->dvr_config_name);
+ } else {
+ snprintf(dst, dstsize, "%s", tvh_gettext_lang(lang, N_("(Default profile)")));
+ }
}
static int
return 0;
}
-static const char *
-dvr_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+dvr_entry_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
dvr_entry_t *de = (dvr_entry_t *)self;
const char *s;
s = lang_str_get(de->de_desc, NULL);
}
}
- return s;
+ snprintf(dst, dstsize, "%s", s);
}
static int
return 0;
}
-static const char *
-dvr_timerec_entry_class_get_title (idnode_t *self, const char *lang)
+static void
+dvr_timerec_entry_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
dvr_timerec_entry_t *dte = (dvr_timerec_entry_t *)self;
const char *s = "";
s = dte->dte_name;
else if (dte->dte_comment && dte->dte_comment[0] != '\0')
s = dte->dte_comment;
- return s;
+ snprintf(dst, dstsize, "%s", s);
}
static int
* Class
*/
-static const char *
-epggrab_channel_class_get_title(idnode_t *self, const char *lang)
+static void
+epggrab_channel_class_get_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
epggrab_channel_t *ec = (epggrab_channel_t*)self;
- snprintf(prop_sbuf, PROP_SBUF_LEN, "%s: %s (%s)",
+ snprintf(dst, dstsize, "%s: %s (%s)",
ec->name ?: ec->id, ec->id, ec->mod->name);
- return prop_sbuf;
}
static htsmsg_t *
* Class
*/
-static const char *epggrab_mod_class_title(idnode_t *self, const char *lang)
+static void epggrab_mod_class_title
+ (idnode_t *self, const char *lang, char *dst, size_t dstsize)
{
epggrab_module_t *mod = (epggrab_module_t *)self;
const char *s1 = tvh_gettext_lang(lang, epggrab_module_type(mod));
const char *s2 = tvh_str_default(mod->name, mod->id);
- snprintf(prop_sbuf, PROP_SBUF_LEN, "%s: %s", s1, s2);
- return prop_sbuf;
+ snprintf(dst, dstsize, "%s: %s", s1, s2);
}
static void
return c;
}
-static const char *
-esfilter_class_get_title(idnode_t *self, const char *lang)
-{
- esfilter_t *esf = (esfilter_t *)self;
- return idnode_uuid_as_str(&esf->esf_id, prop_sbuf);
-}
-
static void
esfilter_class_delete(idnode_t *self)
{
.ic_event = "esfilter",
.ic_perm_def = ACCESS_ADMIN,
.ic_save = esfilter_class_save,
- .ic_get_title = esfilter_class_get_title,
.ic_delete = esfilter_class_delete,
.ic_moveup = esfilter_class_moveup,
.ic_movedown = esfilter_class_movedown,
RB_ENTRY(idclass_link) link;
} idclass_link_t;
+pthread_mutex_t idnode_mutex = PTHREAD_MUTEX_INITIALIZER;
static idnodes_rb_t idnodes;
static RB_HEAD(,idclass_link) idclasses;
static RB_HEAD(,idclass_link) idrootclasses;
static TAILQ_HEAD(,idnode_save) idnodes_save;
-tvh_cond_t save_cond;
-pthread_t save_tid;
-static int save_running;
-static mtimer_t save_timer;
+static tvh_cond_t save_cond;
+static pthread_t save_tid;
+static int save_running;
+static mtimer_t save_timer;
+
+static pthread_mutex_t idnode_lnotify_mutex = PTHREAD_MUTEX_INITIALIZER;
+static tvh_uuid_set_t idnode_lnotify_set;
+static tvh_uuid_set_t idnode_lnotify_title_set;
SKEL_DECLARE(idclasses_skel, idclass_link_t);
lock_assert(&global_lock);
+ idnode_lock();
+
in->in_class = class;
do {
c = RB_INSERT_SORTED(in->in_domain, in, in_domain_link, in_cmp);
assert(c == NULL);
+ idnode_unlock();
+
/* Fire event */
idnode_notify(in, "create");
char ubuf[UUID_HEX_SIZE];
lock_assert(&global_lock);
+ idnode_lock();
RB_REMOVE(&idnodes, in, in_link);
RB_REMOVE(in->in_domain, in, in_domain_link);
+ idnode_unlock();
tvhtrace(LS_IDNODE, "unlink node %s", idnode_uuid_as_str(in, ubuf));
idnode_notify(in, "delete");
assert(in->in_save == NULL || in->in_save == SAVEPTR_OUTOFSERVICE);
*
*/
const char *
-idnode_get_title(idnode_t *in, const char *lang)
+idnode_get_title(idnode_t *in, const char *lang, char *dst, size_t dstsize)
{
static char ubuf[UUID_HEX_SIZE];
const idclass_t *ic = in->in_class;
for(; ic != NULL; ic = ic->ic_super) {
- if(ic->ic_get_title != NULL)
- return ic->ic_get_title(in, lang);
+ if(ic->ic_get_title != NULL) {
+ ic->ic_get_title(in, lang, dst, dstsize);
+ return dst;
+ }
}
- return idnode_uuid_as_str(in, ubuf);
+ strncpy(dst, idnode_uuid_as_str(in, ubuf), dstsize);
+ dst[dstsize-1] = 0;
+ return dst;
}
{
idnode_t *ina = *(idnode_t**)a;
idnode_t *inb = *(idnode_t**)b;
- const char *sa = idnode_get_title(ina, (const char *)lang);
- const char *sb = idnode_get_title(inb, (const char *)lang);
- return strcmp(sa ?: "", sb ?: "");
+ char bufa[384];
+ char bufb[384];
+ idnode_get_title(ina, (const char *)lang, bufa, sizeof(bufa));
+ idnode_get_title(inb, (const char *)lang, bufb, sizeof(bufb));
+ return strcmp(bufa, bufb);
}
#define safecmp(a, b) ((a) > (b) ? 1 : ((a) < (b) ? -1 : 0))
{
const idclass_t *idc = self->in_class;
const char *uuid, *s;
- char ubuf[UUID_HEX_SIZE];
+ char ubuf[UUID_HEX_SIZE], buf[384];
htsmsg_t *m = htsmsg_create_map();
if (!idc->ic_snode) {
htsmsg_add_str(m, "uuid", uuid);
htsmsg_add_str(m, "id", uuid);
}
- htsmsg_add_str(m, "text", idnode_get_title(self, lang) ?: "");
+ htsmsg_add_str(m, "text", idnode_get_title(self, lang, buf, sizeof(buf)) ?: "");
if ((s = idclass_get_caption(idc, lang)))
htsmsg_add_str(m, "caption", s);
if ((s = idclass_get_class(idc)))
char *str;
idnode_list_mapping_t *ilm;
htsmsg_t *l = htsmsg_create_list();
+ char buf[384];
LIST_FOREACH(ilm, in1_list, ilm_in1_link)
- htsmsg_add_str(l, NULL, idnode_get_title(ilm->ilm_in2, lang));
+ htsmsg_add_str(l, NULL, idnode_get_title(ilm->ilm_in2, lang, buf, sizeof(buf)));
str = htsmsg_list_2_csv(l, ',', 1);
htsmsg_destroy(l);
char *str;
idnode_list_mapping_t *ilm;
htsmsg_t *l = htsmsg_create_list();
+ char buf[384];
LIST_FOREACH(ilm, in2_list, ilm_in2_link)
- htsmsg_add_str(l, NULL, idnode_get_title(ilm->ilm_in1, lang));
+ htsmsg_add_str(l, NULL, idnode_get_title(ilm->ilm_in1, lang, buf, sizeof(buf)));
str = htsmsg_list_2_csv(l, ',', 1);
htsmsg_destroy(l);
}
void
-idnode_notify_title_changed (void *in, const char *lang)
+idnode_notify_title_changed (void *in)
{
char ubuf[UUID_HEX_SIZE];
htsmsg_t *m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(in, ubuf));
- htsmsg_add_str(m, "text", idnode_get_title(in, lang));
- notify_by_msg("title", m, 0);
+ notify_by_msg("title", m, NOTIFY_REWRITE_TITLE);
idnode_notify_changed(in);
}
+void
+idnode_notify_title_changed_lang (void *in, const char *lang)
+{
+ return idnode_notify_title_changed(in);
+}
+
/* **************************************************************************
* Save thread
* *************************************************************************/
save_thread ( void *aux )
{
idnode_save_t *ise;
+ idnode_t *in;
htsmsg_t *m;
+ uint32_t u32;
+ tvh_uuid_t *uuid;
char filename[PATH_MAX];
+ tvh_uuid_set_t set, tset;
+
+ uuid_set_init(&set, 10);
+ uuid_set_init(&tset, 10);
tvhthread_renice(15);
pthread_mutex_lock(&global_lock);
while (atomic_get(&save_running)) {
- if ((ise = TAILQ_FIRST(&idnodes_save)) == NULL ||
- (ise->ise_reqtime + IDNODE_SAVE_DELAY > mclk())) {
+ if (((ise = TAILQ_FIRST(&idnodes_save)) == NULL ||
+ (ise->ise_reqtime + IDNODE_SAVE_DELAY > mclk())) &&
+ uuid_set_empty(&idnode_lnotify_set) &&
+ uuid_set_empty(&idnode_lnotify_title_set)) {
if (ise)
mtimer_arm_abs(&save_timer, idnode_save_trigger_thread_cb, NULL,
ise->ise_reqtime + IDNODE_SAVE_DELAY);
tvh_cond_wait(&save_cond, &global_lock);
continue;
}
- m = idnode_savefn(ise->ise_node, filename, sizeof(filename));
- ise->ise_node->in_save = NULL;
- TAILQ_REMOVE(&idnodes_save, ise, ise_link);
- pthread_mutex_unlock(&global_lock);
- free(ise);
- if (m) {
- hts_settings_save(m, "%s", filename);
- htsmsg_destroy(m);
+ if (ise) {
+ m = idnode_savefn(ise->ise_node, filename, sizeof(filename));
+ ise->ise_node->in_save = NULL;
+ TAILQ_REMOVE(&idnodes_save, ise, ise_link);
+ pthread_mutex_unlock(&global_lock);
+ free(ise);
+ if (m) {
+ hts_settings_save(m, "%s", filename);
+ htsmsg_destroy(m);
+ }
+ pthread_mutex_lock(&global_lock);
+ }
+ pthread_mutex_lock(&idnode_lnotify_mutex);
+ if (!uuid_set_empty(&idnode_lnotify_set)) {
+ set = idnode_lnotify_set;
+ uuid_set_init(&idnode_lnotify_set, 10);
+ }
+ if (!uuid_set_empty(&idnode_lnotify_title_set)) {
+ tset = idnode_lnotify_title_set;
+ uuid_set_init(&idnode_lnotify_title_set, 10);
+ }
+ pthread_mutex_unlock(&idnode_lnotify_mutex);
+ if (!uuid_set_empty(&set)) {
+ UUID_SET_FOREACH(uuid, &set, u32) {
+ in = idnode_find0(uuid, NULL, NULL);
+ if (in)
+ idnode_notify_changed(in);
+ }
+ uuid_set_free(&set);
+ }
+ if (!uuid_set_empty(&tset)) {
+ UUID_SET_FOREACH(uuid, &tset, u32) {
+ in = idnode_find0(uuid, NULL, NULL);
+ if (in)
+ idnode_notify_title_changed(in);
+ }
+ uuid_set_free(&tset);
}
- pthread_mutex_lock(&global_lock);
}
mtimer_disarm(&save_timer);
return NULL;
}
+/* **************************************************************************
+ * Light update - outside global lock
+ * *************************************************************************/
+
+void idnode_lnotify_changed( void *in )
+{
+ pthread_mutex_lock(&idnode_lnotify_mutex);
+ uuid_set_add(&idnode_lnotify_set, &((idnode_t *)in)->in_uuid);
+ pthread_mutex_unlock(&idnode_lnotify_mutex);
+ tvh_cond_signal(&save_cond, 0);
+}
+
+void idnode_lnotify_title_changed( void *in )
+{
+ pthread_mutex_lock(&idnode_lnotify_mutex);
+ uuid_set_add(&idnode_lnotify_title_set, &((idnode_t *)in)->in_uuid);
+ pthread_mutex_unlock(&idnode_lnotify_mutex);
+ tvh_cond_signal(&save_cond, 0);
+}
+
/* **************************************************************************
* Initialization
* *************************************************************************/
RB_INIT(&idrootclasses);
TAILQ_INIT(&idnodes_save);
tvh_cond_init(&save_cond);
+ uuid_set_init(&idnode_lnotify_set, 10);
+ uuid_set_init(&idnode_lnotify_title_set, 10);
}
void
free(il);
}
SKEL_FREE(idclasses_skel);
+
+ uuid_set_free(&idnode_lnotify_set);
+ uuid_set_free(&idnode_lnotify_title_set);
}
/******************************************************************************
/* Callbacks */
idnode_set_t *(*ic_get_childs) (idnode_t *self);
- const char *(*ic_get_title) (idnode_t *self, const char *lang);
+ void (*ic_get_title) (idnode_t *self, const char *lang, char *dst, size_t dstsize);
void (*ic_changed) (idnode_t *self);
htsmsg_t *(*ic_save) (idnode_t *self, char *filename, size_t fsize);
void (*ic_load) (idnode_t *self, htsmsg_t *conf);
extern idnode_t tvhlog_conf;
extern const idclass_t tvhlog_conf_class;
+extern pthread_mutex_t idnode_mutex;
void idnode_boot(void);
void idnode_init(void);
void idnode_done(void);
+static inline void idnode_lock(void)
+ { pthread_mutex_lock(&idnode_mutex); }
+static inline void idnode_unlock(void)
+ { pthread_mutex_unlock(&idnode_mutex); }
+
#define IDNODE_SHORT_UUID (1<<0)
int idnode_insert(idnode_t *in, const char *uuid, const idclass_t *idc, int flags);
uint32_t idnode_get_short_uuid (const idnode_t *in);
const char *idnode_uuid_as_str (const idnode_t *in, char *buf);
idnode_set_t *idnode_get_childs (idnode_t *in);
-const char *idnode_get_title (idnode_t *in, const char *lang);
+const char *idnode_get_title (idnode_t *in, const char *lang, char *dst, size_t dstsize);
int idnode_is_leaf (idnode_t *in);
int idnode_is_instance (idnode_t *in, const idclass_t *idc);
void idnode_delete (idnode_t *in);
void idnode_notify (idnode_t *in, const char *action);
void idnode_notify_changed (void *in);
-void idnode_notify_title_changed (void *in, const char *lang);
+void idnode_notify_title_changed (void *in);
+void idnode_notify_title_changed_lang (void *in, const char *lang);
+
+void idnode_lnotify_changed (void *in);
+void idnode_lnotify_title_changed (void *in);
void idclass_register ( const idclass_t *idc );
const idclass_t *idclass_find ( const char *name );
* IPTV input
* *************************************************************************/
-static const char *
-iptv_input_class_get_title ( idnode_t *self, const char *lang )
+static void
+iptv_input_class_get_title
+ ( idnode_t *self, const char *lang, char *dst, size_t dstsize )
{
- return tvh_gettext_lang(lang, N_("IPTV"));
+ snprintf(dst, dstsize, "%s", tvh_gettext_lang(lang, N_("IPTV")));
}
extern const idclass_t mpegts_input_class;
iptv_network_t *in = (iptv_network_t*)im->mm_network;
mpegts_mux_instance_t *mmi;
mpegts_pcr_t pcr;
+ char buf[384];
int64_t s64;
pcr.pcr_first = PTS_UNSET;
in->in_bps > in->in_max_bandwidth * 1024) {
if (!in->in_bw_limited) {
tvhinfo(LS_IPTV, "%s bandwidth limited exceeded",
- idnode_get_title(&in->mn_id, NULL));
+ idnode_get_title(&in->mn_id, NULL, buf, sizeof(buf)));
in->in_bw_limited = 1;
}
}
return is;
}
-static const char *
-linuxdvb_adapter_class_get_title ( idnode_t *in, const char *lang )
+static void
+linuxdvb_adapter_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
linuxdvb_adapter_t *la = (linuxdvb_adapter_t*)in;
- return la->la_name ?: la->la_rootpath;
+ snprintf(dst, dstsize, "%s", la->la_name ?: la->la_rootpath);
}
static const void *
#endif
}
- idnode_notify_title_changed(&lca->lca_id, lang);
+ idnode_notify_title_changed(&lca->lca_id);
}
}
CIPLUS13_DATA_RATE_72_MBPS);
}
-static const char *
-linuxdvb_ca_class_get_title ( idnode_t *in, const char *lang )
+static void
+linuxdvb_ca_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
linuxdvb_ca_t *lca = (linuxdvb_ca_t *) in;
- static char buf[256];
if (!lca->lca_enabled)
- snprintf(buf, sizeof(buf), "ca%u: disabled", lca->lca_number);
+ snprintf(dst, dstsize, "ca%u: disabled", lca->lca_number);
else if (lca->lca_state == CA_SLOT_STATE_EMPTY)
- snprintf(buf, sizeof(buf), "ca%u: slot empty", lca->lca_number);
+ snprintf(dst, dstsize, "ca%u: slot empty", lca->lca_number);
else
- snprintf(buf, sizeof(buf), "ca%u: %s (%s)", lca->lca_number,
- lca->lca_cam_menu_string, lca->lca_state_str);
-
- return buf;
+ snprintf(dst, dstsize, "ca%u: %s (%s)", lca->lca_number,
+ lca->lca_cam_menu_string, lca->lca_state_str);
}
static const void *
snprintf(lca->lca_cam_menu_string, sizeof(lca->lca_cam_menu_string),
"%.*s", menu_string_len, menu_string);
- idnode_notify_title_changed(&lca->lca_id, NULL);
+ idnode_notify_title_changed(&lca->lca_id);
return 0;
}
if (lca->lca_state != state) {
tvhnotice(LS_LINUXDVB, "%s: CAM slot %u status changed to %s",
lca->lca_name, csi.num, lca->lca_state_str);
- idnode_notify_title_changed(&lca->lca_id, NULL);
+ idnode_notify_title_changed(&lca->lca_id);
lca->lca_state = state;
}
/* prevention of self raised DiSEqC collisions */
static pthread_mutex_t linuxdvb_en50494_lock;
-static const char *
-linuxdvb_en50494_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_en50494_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- static const char *title = N_("Unicable I (EN50494)");
- return tvh_gettext_lang(lang, title);
+ const char *title = N_("Unicable I (EN50494)");
+ snprintf(dst, dstsize, "%s", tvh_gettext_lang(lang, title));
}
-static const char *
-linuxdvb_en50607_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_en50607_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- static const char *title = N_("Unicable II (EN50607)");
- return tvh_gettext_lang(lang, title);
+ const char *title = N_("Unicable II (EN50607)");
+ snprintf(dst, dstsize, "%s", tvh_gettext_lang(lang, title));
}
static htsmsg_t *
int lnb_switch;
} linuxdvb_lnb_conf_t;
-static const char *
-linuxdvb_lnb_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_lnb_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- static char buf[256];
linuxdvb_diseqc_t *ld = (linuxdvb_diseqc_t*)o;
- snprintf(buf, sizeof(buf), "LNB: %s", ld->ld_type);
- return buf;
+ snprintf(dst, dstsize, tvh_gettext_lang(lang, N_("LNB: %s")), ld->ld_type);
}
extern const idclass_t linuxdvb_diseqc_class;
#ifndef ROTOR_TEST
-static const char *
-linuxdvb_rotor_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_rotor_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- static char buf[256];
linuxdvb_diseqc_t *ld = (linuxdvb_diseqc_t*)o;
- snprintf(buf, sizeof(buf), "Rotor: %s", ld->ld_type);
- return buf;
+ snprintf(dst, dstsize, tvh_gettext_lang(lang, N_("Rotor: %s")), ld->ld_type);
}
extern const idclass_t linuxdvb_diseqc_class;
linuxdvb_satconf_class_network_getset(2);
linuxdvb_satconf_class_network_getset(3);
-static const char *
-linuxdvb_satconf_class_get_title ( idnode_t *p, const char *lang )
+static void
+linuxdvb_satconf_class_get_title
+ ( idnode_t *p, const char *lang, char *dst, size_t dstsize )
{
linuxdvb_satconf_t *ls = (linuxdvb_satconf_t*)p;
struct linuxdvb_satconf_type *lst =
linuxdvb_satconf_type_find(ls->ls_type);
- return lst ? lst->name : ls->ls_type;
+ snprintf(dst, dstsize, "%s", lst ? lst->name : ls->ls_type);
}
static void
return &prop_ptr;
}
-static const char *
-linuxdvb_satconf_ele_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_satconf_ele_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- return ((linuxdvb_satconf_ele_t *)o)->lse_name;
+ snprintf(dst, dstsize, "%s", ((linuxdvb_satconf_ele_t *)o)->lse_name);
}
static idnode_set_t *
.id = "displayname",
.name = N_("Name"),
.off = offsetof(linuxdvb_satconf_ele_t, lse_name),
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
},
{
.type = PT_INT,
* DiseqC
*****************************************************************************/
-static const char *
-linuxdvb_diseqc_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_diseqc_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
linuxdvb_diseqc_t *ld = (linuxdvb_diseqc_t*)o;
- return ld->ld_type;
+ snprintf(dst, dstsize, "%s", ld->ld_type);
}
static void
return strtab2htsmsg(tab, 1, lang);
}
-static const char *
-linuxdvb_switch_class_get_title ( idnode_t *o, const char *lang )
+static void
+linuxdvb_switch_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t dstsize )
{
- static char buf[256];
linuxdvb_diseqc_t *ld = (linuxdvb_diseqc_t*)o;
- snprintf(buf, sizeof(buf), tvh_gettext_lang(lang, N_("Switch: %s")), ld->ld_type);
- return buf;
+ snprintf(dst, dstsize, tvh_gettext_lang(lang, N_("Switch: %s")), ld->ld_type);
}
extern const idclass_t linuxdvb_diseqc_class;
* Class definition
* *************************************************************************/
-static const char *
-mpegts_input_class_get_title ( idnode_t *in, const char *lang )
+static void
+mpegts_input_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
- static char buf[512];
mpegts_input_t *mi = (mpegts_input_t*)in;
- mi->mi_display_name(mi, buf, sizeof(buf));
- return buf;
+ mi->mi_display_name(mi, dst, dstsize);
}
const void *
{
char *str;
mpegts_network_link_t *mnl;
+ mpegts_network_t *mn;
mpegts_input_t *mi = obj;
htsmsg_t *l = htsmsg_create_list();
+ char buf[384];
- LIST_FOREACH(mnl, &mi->mi_networks, mnl_mi_link)
- htsmsg_add_str(l, NULL, idnode_get_title(&mnl->mnl_network->mn_id, lang));
+ LIST_FOREACH(mnl, &mi->mi_networks, mnl_mi_link) {
+ mn = mnl->mnl_network;
+ htsmsg_add_str(l, NULL, idnode_get_title(&mn->mn_id, lang, buf, sizeof(buf)));
+ }
str = htsmsg_list_2_csv(l, ',', 1);
htsmsg_destroy(l);
{
mpegts_input_t *mi = self, *mi2;
tvh_input_t *ti;
- char ubuf[UUID_HEX_SIZE];
+ char ubuf[UUID_HEX_SIZE], buf[384];
htsmsg_t *m = htsmsg_create_list();
htsmsg_t *e = htsmsg_create_key_val("", tvh_gettext_lang(lang, N_("Not linked")));
htsmsg_add_msg(m, NULL, e);
mi2 = (mpegts_input_t *)ti;
if (mi2 != mi) {
e = htsmsg_create_key_val(idnode_uuid_as_str(&ti->ti_id, ubuf),
- idnode_get_title(&mi2->ti_id, lang));
+ idnode_get_title(&mi2->ti_id, lang, buf, sizeof(buf)));
htsmsg_add_msg(m, NULL, e);
}
}
.name = N_("Name"),
.desc = N_("Name of the tuner/adapter."),
.off = offsetof(mpegts_input_t, mi_name),
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
},
{
.type = PT_BOOL,
if (mm->mm_delete) mm->mm_delete(mm, 1);
}
-static const char *
-mpegts_mux_class_get_title ( idnode_t *self, const char *lang )
+static void
+mpegts_mux_class_get_title
+ ( idnode_t *self, const char *lang, char *dst, size_t dstsize )
{
- static __thread char buf[256];
- mpegts_mux_nice_name((mpegts_mux_t*)self, buf, sizeof(buf));
- return buf;
+ mpegts_mux_nice_name((mpegts_mux_t*)self, dst, dstsize);
}
static const void *
return NULL;
}
-static const char *
-mpegts_network_class_get_title ( idnode_t *in, const char *lang )
+static void
+mpegts_network_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
- static char buf[256];
mpegts_network_t *mn = (mpegts_network_t*)in;
- *buf = 0;
+ *dst = 0;
if (mn->mn_display_name)
- mn->mn_display_name(mn, buf, sizeof(buf));
- return buf;
+ mn->mn_display_name(mn, dst, dstsize);
}
static const void *
.name = N_("Network name"),
.desc = N_("Name of the network."),
.off = offsetof(mpegts_network_t, mn_network_name),
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
},
{
.type = PT_STR,
return is;
}
-static const char *
-satip_device_class_get_title( idnode_t *in, const char *lang )
+static void
+satip_device_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
- static char buf[256];
satip_device_t *sd = (satip_device_t *)in;
- snprintf(buf, sizeof(buf),
- "%s - %s", sd->sd_info.friendlyname, sd->sd_info.addr);
- return buf;
+ snprintf(dst, dstsize, "%s - %s", sd->sd_info.friendlyname, sd->sd_info.addr);
}
static const char *satip_tunercfg_tab[] = {
return str;
}
-static const char *
-satip_satconf_class_get_title ( idnode_t *o, const char *lang )
+static void
+satip_satconf_class_get_title
+ ( idnode_t *o, const char *lang, char *dst, size_t size )
{
- return ((satip_satconf_t *)o)->sfc_name;
+ snprintf(dst, size, "%s", ((satip_satconf_t *)o)->sfc_name);
}
static void
.name = N_("Name"),
.desc = N_("Set the display name."),
.off = offsetof(satip_satconf_t, sfc_name),
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
},
{
.type = PT_INT,
static pthread_mutex_t tvhdhomerun_discovery_lock;
static tvh_cond_t tvhdhomerun_discovery_cond;
-static const char *
-tvhdhomerun_device_class_get_title( idnode_t *in, const char *lang )
+static void
+tvhdhomerun_device_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
tvhdhomerun_device_t *hd = (tvhdhomerun_device_t *)in;
char ip[64];
tcp_get_str_from_ip(&hd->hd_info.ip_address, ip, sizeof(ip));
- snprintf(prop_sbuf, PROP_SBUF_LEN,
+ snprintf(dst, dstsize,
"%s - %s", hd->hd_info.friendlyname, ip);
- return prop_sbuf;
}
static const void *
struct memoryinfo_list memoryinfo_entries;
-static const char *
-service_class_get_title ( idnode_t *self, const char *lang )
+static void
+service_class_get_title
+ ( idnode_t *self, const char *lang, char *dst, size_t dstsize )
{
- return ((memoryinfo_t *)self)->my_name;
+ snprintf(dst, dstsize, "%s", ((memoryinfo_t *)self)->my_name);
}
CLASS_DOC(memoryinfo)
#include "htsmsg.h"
-#define NOTIFY_REWRITE_SUBSCRIPTIONS 1
+#define NOTIFY_REWRITE_TITLE 1
+#define NOTIFY_REWRITE_SUBSCRIPTIONS 2
void notify_by_msg(const char *class, htsmsg_t *m, int rewrite);
return c;
}
-static const char *
-profile_class_get_title ( idnode_t *in, const char *lang )
+static void
+profile_class_get_title
+ ( idnode_t *in, const char *lang, char *dst, size_t dstsize )
{
profile_t *pro = (profile_t *)in;
- if (pro->pro_name && pro->pro_name[0])
- return pro->pro_name;
- snprintf(prop_sbuf, sizeof(prop_sbuf), "%s", idclass_get_caption(in->in_class, lang));
- return prop_sbuf;
+ if (pro->pro_name && pro->pro_name[0]) {
+ snprintf(dst, dstsize, "%s", pro->pro_name);
+ } else {
+ snprintf(dst, dstsize, "%s", idclass_get_caption(in->in_class, lang));
+ }
}
static void
.desc = N_("The name of the profile."),
.off = offsetof(profile_t, pro_name),
.get_opts = profile_class_name_opts,
- .notify = idnode_notify_title_changed,
+ .notify = idnode_notify_title_changed_lang,
.group = 1
},
{
service_mapper_create);
}
-static const char *
-service_class_get_title ( idnode_t *self, const char *lang )
+static void
+service_class_get_title
+ ( idnode_t *self, const char *lang, char *dst, size_t dstsize )
{
- return service_get_full_channel_name((service_t *)self);
+ snprintf(dst, dstsize, "%s",
+ service_get_full_channel_name((service_t *)self) ?: "");
}
static const void *
if (s->ths_prch != NULL) {
pro = s->ths_prch->prch_pro;
if (pro)
- htsmsg_add_str(m, "profile", idnode_get_title(&pro->pro_id, lang));
+ htsmsg_add_str(m, "profile",
+ idnode_get_title(&pro->pro_id, lang, buf, sizeof(buf)));
}
} else if(s->ths_dvrfile != NULL)
}
}
+static void
+comet_mailbox_rewrite_title(htsmsg_t *m, const char *lang)
+{
+ idnode_t *in;
+ const char *s = htsmsg_get_str(m, "uuid");
+ char buf[384];
+ if (s) {
+ idnode_lock();
+ in = idnode_find(s, NULL, NULL);
+ if (in)
+ htsmsg_set_str(m, "text", idnode_get_title(in, lang, buf, sizeof(buf)));
+ idnode_unlock();
+ }
+}
+
static void
comet_mailbox_rewrite_msg(int rewrite, htsmsg_t *m, const char *lang)
{
switch (rewrite) {
+ case NOTIFY_REWRITE_TITLE:
+ comet_mailbox_rewrite_title(m, lang);
+ break;
case NOTIFY_REWRITE_SUBSCRIPTIONS:
comet_mailbox_rewrite_str(m, "state", lang);
break;