~ubuntu-branches/ubuntu/quantal/evolution-data-server/quantal

« back to all changes in this revision

Viewing changes to camel/providers/imapx/camel-imapx-utils.h

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-07-03 22:41:23 UTC
  • mfrom: (1.1.100)
  • Revision ID: package-import@ubuntu.com-20120703224123-90dydkyfyvff8s0s
Tags: 3.5.3.1-0ubuntu1
* New upstream release 3.5.3.1.
* debian/control:
  - Drop libgconf2-dev from Build-Depends.
  - Bump versions for glib, goa, and libsoup in Build-Depends.
  - Add a Build-Depends on libgcr-3-dev (>= 3.4)
  - Rename packages following upstream SONAME changes.
  - Add Depends on libgnome-keyring-dev to libedataserver1.2-dev.
* debian/rules:
  - Update mkshlibs arguments for libcamel-1.2-38 instead of -33; as it was
    renamed in control due to the soname change.
  - Strip out -Bsymbolic-functions from LDFLAGS.
* Renamed install files in debian/:
  - libcamel-1.2-33.install => libcamel-1.2-38.install
  - libebackend-1.2-2.install => libebackend-1.2-4.install
  - libebook-1.2-13.install => libebook-1.2-17.install
  - libecal-1.2-11.install => libecal-1.2-15.install
  - libedata-book-1.2-13.install => libedata-book-1.2-15.install
  - libedata-cal-1.2-15.install => libedata-cal-1.2-18.install
  - libedataserver-1.2-16.install => libedataserver-1.2-17.install
  - libedataserverui-3.0-1.install => libedataserverui-3.0-4.install
* debian/patches/google_tests_fpic.patch: build tests with -fPIC; otherwise
  build fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#ifndef CAMEL_IMAPX_UTILS_H
21
 
#define CAMEL_IMAPX_UTILS_H
22
 
 
23
 
#include <camel/camel.h>
24
 
 
25
 
struct _CamelIMAPXStream;
26
 
struct _CamelFlag;
27
 
struct _CamelIMAPXNamespaceList;
28
 
struct _CamelIMAPXStore;
29
 
 
30
 
/* list of strings we know about that can be *quickly* tokenised */
31
 
typedef enum _camel_imapx_id_t {
32
 
        IMAPX_UNKNOWN = 0,
33
 
        IMAPX_ALERT,
34
 
        IMAPX_APPENDUID,
35
 
        IMAPX_BAD,
36
 
        IMAPX_BODY,
37
 
        IMAPX_BODYSTRUCTURE,
38
 
        IMAPX_BYE,
39
 
        IMAPX_CAPABILITY,
40
 
        IMAPX_CLOSED,
41
 
        IMAPX_COPYUID,
42
 
        IMAPX_ENVELOPE,
43
 
        IMAPX_EXISTS,
44
 
        IMAPX_EXPUNGE,
45
 
        IMAPX_FETCH,
46
 
        IMAPX_FLAGS,
47
 
        IMAPX_HIGHESTMODSEQ,
48
 
        IMAPX_INTERNALDATE,
49
 
        IMAPX_LIST,
50
 
        IMAPX_LSUB,
51
 
        IMAPX_MESSAGES,
52
 
        IMAPX_MODSEQ,
53
 
        IMAPX_NAMESPACE,
54
 
        IMAPX_NEWNAME,
55
 
        IMAPX_NO,
56
 
        IMAPX_NOMODSEQ,
57
 
        IMAPX_OK,
58
 
        IMAPX_PARSE,
59
 
        IMAPX_PERMANENTFLAGS,
60
 
        IMAPX_PREAUTH,
61
 
        IMAPX_READ_ONLY,
62
 
        IMAPX_READ_WRITE,
63
 
        IMAPX_RECENT,
64
 
        IMAPX_RFC822_HEADER,
65
 
        IMAPX_RFC822_SIZE,
66
 
        IMAPX_RFC822_TEXT,
67
 
        IMAPX_STATUS,
68
 
        IMAPX_TRYCREATE,
69
 
        IMAPX_UID,
70
 
        IMAPX_UIDVALIDITY,
71
 
        IMAPX_UNSEEN,
72
 
        IMAPX_UIDNEXT,
73
 
        IMAPX_VANISHED,
74
 
} camel_imapx_id_t;
75
 
 
76
 
/* str MUST be in upper case, tokenised using gperf function */
77
 
camel_imapx_id_t imapx_tokenise (register const gchar *str, register guint len);
78
 
 
79
 
/* this flag should be part of imapfoldersummary */
80
 
enum {
81
 
        CAMEL_IMAPX_MESSAGE_RECENT = (1 << 21),
82
 
};
83
 
 
84
 
/* ********************************************************************** */
85
 
 
86
 
GPtrArray *imapx_parse_uids (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error);
87
 
void imapx_parse_flags (struct _CamelIMAPXStream *stream, guint32 *flagsp, struct _CamelFlag **user_flagsp, GCancellable *cancellable, GError **error);
88
 
void imapx_write_flags (GString *string, guint32 flags, struct _CamelFlag *user_flags);
89
 
gboolean imapx_update_message_info_flags (CamelMessageInfo *info, guint32 server_flags, CamelFlag *server_user_flags, guint32 permanent_flags, CamelFolder *folder, gboolean unsolicited);
90
 
void imapx_set_message_info_flags_for_new_message (CamelMessageInfo *info, guint32 server_flags, CamelFlag *server_user_flags,
91
 
                                                        CamelFolder *folder);
92
 
void imapx_update_store_summary (CamelFolder *folder);
93
 
 
94
 
/* ********************************************************************** */
95
 
enum {
96
 
        IMAPX_CAPABILITY_IMAP4                  = (1 << 0),
97
 
        IMAPX_CAPABILITY_IMAP4REV1              = (1 << 1),
98
 
        IMAPX_CAPABILITY_STATUS                 = (1 << 2),
99
 
        IMAPX_CAPABILITY_NAMESPACE              = (1 << 3),
100
 
        IMAPX_CAPABILITY_UIDPLUS                = (1 << 4),
101
 
        IMAPX_CAPABILITY_LITERALPLUS            = (1 << 5),
102
 
        IMAPX_CAPABILITY_STARTTLS               = (1 << 6),
103
 
        IMAPX_CAPABILITY_IDLE                   = (1 << 7),
104
 
        IMAPX_CAPABILITY_CONDSTORE              = (1 << 8),
105
 
        IMAPX_CAPABILITY_QRESYNC                = (1 << 9),
106
 
        IMAPX_CAPABILITY_LIST_STATUS            = (1 << 10),
107
 
        IMAPX_CAPABILITY_LIST_EXTENDED          = (1 << 11),
108
 
};
109
 
 
110
 
struct _capability_info {
111
 
        guint32 capa;
112
 
        GHashTable *auth_types;
113
 
};
114
 
 
115
 
struct _capability_info *imapx_parse_capability (struct _CamelIMAPXStream *stream, GCancellable *cancellable, GError **error);
116
 
void imapx_free_capability (struct _capability_info *);
117
 
 
118
 
gboolean imapx_parse_param_list (struct _CamelIMAPXStream *is, struct _camel_header_param **plist, GCancellable *cancellable, GError **error) /* IO,PARSE */;
119
 
struct _CamelContentDisposition *imapx_parse_ext_optional (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
120
 
struct _CamelMessageContentInfo *imapx_parse_body_fields (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
121
 
struct _camel_header_address *imapx_parse_address_list (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
122
 
struct _CamelMessageInfo *imapx_parse_envelope (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO, PARSE */;
123
 
struct _CamelMessageContentInfo *imapx_parse_body (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
124
 
gchar *imapx_parse_section (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error) /* IO,PARSE */;
125
 
void imapx_free_body (struct _CamelMessageContentInfo *cinfo);
126
 
 
127
 
/* ********************************************************************** */
128
 
/* all the possible stuff we might get from a fetch request */
129
 
/* this assumes the caller/server doesn't send any one of these types twice */
130
 
struct _fetch_info {
131
 
        guint32 got;            /* what we got, see below */
132
 
        CamelStream *body;      /* BODY[.*](<.*>)? */
133
 
        CamelStream *text;      /* RFC822.TEXT */
134
 
        CamelStream *header;    /* RFC822.HEADER */
135
 
        struct _CamelMessageInfo *minfo; /* ENVELOPE */
136
 
        struct _CamelMessageContentInfo *cinfo; /* BODYSTRUCTURE,BODY */
137
 
        guint32 size;           /* RFC822.SIZE */
138
 
        guint32 offset;         /* start offset of a BODY[]<offset.length> request */
139
 
        guint32 flags;          /* FLAGS */
140
 
        guint64 modseq;         /* MODSEQ */
141
 
        struct _CamelFlag *user_flags;
142
 
        gchar *date;            /* INTERNALDATE */
143
 
        gchar *section;         /* section for a BODY[section] request */
144
 
        gchar *uid;             /* UID */
145
 
};
146
 
 
147
 
#define FETCH_BODY (1 << 0)
148
 
#define FETCH_TEXT (1 << 1)
149
 
#define FETCH_HEADER (1 << 2)
150
 
#define FETCH_MINFO (1 << 3)
151
 
#define FETCH_CINFO (1 << 4)
152
 
#define FETCH_SIZE (1 << 5)
153
 
#define FETCH_OFFSET (1 << 6)
154
 
#define FETCH_FLAGS (1 << 7)
155
 
#define FETCH_DATE (1 << 8)
156
 
#define FETCH_SECTION (1 << 9)
157
 
#define FETCH_UID (1 << 10)
158
 
#define FETCH_MODSEQ (1 << 11)
159
 
 
160
 
struct _fetch_info *imapx_parse_fetch (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error);
161
 
void imapx_free_fetch (struct _fetch_info *finfo);
162
 
void imapx_dump_fetch (struct _fetch_info *finfo);
163
 
 
164
 
/* ********************************************************************** */
165
 
 
166
 
struct _status_info {
167
 
        camel_imapx_id_t result; /* ok/no/bad/preauth only, user_cancel - client response */
168
 
        camel_imapx_id_t condition; /* read-only/read-write/alert/parse/trycreate/newname/permanentflags/uidvalidity/unseen/highestmodseq */
169
 
 
170
 
        union {
171
 
                struct {
172
 
                        gchar *oldname;
173
 
                        gchar *newname;
174
 
                } newname;
175
 
                guint32 permanentflags;
176
 
                guint64 uidvalidity;
177
 
                guint32 uidnext;
178
 
                guint32 unseen;
179
 
                guint64 highestmodseq;
180
 
                struct {
181
 
                        guint64 uidvalidity;
182
 
                        guint32 uid;
183
 
                } appenduid;
184
 
                struct {
185
 
                        guint64 uidvalidity;
186
 
                        GPtrArray *uids;
187
 
                        GPtrArray *copied_uids;
188
 
                } copyuid;
189
 
                struct _capability_info *cinfo;
190
 
        } u;
191
 
 
192
 
        gchar *text;
193
 
};
194
 
 
195
 
struct _status_info *imapx_parse_status (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error);
196
 
struct _status_info *imapx_copy_status (struct _status_info *sinfo);
197
 
void imapx_free_status (struct _status_info *sinfo);
198
 
 
199
 
/* ********************************************************************** */
200
 
/* parses the response from the status command */
201
 
struct _state_info {
202
 
        gchar *name;
203
 
        guint32 messages;
204
 
        guint32 recent;
205
 
        guint32 uidnext;
206
 
        guint32 unseen;
207
 
        guint64 uidvalidity;
208
 
        guint64 highestmodseq;
209
 
};
210
 
 
211
 
/* use g_free to free the return value */
212
 
struct _state_info *imapx_parse_status_info (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error);
213
 
 
214
 
/* ********************************************************************** */
215
 
 
216
 
/* should this just return a FolderInfo?
217
 
 * should this just return the name & flags & separator by reference? */
218
 
struct _list_info {
219
 
        guint32 flags : 24;
220
 
        gchar separator;
221
 
        gchar *name;
222
 
};
223
 
 
224
 
struct _list_info *imapx_parse_list (struct _CamelIMAPXStream *is, GCancellable *cancellable, GError **error);
225
 
gchar *imapx_list_get_path (struct _list_info *li);
226
 
void imapx_free_list (struct _list_info *linfo);
227
 
 
228
 
/* ********************************************************************** */
229
 
typedef struct _IMAPXJobQueueInfo {
230
 
        guint queue_len;
231
 
 
232
 
        /* list of folders for which jobs are in the queue */
233
 
        GHashTable *folders;
234
 
} IMAPXJobQueueInfo;
235
 
 
236
 
void camel_imapx_destroy_job_queue_info (IMAPXJobQueueInfo *jinfo);
237
 
 
238
 
/* ********************************************************************** */
239
 
 
240
 
extern guchar imapx_specials[256];
241
 
 
242
 
#define IMAPX_TYPE_CHAR (1 << 0)
243
 
#define IMAPX_TYPE_TEXT_CHAR (1 << 1)
244
 
#define IMAPX_TYPE_QUOTED_CHAR (1 << 2)
245
 
#define IMAPX_TYPE_ATOM_CHAR (1 << 3)
246
 
#define IMAPX_TYPE_TOKEN_CHAR (1 << 4)
247
 
#define IMAPX_TYPE_NOTID_CHAR (1 << 5)
248
 
 
249
 
guchar imapx_is_mask (const gchar *p);
250
 
 
251
 
#define imapx_is_text_char(c) ((imapx_specials[((unsigned char)(c))&0xff] & IMAPX_TYPE_TEXT_CHAR) != 0)
252
 
#define imapx_is_quoted_char(c) ((imapx_specials[((unsigned char)(c))&0xff] & IMAPX_TYPE_QUOTED_CHAR) != 0)
253
 
#define imapx_is_atom_char(c) ((imapx_specials[((unsigned char)(c))&0xff] & IMAPX_TYPE_ATOM_CHAR) != 0)
254
 
#define imapx_is_token_char(c) ((imapx_specials[((unsigned char)(c))&0xff] & IMAPX_TYPE_TOKEN_CHAR) != 0)
255
 
#define imapx_is_notid_char(c) ((imapx_specials[((unsigned char)(c))&0xff] & IMAPX_TYPE_NOTID_CHAR) != 0)
256
 
 
257
 
#define imapx_is_atom(s) (imapx_is_mask(s) & IMAPX_TYPE_ATOM_CHAR)
258
 
 
259
 
extern gint camel_imapx_debug_flags;
260
 
#define CAMEL_IMAPX_DEBUG_command       (1 << 0)
261
 
#define CAMEL_IMAPX_DEBUG_debug         (1 << 1)
262
 
#define CAMEL_IMAPX_DEBUG_extra         (1 << 2)
263
 
#define CAMEL_IMAPX_DEBUG_io            (1 << 3)
264
 
#define CAMEL_IMAPX_DEBUG_token         (1 << 4)
265
 
#define CAMEL_IMAPX_DEBUG_parse         (1 << 5)
266
 
#define CAMEL_IMAPX_DEBUG_conman        (1 << 6)
267
 
 
268
 
/* Set this to zero to remove all debug output at build time */
269
 
#define CAMEL_IMAPX_DEBUG_ALL           ((1 << 7)-1)
270
 
 
271
 
#define camel_debug_flag(type) (camel_imapx_debug_flags & CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type)
272
 
#define camel_imapx_debug(type, tagprefix, fmt, ...) do {               \
273
 
                if (camel_debug_flag (type))                            \
274
 
                        printf ("[imapx:%c] " fmt, tagprefix , ##__VA_ARGS__); \
275
 
        } while (0)
276
 
 
277
 
/* ********************************************************************** */
278
 
 
279
 
void imapx_utils_init (void);
280
 
 
281
 
/* chen adds from old imap provider - place it in right place */
282
 
gchar *imapx_path_to_physical (const gchar *prefix, const gchar *vpath);
283
 
gchar *imapx_concat (struct _CamelIMAPXStore *imapx_store, const gchar *prefix, const gchar *suffix);
284
 
gchar * imapx_get_temp_uid (void);
285
 
 
286
 
void camel_imapx_namespace_list_clear (struct _CamelIMAPXNamespaceList *nsl);
287
 
struct _CamelIMAPXNamespaceList * imapx_parse_namespace_list (struct _CamelIMAPXStream *stream, GCancellable *cancellable, GError **error);
288
 
struct _CamelIMAPXNamespaceList *camel_imapx_namespace_list_copy (const struct _CamelIMAPXNamespaceList *nsl);
289
 
 
290
 
#endif