2 * camel-imapx-command.h
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
19 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
20 #error "Only <camel/camel.h> can be included directly."
23 #ifndef CAMEL_IMAPX_COMMAND_H
24 #define CAMEL_IMAPX_COMMAND_H
26 #include "camel-imapx-utils.h"
28 #define CAMEL_IS_IMAPX_COMMAND(command) \
29 (camel_imapx_command_check (command))
33 /* Avoid a circular reference. */
34 struct _CamelIMAPXJob;
35 struct _CamelIMAPXServer;
37 typedef struct _CamelIMAPXCommand CamelIMAPXCommand;
38 typedef struct _CamelIMAPXCommandPart CamelIMAPXCommandPart;
41 (*CamelIMAPXCommandFunc) (struct _CamelIMAPXServer *is,
42 CamelIMAPXCommand *ic,
46 CAMEL_IMAPX_COMMAND_SIMPLE = 0,
47 CAMEL_IMAPX_COMMAND_DATAWRAPPER,
48 CAMEL_IMAPX_COMMAND_STREAM,
49 CAMEL_IMAPX_COMMAND_AUTH,
50 CAMEL_IMAPX_COMMAND_FILE,
51 CAMEL_IMAPX_COMMAND_STRING,
52 CAMEL_IMAPX_COMMAND_MASK = 0xff,
54 /* Continuation with LITERAL+ */
55 CAMEL_IMAPX_COMMAND_LITERAL_PLUS = 1 << 14,
57 /* Does this command expect continuation? */
58 CAMEL_IMAPX_COMMAND_CONTINUATION = 1 << 15
60 } CamelIMAPXCommandPartType;
62 struct _CamelIMAPXCommandPart {
66 CamelIMAPXCommandPartType type;
72 struct _CamelIMAPXCommand {
73 struct _CamelIMAPXServer *is;
76 /* Command name/type (e.g. FETCH) */
79 /* Folder to select */
82 /* Status for command, indicates it is complete if != NULL. */
83 struct _status_info *status;
90 /* Responsible for free'ing the command. */
91 CamelIMAPXCommandFunc complete;
95 camel_imapx_command_new (struct _CamelIMAPXServer *is,
101 camel_imapx_command_ref (CamelIMAPXCommand *ic);
102 void camel_imapx_command_unref (CamelIMAPXCommand *ic);
103 gboolean camel_imapx_command_check (CamelIMAPXCommand *ic);
104 gint camel_imapx_command_compare (CamelIMAPXCommand *ic1,
105 CamelIMAPXCommand *ic2);
106 struct _CamelIMAPXJob *
107 camel_imapx_command_get_job (CamelIMAPXCommand *ic);
108 void camel_imapx_command_set_job (CamelIMAPXCommand *ic,
109 struct _CamelIMAPXJob *job);
110 void camel_imapx_command_add (CamelIMAPXCommand *ic,
113 void camel_imapx_command_addv (CamelIMAPXCommand *ic,
116 void camel_imapx_command_add_part (CamelIMAPXCommand *ic,
117 CamelIMAPXCommandPartType type,
119 void camel_imapx_command_close (CamelIMAPXCommand *ic);
120 void camel_imapx_command_wait (CamelIMAPXCommand *ic);
121 void camel_imapx_command_done (CamelIMAPXCommand *ic);
122 gboolean camel_imapx_command_set_error_if_failed
123 (CamelIMAPXCommand *ic,
126 /* These are simple GQueue wrappers for CamelIMAPXCommands.
127 * They help make sure reference counting is done properly.
128 * Add more wrappers as needed, don't circumvent them. */
130 typedef struct _CamelIMAPXCommandQueue CamelIMAPXCommandQueue;
132 CamelIMAPXCommandQueue *
133 camel_imapx_command_queue_new (void);
134 void camel_imapx_command_queue_free (CamelIMAPXCommandQueue *queue);
135 void camel_imapx_command_queue_transfer
136 (CamelIMAPXCommandQueue *from,
137 CamelIMAPXCommandQueue *to);
138 void camel_imapx_command_queue_push_tail
139 (CamelIMAPXCommandQueue *queue,
140 CamelIMAPXCommand *ic);
141 void camel_imapx_command_queue_insert_sorted
142 (CamelIMAPXCommandQueue *queue,
143 CamelIMAPXCommand *ic);
144 gboolean camel_imapx_command_queue_is_empty
145 (CamelIMAPXCommandQueue *queue);
146 guint camel_imapx_command_queue_get_length
147 (CamelIMAPXCommandQueue *queue);
149 camel_imapx_command_queue_peek_head
150 (CamelIMAPXCommandQueue *queue);
151 GList * camel_imapx_command_queue_peek_head_link
152 (CamelIMAPXCommandQueue *queue);
153 gboolean camel_imapx_command_queue_remove
154 (CamelIMAPXCommandQueue *queue,
155 CamelIMAPXCommand *ic);
156 void camel_imapx_command_queue_delete_link
157 (CamelIMAPXCommandQueue *queue,
162 #endif /* CAMEL_IMAPX_COMMAND_H */