2 * $Id: flag.h 1142 2008-08-13 17:22:21Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2006-2007 University of Washington
6 * Copyright 2013-2016 Eduardo Chappa
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_FLAG_INCLUDED
18 #define PITH_FLAG_INCLUDED
21 #include "../pith/msgno.h"
25 * Useful def's to specify interesting flags
27 #define F_NONE 0x00000000
28 #define F_SEEN 0x00000001
29 #define F_UNSEEN 0x00000002
30 #define F_DEL 0x00000004
31 #define F_UNDEL 0x00000008
32 #define F_FLAG 0x00000010
33 #define F_UNFLAG 0x00000020
34 #define F_ANS 0x00000040
35 #define F_UNANS 0x00000080
36 #define F_FWD 0x00000100
37 #define F_UNFWD 0x00000200
38 #define F_RECENT 0x00000400
39 #define F_UNRECENT 0x00000800
40 #define F_DRAFT 0x00001000
41 #define F_UNDRAFT 0x00002000
43 #define F_SRCHBACK 0x00004000 /* search backwards instead of forw */
44 #define F_NOFILT 0x00008000 /* defer processing filters */
46 #define F_OR_SEEN 0x00010000
47 #define F_OR_UNSEEN 0x00020000
48 #define F_OR_DEL 0x00040000
49 #define F_OR_UNDEL 0x00080000
50 #define F_OR_FLAG 0x00100000
51 #define F_OR_UNFLAG 0x00200000
52 #define F_OR_ANS 0x00400000
53 #define F_OR_UNANS 0x00800000
54 #define F_OR_FWD 0x01000000
55 #define F_OR_UNFWD 0x02000000
56 #define F_OR_RECENT 0x04000000
57 #define F_OR_UNRECENT 0x08000000
59 #define F_KEYWORD 0x10000000
60 #define F_UNKEYWORD 0x20000000
62 #define F_COMMENT 0x40000000
66 * Useful flag checking macro
68 #define FLAG_MATCH(F,M,S) (((((F)&F_SEEN) ? (M)->seen \
69 : ((F)&F_UNSEEN) ? !(M)->seen : 1) \
70 && (((F)&F_DEL) ? (M)->deleted \
71 : ((F)&F_UNDEL) ? !(M)->deleted : 1) \
72 && (((F)&F_ANS) ? (M)->answered \
73 : ((F)&F_UNANS) ? !(M)->answered : 1) \
74 && (((F)&F_FWD) ? ((S) && user_flag_is_set((S),(M)->msgno,FORWARDED_FLAG)) \
75 : ((F)&F_UNFWD) ? ((S) && !user_flag_is_set((S),(M)->msgno,FORWARDED_FLAG)) : 1) \
76 && (((F)&F_FLAG) ? (M)->flagged \
77 : ((F)&F_UNFLAG) ? !(M)->flagged : 1) \
78 && (((F)&F_RECENT) ? (M)->recent \
79 : ((F)&F_UNRECENT) ? !(M)->recent : 1)) \
80 || ((((F)&F_OR_SEEN) ? (M)->seen \
81 : ((F)&F_OR_UNSEEN) ? !(M)->seen : 0) \
82 || (((F)&F_OR_DEL) ? (M)->deleted \
83 : ((F)&F_OR_UNDEL) ? !(M)->deleted : 0) \
84 || (((F)&F_OR_ANS) ? (M)->answered \
85 : ((F)&F_OR_UNANS) ? !(M)->answered : 0) \
86 || (((F)&F_OR_FWD) ? ((S) && user_flag_is_set((S),(M)->msgno,FORWARDED_FLAG)) \
87 : ((F)&F_OR_UNFWD) ? !((S) && user_flag_is_set((S),(M)->msgno,FORWARDED_FLAG)) : 0) \
88 || (((F)&F_OR_FLAG)? (M)->flagged \
89 : ((F)&F_OR_UNFLAG) ? !(M)->flagged : 0) \
90 || (((F)&F_OR_RECENT)? (M)->recent \
91 : ((F)&F_OR_UNRECENT) ? !(M)->recent : 0)))
95 * These are def's to help manage local, private flags pine uses
96 * to maintain it's mapping table (see MSGNO_S def). The local flags
97 * are actually stored in spare bits in c-client's per-message
98 * MESSAGECACHE struct. But they're private, you ask. Since the flags
99 * are tied to the actual message (independent of the mapping), storing
100 * them in the c-client means we don't have to worry about them during
101 * sorting and such. See {set,get}_lflags for more on local flags.
103 * MN_HIDE hides messages which are not visible due to Zooming.
104 * MN_EXLD hides messages which have been filtered away.
105 * MN_SLCT marks messages which have been Selected.
106 * MN_SRCH marks messages that are the result of a search
107 * MN_COLL marks a point in the thread tree where the view has been
108 * collapsed, hiding the messages below that point
109 * MN_CHID hides messages which are collapsed out of view
110 * MN_CHID2 is similar to CHID and is introduced for performance reasons.
111 * When using the separate-thread-index the toplevel messages are
112 * MN_COLL and everything else is MN_CHID. However, if we view a
113 * single thread from there, instead of marking all of those top
114 * level threads MN_HIDE (or something) we change the semantics
115 * of the flags. When viewing a single thread we mark the messages
116 * of the thread with MN_CHID2 for performance reasons.
118 #define MN_NONE 0x0000 /* No Pine specific flags */
119 #define MN_HIDE 0x0001 /* Pine specific hidden */
120 #define MN_EXLD 0x0002 /* Pine specific excluded */
121 #define MN_SLCT 0x0004 /* Pine specific selected */
122 #define MN_COLL 0x0008 /* Pine specific collapsed */
123 #define MN_CHID 0x0010 /* A parent somewhere above us is collapsed */
124 #define MN_CHID2 0x0020 /* performance related */
125 #define MN_USOR 0x0040 /* New message which hasn't been sorted yet */
126 #define MN_STMP 0x0080 /* Temporary storage for a per-message bit */
127 #define MN_SRCH 0x0100 /* Search result */
130 /* next_sorted_flagged options */
131 #define NSF_TRUST_FLAGS 0x01 /* input flag, don't need to ping */
132 #define NSF_SKIP_CHID 0x02 /* input flag, skip MN_CHID messages */
133 #define NSF_SEARCH_BACK 0x04 /* input flag, search backward if none forw */
134 #define NSF_FLAG_MATCH 0x08 /* return flag, actually got a match */
136 /* first_sorted_flagged options */
137 #define FSF_LAST 0x01 /* last instead of first */
138 #define FSF_SKIP_CHID 0x02 /* skip MN_CHID messages */
144 /* exported protoypes */
145 long count_flagged(MAILSTREAM
*, long);
146 MsgNo
first_sorted_flagged(unsigned long, MAILSTREAM
*, long, int);
147 MsgNo
next_sorted_flagged(unsigned long, MAILSTREAM
*, long, int *);
148 int get_lflag(MAILSTREAM
*, MSGNO_S
*, long, int);
149 int set_lflag(MAILSTREAM
*, MSGNO_S
*, long, int, int);
150 void copy_lflags(MAILSTREAM
*, MSGNO_S
*, int, int);
151 void set_lflags(MAILSTREAM
*, MSGNO_S
*, int, int);
152 long any_lflagged(MSGNO_S
*, int);
155 #endif /* PITH_FLAG_INCLUDED */