2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 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 3 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, see <http://www.gnu.org/licenses/>.
24 #include "claws-features.h"
30 #include <sys/types.h>
33 #include "proctypes.h"
35 #define MSG_NEW (1U << 0)
36 #define MSG_UNREAD (1U << 1)
37 #define MSG_MARKED (1U << 2)
38 #define MSG_DELETED (1U << 3)
39 #define MSG_REPLIED (1U << 4)
40 #define MSG_FORWARDED (1U << 5)
42 #define MSG_CLABEL_SBIT (6) /* start bit of color label */
43 /* color labels use 4 bits: 6, 7, 8, 9; bit weight is 7<8<9<6,
44 IOW the color label value itself must be computed from MsgPermFlags
46 value = bit-7-value*2^0
51 /* color label permflags masks */
52 #define MAKE_MSG_CLABEL(x, h, m, l) (\
53 ((x) << (MSG_CLABEL_SBIT + 0)) | \
54 ((h) << (MSG_CLABEL_SBIT + 3)) | \
55 ((m) << (MSG_CLABEL_SBIT + 2)) | \
56 ((l) << (MSG_CLABEL_SBIT + 1)))
57 #define MSG_CLABEL_NONE MAKE_MSG_CLABEL(0U, 0U, 0U, 0U)
58 #define MSG_CLABEL_1 MAKE_MSG_CLABEL(0U, 0U, 0U, 1U)
59 #define MSG_CLABEL_2 MAKE_MSG_CLABEL(0U, 0U, 1U, 0U)
60 #define MSG_CLABEL_3 MAKE_MSG_CLABEL(0U, 0U, 1U, 1U)
61 #define MSG_CLABEL_4 MAKE_MSG_CLABEL(0U, 1U, 0U, 0U)
62 #define MSG_CLABEL_5 MAKE_MSG_CLABEL(0U, 1U, 0U, 1U)
63 #define MSG_CLABEL_6 MAKE_MSG_CLABEL(0U, 1U, 1U, 0U)
64 #define MSG_CLABEL_7 MAKE_MSG_CLABEL(0U, 1U, 1U, 1U)
65 #define MSG_CLABEL_8 MAKE_MSG_CLABEL(1U, 0U, 0U, 0U)
66 #define MSG_CLABEL_9 MAKE_MSG_CLABEL(1U, 0U, 0U, 1U)
67 #define MSG_CLABEL_10 MAKE_MSG_CLABEL(1U, 0U, 1U, 0U)
68 #define MSG_CLABEL_11 MAKE_MSG_CLABEL(1U, 0U, 1U, 1U)
69 #define MSG_CLABEL_12 MAKE_MSG_CLABEL(1U, 1U, 0U, 0U)
70 #define MSG_CLABEL_13 MAKE_MSG_CLABEL(1U, 1U, 0U, 1U)
71 #define MSG_CLABEL_14 MAKE_MSG_CLABEL(1U, 1U, 1U, 0U)
72 #define MSG_CLABEL_15 MAKE_MSG_CLABEL(1U, 1U, 1U, 1U)
73 #define MSG_CLABEL_FLAG_MASK (MSG_CLABEL_15)
75 #define MSG_IGNORE_THREAD (1U << 10) /* ignore threads */
76 #define MSG_LOCKED (1U << 11) /* msg is locked */
77 #define MSG_RETRCPT_SENT (1U << 12) /* new one */
78 #define MSG_SPAM (1U << 13) /* new one */
79 #define MSG_POSTFILTERED (1U << 14)
80 #define MSG_WATCH_THREAD (1U << 15) /* watch threads */
81 #define MSG_FULLY_CACHED (1U << 16) /* IMAP: fully cached */
82 #define MSG_RETRCPT_GOT (1U << 17) /* got return receipt */
85 #define MSG_RESERVED_CLAWS (1U << 30) /* for claws-mail */
86 #define MSG_RESERVED (1U << 31)
88 #define MSG_MOVE (1U << 0)
89 #define MSG_COPY (1U << 1)
90 #define MSG_MOVE_DONE (1U << 15)
91 #define MSG_QUEUED (1U << 16)
92 #define MSG_DRAFT (1U << 17)
93 #define MSG_ENCRYPTED (1U << 18)
94 #define MSG_IMAP (1U << 19)
95 #define MSG_NEWS (1U << 20)
96 #define MSG_SIGNED (1U << 21)
97 #define MSG_MULTIPART (1U << 29)
98 #define MSG_HAS_ATTACHMENT (1U << 30)
99 #define MSG_SCANNED (1U << 31)
101 #define MSG_CACHED_FLAG_MASK (MSG_MULTIPART | MSG_ENCRYPTED | MSG_SIGNED | MSG_HAS_ATTACHMENT | MSG_SCANNED)
103 #define MSG_SET_FLAGS(msg, flags) { (msg) |= (flags); }
104 #define MSG_UNSET_FLAGS(msg, flags) { (msg) &= ~(flags); }
105 #define MSG_SET_PERM_FLAGS(msg, flags) \
106 MSG_SET_FLAGS((msg).perm_flags, flags)
107 #define MSG_SET_TMP_FLAGS(msg, flags) \
108 MSG_SET_FLAGS((msg).tmp_flags, flags)
109 #define MSG_UNSET_PERM_FLAGS(msg, flags) \
110 MSG_UNSET_FLAGS((msg).perm_flags, flags)
111 #define MSG_UNSET_TMP_FLAGS(msg, flags) \
112 MSG_UNSET_FLAGS((msg).tmp_flags, flags)
114 #define MSG_IS_NEW(msg) (((msg).perm_flags & MSG_NEW) != 0)
115 #define MSG_IS_UNREAD(msg) (((msg).perm_flags & MSG_UNREAD) != 0)
116 #define MSG_IS_MARKED(msg) (((msg).perm_flags & MSG_MARKED) != 0)
117 #define MSG_IS_DELETED(msg) (((msg).perm_flags & MSG_DELETED) != 0)
118 #define MSG_IS_REPLIED(msg) (((msg).perm_flags & MSG_REPLIED) != 0)
119 #define MSG_IS_LOCKED(msg) (((msg).perm_flags & MSG_LOCKED) != 0)
120 #define MSG_IS_FORWARDED(msg) (((msg).perm_flags & MSG_FORWARDED) != 0)
121 #define MSG_IS_POSTFILTERED(msg) (((msg).perm_flags & MSG_POSTFILTERED) != 0)
123 /* color label decoding/encoding (permflag storage bits <-> color list index value)*/
124 #define MSG_COLORLABEL_TO_FLAGS(val) (((((guint)(val)) & 7) << (MSG_CLABEL_SBIT+1)) \
125 | (((guint)(val) & 8) << (MSG_CLABEL_SBIT-3)))
126 #define MSG_COLORLABEL_FROM_FLAGS(val) ((((guint)(val) >> (MSG_CLABEL_SBIT+1)) & 7 ) \
127 | (((guint)(val) >> (MSG_CLABEL_SBIT-3)) & 8))
128 #define MSG_GET_COLORLABEL(msg) (((msg).perm_flags & MSG_CLABEL_FLAG_MASK))
129 #define MSG_GET_COLORLABEL_VALUE(msg) (MSG_COLORLABEL_FROM_FLAGS(MSG_GET_COLORLABEL(msg)))
130 #define MSG_SET_COLORLABEL_VALUE(msg, val) MSG_SET_PERM_FLAGS(msg, MSG_COLORLABEL_TO_FLAGS(val))
132 #define MSG_IS_MOVE(msg) (((msg).tmp_flags & MSG_MOVE) != 0)
133 #define MSG_IS_COPY(msg) (((msg).tmp_flags & MSG_COPY) != 0)
134 #define MSG_IS_MOVE_DONE(msg) (((msg).tmp_flags & MSG_MOVE_DONE) != 0)
136 #define MSG_IS_QUEUED(msg) (((msg).tmp_flags & MSG_QUEUED) != 0)
137 #define MSG_IS_DRAFT(msg) (((msg).tmp_flags & MSG_DRAFT) != 0)
138 #define MSG_IS_ENCRYPTED(msg) (((msg).tmp_flags & MSG_ENCRYPTED) != 0)
139 #define MSG_IS_SIGNED(msg) (((msg).tmp_flags & MSG_SIGNED) != 0)
140 #define MSG_IS_IMAP(msg) (((msg).tmp_flags & MSG_IMAP) != 0)
141 #define MSG_IS_NEWS(msg) (((msg).tmp_flags & MSG_NEWS) != 0)
142 #define MSG_IS_MULTIPART(msg) (((msg).tmp_flags & MSG_MULTIPART) != 0)
143 #define MSG_IS_WITH_ATTACHMENT(msg) (((msg).tmp_flags & MSG_HAS_ATTACHMENT) != 0)
144 #define MSG_IS_SCANNED(msg) (((msg).tmp_flags & MSG_SCANNED) != 0)
146 /* Claws related flags */
147 #define MSG_IS_IGNORE_THREAD(msg) (((msg).perm_flags & MSG_IGNORE_THREAD) != 0)
148 #define MSG_IS_RETRCPT_PENDING(msg) (((msg).perm_flags & MSG_RETRCPT_PENDING) != 0)
149 #define MSG_IS_RETRCPT_SENT(msg) (((msg).perm_flags & MSG_RETRCPT_SENT) != 0)
150 #define MSG_IS_RETRCPT_GOT(msg) (((msg).perm_flags & MSG_RETRCPT_GOT) != 0)
151 #define MSG_IS_SPAM(msg) (((msg).perm_flags & MSG_SPAM) != 0)
152 #define MSG_IS_WATCH_THREAD(msg) (((msg).perm_flags & MSG_WATCH_THREAD) != 0)
153 #define MSG_IS_FULLY_CACHED(msg) (((msg).perm_flags & MSG_FULLY_CACHED) != 0)
155 #define MSGINFO_UPDATE_HOOKLIST "msginfo_update"
156 #define MAIL_FILTERING_HOOKLIST "mail_filtering_hooklist"
157 #define MAIL_LISTFILTERING_HOOKLIST "mail_listfiltering_hooklist"
158 #define MAIL_POSTFILTERING_HOOKLIST "mail_postfiltering_hooklist"
161 MSGINFO_UPDATE_FLAGS
= 1 << 0,
162 MSGINFO_UPDATE_DELETED
= 1 << 1
163 } MsgInfoUpdateFlags
;
165 #include "prefs_account.h"
166 #include "prefs_filtering.h"
171 MsgPermFlags perm_flags
;
172 MsgTmpFlags tmp_flags
;
182 /* *********************************************************** *
183 * WARNING: When adding or removing members to this structure, *
184 * be sure to update procmsg.c::procmsg_msginfo_memusage() to *
185 * avoid underestimating cache memory usage - especially since *
186 * this would cause an overflow and metadata loss when writing *
187 * the cache to disk. *
188 * *********************************************************** */
214 FolderItem
*to_folder
;
216 FolderItem
*to_filter_folder
;
224 /* used only for encrypted messages */
225 gchar
*plaintext_file
;
229 /* used only for partially received messages */
231 gint planned_download
;
233 /* list of tags ids */
236 MsgInfoExtraData
*extradata
;
239 struct _MsgInfoExtraData
243 gchar
*dispositionnotificationto
;
244 gchar
*returnreceiptto
;
248 /* used only for partially received messages */
250 gchar
*account_server
;
251 gchar
*account_login
;
253 /* Mailing list support */
255 gchar
*list_subscribe
;
256 gchar
*list_unsubscribe
;
262 struct _MsgInfoAvatar
275 struct _MsgInfoUpdate
{
277 MsgInfoUpdateFlags flags
;
280 struct _MailFilteringData
286 PrefsAccount
*account
;
289 struct _AvatarCaptureData
293 const gchar
*content
;
296 GSList
*procmsg_read_cache (FolderItem
*item
,
298 void procmsg_msg_list_free (MsgInfoList
*mlist
);
299 MsgNumberList
*procmsg_get_number_list_for_msgs(MsgInfoList
*msglist
);
300 void procmsg_get_mark_sum (const gchar
*folder
,
308 GNode
*procmsg_get_thread_tree (GSList
*mlist
);
310 gint
procmsg_move_messages (GSList
*mlist
);
311 void procmsg_copy_messages (GSList
*mlist
);
313 /* return path is locale charset */
314 gchar
*procmsg_get_message_file_path (MsgInfo
*msginfo
);
315 gchar
*procmsg_get_message_file (MsgInfo
*msginfo
);
316 gchar
*procmsg_get_message_file_full (MsgInfo
*msginfo
,
317 gboolean get_headers
,
319 GSList
*procmsg_get_message_file_list (MsgInfoList
*mlist
);
320 void procmsg_message_file_list_free (MsgInfoList
*file_list
);
321 FILE *procmsg_open_message (MsgInfo
*msginfo
);
322 gboolean
procmsg_msg_exist (MsgInfo
*msginfo
);
324 void procmsg_get_filter_keyword (MsgInfo
*msginfo
,
327 PrefsFilterType type
);
329 void procmsg_empty_all_trash (void);
331 gint
procmsg_send_queue (FolderItem
*queue
,
334 gboolean
procmsg_queue_lock (gchar
**errstr
);
335 void procmsg_queue_unlock (void);
336 gboolean
procmsg_queue_is_empty (FolderItem
*queue
);
338 MsgInfo
*procmsg_msginfo_new ();
339 MsgInfo
*procmsg_msginfo_new_ref (MsgInfo
*msginfo
);
340 MsgInfo
*procmsg_msginfo_copy (MsgInfo
*msginfo
);
341 MsgInfo
*procmsg_msginfo_get_full_info (MsgInfo
*msginfo
);
342 MsgInfo
*procmsg_msginfo_get_full_info_from_file
345 void procmsg_msginfo_free (MsgInfo
**msginfo
);
346 guint
procmsg_msginfo_memusage (MsgInfo
*msginfo
);
348 gint
procmsg_send_message_queue_with_lock(const gchar
*file
,
352 gboolean
*queued_removed
);
354 gint
procmsg_send_message_queue (const gchar
*file
,
358 gboolean
*queued_removed
);
360 void procmsg_msginfo_set_flags (MsgInfo
*msginfo
,
361 MsgPermFlags perm_flags
,
362 MsgTmpFlags tmp_flags
);
363 void procmsg_msginfo_unset_flags (MsgInfo
*msginfo
,
364 MsgPermFlags perm_flags
,
365 MsgTmpFlags tmp_flags
);
366 void procmsg_msginfo_change_flags (MsgInfo
*msginfo
,
367 MsgPermFlags add_perm_flags
,
368 MsgTmpFlags add_tmp_flags
,
369 MsgPermFlags rem_perm_flags
,
370 MsgTmpFlags rem_tmp_flags
);
371 gint
procmsg_remove_special_headers (const gchar
*in
,
374 gint
procmsg_save_to_outbox(FolderItem
*outbox
, const gchar
*file
,
376 gboolean
procmsg_msg_has_flagged_parent (MsgInfo
*info
,
377 MsgPermFlags perm_flags
);
378 gboolean
procmsg_msg_has_marked_parent (MsgInfo
*info
);
379 void procmsg_msginfo_set_to_folder (MsgInfo
*msginfo
,
380 FolderItem
*to_folder
);
381 void procmsg_msglist_filter (GSList
*list
,
387 MsgInfo
*procmsg_msginfo_new_from_mimeinfo
388 (MsgInfo
*src_msginfo
,
391 void procmsg_register_spam_learner (int (*learn_func
)(MsgInfo
*info
, GSList
*list
, gboolean spam
));
392 void procmsg_unregister_spam_learner (int (*learn_func
)(MsgInfo
*info
, GSList
*list
, gboolean spam
));
393 gboolean
procmsg_spam_can_learn (void);
394 void procmsg_spam_set_folder (const char *item_identifier
, FolderItem
*(*spam_get_folder_func
)(MsgInfo
*info
));
395 FolderItem
*procmsg_spam_get_folder (MsgInfo
*msginfo
);
396 int procmsg_spam_learner_learn (MsgInfo
*msginfo
, GSList
*msglist
, gboolean spam
);
397 gboolean
procmsg_have_queued_mails_fast (void);
398 gboolean
procmsg_have_trashed_mails_fast (void);
399 gboolean
procmsg_is_sending(void);
400 gchar
*procmsg_msginfo_get_tags_str(MsgInfo
*msginfo
);
401 void procmsg_msginfo_update_tags(MsgInfo
*msginfo
, gboolean set
, gint id
);
402 void procmsg_msginfo_clear_tags(MsgInfo
*msginfo
);
403 void procmsg_msginfo_commit_tags(GSList
*msglist
);
404 MsgInfo
*procmsg_get_msginfo_from_identifier(const gchar
*id
);
405 gchar
*procmsg_msginfo_get_identifier(MsgInfo
*msginfo
);
407 gchar
*procmsg_msginfo_get_avatar(MsgInfo
*msginfo
, gint type
);
408 void procmsg_msginfo_add_avatar(MsgInfo
*msginfo
, gint type
, const gchar
*data
);
409 #endif /* __PROCMSG_H__ */