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-enums.h>
32 #include <camel/camel-memchunk.h>
33 #include <camel/camel-mime-parser.h>
34 #include <camel/camel-object.h>
36 /* Standard GObject macros */
37 #define CAMEL_TYPE_STORE_SUMMARY \
38 (camel_store_summary_get_type ())
39 #define CAMEL_STORE_SUMMARY(obj) \
40 (G_TYPE_CHECK_INSTANCE_CAST \
41 ((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummary))
42 #define CAMEL_STORE_SUMMARY_CLASS(cls) \
43 (G_TYPE_CHECK_CLASS_CAST \
44 ((cls), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))
45 #define CAMEL_IS_STORE_SUMMARY(obj) \
46 (G_TYPE_CHECK_INSTANCE_TYPE \
47 ((obj), CAMEL_TYPE_STORE_SUMMARY))
48 #define CAMEL_IS_STORE_SUMMARY_CLASS(cls) \
49 (G_TYPE_CHECK_CLASS_TYPE \
50 ((cls), CAMEL_TYPE_STORE_SUMMARY))
51 #define CAMEL_STORE_SUMMARY_GET_CLASS(obj) \
52 (G_TYPE_INSTANCE_GET_CLASS \
53 ((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))
57 typedef struct _CamelStoreSummary CamelStoreSummary;
58 typedef struct _CamelStoreSummaryClass CamelStoreSummaryClass;
59 typedef struct _CamelStoreSummaryPrivate CamelStoreSummaryPrivate;
61 typedef struct _CamelStoreInfo CamelStoreInfo;
63 #define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)
66 CAMEL_STORE_INFO_PATH = 0,
67 CAMEL_STORE_INFO_NAME,
71 struct _CamelStoreInfo {
79 typedef enum _CamelStoreSummaryFlags {
80 CAMEL_STORE_SUMMARY_DIRTY = 1 << 0,
81 } CamelStoreSummaryFlags;
84 * CamelStoreSummaryLock:
89 CAMEL_STORE_SUMMARY_SUMMARY_LOCK,
90 CAMEL_STORE_SUMMARY_IO_LOCK,
91 CAMEL_STORE_SUMMARY_REF_LOCK
92 } CamelStoreSummaryLock;
94 struct _CamelStoreSummary {
96 CamelStoreSummaryPrivate *priv;
99 guint32 version; /* version of base part of file */
100 guint32 flags; /* flags */
101 guint32 count; /* how many were saved/loaded */
102 time_t time; /* timestamp for this summary (for implementors to use) */
104 /* sizes of memory objects */
105 guint32 store_info_size;
107 /* memory allocators (setup automatically) */
108 CamelMemChunk *store_info_chunks;
112 GPtrArray *folders; /* CamelStoreInfo's */
113 GHashTable *folders_path; /* CamelStoreInfo's by path name */
116 struct _CamelStoreSummaryClass {
117 CamelObjectClass parent_class;
119 /* load/save the global info */
120 gint (*summary_header_load)(CamelStoreSummary *, FILE *);
121 gint (*summary_header_save)(CamelStoreSummary *, FILE *);
123 /* create/save/load an individual message info */
124 CamelStoreInfo * (*store_info_new)(CamelStoreSummary *, const gchar *path);
125 CamelStoreInfo * (*store_info_load)(CamelStoreSummary *, FILE *);
126 gint (*store_info_save)(CamelStoreSummary *, FILE *, CamelStoreInfo *);
127 void (*store_info_free)(CamelStoreSummary *, CamelStoreInfo *);
129 /* virtualise access methods */
130 const gchar *(*store_info_string)(CamelStoreSummary *, const CamelStoreInfo *, gint);
131 void (*store_info_set_string)(CamelStoreSummary *, CamelStoreInfo *, int, const gchar *);
134 GType camel_store_summary_get_type (void);
135 CamelStoreSummary *camel_store_summary_new (void);
137 void camel_store_summary_set_filename (CamelStoreSummary *summary, const gchar *filename);
139 /* load/save the summary in its entirety */
140 gint camel_store_summary_load (CamelStoreSummary *summary);
141 gint camel_store_summary_save (CamelStoreSummary *summary);
143 /* only load the header */
144 gint camel_store_summary_header_load (CamelStoreSummary *summary);
146 /* set the dirty bit on the summary */
147 void camel_store_summary_touch (CamelStoreSummary *summary);
149 /* add a new raw summary item */
150 void camel_store_summary_add (CamelStoreSummary *summary, CamelStoreInfo *info);
152 /* build/add raw summary items */
153 CamelStoreInfo *camel_store_summary_add_from_path (CamelStoreSummary *summary, const gchar *path);
155 /* Just build raw summary items */
156 CamelStoreInfo *camel_store_summary_info_new (CamelStoreSummary *summary);
157 CamelStoreInfo *camel_store_summary_info_new_from_path (CamelStoreSummary *summary, const gchar *path);
159 void camel_store_summary_info_ref (CamelStoreSummary *summary, CamelStoreInfo *info);
160 void camel_store_summary_info_free (CamelStoreSummary *summary, CamelStoreInfo *info);
162 /* removes a summary item */
163 void camel_store_summary_remove (CamelStoreSummary *summary, CamelStoreInfo *info);
164 void camel_store_summary_remove_path (CamelStoreSummary *summary, const gchar *path);
165 void camel_store_summary_remove_index (CamelStoreSummary *summary, gint index);
167 /* remove all items */
168 void camel_store_summary_clear (CamelStoreSummary *summary);
170 /* lookup functions */
171 gint camel_store_summary_count (CamelStoreSummary *summary);
172 CamelStoreInfo *camel_store_summary_index (CamelStoreSummary *summary, gint index);
173 CamelStoreInfo *camel_store_summary_path (CamelStoreSummary *summary, const gchar *path);
174 GPtrArray *camel_store_summary_array (CamelStoreSummary *summary);
175 void camel_store_summary_array_free (CamelStoreSummary *summary, GPtrArray *array);
177 const gchar *camel_store_info_string (CamelStoreSummary *summary, const CamelStoreInfo *info, gint type);
178 void camel_store_info_set_string (CamelStoreSummary *summary, CamelStoreInfo *info, gint type, const gchar *value);
181 #define camel_store_info_path(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_PATH))
182 #define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
184 void camel_store_summary_lock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
185 void camel_store_summary_unlock (CamelStoreSummary *summary, CamelStoreSummaryLock lock);
187 struct _CamelFolderSummary;
188 gboolean camel_store_summary_connect_folder_summary (CamelStoreSummary *summary, const gchar *path, struct _CamelFolderSummary *folder_summary);
189 gboolean camel_store_summary_disconnect_folder_summary (CamelStoreSummary *summary, struct _CamelFolderSummary *folder_summary);
193 #endif /* CAMEL_STORE_SUMMARY_H */