1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000 Ximian Inc.
5 * Authors: Michael Zucchi <notzed@ximian.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU General Public
9 * License as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef _CAMEL_STORE_SUMMARY_H
24 #define _CAMEL_STORE_SUMMARY_H
29 #endif /* __cplusplus */
35 #include <camel/camel-mime-parser.h>
36 #include <camel/camel-object.h>
37 #include <camel/camel-url.h>
39 #define CAMEL_STORE_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_store_summary_get_type (), CamelStoreSummary)
40 #define CAMEL_STORE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_store_summary_get_type (), CamelStoreSummaryClass)
41 #define CAMEL_IS_STORE_SUMMARY(obj) CAMEL_CHECK_TYPE (obj, camel_store_summary_get_type ())
43 typedef struct _CamelStoreSummary CamelStoreSummary;
44 typedef struct _CamelStoreSummaryClass CamelStoreSummaryClass;
46 typedef struct _CamelStoreInfo CamelStoreInfo;
48 enum _CamelStoreInfoFlags {
49 CAMEL_STORE_INFO_FOLDER_NOSELECT,
50 CAMEL_STORE_INFO_FOLDER_READONLY,
51 CAMEL_STORE_INFO_FOLDER_SUBSCRIBED,
52 CAMEL_STORE_INFO_FOLDER_FLAGGED,
55 #define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)
58 CAMEL_STORE_INFO_PATH = 0,
59 CAMEL_STORE_INFO_NAME,
61 CAMEL_STORE_INFO_LAST,
64 struct _CamelStoreInfo {
73 enum _CamelStoreSummaryFlags {
74 CAMEL_STORE_SUMMARY_DIRTY = 1<<0,
75 CAMEL_STORE_SUMMARY_FRAGMENT = 1<<1, /* path name is stored in fragment rather than path */
78 struct _CamelStoreSummary {
81 struct _CamelStoreSummaryPrivate *priv;
84 guint32 version; /* version of base part of file */
85 guint32 flags; /* flags */
86 guint32 count; /* how many were saved/loaded */
87 time_t time; /* timestamp for this summary (for implementors to use) */
88 struct _CamelURL *uri_base; /* url of base part of summary */
90 /* sizes of memory objects */
91 guint32 store_info_size;
93 /* memory allocators (setup automatically) */
94 struct _EMemChunk *store_info_chunks;
98 GPtrArray *folders; /* CamelStoreInfo's */
99 GHashTable *folders_path; /* CamelStoreInfo's by path name */
102 struct _CamelStoreSummaryClass {
103 CamelObjectClass parent_class;
105 /* load/save the global info */
106 int (*summary_header_load)(CamelStoreSummary *, FILE *);
107 int (*summary_header_save)(CamelStoreSummary *, FILE *);
109 /* create/save/load an individual message info */
110 CamelStoreInfo * (*store_info_new)(CamelStoreSummary *, const char *path);
111 CamelStoreInfo * (*store_info_load)(CamelStoreSummary *, FILE *);
112 int (*store_info_save)(CamelStoreSummary *, FILE *, CamelStoreInfo *);
113 void (*store_info_free)(CamelStoreSummary *, CamelStoreInfo *);
115 /* virtualise access methods */
116 const char *(*store_info_string)(CamelStoreSummary *, const CamelStoreInfo *, int);
117 void (*store_info_set_string)(CamelStoreSummary *, CamelStoreInfo *, int, const char *);
120 CamelType camel_store_summary_get_type (void);
121 CamelStoreSummary *camel_store_summary_new (void);
123 void camel_store_summary_set_filename(CamelStoreSummary *, const char *);
124 void camel_store_summary_set_uri_base(CamelStoreSummary *s, CamelURL *base);
126 /* load/save the summary in its entirety */
127 int camel_store_summary_load(CamelStoreSummary *);
128 int camel_store_summary_save(CamelStoreSummary *);
130 /* only load the header */
131 int camel_store_summary_header_load(CamelStoreSummary *);
133 /* set the dirty bit on the summary */
134 void camel_store_summary_touch(CamelStoreSummary *s);
136 /* add a new raw summary item */
137 void camel_store_summary_add(CamelStoreSummary *, CamelStoreInfo *info);
139 /* build/add raw summary items */
140 CamelStoreInfo *camel_store_summary_add_from_path(CamelStoreSummary *, const char *);
142 /* Just build raw summary items */
143 CamelStoreInfo *camel_store_summary_info_new(CamelStoreSummary *s);
144 CamelStoreInfo *camel_store_summary_info_new_from_path(CamelStoreSummary *s, const char *);
146 void camel_store_summary_info_ref(CamelStoreSummary *, CamelStoreInfo *);
147 void camel_store_summary_info_free(CamelStoreSummary *, CamelStoreInfo *);
149 /* removes a summary item */
150 void camel_store_summary_remove(CamelStoreSummary *s, CamelStoreInfo *info);
151 void camel_store_summary_remove_path(CamelStoreSummary *s, const char *path);
152 void camel_store_summary_remove_index(CamelStoreSummary *s, int);
154 /* remove all items */
155 void camel_store_summary_clear(CamelStoreSummary *s);
157 /* lookup functions */
158 int camel_store_summary_count(CamelStoreSummary *);
159 CamelStoreInfo *camel_store_summary_index(CamelStoreSummary *, int);
160 CamelStoreInfo *camel_store_summary_path(CamelStoreSummary *, const char *uid);
161 GPtrArray *camel_store_summary_array(CamelStoreSummary *s);
162 void camel_store_summary_array_free(CamelStoreSummary *s, GPtrArray *array);
164 const char *camel_store_info_string(CamelStoreSummary *, const CamelStoreInfo *, int type);
165 void camel_store_info_set_string(CamelStoreSummary *, CamelStoreInfo *, int type, const char *value);
168 #define camel_store_info_path(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_PATH))
169 #define camel_store_info_uri(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_URI))
170 #define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
174 #endif /* __cplusplus */
176 #endif /* ! _CAMEL_STORE_SUMMARY_H */