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 /* FIXME: this needs to track the CAMEL_FOLDER_* flags in camel-store.h */
49 typedef enum _CamelStoreInfoFlags {
50 CAMEL_STORE_INFO_FOLDER_NOSELECT = 1<<0,
51 CAMEL_STORE_INFO_FOLDER_NOINFERIORS = 1<<1,
52 CAMEL_STORE_INFO_FOLDER_CHILDREN = 1<<2,
53 CAMEL_STORE_INFO_FOLDER_NOCHILDREN = 1<<3,
54 CAMEL_STORE_INFO_FOLDER_SUBSCRIBED = 1<<4,
55 CAMEL_STORE_INFO_FOLDER_VIRTUAL = 1<<5,
56 CAMEL_STORE_INFO_FOLDER_SYSTEM = 1<<6,
57 CAMEL_STORE_INFO_FOLDER_VTRASH = 1<<7,
58 CAMEL_STORE_INFO_FOLDER_SHARED_BY_ME = 1<<8,
59 CAMEL_STORE_INFO_FOLDER_SHARED_TO_ME = 1<<9,
61 /* not in camle-store.h yet */
62 CAMEL_STORE_INFO_FOLDER_READONLY = 1<<13,
64 CAMEL_STORE_INFO_FOLDER_FLAGGED = 1<<31
65 } CamelStoreInfoFlags;
67 #define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)
70 CAMEL_STORE_INFO_PATH = 0,
71 CAMEL_STORE_INFO_NAME,
73 CAMEL_STORE_INFO_LAST,
76 struct _CamelStoreInfo {
85 typedef enum _CamelStoreSummaryFlags {
86 CAMEL_STORE_SUMMARY_DIRTY = 1<<0,
87 CAMEL_STORE_SUMMARY_FRAGMENT = 1<<1, /* path name is stored in fragment rather than path */
88 } CamelStoreSummaryFlags;
90 struct _CamelStoreSummary {
93 struct _CamelStoreSummaryPrivate *priv;
96 guint32 version; /* version of base part of file */
97 guint32 flags; /* flags */
98 guint32 count; /* how many were saved/loaded */
99 time_t time; /* timestamp for this summary (for implementors to use) */
100 struct _CamelURL *uri_base; /* url of base part of summary */
102 /* sizes of memory objects */
103 guint32 store_info_size;
105 /* memory allocators (setup automatically) */
106 struct _EMemChunk *store_info_chunks;
110 GPtrArray *folders; /* CamelStoreInfo's */
111 GHashTable *folders_path; /* CamelStoreInfo's by path name */
114 struct _CamelStoreSummaryClass {
115 CamelObjectClass parent_class;
117 /* load/save the global info */
118 int (*summary_header_load)(CamelStoreSummary *, FILE *);
119 int (*summary_header_save)(CamelStoreSummary *, FILE *);
121 /* create/save/load an individual message info */
122 CamelStoreInfo * (*store_info_new)(CamelStoreSummary *, const char *path);
123 CamelStoreInfo * (*store_info_load)(CamelStoreSummary *, FILE *);
124 int (*store_info_save)(CamelStoreSummary *, FILE *, CamelStoreInfo *);
125 void (*store_info_free)(CamelStoreSummary *, CamelStoreInfo *);
127 /* virtualise access methods */
128 const char *(*store_info_string)(CamelStoreSummary *, const CamelStoreInfo *, int);
129 void (*store_info_set_string)(CamelStoreSummary *, CamelStoreInfo *, int, const char *);
132 CamelType camel_store_summary_get_type (void);
133 CamelStoreSummary *camel_store_summary_new (void);
135 void camel_store_summary_set_filename(CamelStoreSummary *summary, const char *filename);
136 void camel_store_summary_set_uri_base(CamelStoreSummary *summary, CamelURL *base);
138 /* load/save the summary in its entirety */
139 int camel_store_summary_load(CamelStoreSummary *summary);
140 int camel_store_summary_save(CamelStoreSummary *summary);
142 /* only load the header */
143 int camel_store_summary_header_load(CamelStoreSummary *summary);
145 /* set the dirty bit on the summary */
146 void camel_store_summary_touch(CamelStoreSummary *summary);
148 /* add a new raw summary item */
149 void camel_store_summary_add(CamelStoreSummary *summary, CamelStoreInfo *info);
151 /* build/add raw summary items */
152 CamelStoreInfo *camel_store_summary_add_from_path(CamelStoreSummary *summary, const char *path);
154 /* Just build raw summary items */
155 CamelStoreInfo *camel_store_summary_info_new(CamelStoreSummary *summary);
156 CamelStoreInfo *camel_store_summary_info_new_from_path(CamelStoreSummary *summary, const char *path);
158 void camel_store_summary_info_ref(CamelStoreSummary *summary, CamelStoreInfo *info);
159 void camel_store_summary_info_free(CamelStoreSummary *summary, CamelStoreInfo *info);
161 /* removes a summary item */
162 void camel_store_summary_remove(CamelStoreSummary *summary, CamelStoreInfo *info);
163 void camel_store_summary_remove_path(CamelStoreSummary *summary, const char *path);
164 void camel_store_summary_remove_index(CamelStoreSummary *summary, int index);
166 /* remove all items */
167 void camel_store_summary_clear(CamelStoreSummary *summary);
169 /* lookup functions */
170 int camel_store_summary_count(CamelStoreSummary *summary);
171 CamelStoreInfo *camel_store_summary_index(CamelStoreSummary *summary, int index);
172 CamelStoreInfo *camel_store_summary_path(CamelStoreSummary *summary, const char *path);
173 GPtrArray *camel_store_summary_array(CamelStoreSummary *summary);
174 void camel_store_summary_array_free(CamelStoreSummary *summary, GPtrArray *array);
176 const char *camel_store_info_string(CamelStoreSummary *summary, const CamelStoreInfo *info, int type);
177 void camel_store_info_set_string(CamelStoreSummary *summary, CamelStoreInfo *info, int type, const char *value);
180 #define camel_store_info_path(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_PATH))
181 #define camel_store_info_uri(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_URI))
182 #define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
186 #endif /* __cplusplus */
188 #endif /* ! _CAMEL_STORE_SUMMARY_H */