Bug #606181 - Accepting bad SSL certificate applies to any hostname
[platform/upstream/evolution-data-server.git] / camel / camel-imapx-command.h
1 /*
2  * camel-imapx-command.h
3  *
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.
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  * Lesser General Public License for more details.
13  *
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/>
16  *
17  */
18
19 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
20 #error "Only <camel/camel.h> can be included directly."
21 #endif
22
23 #ifndef CAMEL_IMAPX_COMMAND_H
24 #define CAMEL_IMAPX_COMMAND_H
25
26 #include "camel-imapx-utils.h"
27
28 #define CAMEL_IS_IMAPX_COMMAND(command) \
29         (camel_imapx_command_check (command))
30
31 G_BEGIN_DECLS
32
33 /* Avoid a circular reference. */
34 struct _CamelIMAPXJob;
35 struct _CamelIMAPXServer;
36
37 typedef struct _CamelIMAPXCommand CamelIMAPXCommand;
38 typedef struct _CamelIMAPXCommandPart CamelIMAPXCommandPart;
39
40 typedef gboolean
41                 (*CamelIMAPXCommandFunc)        (struct _CamelIMAPXServer *is,
42                                                  CamelIMAPXCommand *ic,
43                                                  GError **error);
44
45 typedef enum {
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,
53
54         /* Continuation with LITERAL+ */
55         CAMEL_IMAPX_COMMAND_LITERAL_PLUS = 1 << 14,
56
57         /* Does this command expect continuation? */
58         CAMEL_IMAPX_COMMAND_CONTINUATION = 1 << 15
59
60 } CamelIMAPXCommandPartType;
61
62 struct _CamelIMAPXCommandPart {
63         gint data_size;
64         gchar *data;
65
66         CamelIMAPXCommandPartType type;
67
68         gint ob_size;
69         gpointer ob;
70 };
71
72 struct _CamelIMAPXCommand {
73         struct _CamelIMAPXServer *is;
74         gint pri;
75
76         /* Command name/type (e.g. FETCH) */
77         const gchar *name;
78
79         /* Folder to select */
80         CamelFolder *select;
81
82         /* Status for command, indicates it is complete if != NULL. */
83         struct _status_info *status;
84
85         guint32 tag;
86
87         GQueue parts;
88         GList *current_part;
89
90         /* Responsible for free'ing the command. */
91         CamelIMAPXCommandFunc complete;
92 };
93
94 CamelIMAPXCommand *
95                 camel_imapx_command_new         (struct _CamelIMAPXServer *is,
96                                                  const gchar *name,
97                                                  CamelFolder *select,
98                                                  const gchar *format,
99                                                  ...);
100 CamelIMAPXCommand *
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,
111                                                  const gchar *format,
112                                                  ...);
113 void            camel_imapx_command_addv        (CamelIMAPXCommand *ic,
114                                                  const gchar *format,
115                                                  va_list ap);
116 void            camel_imapx_command_add_part    (CamelIMAPXCommand *ic,
117                                                  CamelIMAPXCommandPartType type,
118                                                  gpointer data);
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,
124                                                  GError **error);
125
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. */
129
130 typedef struct _CamelIMAPXCommandQueue CamelIMAPXCommandQueue;
131
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);
148 CamelIMAPXCommand *
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,
158                                                  GList *link);
159
160 G_END_DECLS
161
162 #endif /* CAMEL_IMAPX_COMMAND_H */
163