(maildir_msg_finish_delivery): Take
original message as the 3rd argument. Use message attributes to select the subdirectory to place it into.
Showing
1 changed file
with
19 additions
and
3 deletions
... | @@ -480,11 +480,27 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm) | ... | @@ -480,11 +480,27 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm) |
480 | } | 480 | } |
481 | 481 | ||
482 | static int | 482 | static int |
483 | maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm) | 483 | maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm, |
484 | const mu_message_t orig_msg) | ||
484 | { | 485 | { |
485 | struct _maildir_message *msg = (struct _maildir_message *) amm; | 486 | struct _maildir_message *msg = (struct _maildir_message *) amm; |
486 | char *oldname = maildir_mkfilename (amd->name, TMPSUF, msg->file_name); | 487 | char *oldname = maildir_mkfilename (amd->name, TMPSUF, msg->file_name); |
487 | char *newname = maildir_mkfilename (amd->name, NEWSUF, msg->file_name); | 488 | char *newname; |
489 | mu_attribute_t attr; | ||
490 | int flags; | ||
491 | |||
492 | if (mu_message_get_attribute (orig_msg, &attr) == 0 | ||
493 | && mu_attribute_is_read (attr) | ||
494 | && mu_attribute_get_flags (attr, &flags) == 0) | ||
495 | { | ||
496 | msg->dir = CURSUF; | ||
497 | newname = mk_info_filename (amd->name, CURSUF, msg->file_name, flags); | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | msg->dir = NEWSUF; | ||
502 | newname = maildir_mkfilename (amd->name, NEWSUF, msg->file_name); | ||
503 | } | ||
488 | 504 | ||
489 | unlink (newname); | 505 | unlink (newname); |
490 | if (link (oldname, newname) == 0) | 506 | if (link (oldname, newname) == 0) |
... | @@ -493,7 +509,7 @@ maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm) | ... | @@ -493,7 +509,7 @@ maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm) |
493 | { | 509 | { |
494 | return errno; /* FIXME? */ | 510 | return errno; /* FIXME? */ |
495 | } | 511 | } |
496 | msg->dir = NEWSUF; | 512 | |
497 | free (oldname); | 513 | free (oldname); |
498 | free (newname); | 514 | free (newname); |
499 | return 0; | 515 | return 0; | ... | ... |
-
Please register or sign in to post a comment