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 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.
23 #ifndef _CAMEL_STORE_SUMMARY_H
24 #define _CAMEL_STORE_SUMMARY_H
30 #include <camel/camel-mime-parser.h>
31 #include <camel/camel-object.h>
32 #include <camel/camel-url.h>
34 #define CAMEL_STORE_SUMMARY(obj) CAMEL_CHECK_CAST (obj, camel_store_summary_get_type (), CamelStoreSummary)
35 #define CAMEL_STORE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_store_summary_get_type (), CamelStoreSummaryClass)
36 #define CAMEL_IS_STORE_SUMMARY(obj) CAMEL_CHECK_TYPE (obj, camel_store_summary_get_type ())
40 typedef struct _CamelStoreSummary CamelStoreSummary;
41 typedef struct _CamelStoreSummaryClass CamelStoreSummaryClass;
43 typedef struct _CamelStoreInfo CamelStoreInfo;
45 /* FIXME: this needs to track the CAMEL_FOLDER_* flags in camel-store.h */
46 typedef enum _CamelStoreInfoFlags {
47 CAMEL_STORE_INFO_FOLDER_NOSELECT = 1<<0,
48 CAMEL_STORE_INFO_FOLDER_NOINFERIORS = 1<<1,
49 CAMEL_STORE_INFO_FOLDER_CHILDREN = 1<<2,
50 CAMEL_STORE_INFO_FOLDER_NOCHILDREN = 1<<3,
51 CAMEL_STORE_INFO_FOLDER_SUBSCRIBED = 1<<4,
52 CAMEL_STORE_INFO_FOLDER_VIRTUAL = 1<<5,
53 CAMEL_STORE_INFO_FOLDER_SYSTEM = 1<<6,
54 CAMEL_STORE_INFO_FOLDER_VTRASH = 1<<7,
55 CAMEL_STORE_INFO_FOLDER_SHARED_BY_ME = 1<<8,
56 CAMEL_STORE_INFO_FOLDER_SHARED_TO_ME = 1<<9,
58 /* not in camle-store.h yet */
59 CAMEL_STORE_INFO_FOLDER_READONLY = 1<<13,
61 CAMEL_STORE_INFO_FOLDER_FLAGGED = 1<<31
62 } CamelStoreInfoFlags;
64 #define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)
67 CAMEL_STORE_INFO_PATH = 0,
68 CAMEL_STORE_INFO_NAME,
70 CAMEL_STORE_INFO_LAST,
73 struct _CamelStoreInfo {
82 typedef enum _CamelStoreSummaryFlags {
83 CAMEL_STORE_SUMMARY_DIRTY = 1<<0,
84 CAMEL_STORE_SUMMARY_FRAGMENT = 1<<1, /* path name is stored in fragment rather than path */
85 } CamelStoreSummaryFlags;
87 struct _CamelStoreSummary {
90 struct _CamelStoreSummaryPrivate *priv;
93 guint32 version; /* version of base part of file */
94 guint32 flags; /* flags */
95 guint32 count; /* how many were saved/loaded */
96 time_t time; /* timestamp for this summary (for implementors to use) */
97 struct _CamelURL *uri_base; /* url of base part of summary */
99 /* sizes of memory objects */
100 guint32 store_info_size;
102 /* memory allocators (setup automatically) */
103 struct _EMemChunk *store_info_chunks;
107 GPtrArray *folders; /* CamelStoreInfo's */
108 GHashTable *folders_path; /* CamelStoreInfo's by path name */
111 struct _CamelStoreSummaryClass {
112 CamelObjectClass parent_class;
114 /* load/save the global info */
115 int (*summary_header_load)(CamelStoreSummary *, FILE *);
116 int (*summary_header_save)(CamelStoreSummary *, FILE *);
118 /* create/save/load an individual message info */
119 CamelStoreInfo * (*store_info_new)(CamelStoreSummary *, const char *path);
120 CamelStoreInfo * (*store_info_load)(CamelStoreSummary *, FILE *);
121 int (*store_info_save)(CamelStoreSummary *, FILE *, CamelStoreInfo *);
122 void (*store_info_free)(CamelStoreSummary *, CamelStoreInfo *);
124 /* virtualise access methods */
125 const char *(*store_info_string)(CamelStoreSummary *, const CamelStoreInfo *, int);
126 void (*store_info_set_string)(CamelStoreSummary *, CamelStoreInfo *, int, const char *);
129 CamelType camel_store_summary_get_type (void);
130 CamelStoreSummary *camel_store_summary_new (void);
132 void camel_store_summary_set_filename(CamelStoreSummary *summary, const char *filename);
133 void camel_store_summary_set_uri_base(CamelStoreSummary *summary, CamelURL *base);
135 /* load/save the summary in its entirety */
136 int camel_store_summary_load(CamelStoreSummary *summary);
137 int camel_store_summary_save(CamelStoreSummary *summary);
139 /* only load the header */
140 int camel_store_summary_header_load(CamelStoreSummary *summary);
142 /* set the dirty bit on the summary */
143 void camel_store_summary_touch(CamelStoreSummary *summary);
145 /* add a new raw summary item */
146 void camel_store_summary_add(CamelStoreSummary *summary, CamelStoreInfo *info);
148 /* build/add raw summary items */
149 CamelStoreInfo *camel_store_summary_add_from_path(CamelStoreSummary *summary, const char *path);
151 /* Just build raw summary items */
152 CamelStoreInfo *camel_store_summary_info_new(CamelStoreSummary *summary);
153 CamelStoreInfo *camel_store_summary_info_new_from_path(CamelStoreSummary *summary, const char *path);
155 void camel_store_summary_info_ref(CamelStoreSummary *summary, CamelStoreInfo *info);
156 void camel_store_summary_info_free(CamelStoreSummary *summary, CamelStoreInfo *info);
158 /* removes a summary item */
159 void camel_store_summary_remove(CamelStoreSummary *summary, CamelStoreInfo *info);
160 void camel_store_summary_remove_path(CamelStoreSummary *summary, const char *path);
161 void camel_store_summary_remove_index(CamelStoreSummary *summary, int index);
163 /* remove all items */
164 void camel_store_summary_clear(CamelStoreSummary *summary);
166 /* lookup functions */
167 int camel_store_summary_count(CamelStoreSummary *summary);
168 CamelStoreInfo *camel_store_summary_index(CamelStoreSummary *summary, int index);
169 CamelStoreInfo *camel_store_summary_path(CamelStoreSummary *summary, const char *path);
170 GPtrArray *camel_store_summary_array(CamelStoreSummary *summary);
171 void camel_store_summary_array_free(CamelStoreSummary *summary, GPtrArray *array);
173 const char *camel_store_info_string(CamelStoreSummary *summary, const CamelStoreInfo *info, int type);
174 void camel_store_info_set_string(CamelStoreSummary *summary, CamelStoreInfo *info, int type, const char *value);
177 #define camel_store_info_path(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_PATH))
178 #define camel_store_info_uri(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_URI))
179 #define camel_store_info_name(s, i) (camel_store_info_string((CamelStoreSummary *)s, (const CamelStoreInfo *)i, CAMEL_STORE_INFO_NAME))
183 #endif /* ! _CAMEL_STORE_SUMMARY_H */