For consistency, reduced all operations
with flags to manipulations with _imap4d_attrlist array RFC2060 states that \Seen flag means "Message has been read", so it should be mapped to our MU_ATTRIBUTE_READ. (util_print_flags, util_attribute_matches_flag): New functions.
Showing
1 changed file
with
48 additions
and
7 deletions
... | @@ -731,6 +731,7 @@ util_strcasestr (const char *haystack, const char *needle) | ... | @@ -731,6 +731,7 @@ util_strcasestr (const char *haystack, const char *needle) |
731 | return NULL; | 731 | return NULL; |
732 | } | 732 | } |
733 | 733 | ||
734 | |||
734 | struct | 735 | struct |
735 | { | 736 | { |
736 | char *name; | 737 | char *name; |
... | @@ -740,7 +741,7 @@ struct | ... | @@ -740,7 +741,7 @@ struct |
740 | { "\\Flagged", MU_ATTRIBUTE_FLAGGED }, | 741 | { "\\Flagged", MU_ATTRIBUTE_FLAGGED }, |
741 | { "\\Deleted", MU_ATTRIBUTE_DELETED }, | 742 | { "\\Deleted", MU_ATTRIBUTE_DELETED }, |
742 | { "\\Draft", MU_ATTRIBUTE_DRAFT }, | 743 | { "\\Draft", MU_ATTRIBUTE_DRAFT }, |
743 | { "\\Seen", MU_ATTRIBUTE_SEEN }, | 744 | { "\\Seen", MU_ATTRIBUTE_READ }, |
744 | { "\\Recent", MU_ATTRIBUTE_RECENT }, | 745 | { "\\Recent", MU_ATTRIBUTE_RECENT }, |
745 | }; | 746 | }; |
746 | 747 | ||
... | @@ -761,19 +762,20 @@ util_attribute_to_type (const char *item, int *type) | ... | @@ -761,19 +762,20 @@ util_attribute_to_type (const char *item, int *type) |
761 | return 1; | 762 | return 1; |
762 | } | 763 | } |
763 | 764 | ||
765 | /* Note: currently unused. Not needed, possibly? */ | ||
764 | int | 766 | int |
765 | util_type_to_attribute (int type, char **attr_str) | 767 | util_type_to_attribute (int type, char **attr_str) |
766 | { | 768 | { |
767 | *attr_str = NULL; | ||
768 | if (type == MU_ATTRIBUTE_RECENT) | ||
769 | *attr_str = strdup("\\Recent"); | ||
770 | else | ||
771 | { | ||
772 | char *attr_list[NATTR]; | 769 | char *attr_list[NATTR]; |
773 | int nattr = 0; | 770 | int nattr = 0; |
774 | int i; | 771 | int i; |
775 | size_t len = 0; | 772 | size_t len = 0; |
776 | 773 | ||
774 | if (MU_ATTRIBUTE_IS_UNSEEN(type)) | ||
775 | *attr_str = strdup("\\Recent"); | ||
776 | else | ||
777 | *attr_str = NULL; | ||
778 | |||
777 | for (i = 0; i < _imap4d_nattr; i++) | 779 | for (i = 0; i < _imap4d_nattr; i++) |
778 | if (type & _imap4d_attrlist[i].flag) | 780 | if (type & _imap4d_attrlist[i].flag) |
779 | { | 781 | { |
... | @@ -792,13 +794,52 @@ util_type_to_attribute (int type, char **attr_str) | ... | @@ -792,13 +794,52 @@ util_type_to_attribute (int type, char **attr_str) |
792 | strcat(*attr_str, " "); | 794 | strcat(*attr_str, " "); |
793 | } | 795 | } |
794 | } | 796 | } |
795 | } | ||
796 | 797 | ||
797 | if (!*attr_str) | 798 | if (!*attr_str) |
798 | imap4d_bye (ERR_NO_MEM); | 799 | imap4d_bye (ERR_NO_MEM); |
799 | return 0; | 800 | return 0; |
800 | } | 801 | } |
801 | 802 | ||
803 | void | ||
804 | util_print_flags(attribute_t attr) | ||
805 | { | ||
806 | int i; | ||
807 | int flags = 0; | ||
808 | int space = 0; | ||
809 | |||
810 | attribute_get_flags (attr, &flags); | ||
811 | for (i = 0; i < _imap4d_nattr; i++) | ||
812 | if (flags & _imap4d_attrlist[i].flag) | ||
813 | { | ||
814 | if (space) | ||
815 | util_send (" "); | ||
816 | else | ||
817 | space = 1; | ||
818 | util_send (_imap4d_attrlist[i].name); | ||
819 | } | ||
820 | |||
821 | if (MU_ATTRIBUTE_IS_UNSEEN(flags)) | ||
822 | { | ||
823 | if (space) | ||
824 | util_send (" "); | ||
825 | util_send ("\\Recent"); | ||
826 | } | ||
827 | } | ||
828 | |||
829 | int | ||
830 | util_attribute_matches_flag (attribute_t attr, const char *item) | ||
831 | { | ||
832 | int flags = 0, mask = 0; | ||
833 | |||
834 | attribute_get_flags (attr, &flags); | ||
835 | util_attribute_to_type (item, &mask); | ||
836 | if (mask == MU_ATTRIBUTE_RECENT) | ||
837 | return MU_ATTRIBUTE_IS_UNSEEN (flags); | ||
838 | |||
839 | return flags & mask; | ||
840 | } | ||
841 | |||
842 | |||
802 | int | 843 | int |
803 | util_parse_attributes(char *items, char **save, int *flags) | 844 | util_parse_attributes(char *items, char **save, int *flags) |
804 | { | 845 | { | ... | ... |
-
Please register or sign in to post a comment