1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-store.h : Abstract class for an email store */
6 * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
7 * Michael Zucchi <NotZed@ximian.com>
8 * Jeffrey Stedfast <fejj@ximian.com>
10 * Copyright 1999, 2003 Ximian, Inc. (www.ximian.com)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of version 2 of the GNU Lesser General Public
14 * License as published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
28 #define CAMEL_STORE_H 1
31 #include <sys/types.h>
33 #include <camel/camel-object.h>
34 #include <camel/camel-service.h>
39 CAMEL_STORE_ARG_FIRST = CAMEL_SERVICE_ARG_FIRST + 100,
42 typedef struct _CamelFolderInfo {
43 struct _CamelFolderInfo *next;
44 struct _CamelFolderInfo *parent;
45 struct _CamelFolderInfo *child;
56 /* Note: these are abstractions (duh), its upto the provider to make them make sense */
58 /* a folder which can't contain messages */
59 #define CAMEL_FOLDER_NOSELECT (1<<0)
60 /* a folder which cannot have children */
61 #define CAMEL_FOLDER_NOINFERIORS (1<<1)
62 /* a folder which has children (not yet fully implemented) */
63 #define CAMEL_FOLDER_CHILDREN (1<<2)
64 /* a folder which does not have any children (not yet fully implemented) */
65 #define CAMEL_FOLDER_NOCHILDREN (1<<3)
66 /* a folder which is subscribed */
67 #define CAMEL_FOLDER_SUBSCRIBED (1<<4)
68 /* a virtual folder, cannot copy/move messages here */
69 #define CAMEL_FOLDER_VIRTUAL (1<<5)
70 /* a system folder, cannot be renamed/deleted */
71 #define CAMEL_FOLDER_SYSTEM (1<<6)
72 /* a virtual folder that can't be copied to, and can only be moved to if in an existing folder */
73 #define CAMEL_FOLDER_VTRASH (1<<7)
74 /* a shared folder i'm accessing */
75 #define CAMEL_FOLDER_SHARED_TO_ME (1<<8)
76 /* a folder that i'm sharing */
77 #define CAMEL_FOLDER_SHARED_BY_ME (1<<9)
79 /* use 3 bits as a hint for a folder type */
80 #define CAMEL_FOLDER_TYPE_MASK (7 << 10)
81 #define CAMEL_FOLDER_TYPE_BIT (10)
83 #define CAMEL_FOLDER_TYPE_NORMAL (0 << 10)
85 #define CAMEL_FOLDER_TYPE_INBOX (1 << 10)
86 /* an outbox folder */
87 #define CAMEL_FOLDER_TYPE_OUTBOX (2 << 10)
88 /* a rubbish folder */
89 #define CAMEL_FOLDER_TYPE_TRASH (3 << 10)
91 #define CAMEL_FOLDER_TYPE_JUNK (4 << 10)
92 /* a sent-items folder */
93 #define CAMEL_FOLDER_TYPE_SENT (5 << 10)
95 /* next bit is 1<<13 */
97 /* store premissions */
98 #define CAMEL_STORE_READ (1 << 0)
99 #define CAMEL_STORE_WRITE (1 << 1)
101 /* Structure of rename event's event_data */
102 typedef struct _CamelRenameInfo {
104 struct _CamelFolderInfo *new;
107 #define CAMEL_STORE_TYPE (camel_store_get_type ())
108 #define CAMEL_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STORE_TYPE, CamelStore))
109 #define CAMEL_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STORE_TYPE, CamelStoreClass))
110 #define CAMEL_IS_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_STORE_TYPE))
112 /* Flags for store flags */
113 #define CAMEL_STORE_SUBSCRIPTIONS (1 << 0)
114 #define CAMEL_STORE_VTRASH (1 << 1)
115 #define CAMEL_STORE_FILTER_INBOX (1 << 2)
116 #define CAMEL_STORE_VJUNK (1 << 3)
117 #define CAMEL_STORE_PROXY (1 << 4)
120 CamelService parent_object;
121 struct _CamelStorePrivate *priv;
123 CamelObjectBag *folders;
129 /* open mode for folder */
130 #define CAMEL_STORE_FOLDER_CREATE (1<<0)
131 #define CAMEL_STORE_FOLDER_EXCL (1<<1)
132 #define CAMEL_STORE_FOLDER_BODY_INDEX (1<<2)
133 #define CAMEL_STORE_FOLDER_PRIVATE (1<<3) /* a private folder, that shouldn't show up in unmatched/folder info's, etc */
135 #define CAMEL_STORE_FOLDER_CREATE_EXCL (CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_FOLDER_EXCL)
137 #define CAMEL_STORE_FOLDER_INFO_FAST (1 << 0)
138 #define CAMEL_STORE_FOLDER_INFO_RECURSIVE (1 << 1)
139 #define CAMEL_STORE_FOLDER_INFO_SUBSCRIBED (1 << 2)
140 #define CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL (1 << 3) /* don't include vTrash/vJunk folders */
143 CamelServiceClass parent_class;
145 GHashFunc hash_folder_name;
146 GCompareFunc compare_folder_name;
148 CamelFolder * (*get_folder) (CamelStore *store,
149 const char *folder_name,
153 CamelFolder * (*get_inbox) (CamelStore *store, CamelException *ex);
154 CamelFolder * (*get_trash) (CamelStore *store, CamelException *ex);
155 CamelFolder * (*get_junk) (CamelStore *store, CamelException *ex);
157 CamelFolderInfo *(*create_folder) (CamelStore *store,
158 const char *parent_name,
159 const char *folder_name,
161 void (*delete_folder) (CamelStore *store,
162 const char *folder_name,
164 void (*rename_folder) (CamelStore *store,
165 const char *old_name,
166 const char *new_name,
169 void (*sync) (CamelStore *store, int expunge, CamelException *ex);
171 CamelFolderInfo *(*get_folder_info) (CamelStore *store,
175 void (*free_folder_info) (CamelStore *store,
176 CamelFolderInfo *fi);
178 gboolean (*folder_subscribed) (CamelStore *store,
179 const char *folder_name);
180 void (*subscribe_folder) (CamelStore *store,
181 const char *folder_name,
183 void (*unsubscribe_folder) (CamelStore *store,
184 const char *folder_name,
186 void (*noop) (CamelStore *store,
190 /* Standard Camel function */
191 CamelType camel_store_get_type (void);
194 CamelFolder * camel_store_get_folder (CamelStore *store,
195 const char *folder_name,
198 CamelFolder * camel_store_get_inbox (CamelStore *store,
200 CamelFolder * camel_store_get_trash (CamelStore *store,
202 CamelFolder * camel_store_get_junk (CamelStore *store,
205 CamelFolderInfo *camel_store_create_folder (CamelStore *store,
206 const char *parent_name,
207 const char *folder_name,
209 void camel_store_delete_folder (CamelStore *store,
210 const char *folder_name,
212 void camel_store_rename_folder (CamelStore *store,
213 const char *old_name,
214 const char *new_name,
217 void camel_store_sync (CamelStore *store, int expunge, CamelException *ex);
219 CamelFolderInfo *camel_store_get_folder_info (CamelStore *store,
223 void camel_store_free_folder_info (CamelStore *store,
224 CamelFolderInfo *fi);
226 void camel_store_free_folder_info_full (CamelStore *store,
227 CamelFolderInfo *fi);
228 void camel_store_free_folder_info_nop (CamelStore *store,
229 CamelFolderInfo *fi);
231 void camel_folder_info_free (CamelFolderInfo *fi);
232 CamelFolderInfo *camel_folder_info_build (GPtrArray *folders,
233 const char *namespace,
235 gboolean short_names);
236 CamelFolderInfo *camel_folder_info_clone (CamelFolderInfo *fi);
238 gboolean camel_store_supports_subscriptions (CamelStore *store);
240 gboolean camel_store_folder_subscribed (CamelStore *store,
241 const char *folder_name);
242 void camel_store_subscribe_folder (CamelStore *store,
243 const char *folder_name,
245 void camel_store_unsubscribe_folder (CamelStore *store,
246 const char *folder_name,
249 void camel_store_noop (CamelStore *store,
252 int camel_store_folder_uri_equal (CamelStore *store,
256 typedef struct _CamelISubscribe CamelISubscribe;
257 struct _CamelISubscribe {
258 CamelInterface iface;
260 gboolean (*subscribed)(CamelStore *store, const char *folder_name);
261 void (*subscribe)(CamelStore *store, const char *folder_name, CamelException *ex);
262 void (*unsubscribe)(CamelStore *store, const char *folder_name, CamelException *ex);
265 CamelType camel_isubscribe_get_type (void);
266 gboolean camel_isubscribe_subscribed(CamelStore *store, const char *name);
267 void camel_isubscribe_subscribe(CamelStore *store, const char *folder_name, CamelException *ex);
268 void camel_isubscribe_unsubscribe(CamelStore *store, const char *folder_name, CamelException *ex);
272 #endif /* CAMEL_STORE_H */