Statistics
| Branch: | Tag: | Revision:

root / libsylph / procmsg.h @ 8d7dcace

History | View | Annotate | Download (6.12 KB)

1
/*
2
 * LibSylph -- E-Mail client library
3
 * Copyright (C) 1999-2011 Hiroyuki Yamamoto
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library 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 GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19

    
20
#ifndef __PROCMSG_H__
21
#define __PROCMSG_H__
22

    
23
#ifdef HAVE_CONFIG_H
24
#  include "config.h"
25
#endif
26

    
27
#include <glib.h>
28
#include <stdio.h>
29
#include <time.h>
30
#include <sys/types.h>
31
#include <string.h>
32

    
33
typedef struct _MsgInfo                MsgInfo;
34
typedef struct _MsgFlags        MsgFlags;
35
typedef struct _MsgFileInfo        MsgFileInfo;
36
typedef struct _MsgEncryptInfo        MsgEncryptInfo;
37

    
38
/* incomplete types */
39
typedef struct _Folder                Folder;
40
typedef struct _FolderItem        FolderItem;
41

    
42
#include "procmime.h"
43

    
44
typedef enum
45
{
46
        DATA_READ,
47
        DATA_WRITE,
48
        DATA_APPEND
49
} DataOpenMode;
50

    
51
#define MSG_NEW                        (1U << 0)
52
#define MSG_UNREAD                (1U << 1)
53
#define MSG_MARKED                (1U << 2)
54
#define MSG_DELETED                (1U << 3)
55
#define MSG_REPLIED                (1U << 4)
56
#define MSG_FORWARDED                (1U << 5)
57

    
58
#define MSG_CLABEL_SBIT        (7)                /* start bit of color label */
59
#define MAKE_MSG_CLABEL(h, m, l)        (((h) << (MSG_CLABEL_SBIT + 2)) | \
60
                                         ((m) << (MSG_CLABEL_SBIT + 1)) | \
61
                                         ((l) << (MSG_CLABEL_SBIT + 0)))
62

    
63
#define MSG_CLABEL_NONE                MAKE_MSG_CLABEL(0U, 0U, 0U)
64
#define MSG_CLABEL_1                MAKE_MSG_CLABEL(0U, 0U, 1U)
65
#define MSG_CLABEL_2                MAKE_MSG_CLABEL(0U, 1U, 0U)
66
#define MSG_CLABEL_3                MAKE_MSG_CLABEL(0U, 1U, 1U)
67
#define MSG_CLABEL_4                MAKE_MSG_CLABEL(1U, 0U, 0U)
68
#define MSG_CLABEL_5                MAKE_MSG_CLABEL(1U, 0U, 1U)
69
#define MSG_CLABEL_6                MAKE_MSG_CLABEL(1U, 1U, 0U)
70
#define MSG_CLABEL_7                MAKE_MSG_CLABEL(1U, 1U, 1U)
71

    
72
#define MSG_CLABEL_ORANGE        MSG_CLABEL_1
73
#define MSG_CLABEL_RED                MSG_CLABEL_2
74
#define MSG_CLABEL_PINK                MSG_CLABEL_3
75
#define MSG_CLABEL_SKYBLUE        MSG_CLABEL_4
76
#define MSG_CLABEL_BLUE                MSG_CLABEL_5
77
#define MSG_CLABEL_GREEN        MSG_CLABEL_6
78
#define MSG_CLABEL_BROWN        MSG_CLABEL_7
79

    
80
/* RESERVED */
81
#define        MSG_RESERVED                (1U << 31)
82

    
83
#define MSG_CLABEL_FLAG_MASK        (MSG_CLABEL_7)
84

    
85
typedef guint32 MsgPermFlags;
86

    
87
#define MSG_MOVE                (1U << 0)
88
#define MSG_COPY                (1U << 1)
89
#define MSG_QUEUED                (1U << 16)
90
#define MSG_DRAFT                (1U << 17)
91
#define MSG_ENCRYPTED                (1U << 18)
92
#define MSG_IMAP                (1U << 19)
93
#define MSG_NEWS                (1U << 20)
94
#define MSG_SIGNED                (1U << 21)
95
#define MSG_FLAG_CHANGED        (1U << 27)
96
#define MSG_CACHED                (1U << 28)
97
#define MSG_MIME                (1U << 29)
98
#define MSG_INVALID                (1U << 30)
99
#define MSG_RECEIVED                (1U << 31)
100

    
101
#define MSG_CACHED_FLAG_MASK        (MSG_MIME)
102

    
103
typedef guint32 MsgTmpFlags;
104

    
105
#define MSG_SET_FLAGS(msg, flags)        { (msg) |= (flags); }
106
#define MSG_UNSET_FLAGS(msg, flags)        { (msg) &= ~(flags); }
107
#define MSG_SET_PERM_FLAGS(msg, flags) \
108
        MSG_SET_FLAGS((msg).perm_flags, flags)
109
#define MSG_SET_TMP_FLAGS(msg, flags) \
110
        MSG_SET_FLAGS((msg).tmp_flags, flags)
111
#define MSG_UNSET_PERM_FLAGS(msg, flags) \
112
        MSG_UNSET_FLAGS((msg).perm_flags, flags)
113
#define MSG_UNSET_TMP_FLAGS(msg, flags) \
114
        MSG_UNSET_FLAGS((msg).tmp_flags, flags)
115

    
116
#define MSG_IS_NEW(msg)                        (((msg).perm_flags & MSG_NEW) != 0)
117
#define MSG_IS_UNREAD(msg)                (((msg).perm_flags & MSG_UNREAD) != 0)
118
#define MSG_IS_MARKED(msg)                (((msg).perm_flags & MSG_MARKED) != 0)
119
#define MSG_IS_DELETED(msg)                (((msg).perm_flags & MSG_DELETED) != 0)
120
#define MSG_IS_REPLIED(msg)                (((msg).perm_flags & MSG_REPLIED) != 0)
121
#define MSG_IS_FORWARDED(msg)                (((msg).perm_flags & MSG_FORWARDED) != 0)
122

    
123
#define MSG_GET_COLORLABEL(msg)                (((msg).perm_flags & MSG_CLABEL_FLAG_MASK))
124
#define MSG_GET_COLORLABEL_VALUE(msg)        (MSG_GET_COLORLABEL(msg) >> MSG_CLABEL_SBIT)
125
#define MSG_SET_COLORLABEL_VALUE(msg, val) \
126
        MSG_SET_PERM_FLAGS(msg, ((((guint)(val)) & 7) << MSG_CLABEL_SBIT))
127

    
128
#define MSG_IS_MOVE(msg)                (((msg).tmp_flags & MSG_MOVE) != 0)
129
#define MSG_IS_COPY(msg)                (((msg).tmp_flags & MSG_COPY) != 0)
130

    
131
#define MSG_IS_QUEUED(msg)                (((msg).tmp_flags & MSG_QUEUED) != 0)
132
#define MSG_IS_DRAFT(msg)                (((msg).tmp_flags & MSG_DRAFT) != 0)
133
#define MSG_IS_ENCRYPTED(msg)                (((msg).tmp_flags & MSG_ENCRYPTED) != 0)
134
#define MSG_IS_IMAP(msg)                (((msg).tmp_flags & MSG_IMAP) != 0)
135
#define MSG_IS_NEWS(msg)                (((msg).tmp_flags & MSG_NEWS) != 0)
136
#define MSG_IS_SIGNED(msg)                (((msg).tmp_flags & MSG_SIGNED) != 0)
137
#define MSG_IS_FLAG_CHANGED(msg)        (((msg).tmp_flags & MSG_FLAG_CHANGED) != 0)
138
#define MSG_IS_CACHED(msg)                (((msg).tmp_flags & MSG_CACHED) != 0)
139
#define MSG_IS_MIME(msg)                (((msg).tmp_flags & MSG_MIME) != 0)
140
#define MSG_IS_INVALID(msg)                (((msg).tmp_flags & MSG_INVALID) != 0)
141
#define MSG_IS_RECEIVED(msg)                (((msg).tmp_flags & MSG_RECEIVED) != 0)
142

    
143
struct _MsgFlags
144
{
145
        MsgPermFlags perm_flags;
146
        MsgTmpFlags  tmp_flags;
147
};
148

    
149
struct _MsgInfo
150
{
151
        guint  msgnum;
152
        gsize  size;
153
        time_t mtime;
154
        time_t date_t;
155

    
156
        MsgFlags flags;
157

    
158
        gchar *fromname;
159

    
160
        gchar *date;
161
        gchar *from;
162
        gchar *to;
163
        gchar *cc;
164
        gchar *newsgroups;
165
        gchar *subject;
166
        gchar *msgid;
167
        gchar *inreplyto;
168

    
169
        GSList *references;
170

    
171
        FolderItem *folder;
172
        FolderItem *to_folder;
173

    
174
        gchar *xface;
175

    
176
        /* used only for temporary messages */
177
        gchar *file_path;
178

    
179
        /* used only for encrypted (and signed) messages */
180
        MsgEncryptInfo *encinfo;
181
};
182

    
183
struct _MsgFileInfo
184
{
185
        gchar *file;
186
        MsgFlags *flags;
187
};
188

    
189
struct _MsgEncryptInfo
190
{
191
        gchar *plaintext_file;
192
        gchar *sigstatus;
193
        gchar *sigstatus_full;
194
        gboolean decryption_failed;
195
};
196

    
197
gchar  *procmsg_get_message_file_path        (MsgInfo        *msginfo);
198
gchar  *procmsg_get_message_file        (MsgInfo        *msginfo);
199
FILE   *procmsg_open_message                (MsgInfo        *msginfo);
200

    
201
FILE   *procmsg_open_message_decrypted        (MsgInfo        *msginfo,
202
                                         MimeInfo      **mimeinfo);
203

    
204
MsgInfo *procmsg_msginfo_copy                (MsgInfo        *msginfo);
205
MsgInfo *procmsg_msginfo_get_full_info        (MsgInfo        *msginfo);
206
gboolean procmsg_msginfo_equal                (MsgInfo        *msginfo_a,
207
                                         MsgInfo        *msginfo_b);
208
void         procmsg_msginfo_free                (MsgInfo        *msginfo);
209

    
210
#endif /* __PROCMSG_H__ */