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 * 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.
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.
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.
20 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
21 #error "Only <camel/camel.h> can be included directly."
25 #ifndef CAMEL_IMAPX_SERVER_H
26 #define CAMEL_IMAPX_SERVER_H
28 #include <camel/camel-session.h>
29 #include <camel/camel-store.h>
31 #include "camel-imapx-command.h"
32 #include "camel-imapx-stream.h"
33 #include "camel-imapx-store-summary.h"
35 /* Standard GObject macros */
36 #define CAMEL_TYPE_IMAPX_SERVER \
37 (camel_imapx_server_get_type ())
38 #define CAMEL_IMAPX_SERVER(obj) \
39 (G_TYPE_CHECK_INSTANCE_CAST \
40 ((obj), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServer))
41 #define CAMEL_IMAPX_SERVER_CLASS(cls) \
42 (G_TYPE_CHECK_CLASS_CAST \
43 ((cls), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServerClass))
44 #define CAMEL_IS_IMAPX_SERVER(obj) \
45 (G_TYPE_CHECK_INSTANCE_TYPE \
46 ((obj), CAMEL_TYPE_IMAPX_SERVER))
47 #define CAMEL_IS_IMAPX_SERVER_CLASS(cls) \
48 (G_TYPE_CHECK_CLASS_TYPE \
49 ((cls), CAMEL_TYPE_IMAPX_SERVER))
50 #define CAMEL_IMAPX_SERVER_GET_CLASS(obj) \
51 (G_TYPE_INSTANCE_GET_CLASS \
52 ((obj), CAMEL_TYPE_IMAPX_SERVER, CamelIMAPXServerClass))
54 #define IMAPX_MODE_READ (1 << 0)
55 #define IMAPX_MODE_WRITE (1 << 1)
59 typedef struct _CamelIMAPXServer CamelIMAPXServer;
60 typedef struct _CamelIMAPXServerClass CamelIMAPXServerClass;
62 typedef struct _CamelIMAPXIdle CamelIMAPXIdle;
63 struct _IMAPXJobQueueInfo;
65 struct _CamelIMAPXServer {
69 CamelSession *session;
71 /* Info about the current connection */
72 CamelIMAPXStream *stream;
73 struct _capability_info *cinfo;
74 gboolean is_process_stream;
76 CamelIMAPXNamespaceList *nsl;
81 /* in micro seconds */
87 /* Current command/work queue. All commands are stored in one list,
88 * all the time, so they can be cleaned up in exception cases */
89 GStaticRecMutex queue_lock;
90 CamelIMAPXCommand *literal;
91 CamelIMAPXCommandQueue *queue;
92 CamelIMAPXCommandQueue *active;
93 CamelIMAPXCommandQueue *done;
95 /* info on currently selected folder */
96 CamelFolder *select_folder;
97 CamelFolderChangeInfo *changes;
98 CamelFolder *select_pending;
99 guint32 permanentflags;
102 guint64 highestmodseq;
108 /* any expunges that happened from the last command, they are
109 * processed after the command completes. */
112 GThread *parser_thread;
113 /* Protects the output stream between parser thread (which can disconnect from server) and other threads that issue
114 * commands. Input stream does not require a lock since only parser_thread can operate on it */
115 GStaticRecMutex ostream_lock;
116 /* Used for canceling operations as well as signaling parser thread to disconnnect/quit */
117 GCancellable *cancellable;
118 gboolean parser_quit;
121 CamelIMAPXIdle *idle;
124 gboolean use_qresync;
126 /* used to synchronize duplicate get_message requests */
132 struct _CamelIMAPXServerClass {
133 CamelObjectClass parent_class;
136 void (*select_changed) (CamelIMAPXServer *is,
137 const gchar *selected_folder);
138 void (*shutdown) (CamelIMAPXServer *is);
143 GType camel_imapx_server_get_type (void);
145 camel_imapx_server_new (CamelStore *store);
146 gboolean camel_imapx_server_connect (CamelIMAPXServer *is,
147 GCancellable *cancellable,
149 gboolean imapx_connect_to_server (CamelIMAPXServer *is,
150 GCancellable *cancellable,
152 CamelAuthenticationResult
153 camel_imapx_server_authenticate (CamelIMAPXServer *is,
154 const gchar *mechanism,
155 GCancellable *cancellable,
157 GPtrArray * camel_imapx_server_list (CamelIMAPXServer *is,
161 GCancellable *cancellable,
163 gboolean camel_imapx_server_refresh_info (CamelIMAPXServer *is,
165 GCancellable *cancellable,
167 gboolean camel_imapx_server_sync_changes (CamelIMAPXServer *is,
169 GCancellable *cancellable,
171 gboolean camel_imapx_server_expunge (CamelIMAPXServer *is,
173 GCancellable *cancellable,
175 gboolean camel_imapx_server_fetch_messages
176 (CamelIMAPXServer *is,
180 GCancellable *cancellable,
182 gboolean camel_imapx_server_noop (CamelIMAPXServer *is,
184 GCancellable *cancellable,
186 CamelStream * camel_imapx_server_get_message (CamelIMAPXServer *is,
189 GCancellable *cancellable,
191 gboolean camel_imapx_server_copy_message (CamelIMAPXServer *is,
195 gboolean delete_originals,
196 GCancellable *cancellable,
198 gboolean camel_imapx_server_append_message
199 (CamelIMAPXServer *is,
201 CamelMimeMessage *message,
202 const CamelMessageInfo *mi,
204 GCancellable *cancellable,
206 gboolean camel_imapx_server_sync_message (CamelIMAPXServer *is,
209 GCancellable *cancellable,
211 gboolean camel_imapx_server_manage_subscription
212 (CamelIMAPXServer *is,
213 const gchar *folder_name,
215 GCancellable *cancellable,
217 gboolean camel_imapx_server_create_folder
218 (CamelIMAPXServer *is,
219 const gchar *folder_name,
220 GCancellable *cancellable,
222 gboolean camel_imapx_server_delete_folder
223 (CamelIMAPXServer *is,
224 const gchar *folder_name,
225 GCancellable *cancellable,
227 gboolean camel_imapx_server_rename_folder
228 (CamelIMAPXServer *is,
229 const gchar *old_name,
230 const gchar *new_name,
231 GCancellable *cancellable,
233 struct _IMAPXJobQueueInfo *
234 camel_imapx_server_get_job_queue_info
235 (CamelIMAPXServer *is);
239 #endif /* CAMEL_IMAPX_SERVER_H */