1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
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 Lesser 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 Lesser General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
23 #error "Only <camel/camel.h> can be included directly."
26 #ifndef CAMEL_STORE_SUMMARY_H
27 #define CAMEL_STORE_SUMMARY_H
31 #include <camel/camel-mime-parser.h>
32 #include <camel/camel-object.h>
33 #include <camel/camel-url.h>
35 /* Standard GObject macros */
36 #define CAMEL_TYPE_STORE_SUMMARY \
37 (camel_store_summary_get_type ())
38 #define CAMEL_STORE_SUMMARY(obj) \
39 (G_TYPE_CHECK_INSTANCE_CAST \
40 ((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummary))
41 #define CAMEL_STORE_SUMMARY_CLASS(cls) \
42 (G_TYPE_CHECK_CLASS_CAST \
43 ((cls), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))
44 #define CAMEL_IS_STORE_SUMMARY(obj) \
45 (G_TYPE_CHECK_INSTANCE_TYPE \
46 ((obj), CAMEL_TYPE_STORE_SUMMARY))
47 #define CAMEL_IS_STORE_SUMMARY_CLASS(cls) \
48 (G_TYPE_CHECK_CLASS_TYPE \
49 ((cls), CAMEL_TYPE_STORE_SUMMARY))
50 #define CAMEL_STORE_SUMMARY_GET_CLASS(obj) \
51 (G_TYPE_INSTANCE_GET_CLASS \
52 ((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))
56 typedef struct _CamelStoreSummary CamelStoreSummary;
57 typedef struct _CamelStoreSummaryClass CamelStoreSummaryClass;
58 typedef struct _CamelStoreSummaryPrivate CamelStoreSummaryPrivate;
60 typedef struct _CamelStoreInfo CamelStoreInfo;
62 /* FIXME: this needs to track the CAMEL_FOLDER_* flags in camel-store.h */
63 typedef enum _CamelStoreInfoFlags {
64 CAMEL_STORE_INFO_FOLDER_NOSELECT = 1<<0,
65 CAMEL_STORE_INFO_FOLDER_NOINFERIORS = 1<<1,
66 CAMEL_STORE_INFO_FOLDER_CHILDREN = 1<<2,
67 CAMEL_STORE_INFO_FOLDER_NOCHILDREN = 1<<3,
68 CAMEL_STORE_INFO_FOLDER_SUBSCRIBED = 1<<4,
69 CAMEL_STORE_INFO_FOLDER_VIRTUAL = 1<<5,
70 CAMEL_STORE_INFO_FOLDER_SYSTEM = 1<<6,
71 CAMEL_STORE_INFO_FOLDER_VTRASH = 1<<7,
72 CAMEL_STORE_INFO_FOLDER_SHARED_BY_ME = 1<<8,
73 CAMEL_STORE_INFO_FOLDER_SHARED_TO_ME = 1<<9,
75 /* not in camle-store.h yet */
76 CAMEL_STORE_INFO_FOLDER_READONLY = 1<<13,
77 CAMEL_STORE_INFO_FOLDER_CHECK_FOR_NEW = 1<<14,
79 CAMEL_STORE_INFO_FOLDER_FLAGGED = 1<<31
80 } CamelStoreInfoFlags;
82 #define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)
85 CAMEL_STORE_INFO_PATH = 0,
86 CAMEL_STORE_INFO_NAME,
91 struct _CamelStoreInfo {
100 typedef enum _CamelStoreSummaryFlags {
101 CAMEL_STORE_SUMMARY_DIRTY = 1<<0,
102 CAMEL_STORE_SUMMARY_FRAGMENT = 1<<1 /* path name is stored in fragment rather than path */
103 } CamelStoreSummaryFlags;
109 } CamelStoreSummaryLock;
111 struct _CamelStoreSummary {
113 CamelStoreSummaryPrivate *priv;
116 guint32 version; /* version of base part of file */
117 guint32 flags; /* flags */
118 guint32 count; /* how many were saved/loaded */
119 time_t time; /* timestamp for this summary (for implementors to use) */
120 struct _CamelURL *uri_base; /* url of base part of summary */
122 /* sizes of memory objects */
123 guint32 store_info_size;
125 /* memory allocators (setup automatically) */
126 struct _EMemChunk *store_info_chunks;
130 GPtrArray *folders; /* CamelStoreInfo's */
131 GHashTable *folders_path; /* CamelStoreInfo's by path name */
134 struct _CamelStoreSummaryClass {
135 CamelObjectClass parent_class;
137 /* load/save the global info */
138 gint (*summary_header_load)(CamelStoreSummary *, FILE *);
139 gint (*summary_header_save)(CamelStoreSummary *, FILE *);
141 /* create/save/load an individual message info */
142 CamelStoreInfo * (*store_info_new)(CamelStoreSummary *, const gchar *path);
143 CamelStoreInfo * (*store_info_load)(CamelStoreSummary *, FILE *);
144 gint (*store_info_save)(CamelStoreSummary *, FILE *, CamelStoreInfo *);
145 void (*store_info_free)(CamelStoreSummary *, CamelStoreInfo *);
147 /* virtualise access methods */
148 const gchar *(*store_info_string)(CamelStoreSummary *, const CamelStoreInfo *, gint);
149 void (*store_info_set_string)(CamelStoreSummary *, CamelStoreInfo *, int, const gchar *);
152 GType camel_store_summary_get_type (void);
153 CamelStoreSummary *camel_store_summary_new (void);
155 void camel_store_summary_set_filename(CamelStoreSummary *summary, const gchar *filename);
156 void camel_store_summary_set_uri_base(CamelStoreSummary *summary, CamelURL *base);
158 /* load/save the summary in its entirety */
159 gint camel_store_summary_load(CamelStoreSummary *summary);
160 gint camel_store_summary_save(CamelStoreSummary *summary);
162 /* only load the header */
163 gint camel_store_summary_header_load(CamelStoreSummary *summary);
165 /* set the dirty bit on the summary */
166 void camel_store_summary_touch(CamelStoreSummary *summary);
168 /* add a new raw summary item */
169 void camel_store_summary_add(CamelStoreSummary *summary, CamelStoreInfo *info);
171 /* build/add raw summary items */
172 CamelStoreInfo *camel_store_summary_add_from_path(CamelStoreSummary *summary, const gchar *path);
174 /* Just build raw summary items */
175 CamelStoreInfo *camel_store_summary_info_new(CamelStoreSummary *summary);
176 CamelStoreInfo *camel_store_summary_info_new_from_path(CamelStoreSummary *summary, const gchar *path);
178 void camel_store_summary_info_ref(CamelStoreSummary *summary, CamelStoreInfo *info);
179 void camel_store_summary_info_free(CamelStoreSummary *summary, CamelStoreInfo *info);
181 /* removes a summary item */
182 void camel_store_summary_remove(CamelStoreSummary *summary, CamelStoreInfo *info);
183 void camel_store_summary_remove_path(CamelStoreSummary *summary, const gchar *path);
184 void camel_store_summary_remove_index(CamelStoreSummary *summary, gint index);
186 /* remove all items */
187 void camel_store_summary_clear(CamelStoreSummary *summary);
189 /* lookup functions */
190 gint camel_store_summary_count(CamelStoreSummary *summary);
191 CamelStoreInfo *camel_store_summary_index(CamelStoreSummary *summary, gint index);
192 CamelStoreInfo *camel_store_summary_path(CamelStoreSummary *summary, const gchar *path);
193 GPtrArray *camel_store_summary_array(CamelStoreSummary *summary);
194 void camel_store_summary_array_free(CamelStoreSummary *summary, GPtrArray *array);
196 const gchar *camel_store_info_string(CamelStoreSummary *summary, const CamelStoreInfo *info, gint type);
197 void camel_store_info_set_string(CamelStoreSummary *summary, CamelStoreInfo *info, gint type, const gchar *value);
200 #define camel_store_info_path(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_PATH))
201 #define camel_store_info_uri(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_URI))
202 #define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
204 void camel_store_summary_lock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
205 void camel_store_summary_unlock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
209 #endif /* CAMEL_STORE_SUMMARY_H */