/usr/include/evolution-data-server/camel/camel-imapx-utils.h is in libcamel1.2-dev 3.10.4-0ubuntu1.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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 Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
#error "Only <camel/camel.h> can be included directly."
#endif
#ifndef CAMEL_IMAPX_UTILS_H
#define CAMEL_IMAPX_UTILS_H
#include <camel/camel-store.h>
G_BEGIN_DECLS
/* FIXME Split off a camel-imapx-types.h file with supplemental
* enum/struct definitions and helper macros, so we don't
* have these conflicting header dependencies. */
struct _CamelIMAPXCommand;
struct _CamelIMAPXStream;
struct _CamelFlag;
struct _CamelIMAPXNamespaceList;
struct _CamelIMAPXStore;
/* list of strings we know about that can be *quickly* tokenised */
typedef enum _camel_imapx_id_t {
IMAPX_UNKNOWN = 0,
IMAPX_ALERT,
IMAPX_APPENDUID,
IMAPX_BAD,
IMAPX_BODY,
IMAPX_BODYSTRUCTURE,
IMAPX_BYE,
IMAPX_CAPABILITY,
IMAPX_CLOSED,
IMAPX_COPYUID,
IMAPX_ENVELOPE,
IMAPX_EXISTS,
IMAPX_EXPUNGE,
IMAPX_FETCH,
IMAPX_FLAGS,
IMAPX_HIGHESTMODSEQ,
IMAPX_INTERNALDATE,
IMAPX_LIST,
IMAPX_LSUB,
IMAPX_MESSAGES,
IMAPX_MODSEQ,
IMAPX_NAMESPACE,
IMAPX_NEWNAME,
IMAPX_NO,
IMAPX_NOMODSEQ,
IMAPX_OK,
IMAPX_PARSE,
IMAPX_PERMANENTFLAGS,
IMAPX_PREAUTH,
IMAPX_READ_ONLY,
IMAPX_READ_WRITE,
IMAPX_RECENT,
IMAPX_RFC822_HEADER,
IMAPX_RFC822_SIZE,
IMAPX_RFC822_TEXT,
IMAPX_STATUS,
IMAPX_TRYCREATE,
IMAPX_UID,
IMAPX_UIDVALIDITY,
IMAPX_UNSEEN,
IMAPX_UIDNEXT,
IMAPX_VANISHED,
/* RFC 5530: IMAP Response Codes */
IMAPX_ALREADYEXISTS,
IMAPX_AUTHENTICATIONFAILED,
IMAPX_AUTHORIZATIONFAILED,
IMAPX_CANNOT,
IMAPX_CLIENTBUG,
IMAPX_CONTACTADMIN,
IMAPX_CORRUPTION,
IMAPX_EXPIRED,
IMAPX_EXPUNGEISSUED,
IMAPX_INUSE,
IMAPX_LIMIT,
IMAPX_NONEXISTENT,
IMAPX_NOPERM,
IMAPX_OVERQUOTA,
IMAPX_PRIVACYREQUIRED,
IMAPX_SERVERBUG,
IMAPX_UNAVAILABLE
} camel_imapx_id_t;
#define CAMEL_IMAPX_UNTAGGED_BAD "BAD"
#define CAMEL_IMAPX_UNTAGGED_BYE "BYE"
#define CAMEL_IMAPX_UNTAGGED_CAPABILITY "CAPABILITY"
#define CAMEL_IMAPX_UNTAGGED_EXISTS "EXISTS"
#define CAMEL_IMAPX_UNTAGGED_EXPUNGE "EXPUNGE"
#define CAMEL_IMAPX_UNTAGGED_FETCH "FETCH"
#define CAMEL_IMAPX_UNTAGGED_FLAGS "FLAGS"
#define CAMEL_IMAPX_UNTAGGED_LIST "LIST"
#define CAMEL_IMAPX_UNTAGGED_LSUB "LSUB"
#define CAMEL_IMAPX_UNTAGGED_NAMESPACE "NAMESPACE"
#define CAMEL_IMAPX_UNTAGGED_NO "NO"
#define CAMEL_IMAPX_UNTAGGED_OK "OK"
#define CAMEL_IMAPX_UNTAGGED_PREAUTH "PREAUTH"
#define CAMEL_IMAPX_UNTAGGED_QUOTA "QUOTA"
#define CAMEL_IMAPX_UNTAGGED_QUOTAROOT "QUOTAROOT"
#define CAMEL_IMAPX_UNTAGGED_RECENT "RECENT"
#define CAMEL_IMAPX_UNTAGGED_SEARCH "SEARCH"
#define CAMEL_IMAPX_UNTAGGED_STATUS "STATUS"
#define CAMEL_IMAPX_UNTAGGED_VANISHED "VANISHED"
/* str MUST be in upper case, tokenised using gperf function */
camel_imapx_id_t
imapx_tokenise (register const gchar *str,
register guint len);
/* this flag should be part of imapfoldersummary */
enum {
CAMEL_IMAPX_MESSAGE_RECENT = (1 << 21),
};
/* ********************************************************************** */
GPtrArray * imapx_parse_uids (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
gboolean imapx_parse_flags (struct _CamelIMAPXStream *is,
guint32 *flagsp,
struct _CamelFlag **user_flagsp,
GCancellable *cancellable,
GError **error);
void imapx_write_flags (GString *string,
guint32 flags,
struct _CamelFlag *user_flags);
gboolean imapx_update_message_info_flags (CamelMessageInfo *info,
guint32 server_flags,
CamelFlag *server_user_flags,
guint32 permanent_flags,
CamelFolder *folder,
gboolean unsolicited);
void imapx_set_message_info_flags_for_new_message
(CamelMessageInfo *info,
guint32 server_flags,
CamelFlag *server_user_flags,
CamelFolder *folder);
void imapx_update_store_summary (CamelFolder *folder);
gchar * camel_imapx_dup_uid_from_summary_index
(CamelFolder *folder,
guint summary_index);
/* ********************************************************************** */
/* Handy server capability test macros.
* Both return FALSE if capabilities are unknown. */
#define CAMEL_IMAPX_HAVE_CAPABILITY(info, name) \
((info) != NULL && ((info)->capa & IMAPX_CAPABILITY_##name) != 0)
#define CAMEL_IMAPX_LACK_CAPABILITY(info, name) \
((info) != NULL && ((info)->capa & IMAPX_CAPABILITY_##name) == 0)
enum {
IMAPX_CAPABILITY_IMAP4 = (1 << 0),
IMAPX_CAPABILITY_IMAP4REV1 = (1 << 1),
IMAPX_CAPABILITY_STATUS = (1 << 2),
IMAPX_CAPABILITY_NAMESPACE = (1 << 3),
IMAPX_CAPABILITY_UIDPLUS = (1 << 4),
IMAPX_CAPABILITY_LITERALPLUS = (1 << 5),
IMAPX_CAPABILITY_STARTTLS = (1 << 6),
IMAPX_CAPABILITY_IDLE = (1 << 7),
IMAPX_CAPABILITY_CONDSTORE = (1 << 8),
IMAPX_CAPABILITY_QRESYNC = (1 << 9),
IMAPX_CAPABILITY_LIST_STATUS = (1 << 10),
IMAPX_CAPABILITY_LIST_EXTENDED = (1 << 11),
IMAPX_CAPABILITY_QUOTA = (1 << 12),
IMAPX_CAPABILITY_MOVE = (1 << 13)
};
struct _capability_info {
guint32 capa;
GHashTable *auth_types;
};
struct _capability_info *
imapx_parse_capability (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
void imapx_free_capability (struct _capability_info *);
guint32 imapx_register_capability (const gchar *capability);
guint32 imapx_lookup_capability (const gchar *capability);
gboolean imapx_parse_param_list (struct _CamelIMAPXStream *is,
struct _camel_header_param **plist,
GCancellable *cancellable,
GError **error);
struct _CamelContentDisposition *
imapx_parse_ext_optional (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
struct _CamelMessageContentInfo *
imapx_parse_body_fields (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
struct _camel_header_address *
imapx_parse_address_list (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
struct _CamelMessageInfo *
imapx_parse_envelope (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
struct _CamelMessageContentInfo *
imapx_parse_body (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
gchar * imapx_parse_section (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
void imapx_free_body (struct _CamelMessageContentInfo *cinfo);
/* ********************************************************************** */
/* all the possible stuff we might get from a fetch request */
/* this assumes the caller/server doesn't send any one of these types twice */
struct _fetch_info {
guint32 got; /* what we got, see below */
CamelStream *body; /* BODY[.*](<.*>)? */
CamelStream *text; /* RFC822.TEXT */
CamelStream *header; /* RFC822.HEADER */
CamelMessageInfo *minfo; /* ENVELOPE */
CamelMessageContentInfo *cinfo; /* BODYSTRUCTURE,BODY */
guint32 size; /* RFC822.SIZE */
guint32 offset; /* start offset of a BODY[]<offset.length> request */
guint32 flags; /* FLAGS */
guint64 modseq; /* MODSEQ */
CamelFlag *user_flags;
gchar *date; /* INTERNALDATE */
gchar *section; /* section for a BODY[section] request */
gchar *uid; /* UID */
};
#define FETCH_BODY (1 << 0)
#define FETCH_TEXT (1 << 1)
#define FETCH_HEADER (1 << 2)
#define FETCH_MINFO (1 << 3)
#define FETCH_CINFO (1 << 4)
#define FETCH_SIZE (1 << 5)
#define FETCH_OFFSET (1 << 6)
#define FETCH_FLAGS (1 << 7)
#define FETCH_DATE (1 << 8)
#define FETCH_SECTION (1 << 9)
#define FETCH_UID (1 << 10)
#define FETCH_MODSEQ (1 << 11)
struct _fetch_info *
imapx_parse_fetch (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
void imapx_free_fetch (struct _fetch_info *finfo);
void imapx_dump_fetch (struct _fetch_info *finfo);
/* ********************************************************************** */
struct _status_info {
camel_imapx_id_t result; /* ok/no/bad/preauth only, user_cancel - client response */
camel_imapx_id_t condition; /* read-only/read-write/alert/parse/trycreate/newname/permanentflags/uidvalidity/unseen/highestmodseq */
union {
struct {
gchar *oldname;
gchar *newname;
} newname;
guint32 permanentflags;
guint64 uidvalidity;
guint32 uidnext;
guint32 unseen;
guint64 highestmodseq;
struct {
guint64 uidvalidity;
guint32 uid;
} appenduid;
struct {
guint64 uidvalidity;
GPtrArray *uids;
GPtrArray *copied_uids;
} copyuid;
struct _capability_info *cinfo;
} u;
gchar *text;
};
struct _status_info *
imapx_parse_status (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
struct _status_info *
imapx_copy_status (struct _status_info *sinfo);
void imapx_free_status (struct _status_info *sinfo);
/* ********************************************************************** */
gboolean camel_imapx_command_add_qresync_parameter
(struct _CamelIMAPXCommand *ic,
CamelFolder *folder);
/* ********************************************************************** */
gchar * camel_imapx_parse_mailbox (struct _CamelIMAPXStream *is,
gchar separator,
GCancellable *cancellable,
GError **error);
void camel_imapx_normalize_mailbox (gchar *mailbox_name,
gchar separator);
gboolean camel_imapx_mailbox_is_inbox (const gchar *mailbox_name);
gchar * camel_imapx_mailbox_to_folder_path
(const gchar *mailbox_name,
gchar separator);
gchar * camel_imapx_folder_path_to_mailbox
(const gchar *folder_path,
gchar separator);
/* ********************************************************************** */
gboolean camel_imapx_parse_quota (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
gchar **out_quota_root_name,
CamelFolderQuotaInfo **out_quota_info,
GError **error);
gboolean camel_imapx_parse_quotaroot (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
gchar **out_mailbox_name,
gchar ***out_quota_root_names,
GError **error);
/* ********************************************************************** */
extern guchar imapx_specials[256];
#define IMAPX_TYPE_CHAR (1 << 0)
#define IMAPX_TYPE_TEXT_CHAR (1 << 1)
#define IMAPX_TYPE_QUOTED_CHAR (1 << 2)
#define IMAPX_TYPE_ATOM_CHAR (1 << 3)
#define IMAPX_TYPE_TOKEN_CHAR (1 << 4)
#define IMAPX_TYPE_NOTID_CHAR (1 << 5)
guchar imapx_is_mask (const gchar *p);
#define imapx_is_text_char(c) \
((imapx_specials[((guchar)(c)) & 0xff] & IMAPX_TYPE_TEXT_CHAR) != 0)
#define imapx_is_quoted_char(c) \
((imapx_specials[((guchar)(c)) & 0xff] & IMAPX_TYPE_QUOTED_CHAR) != 0)
#define imapx_is_atom_char(c) \
((imapx_specials[((guchar)(c)) & 0xff] & IMAPX_TYPE_ATOM_CHAR) != 0)
#define imapx_is_token_char(c) \
((imapx_specials[((guchar)(c)) & 0xff] & IMAPX_TYPE_TOKEN_CHAR) != 0)
#define imapx_is_notid_char(c) \
((imapx_specials[((guchar)(c)) & 0xff] & IMAPX_TYPE_NOTID_CHAR) != 0)
#define imapx_is_atom(s) \
(imapx_is_mask (s) & IMAPX_TYPE_ATOM_CHAR)
extern gint camel_imapx_debug_flags;
#define CAMEL_IMAPX_DEBUG_command (1 << 0)
#define CAMEL_IMAPX_DEBUG_debug (1 << 1)
#define CAMEL_IMAPX_DEBUG_extra (1 << 2)
#define CAMEL_IMAPX_DEBUG_io (1 << 3)
#define CAMEL_IMAPX_DEBUG_token (1 << 4)
#define CAMEL_IMAPX_DEBUG_parse (1 << 5)
/* Set this to zero to remove all debug output at build time */
#define CAMEL_IMAPX_DEBUG_ALL ((1 << 7)-1)
#define camel_debug_flag(type) \
(camel_imapx_debug_flags & \
CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type)
#define camel_imapx_debug(type, tagprefix, fmt, ...) \
G_STMT_START { \
if (camel_debug_flag (type)) { \
printf ("[imapx:%c] " fmt, tagprefix , ##__VA_ARGS__); \
fflush (stdout); \
} \
} G_STMT_END
/* ********************************************************************** */
void imapx_utils_init (void);
/* chen adds from old imap provider - place it in right place */
gchar * imapx_path_to_physical (const gchar *prefix,
const gchar *vpath);
gchar * imapx_concat (struct _CamelIMAPXStore *imapx_store,
const gchar *prefix,
const gchar *suffix);
gchar * imapx_get_temp_uid (void);
void camel_imapx_namespace_list_clear
(struct _CamelIMAPXNamespaceList *nsl);
struct _CamelIMAPXNamespaceList *
imapx_parse_namespace_list (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
G_END_DECLS
#endif /* CAMEL_IMAPX_UTILS_H */
|