2 * $Id: msgno.h 1142 2008-08-13 17:22:21Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2006 University of Washington
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * ========================================================================
16 #ifndef PITH_MSGNO_INCLUDED
17 #define PITH_MSGNO_INCLUDED
20 #include "../pith/sorttype.h"
24 * Macros to support anything you'd ever want to do with a message
27 #define mn_init(P, m) msgno_init((P), (m), \
28 ps_global->def_sort, ps_global->def_sort_rev)
30 #define mn_get_cur(p) (((p) && (p)->select) \
31 ? (p)->select[(p)->sel_cur] : -1)
33 #define mn_set_cur(p, m) do{ \
35 (p)->select[(p)->sel_cur] = (m); \
39 #define mn_inc_cur(s, p, f) msgno_inc(s, p, f)
41 #define mn_dec_cur(s, p, f) msgno_dec(s, p, f)
43 #define mn_add_cur(p, m) do{ \
45 if((p)->sel_cnt+1L > (p)->sel_size){ \
46 (p)->sel_size += 10L; \
47 fs_resize((void **)&((p)->select), \
48 (size_t)(p)->sel_size \
51 (p)->select[((p)->sel_cnt)++] = (m); \
55 #define mn_total_cur(p) ((p) ? (p)->sel_cnt : 0L)
57 #define mn_first_cur(p) (((p) && (p)->sel_cnt > 0L) \
58 ? (p)->select[(p)->sel_cur = 0] : 0L)
60 #define mn_next_cur(p) (((p) && ((p)->sel_cur + 1) < (p)->sel_cnt) \
61 ? (p)->select[++((p)->sel_cur)] : -1L)
63 #define mn_is_cur(p, m) msgno_in_select((p), (m))
65 #define mn_reset_cur(p, m) do{ \
70 fs_resize((void **)&((p)->select), \
71 (size_t)(p)->sel_size * sizeof(long));\
72 (p)->select[0] = (m); \
76 #define mn_m2raw(p, m) (((p) && (p)->sort && (m) > 0 \
77 && (m) <= mn_get_total(p)) \
80 #define mn_raw2m(p, m) (((p) && (p)->isort && (m) > 0 \
81 && (m) <= mn_get_nmsgs(p)) \
84 #define mn_get_total(p) ((p) ? (p)->max_msgno : 0L)
86 #define mn_set_total(p, m) do{ if(p) (p)->max_msgno = (m); }while(0)
88 #define mn_get_nmsgs(p) ((p) ? (p)->nmsgs : 0L)
90 #define mn_set_nmsgs(p, m) do{ if(p) (p)->nmsgs = (m); }while(0)
92 #define mn_add_raw(p, m) msgno_add_raw((p), (m))
94 #define mn_flush_raw(p, m) msgno_flush_raw((p), (m))
96 #define mn_get_sort(p) ((p) ? (p)->sort_order : SortArrival)
98 #define mn_set_sort(p, t) msgno_set_sort((p), (t))
100 #define mn_get_revsort(p) ((p) ? (p)->reverse_sort : 0)
102 #define mn_set_revsort(p, t) do{ \
104 (p)->reverse_sort = (t); \
107 #define mn_get_mansort(p) ((p) ? (p)->manual_sort : 0)
109 #define mn_set_mansort(p, t) do{ \
111 (p)->manual_sort = (t); \
114 #define mn_give(P) msgno_give(P)
118 * This is *the* struct that keeps track of the pine message number to
119 * raw c-client sequence number mappings. The mapping is necessary
120 * because pine may re-sort or even hide (exclude) c-client numbers
121 * from the displayed list of messages. See mailindx.c:msgno_* and
122 * the mn_* macros above for how this things gets used. See
123 * mailcmd.c:pseudo_selected for an explanation of the funny business
124 * going on with the "hilited" field...
126 typedef struct msg_nos
{
127 long *select
, /* selected message array */
128 sel_cur
, /* current interesting msg */
129 sel_cnt
, /* its size */
130 sel_size
, /* its size */
131 *sort
, /* sorted array of msgno's */
132 sort_size
, /* its size */
133 *isort
, /* inverse of sort array */
134 isort_size
, /* its size */
135 max_msgno
, /* total messages in table */
136 nmsgs
, /* total msgs in folder */
137 hilited
, /* holder for "current" msg*/
138 top
, /* message at top of screen*/
140 top_after_thrd
; /* top after thrd view */
141 SortOrder sort_order
; /* list's current sort */
142 unsigned reverse_sort
:1; /* whether that's reversed */
143 unsigned manual_sort
:1; /* sorted with $ command */
144 long flagged_hid
, /* hidden count */
145 flagged_exld
, /* excluded count */
146 flagged_coll
, /* collapsed count */
147 flagged_chid
, /* collapsed-hidden count */
149 flagged_usor
, /* new unsorted mail */
150 flagged_tmp
, /* tmp flagged count */
151 flagged_stmp
, /* stmp flagged count */
152 flagged_invisible
, /* this one's different */
153 flagged_srch
, /* search result/not slctd */
154 visible_threads
; /* so is this one */
158 #define MSG_EX_DELETE 0x0001 /* part is deleted */
159 #define MSG_EX_RECENT 0x0002
160 #define MSG_EX_TESTED 0x0004 /* filtering has been run on this msg */
161 #define MSG_EX_FILTERED 0x0008 /* msg has actually been filtered away*/
162 #define MSG_EX_FILED 0x0010 /* msg has been filed */
163 #define MSG_EX_FILTONCE 0x0020
164 #define MSG_EX_FILEONCE 0x0040 /* These last two mean that the
165 message has been filtered or filed
166 already but the filter rule was
167 non-terminating so it is still
168 possible it will get filtered
169 again. When we're done, we flip
170 these two to EX_FILTERED and
171 EX_FILED, the permanent versions. */
172 #define MSG_EX_PEND_EXLD 0x0080 /* pending exclusion */
173 #define MSG_EX_MANUNDEL 0x0100 /* has been manually undeleted */
174 #define MSG_EX_STATECHG 0x0200 /* state change since filtering */
176 /* msgno_include flags */
178 #define MI_REFILTERING 0x01
179 #define MI_STATECHGONLY 0x02
180 #define MI_CLOSING 0x04
183 /* exported protoypes */
184 void msgno_init(MSGNO_S
**, long, SortOrder
, int);
185 void msgno_reset_isort(MSGNO_S
*);
186 void msgno_give(MSGNO_S
**);
187 void msgno_inc(MAILSTREAM
*, MSGNO_S
*, int);
188 void msgno_dec(MAILSTREAM
*, MSGNO_S
*, int);
189 void msgno_exclude_deleted(MAILSTREAM
*, MSGNO_S
*, char *);
190 void msgno_exclude(MAILSTREAM
*, MSGNO_S
*, long, int);
191 int msgno_include(MAILSTREAM
*, MSGNO_S
*, int);
192 void msgno_add_raw(MSGNO_S
*, long);
193 void msgno_flush_raw(MSGNO_S
*, long);
194 void msgno_flush_selected(MSGNO_S
*, long);
195 void msgno_set_sort(MSGNO_S
*, SortOrder
);
196 int msgno_in_select(MSGNO_S
*, long);
197 int msgno_exceptions(MAILSTREAM
*, long, char *, int *, int);
198 int msgno_any_deletedparts(MAILSTREAM
*, MSGNO_S
*);
199 int msgno_part_deleted(MAILSTREAM
*, long, char *);
200 long get_msg_score(MAILSTREAM
*, long);
201 void clear_msg_score(MAILSTREAM
*, long);
202 void clear_folder_scores(MAILSTREAM
*);
203 int calculate_some_scores(MAILSTREAM
*, SEARCHSET
*, int);
204 void free_pine_elt(void **);
207 #endif /* PITH_MSGNO_INCLUDED */