Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[platform/upstream/evolution-data-server.git] / camel / camel-imapx-server.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU Lesser General Public
7  * License as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
21 #error "Only <camel/camel.h> can be included directly."
22 #endif
23
24 #ifndef CAMEL_IMAPX_SERVER_H
25 #define CAMEL_IMAPX_SERVER_H
26
27 #include <camel/camel-session.h>
28 #include <camel/camel-store.h>
29
30 #include "camel-imapx-command.h"
31 #include "camel-imapx-stream.h"
32 #include "camel-imapx-store-summary.h"
33
34 /* Standard GObject macros */
35 #define CAMEL_TYPE_IMAPX_SERVER \
36         (camel_imapx_server_get_type ())
37 #define CAMEL_IMAPX_SERVER(obj) \
38         (G_TYPE_CHECK_INSTANCE_CAST \
39         ((obj), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServer))
40 #define CAMEL_IMAPX_SERVER_CLASS(cls) \
41         (G_TYPE_CHECK_CLASS_CAST \
42         ((cls), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServerClass))
43 #define CAMEL_IS_IMAPX_SERVER(obj) \
44         (G_TYPE_CHECK_INSTANCE_TYPE \
45         ((obj), CAMEL_TYPE_IMAPX_SERVER))
46 #define CAMEL_IS_IMAPX_SERVER_CLASS(cls) \
47         (G_TYPE_CHECK_CLASS_TYPE \
48         ((cls), CAMEL_TYPE_IMAPX_SERVER))
49 #define CAMEL_IMAPX_SERVER_GET_CLASS(obj) \
50         (G_TYPE_INSTANCE_GET_CLASS \
51         ((obj), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServerClass))
52
53 #define IMAPX_MODE_READ (1 << 0)
54 #define IMAPX_MODE_WRITE (1 << 1)
55
56 G_BEGIN_DECLS
57
58 /* Avoid a circular reference. */
59 struct _CamelIMAPXStore;
60 struct _CamelIMAPXSettings;
61
62 typedef struct _CamelIMAPXServer CamelIMAPXServer;
63 typedef struct _CamelIMAPXServerClass CamelIMAPXServerClass;
64 typedef struct _CamelIMAPXServerPrivate CamelIMAPXServerPrivate;
65
66 typedef struct _CamelIMAPXIdle CamelIMAPXIdle;
67 struct _IMAPXJobQueueInfo;
68
69 /* untagged response handling */
70 typedef gboolean
71                 (*CamelIMAPXUntaggedRespHandler)
72                                                 (CamelIMAPXServer *server,
73                                                  CamelIMAPXStream *stream,
74                                                  GCancellable *cancellable,
75                                                  GError **error);
76
77 /**
78  * CamelIMAPXUntaggedRespHandlerDesc:
79  * @untagged_response: a string representation of the IMAP
80  *                     untagged response code. Must be
81  *                     all-uppercase with underscores allowed
82  *                     (see RFC 3501)
83  * @handler: an untagged response handler function for #CamelIMAPXServer
84  * @next_response: the IMAP untagged code to call a registered
85  *                 handler for directly after successfully
86  *                 running @handler. If not NULL, @skip_stream_when_done
87  *                 for the current handler has no effect
88  * @skip_stream_when_done: whether or not to skip the current IMAP
89  *                         untagged response in the #CamelIMAPXStream.
90  *                         Set to TRUE if your handler does not eat
91  *                         the stream up to the next response token
92  *
93  * IMAP untagged response handler function descriptor. Use in conjunction
94  * with camel_imapx_server_register_untagged_handler() to register a new
95  * handler function for a given untagged response code
96  *
97  * Since: 3.6
98  */
99 typedef struct _CamelIMAPXUntaggedRespHandlerDesc CamelIMAPXUntaggedRespHandlerDesc;
100 struct _CamelIMAPXUntaggedRespHandlerDesc {
101         const gchar *untagged_response;
102         const CamelIMAPXUntaggedRespHandler handler;
103         const gchar *next_response;
104         gboolean skip_stream_when_done;
105 };
106
107 struct _CamelIMAPXServer {
108         CamelObject parent;
109         CamelIMAPXServerPrivate *priv;
110
111         /* Info about the current connection */
112         struct _capability_info *cinfo;
113         gboolean is_process_stream;
114
115         CamelIMAPXNamespaceList *nsl;
116
117         /* incoming jobs */
118         GQueue jobs;
119
120         /* in micro seconds */
121         guint job_timeout;
122
123         gchar tagprefix;
124         gint state : 4;
125
126         /* Current command/work queue.  All commands are stored in one list,
127          * all the time, so they can be cleaned up in exception cases */
128         GRecMutex queue_lock;
129         CamelIMAPXCommand *literal;
130         CamelIMAPXCommandQueue *queue;
131         CamelIMAPXCommandQueue *active;
132         CamelIMAPXCommandQueue *done;
133
134         /* info on currently selected folder */
135         CamelFolder *select_folder;
136         CamelFolderChangeInfo *changes;
137         CamelFolder *select_pending;
138         guint32 permanentflags;
139         guint32 unseen;
140         guint64 uidvalidity;
141         guint64 highestmodseq;
142         guint32 uidnext;
143         guint32 exists;
144         guint32 recent;
145         guint32 mode;
146
147         /* any expunges that happened from the last command, they are
148          * processed after the command completes. */
149         GList *expunged;
150
151         GThread *parser_thread;
152         /* Used for canceling operations as well as signaling parser thread to disconnnect/quit */
153         GCancellable *cancellable;
154         gboolean parser_quit;
155
156         /* Idle */
157         CamelIMAPXIdle *idle;
158         gboolean use_idle;
159
160         gboolean use_qresync;
161
162         /* used to synchronize duplicate get_message requests */
163         GCond fetch_cond;
164         GMutex fetch_mutex;
165         gint fetch_count;
166 };
167
168 struct _CamelIMAPXServerClass {
169         CamelObjectClass parent_class;
170
171         /* Signals */
172         void    (*select_changed)       (CamelIMAPXServer *is,
173                                          const gchar *selected_folder);
174         void    (*shutdown)             (CamelIMAPXServer *is);
175
176         gchar tagprefix;
177 };
178
179 GType           camel_imapx_server_get_type     (void);
180 CamelIMAPXServer *
181                 camel_imapx_server_new          (struct _CamelIMAPXStore *store);
182 struct _CamelIMAPXStore *
183                 camel_imapx_server_ref_store    (CamelIMAPXServer *is);
184 struct _CamelIMAPXSettings *
185                 camel_imapx_server_ref_settings (CamelIMAPXServer *is);
186 CamelIMAPXStream *
187                 camel_imapx_server_ref_stream   (CamelIMAPXServer *is);
188 gboolean        camel_imapx_server_connect      (CamelIMAPXServer *is,
189                                                  GCancellable *cancellable,
190                                                  GError **error);
191 gboolean        imapx_connect_to_server         (CamelIMAPXServer *is,
192                                                  GCancellable *cancellable,
193                                                  GError **error);
194 CamelAuthenticationResult
195                 camel_imapx_server_authenticate (CamelIMAPXServer *is,
196                                                  const gchar *mechanism,
197                                                  GCancellable *cancellable,
198                                                  GError **error);
199 GPtrArray *     camel_imapx_server_list         (CamelIMAPXServer *is,
200                                                  const gchar *top,
201                                                  guint32 flags,
202                                                  const gchar *ext,
203                                                  GCancellable *cancellable,
204                                                  GError **error);
205 gboolean        camel_imapx_server_refresh_info (CamelIMAPXServer *is,
206                                                  CamelFolder *folder,
207                                                  GCancellable *cancellable,
208                                                  GError **error);
209 gboolean        camel_imapx_server_sync_changes (CamelIMAPXServer *is,
210                                                  CamelFolder *folder,
211                                                  GCancellable *cancellable,
212                                                  GError **error);
213 gboolean        camel_imapx_server_expunge      (CamelIMAPXServer *is,
214                                                  CamelFolder *folder,
215                                                  GCancellable *cancellable,
216                                                  GError **error);
217 gboolean        camel_imapx_server_fetch_messages
218                                                 (CamelIMAPXServer *is,
219                                                  CamelFolder *folder,
220                                                  CamelFetchType type,
221                                                  gint limit,
222                                                  GCancellable *cancellable,
223                                                  GError **error);
224 gboolean        camel_imapx_server_noop         (CamelIMAPXServer *is,
225                                                  CamelFolder *folder,
226                                                  GCancellable *cancellable,
227                                                  GError **error);
228 CamelStream *   camel_imapx_server_get_message  (CamelIMAPXServer *is,
229                                                  CamelFolder *folder,
230                                                  const gchar *uid,
231                                                  GCancellable *cancellable,
232                                                  GError **error);
233 gboolean        camel_imapx_server_copy_message (CamelIMAPXServer *is,
234                                                  CamelFolder *source,
235                                                  CamelFolder *dest,
236                                                  GPtrArray *uids,
237                                                  gboolean delete_originals,
238                                                  GCancellable *cancellable,
239                                                  GError **error);
240 gboolean        camel_imapx_server_append_message
241                                                 (CamelIMAPXServer *is,
242                                                  CamelFolder *folder,
243                                                  CamelMimeMessage *message,
244                                                  const CamelMessageInfo *mi,
245                                                  gchar **append_uid,
246                                                  GCancellable *cancellable,
247                                                  GError **error);
248 gboolean        camel_imapx_server_sync_message (CamelIMAPXServer *is,
249                                                  CamelFolder *folder,
250                                                  const gchar *uid,
251                                                  GCancellable *cancellable,
252                                                  GError **error);
253 gboolean        camel_imapx_server_manage_subscription
254                                                 (CamelIMAPXServer *is,
255                                                  const gchar *folder_name,
256                                                  gboolean subscribe,
257                                                  GCancellable *cancellable,
258                                                  GError **error);
259 gboolean        camel_imapx_server_create_folder
260                                                 (CamelIMAPXServer *is,
261                                                  const gchar *folder_name,
262                                                  GCancellable *cancellable,
263                                                  GError **error);
264 gboolean        camel_imapx_server_delete_folder
265                                                 (CamelIMAPXServer *is,
266                                                  const gchar *folder_name,
267                                                  GCancellable *cancellable,
268                                                  GError **error);
269 gboolean        camel_imapx_server_rename_folder
270                                                 (CamelIMAPXServer *is,
271                                                  const gchar *old_name,
272                                                  const gchar *new_name,
273                                                  GCancellable *cancellable,
274                                                  GError **error);
275 struct _IMAPXJobQueueInfo *
276                 camel_imapx_server_get_job_queue_info
277                                                 (CamelIMAPXServer *is);
278 const CamelIMAPXUntaggedRespHandlerDesc *
279                 camel_imapx_server_register_untagged_handler
280                                                 (CamelIMAPXServer *is,
281                                                  const gchar *untagged_response,
282                                                  const CamelIMAPXUntaggedRespHandlerDesc *desc);
283 gboolean        camel_imapx_server_command_run  (CamelIMAPXServer *is,
284                                                  CamelIMAPXCommand *ic,
285                                                  GCancellable *cancellable,
286                                                  GError **error);
287
288 G_END_DECLS
289
290 #endif /* CAMEL_IMAPX_SERVER_H */