2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <sys/types.h>
33 typedef struct _MsgInfo MsgInfo
;
34 typedef struct _MsgFlags MsgFlags
;
35 typedef struct _MsgFileInfo MsgFileInfo
;
36 typedef struct _MsgInfoUpdate MsgInfoUpdate
;
37 typedef struct _MailFilteringData MailFilteringData
;
39 typedef struct _MsgInfoExtraData MsgInfoExtraData
;
41 typedef GSList MsgInfoList
;
42 typedef GSList MsgNumberList
;
44 #define MSG_NEW (1U << 0)
45 #define MSG_UNREAD (1U << 1)
46 #define MSG_MARKED (1U << 2)
47 #define MSG_DELETED (1U << 3)
48 #define MSG_REPLIED (1U << 4)
49 #define MSG_FORWARDED (1U << 5)
50 #define MSG_POSTFILTERED (1U << 14)
52 #define MSG_CLABEL_SBIT (6) /* start bit of color label */
53 /* color labels use 4 bits: 6, 7, 8, 9; bit weight is 7<8<9<6,
54 IOW the color label value itself must be computed from MsgPermFlags
56 value = bit-7-value*2^0
61 /* color label permflags masks */
62 #define MAKE_MSG_CLABEL(x, h, m, l) (\
63 ((x) << (MSG_CLABEL_SBIT + 0)) | \
64 ((h) << (MSG_CLABEL_SBIT + 3)) | \
65 ((m) << (MSG_CLABEL_SBIT + 2)) | \
66 ((l) << (MSG_CLABEL_SBIT + 1)))
67 #define MSG_CLABEL_NONE MAKE_MSG_CLABEL(0U, 0U, 0U, 0U)
68 #define MSG_CLABEL_1 MAKE_MSG_CLABEL(0U, 0U, 0U, 1U)
69 #define MSG_CLABEL_2 MAKE_MSG_CLABEL(0U, 0U, 1U, 0U)
70 #define MSG_CLABEL_3 MAKE_MSG_CLABEL(0U, 0U, 1U, 1U)
71 #define MSG_CLABEL_4 MAKE_MSG_CLABEL(0U, 1U, 0U, 0U)
72 #define MSG_CLABEL_5 MAKE_MSG_CLABEL(0U, 1U, 0U, 1U)
73 #define MSG_CLABEL_6 MAKE_MSG_CLABEL(0U, 1U, 1U, 0U)
74 #define MSG_CLABEL_7 MAKE_MSG_CLABEL(0U, 1U, 1U, 1U)
75 #define MSG_CLABEL_8 MAKE_MSG_CLABEL(1U, 0U, 0U, 0U)
76 #define MSG_CLABEL_9 MAKE_MSG_CLABEL(1U, 0U, 0U, 1U)
77 #define MSG_CLABEL_10 MAKE_MSG_CLABEL(1U, 0U, 1U, 0U)
78 #define MSG_CLABEL_11 MAKE_MSG_CLABEL(1U, 0U, 1U, 1U)
79 #define MSG_CLABEL_12 MAKE_MSG_CLABEL(1U, 1U, 0U, 0U)
80 #define MSG_CLABEL_13 MAKE_MSG_CLABEL(1U, 1U, 0U, 1U)
81 #define MSG_CLABEL_14 MAKE_MSG_CLABEL(1U, 1U, 1U, 0U)
82 #define MSG_CLABEL_15 MAKE_MSG_CLABEL(1U, 1U, 1U, 1U)
83 #define MSG_CLABEL_FLAG_MASK (MSG_CLABEL_15)
85 #define MSG_IGNORE_THREAD (1U << 10) /* ignore threads */
86 #define MSG_LOCKED (1U << 11) /* msg is locked */
87 #define MSG_RETRCPT_SENT (1U << 12) /* new one */
88 #define MSG_SPAM (1U << 13) /* new one */
91 #define MSG_RESERVED_CLAWS (1U << 30) /* for claws-mail */
92 #define MSG_RESERVED (1U << 31)
94 typedef guint32 MsgPermFlags
;
96 #define MSG_MOVE (1U << 0)
97 #define MSG_COPY (1U << 1)
98 #define MSG_MOVE_DONE (1U << 15)
99 #define MSG_QUEUED (1U << 16)
100 #define MSG_DRAFT (1U << 17)
101 #define MSG_ENCRYPTED (1U << 18)
102 #define MSG_IMAP (1U << 19)
103 #define MSG_NEWS (1U << 20)
104 #define MSG_SIGNED (1U << 21)
105 #define MSG_MULTIPART (1U << 29)
106 #define MSG_HAS_ATTACHMENT (1U << 30)
107 #define MSG_SCANNED (1U << 31)
109 typedef guint32 MsgTmpFlags
;
111 #define MSG_CACHED_FLAG_MASK (MSG_MULTIPART | MSG_ENCRYPTED | MSG_SIGNED | MSG_HAS_ATTACHMENT | MSG_SCANNED)
113 #define MSG_SET_FLAGS(msg, flags) { (msg) |= (flags); }
114 #define MSG_UNSET_FLAGS(msg, flags) { (msg) &= ~(flags); }
115 #define MSG_SET_PERM_FLAGS(msg, flags) \
116 MSG_SET_FLAGS((msg).perm_flags, flags)
117 #define MSG_SET_TMP_FLAGS(msg, flags) \
118 MSG_SET_FLAGS((msg).tmp_flags, flags)
119 #define MSG_UNSET_PERM_FLAGS(msg, flags) \
120 MSG_UNSET_FLAGS((msg).perm_flags, flags)
121 #define MSG_UNSET_TMP_FLAGS(msg, flags) \
122 MSG_UNSET_FLAGS((msg).tmp_flags, flags)
124 #define MSG_IS_NEW(msg) (((msg).perm_flags & MSG_NEW) != 0)
125 #define MSG_IS_UNREAD(msg) (((msg).perm_flags & MSG_UNREAD) != 0)
126 #define MSG_IS_MARKED(msg) (((msg).perm_flags & MSG_MARKED) != 0)
127 #define MSG_IS_DELETED(msg) (((msg).perm_flags & MSG_DELETED) != 0)
128 #define MSG_IS_REPLIED(msg) (((msg).perm_flags & MSG_REPLIED) != 0)
129 #define MSG_IS_LOCKED(msg) (((msg).perm_flags & MSG_LOCKED) != 0)
130 #define MSG_IS_FORWARDED(msg) (((msg).perm_flags & MSG_FORWARDED) != 0)
131 #define MSG_IS_POSTFILTERED(msg) (((msg).perm_flags & MSG_POSTFILTERED) != 0)
133 /* color label decoding/encoding (permflag storage bits <-> color list index value)*/
134 #define MSG_COLORLABEL_TO_FLAGS(val) (((((guint)(val)) & 7) << (MSG_CLABEL_SBIT+1)) \
135 | (((guint)(val) & 8) << (MSG_CLABEL_SBIT-3)))
136 #define MSG_COLORLABEL_FROM_FLAGS(val) ((((guint)(val) >> (MSG_CLABEL_SBIT+1)) & 7 ) \
137 | (((guint)(val) >> (MSG_CLABEL_SBIT-3)) & 8))
138 #define MSG_GET_COLORLABEL(msg) (((msg).perm_flags & MSG_CLABEL_FLAG_MASK))
139 #define MSG_GET_COLORLABEL_VALUE(msg) (MSG_COLORLABEL_FROM_FLAGS(MSG_GET_COLORLABEL(msg)))
140 #define MSG_SET_COLORLABEL_VALUE(msg, val) MSG_SET_PERM_FLAGS(msg, MSG_COLORLABEL_TO_FLAGS(val))
142 #define MSG_IS_MOVE(msg) (((msg).tmp_flags & MSG_MOVE) != 0)
143 #define MSG_IS_COPY(msg) (((msg).tmp_flags & MSG_COPY) != 0)
144 #define MSG_IS_MOVE_DONE(msg) (((msg).tmp_flags & MSG_MOVE_DONE) != 0)
146 #define MSG_IS_QUEUED(msg) (((msg).tmp_flags & MSG_QUEUED) != 0)
147 #define MSG_IS_DRAFT(msg) (((msg).tmp_flags & MSG_DRAFT) != 0)
148 #define MSG_IS_ENCRYPTED(msg) (((msg).tmp_flags & MSG_ENCRYPTED) != 0)
149 #define MSG_IS_SIGNED(msg) (((msg).tmp_flags & MSG_SIGNED) != 0)
150 #define MSG_IS_IMAP(msg) (((msg).tmp_flags & MSG_IMAP) != 0)
151 #define MSG_IS_NEWS(msg) (((msg).tmp_flags & MSG_NEWS) != 0)
152 #define MSG_IS_MULTIPART(msg) (((msg).tmp_flags & MSG_MULTIPART) != 0)
153 #define MSG_IS_WITH_ATTACHMENT(msg) (((msg).tmp_flags & MSG_HAS_ATTACHMENT) != 0)
154 #define MSG_IS_SCANNED(msg) (((msg).tmp_flags & MSG_SCANNED) != 0)
156 /* Claws related flags */
157 #define MSG_IS_REALLY_DELETED(msg) (((msg).perm_flags & MSG_REALLY_DELETED) != 0)
158 #define MSG_IS_IGNORE_THREAD(msg) (((msg).perm_flags & MSG_IGNORE_THREAD) != 0)
159 #define MSG_IS_RETRCPT_PENDING(msg) (((msg).perm_flags & MSG_RETRCPT_PENDING) != 0)
160 #define MSG_IS_RETRCPT_SENT(msg) (((msg).perm_flags & MSG_RETRCPT_SENT) != 0)
161 #define MSG_IS_SPAM(msg) (((msg).perm_flags & MSG_SPAM) != 0)
163 #define MSGINFO_UPDATE_HOOKLIST "msginfo_update"
164 #define MAIL_FILTERING_HOOKLIST "mail_filtering_hooklist"
165 #define MAIL_LISTFILTERING_HOOKLIST "mail_listfiltering_hooklist"
166 #define MAIL_POSTFILTERING_HOOKLIST "mail_postfiltering_hooklist"
169 MSGINFO_UPDATE_FLAGS
= 1 << 0,
170 MSGINFO_UPDATE_DELETED
= 1 << 1
171 } MsgInfoUpdateFlags
;
173 #include "procmime.h"
174 #include "prefs_filtering.h"
179 MsgPermFlags perm_flags
;
180 MsgTmpFlags tmp_flags
;
183 /* *********************************************************** *
184 * WARNING: When adding or removing members to this structure, *
185 * be sure to update procmsg.c::procmsg_msginfo_memusage() to *
186 * avoid underestimating cache memory usage - especially since *
187 * this would cause an overflow and metadata loss when writing *
188 * the cache to disk. *
189 * *********************************************************** */
214 FolderItem
*to_folder
;
216 FolderItem
*to_filter_folder
;
225 /* used only for encrypted messages */
226 gchar
*plaintext_file
;
230 /* used only for partially received messages */
232 gint planned_download
;
234 MsgInfoExtraData
*extradata
;
237 struct _MsgInfoExtraData
242 gchar
*dispositionnotificationto
;
243 gchar
*returnreceiptto
;
245 /* used only for partially received messages */
247 gchar
*account_server
;
248 gchar
*account_login
;
250 /* Mailing list support */
252 gchar
*list_subscribe
;
253 gchar
*list_unsubscribe
;
266 struct _MsgInfoUpdate
{
268 MsgInfoUpdateFlags flags
;
271 struct _MailFilteringData
277 PrefsAccount
*account
;
280 GSList
*procmsg_read_cache (FolderItem
*item
,
282 void procmsg_msg_list_free (GSList
*mlist
);
283 void procmsg_get_mark_sum (const gchar
*folder
,
291 GNode
*procmsg_get_thread_tree (GSList
*mlist
);
293 gint
procmsg_move_messages (GSList
*mlist
);
294 void procmsg_copy_messages (GSList
*mlist
);
296 /* return path is locale charset */
297 gchar
*procmsg_get_message_file_path (MsgInfo
*msginfo
);
298 gchar
*procmsg_get_message_file (MsgInfo
*msginfo
);
299 gchar
*procmsg_get_message_file_full (MsgInfo
*msginfo
,
300 gboolean get_headers
,
302 GSList
*procmsg_get_message_file_list (MsgInfoList
*mlist
);
303 void procmsg_message_file_list_free (MsgInfoList
*file_list
);
304 FILE *procmsg_open_message (MsgInfo
*msginfo
);
305 gboolean
procmsg_msg_exist (MsgInfo
*msginfo
);
307 void procmsg_get_filter_keyword (MsgInfo
*msginfo
,
310 PrefsFilterType type
);
312 void procmsg_empty_all_trash (void);
314 gint
procmsg_send_queue (FolderItem
*queue
,
317 gboolean
procmsg_queue_is_empty (FolderItem
*queue
);
318 void procmsg_print_message (MsgInfo
*msginfo
,
319 const gchar
*cmdline
);
321 MsgInfo
*procmsg_msginfo_new ();
322 MsgInfo
*procmsg_msginfo_new_ref (MsgInfo
*msginfo
);
323 MsgInfo
*procmsg_msginfo_copy (MsgInfo
*msginfo
);
324 MsgInfo
*procmsg_msginfo_get_full_info (MsgInfo
*msginfo
);
325 void procmsg_msginfo_free (MsgInfo
*msginfo
);
326 guint
procmsg_msginfo_memusage (MsgInfo
*msginfo
);
328 gint
procmsg_send_message_queue (const gchar
*file
,
332 gboolean
*queued_removed
);
334 void procmsg_msginfo_set_flags (MsgInfo
*msginfo
,
335 MsgPermFlags perm_flags
,
336 MsgTmpFlags tmp_flags
);
337 void procmsg_msginfo_unset_flags (MsgInfo
*msginfo
,
338 MsgPermFlags perm_flags
,
339 MsgTmpFlags tmp_flags
);
340 void procmsg_msginfo_change_flags (MsgInfo
*msginfo
,
341 MsgPermFlags add_perm_flags
,
342 MsgTmpFlags add_tmp_flags
,
343 MsgPermFlags rem_perm_flags
,
344 MsgTmpFlags rem_tmp_flags
);
345 gint
procmsg_remove_special_headers (const gchar
*in
,
348 gboolean
procmsg_msg_has_flagged_parent (MsgInfo
*info
,
349 MsgPermFlags perm_flags
);
350 gboolean
procmsg_msg_has_marked_parent (MsgInfo
*info
);
351 void procmsg_msginfo_set_to_folder (MsgInfo
*msginfo
,
352 FolderItem
*to_folder
);
353 void procmsg_msglist_filter (GSList
*list
,
359 MsgInfo
*procmsg_msginfo_new_from_mimeinfo
360 (MsgInfo
*src_msginfo
,
363 void procmsg_register_spam_learner (int (*learn_func
)(MsgInfo
*info
, GSList
*list
, gboolean spam
));
364 void procmsg_unregister_spam_learner (int (*learn_func
)(MsgInfo
*info
, GSList
*list
, gboolean spam
));
365 gboolean
procmsg_spam_can_learn (void);
366 void procmsg_spam_set_folder (const char *item_identifier
, FolderItem
*(*spam_get_folder_func
)(MsgInfo
*info
));
367 FolderItem
*procmsg_spam_get_folder (MsgInfo
*msginfo
);
368 int procmsg_spam_learner_learn (MsgInfo
*msginfo
, GSList
*msglist
, gboolean spam
);
369 gboolean
procmsg_have_queued_mails_fast (void);
370 gboolean
procmsg_have_trashed_mails_fast (void);
371 gboolean
procmsg_is_sending(void);
373 #endif /* __PROCMSG_H__ */