static void mail_log_group(struct mailbox *box, const struct mail_log_group_changes *group, string_t *str) { const struct seq_range *range; unsigned int i, count; str_printfa(str, "%s: ", mail_log_event_get_name(group->event)); if ((mail_log_set.fields & MAIL_LOG_FIELD_UID) != 0 && array_is_created(&group->uids)) { str_append(str, "uids="); range = array_get(&group->uids, &count); for (i = 0; i < count; i++) { if (i != 0) str_append_c(str, ','); str_printfa(str, "%u", range[i].seq1); if (range[i].seq1 != range[i].seq2) str_printfa(str, "-%u", range[i].seq2); } str_append(str, ", "); } if ((mail_log_set.fields & MAIL_LOG_FIELD_BOX) != 0) mail_log_append_mailbox_name(str, box); if (group->event == MAIL_LOG_EVENT_COPY) str_printfa(str, "dest=%s, ", group->data); if (group->psize_total != 0) str_printfa(str, "size=%"PRIuUOFF_T", ", group->psize_total); if (group->vsize_total != 0) str_printfa(str, "size=%"PRIuUOFF_T", ", group->vsize_total); /*str_truncate(str, str_len(str)-2);*/ }
static void mail_log_append_mail_message_real(struct mail_log_mail_txn_context *ctx, struct mail *mail, enum mail_log_event event, const char *desc) { struct mail_log_user *muser = MAIL_LOG_USER_CONTEXT(mail->box->storage->user); struct mail_log_message *msg; string_t *text; uoff_t size; msg = p_new(ctx->pool, struct mail_log_message, 1); text = t_str_new(128); str_append(text, desc); str_append(text, ": "); if ((muser->fields & MAIL_LOG_FIELD_BOX) != 0) { mail_log_append_mailbox_name(text, mail); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_UID) != 0) { if (event != MAIL_LOG_EVENT_SAVE && event != MAIL_LOG_EVENT_COPY) mail_log_append_uid(ctx, msg, text, mail->uid); else { /* with mbox mail->uid contains the uid, but handle this consistently with all mailbox formats */ mail_log_append_uid(ctx, msg, text, 0); } str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_MSGID) != 0) { mail_log_append_mail_header(text, mail, "msgid", "Message-ID"); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_PSIZE) != 0) { if (mail_get_physical_size(mail, &size) == 0) str_printfa(text, "size=%"PRIuUOFF_T, size); else str_printfa(text, "size=error"); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_VSIZE) != 0) { if (mail_get_virtual_size(mail, &size) == 0) str_printfa(text, "vsize=%"PRIuUOFF_T, size); else str_printfa(text, "vsize=error"); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_FROM) != 0) { mail_log_append_mail_header(text, mail, "from", "From"); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_SUBJECT) != 0) { mail_log_append_mail_header(text, mail, "subject", "Subject"); str_append(text, ", "); } if ((muser->fields & MAIL_LOG_FIELD_FLAGS) != 0) { str_printfa(text, "flags=("); imap_write_flags(text, mail_get_flags(mail), mail_get_keywords(mail)); str_append(text, "), "); } str_truncate(text, str_len(text)-2); msg->event = event; msg->text = p_strdup(ctx->pool, str_c(text)); DLLIST2_APPEND(&ctx->messages, &ctx->messages_tail, msg); }