+static inline struct mail_s *ensure_mail_thread(struct text_object *obj,
+ void *thread(void *), const char *text)
+{
+ if (obj->char_b && info.mail) {
+ // this means we use info
+ if (!info.mail->p_timed_thread) {
+ info.mail->p_timed_thread =
+ timed_thread_create(thread,
+ (void *) info.mail, info.mail->interval * 1000000);
+ if (!info.mail->p_timed_thread) {
+ NORM_ERR("Error creating %s timed thread", text);
+ }
+ timed_thread_register(info.mail->p_timed_thread,
+ &info.mail->p_timed_thread);
+ if (timed_thread_run(info.mail->p_timed_thread)) {
+ NORM_ERR("Error running %s timed thread", text);
+ }
+ }
+ return 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;
+}
+
+static void *imap_thread(void *arg)