Statistics
| Revision:

root / src / procmsg.h @ 358

History | View | Annotate | Download (8.2 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1 hiro
 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifndef __PROCMSG_H__
21 1 hiro
#define __PROCMSG_H__
22 1 hiro
23 1 hiro
#ifdef HAVE_CONFIG_H
24 1 hiro
#  include "config.h"
25 1 hiro
#endif
26 1 hiro
27 1 hiro
#include <glib.h>
28 1 hiro
#include <stdio.h>
29 1 hiro
#include <time.h>
30 1 hiro
#include <sys/types.h>
31 1 hiro
#include <string.h>
32 1 hiro
33 1 hiro
typedef struct _MsgInfo                MsgInfo;
34 1 hiro
typedef struct _MsgFlags        MsgFlags;
35 1 hiro
typedef struct _MsgFileInfo        MsgFileInfo;
36 1 hiro
37 1 hiro
#include "folder.h"
38 1 hiro
#include "procmime.h"
39 1 hiro
#include "prefs_filter.h"
40 1 hiro
41 1 hiro
typedef enum
42 1 hiro
{
43 1 hiro
        DATA_READ,
44 1 hiro
        DATA_WRITE,
45 1 hiro
        DATA_APPEND
46 1 hiro
} DataOpenMode;
47 1 hiro
48 1 hiro
#define MSG_NEW                        (1U << 0)
49 1 hiro
#define MSG_UNREAD                (1U << 1)
50 1 hiro
#define MSG_MARKED                (1U << 2)
51 1 hiro
#define MSG_DELETED                (1U << 3)
52 1 hiro
#define MSG_REPLIED                (1U << 4)
53 1 hiro
#define MSG_FORWARDED                (1U << 5)
54 1 hiro
55 1 hiro
#define MSG_CLABEL_SBIT        (7)                /* start bit of color label */
56 1 hiro
#define MAKE_MSG_CLABEL(h, m, l)        (((h) << (MSG_CLABEL_SBIT + 2)) | \
57 1 hiro
                                         ((m) << (MSG_CLABEL_SBIT + 1)) | \
58 1 hiro
                                         ((l) << (MSG_CLABEL_SBIT + 0)))
59 1 hiro
60 1 hiro
#define MSG_CLABEL_NONE                MAKE_MSG_CLABEL(0U, 0U, 0U)
61 1 hiro
#define MSG_CLABEL_1                MAKE_MSG_CLABEL(0U, 0U, 1U)
62 1 hiro
#define MSG_CLABEL_2                MAKE_MSG_CLABEL(0U, 1U, 0U)
63 1 hiro
#define MSG_CLABEL_3                MAKE_MSG_CLABEL(0U, 1U, 1U)
64 1 hiro
#define MSG_CLABEL_4                MAKE_MSG_CLABEL(1U, 0U, 0U)
65 1 hiro
#define MSG_CLABEL_5                MAKE_MSG_CLABEL(1U, 0U, 1U)
66 1 hiro
#define MSG_CLABEL_6                MAKE_MSG_CLABEL(1U, 1U, 0U)
67 1 hiro
#define MSG_CLABEL_7                MAKE_MSG_CLABEL(1U, 1U, 1U)
68 1 hiro
69 1 hiro
#define MSG_CLABEL_ORANGE        MSG_CLABEL_1
70 1 hiro
#define MSG_CLABEL_RED                MSG_CLABEL_2
71 1 hiro
#define MSG_CLABEL_PINK                MSG_CLABEL_3
72 1 hiro
#define MSG_CLABEL_SKYBLUE        MSG_CLABEL_4
73 1 hiro
#define MSG_CLABEL_BLUE                MSG_CLABEL_5
74 1 hiro
#define MSG_CLABEL_GREEN        MSG_CLABEL_6
75 1 hiro
#define MSG_CLABEL_BROWN        MSG_CLABEL_7
76 1 hiro
77 1 hiro
/* RESERVED */
78 1 hiro
#define        MSG_RESERVED                (1U << 31)
79 1 hiro
80 1 hiro
#define MSG_CLABEL_FLAG_MASK        (MSG_CLABEL_7)
81 1 hiro
82 1 hiro
typedef guint32 MsgPermFlags;
83 1 hiro
84 1 hiro
#define MSG_MOVE                (1U << 0)
85 1 hiro
#define MSG_COPY                (1U << 1)
86 1 hiro
#define MSG_QUEUED                (1U << 16)
87 1 hiro
#define MSG_DRAFT                (1U << 17)
88 1 hiro
#define MSG_ENCRYPTED                (1U << 18)
89 1 hiro
#define MSG_IMAP                (1U << 19)
90 1 hiro
#define MSG_NEWS                (1U << 20)
91 1 hiro
#define MSG_SIGNED                (1U << 21)
92 1 hiro
#define MSG_MIME                (1U << 29)
93 1 hiro
#define MSG_INVALID                (1U << 30)
94 1 hiro
#define MSG_RECEIVED                (1U << 31)
95 1 hiro
96 1 hiro
#define MSG_CACHED_FLAG_MASK        (MSG_MIME)
97 1 hiro
98 1 hiro
typedef guint32 MsgTmpFlags;
99 1 hiro
100 1 hiro
#define MSG_SET_FLAGS(msg, flags)        { (msg) |= (flags); }
101 1 hiro
#define MSG_UNSET_FLAGS(msg, flags)        { (msg) &= ~(flags); }
102 1 hiro
#define MSG_SET_PERM_FLAGS(msg, flags) \
103 1 hiro
        MSG_SET_FLAGS((msg).perm_flags, flags)
104 1 hiro
#define MSG_SET_TMP_FLAGS(msg, flags) \
105 1 hiro
        MSG_SET_FLAGS((msg).tmp_flags, flags)
106 1 hiro
#define MSG_UNSET_PERM_FLAGS(msg, flags) \
107 1 hiro
        MSG_UNSET_FLAGS((msg).perm_flags, flags)
108 1 hiro
#define MSG_UNSET_TMP_FLAGS(msg, flags) \
109 1 hiro
        MSG_UNSET_FLAGS((msg).tmp_flags, flags)
110 1 hiro
111 1 hiro
#define MSG_IS_NEW(msg)                        (((msg).perm_flags & MSG_NEW) != 0)
112 1 hiro
#define MSG_IS_UNREAD(msg)                (((msg).perm_flags & MSG_UNREAD) != 0)
113 1 hiro
#define MSG_IS_MARKED(msg)                (((msg).perm_flags & MSG_MARKED) != 0)
114 1 hiro
#define MSG_IS_DELETED(msg)                (((msg).perm_flags & MSG_DELETED) != 0)
115 1 hiro
#define MSG_IS_REPLIED(msg)                (((msg).perm_flags & MSG_REPLIED) != 0)
116 1 hiro
#define MSG_IS_FORWARDED(msg)                (((msg).perm_flags & MSG_FORWARDED) != 0)
117 1 hiro
118 1 hiro
#define MSG_GET_COLORLABEL(msg)                (((msg).perm_flags & MSG_CLABEL_FLAG_MASK))
119 1 hiro
#define MSG_GET_COLORLABEL_VALUE(msg)        (MSG_GET_COLORLABEL(msg) >> MSG_CLABEL_SBIT)
120 1 hiro
#define MSG_SET_COLORLABEL_VALUE(msg, val) \
121 1 hiro
        MSG_SET_PERM_FLAGS(msg, ((((guint)(val)) & 7) << MSG_CLABEL_SBIT))
122 1 hiro
123 1 hiro
#define MSG_IS_MOVE(msg)                (((msg).tmp_flags & MSG_MOVE) != 0)
124 1 hiro
#define MSG_IS_COPY(msg)                (((msg).tmp_flags & MSG_COPY) != 0)
125 1 hiro
126 1 hiro
#define MSG_IS_QUEUED(msg)                (((msg).tmp_flags & MSG_QUEUED) != 0)
127 1 hiro
#define MSG_IS_DRAFT(msg)                (((msg).tmp_flags & MSG_DRAFT) != 0)
128 1 hiro
#define MSG_IS_ENCRYPTED(msg)                (((msg).tmp_flags & MSG_ENCRYPTED) != 0)
129 1 hiro
#define MSG_IS_IMAP(msg)                (((msg).tmp_flags & MSG_IMAP) != 0)
130 1 hiro
#define MSG_IS_NEWS(msg)                (((msg).tmp_flags & MSG_NEWS) != 0)
131 292 hiro
#define MSG_IS_SIGNED(msg)                (((msg).tmp_flags & MSG_SIGNED) != 0)
132 1 hiro
#define MSG_IS_MIME(msg)                (((msg).tmp_flags & MSG_MIME) != 0)
133 1 hiro
#define MSG_IS_INVALID(msg)                (((msg).tmp_flags & MSG_INVALID) != 0)
134 1 hiro
#define MSG_IS_RECEIVED(msg)                (((msg).tmp_flags & MSG_RECEIVED) != 0)
135 1 hiro
136 1 hiro
#define WRITE_CACHE_DATA_INT(n, fp)                \
137 1 hiro
{                                                \
138 1 hiro
        guint32 idata;                                \
139 1 hiro
                                                \
140 1 hiro
        idata = (guint32)n;                        \
141 1 hiro
        fwrite(&idata, sizeof(idata), 1, fp);        \
142 1 hiro
}
143 1 hiro
144 1 hiro
#define WRITE_CACHE_DATA(data, fp)                        \
145 1 hiro
{                                                        \
146 1 hiro
        size_t len;                                        \
147 1 hiro
                                                        \
148 1 hiro
        if (data == NULL) {                                \
149 1 hiro
                len = 0;                                \
150 1 hiro
                WRITE_CACHE_DATA_INT(len, fp);                \
151 1 hiro
        } else {                                        \
152 1 hiro
                len = strlen(data);                        \
153 1 hiro
                WRITE_CACHE_DATA_INT(len, fp);                \
154 1 hiro
                if (len > 0)                                \
155 1 hiro
                        fwrite(data, len, 1, fp);        \
156 1 hiro
        }                                                \
157 1 hiro
}
158 1 hiro
159 1 hiro
struct _MsgFlags
160 1 hiro
{
161 1 hiro
        MsgPermFlags perm_flags;
162 1 hiro
        MsgTmpFlags  tmp_flags;
163 1 hiro
};
164 1 hiro
165 1 hiro
struct _MsgInfo
166 1 hiro
{
167 1 hiro
        guint  msgnum;
168 1 hiro
        off_t  size;
169 1 hiro
        time_t mtime;
170 1 hiro
        time_t date_t;
171 1 hiro
172 1 hiro
        MsgFlags flags;
173 1 hiro
174 1 hiro
        gchar *fromname;
175 1 hiro
176 1 hiro
        gchar *date;
177 1 hiro
        gchar *from;
178 1 hiro
        gchar *to;
179 1 hiro
        gchar *cc;
180 1 hiro
        gchar *newsgroups;
181 1 hiro
        gchar *subject;
182 1 hiro
        gchar *msgid;
183 1 hiro
        gchar *inreplyto;
184 1 hiro
185 190 hiro
        GSList *references;
186 190 hiro
187 1 hiro
        FolderItem *folder;
188 1 hiro
        FolderItem *to_folder;
189 1 hiro
190 1 hiro
        gchar *xface;
191 1 hiro
192 1 hiro
        /* used only for temporary messages */
193 1 hiro
        gchar *file_path;
194 1 hiro
195 1 hiro
        /* used only for encrypted messages */
196 1 hiro
        gchar *plaintext_file;
197 1 hiro
        guint decryption_failed : 1;
198 1 hiro
};
199 1 hiro
200 1 hiro
struct _MsgFileInfo
201 1 hiro
{
202 1 hiro
        gchar *file;
203 1 hiro
        MsgFlags *flags;
204 1 hiro
};
205 1 hiro
206 1 hiro
GHashTable *procmsg_msg_hash_table_create        (GSList                *mlist);
207 1 hiro
void procmsg_msg_hash_table_append                (GHashTable        *msg_table,
208 1 hiro
                                                 GSList                *mlist);
209 1 hiro
GHashTable *procmsg_to_folder_hash_table_create        (GSList                *mlist);
210 1 hiro
211 1 hiro
GSList *procmsg_read_cache                (FolderItem        *item,
212 1 hiro
                                         gboolean         scan_file);
213 1 hiro
void        procmsg_set_flags                (GSList                *mlist,
214 1 hiro
                                         FolderItem        *item);
215 1 hiro
GSList *procmsg_sort_msg_list                (GSList                *mlist,
216 1 hiro
                                         FolderSortKey         sort_key,
217 1 hiro
                                         FolderSortType         sort_type);
218 1 hiro
gint        procmsg_get_last_num_in_msg_list(GSList                *mlist);
219 1 hiro
void        procmsg_msg_list_free                (GSList                *mlist);
220 1 hiro
void        procmsg_write_cache                (MsgInfo        *msginfo,
221 1 hiro
                                         FILE                *fp);
222 1 hiro
void        procmsg_write_flags                (MsgInfo        *msginfo,
223 1 hiro
                                         FILE                *fp);
224 1 hiro
void        procmsg_flush_mark_queue        (FolderItem        *item,
225 1 hiro
                                         FILE                *fp);
226 1 hiro
void        procmsg_add_mark_queue                (FolderItem        *item,
227 1 hiro
                                         gint                 num,
228 1 hiro
                                         MsgFlags         flags);
229 1 hiro
void        procmsg_add_flags                (FolderItem        *item,
230 1 hiro
                                         gint                 num,
231 1 hiro
                                         MsgFlags         flags);
232 1 hiro
void        procmsg_get_mark_sum                (FolderItem        *item,
233 1 hiro
                                         gint                *new,
234 1 hiro
                                         gint                *unread,
235 1 hiro
                                         gint                *total,
236 1 hiro
                                         gint                *min,
237 1 hiro
                                         gint                *max,
238 1 hiro
                                         gint                 first);
239 1 hiro
FILE   *procmsg_open_cache_file                (FolderItem        *item,
240 1 hiro
                                         DataOpenMode         mode);
241 1 hiro
FILE   *procmsg_open_mark_file                (FolderItem        *item,
242 1 hiro
                                         DataOpenMode         mode);
243 1 hiro
244 1 hiro
GNode  *procmsg_get_thread_tree                (GSList                *mlist);
245 1 hiro
246 1 hiro
gint        procmsg_move_messages                (GSList                *mlist);
247 1 hiro
gint        procmsg_copy_messages                (GSList                *mlist);
248 1 hiro
249 1 hiro
gchar  *procmsg_get_message_file_path        (MsgInfo        *msginfo);
250 1 hiro
gchar  *procmsg_get_message_file        (MsgInfo        *msginfo);
251 1 hiro
GSList *procmsg_get_message_file_list        (GSList                *mlist);
252 1 hiro
void        procmsg_message_file_list_free        (GSList                *file_list);
253 1 hiro
FILE   *procmsg_open_message                (MsgInfo        *msginfo);
254 1 hiro
#if USE_GPGME
255 1 hiro
FILE   *procmsg_open_message_decrypted        (MsgInfo        *msginfo,
256 1 hiro
                                         MimeInfo      **mimeinfo);
257 1 hiro
#endif
258 1 hiro
gboolean procmsg_msg_exist                (MsgInfo        *msginfo);
259 1 hiro
260 1 hiro
void        procmsg_get_filter_keyword        (MsgInfo          *msginfo,
261 1 hiro
                                         gchar                 **header,
262 1 hiro
                                         gchar                 **key,
263 1 hiro
                                         PrefsFilterType   type);
264 1 hiro
265 1 hiro
void        procmsg_empty_trash                (FolderItem        *trash);
266 1 hiro
void        procmsg_empty_all_trash                (void);
267 1 hiro
268 1 hiro
gint        procmsg_send_queue                (FolderItem        *queue,
269 317 hiro
                                         gboolean         save_msgs,
270 317 hiro
                                         gboolean         filter_msgs);
271 1 hiro
gint        procmsg_save_to_outbox                (FolderItem        *outbox,
272 317 hiro
                                         const gchar        *file);
273 1 hiro
void        procmsg_print_message                (MsgInfo        *msginfo,
274 1 hiro
                                         const gchar        *cmdline);
275 1 hiro
276 1 hiro
MsgInfo *procmsg_msginfo_copy                (MsgInfo        *msginfo);
277 1 hiro
MsgInfo *procmsg_msginfo_get_full_info        (MsgInfo        *msginfo);
278 1 hiro
void         procmsg_msginfo_free                (MsgInfo        *msginfo);
279 1 hiro
280 1 hiro
gint procmsg_cmp_msgnum_for_sort        (gconstpointer         a,
281 1 hiro
                                         gconstpointer         b);
282 1 hiro
283 1 hiro
#endif /* __PROCMSG_H__ */