1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Camel
* Copyright (C) 1999-2004 Jeffrey Stedfast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#ifndef __CAMEL_IMAP4_ENGINE_H__
#define __CAMEL_IMAP4_ENGINE_H__
#include <stdarg.h>
#include <glib.h>
#include <e-util/e-msgport.h>
#include <camel/camel-stream.h>
#include <camel/camel-folder.h>
#include <camel/camel-session.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define CAMEL_TYPE_IMAP4_ENGINE (camel_imap4_engine_get_type ())
#define CAMEL_IMAP4_ENGINE(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP4_ENGINE, CamelIMAP4Engine))
#define CAMEL_IMAP4_ENGINE_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP4_ENGINE, CamelIMAP4EngineClass))
#define CAMEL_IS_IMAP4_ENGINE(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP4_ENGINE))
#define CAMEL_IS_IMAP4_ENGINE_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP4_ENGINE))
#define CAMEL_IMAP4_ENGINE_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP4_ENGINE, CamelIMAP4EngineClass))
typedef struct _CamelIMAP4Engine CamelIMAP4Engine;
typedef struct _CamelIMAP4EngineClass CamelIMAP4EngineClass;
struct _camel_imap4_token_t;
struct _CamelIMAP4Command;
struct _CamelIMAP4Folder;
struct _CamelIMAP4Stream;
typedef enum {
CAMEL_IMAP4_ENGINE_DISCONNECTED,
CAMEL_IMAP4_ENGINE_CONNECTED,
CAMEL_IMAP4_ENGINE_PREAUTH,
CAMEL_IMAP4_ENGINE_AUTHENTICATED,
CAMEL_IMAP4_ENGINE_SELECTED,
} camel_imap4_engine_t;
typedef enum {
CAMEL_IMAP4_LEVEL_UNKNOWN,
CAMEL_IMAP4_LEVEL_IMAP44,
CAMEL_IMAP4_LEVEL_IMAP44REV1
} camel_imap4_level_t;
enum {
CAMEL_IMAP4_CAPABILITY_IMAP44 = (1 << 0),
CAMEL_IMAP4_CAPABILITY_IMAP44REV1 = (1 << 1),
CAMEL_IMAP4_CAPABILITY_STATUS = (1 << 2),
CAMEL_IMAP4_CAPABILITY_NAMESPACE = (1 << 3),
CAMEL_IMAP4_CAPABILITY_UIDPLUS = (1 << 4),
CAMEL_IMAP4_CAPABILITY_LITERALPLUS = (1 << 5),
CAMEL_IMAP4_CAPABILITY_LOGINDISABLED = (1 << 6),
CAMEL_IMAP4_CAPABILITY_STARTTLS = (1 << 7),
CAMEL_IMAP4_CAPABILITY_useful_lsub = (1 << 8),
CAMEL_IMAP4_CAPABILITY_utf8_search = (1 << 9),
};
typedef enum {
CAMEL_IMAP4_RESP_CODE_ALERT,
CAMEL_IMAP4_RESP_CODE_BADCHARSET,
CAMEL_IMAP4_RESP_CODE_CAPABILITY,
CAMEL_IMAP4_RESP_CODE_PARSE,
CAMEL_IMAP4_RESP_CODE_PERM_FLAGS,
CAMEL_IMAP4_RESP_CODE_READONLY,
CAMEL_IMAP4_RESP_CODE_READWRITE,
CAMEL_IMAP4_RESP_CODE_TRYCREATE,
CAMEL_IMAP4_RESP_CODE_UIDNEXT,
CAMEL_IMAP4_RESP_CODE_UIDVALIDITY,
CAMEL_IMAP4_RESP_CODE_UNSEEN,
CAMEL_IMAP4_RESP_CODE_NEWNAME,
CAMEL_IMAP4_RESP_CODE_APPENDUID,
CAMEL_IMAP4_RESP_CODE_COPYUID,
CAMEL_IMAP4_RESP_CODE_UNKNOWN,
} camel_imap4_resp_code_t;
typedef struct _CamelIMAP4RespCode {
camel_imap4_resp_code_t code;
union {
guint32 flags;
char *parse;
guint32 uidnext;
guint32 uidvalidity;
guint32 unseen;
char *newname[2];
struct {
guint32 uidvalidity;
guint32 uid;
} appenduid;
struct {
guint32 uidvalidity;
char *srcset;
char *destset;
} copyuid;
} v;
} CamelIMAP4RespCode;
enum {
CAMEL_IMAP4_UNTAGGED_ERROR = -1,
CAMEL_IMAP4_UNTAGGED_OK,
CAMEL_IMAP4_UNTAGGED_NO,
CAMEL_IMAP4_UNTAGGED_BAD,
CAMEL_IMAP4_UNTAGGED_PREAUTH,
CAMEL_IMAP4_UNTAGGED_HANDLED,
};
typedef struct _CamelIMAP4Namespace {
struct _CamelIMAP4Namespace *next;
char *path;
char sep;
} CamelIMAP4Namespace;
typedef struct _CamelIMAP4NamespaceList {
CamelIMAP4Namespace *personal;
CamelIMAP4Namespace *other;
CamelIMAP4Namespace *shared;
} CamelIMAP4NamespaceList;
enum {
CAMEL_IMAP4_ENGINE_MAXLEN_LINE,
CAMEL_IMAP4_ENGINE_MAXLEN_TOKEN
};
struct _CamelIMAP4Engine {
CamelObject parent_object;
CamelSession *session;
CamelURL *url;
camel_imap4_engine_t state;
camel_imap4_level_t level;
guint32 capa;
guint32 maxlen:31;
guint32 maxlentype:1;
CamelIMAP4NamespaceList namespaces;
GHashTable *authtypes; /* supported authtypes */
struct _CamelIMAP4Stream *istream;
CamelStream *ostream;
unsigned char tagprefix; /* 'A'..'Z' */
unsigned int tag; /* next command tag */
int nextid;
struct _CamelIMAP4Folder *folder; /* currently selected folder */
EDList queue; /* queue of waiting commands */
struct _CamelIMAP4Command *current;
};
struct _CamelIMAP4EngineClass {
CamelObjectClass parent_class;
unsigned char tagprefix;
};
CamelType camel_imap4_engine_get_type (void);
CamelIMAP4Engine *camel_imap4_engine_new (CamelSession *session, CamelURL *url);
/* returns 0 on success or -1 on error */
int camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, CamelException *ex);
int camel_imap4_engine_capability (CamelIMAP4Engine *engine, CamelException *ex);
int camel_imap4_engine_namespace (CamelIMAP4Engine *engine, CamelException *ex);
int camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, CamelException *ex);
struct _CamelIMAP4Command *camel_imap4_engine_queue (CamelIMAP4Engine *engine, CamelFolder *folder,
const char *format, ...);
void camel_imap4_engine_prequeue (CamelIMAP4Engine *engine, struct _CamelIMAP4Command *ic);
void camel_imap4_engine_dequeue (CamelIMAP4Engine *engine, struct _CamelIMAP4Command *ic);
int camel_imap4_engine_iterate (CamelIMAP4Engine *engine);
/* untagged response utility functions */
int camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, CamelException *ex);
void camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, CamelException *ex);
/* stream wrapper utility functions */
int camel_imap4_engine_next_token (CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token, CamelException *ex);
int camel_imap4_engine_line (CamelIMAP4Engine *engine, unsigned char **line, size_t *len, CamelException *ex);
int camel_imap4_engine_literal (CamelIMAP4Engine *engine, unsigned char **literal, size_t *len, CamelException *ex);
int camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, CamelException *ex);
/* response code stuff */
int camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, CamelException *ex);
void camel_imap4_resp_code_free (CamelIMAP4RespCode *rcode);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CAMEL_IMAP4_ENGINE_H__ */
|