Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / providers / local / camel-local-summary.h
1 /*
2  *  Copyright (C) 2000 Ximian Inc.
3  *
4  *  Authors: Michael Zucchi <notzed@ximian.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
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 GNU
13  * 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 program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef _CAMEL_LOCAL_SUMMARY_H
22 #define _CAMEL_LOCAL_SUMMARY_H
23
24 #include <camel/camel-folder-summary.h>
25 #include <camel/camel-folder.h>
26 #include <camel/camel-exception.h>
27 #include <camel/camel-index.h>
28
29 #define CAMEL_LOCAL_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_local_summary_get_type (), CamelLocalSummary)
30 #define CAMEL_LOCAL_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_local_summary_get_type (), CamelLocalSummaryClass)
31 #define CAMEL_IS_LOCAL_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_local_summary_get_type ())
32
33 G_BEGIN_DECLS
34
35 typedef struct _CamelLocalSummary      CamelLocalSummary;
36 typedef struct _CamelLocalSummaryClass CamelLocalSummaryClass;
37
38 /* extra summary flags */
39 enum {
40         CAMEL_MESSAGE_FOLDER_NOXEV = 1<<17,
41         CAMEL_MESSAGE_FOLDER_XEVCHANGE = 1<<18,
42         CAMEL_MESSAGE_FOLDER_NOTSEEN = 1<<19, /* have we seen this in processing this loop? */
43 };
44
45 typedef struct _CamelLocalMessageInfo CamelLocalMessageInfo;
46
47 struct _CamelLocalMessageInfo {
48         CamelMessageInfoBase info;
49 };
50
51 struct _CamelLocalSummary {
52         CamelFolderSummary parent;
53
54         guint32 version;        /* file version being loaded */
55
56         char *folder_path;      /* name of matching folder */
57         
58         CamelIndex *index;
59         unsigned int index_force:1; /* do we force index during creation? */
60         unsigned int check_force:1; /* does a check force a full check? */
61 };
62
63 struct _CamelLocalSummaryClass {
64         CamelFolderSummaryClass parent_class;
65
66         int (*load)(CamelLocalSummary *cls, int forceindex, CamelException *ex);
67         int (*check)(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex);
68         int (*sync)(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex);
69         CamelMessageInfo *(*add)(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
70
71         char *(*encode_x_evolution)(CamelLocalSummary *cls, const CamelLocalMessageInfo *info);
72         int (*decode_x_evolution)(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *info);
73 };
74
75 CamelType       camel_local_summary_get_type    (void);
76 void    camel_local_summary_construct   (CamelLocalSummary *new, const char *filename, const char *local_name, CamelIndex *index);
77
78 /* load/check the summary */
79 int camel_local_summary_load(CamelLocalSummary *cls, int forceindex, CamelException *ex);
80 /* check for new/removed messages */
81 int camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *, CamelException *ex);
82 /* perform a folder sync or expunge, if needed */
83 int camel_local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *, CamelException *ex);
84 /* add a new message to the summary */
85 CamelMessageInfo *camel_local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex);
86
87 /* force the next check to be a full check/rebuild */
88 void camel_local_summary_check_force(CamelLocalSummary *cls);
89
90 /* generate an X-Evolution header line */
91 char *camel_local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *info);
92 int camel_local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *info);
93
94 /* utility functions - write headers to a file with optional X-Evolution header and/or status header */
95 int camel_local_summary_write_headers(int fd, struct _camel_header_raw *header, const char *xevline, const char *status, const char *xstatus);
96
97 G_END_DECLS
98
99 #endif /* ! _CAMEL_LOCAL_SUMMARY_H */