+static struct mail_s *ensure_mail_thread(conky_context *ctx, struct text_object *obj,
+ void *thread(void *), const char *text)
+{
+ if (obj->char_b && ctx->info.mail) {
+ /* this means we use ctx->info */
+ if (!ctx->info.mail->p_timed_thread) {
+ ctx->info.mail->p_timed_thread =
+ timed_thread_create(thread,
+ (void *) ctx->info.mail, ctx->info.mail->interval * 1000000);
+ if (!ctx->info.mail->p_timed_thread) {
+ NORM_ERR("Error creating %s timed thread", text);
+ }
+ timed_thread_register(ctx->info.mail->p_timed_thread,
+ &ctx->info.mail->p_timed_thread);
+ if (timed_thread_run(ctx->info.mail->p_timed_thread)) {
+ NORM_ERR("Error running %s timed thread", text);
+ }
+ }
+ return ctx->info.mail;
+ } else if (obj->data.mail) {
+ // this means we use obj
+ if (!obj->data.mail->p_timed_thread) {
+ obj->data.mail->p_timed_thread =
+ timed_thread_create(thread,
+ (void *) obj->data.mail,
+ obj->data.mail->interval * 1000000);
+ if (!obj->data.mail->p_timed_thread) {
+ NORM_ERR("Error creating %s timed thread", text);
+ }
+ timed_thread_register(obj->data.mail->p_timed_thread,
+ &obj->data.mail->p_timed_thread);
+ if (timed_thread_run(obj->data.mail->p_timed_thread)) {
+ NORM_ERR("Error running %s timed thread", text);
+ }
+ }
+ return obj->data.mail;
+ } else if (!obj->a) {
+ // something is wrong, warn once then stop
+ NORM_ERR("There's a problem with your mail settings. "
+ "Check that the global mail settings are properly defined"
+ " (line %li).", obj->line);
+ obj->a++;
+ }
+ return NULL;
+}
+
+void generate_text_internal(conky_context *ctx, char *p, int p_max_size, struct
+ text_object root)