aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap4
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/imap4')
-rw-r--r--camel/providers/imap4/Makefile.am34
-rw-r--r--camel/providers/imap4/camel-imap-command.h144
-rw-r--r--camel/providers/imap4/camel-imap-engine.h222
-rw-r--r--camel/providers/imap4/camel-imap-folder.h66
-rw-r--r--camel/providers/imap4/camel-imap-stream.h124
-rw-r--r--camel/providers/imap4/camel-imap-summary.h91
-rw-r--r--camel/providers/imap4/camel-imap-utils.h72
-rw-r--r--camel/providers/imap4/camel-imap4-command.c (renamed from camel/providers/imap4/camel-imap-command.c)208
-rw-r--r--camel/providers/imap4/camel-imap4-command.h144
-rw-r--r--camel/providers/imap4/camel-imap4-engine.c (renamed from camel/providers/imap4/camel-imap-engine.c)793
-rw-r--r--camel/providers/imap4/camel-imap4-engine.h222
-rw-r--r--camel/providers/imap4/camel-imap4-folder.c (renamed from camel/providers/imap4/camel-imap-folder.c)352
-rw-r--r--camel/providers/imap4/camel-imap4-folder.h65
-rw-r--r--camel/providers/imap4/camel-imap4-provider.c (renamed from camel/providers/imap4/camel-imap-provider.c)16
-rw-r--r--camel/providers/imap4/camel-imap4-specials.c (renamed from camel/providers/imap4/camel-imap-specials.c)36
-rw-r--r--camel/providers/imap4/camel-imap4-specials.h (renamed from camel/providers/imap4/camel-imap-specials.h)22
-rw-r--r--camel/providers/imap4/camel-imap4-store.c (renamed from camel/providers/imap4/camel-imap-store.c)327
-rw-r--r--camel/providers/imap4/camel-imap4-store.h (renamed from camel/providers/imap4/camel-imap-store.h)32
-rw-r--r--camel/providers/imap4/camel-imap4-stream.c (renamed from camel/providers/imap4/camel-imap-stream.c)276
-rw-r--r--camel/providers/imap4/camel-imap4-stream.h124
-rw-r--r--camel/providers/imap4/camel-imap4-summary.c (renamed from camel/providers/imap4/camel-imap-summary.c)444
-rw-r--r--camel/providers/imap4/camel-imap4-summary.h91
-rw-r--r--camel/providers/imap4/camel-imap4-utils.c (renamed from camel/providers/imap4/camel-imap-utils.c)122
-rw-r--r--camel/providers/imap4/camel-imap4-utils.h67
24 files changed, 2098 insertions, 1996 deletions
diff --git a/camel/providers/imap4/Makefile.am b/camel/providers/imap4/Makefile.am
index b94c8f9564..d1bb57e150 100644
--- a/camel/providers/imap4/Makefile.am
+++ b/camel/providers/imap4/Makefile.am
@@ -17,23 +17,23 @@ INCLUDES = \
-DG_LOG_DOMAIN=\"camel-imap4-provider\"
libcamelimap4_la_SOURCES = \
- camel-imap-command.c \
- camel-imap-command.h \
- camel-imap-engine.c \
- camel-imap-engine.h \
- camel-imap-folder.c \
- camel-imap-folder.h \
- camel-imap-provider.c \
- camel-imap-specials.c \
- camel-imap-specials.h \
- camel-imap-store.c \
- camel-imap-store.h \
- camel-imap-stream.c \
- camel-imap-stream.h \
- camel-imap-summary.c \
- camel-imap-summary.h \
- camel-imap-utils.c \
- camel-imap-utils.h
+ camel-imap4-command.c \
+ camel-imap4-command.h \
+ camel-imap4-engine.c \
+ camel-imap4-engine.h \
+ camel-imap4-folder.c \
+ camel-imap4-folder.h \
+ camel-imap4-provider.c \
+ camel-imap4-specials.c \
+ camel-imap4-specials.h \
+ camel-imap4-store.c \
+ camel-imap4-store.h \
+ camel-imap4-stream.c \
+ camel-imap4-stream.h \
+ camel-imap4-summary.c \
+ camel-imap4-summary.h \
+ camel-imap4-utils.c \
+ camel-imap4-utils.h
libcamelimap4_la_LDFLAGS = -avoid-version -module
diff --git a/camel/providers/imap4/camel-imap-command.h b/camel/providers/imap4/camel-imap-command.h
deleted file mode 100644
index af3ad9f927..0000000000
--- a/camel/providers/imap4/camel-imap-command.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* -*- 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_IMAP_COMMAND_H__
-#define __CAMEL_IMAP_COMMAND_H__
-
-#include <stdarg.h>
-
-#include <glib.h>
-
-#include <e-util/e-msgport.h>
-
-#include <camel/camel-stream.h>
-#include <camel/camel-exception.h>
-#include <camel/camel-data-wrapper.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-struct _CamelIMAPEngine;
-struct _CamelIMAPFolder;
-struct _camel_imap_token_t;
-
-typedef struct _CamelIMAPCommand CamelIMAPCommand;
-typedef struct _CamelIMAPLiteral CamelIMAPLiteral;
-
-typedef int (* CamelIMAPPlusCallback) (struct _CamelIMAPEngine *engine,
- CamelIMAPCommand *ic,
- const unsigned char *linebuf,
- size_t linelen, CamelException *ex);
-
-typedef int (* CamelIMAPUntaggedCallback) (struct _CamelIMAPEngine *engine,
- CamelIMAPCommand *ic,
- guint32 index,
- struct _camel_imap_token_t *token,
- CamelException *ex);
-
-enum {
- CAMEL_IMAP_LITERAL_STRING,
- CAMEL_IMAP_LITERAL_STREAM,
- CAMEL_IMAP_LITERAL_WRAPPER,
-};
-
-struct _CamelIMAPLiteral {
- int type;
- union {
- char *string;
- CamelStream *stream;
- CamelDataWrapper *wrapper;
- } literal;
-};
-
-typedef struct _CamelIMAPCommandPart {
- struct _CamelIMAPCommandPart *next;
- unsigned char *buffer;
- size_t buflen;
-
- CamelIMAPLiteral *literal;
-} CamelIMAPCommandPart;
-
-enum {
- CAMEL_IMAP_COMMAND_QUEUED,
- CAMEL_IMAP_COMMAND_ACTIVE,
- CAMEL_IMAP_COMMAND_COMPLETE,
- CAMEL_IMAP_COMMAND_ERROR,
-};
-
-enum {
- CAMEL_IMAP_RESULT_NONE,
- CAMEL_IMAP_RESULT_OK,
- CAMEL_IMAP_RESULT_NO,
- CAMEL_IMAP_RESULT_BAD,
-};
-
-struct _CamelIMAPCommand {
- EDListNode node;
-
- struct _CamelIMAPEngine *engine;
-
- unsigned int ref_count:26;
- unsigned int status:3;
- unsigned int result:3;
- int id;
-
- char *tag;
-
- GPtrArray *resp_codes;
-
- struct _CamelIMAPFolder *folder;
- CamelException ex;
-
- /* command parts - logical breaks in the overall command based on literals */
- CamelIMAPCommandPart *parts;
-
- /* current part */
- CamelIMAPCommandPart *part;
-
- /* untagged handlers */
- GHashTable *untagged;
-
- /* '+' callback/data */
- CamelIMAPPlusCallback plus;
- void *user_data;
-};
-
-CamelIMAPCommand *camel_imap_command_new (struct _CamelIMAPEngine *engine, struct _CamelIMAPFolder *folder,
- const char *format, ...);
-CamelIMAPCommand *camel_imap_command_newv (struct _CamelIMAPEngine *engine, struct _CamelIMAPFolder *folder,
- const char *format, va_list args);
-
-void camel_imap_command_register_untagged (CamelIMAPCommand *ic, const char *atom, CamelIMAPUntaggedCallback untagged);
-
-void camel_imap_command_ref (CamelIMAPCommand *ic);
-void camel_imap_command_unref (CamelIMAPCommand *ic);
-
-/* returns 1 when complete, 0 if there is more to do, or -1 on error */
-int camel_imap_command_step (CamelIMAPCommand *ic);
-
-void camel_imap_command_reset (CamelIMAPCommand *ic);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_COMMAND_H__ */
diff --git a/camel/providers/imap4/camel-imap-engine.h b/camel/providers/imap4/camel-imap-engine.h
deleted file mode 100644
index 6612693243..0000000000
--- a/camel/providers/imap4/camel-imap-engine.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- 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_IMAP_ENGINE_H__
-#define __CAMEL_IMAP_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_IMAP_ENGINE (camel_imap_engine_get_type ())
-#define CAMEL_IMAP_ENGINE(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP_ENGINE, CamelIMAPEngine))
-#define CAMEL_IMAP_ENGINE_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP_ENGINE, CamelIMAPEngineClass))
-#define CAMEL_IS_IMAP_ENGINE(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP_ENGINE))
-#define CAMEL_IS_IMAP_ENGINE_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP_ENGINE))
-#define CAMEL_IMAP_ENGINE_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP_ENGINE, CamelIMAPEngineClass))
-
-typedef struct _CamelIMAPEngine CamelIMAPEngine;
-typedef struct _CamelIMAPEngineClass CamelIMAPEngineClass;
-
-struct _camel_imap_token_t;
-struct _CamelIMAPCommand;
-struct _CamelIMAPFolder;
-struct _CamelIMAPStream;
-
-typedef enum {
- CAMEL_IMAP_ENGINE_DISCONNECTED,
- CAMEL_IMAP_ENGINE_CONNECTED,
- CAMEL_IMAP_ENGINE_PREAUTH,
- CAMEL_IMAP_ENGINE_AUTHENTICATED,
- CAMEL_IMAP_ENGINE_SELECTED,
-} camel_imap_engine_t;
-
-typedef enum {
- CAMEL_IMAP_LEVEL_UNKNOWN,
- CAMEL_IMAP_LEVEL_IMAP4,
- CAMEL_IMAP_LEVEL_IMAP4REV1
-} camel_imap_level_t;
-
-enum {
- CAMEL_IMAP_CAPABILITY_IMAP4 = (1 << 0),
- CAMEL_IMAP_CAPABILITY_IMAP4REV1 = (1 << 1),
- CAMEL_IMAP_CAPABILITY_STATUS = (1 << 2),
- CAMEL_IMAP_CAPABILITY_NAMESPACE = (1 << 3),
- CAMEL_IMAP_CAPABILITY_UIDPLUS = (1 << 4),
- CAMEL_IMAP_CAPABILITY_LITERALPLUS = (1 << 5),
- CAMEL_IMAP_CAPABILITY_LOGINDISABLED = (1 << 6),
- CAMEL_IMAP_CAPABILITY_STARTTLS = (1 << 7),
- CAMEL_IMAP_CAPABILITY_useful_lsub = (1 << 8),
- CAMEL_IMAP_CAPABILITY_utf8_search = (1 << 9),
-};
-
-typedef enum {
- CAMEL_IMAP_RESP_CODE_ALERT,
- CAMEL_IMAP_RESP_CODE_BADCHARSET,
- CAMEL_IMAP_RESP_CODE_CAPABILITY,
- CAMEL_IMAP_RESP_CODE_PARSE,
- CAMEL_IMAP_RESP_CODE_PERM_FLAGS,
- CAMEL_IMAP_RESP_CODE_READONLY,
- CAMEL_IMAP_RESP_CODE_READWRITE,
- CAMEL_IMAP_RESP_CODE_TRYCREATE,
- CAMEL_IMAP_RESP_CODE_UIDNEXT,
- CAMEL_IMAP_RESP_CODE_UIDVALIDITY,
- CAMEL_IMAP_RESP_CODE_UNSEEN,
- CAMEL_IMAP_RESP_CODE_NEWNAME,
- CAMEL_IMAP_RESP_CODE_APPENDUID,
- CAMEL_IMAP_RESP_CODE_COPYUID,
- CAMEL_IMAP_RESP_CODE_UNKNOWN,
-} camel_imap_resp_code_t;
-
-typedef struct _CamelIMAPRespCode {
- camel_imap_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;
-} CamelIMAPRespCode;
-
-enum {
- CAMEL_IMAP_UNTAGGED_ERROR = -1,
- CAMEL_IMAP_UNTAGGED_OK,
- CAMEL_IMAP_UNTAGGED_NO,
- CAMEL_IMAP_UNTAGGED_BAD,
- CAMEL_IMAP_UNTAGGED_PREAUTH,
- CAMEL_IMAP_UNTAGGED_HANDLED,
-};
-
-typedef struct _CamelIMAPNamespace {
- struct _CamelIMAPNamespace *next;
- char *path;
- char sep;
-} CamelIMAPNamespace;
-
-typedef struct _CamelIMAPNamespaceList {
- CamelIMAPNamespace *personal;
- CamelIMAPNamespace *other;
- CamelIMAPNamespace *shared;
-} CamelIMAPNamespaceList;
-
-enum {
- CAMEL_IMAP_ENGINE_MAXLEN_LINE,
- CAMEL_IMAP_ENGINE_MAXLEN_TOKEN
-};
-
-struct _CamelIMAPEngine {
- CamelObject parent_object;
-
- CamelSession *session;
- CamelURL *url;
-
- camel_imap_engine_t state;
- camel_imap_level_t level;
- guint32 capa;
-
- guint32 maxlen:31;
- guint32 maxlentype:1;
-
- CamelIMAPNamespaceList namespaces;
- GHashTable *authtypes; /* supported authtypes */
-
- struct _CamelIMAPStream *istream;
- CamelStream *ostream;
-
- unsigned char tagprefix; /* 'A'..'Z' */
- unsigned int tag; /* next command tag */
- int nextid;
-
- struct _CamelIMAPFolder *folder; /* currently selected folder */
-
- EDList queue; /* queue of waiting commands */
- struct _CamelIMAPCommand *current;
-};
-
-struct _CamelIMAPEngineClass {
- CamelObjectClass parent_class;
-
- unsigned char tagprefix;
-};
-
-
-CamelType camel_imap_engine_get_type (void);
-
-CamelIMAPEngine *camel_imap_engine_new (CamelSession *session, CamelURL *url);
-
-/* returns 0 on success or -1 on error */
-int camel_imap_engine_take_stream (CamelIMAPEngine *engine, CamelStream *stream, CamelException *ex);
-
-int camel_imap_engine_capability (CamelIMAPEngine *engine, CamelException *ex);
-int camel_imap_engine_namespace (CamelIMAPEngine *engine, CamelException *ex);
-
-int camel_imap_engine_select_folder (CamelIMAPEngine *engine, CamelFolder *folder, CamelException *ex);
-
-struct _CamelIMAPCommand *camel_imap_engine_queue (CamelIMAPEngine *engine, CamelFolder *folder,
- const char *format, ...);
-void camel_imap_engine_prequeue (CamelIMAPEngine *engine, struct _CamelIMAPCommand *ic);
-
-void camel_imap_engine_dequeue (CamelIMAPEngine *engine, struct _CamelIMAPCommand *ic);
-
-int camel_imap_engine_iterate (CamelIMAPEngine *engine);
-
-
-/* untagged response utility functions */
-int camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, struct _camel_imap_token_t *token, CamelException *ex);
-void camel_imap_engine_handle_untagged (CamelIMAPEngine *engine, CamelException *ex);
-
-/* stream wrapper utility functions */
-int camel_imap_engine_next_token (CamelIMAPEngine *engine, struct _camel_imap_token_t *token, CamelException *ex);
-int camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *len, CamelException *ex);
-int camel_imap_engine_literal (CamelIMAPEngine *engine, unsigned char **literal, size_t *len, CamelException *ex);
-int camel_imap_engine_eat_line (CamelIMAPEngine *engine, CamelException *ex);
-
-
-/* response code stuff */
-int camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex);
-void camel_imap_resp_code_free (CamelIMAPRespCode *rcode);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_ENGINE_H__ */
diff --git a/camel/providers/imap4/camel-imap-folder.h b/camel/providers/imap4/camel-imap-folder.h
deleted file mode 100644
index a4f4e55528..0000000000
--- a/camel/providers/imap4/camel-imap-folder.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- 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_IMAP_FOLDER_H__
-#define __CAMEL_IMAP_FOLDER_H__
-
-#include <camel/camel-store.h>
-#include <camel/camel-folder.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define CAMEL_TYPE_IMAP_FOLDER (camel_imap_folder_get_type ())
-#define CAMEL_IMAP_FOLDER(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP_FOLDER, CamelIMAPFolder))
-#define CAMEL_IMAP_FOLDER_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP_FOLDER, CamelIMAPFolderClass))
-#define CAMEL_IS_IMAP_FOLDER(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP_FOLDER))
-#define CAMEL_IS_IMAP_FOLDER_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP_FOLDER))
-#define CAMEL_IMAP_FOLDER_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP_FOLDER, CamelIMAPFolderClass))
-
-typedef struct _CamelIMAPFolder CamelIMAPFolder;
-typedef struct _CamelIMAPFolderClass CamelIMAPFolderClass;
-
-struct _CamelIMAPFolder {
- CamelFolder parent_object;
-
- char *cachedir;
- char *utf7_name;
-};
-
-struct _CamelIMAPFolderClass {
- CamelFolderClass parent_class;
-
-};
-
-
-CamelType camel_imap_folder_get_type (void);
-
-CamelFolder *camel_imap_folder_new (CamelStore *store, const char *full_name, gboolean query, CamelException *ex);
-CamelFolder *camel_imap_folder_new_utf7_name (CamelStore *store, const char *utf7_name, CamelException *ex);
-
-const char *camel_imap_folder_utf7_name (CamelIMAPFolder *folder);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_FOLDER_H__ */
diff --git a/camel/providers/imap4/camel-imap-stream.h b/camel/providers/imap4/camel-imap-stream.h
deleted file mode 100644
index 872cbf7141..0000000000
--- a/camel/providers/imap4/camel-imap-stream.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- 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_IMAP_STREAM_H__
-#define __CAMEL_IMAP_STREAM_H__
-
-#include <camel/camel-stream.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define CAMEL_TYPE_IMAP_STREAM (camel_imap_stream_get_type ())
-#define CAMEL_IMAP_STREAM(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP_STREAM, CamelIMAPStream))
-#define CAMEL_IMAP_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TYPE_IMAP_STREAM, CamelIMAPStreamClass))
-#define CAMEL_IS_IMAP_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_TYPE_IMAP_STREAM))
-
-typedef struct _CamelIMAPStream CamelIMAPStream;
-typedef struct _CamelIMAPStreamClass CamelIMAPStreamClass;
-
-#define IMAP_READ_PRELEN 128
-#define IMAP_READ_BUFLEN 4096
-
-enum {
- CAMEL_IMAP_TOKEN_NO_DATA = -8,
- CAMEL_IMAP_TOKEN_ERROR = -7,
- CAMEL_IMAP_TOKEN_NIL = -6,
- CAMEL_IMAP_TOKEN_ATOM = -5,
- CAMEL_IMAP_TOKEN_FLAG = -4,
- CAMEL_IMAP_TOKEN_NUMBER = -3,
- CAMEL_IMAP_TOKEN_QSTRING = -2,
- CAMEL_IMAP_TOKEN_LITERAL = -1,
- /* CAMEL_IMAP_TOKEN_CHAR would just be the char we got */
- CAMEL_IMAP_TOKEN_EOLN = '\n',
- CAMEL_IMAP_TOKEN_LPAREN = '(',
- CAMEL_IMAP_TOKEN_RPAREN = ')',
- CAMEL_IMAP_TOKEN_ASTERISK = '*',
- CAMEL_IMAP_TOKEN_PLUS = '+',
- CAMEL_IMAP_TOKEN_LBRACKET = '[',
- CAMEL_IMAP_TOKEN_RBRACKET = ']',
-};
-
-typedef struct _camel_imap_token_t {
- int token;
- union {
- char *atom;
- char *flag;
- char *qstring;
- size_t literal;
- guint32 number;
- } v;
-} camel_imap_token_t;
-
-enum {
- CAMEL_IMAP_STREAM_MODE_TOKEN = 0,
- CAMEL_IMAP_STREAM_MODE_LITERAL = 1,
-};
-
-struct _CamelIMAPStream {
- CamelStream parent_object;
-
- CamelStream *stream;
-
- guint disconnected:1; /* disconnected state */
- guint mode:1; /* TOKEN vs LITERAL */
- guint eol:1; /* end-of-literal */
-
- size_t literal;
-
- /* i/o buffers */
- unsigned char realbuf[IMAP_READ_PRELEN + IMAP_READ_BUFLEN + 1];
- unsigned char *inbuf;
- unsigned char *inptr;
- unsigned char *inend;
-
- /* token buffers */
- unsigned char *tokenbuf;
- unsigned char *tokenptr;
- unsigned int tokenleft;
-
- camel_imap_token_t *unget;
-};
-
-struct _CamelIMAPStreamClass {
- CamelStreamClass parent_class;
-
- /* Virtual methods */
-};
-
-
-/* Standard Camel function */
-CamelType camel_imap_stream_get_type (void);
-
-CamelStream *camel_imap_stream_new (CamelStream *stream);
-
-int camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token);
-int camel_imap_stream_unget_token (CamelIMAPStream *stream, camel_imap_token_t *token);
-
-int camel_imap_stream_line (CamelIMAPStream *stream, unsigned char **line, size_t *len);
-int camel_imap_stream_literal (CamelIMAPStream *stream, unsigned char **literal, size_t *len);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_STREAM_H__ */
diff --git a/camel/providers/imap4/camel-imap-summary.h b/camel/providers/imap4/camel-imap-summary.h
deleted file mode 100644
index a8faff8522..0000000000
--- a/camel/providers/imap4/camel-imap-summary.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- 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_IMAP_SUMMARY_H__
-#define __CAMEL_IMAP_SUMMARY_H__
-
-#include <sys/types.h>
-
-#include <camel/camel-folder.h>
-#include <camel/camel-folder-summary.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define CAMEL_TYPE_IMAP_SUMMARY (camel_imap_summary_get_type ())
-#define CAMEL_IMAP_SUMMARY(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP_SUMMARY, CamelIMAPSummary))
-#define CAMEL_IMAP_SUMMARY_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP_SUMMARY, CamelIMAPSummaryClass))
-#define CAMEL_IS_IMAP_SUMMARY(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP_SUMMARY))
-#define CAMEL_IS_IMAP_SUMMARY_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP_SUMMARY))
-#define CAMEL_IMAP_SUMMARY_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_FOLDER_SUMMARY, CamelIMAPSummaryClass))
-
-typedef struct _CamelIMAPMessageInfo CamelIMAPMessageInfo;
-typedef struct _CamelIMAPSummary CamelIMAPSummary;
-typedef struct _CamelIMAPSummaryClass CamelIMAPSummaryClass;
-
-struct _CamelIMAPMessageInfo {
- CamelMessageInfo parent_info;
-
- guint32 server_flags;
-};
-
-struct _CamelIMAPSummary {
- CamelFolderSummary parent_object;
-
- CamelFolder *folder;
-
- guint32 exists;
- guint32 recent;
- guint32 unseen;
-
- guint32 uidvalidity;
-
- guint uidvalidity_changed:1;
- guint exists_changed:1;
-};
-
-struct _CamelIMAPSummaryClass {
- CamelFolderSummaryClass parent_class;
-
-};
-
-
-CamelType camel_imap_summary_get_type (void);
-
-CamelFolderSummary *camel_imap_summary_new (CamelFolder *folder);
-
-void camel_imap_summary_set_exists (CamelFolderSummary *summary, guint32 exists);
-void camel_imap_summary_set_recent (CamelFolderSummary *summary, guint32 recent);
-void camel_imap_summary_set_unseen (CamelFolderSummary *summary, guint32 unseen);
-void camel_imap_summary_set_uidnext (CamelFolderSummary *summary, guint32 uidnext);
-
-void camel_imap_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidvalidity);
-
-void camel_imap_summary_expunge (CamelFolderSummary *summary, int seqid);
-
-int camel_imap_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_SUMMARY_H__ */
diff --git a/camel/providers/imap4/camel-imap-utils.h b/camel/providers/imap4/camel-imap-utils.h
deleted file mode 100644
index c2f87ae4e1..0000000000
--- a/camel/providers/imap4/camel-imap-utils.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- 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_IMAP_UTILS_H__
-#define __CAMEL_IMAP_UTILS_H__
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* IMAP flag merging */
-typedef struct {
- guint32 changed;
- guint32 bits;
-} flags_diff_t;
-
-void camel_imap_flags_diff (flags_diff_t *diff, guint32 old, guint32 new);
-guint32 camel_imap_flags_merge (flags_diff_t *diff, guint32 flags);
-guint32 camel_imap_merge_flags (guint32 original, guint32 local, guint32 server);
-
-
-struct _CamelIMAPEngine;
-struct _CamelIMAPCommand;
-struct _camel_imap_token_t;
-
-void camel_imap_utils_set_unexpected_token_error (CamelException *ex, struct _CamelIMAPEngine *engine, struct _camel_imap_token_t *token);
-
-int camel_imap_parse_flags_list (struct _CamelIMAPEngine *engine, guint32 *flags, CamelException *ex);
-
-enum {
- CAMEL_IMAP_FOLDER_MARKED = (1 << 0),
- CAMEL_IMAP_FOLDER_UNMARKED = (1 << 1),
- CAMEL_IMAP_FOLDER_NOSELECT = (1 << 2),
- CAMEL_IMAP_FOLDER_NOINFERIORS = (1 << 3),
- CAMEL_IMAP_FOLDER_HAS_CHILDREN = (1 << 4),
- CAMEL_IMAP_FOLDER_HAS_NO_CHILDREN = (1 << 5),
-};
-
-typedef struct {
- guint32 flags;
- char delim;
- char *name;
-} camel_imap_list_t;
-
-int camel_imap_untagged_list (struct _CamelIMAPEngine *engine, struct _CamelIMAPCommand *ic,
- guint32 index, struct _camel_imap_token_t *token, CamelException *ex);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __CAMEL_IMAP_UTILS_H__ */
diff --git a/camel/providers/imap4/camel-imap-command.c b/camel/providers/imap4/camel-imap4-command.c
index e5668ccbc6..c1ff3a289b 100644
--- a/camel/providers/imap4/camel-imap-command.c
+++ b/camel/providers/imap4/camel-imap4-command.c
@@ -30,34 +30,34 @@
#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-crlf.h>
-#include "camel-imap-stream.h"
-#include "camel-imap-engine.h"
-#include "camel-imap-folder.h"
-#include "camel-imap-specials.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-engine.h"
+#include "camel-imap4-folder.h"
+#include "camel-imap4-specials.h"
-#include "camel-imap-command.h"
+#include "camel-imap4-command.h"
#define d(x) x
enum {
- IMAP_STRING_ATOM,
- IMAP_STRING_QSTRING,
- IMAP_STRING_LITERAL,
+ IMAP4_STRING_ATOM,
+ IMAP4_STRING_QSTRING,
+ IMAP4_STRING_LITERAL,
};
static int
-imap_string_get_type (const char *str)
+imap4_string_get_type (const char *str)
{
int type = 0;
while (*str) {
if (!is_atom (*str)) {
if (is_qsafe (*str))
- type = IMAP_STRING_QSTRING;
+ type = IMAP4_STRING_QSTRING;
else
- return IMAP_STRING_LITERAL;
+ return IMAP4_STRING_LITERAL;
}
str++;
}
@@ -67,7 +67,7 @@ imap_string_get_type (const char *str)
#if 0
static gboolean
-imap_string_is_atom_safe (const char *str)
+imap4_string_is_atom_safe (const char *str)
{
while (is_atom (*str))
str++;
@@ -76,7 +76,7 @@ imap_string_is_atom_safe (const char *str)
}
static gboolean
-imap_string_is_quote_safe (const char *str)
+imap4_string_is_quote_safe (const char *str)
{
while (is_qsafe (*str))
str++;
@@ -86,13 +86,13 @@ imap_string_is_quote_safe (const char *str)
#endif
static size_t
-camel_imap_literal_length (CamelIMAPLiteral *literal)
+camel_imap4_literal_length (CamelIMAP4Literal *literal)
{
CamelStream *stream, *null;
CamelMimeFilter *crlf;
size_t len;
- if (literal->type == CAMEL_IMAP_LITERAL_STRING)
+ if (literal->type == CAMEL_IMAP4_LITERAL_STRING)
return strlen (literal->literal.string);
null = camel_stream_null_new ();
@@ -102,11 +102,11 @@ camel_imap_literal_length (CamelIMAPLiteral *literal)
camel_object_unref (crlf);
switch (literal->type) {
- case CAMEL_IMAP_LITERAL_STREAM:
+ case CAMEL_IMAP4_LITERAL_STREAM:
camel_stream_write_to_stream (literal->literal.stream, stream);
camel_stream_reset (literal->literal.stream);
break;
- case CAMEL_IMAP_LITERAL_WRAPPER:
+ case CAMEL_IMAP4_LITERAL_WRAPPER:
camel_data_wrapper_write_to_stream (literal->literal.wrapper, stream);
break;
default:
@@ -122,12 +122,12 @@ camel_imap_literal_length (CamelIMAPLiteral *literal)
return len;
}
-static CamelIMAPCommandPart *
+static CamelIMAP4CommandPart *
command_part_new (void)
{
- CamelIMAPCommandPart *part;
+ CamelIMAP4CommandPart *part;
- part = g_new (CamelIMAPCommandPart, 1);
+ part = g_new (CamelIMAP4CommandPart, 1);
part->next = NULL;
part->buffer = NULL;
part->buflen = 0;
@@ -137,29 +137,29 @@ command_part_new (void)
}
static void
-imap_command_append_string (CamelIMAPEngine *engine, CamelIMAPCommandPart **tail, GString *str, const char *string)
+imap4_command_append_string (CamelIMAP4Engine *engine, CamelIMAP4CommandPart **tail, GString *str, const char *string)
{
- CamelIMAPCommandPart *part;
- CamelIMAPLiteral *literal;
+ CamelIMAP4CommandPart *part;
+ CamelIMAP4Literal *literal;
- switch (imap_string_get_type (string)) {
- case IMAP_STRING_ATOM:
+ switch (imap4_string_get_type (string)) {
+ case IMAP4_STRING_ATOM:
/* string is safe as it is... */
g_string_append (str, string);
break;
- case IMAP_STRING_QSTRING:
+ case IMAP4_STRING_QSTRING:
/* we need to quote the string */
/* FIXME: need to escape stuff */
g_string_append_printf (str, "\"%s\"", string);
break;
- case IMAP_STRING_LITERAL:
- if (engine->capa & CAMEL_IMAP_CAPABILITY_LITERALPLUS) {
+ case IMAP4_STRING_LITERAL:
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_LITERALPLUS) {
/* we have to send a literal, but the server supports LITERAL+ so use that */
g_string_append_printf (str, "{%u+}\r\n%s", strlen (string), string);
} else {
/* we have to make it a literal */
- literal = g_new (CamelIMAPLiteral, 1);
- literal->type = CAMEL_IMAP_LITERAL_STRING;
+ literal = g_new (CamelIMAP4Literal, 1);
+ literal->type = CAMEL_IMAP4_LITERAL_STRING;
literal->literal.string = g_strdup (string);
g_string_append_printf (str, "{%u}\r\n", strlen (string));
@@ -178,11 +178,11 @@ imap_command_append_string (CamelIMAPEngine *engine, CamelIMAPCommandPart **tail
}
}
-CamelIMAPCommand *
-camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder, const char *format, va_list args)
+CamelIMAP4Command *
+camel_imap4_command_newv (CamelIMAP4Engine *engine, CamelIMAP4Folder *imap4_folder, const char *format, va_list args)
{
- CamelIMAPCommandPart *parts, *part, *tail;
- CamelIMAPCommand *ic;
+ CamelIMAP4CommandPart *parts, *part, *tail;
+ CamelIMAP4Command *ic;
const char *start;
GString *str;
@@ -195,8 +195,8 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
register char ch = *format++;
if (ch == '%') {
- CamelIMAPLiteral *literal;
- CamelIMAPFolder *folder;
+ CamelIMAP4Literal *literal;
+ CamelIMAP4Folder *folder;
unsigned int u;
char *string;
size_t len;
@@ -226,21 +226,21 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
g_string_append_printf (str, "%u", u);
break;
case 'F':
- /* CamelIMAPFolder */
- folder = va_arg (args, CamelIMAPFolder *);
- string = (char *) camel_imap_folder_utf7_name (folder);
- imap_command_append_string (engine, &tail, str, string);
+ /* CamelIMAP4Folder */
+ folder = va_arg (args, CamelIMAP4Folder *);
+ string = (char *) camel_imap4_folder_utf7_name (folder);
+ imap4_command_append_string (engine, &tail, str, string);
break;
case 'L':
/* Literal */
obj = va_arg (args, void *);
- literal = g_new (CamelIMAPLiteral, 1);
+ literal = g_new (CamelIMAP4Literal, 1);
if (CAMEL_IS_DATA_WRAPPER (obj)) {
- literal->type = CAMEL_IMAP_LITERAL_WRAPPER;
+ literal->type = CAMEL_IMAP4_LITERAL_WRAPPER;
literal->literal.wrapper = obj;
} else if (CAMEL_IS_STREAM (obj)) {
- literal->type = CAMEL_IMAP_LITERAL_STREAM;
+ literal->type = CAMEL_IMAP4_LITERAL_STREAM;
literal->literal.stream = obj;
} else {
g_assert_not_reached ();
@@ -249,7 +249,7 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
camel_object_ref (obj);
/* FIXME: take advantage of LITERAL+? */
- len = camel_imap_literal_length (literal);
+ len = camel_imap4_literal_length (literal);
g_string_append_printf (str, "{%u}\r\n", len);
tail->buffer = g_strdup (str->str);
@@ -266,7 +266,7 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
case 'S':
/* string which may need to be quoted or made into a literal */
string = va_arg (args, char *);
- imap_command_append_string (engine, &tail, str, string);
+ imap4_command_append_string (engine, &tail, str, string);
break;
case 's':
/* safe atom string */
@@ -292,11 +292,11 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
tail->literal = NULL;
g_string_free (str, FALSE);
- ic = g_new0 (CamelIMAPCommand, 1);
+ ic = g_new0 (CamelIMAP4Command, 1);
((EDListNode *) ic)->next = NULL;
((EDListNode *) ic)->prev = NULL;
ic->untagged = g_hash_table_new (g_str_hash, g_str_equal);
- ic->status = CAMEL_IMAP_COMMAND_QUEUED;
+ ic->status = CAMEL_IMAP4_COMMAND_QUEUED;
ic->resp_codes = g_ptr_array_new ();
ic->engine = engine;
ic->ref_count = 1;
@@ -305,44 +305,44 @@ camel_imap_command_newv (CamelIMAPEngine *engine, CamelIMAPFolder *imap_folder,
camel_exception_init (&ic->ex);
- if (imap_folder) {
- camel_object_ref (imap_folder);
- ic->folder = imap_folder;
+ if (imap4_folder) {
+ camel_object_ref (imap4_folder);
+ ic->folder = imap4_folder;
} else
ic->folder = NULL;
return ic;
}
-CamelIMAPCommand *
-camel_imap_command_new (CamelIMAPEngine *engine, CamelIMAPFolder *folder, const char *format, ...)
+CamelIMAP4Command *
+camel_imap4_command_new (CamelIMAP4Engine *engine, CamelIMAP4Folder *folder, const char *format, ...)
{
- CamelIMAPCommand *command;
+ CamelIMAP4Command *command;
va_list args;
va_start (args, format);
- command = camel_imap_command_newv (engine, folder, format, args);
+ command = camel_imap4_command_newv (engine, folder, format, args);
va_end (args);
return command;
}
void
-camel_imap_command_register_untagged (CamelIMAPCommand *ic, const char *atom, CamelIMAPUntaggedCallback untagged)
+camel_imap4_command_register_untagged (CamelIMAP4Command *ic, const char *atom, CamelIMAP4UntaggedCallback untagged)
{
g_hash_table_insert (ic->untagged, g_strdup (atom), untagged);
}
void
-camel_imap_command_ref (CamelIMAPCommand *ic)
+camel_imap4_command_ref (CamelIMAP4Command *ic)
{
ic->ref_count++;
}
void
-camel_imap_command_unref (CamelIMAPCommand *ic)
+camel_imap4_command_unref (CamelIMAP4Command *ic)
{
- CamelIMAPCommandPart *part, *next;
+ CamelIMAP4CommandPart *part, *next;
int i;
if (ic == NULL)
@@ -356,10 +356,10 @@ camel_imap_command_unref (CamelIMAPCommand *ic)
g_free (ic->tag);
for (i = 0; i < ic->resp_codes->len; i++) {
- CamelIMAPRespCode *resp_code;
+ CamelIMAP4RespCode *resp_code;
resp_code = ic->resp_codes->pdata[i];
- camel_imap_resp_code_free (resp_code);
+ camel_imap4_resp_code_free (resp_code);
}
g_ptr_array_free (ic->resp_codes, TRUE);
@@ -373,13 +373,13 @@ camel_imap_command_unref (CamelIMAPCommand *ic)
g_free (part->buffer);
if (part->literal) {
switch (part->literal->type) {
- case CAMEL_IMAP_LITERAL_STRING:
+ case CAMEL_IMAP4_LITERAL_STRING:
g_free (part->literal->literal.string);
break;
- case CAMEL_IMAP_LITERAL_STREAM:
+ case CAMEL_IMAP4_LITERAL_STREAM:
camel_object_unref (part->literal->literal.stream);
break;
- case CAMEL_IMAP_LITERAL_WRAPPER:
+ case CAMEL_IMAP4_LITERAL_WRAPPER:
camel_object_unref (part->literal->literal.wrapper);
break;
}
@@ -398,14 +398,14 @@ camel_imap_command_unref (CamelIMAPCommand *ic)
static int
-imap_literal_write_to_stream (CamelIMAPLiteral *literal, CamelStream *stream)
+imap4_literal_write_to_stream (CamelIMAP4Literal *literal, CamelStream *stream)
{
CamelStream *istream, *ostream = NULL;
CamelDataWrapper *wrapper;
CamelMimeFilter *crlf;
char *string;
- if (literal->type == CAMEL_IMAP_LITERAL_STRING) {
+ if (literal->type == CAMEL_IMAP4_LITERAL_STRING) {
string = literal->literal.string;
if (camel_stream_write (stream, string, strlen (string)) == -1)
return -1;
@@ -420,12 +420,12 @@ imap_literal_write_to_stream (CamelIMAPLiteral *literal, CamelStream *stream)
/* write the literal */
switch (literal->type) {
- case CAMEL_IMAP_LITERAL_STREAM:
+ case CAMEL_IMAP4_LITERAL_STREAM:
istream = literal->literal.stream;
if (camel_stream_write_to_stream (istream, ostream) == -1)
goto exception;
break;
- case CAMEL_IMAP_LITERAL_WRAPPER:
+ case CAMEL_IMAP4_LITERAL_WRAPPER:
wrapper = literal->literal.wrapper;
if (camel_data_wrapper_write_to_stream (wrapper, ostream) == -1)
goto exception;
@@ -451,25 +451,25 @@ imap_literal_write_to_stream (CamelIMAPLiteral *literal, CamelStream *stream)
static void
-unexpected_token (camel_imap_token_t *token)
+unexpected_token (camel_imap4_token_t *token)
{
switch (token->token) {
- case CAMEL_IMAP_TOKEN_NO_DATA:
+ case CAMEL_IMAP4_TOKEN_NO_DATA:
fprintf (stderr, "*** NO DATA ***");
break;
- case CAMEL_IMAP_TOKEN_ERROR:
+ case CAMEL_IMAP4_TOKEN_ERROR:
fprintf (stderr, "*** ERROR ***");
break;
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
fprintf (stderr, "NIL");
break;
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
fprintf (stderr, "%s", token->v.atom);
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
fprintf (stderr, "\"%s\"", token->v.qstring);
break;
- case CAMEL_IMAP_TOKEN_LITERAL:
+ case CAMEL_IMAP4_TOKEN_LITERAL:
fprintf (stderr, "{%u}", token->v.literal);
break;
default:
@@ -479,12 +479,12 @@ unexpected_token (camel_imap_token_t *token)
}
int
-camel_imap_command_step (CamelIMAPCommand *ic)
+camel_imap4_command_step (CamelIMAP4Command *ic)
{
- CamelIMAPEngine *engine = ic->engine;
- int result = CAMEL_IMAP_RESULT_NONE;
- CamelIMAPLiteral *literal;
- camel_imap_token_t token;
+ CamelIMAP4Engine *engine = ic->engine;
+ int result = CAMEL_IMAP4_RESULT_NONE;
+ CamelIMAP4Literal *literal;
+ camel_imap4_token_t token;
unsigned char *linebuf;
ssize_t nwritten;
size_t len;
@@ -532,21 +532,21 @@ camel_imap_command_step (CamelIMAPCommand *ic)
if (camel_stream_flush (engine->ostream) == -1)
goto exception;
- /* now we need to read the response(s) from the IMAP server */
+ /* now we need to read the response(s) from the IMAP4 server */
do {
- if (camel_imap_engine_next_token (engine, &token, &ic->ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
if (token.token == '+') {
/* we got a continuation response from the server */
literal = ic->part->literal;
- if (camel_imap_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
+ if (camel_imap4_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
goto exception;
if (literal) {
- if (imap_literal_write_to_stream (literal, engine->ostream) == -1)
+ if (imap4_literal_write_to_stream (literal, engine->ostream) == -1)
goto exception;
g_free (linebuf);
@@ -570,39 +570,39 @@ camel_imap_command_step (CamelIMAPCommand *ic)
linebuf = NULL;
} else if (token.token == '*') {
/* we got an untagged response, let the engine handle this */
- if (camel_imap_engine_handle_untagged_1 (engine, &token, &ic->ex) == -1)
+ if (camel_imap4_engine_handle_untagged_1 (engine, &token, &ic->ex) == -1)
goto exception;
- } else if (token.token == CAMEL_IMAP_TOKEN_ATOM && !strcmp (token.v.atom, ic->tag)) {
+ } else if (token.token == CAMEL_IMAP4_TOKEN_ATOM && !strcmp (token.v.atom, ic->tag)) {
/* we got "<tag> OK/NO/BAD" */
fprintf (stderr, "got %s response\n", token.v.atom);
- if (camel_imap_engine_next_token (engine, &token, &ic->ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
- if (token.token == CAMEL_IMAP_TOKEN_ATOM) {
+ if (token.token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!strcmp (token.v.atom, "OK"))
- result = CAMEL_IMAP_RESULT_OK;
+ result = CAMEL_IMAP4_RESULT_OK;
else if (!strcmp (token.v.atom, "NO"))
- result = CAMEL_IMAP_RESULT_NO;
+ result = CAMEL_IMAP4_RESULT_NO;
else if (!strcmp (token.v.atom, "BAD"))
- result = CAMEL_IMAP_RESULT_BAD;
+ result = CAMEL_IMAP4_RESULT_BAD;
- if (result == CAMEL_IMAP_RESULT_NONE) {
+ if (result == CAMEL_IMAP4_RESULT_NONE) {
fprintf (stderr, "expected OK/NO/BAD but got %s\n", token.v.atom);
goto unexpected;
}
- if (camel_imap_engine_next_token (engine, &token, &ic->ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
if (token.token == '[') {
/* we have a response code */
- camel_imap_stream_unget_token (engine->istream, &token);
- if (camel_imap_engine_parse_resp_code (engine, &ic->ex) == -1)
+ camel_imap4_stream_unget_token (engine->istream, &token);
+ if (camel_imap4_engine_parse_resp_code (engine, &ic->ex) == -1)
goto exception;
} else if (token.token != '\n') {
/* just gobble up the rest of the line */
- if (camel_imap_engine_line (engine, NULL, NULL, &ic->ex) == -1)
+ if (camel_imap4_engine_line (engine, NULL, NULL, &ic->ex) == -1)
goto exception;
}
} else {
@@ -622,11 +622,11 @@ camel_imap_command_step (CamelIMAPCommand *ic)
unexpected:
/* no fucking clue what we got... */
- if (camel_imap_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
+ if (camel_imap4_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
goto exception;
camel_exception_setv (&ic->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unexpected response from IMAP server %s: %s"),
+ _("Unexpected response from IMAP4 server %s: %s"),
engine->url->host, linebuf);
g_free (linebuf);
@@ -636,10 +636,10 @@ camel_imap_command_step (CamelIMAPCommand *ic)
} while (1);
/* status should always be ACTIVE here... */
- if (ic->status == CAMEL_IMAP_COMMAND_ACTIVE) {
+ if (ic->status == CAMEL_IMAP4_COMMAND_ACTIVE) {
ic->part = ic->part->next;
if (ic->part == NULL || result) {
- ic->status = CAMEL_IMAP_COMMAND_COMPLETE;
+ ic->status = CAMEL_IMAP4_COMMAND_COMPLETE;
ic->result = result;
return 1;
}
@@ -649,23 +649,23 @@ camel_imap_command_step (CamelIMAPCommand *ic)
exception:
- ic->status = CAMEL_IMAP_COMMAND_ERROR;
+ ic->status = CAMEL_IMAP4_COMMAND_ERROR;
return -1;
}
void
-camel_imap_command_reset (CamelIMAPCommand *ic)
+camel_imap4_command_reset (CamelIMAP4Command *ic)
{
int i;
for (i = 0; i < ic->resp_codes->len; i++)
- camel_imap_resp_code_free (ic->resp_codes->pdata[i]);
+ camel_imap4_resp_code_free (ic->resp_codes->pdata[i]);
g_ptr_array_set_size (ic->resp_codes, 0);
- ic->status = CAMEL_IMAP_COMMAND_QUEUED;
- ic->result = CAMEL_IMAP_RESULT_NONE;
+ ic->status = CAMEL_IMAP4_COMMAND_QUEUED;
+ ic->result = CAMEL_IMAP4_RESULT_NONE;
ic->part = ic->parts;
g_free (ic->tag);
ic->tag = NULL;
diff --git a/camel/providers/imap4/camel-imap4-command.h b/camel/providers/imap4/camel-imap4-command.h
new file mode 100644
index 0000000000..49487b1b2d
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-command.h
@@ -0,0 +1,144 @@
+/* -*- 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_COMMAND_H__
+#define __CAMEL_IMAP4_COMMAND_H__
+
+#include <stdarg.h>
+
+#include <glib.h>
+
+#include <e-util/e-msgport.h>
+
+#include <camel/camel-stream.h>
+#include <camel/camel-exception.h>
+#include <camel/camel-data-wrapper.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+struct _CamelIMAP4Engine;
+struct _CamelIMAP4Folder;
+struct _camel_imap4_token_t;
+
+typedef struct _CamelIMAP4Command CamelIMAP4Command;
+typedef struct _CamelIMAP4Literal CamelIMAP4Literal;
+
+typedef int (* CamelIMAP4PlusCallback) (struct _CamelIMAP4Engine *engine,
+ CamelIMAP4Command *ic,
+ const unsigned char *linebuf,
+ size_t linelen, CamelException *ex);
+
+typedef int (* CamelIMAP4UntaggedCallback) (struct _CamelIMAP4Engine *engine,
+ CamelIMAP4Command *ic,
+ guint32 index,
+ struct _camel_imap4_token_t *token,
+ CamelException *ex);
+
+enum {
+ CAMEL_IMAP4_LITERAL_STRING,
+ CAMEL_IMAP4_LITERAL_STREAM,
+ CAMEL_IMAP4_LITERAL_WRAPPER,
+};
+
+struct _CamelIMAP4Literal {
+ int type;
+ union {
+ char *string;
+ CamelStream *stream;
+ CamelDataWrapper *wrapper;
+ } literal;
+};
+
+typedef struct _CamelIMAP4CommandPart {
+ struct _CamelIMAP4CommandPart *next;
+ unsigned char *buffer;
+ size_t buflen;
+
+ CamelIMAP4Literal *literal;
+} CamelIMAP4CommandPart;
+
+enum {
+ CAMEL_IMAP4_COMMAND_QUEUED,
+ CAMEL_IMAP4_COMMAND_ACTIVE,
+ CAMEL_IMAP4_COMMAND_COMPLETE,
+ CAMEL_IMAP4_COMMAND_ERROR,
+};
+
+enum {
+ CAMEL_IMAP4_RESULT_NONE,
+ CAMEL_IMAP4_RESULT_OK,
+ CAMEL_IMAP4_RESULT_NO,
+ CAMEL_IMAP4_RESULT_BAD,
+};
+
+struct _CamelIMAP4Command {
+ EDListNode node;
+
+ struct _CamelIMAP4Engine *engine;
+
+ unsigned int ref_count:26;
+ unsigned int status:3;
+ unsigned int result:3;
+ int id;
+
+ char *tag;
+
+ GPtrArray *resp_codes;
+
+ struct _CamelIMAP4Folder *folder;
+ CamelException ex;
+
+ /* command parts - logical breaks in the overall command based on literals */
+ CamelIMAP4CommandPart *parts;
+
+ /* current part */
+ CamelIMAP4CommandPart *part;
+
+ /* untagged handlers */
+ GHashTable *untagged;
+
+ /* '+' callback/data */
+ CamelIMAP4PlusCallback plus;
+ void *user_data;
+};
+
+CamelIMAP4Command *camel_imap4_command_new (struct _CamelIMAP4Engine *engine, struct _CamelIMAP4Folder *folder,
+ const char *format, ...);
+CamelIMAP4Command *camel_imap4_command_newv (struct _CamelIMAP4Engine *engine, struct _CamelIMAP4Folder *folder,
+ const char *format, va_list args);
+
+void camel_imap4_command_register_untagged (CamelIMAP4Command *ic, const char *atom, CamelIMAP4UntaggedCallback untagged);
+
+void camel_imap4_command_ref (CamelIMAP4Command *ic);
+void camel_imap4_command_unref (CamelIMAP4Command *ic);
+
+/* returns 1 when complete, 0 if there is more to do, or -1 on error */
+int camel_imap4_command_step (CamelIMAP4Command *ic);
+
+void camel_imap4_command_reset (CamelIMAP4Command *ic);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CAMEL_IMAP4_COMMAND_H__ */
diff --git a/camel/providers/imap4/camel-imap-engine.c b/camel/providers/imap4/camel-imap4-engine.c
index 86afb12fd5..5e3d93ddaf 100644
--- a/camel/providers/imap4/camel-imap-engine.c
+++ b/camel/providers/imap4/camel-imap4-engine.c
@@ -29,46 +29,46 @@
#include <camel/camel-sasl.h>
#include <camel/camel-stream-buffer.h>
-#include "camel-imap-summary.h"
-#include "camel-imap-command.h"
-#include "camel-imap-stream.h"
-#include "camel-imap-folder.h"
-#include "camel-imap-utils.h"
+#include "camel-imap4-summary.h"
+#include "camel-imap4-command.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-folder.h"
+#include "camel-imap4-utils.h"
-#include "camel-imap-engine.h"
+#include "camel-imap4-engine.h"
#define d(x) x
-static void camel_imap_engine_class_init (CamelIMAPEngineClass *klass);
-static void camel_imap_engine_init (CamelIMAPEngine *engine, CamelIMAPEngineClass *klass);
-static void camel_imap_engine_finalize (CamelObject *object);
+static void camel_imap4_engine_class_init (CamelIMAP4EngineClass *klass);
+static void camel_imap4_engine_init (CamelIMAP4Engine *engine, CamelIMAP4EngineClass *klass);
+static void camel_imap4_engine_finalize (CamelObject *object);
static CamelObjectClass *parent_class = NULL;
CamelType
-camel_imap_engine_get_type (void)
+camel_imap4_engine_get_type (void)
{
static CamelType type = 0;
if (!type) {
- type = camel_type_register (CAMEL_TYPE_IMAP_ENGINE,
- "CamelIMAPEngine",
- sizeof (CamelIMAPEngine),
- sizeof (CamelIMAPEngineClass),
- (CamelObjectClassInitFunc) camel_imap_engine_class_init,
+ type = camel_type_register (CAMEL_TYPE_IMAP4_ENGINE,
+ "CamelIMAP4Engine",
+ sizeof (CamelIMAP4Engine),
+ sizeof (CamelIMAP4EngineClass),
+ (CamelObjectClassInitFunc) camel_imap4_engine_class_init,
NULL,
- (CamelObjectInitFunc) camel_imap_engine_init,
- (CamelObjectFinalizeFunc) camel_imap_engine_finalize);
+ (CamelObjectInitFunc) camel_imap4_engine_init,
+ (CamelObjectFinalizeFunc) camel_imap4_engine_finalize);
}
return type;
}
static void
-camel_imap_engine_class_init (CamelIMAPEngineClass *klass)
+camel_imap4_engine_class_init (CamelIMAP4EngineClass *klass)
{
parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE);
@@ -76,10 +76,10 @@ camel_imap_engine_class_init (CamelIMAPEngineClass *klass)
}
static void
-camel_imap_engine_init (CamelIMAPEngine *engine, CamelIMAPEngineClass *klass)
+camel_imap4_engine_init (CamelIMAP4Engine *engine, CamelIMAP4EngineClass *klass)
{
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
- engine->level = CAMEL_IMAP_LEVEL_UNKNOWN;
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
+ engine->level = CAMEL_IMAP4_LEVEL_UNKNOWN;
engine->session = NULL;
engine->url = NULL;
@@ -92,7 +92,7 @@ camel_imap_engine_init (CamelIMAPEngine *engine, CamelIMAPEngineClass *klass)
engine->capa = 0;
/* this is the suggested default, impacts the max command line length we'll send */
- engine->maxlentype = CAMEL_IMAP_ENGINE_MAXLEN_LINE;
+ engine->maxlentype = CAMEL_IMAP4_ENGINE_MAXLEN_LINE;
engine->maxlen = 1000;
engine->namespaces.personal = NULL;
@@ -113,9 +113,9 @@ camel_imap_engine_init (CamelIMAPEngine *engine, CamelIMAPEngineClass *klass)
}
static void
-imap_namespace_clear (CamelIMAPNamespace **namespace)
+imap4_namespace_clear (CamelIMAP4Namespace **namespace)
{
- CamelIMAPNamespace *node, *next;
+ CamelIMAP4Namespace *node, *next;
node = *namespace;
while (node != NULL) {
@@ -129,9 +129,9 @@ imap_namespace_clear (CamelIMAPNamespace **namespace)
}
static void
-camel_imap_engine_finalize (CamelObject *object)
+camel_imap4_engine_finalize (CamelObject *object)
{
- CamelIMAPEngine *engine = (CamelIMAPEngine *) object;
+ CamelIMAP4Engine *engine = (CamelIMAP4Engine *) object;
EDListNode *node;
if (engine->session)
@@ -146,9 +146,9 @@ camel_imap_engine_finalize (CamelObject *object)
g_hash_table_foreach (engine->authtypes, (GHFunc) g_free, NULL);
g_hash_table_destroy (engine->authtypes);
- imap_namespace_clear (&engine->namespaces.personal);
- imap_namespace_clear (&engine->namespaces.other);
- imap_namespace_clear (&engine->namespaces.shared);
+ imap4_namespace_clear (&engine->namespaces.personal);
+ imap4_namespace_clear (&engine->namespaces.other);
+ imap4_namespace_clear (&engine->namespaces.shared);
if (engine->folder)
camel_object_unref (engine->folder);
@@ -157,26 +157,26 @@ camel_imap_engine_finalize (CamelObject *object)
node->next = NULL;
node->prev = NULL;
- camel_imap_command_unref ((CamelIMAPCommand *) node);
+ camel_imap4_command_unref ((CamelIMAP4Command *) node);
}
}
/**
- * camel_imap_engine_new:
+ * camel_imap4_engine_new:
* @session: session
* @url: service url
*
- * Returns a new imap engine
+ * Returns a new imap4 engine
**/
-CamelIMAPEngine *
-camel_imap_engine_new (CamelSession *session, CamelURL *url)
+CamelIMAP4Engine *
+camel_imap4_engine_new (CamelSession *session, CamelURL *url)
{
- CamelIMAPEngine *engine;
+ CamelIMAP4Engine *engine;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
- engine = (CamelIMAPEngine *) camel_object_new (CAMEL_TYPE_IMAP_ENGINE);
+ engine = (CamelIMAP4Engine *) camel_object_new (CAMEL_TYPE_IMAP4_ENGINE);
camel_object_ref (session);
engine->session = session;
engine->url = url;
@@ -186,8 +186,8 @@ camel_imap_engine_new (CamelSession *session, CamelURL *url)
/**
- * camel_imap_engine_take_stream:
- * @engine: imap engine
+ * camel_imap4_engine_take_stream:
+ * @engine: imap4 engine
* @stream: tcp stream
* @ex: exception
*
@@ -199,12 +199,12 @@ camel_imap_engine_new (CamelSession *session, CamelURL *url)
* Note: on error, @stream will be unref'd.
**/
int
-camel_imap_engine_take_stream (CamelIMAPEngine *engine, CamelStream *stream, CamelException *ex)
+camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
int code;
- g_return_val_if_fail (CAMEL_IS_IMAP_ENGINE (engine), -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
if (engine->istream)
@@ -213,22 +213,22 @@ camel_imap_engine_take_stream (CamelIMAPEngine *engine, CamelStream *stream, Cam
if (engine->ostream)
camel_object_unref (engine->ostream);
- engine->istream = (CamelIMAPStream *) camel_imap_stream_new (stream);
+ engine->istream = (CamelIMAP4Stream *) camel_imap4_stream_new (stream);
engine->ostream = camel_stream_buffer_new (stream, CAMEL_STREAM_BUFFER_WRITE);
- engine->state = CAMEL_IMAP_ENGINE_CONNECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_CONNECTED;
camel_object_unref (stream);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
if (token.token != '*') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
- if ((code = camel_imap_engine_handle_untagged_1 (engine, &token, ex)) == -1) {
+ if ((code = camel_imap4_engine_handle_untagged_1 (engine, &token, ex)) == -1) {
goto exception;
- } else if (code != CAMEL_IMAP_UNTAGGED_OK && code != CAMEL_IMAP_UNTAGGED_PREAUTH) {
+ } else if (code != CAMEL_IMAP4_UNTAGGED_OK && code != CAMEL_IMAP4_UNTAGGED_PREAUTH) {
/* FIXME: set an error? */
goto exception;
}
@@ -237,7 +237,7 @@ camel_imap_engine_take_stream (CamelIMAPEngine *engine, CamelStream *stream, Cam
exception:
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
camel_object_unref (engine->istream);
engine->istream = NULL;
@@ -249,78 +249,78 @@ camel_imap_engine_take_stream (CamelIMAPEngine *engine, CamelStream *stream, Cam
/**
- * camel_imap_engine_capability:
- * @engine: IMAP engine
+ * camel_imap4_engine_capability:
+ * @engine: IMAP4 engine
* @ex: exception
*
- * Forces the IMAP engine to query the IMAP server for a list of capabilities.
+ * Forces the IMAP4 engine to query the IMAP4 server for a list of capabilities.
*
* Returns 0 on success or -1 on fail.
**/
int
-camel_imap_engine_capability (CamelIMAPEngine *engine, CamelException *ex)
+camel_imap4_engine_capability (CamelIMAP4Engine *engine, CamelException *ex)
{
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
int id, retval = 0;
- ic = camel_imap_engine_queue (engine, NULL, "CAPABILITY\r\n");
+ ic = camel_imap4_engine_queue (engine, NULL, "CAPABILITY\r\n");
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
retval = -1;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return retval;
}
/**
- * camel_imap_engine_namespace:
- * @engine: IMAP engine
+ * camel_imap4_engine_namespace:
+ * @engine: IMAP4 engine
* @ex: exception
*
- * Forces the IMAP engine to query the IMAP server for a list of namespaces.
+ * Forces the IMAP4 engine to query the IMAP4 server for a list of namespaces.
*
* Returns 0 on success or -1 on fail.
**/
int
-camel_imap_engine_namespace (CamelIMAPEngine *engine, CamelException *ex)
+camel_imap4_engine_namespace (CamelIMAP4Engine *engine, CamelException *ex)
{
- camel_imap_list_t *list;
+ camel_imap4_list_t *list;
GPtrArray *array = NULL;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
int id, i;
- if (engine->capa & CAMEL_IMAP_CAPABILITY_NAMESPACE) {
- ic = camel_imap_engine_queue (engine, NULL, "NAMESPACE\r\n");
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_NAMESPACE) {
+ ic = camel_imap4_engine_queue (engine, NULL, "NAMESPACE\r\n");
} else {
- ic = camel_imap_engine_queue (engine, NULL, "LIST \"\" \"\"\r\n");
- camel_imap_command_register_untagged (ic, "LIST", camel_imap_untagged_list);
+ ic = camel_imap4_engine_queue (engine, NULL, "LIST \"\" \"\"\r\n");
+ camel_imap4_command_register_untagged (ic, "LIST", camel_imap4_untagged_list);
ic->user_data = array = g_ptr_array_new ();
}
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return -1;
}
if (array != NULL) {
- if (ic->result == CAMEL_IMAP_RESULT_OK) {
- CamelIMAPNamespace *namespace;
+ if (ic->result == CAMEL_IMAP4_RESULT_OK) {
+ CamelIMAP4Namespace *namespace;
g_assert (array->len == 1);
list = array->pdata[0];
- namespace = g_new (CamelIMAPNamespace, 1);
+ namespace = g_new (CamelIMAP4Namespace, 1);
namespace->next = NULL;
namespace->path = g_strdup ("");
namespace->sep = list->delim;
@@ -339,60 +339,60 @@ camel_imap_engine_namespace (CamelIMAPEngine *engine, CamelException *ex)
g_ptr_array_free (array, TRUE);
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return 0;
}
int
-camel_imap_engine_select_folder (CamelIMAPEngine *engine, CamelFolder *folder, CamelException *ex)
+camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, CamelException *ex)
{
- CamelIMAPRespCode *resp;
- CamelIMAPCommand *ic;
+ CamelIMAP4RespCode *resp;
+ CamelIMAP4Command *ic;
int id, retval = 0;
int i;
- g_return_val_if_fail (CAMEL_IS_IMAP_ENGINE (engine), -1);
- g_return_val_if_fail (CAMEL_IS_IMAP_FOLDER (folder), -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_FOLDER (folder), -1);
/* POSSIBLE FIXME: if the folder to be selected will already
* be selected by the time the queue is emptied, simply
* no-op? */
- ic = camel_imap_engine_queue (engine, folder, "SELECT %F\r\n", folder);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (engine, folder, "SELECT %F\r\n", folder);
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return -1;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
/*folder->mode = 0;*/
for (i = 0; i < ic->resp_codes->len; i++) {
resp = ic->resp_codes->pdata[i];
switch (resp->code) {
- case CAMEL_IMAP_RESP_CODE_PERM_FLAGS:
+ case CAMEL_IMAP4_RESP_CODE_PERM_FLAGS:
folder->permanent_flags = resp->v.flags;
break;
- case CAMEL_IMAP_RESP_CODE_READONLY:
+ case CAMEL_IMAP4_RESP_CODE_READONLY:
/*folder->mode = CAMEL_FOLDER_MODE_READ_ONLY;*/
break;
- case CAMEL_IMAP_RESP_CODE_READWRITE:
+ case CAMEL_IMAP4_RESP_CODE_READWRITE:
/*folder->mode = CAMEL_FOLDER_MODE_READ_WRITE;*/
break;
- case CAMEL_IMAP_RESP_CODE_UIDNEXT:
- camel_imap_summary_set_uidnext (folder->summary, resp->v.uidnext);
+ case CAMEL_IMAP4_RESP_CODE_UIDNEXT:
+ camel_imap4_summary_set_uidnext (folder->summary, resp->v.uidnext);
break;
- case CAMEL_IMAP_RESP_CODE_UIDVALIDITY:
- camel_imap_summary_set_uidvalidity (folder->summary, resp->v.uidvalidity);
+ case CAMEL_IMAP4_RESP_CODE_UIDVALIDITY:
+ camel_imap4_summary_set_uidvalidity (folder->summary, resp->v.uidvalidity);
break;
- case CAMEL_IMAP_RESP_CODE_UNSEEN:
- camel_imap_summary_set_unseen (folder->summary, resp->v.unseen);
+ case CAMEL_IMAP4_RESP_CODE_UNSEEN:
+ camel_imap4_summary_set_unseen (folder->summary, resp->v.unseen);
break;
default:
break;
@@ -405,14 +405,14 @@ camel_imap_engine_select_folder (CamelIMAPEngine *engine, CamelFolder *folder, C
}*/
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot select folder `%s': Invalid mailbox name"),
folder->full_name);
retval = -1;
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot select folder `%s': Bad command"),
folder->full_name);
@@ -423,7 +423,7 @@ camel_imap_engine_select_folder (CamelIMAPEngine *engine, CamelFolder *folder, C
retval = -1;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return retval;
}
@@ -432,15 +432,15 @@ camel_imap_engine_select_folder (CamelIMAPEngine *engine, CamelFolder *folder, C
static struct {
const char *name;
guint32 flag;
-} imap_capabilities[] = {
- { "IMAP4", CAMEL_IMAP_CAPABILITY_IMAP4 },
- { "IMAP4REV1", CAMEL_IMAP_CAPABILITY_IMAP4REV1 },
- { "STATUS", CAMEL_IMAP_CAPABILITY_STATUS },
- { "NAMESPACE", CAMEL_IMAP_CAPABILITY_NAMESPACE },
- { "UIDPLUS", CAMEL_IMAP_CAPABILITY_UIDPLUS },
- { "LITERAL+", CAMEL_IMAP_CAPABILITY_LITERALPLUS },
- { "LOGINDISABLED", CAMEL_IMAP_CAPABILITY_LOGINDISABLED },
- { "STARTTLS", CAMEL_IMAP_CAPABILITY_STARTTLS },
+} imap4_capabilities[] = {
+ { "IMAP44", CAMEL_IMAP4_CAPABILITY_IMAP44 },
+ { "IMAP44REV1", CAMEL_IMAP4_CAPABILITY_IMAP44REV1 },
+ { "STATUS", CAMEL_IMAP4_CAPABILITY_STATUS },
+ { "NAMESPACE", CAMEL_IMAP4_CAPABILITY_NAMESPACE },
+ { "UIDPLUS", CAMEL_IMAP4_CAPABILITY_UIDPLUS },
+ { "LITERAL+", CAMEL_IMAP4_CAPABILITY_LITERALPLUS },
+ { "LOGINDISABLED", CAMEL_IMAP4_CAPABILITY_LOGINDISABLED },
+ { "STARTTLS", CAMEL_IMAP4_CAPABILITY_STARTTLS },
{ NULL, 0 }
};
@@ -452,63 +452,63 @@ auth_free (gpointer key, gpointer value, gpointer user_data)
}
static int
-engine_parse_capability (CamelIMAPEngine *engine, int sentinel, CamelException *ex)
+engine_parse_capability (CamelIMAP4Engine *engine, int sentinel, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
int i;
- engine->capa = CAMEL_IMAP_CAPABILITY_utf8_search;
+ engine->capa = CAMEL_IMAP4_CAPABILITY_utf8_search;
engine->level = 0;
g_hash_table_foreach_remove (engine->authtypes, (GHRFunc) auth_free, NULL);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- while (token.token == CAMEL_IMAP_TOKEN_ATOM) {
+ while (token.token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!strncasecmp ("AUTH=", token.v.atom, 5)) {
CamelServiceAuthType *auth;
if ((auth = camel_sasl_authtype (token.v.atom + 5)) != NULL)
g_hash_table_insert (engine->authtypes, g_strdup (token.v.atom + 5), auth);
} else {
- for (i = 0; imap_capabilities[i].name; i++) {
- if (!strcasecmp (imap_capabilities[i].name, token.v.atom))
- engine->capa |= imap_capabilities[i].flag;
+ for (i = 0; imap4_capabilities[i].name; i++) {
+ if (!strcasecmp (imap4_capabilities[i].name, token.v.atom))
+ engine->capa |= imap4_capabilities[i].flag;
}
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
}
if (token.token != sentinel) {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
/* unget our sentinel token */
- camel_imap_stream_unget_token (engine->istream, &token);
-
- /* figure out which version of IMAP we are dealing with */
- if (engine->capa & CAMEL_IMAP_CAPABILITY_IMAP4REV1) {
- engine->level = CAMEL_IMAP_LEVEL_IMAP4REV1;
- engine->capa |= CAMEL_IMAP_CAPABILITY_STATUS;
- } else if (engine->capa & CAMEL_IMAP_CAPABILITY_IMAP4) {
- engine->level = CAMEL_IMAP_LEVEL_IMAP4;
+ camel_imap4_stream_unget_token (engine->istream, &token);
+
+ /* figure out which version of IMAP4 we are dealing with */
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_IMAP44REV1) {
+ engine->level = CAMEL_IMAP4_LEVEL_IMAP44REV1;
+ engine->capa |= CAMEL_IMAP4_CAPABILITY_STATUS;
+ } else if (engine->capa & CAMEL_IMAP4_CAPABILITY_IMAP44) {
+ engine->level = CAMEL_IMAP4_LEVEL_IMAP44;
} else {
- engine->level = CAMEL_IMAP_LEVEL_UNKNOWN;
+ engine->level = CAMEL_IMAP4_LEVEL_UNKNOWN;
}
return 0;
}
static int
-engine_parse_flags_list (CamelIMAPEngine *engine, CamelIMAPRespCode *resp, int perm, CamelException *ex)
+engine_parse_flags_list (CamelIMAP4Engine *engine, CamelIMAP4RespCode *resp, int perm, CamelException *ex)
{
guint32 flags = 0;
- if (camel_imap_parse_flags_list (engine, &flags, ex) == -1)
+ if (camel_imap4_parse_flags_list (engine, &flags, ex) == -1)
return-1;
if (resp != NULL)
@@ -534,19 +534,19 @@ engine_parse_flags_list (CamelIMAPEngine *engine, CamelIMAPRespCode *resp, int p
}
static int
-engine_parse_flags (CamelIMAPEngine *engine, CamelException *ex)
+engine_parse_flags (CamelIMAP4Engine *engine, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
if (engine_parse_flags_list (engine, NULL, FALSE, ex) == -1)
return -1;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
if (token.token != '\n') {
d(fprintf (stderr, "Expected to find a '\\n' token after the FLAGS response\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -555,95 +555,95 @@ engine_parse_flags (CamelIMAPEngine *engine, CamelException *ex)
enum {
- IMAP_STATUS_MESSAGES,
- IMAP_STATUS_RECENT,
- IMAP_STATUS_UIDNEXT,
- IMAP_STATUS_UIDVALIDITY,
- IMAP_STATUS_UNSEEN,
- IMAP_STATUS_UNKNOWN
+ IMAP4_STATUS_MESSAGES,
+ IMAP4_STATUS_RECENT,
+ IMAP4_STATUS_UIDNEXT,
+ IMAP4_STATUS_UIDVALIDITY,
+ IMAP4_STATUS_UNSEEN,
+ IMAP4_STATUS_UNKNOWN
};
static struct {
const char *name;
int type;
-} imap_status[] = {
- { "MESSAGES", IMAP_STATUS_MESSAGES },
- { "RECENT", IMAP_STATUS_RECENT },
- { "UIDNEXT", IMAP_STATUS_UIDNEXT },
- { "UIDVALIDITY", IMAP_STATUS_UIDVALIDITY },
- { "UNSEEN", IMAP_STATUS_UNSEEN },
- { NULL, IMAP_STATUS_UNKNOWN },
+} imap4_status[] = {
+ { "MESSAGES", IMAP4_STATUS_MESSAGES },
+ { "RECENT", IMAP4_STATUS_RECENT },
+ { "UIDNEXT", IMAP4_STATUS_UIDNEXT },
+ { "UIDVALIDITY", IMAP4_STATUS_UIDVALIDITY },
+ { "UNSEEN", IMAP4_STATUS_UNSEEN },
+ { NULL, IMAP4_STATUS_UNKNOWN },
};
static int
-engine_parse_status (CamelIMAPEngine *engine, CamelException *ex)
+engine_parse_status (CamelIMAP4Engine *engine, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
char *mailbox;
size_t len;
int type;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
switch (token.token) {
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
mailbox = g_strdup (token.v.atom);
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
mailbox = g_strdup (token.v.qstring);
break;
- case CAMEL_IMAP_TOKEN_LITERAL:
- if (camel_imap_engine_literal (engine, (unsigned char **) &mailbox, &len, ex) == -1)
+ case CAMEL_IMAP4_TOKEN_LITERAL:
+ if (camel_imap4_engine_literal (engine, (unsigned char **) &mailbox, &len, ex) == -1)
return -1;
break;
default:
- fprintf (stderr, "Unexpected token in IMAP untagged STATUS response: %s%c\n",
- token.token == CAMEL_IMAP_TOKEN_NIL ? "NIL" : "",
+ fprintf (stderr, "Unexpected token in IMAP4 untagged STATUS response: %s%c\n",
+ token.token == CAMEL_IMAP4_TOKEN_NIL ? "NIL" : "",
(unsigned char) (token.token & 0xff));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (mailbox);
return -1;
}
if (token.token != '(') {
d(fprintf (stderr, "Expected to find a '(' token after the mailbox token in the STATUS response\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
g_free (mailbox);
return -1;
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (mailbox);
return -1;
}
- while (token.token == CAMEL_IMAP_TOKEN_ATOM) {
+ while (token.token == CAMEL_IMAP4_TOKEN_ATOM) {
const unsigned char *inptr;
unsigned int v = 0;
/* parse the status messages list */
- for (type = 0; imap_status[type].name; type++) {
- if (!strcasecmp (imap_status[type].name, token.v.atom))
+ for (type = 0; imap4_status[type].name; type++) {
+ if (!strcasecmp (imap4_status[type].name, token.v.atom))
break;
}
- if (type == IMAP_STATUS_UNKNOWN)
+ if (type == IMAP4_STATUS_UNKNOWN)
fprintf (stderr, "unrecognized token in STATUS list: %s\n", token.v.atom);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (mailbox);
return -1;
}
- if (token.token != CAMEL_IMAP_TOKEN_ATOM)
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM)
break;
- if (type == IMAP_STATUS_UIDNEXT || type == IMAP_STATUS_UIDVALIDITY) {
+ if (type == IMAP4_STATUS_UIDNEXT || type == IMAP4_STATUS_UIDVALIDITY) {
/* these tokens should be numeric, but we
* treat them as strings internally so we are
* special-casing them here */
@@ -655,25 +655,25 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex)
v = (v * 10) + (*inptr++ - '0');
if (*inptr != '\0') {
- if (type == IMAP_STATUS_UNKNOWN) {
+ if (type == IMAP4_STATUS_UNKNOWN) {
/* we'll let it slide... unget this token and continue */
- camel_imap_stream_unget_token (engine->istream, &token);
+ camel_imap4_stream_unget_token (engine->istream, &token);
goto loop;
}
d(fprintf (stderr, "Encountered non-numeric token after %s in untagged STATUS response: %s\n",
- imap_status[type].name, token.v.atom));
+ imap4_status[type].name, token.v.atom));
goto loop;
}
switch (type) {
- case IMAP_STATUS_MESSAGES:
+ case IMAP4_STATUS_MESSAGES:
/* FIXME: save value */
break;
- case IMAP_STATUS_RECENT:
+ case IMAP4_STATUS_RECENT:
/* FIXME: save value */
break;
- case IMAP_STATUS_UNSEEN:
+ case IMAP4_STATUS_UNSEEN:
/* FIXME: save value */
break;
default:
@@ -682,7 +682,7 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex)
}
loop:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (mailbox);
return -1;
}
@@ -693,16 +693,16 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex)
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' token terminating the untagged STATUS response\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
if (token.token != '\n') {
d(fprintf (stderr, "Expected to find a '\\n' token after the STATUS response\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -710,56 +710,56 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex)
}
static int
-engine_parse_namespace (CamelIMAPEngine *engine, CamelException *ex)
+engine_parse_namespace (CamelIMAP4Engine *engine, CamelException *ex)
{
- CamelIMAPNamespace *namespaces[3], *node, *tail;
- camel_imap_token_t token;
+ CamelIMAP4Namespace *namespaces[3], *node, *tail;
+ camel_imap4_token_t token;
int i, n = 0;
- imap_namespace_clear (&engine->namespaces.personal);
- imap_namespace_clear (&engine->namespaces.other);
- imap_namespace_clear (&engine->namespaces.shared);
+ imap4_namespace_clear (&engine->namespaces.personal);
+ imap4_namespace_clear (&engine->namespaces.other);
+ imap4_namespace_clear (&engine->namespaces.shared);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
do {
namespaces[n] = NULL;
- tail = (CamelIMAPNamespace *) &namespaces[n];
+ tail = (CamelIMAP4Namespace *) &namespaces[n];
if (token.token == '(') {
/* decode the list of namespace pairs */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
while (token.token == '(') {
/* decode a namespace pair */
/* get the path name token */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
- if (token.token != CAMEL_IMAP_TOKEN_QSTRING) {
+ if (token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected to find a qstring token as first element in NAMESPACE pair\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
- node = g_new (CamelIMAPNamespace, 1);
+ node = g_new (CamelIMAP4Namespace, 1);
node->next = NULL;
node->path = g_strdup (token.v.qstring);
/* get the path delimiter token */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (node->path);
g_free (node);
goto exception;
}
- if (token.token != CAMEL_IMAP_TOKEN_QSTRING || strlen (token.v.qstring) > 1) {
+ if (token.token != CAMEL_IMAP4_TOKEN_QSTRING || strlen (token.v.qstring) > 1) {
d(fprintf (stderr, "Expected to find a qstring token as second element in NAMESPACE pair\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
g_free (node->path);
g_free (node);
@@ -774,38 +774,43 @@ engine_parse_namespace (CamelIMAPEngine *engine, CamelException *ex)
if (node->path[strlen (node->path) - 1] == node->sep)
node->path[strlen (node->path) - 1] = '\0';
+ /* canonicalise if this is an INBOX namespace */
+ if (!g_ascii_strncasecmp (node->path, "INBOX", 5) &&
+ (node->path[6] == '\0' || node->path[6] == node->sep))
+ memcpy (node->path, "INBOX", 5);
+
/* get the closing ')' for this namespace pair */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' token to close the current namespace pair\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
/* get the next token (should be either '(' or ')') */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' to close the current namespace list\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
- } else if (token.token == CAMEL_IMAP_TOKEN_NIL) {
+ } else if (token.token == CAMEL_IMAP4_TOKEN_NIL) {
/* namespace list is NIL */
namespaces[n] = NULL;
} else {
d(fprintf (stderr, "Expected to find either NIL or '(' token in untagged NAMESPACE response\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
/* get the next token (should be either '(', NIL, or '\n') */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
n++;
@@ -820,7 +825,7 @@ engine_parse_namespace (CamelIMAPEngine *engine, CamelException *ex)
exception:
for (i = 0; i <= n; i++)
- imap_namespace_clear (&namespaces[i]);
+ imap4_namespace_clear (&namespaces[i]);
return -1;
}
@@ -840,58 +845,58 @@ engine_parse_namespace (CamelIMAPEngine *engine, CamelException *ex)
static struct {
const char *name;
- camel_imap_resp_code_t code;
+ camel_imap4_resp_code_t code;
int save;
-} imap_resp_codes[] = {
- { "ALERT", CAMEL_IMAP_RESP_CODE_ALERT, 0 },
- { "BADCHARSET", CAMEL_IMAP_RESP_CODE_BADCHARSET, 0 },
- { "CAPABILITY", CAMEL_IMAP_RESP_CODE_CAPABILITY, 0 },
- { "PARSE", CAMEL_IMAP_RESP_CODE_PARSE, 1 },
- { "PERMANENTFLAGS", CAMEL_IMAP_RESP_CODE_PERM_FLAGS, 1 },
- { "READ-ONLY", CAMEL_IMAP_RESP_CODE_READONLY, 1 },
- { "READ-WRITE", CAMEL_IMAP_RESP_CODE_READWRITE, 1 },
- { "TRYCREATE", CAMEL_IMAP_RESP_CODE_TRYCREATE, 1 },
- { "UIDNEXT", CAMEL_IMAP_RESP_CODE_UIDNEXT, 1 },
- { "UIDVALIDITY", CAMEL_IMAP_RESP_CODE_UIDVALIDITY, 1 },
- { "UNSEEN", CAMEL_IMAP_RESP_CODE_UNSEEN, 1 },
- { "NEWNAME", CAMEL_IMAP_RESP_CODE_NEWNAME, 1 },
- { "APPENDUID", CAMEL_IMAP_RESP_CODE_APPENDUID, 1 },
- { "COPYUID", CAMEL_IMAP_RESP_CODE_COPYUID, 1 },
- { NULL, CAMEL_IMAP_RESP_CODE_UNKNOWN, 0 }
+} imap4_resp_codes[] = {
+ { "ALERT", CAMEL_IMAP4_RESP_CODE_ALERT, 0 },
+ { "BADCHARSET", CAMEL_IMAP4_RESP_CODE_BADCHARSET, 0 },
+ { "CAPABILITY", CAMEL_IMAP4_RESP_CODE_CAPABILITY, 0 },
+ { "PARSE", CAMEL_IMAP4_RESP_CODE_PARSE, 1 },
+ { "PERMANENTFLAGS", CAMEL_IMAP4_RESP_CODE_PERM_FLAGS, 1 },
+ { "READ-ONLY", CAMEL_IMAP4_RESP_CODE_READONLY, 1 },
+ { "READ-WRITE", CAMEL_IMAP4_RESP_CODE_READWRITE, 1 },
+ { "TRYCREATE", CAMEL_IMAP4_RESP_CODE_TRYCREATE, 1 },
+ { "UIDNEXT", CAMEL_IMAP4_RESP_CODE_UIDNEXT, 1 },
+ { "UIDVALIDITY", CAMEL_IMAP4_RESP_CODE_UIDVALIDITY, 1 },
+ { "UNSEEN", CAMEL_IMAP4_RESP_CODE_UNSEEN, 1 },
+ { "NEWNAME", CAMEL_IMAP4_RESP_CODE_NEWNAME, 1 },
+ { "APPENDUID", CAMEL_IMAP4_RESP_CODE_APPENDUID, 1 },
+ { "COPYUID", CAMEL_IMAP4_RESP_CODE_COPYUID, 1 },
+ { NULL, CAMEL_IMAP4_RESP_CODE_UNKNOWN, 0 }
};
int
-camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
+camel_imap4_engine_parse_resp_code (CamelIMAP4Engine *engine, CamelException *ex)
{
- CamelIMAPRespCode *resp = NULL;
- camel_imap_resp_code_t code;
- camel_imap_token_t token;
+ CamelIMAP4RespCode *resp = NULL;
+ camel_imap4_resp_code_t code;
+ camel_imap4_token_t token;
unsigned char *linebuf;
size_t len;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
if (token.token != '[') {
d(fprintf (stderr, "Expected a '[' token (followed by a RESP-CODE)\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_ATOM) {
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM) {
d(fprintf (stderr, "Expected an atom token containing a RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
- for (code = 0; imap_resp_codes[code].name; code++) {
- if (!strcmp (imap_resp_codes[code].name, token.v.atom)) {
- if (engine->current && imap_resp_codes[code].save) {
- resp = g_new0 (CamelIMAPRespCode, 1);
+ for (code = 0; imap4_resp_codes[code].name; code++) {
+ if (!strcmp (imap4_resp_codes[code].name, token.v.atom)) {
+ if (engine->current && imap4_resp_codes[code].save) {
+ resp = g_new0 (CamelIMAP4RespCode, 1);
resp->code = code;
}
break;
@@ -899,33 +904,33 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
}
switch (code) {
- case CAMEL_IMAP_RESP_CODE_BADCHARSET:
+ case CAMEL_IMAP4_RESP_CODE_BADCHARSET:
/* apparently we don't support UTF-8 afterall */
- engine->capa &= ~CAMEL_IMAP_CAPABILITY_utf8_search;
+ engine->capa &= ~CAMEL_IMAP4_CAPABILITY_utf8_search;
break;
- case CAMEL_IMAP_RESP_CODE_CAPABILITY:
+ case CAMEL_IMAP4_RESP_CODE_CAPABILITY:
/* capability list follows */
if (engine_parse_capability (engine, ']', ex) == -1)
goto exception;
break;
- case CAMEL_IMAP_RESP_CODE_PERM_FLAGS:
+ case CAMEL_IMAP4_RESP_CODE_PERM_FLAGS:
/* flag list follows */
if (engine_parse_flags_list (engine, resp, TRUE, ex) == -1)
goto exception;
break;
- case CAMEL_IMAP_RESP_CODE_READONLY:
+ case CAMEL_IMAP4_RESP_CODE_READONLY:
break;
- case CAMEL_IMAP_RESP_CODE_READWRITE:
+ case CAMEL_IMAP4_RESP_CODE_READWRITE:
break;
- case CAMEL_IMAP_RESP_CODE_TRYCREATE:
+ case CAMEL_IMAP4_RESP_CODE_TRYCREATE:
break;
- case CAMEL_IMAP_RESP_CODE_UIDNEXT:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ case CAMEL_IMAP4_RESP_CODE_UIDNEXT:
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UIDNEXT RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -933,13 +938,13 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
resp->v.uidnext = token.v.number;
break;
- case CAMEL_IMAP_RESP_CODE_UIDVALIDITY:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ case CAMEL_IMAP4_RESP_CODE_UIDVALIDITY:
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UIDVALIDITY RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -947,13 +952,13 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
resp->v.uidvalidity = token.v.number;
break;
- case CAMEL_IMAP_RESP_CODE_UNSEEN:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ case CAMEL_IMAP4_RESP_CODE_UNSEEN:
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UNSEEN RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -961,25 +966,25 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
resp->v.unseen = token.v.number;
break;
- case CAMEL_IMAP_RESP_CODE_NEWNAME:
+ case CAMEL_IMAP4_RESP_CODE_NEWNAME:
/* this RESP-CODE may actually be removed - see here:
- * http://www.washington.edu/imap/listarch/2001/msg00058.html */
+ * http://www.washington.edu/imap4/listarch/2001/msg00058.html */
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_ATOM && token.token != CAMEL_IMAP_TOKEN_QSTRING) {
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected an atom or qstring token as the first argument to the NEWNAME RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
if (resp != NULL)
resp->v.newname[0] = g_strdup (token.v.atom);
- if (token.token != CAMEL_IMAP_TOKEN_ATOM && token.token != CAMEL_IMAP_TOKEN_QSTRING) {
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected an atom or qstring token as the second argument to the NEWNAME RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -987,25 +992,25 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
resp->v.newname[1] = g_strdup (token.v.atom);
break;
- case CAMEL_IMAP_RESP_CODE_APPENDUID:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ case CAMEL_IMAP4_RESP_CODE_APPENDUID:
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the first argument to the APPENDUID RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
if (resp != NULL)
resp->v.appenduid.uidvalidity = token.v.number;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the second argument to the APPENDUID RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -1013,37 +1018,37 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
resp->v.appenduid.uid = token.v.number;
break;
- case CAMEL_IMAP_RESP_CODE_COPYUID:
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ case CAMEL_IMAP4_RESP_CODE_COPYUID:
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_NUMBER) {
+ if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the first argument to the COPYUID RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
if (resp != NULL)
resp->v.copyuid.uidvalidity = token.v.number;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_ATOM) {
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM) {
d(fprintf (stderr, "Expected an atom token as the second argument to the COPYUID RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
if (resp != NULL)
resp->v.copyuid.srcset = g_strdup (token.v.atom);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token != CAMEL_IMAP_TOKEN_ATOM) {
+ if (token.token != CAMEL_IMAP4_TOKEN_ATOM) {
d(fprintf (stderr, "Expected an atom token as the third argument to the APPENDUID RESP-CODE\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
@@ -1058,7 +1063,7 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
/* eat up the TEXT_CHARs */
while (token.token != ']' && token.token != '\n') {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
@@ -1066,30 +1071,30 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
}
while (token.token != ']' && token.token != '\n') {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
if (token.token != ']') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
d(fprintf (stderr, "Expected to find a ']' token after the RESP-CODE\n"));
return -1;
}
- if (code == CAMEL_IMAP_RESP_CODE_ALERT) {
- if (camel_imap_engine_line (engine, &linebuf, &len, ex) == -1)
+ if (code == CAMEL_IMAP4_RESP_CODE_ALERT) {
+ if (camel_imap4_engine_line (engine, &linebuf, &len, ex) == -1)
goto exception;
camel_session_alert_user (engine->session, CAMEL_SESSION_ALERT_INFO, linebuf, FALSE);
g_free (linebuf);
- } else if (resp != NULL && code == CAMEL_IMAP_RESP_CODE_PARSE) {
- if (camel_imap_engine_line (engine, &linebuf, &len, ex) == -1)
+ } else if (resp != NULL && code == CAMEL_IMAP4_RESP_CODE_PARSE) {
+ if (camel_imap4_engine_line (engine, &linebuf, &len, ex) == -1)
goto exception;
resp->v.parse = linebuf;
} else {
/* eat up the rest of the response */
- if (camel_imap_engine_line (engine, NULL, NULL, ex) == -1)
+ if (camel_imap4_engine_line (engine, NULL, NULL, ex) == -1)
goto exception;
}
@@ -1101,38 +1106,38 @@ camel_imap_engine_parse_resp_code (CamelIMAPEngine *engine, CamelException *ex)
exception:
if (resp != NULL)
- camel_imap_resp_code_free (resp);
+ camel_imap4_resp_code_free (resp);
return -1;
}
-/* returns -1 on error, or one of CAMEL_IMAP_UNTAGGED_[OK,NO,BAD,PREAUTH,HANDLED] on success */
+/* returns -1 on error, or one of CAMEL_IMAP4_UNTAGGED_[OK,NO,BAD,PREAUTH,HANDLED] on success */
int
-camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t *token, CamelException *ex)
+camel_imap4_engine_handle_untagged_1 (CamelIMAP4Engine *engine, camel_imap4_token_t *token, CamelException *ex)
{
- int code = CAMEL_IMAP_UNTAGGED_HANDLED;
- CamelIMAPCommand *ic = engine->current;
- CamelIMAPUntaggedCallback untagged;
+ int code = CAMEL_IMAP4_UNTAGGED_HANDLED;
+ CamelIMAP4Command *ic = engine->current;
+ CamelIMAP4UntaggedCallback untagged;
CamelFolder *folder;
unsigned int v;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
- if (token->token == CAMEL_IMAP_TOKEN_ATOM) {
+ if (token->token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!strcmp ("BYE", token->v.atom)) {
/* we don't care if we fail here, either way we've been disconnected */
- camel_imap_engine_parse_resp_code (engine, NULL);
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
+ camel_imap4_engine_parse_resp_code (engine, NULL);
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
/* FIXME: emit a "disconnected" signal for our Store?
* The Store could then initiate a reconnect if
* desirable. */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("IMAP server %s unexpectedly disconnected: %s"),
+ _("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, _("Got BYE response"));
return -1;
@@ -1142,11 +1147,11 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
return -1;
/* find the eoln token */
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
if (token->token != '\n') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
} else if (!strcmp ("FLAGS", token->v.atom)) {
@@ -1157,50 +1162,50 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
if (engine_parse_namespace (engine, ex) == -1)
return -1;
} else if (!strcmp ("NO", token->v.atom) || !strcmp ("BAD", token->v.atom)) {
- code = !strcmp ("NO", token->v.atom) ? CAMEL_IMAP_UNTAGGED_NO : CAMEL_IMAP_UNTAGGED_BAD;
+ code = !strcmp ("NO", token->v.atom) ? CAMEL_IMAP4_UNTAGGED_NO : CAMEL_IMAP4_UNTAGGED_BAD;
/* our command has been rejected */
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
if (token->token == '[') {
/* we have a resp code */
- camel_imap_stream_unget_token (engine->istream, token);
- if (camel_imap_engine_parse_resp_code (engine, ex) == -1)
+ camel_imap4_stream_unget_token (engine->istream, token);
+ if (camel_imap4_engine_parse_resp_code (engine, ex) == -1)
return -1;
} else if (token->token != '\n') {
/* we just have resp text */
- if (camel_imap_engine_line (engine, NULL, NULL, ex) == -1)
+ if (camel_imap4_engine_line (engine, NULL, NULL, ex) == -1)
return -1;
}
} else if (!strcmp ("OK", token->v.atom)) {
- code = CAMEL_IMAP_UNTAGGED_OK;
+ code = CAMEL_IMAP4_UNTAGGED_OK;
- if (engine->state == CAMEL_IMAP_ENGINE_CONNECTED) {
+ if (engine->state == CAMEL_IMAP4_ENGINE_CONNECTED) {
/* initial server greeting */
- engine->state = CAMEL_IMAP_ENGINE_PREAUTH;
+ engine->state = CAMEL_IMAP4_ENGINE_PREAUTH;
}
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
if (token->token == '[') {
/* we have a resp code */
- camel_imap_stream_unget_token (engine->istream, token);
- if (camel_imap_engine_parse_resp_code (engine, ex) == -1)
+ camel_imap4_stream_unget_token (engine->istream, token);
+ if (camel_imap4_engine_parse_resp_code (engine, ex) == -1)
return -1;
} else {
/* we just have resp text */
- if (camel_imap_engine_line (engine, NULL, NULL, ex) == -1)
+ if (camel_imap4_engine_line (engine, NULL, NULL, ex) == -1)
return -1;
}
} else if (!strcmp ("PREAUTH", token->v.atom)) {
- code = CAMEL_IMAP_UNTAGGED_PREAUTH;
+ code = CAMEL_IMAP4_UNTAGGED_PREAUTH;
- if (engine->state == CAMEL_IMAP_ENGINE_CONNECTED)
- engine->state = CAMEL_IMAP_ENGINE_AUTHENTICATED;
+ if (engine->state == CAMEL_IMAP4_ENGINE_CONNECTED)
+ engine->state = CAMEL_IMAP4_ENGINE_AUTHENTICATED;
- if (camel_imap_engine_parse_resp_code (engine, ex) == -1)
+ if (camel_imap4_engine_parse_resp_code (engine, ex) == -1)
return -1;
} else if (!strcmp ("STATUS", token->v.atom)) {
/* FIXME: This should probably be removed... leave it
@@ -1211,24 +1216,24 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
if (engine_parse_status (engine, ex) == -1)
return -1;
} else if (ic && (untagged = g_hash_table_lookup (ic->untagged, token->v.atom))) {
- /* registered untagged handler for imap command */
+ /* registered untagged handler for imap4 command */
if (untagged (engine, ic, 0, token, ex) == -1)
return -1;
} else {
d(fprintf (stderr, "Unhandled atom token in untagged response: %s", token->v.atom));
- if (camel_imap_engine_eat_line (engine, ex) == -1)
+ if (camel_imap4_engine_eat_line (engine, ex) == -1)
return -1;
}
- } else if (token->token == CAMEL_IMAP_TOKEN_NUMBER) {
+ } else if (token->token == CAMEL_IMAP4_TOKEN_NUMBER) {
/* we probably have something like "* 1 EXISTS" */
v = token->v.number;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
- if (token->token != CAMEL_IMAP_TOKEN_ATOM) {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ if (token->token != CAMEL_IMAP4_TOKEN_ATOM) {
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
@@ -1243,13 +1248,13 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
/* NOTE: these can be over-ridden by a registered untagged response handler */
if (!strcmp ("EXISTS", token->v.atom)) {
- camel_imap_summary_set_exists (folder->summary, v);
+ camel_imap4_summary_set_exists (folder->summary, v);
} else if (!strcmp ("EXPUNGE", token->v.atom)) {
- camel_imap_summary_expunge (folder->summary, (int) v);
+ camel_imap4_summary_expunge (folder->summary, (int) v);
} else if (!strcmp ("RECENT", token->v.atom)) {
- camel_imap_summary_set_recent (folder->summary, v);
+ camel_imap4_summary_set_recent (folder->summary, v);
} else if (ic && (untagged = g_hash_table_lookup (ic->untagged, token->v.atom))) {
- /* registered untagged handler for imap command */
+ /* registered untagged handler for imap4 command */
if (untagged (engine, ic, v, token, ex) == -1)
return -1;
} else {
@@ -1257,10 +1262,10 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
}
/* find the eoln token */
- if (camel_imap_engine_eat_line (engine, ex) == -1)
+ if (camel_imap4_engine_eat_line (engine, ex) == -1)
return -1;
} else {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
@@ -1270,43 +1275,43 @@ camel_imap_engine_handle_untagged_1 (CamelIMAPEngine *engine, camel_imap_token_t
void
-camel_imap_engine_handle_untagged (CamelIMAPEngine *engine, CamelException *ex)
+camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
- g_return_if_fail (CAMEL_IS_IMAP_ENGINE (engine));
+ g_return_if_fail (CAMEL_IS_IMAP4_ENGINE (engine));
do {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
if (token.token != '*')
break;
- if (camel_imap_engine_handle_untagged_1 (engine, &token, ex) == -1)
+ if (camel_imap4_engine_handle_untagged_1 (engine, &token, ex) == -1)
goto exception;
} while (1);
- camel_imap_stream_unget_token (engine->istream, &token);
+ camel_imap4_stream_unget_token (engine->istream, &token);
return;
exception:
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
}
static int
-imap_process_command (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
+imap4_process_command (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
int retval;
- while ((retval = camel_imap_command_step (ic)) == 0)
+ while ((retval = camel_imap4_command_step (ic)) == 0)
;
if (retval == -1) {
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
return -1;
}
@@ -1315,12 +1320,12 @@ imap_process_command (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
static void
-engine_prequeue_folder_select (CamelIMAPEngine *engine)
+engine_prequeue_folder_select (CamelIMAP4Engine *engine)
{
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
const char *cmd;
- ic = (CamelIMAPCommand *) engine->queue.head;
+ ic = (CamelIMAP4Command *) engine->queue.head;
cmd = (const char *) ic->parts->buffer;
if (!ic->folder || ic->folder == engine->folder ||
@@ -1330,47 +1335,47 @@ engine_prequeue_folder_select (CamelIMAPEngine *engine)
}
/* we need to pre-queue a SELECT */
- ic = camel_imap_command_new (engine, ic->folder, "SELECT %F\r\n", ic->folder);
- camel_imap_engine_prequeue (engine, ic);
+ ic = camel_imap4_command_new (engine, ic->folder, "SELECT %F\r\n", ic->folder);
+ camel_imap4_engine_prequeue (engine, ic);
ic->user_data = engine;
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
static int
-engine_state_change (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
+engine_state_change (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
const char *cmd;
int retval = 0;
cmd = ic->parts->buffer;
if (!strncmp (cmd, "SELECT ", 7) || !strncmp (cmd, "EXAMINE ", 8)) {
- if (ic->result == CAMEL_IMAP_RESULT_OK) {
+ if (ic->result == CAMEL_IMAP4_RESULT_OK) {
/* Update the selected folder */
camel_object_ref (ic->folder);
if (engine->folder)
camel_object_unref (engine->folder);
engine->folder = ic->folder;
- engine->state = CAMEL_IMAP_ENGINE_SELECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_SELECTED;
} else if (ic->user_data == engine) {
/* the engine pre-queued this SELECT command */
retval = -1;
}
} else if (!strncmp (cmd, "CLOSE", 5)) {
- if (ic->result == CAMEL_IMAP_RESULT_OK)
- engine->state = CAMEL_IMAP_ENGINE_AUTHENTICATED;
+ if (ic->result == CAMEL_IMAP4_RESULT_OK)
+ engine->state = CAMEL_IMAP4_ENGINE_AUTHENTICATED;
} else if (!strncmp (cmd, "LOGOUT", 6)) {
- engine->state = CAMEL_IMAP_ENGINE_DISCONNECTED;
+ engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
}
return retval;
}
/**
- * camel_imap_engine_iterate:
- * @engine: IMAP engine
+ * camel_imap4_engine_iterate:
+ * @engine: IMAP4 engine
*
* Processes the first command in the queue.
*
@@ -1378,12 +1383,12 @@ engine_state_change (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
* commands to process, or -1 on error.
*
* Note: more details on the error will be held on the
- * CamelIMAPCommand that failed.
+ * CamelIMAP4Command that failed.
**/
int
-camel_imap_engine_iterate (CamelIMAPEngine *engine)
+camel_imap4_engine_iterate (CamelIMAP4Engine *engine)
{
- CamelIMAPCommand *ic, *nic;
+ CamelIMAP4Command *ic, *nic;
GPtrArray *resp_codes;
int retval = -1;
@@ -1393,21 +1398,21 @@ camel_imap_engine_iterate (CamelIMAPEngine *engine)
/* check to see if we need to pre-queue a SELECT, if so do it */
engine_prequeue_folder_select (engine);
- engine->current = ic = (CamelIMAPCommand *) e_dlist_remhead (&engine->queue);
- ic->status = CAMEL_IMAP_COMMAND_ACTIVE;
+ engine->current = ic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue);
+ ic->status = CAMEL_IMAP4_COMMAND_ACTIVE;
- if (imap_process_command (engine, ic) != -1) {
+ if (imap4_process_command (engine, ic) != -1) {
if (engine_state_change (engine, ic) == -1) {
/* This can ONLY happen if @ic was the pre-queued SELECT command
* and it got a NO or BAD response.
*
- * We have to pop the next imap command or we'll get into an
+ * We have to pop the next imap4 command or we'll get into an
* infinite loop. In order to provide @nic's owner with as much
* information as possible, we move all @ic status information
* over to @nic and pretend we just processed @nic.
**/
- nic = (CamelIMAPCommand *) e_dlist_remhead (&engine->queue);
+ nic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue);
nic->status = ic->status;
nic->result = ic->result;
@@ -1417,81 +1422,81 @@ camel_imap_engine_iterate (CamelIMAPEngine *engine)
camel_exception_xfer (&nic->ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
ic = nic;
}
retval = ic->id;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return retval;
}
/**
- * camel_imap_engine_queue:
- * @engine: IMAP engine
- * @folder: IMAP folder that the command will affect (or %NULL if it doesn't matter)
+ * camel_imap4_engine_queue:
+ * @engine: IMAP4 engine
+ * @folder: IMAP4 folder that the command will affect (or %NULL if it doesn't matter)
* @format: command format
* @Varargs: arguments
*
- * Basically the same as #camel_imap_command_new() except that this
+ * Basically the same as #camel_imap4_command_new() except that this
* function also places the command in the engine queue.
*
- * Returns the CamelIMAPCommand.
+ * Returns the CamelIMAP4Command.
**/
-CamelIMAPCommand *
-camel_imap_engine_queue (CamelIMAPEngine *engine, CamelFolder *folder, const char *format, ...)
+CamelIMAP4Command *
+camel_imap4_engine_queue (CamelIMAP4Engine *engine, CamelFolder *folder, const char *format, ...)
{
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
va_list args;
va_start (args, format);
- ic = camel_imap_command_newv (engine, (CamelIMAPFolder *) folder, format, args);
+ ic = camel_imap4_command_newv (engine, (CamelIMAP4Folder *) folder, format, args);
va_end (args);
ic->id = engine->nextid++;
e_dlist_addtail (&engine->queue, (EDListNode *) ic);
- camel_imap_command_ref (ic);
+ camel_imap4_command_ref (ic);
return ic;
}
/**
- * camel_imap_engine_prequeue:
- * @engine: IMAP engine
- * @ic: IMAP command to pre-queue
+ * camel_imap4_engine_prequeue:
+ * @engine: IMAP4 engine
+ * @ic: IMAP4 command to pre-queue
*
- * Places @ic at the head of the queue of pending IMAP commands.
+ * Places @ic at the head of the queue of pending IMAP4 commands.
**/
void
-camel_imap_engine_prequeue (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
+camel_imap4_engine_prequeue (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
- g_return_if_fail (CAMEL_IS_IMAP_ENGINE (engine));
+ g_return_if_fail (CAMEL_IS_IMAP4_ENGINE (engine));
g_return_if_fail (ic != NULL);
- camel_imap_command_ref (ic);
+ camel_imap4_command_ref (ic);
if (e_dlist_empty (&engine->queue)) {
e_dlist_addtail (&engine->queue, (EDListNode *) ic);
ic->id = engine->nextid++;
} else {
- CamelIMAPCommand *nic;
+ CamelIMAP4Command *nic;
EDListNode *node;
node = (EDListNode *) ic;
e_dlist_addhead (&engine->queue, node);
- nic = (CamelIMAPCommand *) node->next;
+ nic = (CamelIMAP4Command *) node->next;
ic->id = nic->id - 1;
if (ic->id == 0) {
/* increment all command ids */
node = engine->queue.head;
while (node->next) {
- nic = (CamelIMAPCommand *) node;
+ nic = (CamelIMAP4Command *) node;
node = node->next;
nic->id++;
}
@@ -1501,7 +1506,7 @@ camel_imap_engine_prequeue (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
void
-camel_imap_engine_dequeue (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
+camel_imap4_engine_dequeue (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
EDListNode *node = (EDListNode *) ic;
@@ -1512,16 +1517,16 @@ camel_imap_engine_dequeue (CamelIMAPEngine *engine, CamelIMAPCommand *ic)
node->next = NULL;
node->prev = NULL;
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
int
-camel_imap_engine_next_token (CamelIMAPEngine *engine, camel_imap_token_t *token, CamelException *ex)
+camel_imap4_engine_next_token (CamelIMAP4Engine *engine, camel_imap4_token_t *token, CamelException *ex)
{
- if (camel_imap_stream_next_token (engine->istream, token) == -1) {
+ if (camel_imap4_stream_next_token (engine->istream, token) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("IMAP server %s unexpectedly disconnected: %s"),
+ _("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
return -1;
}
@@ -1531,24 +1536,24 @@ camel_imap_engine_next_token (CamelIMAPEngine *engine, camel_imap_token_t *token
int
-camel_imap_engine_eat_line (CamelIMAPEngine *engine, CamelException *ex)
+camel_imap4_engine_eat_line (CamelIMAP4Engine *engine, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
unsigned char *literal;
int retval;
size_t n;
do {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token == CAMEL_IMAP_TOKEN_LITERAL) {
- while ((retval = camel_imap_stream_literal (engine->istream, &literal, &n)) == 1)
+ if (token.token == CAMEL_IMAP4_TOKEN_LITERAL) {
+ while ((retval = camel_imap4_stream_literal (engine->istream, &literal, &n)) == 1)
;
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("IMAP server %s unexpectedly disconnected: %s"),
+ _("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
return -1;
@@ -1561,7 +1566,7 @@ camel_imap_engine_eat_line (CamelIMAPEngine *engine, CamelException *ex)
int
-camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *len, CamelException *ex)
+camel_imap4_engine_line (CamelIMAP4Engine *engine, unsigned char **line, size_t *len, CamelException *ex)
{
GByteArray *linebuf = NULL;
unsigned char *buf;
@@ -1571,14 +1576,14 @@ camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *l
if (line != NULL)
linebuf = g_byte_array_new ();
- while ((retval = camel_imap_stream_line (engine->istream, &buf, &buflen)) > 0) {
+ while ((retval = camel_imap4_stream_line (engine->istream, &buf, &buflen)) > 0) {
if (linebuf != NULL)
g_byte_array_append (linebuf, buf, buflen);
}
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("IMAP server %s unexpectedly disconnected: %s"),
+ _("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
if (linebuf != NULL)
@@ -1601,7 +1606,7 @@ camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *l
int
-camel_imap_engine_literal (CamelIMAPEngine *engine, unsigned char **literal, size_t *len, CamelException *ex)
+camel_imap4_engine_literal (CamelIMAP4Engine *engine, unsigned char **literal, size_t *len, CamelException *ex)
{
GByteArray *literalbuf = NULL;
unsigned char *buf;
@@ -1611,14 +1616,14 @@ camel_imap_engine_literal (CamelIMAPEngine *engine, unsigned char **literal, siz
if (literal != NULL)
literalbuf = g_byte_array_new ();
- while ((retval = camel_imap_stream_literal (engine->istream, &buf, &buflen)) > 0) {
+ while ((retval = camel_imap4_stream_literal (engine->istream, &buf, &buflen)) > 0) {
if (literalbuf != NULL)
g_byte_array_append (literalbuf, buf, buflen);
}
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("IMAP server %s unexpectedly disconnected: %s"),
+ _("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
if (literalbuf != NULL)
@@ -1642,17 +1647,17 @@ camel_imap_engine_literal (CamelIMAPEngine *engine, unsigned char **literal, siz
void
-camel_imap_resp_code_free (CamelIMAPRespCode *rcode)
+camel_imap4_resp_code_free (CamelIMAP4RespCode *rcode)
{
switch (rcode->code) {
- case CAMEL_IMAP_RESP_CODE_PARSE:
+ case CAMEL_IMAP4_RESP_CODE_PARSE:
g_free (rcode->v.parse);
break;
- case CAMEL_IMAP_RESP_CODE_NEWNAME:
+ case CAMEL_IMAP4_RESP_CODE_NEWNAME:
g_free (rcode->v.newname[0]);
g_free (rcode->v.newname[1]);
break;
- case CAMEL_IMAP_RESP_CODE_COPYUID:
+ case CAMEL_IMAP4_RESP_CODE_COPYUID:
g_free (rcode->v.copyuid.srcset);
g_free (rcode->v.copyuid.destset);
break;
diff --git a/camel/providers/imap4/camel-imap4-engine.h b/camel/providers/imap4/camel-imap4-engine.h
new file mode 100644
index 0000000000..25ae7ed113
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-engine.h
@@ -0,0 +1,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__ */
diff --git a/camel/providers/imap4/camel-imap-folder.c b/camel/providers/imap4/camel-imap4-folder.c
index 04af9f3cb8..2169f053ce 100644
--- a/camel/providers/imap4/camel-imap-folder.c
+++ b/camel/providers/imap4/camel-imap4-folder.c
@@ -22,6 +22,8 @@
#include <config.h>
#endif
+#include <glib.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,90 +35,180 @@
#include <errno.h>
#include <time.h>
+#include <camel/camel-utf8.h>
#include <camel/camel-file-utils.h>
#include <camel/camel-mime-message.h>
#include <camel/camel-stream-mem.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-crlf.h>
-#include "camel-imap-utils.h"
-#include "camel-imap-store.h"
-#include "camel-imap-engine.h"
-#include "camel-imap-folder.h"
-#include "camel-imap-stream.h"
-#include "camel-imap-command.h"
-#include "camel-imap-summary.h"
+#include "camel-imap4-utils.h"
+#include "camel-imap4-store.h"
+#include "camel-imap4-engine.h"
+#include "camel-imap4-folder.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-command.h"
+#include "camel-imap4-summary.h"
#define d(x) x
-static void camel_imap_folder_class_init (CamelIMAPFolderClass *klass);
-static void camel_imap_folder_init (CamelIMAPFolder *folder, CamelIMAPFolderClass *klass);
-static void camel_imap_folder_finalize (CamelObject *object);
+static void camel_imap4_folder_class_init (CamelIMAP4FolderClass *klass);
+static void camel_imap4_folder_init (CamelIMAP4Folder *folder, CamelIMAP4FolderClass *klass);
+static void camel_imap4_folder_finalize (CamelObject *object);
-static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static void imap_expunge (CamelFolder *folder, CamelException *ex);
-static CamelMimeMessage *imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex);
-static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
- const CamelMessageInfo *info, char **appended_uid, CamelException *ex);
-static void imap_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
- GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
+static void imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
+static void imap4_expunge (CamelFolder *folder, CamelException *ex);
+static CamelMimeMessage *imap4_get_message (CamelFolder *folder, const char *uid, CamelException *ex);
+static void imap4_append_message (CamelFolder *folder, CamelMimeMessage *message,
+ const CamelMessageInfo *info, char **appended_uid, CamelException *ex);
+static void imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
+ GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
static CamelFolderClass *parent_class = NULL;
CamelType
-camel_imap_folder_get_type (void)
+camel_imap4_folder_get_type (void)
{
static CamelType type = 0;
if (!type) {
- type = camel_type_register (CAMEL_TYPE_IMAP_FOLDER,
- "CamelIMAPFolder",
- sizeof (CamelIMAPFolder),
- sizeof (CamelIMAPFolderClass),
- (CamelObjectClassInitFunc) camel_imap_folder_class_init,
+ type = camel_type_register (CAMEL_TYPE_IMAP4_FOLDER,
+ "CamelIMAP4Folder",
+ sizeof (CamelIMAP4Folder),
+ sizeof (CamelIMAP4FolderClass),
+ (CamelObjectClassInitFunc) camel_imap4_folder_class_init,
NULL,
- (CamelObjectInitFunc) camel_imap_folder_init,
- (CamelObjectFinalizeFunc) camel_imap_folder_finalize);
+ (CamelObjectInitFunc) camel_imap4_folder_init,
+ (CamelObjectFinalizeFunc) camel_imap4_folder_finalize);
}
return type;
}
static void
-camel_imap_folder_class_init (CamelIMAPFolderClass *klass)
+camel_imap4_folder_class_init (CamelIMAP4FolderClass *klass)
{
CamelFolderClass *folder_class = (CamelFolderClass *) klass;
parent_class = (CamelFolderClass *) camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE);
- folder_class->sync = imap_sync;
- folder_class->expunge = imap_expunge;
- folder_class->get_message = imap_get_message;
- folder_class->append_message = imap_append_message;
- folder_class->transfer_messages_to = imap_transfer_messages_to;
+ folder_class->sync = imap4_sync;
+ folder_class->expunge = imap4_expunge;
+ folder_class->get_message = imap4_get_message;
+ folder_class->append_message = imap4_append_message;
+ folder_class->transfer_messages_to = imap4_transfer_messages_to;
}
static void
-camel_imap_folder_init (CamelIMAPFolder *folder, CamelIMAPFolderClass *klass)
+camel_imap4_folder_init (CamelIMAP4Folder *folder, CamelIMAP4FolderClass *klass)
{
folder->utf7_name = NULL;
}
static void
-camel_imap_folder_finalize (CamelObject *object)
+camel_imap4_folder_finalize (CamelObject *object)
{
- CamelIMAPFolder *folder = (CamelIMAPFolder *) object;
+ CamelIMAP4Folder *folder = (CamelIMAP4Folder *) object;
g_free (folder->utf7_name);
}
+static char
+imap4_get_path_delim (CamelIMAP4Engine *engine, const char *full_name)
+{
+ CamelIMAP4Namespace *namespace;
+ const char *slash;
+ size_t len;
+ char *top;
+
+ if ((slash = strchr (full_name, '/')))
+ len = (slash - full_name);
+ else
+ len = strlen (full_name);
+
+ top = g_alloca (len + 1);
+ memcpy (top, full_name, len);
+ top[len] = '\0';
+
+ if (!g_ascii_strcasecmp (top, "INBOX"))
+ top = "INBOX";
+
+ retry:
+ namespace = engine->namespaces.personal;
+ while (namespace != NULL) {
+ if (!strcmp (namespace->path, top))
+ return namespace->sep;
+ namespace = namespace->next;
+ }
+
+ namespace = engine->namespaces.other;
+ while (namespace != NULL) {
+ if (!strcmp (namespace->path, top))
+ return namespace->sep;
+ namespace = namespace->next;
+ }
+
+ namespace = engine->namespaces.shared;
+ while (namespace != NULL) {
+ if (!strcmp (namespace->path, top))
+ return namespace->sep;
+ namespace = namespace->next;
+ }
+
+ if (top[0] != '\0') {
+ /* look for a default namespace? */
+ top[0] = '\0';
+ goto retry;
+ }
+
+ return '/';
+}
+
+CamelFolder *
+camel_imap4_folder_new (CamelStore *store, const char *full_name, CamelException *ex)
+{
+ CamelIMAP4Folder *imap_folder;
+ char *utf7_name, *name, *p;
+ char sep;
+
+ if (!(p = strrchr (full_name, '/')))
+ p = (char *) full_name;
+ else
+ p++;
+
+ name = g_alloca (strlen (p) + 1);
+ strcpy (name, p);
+
+ utf7_name = g_alloca (strlen (full_name) + 1);
+ strcpy (utf7_name, full_name);
+
+ sep = imap4_get_path_delim (((CamelIMAP4Store *) store)->engine, full_name);
+ if (sep != '/') {
+ p = utf7_name;
+ while (*p != '\0') {
+ if (*p == '/')
+ *p = sep;
+ p++;
+ }
+ }
+
+ utf7_name = camel_utf8_utf7 (utf7_name);
+
+ imap_folder = (CamelIMAP4Folder *) camel_object_new (CAMEL_TYPE_IMAP4_FOLDER);
+ camel_folder_construct ((CamelFolder *) imap_folder, store, full_name, name);
+ imap_folder->utf7_name = utf7_name;
+
+ return (CamelFolder *) imap_folder;
+}
+
+
static struct {
const char *name;
guint32 flag;
-} imap_flags[] = {
+} imap4_flags[] = {
{ "\\Answered", CAMEL_MESSAGE_ANSWERED },
{ "\\Deleted", CAMEL_MESSAGE_DELETED },
{ "\\Draft", CAMEL_MESSAGE_DRAFT },
@@ -126,7 +218,7 @@ static struct {
};
static int
-imap_get_uid_set (CamelIMAPEngine *engine, CamelFolderSummary *summary, GPtrArray *infos, int cur, size_t linelen, char **set)
+imap4_get_uid_set (CamelIMAP4Engine *engine, CamelFolderSummary *summary, GPtrArray *infos, int cur, size_t linelen, char **set)
{
CamelMessageInfo *info;
guint32 this, prev, next;
@@ -135,7 +227,7 @@ imap_get_uid_set (CamelIMAPEngine *engine, CamelFolderSummary *summary, GPtrArra
int scount, i;
size_t len;
- if (engine->maxlentype == CAMEL_IMAP_ENGINE_MAXLEN_LINE)
+ if (engine->maxlentype == CAMEL_IMAP4_ENGINE_MAXLEN_LINE)
len = engine->maxlen - linelen;
else
len = engine->maxlen;
@@ -206,38 +298,38 @@ imap_get_uid_set (CamelIMAPEngine *engine, CamelFolderSummary *summary, GPtrArra
}
static int
-imap_sync_flag (CamelFolder *folder, GPtrArray *infos, char onoff, const char *flag, CamelException *ex)
+imap4_sync_flag (CamelFolder *folder, GPtrArray *infos, char onoff, const char *flag, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) folder->parent_store)->engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
+ CamelIMAP4Command *ic;
int i, id, retval = 0;
char *set = NULL;
for (i = 0; i < infos->len; ) {
- i += imap_get_uid_set (engine, folder->summary, infos, i, 30 + strlen (flag), &set);
+ i += imap4_get_uid_set (engine, folder->summary, infos, i, 30 + strlen (flag), &set);
- ic = camel_imap_engine_queue (engine, folder, "UID STORE %s %cFLAGS.SILENT (%s)\r\n", set, onoff, flag);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (engine, folder, "UID STORE %s %cFLAGS.SILENT (%s)\r\n", set, onoff, flag);
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
g_free (set);
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return -1;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot sync flags to folder `%s': Unknown"),
folder->full_name);
retval = -1;
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot sync flags to folder `%s': Bad command"),
folder->full_name);
@@ -245,7 +337,7 @@ imap_sync_flag (CamelFolder *folder, GPtrArray *infos, char onoff, const char *f
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
if (retval == -1)
return -1;
@@ -255,9 +347,9 @@ imap_sync_flag (CamelFolder *folder, GPtrArray *infos, char onoff, const char *f
}
static int
-imap_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
+imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
{
- CamelIMAPMessageInfo *iinfo;
+ CamelIMAP4MessageInfo *iinfo;
GPtrArray *on_set, *off_set;
CamelMessageInfo *info;
flags_diff_t diff;
@@ -268,15 +360,15 @@ imap_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
off_set = g_ptr_array_new ();
/* construct commands to sync system and user flags */
- for (i = 0; i < G_N_ELEMENTS (imap_flags); i++) {
- if (!(imap_flags[i].flag & folder->permanent_flags))
+ for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
+ if (!(imap4_flags[i].flag & folder->permanent_flags))
continue;
for (j = 0; j < sync->len; j++) {
- iinfo = (CamelIMAPMessageInfo *) info = sync->pdata[j];
- camel_imap_flags_diff (&diff, iinfo->server_flags, info->flags);
- if (diff.changed & imap_flags[i].flag) {
- if (diff.bits & imap_flags[i].flag) {
+ iinfo = (CamelIMAP4MessageInfo *) info = sync->pdata[j];
+ camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags);
+ if (diff.changed & imap4_flags[i].flag) {
+ if (diff.bits & imap4_flags[i].flag) {
g_ptr_array_add (on_set, info);
} else {
g_ptr_array_add (off_set, info);
@@ -285,14 +377,14 @@ imap_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
}
if (on_set->len > 0) {
- if ((retval = imap_sync_flag (folder, on_set, '+', imap_flags[i].name, ex)) == -1)
+ if ((retval = imap4_sync_flag (folder, on_set, '+', imap4_flags[i].name, ex)) == -1)
break;
g_ptr_array_set_size (on_set, 0);
}
if (off_set->len > 0) {
- if ((retval = imap_sync_flag (folder, off_set, '-', imap_flags[i].name, ex)) == -1)
+ if ((retval = imap4_sync_flag (folder, off_set, '-', imap4_flags[i].name, ex)) == -1)
break;
g_ptr_array_set_size (off_set, 0);
@@ -306,7 +398,7 @@ imap_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
return-1;
for (i = 0; i < sync->len; i++) {
- iinfo = (CamelIMAPMessageInfo *) info = sync->pdata[i];
+ iinfo = (CamelIMAP4MessageInfo *) info = sync->pdata[i];
info->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
iinfo->server_flags = info->flags & folder->permanent_flags;
}
@@ -315,12 +407,12 @@ imap_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
}
static void
-imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) folder->parent_store)->engine;
- CamelIMAPMessageInfo *iinfo;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
+ CamelIMAP4MessageInfo *iinfo;
CamelMessageInfo *info;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
flags_diff_t diff;
GPtrArray *sync;
int id, max, i;
@@ -330,10 +422,10 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
sync = g_ptr_array_new ();
max = camel_folder_summary_count (folder->summary);
for (i = 0; i < max; i++) {
- iinfo = (CamelIMAPMessageInfo *) info = camel_folder_summary_index (folder->summary, i);
+ iinfo = (CamelIMAP4MessageInfo *) info = camel_folder_summary_index (folder->summary, i);
expunge = expunge && (info->flags & CAMEL_MESSAGE_DELETED);
if (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) {
- camel_imap_flags_diff (&diff, iinfo->server_flags, info->flags);
+ camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags);
diff.changed &= folder->permanent_flags;
/* weed out flag changes that we can't sync to the server */
@@ -347,7 +439,7 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
if (sync->len > 0) {
- retval = imap_sync_changes (folder, sync, ex);
+ retval = imap4_sync_changes (folder, sync, ex);
for (i = 0; i < sync->len; i++)
camel_folder_summary_info_free (folder->summary, sync->pdata[i]);
@@ -361,65 +453,65 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
}
if (expunge) {
- ic = camel_imap_engine_queue (engine, folder, "EXPUNGE\r\n");
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (engine, folder, "EXPUNGE\r\n");
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
switch (ic->result) {
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot expunge folder `%s': Unknown"),
folder->full_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot expunge folder `%s': Bad command"),
folder->full_name);
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
camel_folder_summary_save (folder->summary);
}
static void
-imap_expunge (CamelFolder *folder, CamelException *ex)
+imap4_expunge (CamelFolder *folder, CamelException *ex)
{
- imap_sync (folder, TRUE, ex);
+ imap4_sync (folder, TRUE, ex);
}
static int
-untagged_fetch (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, camel_imap_token_t *token, CamelException *ex)
+untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
{
CamelStream *fstream, *stream = ic->user_data;
CamelMimeFilter *crlf;
int left = 2;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
/* parse the FETCH response list */
if (token->token != '(') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
do {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
- if (token->token != CAMEL_IMAP_TOKEN_ATOM)
+ if (token->token != CAMEL_IMAP4_TOKEN_ATOM)
goto unexpected;
if (!strcmp (token->v.atom, "BODY[]")) {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
- if (token->token != CAMEL_IMAP_TOKEN_LITERAL)
+ if (token->token != CAMEL_IMAP4_TOKEN_LITERAL)
goto unexpected;
fstream = (CamelStream *) camel_stream_filter_new_with_stream (stream);
@@ -433,10 +525,10 @@ untagged_fetch (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, ca
left--;
} else if (!strcmp (token->v.atom, "UID")) {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
- if (token->token != CAMEL_IMAP_TOKEN_NUMBER || token->v.number == 0)
+ if (token->token != CAMEL_IMAP4_TOKEN_NUMBER || token->v.number == 0)
goto unexpected;
left--;
@@ -446,7 +538,7 @@ untagged_fetch (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, ca
}
} while (left);
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
if (token->token != ')') {
@@ -458,7 +550,7 @@ untagged_fetch (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, ca
unexpected:
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
exception:
@@ -466,48 +558,48 @@ untagged_fetch (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, ca
}
static CamelMimeMessage *
-imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
+imap4_get_message (CamelFolder *folder, const char *uid, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) folder->parent_store)->engine;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
CamelMimeMessage *message = NULL;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
CamelStream *stream;
int id;
- ic = camel_imap_engine_queue (engine, folder, "UID FETCH %s BODY.PEEK[]\r\n", uid);
- camel_imap_command_register_untagged (ic, "FETCH", untagged_fetch);
+ ic = camel_imap4_engine_queue (engine, folder, "UID FETCH %s BODY.PEEK[]\r\n", uid);
+ camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch);
ic->user_data = stream = camel_stream_mem_new ();
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
camel_object_unref (stream);
return NULL;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
camel_stream_reset (stream);
message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream);
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get message %s from folder `%s': No such message"),
uid, folder->full_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get message %s from folder `%s': Bad command"),
uid, folder->full_name);
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
camel_object_unref (stream);
@@ -520,13 +612,13 @@ static char *tm_months[] = {
};
static void
-imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
+imap4_append_message (CamelFolder *folder, CamelMimeMessage *message,
const CamelMessageInfo *info, char **appended_uid, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) folder->parent_store)->engine;
- CamelIMAPSummary *summary = (CamelIMAPSummary *) folder->summary;
- CamelIMAPRespCode *resp;
- CamelIMAPCommand *ic;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
+ CamelIMAP4Summary *summary = (CamelIMAP4Summary *) folder->summary;
+ CamelIMAP4RespCode *resp;
+ CamelIMAP4Command *ic;
CamelFolderInfo *fi;
CamelException lex;
char flags[100], *p;
@@ -538,9 +630,9 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
if (info->flags & folder->permanent_flags) {
p = g_stpcpy (flags, " (");
- for (i = 0; i < G_N_ELEMENTS (imap_flags); i++) {
- if ((info->flags & imap_flags[i].flag) & folder->permanent_flags) {
- p = g_stpcpy (p, imap_flags[i].name);
+ for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
+ if ((info->flags & imap4_flags[i].flag) & folder->permanent_flags) {
+ p = g_stpcpy (p, imap4_flags[i].name);
*p++ = ' ';
}
}
@@ -586,23 +678,23 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
retry:
- if (engine->capa & CAMEL_IMAP_CAPABILITY_UIDPLUS)
- ic = camel_imap_engine_queue (engine, NULL, "UID APPEND %F%s%s %L\r\n", flags, date, message);
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_UIDPLUS)
+ ic = camel_imap4_engine_queue (engine, NULL, "UID APPEND %F%s%s %L\r\n", flags, date, message);
else
- ic = camel_imap_engine_queue (engine, NULL, "APPEND %F%s%s %L\r\n", flags, date, message);
+ ic = camel_imap4_engine_queue (engine, NULL, "APPEND %F%s%s %L\r\n", flags, date, message);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
- if (!(engine->capa & CAMEL_IMAP_CAPABILITY_UIDPLUS))
+ case CAMEL_IMAP4_RESULT_OK:
+ if (!(engine->capa & CAMEL_IMAP4_CAPABILITY_UIDPLUS))
break;
if (!appended_uid)
@@ -610,14 +702,14 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
for (i = 0; i < ic->resp_codes->len; i++) {
resp = ic->resp_codes->pdata[i];
- if (resp->code == CAMEL_IMAP_RESP_CODE_APPENDUID) {
+ if (resp->code == CAMEL_IMAP4_RESP_CODE_APPENDUID) {
if (resp->v.appenduid.uidvalidity == summary->uidvalidity)
*appended_uid = g_strdup_printf ("%u", resp->v.appenduid.uid);
break;
}
}
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: can we give the user any more information? */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to folder `%s': Unknown error"),
@@ -625,7 +717,7 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
for (i = 0; i < ic->resp_codes->len; i++) {
resp = ic->resp_codes->pdata[i];
- if (resp->code == CAMEL_IMAP_RESP_CODE_TRYCREATE) {
+ if (resp->code == CAMEL_IMAP4_RESP_CODE_TRYCREATE) {
char *parent_name, *p;
parent_name = g_alloca (strlen (folder->full_name) + 1);
@@ -640,14 +732,14 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
}
camel_store_free_folder_info (folder->parent_store, fi);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
camel_exception_clear (ex);
goto retry;
}
}
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to folder `%s': Bad command"),
folder->full_name);
@@ -657,7 +749,7 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message,
g_assert_not_reached ();
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
@@ -676,13 +768,13 @@ info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
}
static void
-imap_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
+imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) src->parent_store)->engine;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) src->parent_store)->engine;
int i, j, n, id, dest_namelen;
CamelMessageInfo *info;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
GPtrArray *infos;
char *set;
@@ -701,26 +793,26 @@ imap_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
g_ptr_array_sort (infos, (GCompareFunc) info_uid_sort);
- dest_namelen = strlen (camel_imap_folder_utf7_name ((CamelIMAPFolder *) dest));
+ dest_namelen = strlen (camel_imap4_folder_utf7_name ((CamelIMAP4Folder *) dest));
for (i = 0; i < infos->len; i += n) {
- n = imap_get_uid_set (engine, src->summary, infos, i, 10 + dest_namelen, &set);
+ n = imap4_get_uid_set (engine, src->summary, infos, i, 10 + dest_namelen, &set);
- ic = camel_imap_engine_queue (engine, src, "UID COPY %s %F\r\n", set, dest);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (engine, src, "UID COPY %s %F\r\n", set, dest);
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
g_free (set);
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
g_free (set);
goto done;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
if (delete_originals) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -733,7 +825,7 @@ imap_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
}
goto done;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
if (delete_originals) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot move messages from folder `%s' to folder `%s': Bad command"),
@@ -747,7 +839,7 @@ imap_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest,
goto done;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
if (delete_originals) {
for (j = i; j < n; j++) {
diff --git a/camel/providers/imap4/camel-imap4-folder.h b/camel/providers/imap4/camel-imap4-folder.h
new file mode 100644
index 0000000000..203c80074a
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-folder.h
@@ -0,0 +1,65 @@
+/* -*- 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_FOLDER_H__
+#define __CAMEL_IMAP4_FOLDER_H__
+
+#include <camel/camel-store.h>
+#include <camel/camel-folder.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define CAMEL_TYPE_IMAP4_FOLDER (camel_imap4_folder_get_type ())
+#define CAMEL_IMAP4_FOLDER(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP4_FOLDER, CamelIMAP4Folder))
+#define CAMEL_IMAP4_FOLDER_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP4_FOLDER, CamelIMAP4FolderClass))
+#define CAMEL_IS_IMAP4_FOLDER(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP4_FOLDER))
+#define CAMEL_IS_IMAP4_FOLDER_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP4_FOLDER))
+#define CAMEL_IMAP4_FOLDER_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP4_FOLDER, CamelIMAP4FolderClass))
+
+typedef struct _CamelIMAP4Folder CamelIMAP4Folder;
+typedef struct _CamelIMAP4FolderClass CamelIMAP4FolderClass;
+
+struct _CamelIMAP4Folder {
+ CamelFolder parent_object;
+
+ char *cachedir;
+ char *utf7_name;
+};
+
+struct _CamelIMAP4FolderClass {
+ CamelFolderClass parent_class;
+
+};
+
+
+CamelType camel_imap4_folder_get_type (void);
+
+CamelFolder *camel_imap4_folder_new (CamelStore *store, const char *full_name, CamelException *ex);
+
+const char *camel_imap4_folder_utf7_name (CamelIMAP4Folder *folder);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CAMEL_IMAP4_FOLDER_H__ */
diff --git a/camel/providers/imap4/camel-imap-provider.c b/camel/providers/imap4/camel-imap4-provider.c
index 2cf7f6e1c7..185053f032 100644
--- a/camel/providers/imap4/camel-imap-provider.c
+++ b/camel/providers/imap4/camel-imap4-provider.c
@@ -27,7 +27,7 @@
#include <camel/camel-sasl.h>
#include <camel/camel-provider.h>
-#include "camel-imap-store.h"
+#include "camel-imap4-store.h"
CamelProviderConfEntry imap4_conf_entries[] = {
@@ -52,7 +52,7 @@ static CamelProvider imap4_provider = {
"imap4",
N_("IMAPv4rev1"),
- N_("For reading and storing mail on IMAPv4rev1 servers."),
+ N_("For reading and storing mail on IMAPv4rev1 servers. EXPERIMENTAL !!"),
"mail",
@@ -69,7 +69,7 @@ static CamelProvider imap4_provider = {
CamelServiceAuthType camel_imap4_password_authtype = {
N_("Password"),
- N_("This option will connect to the IMAP server using a "
+ N_("This option will connect to the IMAPv4rev1 server using a "
"plaintext password."),
"",
@@ -85,7 +85,7 @@ add_hash (guint *hash, char *s)
}
static guint
-imap_url_hash (gconstpointer key)
+imap4_url_hash (gconstpointer key)
{
const CamelURL *u = (CamelURL *)key;
guint hash = 0;
@@ -115,7 +115,7 @@ check_equal (char *s1, char *s2)
}
static gint
-imap_url_equal (gconstpointer a, gconstpointer b)
+imap4_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
@@ -129,9 +129,9 @@ imap_url_equal (gconstpointer a, gconstpointer b)
void
camel_provider_module_init (void)
{
- imap4_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imap_store_get_type ();
- imap4_provider.url_hash = imap_url_hash;
- imap4_provider.url_equal = imap_url_equal;
+ imap4_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imap4_store_get_type ();
+ imap4_provider.url_hash = imap4_url_hash;
+ imap4_provider.url_equal = imap4_url_equal;
imap4_provider.authtypes = camel_sasl_authtype_list (FALSE);
imap4_provider.authtypes = g_list_prepend (imap4_provider.authtypes, &camel_imap4_password_authtype);
diff --git a/camel/providers/imap4/camel-imap-specials.c b/camel/providers/imap4/camel-imap4-specials.c
index 5289394f19..4682a403e4 100644
--- a/camel/providers/imap4/camel-imap-specials.c
+++ b/camel/providers/imap4/camel-imap4-specials.c
@@ -24,14 +24,14 @@
#include <string.h>
-#include "camel-imap-specials.h"
+#include "camel-imap4-specials.h"
#define CHARS_ATOM_SPECIALS "(){]"
#define CHARS_LWSP " \t\r\n"
#define CHARS_QUOTED_SPECIALS "\\\""
#define CHARS_LIST_WILDCARDS "*%"
-unsigned char camel_imap_specials[256] = {
+unsigned char camel_imap4_specials[256] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6, 2, 2, 6, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
20, 0, 8, 0, 0, 32, 0, 0, 1, 1, 32, 0, 0, 0, 0, 0,
@@ -52,28 +52,28 @@ unsigned char camel_imap_specials[256] = {
static void
-imap_init_bits (unsigned short bit, unsigned short bitcopy, int remove, unsigned char *vals)
+imap4_init_bits (unsigned short bit, unsigned short bitcopy, int remove, unsigned char *vals)
{
int i, len = strlen (vals);
if (!remove) {
for (i = 0; i < len; i++)
- camel_imap_specials[vals[i]] |= bit;
+ camel_imap4_specials[vals[i]] |= bit;
if (bitcopy) {
for (i = 0; i < 256; i++) {
- if (camel_imap_specials[i] & bitcopy)
- camel_imap_specials[i] |= bit;
+ if (camel_imap4_specials[i] & bitcopy)
+ camel_imap4_specials[i] |= bit;
}
}
} else {
for (i = 0; i < 256; i++)
- camel_imap_specials[i] |= bit;
+ camel_imap4_specials[i] |= bit;
for (i = 0; i < len; i++)
- camel_imap_specials[vals[i]] &= ~bit;
+ camel_imap4_specials[vals[i]] &= ~bit;
if (bitcopy) {
for (i = 0; i < 256; i++) {
- if (camel_imap_specials[i] & bitcopy)
- camel_imap_specials[i] &= ~bit;
+ if (camel_imap4_specials[i] & bitcopy)
+ camel_imap4_specials[i] &= ~bit;
}
}
}
@@ -81,20 +81,20 @@ imap_init_bits (unsigned short bit, unsigned short bitcopy, int remove, unsigned
void
-camel_imap_specials_init (void)
+camel_imap4_specials_init (void)
{
int i;
for (i = 0; i < 256; i++) {
- camel_imap_specials[i] = 0;
+ camel_imap4_specials[i] = 0;
if (i <= 0x1f || i >= 0x7f)
- camel_imap_specials[i] |= IS_CTRL;
+ camel_imap4_specials[i] |= IS_CTRL;
}
- camel_imap_specials[' '] |= IS_SPACE;
+ camel_imap4_specials[' '] |= IS_SPACE;
- imap_init_bits (IS_LWSP, 0, 0, CHARS_LWSP);
- imap_init_bits (IS_ASPECIAL, 0, 0, CHARS_ATOM_SPECIALS);
- imap_init_bits (IS_QSPECIAL, 0, 0, CHARS_QUOTED_SPECIALS);
- imap_init_bits (IS_WILDCARD, 0, 0, CHARS_LIST_WILDCARDS);
+ imap4_init_bits (IS_LWSP, 0, 0, CHARS_LWSP);
+ imap4_init_bits (IS_ASPECIAL, 0, 0, CHARS_ATOM_SPECIALS);
+ imap4_init_bits (IS_QSPECIAL, 0, 0, CHARS_QUOTED_SPECIALS);
+ imap4_init_bits (IS_WILDCARD, 0, 0, CHARS_LIST_WILDCARDS);
}
diff --git a/camel/providers/imap4/camel-imap-specials.h b/camel/providers/imap4/camel-imap4-specials.h
index 6bae4d3ae3..36765cdc6b 100644
--- a/camel/providers/imap4/camel-imap-specials.h
+++ b/camel/providers/imap4/camel-imap4-specials.h
@@ -18,8 +18,8 @@
*/
-#ifndef __CAMEL_IMAP_SPECIALS_H__
-#define __CAMEL_IMAP_SPECIALS_H__
+#ifndef __CAMEL_IMAP4_SPECIALS_H__
+#define __CAMEL_IMAP4_SPECIALS_H__
#ifdef __cplusplus
extern "C" {
@@ -35,19 +35,19 @@ enum {
IS_WILDCARD = (1 << 5),
};
-extern unsigned char camel_imap_specials[256];
+extern unsigned char camel_imap4_specials[256];
-#define is_atom(x) ((camel_imap_specials[(unsigned char)(x)] & (IS_ASPECIAL|IS_SPACE|IS_CTRL|IS_WILDCARD|IS_QSPECIAL)) == 0)
-#define is_ctrl(x) ((camel_imap_specials[(unsigned char)(x)] & IS_CTRL) != 0)
-#define is_lwsp(x) ((camel_imap_specials[(unsigned char)(x)] & IS_LWSP) != 0)
-#define is_type(x, t) ((camel_imap_specials[(unsigned char)(x)] & (t)) != 0)
-#define is_qsafe(x) ((camel_imap_specials[(unsigned char)(x)] & (IS_QSPECIAL|IS_CTRL)) == 0)
-#define is_wild(x) ((camel_imap_specials[(unsigned char)(x)] & IS_WILDCARD) != 0)
+#define is_atom(x) ((camel_imap4_specials[(unsigned char)(x)] & (IS_ASPECIAL|IS_SPACE|IS_CTRL|IS_WILDCARD|IS_QSPECIAL)) == 0)
+#define is_ctrl(x) ((camel_imap4_specials[(unsigned char)(x)] & IS_CTRL) != 0)
+#define is_lwsp(x) ((camel_imap4_specials[(unsigned char)(x)] & IS_LWSP) != 0)
+#define is_type(x, t) ((camel_imap4_specials[(unsigned char)(x)] & (t)) != 0)
+#define is_qsafe(x) ((camel_imap4_specials[(unsigned char)(x)] & (IS_QSPECIAL|IS_CTRL)) == 0)
+#define is_wild(x) ((camel_imap4_specials[(unsigned char)(x)] & IS_WILDCARD) != 0)
-void camel_imap_specials_init (void);
+void camel_imap4_specials_init (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-#endif /* __CAMEL_IMAP_SPECIALS_H__ */
+#endif /* __CAMEL_IMAP4_SPECIALS_H__ */
diff --git a/camel/providers/imap4/camel-imap-store.c b/camel/providers/imap4/camel-imap4-store.c
index 7373088f79..ffc8c91408 100644
--- a/camel/providers/imap4/camel-imap-store.c
+++ b/camel/providers/imap4/camel-imap4-store.c
@@ -34,62 +34,62 @@
#include <camel/camel-private.h>
-#include "camel-imap-store.h"
-#include "camel-imap-engine.h"
-#include "camel-imap-folder.h"
-#include "camel-imap-stream.h"
-#include "camel-imap-command.h"
+#include "camel-imap4-store.h"
+#include "camel-imap4-engine.h"
+#include "camel-imap4-folder.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-command.h"
-static void camel_imap_store_class_init (CamelIMAPStoreClass *klass);
-static void camel_imap_store_init (CamelIMAPStore *store, CamelIMAPStoreClass *klass);
-static void camel_imap_store_finalize (CamelObject *object);
+static void camel_imap4_store_class_init (CamelIMAP4StoreClass *klass);
+static void camel_imap4_store_init (CamelIMAP4Store *store, CamelIMAP4StoreClass *klass);
+static void camel_imap4_store_finalize (CamelObject *object);
/* service methods */
-static void imap_construct (CamelService *service, CamelSession *session,
- CamelProvider *provider, CamelURL *url,
- CamelException *ex);
-static char *imap_get_name (CamelService *service, gboolean brief);
-static gboolean imap_connect (CamelService *service, CamelException *ex);
-static gboolean imap_disconnect (CamelService *service, gboolean clean, CamelException *ex);
-static GList *imap_query_auth_types (CamelService *service, CamelException *ex);
+static void imap4_construct (CamelService *service, CamelSession *session,
+ CamelProvider *provider, CamelURL *url,
+ CamelException *ex);
+static char *imap4_get_name (CamelService *service, gboolean brief);
+static gboolean imap4_connect (CamelService *service, CamelException *ex);
+static gboolean imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex);
+static GList *imap4_query_auth_types (CamelService *service, CamelException *ex);
/* store methods */
-static CamelFolder *imap_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
-static CamelFolderInfo *imap_create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
-static void imap_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex);
-static void imap_rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
-static void imap_sync (CamelStore *store, gboolean expunge, CamelException *ex);
-static CamelFolderInfo *imap_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex);
-static void imap_subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
-static void imap_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
-static void imap_noop (CamelStore *store, CamelException *ex);
+static CamelFolder *imap4_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
+static CamelFolderInfo *imap4_create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
+static void imap4_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex);
+static void imap4_rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
+static void imap4_sync (CamelStore *store, gboolean expunge, CamelException *ex);
+static CamelFolderInfo *imap4_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex);
+static void imap4_subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
+static void imap4_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
+static void imap4_noop (CamelStore *store, CamelException *ex);
static CamelStoreClass *parent_class = NULL;
CamelType
-camel_imap_store_get_type (void)
+camel_imap4_store_get_type (void)
{
static CamelType type = 0;
if (!type) {
- type = camel_type_register (CAMEL_TYPE_IMAP_STORE,
- "CamelIMAPStore",
- sizeof (CamelIMAPStore),
- sizeof (CamelIMAPStoreClass),
- (CamelObjectClassInitFunc) camel_imap_store_class_init,
+ type = camel_type_register (CAMEL_TYPE_IMAP4_STORE,
+ "CamelIMAP4Store",
+ sizeof (CamelIMAP4Store),
+ sizeof (CamelIMAP4StoreClass),
+ (CamelObjectClassInitFunc) camel_imap4_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_imap_store_init,
- (CamelObjectFinalizeFunc) camel_imap_store_finalize);
+ (CamelObjectInitFunc) camel_imap4_store_init,
+ (CamelObjectFinalizeFunc) camel_imap4_store_finalize);
}
return type;
}
static guint
-imap_hash_folder_name (gconstpointer key)
+imap4_hash_folder_name (gconstpointer key)
{
if (g_ascii_strcasecmp (key, "INBOX") == 0)
return g_str_hash ("INBOX");
@@ -98,7 +98,7 @@ imap_hash_folder_name (gconstpointer key)
}
static gint
-imap_compare_folder_name (gconstpointer a, gconstpointer b)
+imap4_compare_folder_name (gconstpointer a, gconstpointer b)
{
gconstpointer aname = a, bname = b;
@@ -110,43 +110,43 @@ imap_compare_folder_name (gconstpointer a, gconstpointer b)
}
static void
-camel_imap_store_class_init (CamelIMAPStoreClass *klass)
+camel_imap4_store_class_init (CamelIMAP4StoreClass *klass)
{
CamelServiceClass *service_class = (CamelServiceClass *) klass;
CamelStoreClass *store_class = (CamelStoreClass *) klass;
parent_class = (CamelStoreClass *) camel_type_get_global_classfuncs (CAMEL_STORE_TYPE);
- service_class->construct = imap_construct;
- service_class->get_name = imap_get_name;
- service_class->connect = imap_connect;
- service_class->disconnect = imap_disconnect;
- service_class->query_auth_types = imap_query_auth_types;
-
- store_class->hash_folder_name = imap_hash_folder_name;
- store_class->compare_folder_name = imap_compare_folder_name;
-
- store_class->get_folder = imap_get_folder;
- store_class->create_folder = imap_create_folder;
- store_class->delete_folder = imap_delete_folder;
- store_class->rename_folder = imap_rename_folder;
- store_class->sync = imap_sync;
- store_class->get_folder_info = imap_get_folder_info;
- store_class->subscribe_folder = imap_subscribe_folder;
- store_class->unsubscribe_folder = imap_unsubscribe_folder;
- store_class->noop = imap_noop;
+ service_class->construct = imap4_construct;
+ service_class->get_name = imap4_get_name;
+ service_class->connect = imap4_connect;
+ service_class->disconnect = imap4_disconnect;
+ service_class->query_auth_types = imap4_query_auth_types;
+
+ store_class->hash_folder_name = imap4_hash_folder_name;
+ store_class->compare_folder_name = imap4_compare_folder_name;
+
+ store_class->get_folder = imap4_get_folder;
+ store_class->create_folder = imap4_create_folder;
+ store_class->delete_folder = imap4_delete_folder;
+ store_class->rename_folder = imap4_rename_folder;
+ store_class->sync = imap4_sync;
+ store_class->get_folder_info = imap4_get_folder_info;
+ store_class->subscribe_folder = imap4_subscribe_folder;
+ store_class->unsubscribe_folder = imap4_unsubscribe_folder;
+ store_class->noop = imap4_noop;
}
static void
-camel_imap_store_init (CamelIMAPStore *store, CamelIMAPStoreClass *klass)
+camel_imap4_store_init (CamelIMAP4Store *store, CamelIMAP4StoreClass *klass)
{
store->engine = NULL;
}
static void
-camel_imap_store_finalize (CamelObject *object)
+camel_imap4_store_finalize (CamelObject *object)
{
- CamelIMAPStore *store = (CamelIMAPStore *) object;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) object;
if (store->engine)
camel_object_unref (store->engine);
@@ -154,13 +154,13 @@ camel_imap_store_finalize (CamelObject *object)
static void
-imap_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+imap4_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
{
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
}
static char *
-imap_get_name (CamelService *service, gboolean brief)
+imap4_get_name (CamelService *service, gboolean brief)
{
if (brief)
return g_strdup_printf (_("IMAP server %s"), service->url->host);
@@ -181,8 +181,8 @@ enum {
static gboolean
connect_to_server (CamelService *service, struct hostent *host, int ssl_mode, int try_starttls, CamelException *ex)
{
- CamelIMAPStore *store = (CamelIMAPStore *) service;
- CamelIMAPEngine *engine;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) service;
+ CamelIMAP4Engine *engine;
CamelStream *tcp_stream;
int port, ret;
@@ -232,14 +232,14 @@ connect_to_server (CamelService *service, struct hostent *host, int ssl_mode, in
return FALSE;
}
- engine = camel_imap_engine_new (service->session, service->url);
- if (camel_imap_engine_take_stream (engine, tcp_stream, ex) == -1) {
+ engine = camel_imap4_engine_new (service->session, service->url);
+ if (camel_imap4_engine_take_stream (engine, tcp_stream, ex) == -1) {
camel_object_unref (engine);
return FALSE;
}
- if (camel_imap_engine_capability (engine, ex) == -1) {
+ if (camel_imap4_engine_capability (engine, ex) == -1) {
camel_object_unref (engine);
return FALSE;
@@ -250,11 +250,11 @@ connect_to_server (CamelService *service, struct hostent *host, int ssl_mode, in
#ifdef HAVE_SSL
if (ssl_mode == USE_SSL_WHEN_POSSIBLE) {
/* try_starttls is always TRUE here */
- if (engine->capa & CAMEL_IMAP_CAPABILITY_STARTTLS)
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_STARTTLS)
goto starttls;
} else if (ssl_mode == USE_SSL_ALWAYS) {
if (try_starttls) {
- if (engine->capa & CAMEL_IMAP_CAPABILITY_STARTTLS) {
+ if (engine->capa & CAMEL_IMAP4_CAPABILITY_STARTTLS) {
goto starttls;
} else {
/* server doesn't support STARTTLS, abort */
@@ -274,15 +274,15 @@ connect_to_server (CamelService *service, struct hostent *host, int ssl_mode, in
starttls:
if (1) {
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
int id;
- ic = camel_imap_engine_queue (engine, NULL, "STARTTLS\r\n");
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (engine, NULL, "STARTTLS\r\n");
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->result != CAMEL_IMAP_RESULT_OK) {
- if (ic->result != CAMEL_IMAP_RESULT_OK) {
+ if (id == -1 || ic->result != CAMEL_IMAP4_RESULT_OK) {
+ if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("Unknown error"));
@@ -290,12 +290,12 @@ connect_to_server (CamelService *service, struct hostent *host, int ssl_mode, in
camel_exception_xfer (ex, &ic->ex);
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
goto exception;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
return TRUE;
@@ -363,7 +363,7 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
}
static int
-sasl_auth (CamelIMAPEngine *engine, CamelIMAPCommand *ic, const unsigned char *linebuf, size_t linelen, CamelException *ex)
+sasl_auth (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, const unsigned char *linebuf, size_t linelen, CamelException *ex)
{
/* Perform a single challenge iteration */
CamelSasl *sasl = ic->user_data;
@@ -401,12 +401,12 @@ sasl_auth (CamelIMAPEngine *engine, CamelIMAPCommand *ic, const unsigned char *l
}
static int
-imap_try_authenticate (CamelService *service, gboolean reprompt, const char *errmsg, CamelException *ex)
+imap4_try_authenticate (CamelService *service, gboolean reprompt, const char *errmsg, CamelException *ex)
{
- CamelIMAPStore *store = (CamelIMAPStore *) service;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelSession *session = service->session;
CamelSasl *sasl = NULL;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
int id;
if (!service->url->passwd) {
@@ -433,47 +433,47 @@ imap_try_authenticate (CamelService *service, gboolean reprompt, const char *err
CamelServiceAuthType *mech;
mech = g_hash_table_lookup (store->engine->authtypes, service->url->authmech);
- sasl = camel_sasl_new ("imap", mech->authproto, service);
+ sasl = camel_sasl_new ("imap4", mech->authproto, service);
- ic = camel_imap_engine_queue (store->engine, NULL, "AUTHENTICATE %s\r\n", service->url->authmech);
+ ic = camel_imap4_engine_queue (store->engine, NULL, "AUTHENTICATE %s\r\n", service->url->authmech);
ic->plus = sasl_auth;
ic->user_data = sasl;
} else {
- ic = camel_imap_engine_queue (store->engine, NULL, "LOGIN %S %S\r\n",
+ ic = camel_imap4_engine_queue (store->engine, NULL, "LOGIN %S %S\r\n",
service->url->user, service->url->passwd);
}
- while ((id = camel_imap_engine_iterate (store->engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (store->engine)) < ic->id && id != -1)
;
if (sasl != NULL)
camel_object_unref (sasl);
- if (id == -1 || ic->status == CAMEL_IMAP_COMMAND_ERROR) {
+ if (id == -1 || ic->status == CAMEL_IMAP4_COMMAND_ERROR) {
/* unrecoverable error */
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return FALSE;
}
- if (ic->result != CAMEL_IMAP_RESULT_OK) {
- camel_imap_command_unref (ic);
+ if (ic->result != CAMEL_IMAP4_RESULT_OK) {
+ camel_imap4_command_unref (ic);
/* try again */
return TRUE;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return FALSE;
}
static gboolean
-imap_connect (CamelService *service, CamelException *ex)
+imap4_connect (CamelService *service, CamelException *ex)
{
- CamelIMAPStore *store = (CamelIMAPStore *) service;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelServiceAuthType *mech;
gboolean reprompt = FALSE;
char *errmsg = NULL;
@@ -502,7 +502,7 @@ imap_connect (CamelService *service, CamelException *ex)
}
camel_exception_init (&lex);
- while (imap_try_authenticate (service, reprompt, errmsg, &lex)) {
+ while (imap4_try_authenticate (service, reprompt, errmsg, &lex)) {
g_free (errmsg);
errmsg = g_strdup (lex.desc);
camel_exception_clear (&lex);
@@ -520,7 +520,7 @@ imap_connect (CamelService *service, CamelException *ex)
return FALSE;
}
- if (camel_imap_engine_namespace (store->engine, ex) == -1) {
+ if (camel_imap4_engine_namespace (store->engine, ex) == -1) {
camel_object_unref (store->engine);
store->engine = NULL;
@@ -535,18 +535,18 @@ imap_connect (CamelService *service, CamelException *ex)
}
static gboolean
-imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
+imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
- CamelIMAPStore *store = (CamelIMAPStore *) service;
- CamelIMAPCommand *ic;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) service;
+ CamelIMAP4Command *ic;
int id;
if (clean && !store->engine->istream->disconnected) {
- ic = camel_imap_engine_queue (store->engine, NULL, "LOGOUT\r\n");
- while ((id = camel_imap_engine_iterate (store->engine)) < ic->id && id != -1)
+ ic = camel_imap4_engine_queue (store->engine, NULL, "LOGOUT\r\n");
+ while ((id = camel_imap4_engine_iterate (store->engine)) < ic->id && id != -1)
;
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
camel_object_unref (store->engine);
@@ -554,12 +554,12 @@ imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
return 0;
}
-extern CamelServiceAuthType camel_imap_password_authtype;
+extern CamelServiceAuthType camel_imap4_password_authtype;
static GList *
-imap_query_auth_types (CamelService *service, CamelException *ex)
+imap4_query_auth_types (CamelService *service, CamelException *ex)
{
- CamelIMAPStore *store = (CamelIMAPStore *) service;
+ CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelServiceAuthType *authtype;
GList *sasl_types, *t, *next;
gboolean connected;
@@ -581,12 +581,12 @@ imap_query_auth_types (CamelService *service, CamelException *ex)
}
}
- return g_list_prepend (sasl_types, &camel_imap_password_authtype);
+ return g_list_prepend (sasl_types, &camel_imap4_password_authtype);
}
static char *
-imap_folder_utf7_name (CamelStore *store, const char *folder_name)
+imap4_folder_utf7_name (CamelStore *store, const char *folder_name)
{
char *real_name, *p;
@@ -606,24 +606,22 @@ imap_folder_utf7_name (CamelStore *store, const char *folder_name)
}
static CamelFolder *
-imap_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
+imap4_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
{
- CamelIMAPStore *imap_store = (CamelIMAPStore *) store;
-
/* FIXME: implement me */
return NULL;
}
static CamelFolderInfo *
-imap_create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex)
+imap4_create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex)
{
/* FIXME: also need to deal with parent folders that can't
* contain subfolders - delete them and re-create with the
* proper hint */
- CamelIMAPEngine *engine = ((CamelIMAPStore *) store)->engine;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
CamelFolderInfo *fi = NULL;
- CamelIMAPCommand *ic;
+ CamelIMAP4Command *ic;
char *utf7_name;
const char *c;
char *name;
@@ -647,32 +645,32 @@ imap_create_folder (CamelStore *store, const char *parent_name, const char *fold
else
name = g_strdup (folder_name);
- utf7_name = imap_folder_utf7_name (store, name);
+ utf7_name = imap4_folder_utf7_name (store, name);
g_free (name);
- ic = camel_imap_engine_queue (engine, NULL, "CREATE %S\r\n", utf7_name);
+ ic = camel_imap4_engine_queue (engine, NULL, "CREATE %S\r\n", utf7_name);
g_free (utf7_name);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return NULL;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
/* FIXME: allocate fi */
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create folder `%s': Invalid mailbox name"),
folder_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create folder `%s': Bad command"),
folder_name);
@@ -681,16 +679,16 @@ imap_create_folder (CamelStore *store, const char *parent_name, const char *fold
g_assert_not_reached ();
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return fi;
}
static void
-imap_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
+imap4_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) store)->engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelIMAP4Command *ic;
char *utf7_name;
int id;
@@ -702,151 +700,162 @@ imap_delete_folder (CamelStore *store, const char *folder_name, CamelException *
return;
}
- utf7_name = imap_folder_utf7_name (store, folder_name);
- ic = camel_imap_engine_queue (engine, NULL, "DELETE %S\r\n", utf7_name);
+ utf7_name = imap4_folder_utf7_name (store, folder_name);
+ ic = camel_imap4_engine_queue (engine, NULL, "DELETE %S\r\n", utf7_name);
g_free (utf7_name);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
/* deleted */
- /*fi = imap_build_folder_info (store, folder_name);
+ /*fi = imap4_build_folder_info (store, folder_name);
camel_object_trigger_event (store, "folder_deleted", fi);
camel_folder_info_free (fi);*/
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot delete folder `%s': Invalid mailbox name"),
folder_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot delete folder `%s': Bad command"),
folder_name);
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
static void
-imap_rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
+imap4_rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
{
}
static void
-imap_sync (CamelStore *store, gboolean expunge, CamelException *ex)
+imap4_sync (CamelStore *store, gboolean expunge, CamelException *ex)
{
}
static CamelFolderInfo *
-imap_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex)
+imap4_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex)
{
return NULL;
}
static void
-imap_subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
+imap4_subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) store)->engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelIMAP4Command *ic;
char *utf7_name;
int id;
- utf7_name = imap_folder_utf7_name (store, folder_name);
- ic = camel_imap_engine_queue (engine, NULL, "SUBSCRIBE %S\r\n", utf7_name);
+ utf7_name = imap4_folder_utf7_name (store, folder_name);
+ ic = camel_imap4_engine_queue (engine, NULL, "SUBSCRIBE %S\r\n", utf7_name);
g_free (utf7_name);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
/* subscribed */
- /*fi = imap_build_folder_info (store, folder_name);
+ /*fi = imap4_build_folder_info (store, folder_name);
fi->flags |= CAMEL_FOLDER_NOCHILDREN;
camel_object_trigger_event (store, "folder_subscribed", fi);
camel_folder_info_free (fi);*/
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot subscribe to folder `%s': Invalid mailbox name"),
folder_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot subscribe to folder `%s': Bad command"),
folder_name);
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
static void
-imap_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
+imap4_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
- CamelIMAPEngine *engine = ((CamelIMAPStore *) store)->engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelIMAP4Command *ic;
char *utf7_name;
int id;
- utf7_name = imap_folder_utf7_name (store, folder_name);
- ic = camel_imap_engine_queue (engine, NULL, "UNSUBSCRIBE %S\r\n", utf7_name);
+ utf7_name = imap4_folder_utf7_name (store, folder_name);
+ ic = camel_imap4_engine_queue (engine, NULL, "UNSUBSCRIBE %S\r\n", utf7_name);
g_free (utf7_name);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return;
}
switch (ic->result) {
- case CAMEL_IMAP_RESULT_OK:
+ case CAMEL_IMAP4_RESULT_OK:
/* unsubscribed */
- /*fi = imap_build_folder_info (store, folder_name);
+ /*fi = imap4_build_folder_info (store, folder_name);
camel_object_trigger_event (store, "folder_unsubscribed", fi);
camel_folder_info_free (fi);*/
break;
- case CAMEL_IMAP_RESULT_NO:
+ case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot unsubscribe from folder `%s': Invalid mailbox name"),
folder_name);
break;
- case CAMEL_IMAP_RESULT_BAD:
+ case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot unsubscribe from folder `%s': Bad command"),
folder_name);
break;
}
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
static void
-imap_noop (CamelStore *store, CamelException *ex)
+imap4_noop (CamelStore *store, CamelException *ex)
{
-
+ CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelIMAP4Command *ic;
+ int id;
+
+ ic = camel_imap4_engine_queue (engine, NULL, "NOOP\r\n");
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
+ ;
+
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE)
+ camel_exception_xfer (ex, &ic->ex);
+
+ camel_imap4_command_unref (ic);
}
diff --git a/camel/providers/imap4/camel-imap-store.h b/camel/providers/imap4/camel-imap4-store.h
index b4643451bf..d8d758ab67 100644
--- a/camel/providers/imap4/camel-imap-store.h
+++ b/camel/providers/imap4/camel-imap4-store.h
@@ -18,8 +18,8 @@
*/
-#ifndef __CAMEL_IMAP_STORE_H__
-#define __CAMEL_IMAP_STORE_H__
+#ifndef __CAMEL_IMAP4_STORE_H__
+#define __CAMEL_IMAP4_STORE_H__
#include <camel/camel-store.h>
@@ -28,34 +28,34 @@ extern "C" {
#pragma }
#endif /* __cplusplus */
-#define CAMEL_TYPE_IMAP_STORE (camel_imap_store_get_type ())
-#define CAMEL_IMAP_STORE(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP_STORE, CamelIMAPStore))
-#define CAMEL_IMAP_STORE_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP_STORE, CamelIMAPStoreClass))
-#define CAMEL_IS_IMAP_STORE(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP_STORE))
-#define CAMEL_IS_IMAP_STORE_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP_STORE))
-#define CAMEL_IMAP_STORE_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP_STORE, CamelIMAPStoreClass))
+#define CAMEL_TYPE_IMAP4_STORE (camel_imap4_store_get_type ())
+#define CAMEL_IMAP4_STORE(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP4_STORE, CamelIMAP4Store))
+#define CAMEL_IMAP4_STORE_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP4_STORE, CamelIMAP4StoreClass))
+#define CAMEL_IS_IMAP4_STORE(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP4_STORE))
+#define CAMEL_IS_IMAP4_STORE_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP4_STORE))
+#define CAMEL_IMAP4_STORE_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_IMAP4_STORE, CamelIMAP4StoreClass))
-typedef struct _CamelIMAPStore CamelIMAPStore;
-typedef struct _CamelIMAPStoreClass CamelIMAPStoreClass;
+typedef struct _CamelIMAP4Store CamelIMAP4Store;
+typedef struct _CamelIMAP4StoreClass CamelIMAP4StoreClass;
-struct _CamelIMAPEngine;
+struct _CamelIMAP4Engine;
-struct _CamelIMAPStore {
+struct _CamelIMAP4Store {
CamelStore parent_object;
- struct _CamelIMAPEngine *engine;
+ struct _CamelIMAP4Engine *engine;
};
-struct _CamelIMAPStoreClass {
+struct _CamelIMAP4StoreClass {
CamelStoreClass parent_class;
};
-CamelType camel_imap_store_get_type (void);
+CamelType camel_imap4_store_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-#endif /* __CAMEL_IMAP_STORE_H__ */
+#endif /* __CAMEL_IMAP4_STORE_H__ */
diff --git a/camel/providers/imap4/camel-imap-stream.c b/camel/providers/imap4/camel-imap4-stream.c
index be3baa7794..f2b2cbeb4b 100644
--- a/camel/providers/imap4/camel-imap-stream.c
+++ b/camel/providers/imap4/camel-imap4-stream.c
@@ -28,17 +28,17 @@
#include <errno.h>
#include <ctype.h>
-#include "camel-imap-specials.h"
+#include "camel-imap4-specials.h"
-#include "camel-imap-stream.h"
+#include "camel-imap4-stream.h"
#define d(x) x
-#define IMAP_TOKEN_LEN 128
+#define IMAP4_TOKEN_LEN 128
-static void camel_imap_stream_class_init (CamelIMAPStreamClass *klass);
-static void camel_imap_stream_init (CamelIMAPStream *stream, CamelIMAPStreamClass *klass);
-static void camel_imap_stream_finalize (CamelObject *object);
+static void camel_imap4_stream_class_init (CamelIMAP4StreamClass *klass);
+static void camel_imap4_stream_init (CamelIMAP4Stream *stream, CamelIMAP4StreamClass *klass);
+static void camel_imap4_stream_finalize (CamelObject *object);
static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n);
static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n);
@@ -51,26 +51,26 @@ static CamelStreamClass *parent_class = NULL;
CamelType
-camel_imap_stream_get_type (void)
+camel_imap4_stream_get_type (void)
{
static CamelType type = 0;
if (!type) {
- type = camel_type_register (CAMEL_TYPE_IMAP_STREAM,
- "CamelIMAPStream",
- sizeof (CamelIMAPStream),
- sizeof (CamelIMAPStreamClass),
- (CamelObjectClassInitFunc) camel_imap_stream_class_init,
+ type = camel_type_register (CAMEL_TYPE_IMAP4_STREAM,
+ "CamelIMAP4Stream",
+ sizeof (CamelIMAP4Stream),
+ sizeof (CamelIMAP4StreamClass),
+ (CamelObjectClassInitFunc) camel_imap4_stream_class_init,
NULL,
- (CamelObjectInitFunc) camel_imap_stream_init,
- (CamelObjectFinalizeFunc) camel_imap_stream_finalize);
+ (CamelObjectInitFunc) camel_imap4_stream_init,
+ (CamelObjectFinalizeFunc) camel_imap4_stream_finalize);
}
return type;
}
static void
-camel_imap_stream_class_init (CamelIMAPStreamClass *klass)
+camel_imap4_stream_class_init (CamelIMAP4StreamClass *klass)
{
CamelStreamClass *stream_class = (CamelStreamClass *) klass;
@@ -85,69 +85,69 @@ camel_imap_stream_class_init (CamelIMAPStreamClass *klass)
}
static void
-camel_imap_stream_init (CamelIMAPStream *imap, CamelIMAPStreamClass *klass)
+camel_imap4_stream_init (CamelIMAP4Stream *imap4, CamelIMAP4StreamClass *klass)
{
- imap->stream = NULL;
+ imap4->stream = NULL;
- imap->mode = CAMEL_IMAP_STREAM_MODE_TOKEN;
- imap->disconnected = FALSE;
- imap->eol = FALSE;
+ imap4->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
+ imap4->disconnected = FALSE;
+ imap4->eol = FALSE;
- imap->literal = 0;
+ imap4->literal = 0;
- imap->inbuf = imap->realbuf + IMAP_READ_PRELEN;
- imap->inptr = imap->inbuf;
- imap->inend = imap->inbuf;
+ imap4->inbuf = imap4->realbuf + IMAP4_READ_PRELEN;
+ imap4->inptr = imap4->inbuf;
+ imap4->inend = imap4->inbuf;
- imap->tokenbuf = g_malloc (IMAP_TOKEN_LEN);
- imap->tokenptr = imap->tokenbuf;
- imap->tokenleft = IMAP_TOKEN_LEN;
+ imap4->tokenbuf = g_malloc (IMAP4_TOKEN_LEN);
+ imap4->tokenptr = imap4->tokenbuf;
+ imap4->tokenleft = IMAP4_TOKEN_LEN;
- imap->unget = NULL;
+ imap4->unget = NULL;
}
static void
-camel_imap_stream_finalize (CamelObject *object)
+camel_imap4_stream_finalize (CamelObject *object)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) object;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) object;
- if (imap->stream)
- camel_object_unref (imap->stream);
+ if (imap4->stream)
+ camel_object_unref (imap4->stream);
- g_free (imap->tokenbuf);
- g_free (imap->unget);
+ g_free (imap4->tokenbuf);
+ g_free (imap4->unget);
}
static ssize_t
-imap_fill (CamelIMAPStream *imap)
+imap4_fill (CamelIMAP4Stream *imap4)
{
unsigned char *inbuf, *inptr, *inend;
ssize_t nread;
size_t inlen;
- if (imap->disconnected) {
+ if (imap4->disconnected) {
errno = EINVAL;
return -1;
}
- inbuf = imap->inbuf;
- inptr = imap->inptr;
- inend = imap->inend;
+ inbuf = imap4->inbuf;
+ inptr = imap4->inptr;
+ inend = imap4->inend;
inlen = inend - inptr;
g_assert (inptr <= inend);
/* attempt to align 'inend' with realbuf + SCAN_HEAD */
if (inptr >= inbuf) {
- inbuf -= inlen < IMAP_READ_PRELEN ? inlen : IMAP_READ_PRELEN;
+ inbuf -= inlen < IMAP4_READ_PRELEN ? inlen : IMAP4_READ_PRELEN;
memmove (inbuf, inptr, inlen);
inptr = inbuf;
inbuf += inlen;
- } else if (inptr > imap->realbuf) {
+ } else if (inptr > imap4->realbuf) {
size_t shift;
- shift = MIN (inptr - imap->realbuf, inend - inbuf);
+ shift = MIN (inptr - imap4->realbuf, inend - inbuf);
memmove (inptr - shift, inptr, inlen);
inptr -= shift;
inbuf = inptr + inlen;
@@ -156,53 +156,53 @@ imap_fill (CamelIMAPStream *imap)
inbuf = inend;
}
- imap->inptr = inptr;
- imap->inend = inbuf;
- inend = imap->realbuf + IMAP_READ_PRELEN + IMAP_READ_BUFLEN - 1;
+ imap4->inptr = inptr;
+ imap4->inend = inbuf;
+ inend = imap4->realbuf + IMAP4_READ_PRELEN + IMAP4_READ_BUFLEN - 1;
- if ((nread = camel_stream_read (imap->stream, inbuf, inend - inbuf)) == -1)
+ if ((nread = camel_stream_read (imap4->stream, inbuf, inend - inbuf)) == -1)
return -1;
else if (nread == 0)
- imap->disconnected = TRUE;
+ imap4->disconnected = TRUE;
- imap->inend += nread;
+ imap4->inend += nread;
- return imap->inend - imap->inptr;
+ return imap4->inend - imap4->inptr;
}
static ssize_t
stream_read (CamelStream *stream, char *buffer, size_t n)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) stream;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
ssize_t len, nread = 0;
- if (imap->mode == CAMEL_IMAP_STREAM_MODE_LITERAL) {
+ if (imap4->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL) {
/* don't let our caller read past the end of the literal */
- n = MIN (n, imap->literal);
+ n = MIN (n, imap4->literal);
}
- if (imap->inptr < imap->inend) {
- len = MIN (n, imap->inend - imap->inptr);
- memcpy (buffer, imap->inptr, len);
- imap->inptr += len;
+ if (imap4->inptr < imap4->inend) {
+ len = MIN (n, imap4->inend - imap4->inptr);
+ memcpy (buffer, imap4->inptr, len);
+ imap4->inptr += len;
nread = len;
}
if (nread < n) {
- if ((len = camel_stream_read (imap->stream, buffer + nread, n - nread)) == 0)
- imap->disconnected = TRUE;
+ if ((len = camel_stream_read (imap4->stream, buffer + nread, n - nread)) == 0)
+ imap4->disconnected = TRUE;
else if (len == -1)
return -1;
nread += len;
}
- if (imap->mode == CAMEL_IMAP_STREAM_MODE_LITERAL) {
- imap->literal -= nread;
+ if (imap4->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL) {
+ imap4->literal -= nread;
- if (imap->literal == 0) {
- imap->mode = CAMEL_IMAP_STREAM_MODE_TOKEN;
- imap->eol = TRUE;
+ if (imap4->literal == 0) {
+ imap4->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
+ imap4->eol = TRUE;
}
}
@@ -212,16 +212,16 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
static ssize_t
stream_write (CamelStream *stream, const char *buffer, size_t n)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) stream;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
ssize_t nwritten;
- if (imap->disconnected) {
+ if (imap4->disconnected) {
errno = EINVAL;
return -1;
}
- if ((nwritten = camel_stream_write (imap->stream, buffer, n)) == 0)
- imap->disconnected = TRUE;
+ if ((nwritten = camel_stream_write (imap4->stream, buffer, n)) == 0)
+ imap4->disconnected = TRUE;
return nwritten;
}
@@ -229,23 +229,23 @@ stream_write (CamelStream *stream, const char *buffer, size_t n)
static int
stream_flush (CamelStream *stream)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) stream;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
- return camel_stream_flush (imap->stream);
+ return camel_stream_flush (imap4->stream);
}
static int
stream_close (CamelStream *stream)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) stream;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
- if (camel_stream_close (imap->stream) == -1)
+ if (camel_stream_close (imap4->stream) == -1)
return -1;
- camel_object_unref (imap->stream);
- imap->stream = NULL;
+ camel_object_unref (imap4->stream);
+ imap4->stream = NULL;
- imap->disconnected = TRUE;
+ imap4->disconnected = TRUE;
return 0;
}
@@ -253,15 +253,15 @@ stream_close (CamelStream *stream)
static gboolean
stream_eos (CamelStream *stream)
{
- CamelIMAPStream *imap = (CamelIMAPStream *) stream;
+ CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
- if (imap->eol)
+ if (imap4->eol)
return TRUE;
- if (imap->disconnected && imap->inptr == imap->inend)
+ if (imap4->disconnected && imap4->inptr == imap4->inend)
return TRUE;
- if (camel_stream_eos (imap->stream))
+ if (camel_stream_eos (imap4->stream))
return TRUE;
return FALSE;
@@ -269,65 +269,65 @@ stream_eos (CamelStream *stream)
/**
- * camel_imap_stream_new:
+ * camel_imap4_stream_new:
* @stream: tcp stream
*
- * Returns a new imap stream
+ * Returns a new imap4 stream
**/
CamelStream *
-camel_imap_stream_new (CamelStream *stream)
+camel_imap4_stream_new (CamelStream *stream)
{
- CamelIMAPStream *imap;
+ CamelIMAP4Stream *imap4;
g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
- imap = (CamelIMAPStream *) camel_object_new (CAMEL_TYPE_IMAP_STREAM);
+ imap4 = (CamelIMAP4Stream *) camel_object_new (CAMEL_TYPE_IMAP4_STREAM);
camel_object_ref (stream);
- imap->stream = stream;
+ imap4->stream = stream;
- return (CamelStream *) imap;
+ return (CamelStream *) imap4;
}
-#define token_save(imap, start, len) G_STMT_START { \
- if (imap->tokenleft <= len) { \
+#define token_save(imap4, start, len) G_STMT_START { \
+ if (imap4->tokenleft <= len) { \
unsigned int tlen, toff; \
\
- tlen = toff = imap->tokenptr - imap->tokenbuf; \
+ tlen = toff = imap4->tokenptr - imap4->tokenbuf; \
tlen = tlen ? tlen : 1; \
\
while (tlen < toff + len) \
tlen <<= 1; \
\
- imap->tokenbuf = g_realloc (imap->tokenbuf, tlen + 1); \
- imap->tokenptr = imap->tokenbuf + toff; \
- imap->tokenleft = tlen - toff; \
+ imap4->tokenbuf = g_realloc (imap4->tokenbuf, tlen + 1); \
+ imap4->tokenptr = imap4->tokenbuf + toff; \
+ imap4->tokenleft = tlen - toff; \
} \
\
- memcpy (imap->tokenptr, start, len); \
- imap->tokenptr += len; \
- imap->tokenleft -= len; \
+ memcpy (imap4->tokenptr, start, len); \
+ imap4->tokenptr += len; \
+ imap4->tokenleft -= len; \
} G_STMT_END
-#define token_clear(imap) G_STMT_START { \
- imap->tokenleft += imap->tokenptr - imap->tokenbuf; \
- imap->tokenptr = imap->tokenbuf; \
- imap->literal = 0; \
+#define token_clear(imap4) G_STMT_START { \
+ imap4->tokenleft += imap4->tokenptr - imap4->tokenbuf; \
+ imap4->tokenptr = imap4->tokenbuf; \
+ imap4->literal = 0; \
} G_STMT_END
/**
- * camel_imap_stream_next_token:
- * @stream: imap stream
- * @token: imap token
+ * camel_imap4_stream_next_token:
+ * @stream: imap4 stream
+ * @token: imap4 token
*
- * Reads the next token from the imap stream and saves it in @token.
+ * Reads the next token from the imap4 stream and saves it in @token.
*
* Returns 0 on success or -1 on fail.
**/
int
-camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token)
+camel_imap4_stream_next_token (CamelIMAP4Stream *stream, camel_imap4_token_t *token)
{
register unsigned char *inptr;
unsigned char *inend, *start, *p;
@@ -336,12 +336,12 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
guint32 nz_number;
int ret;
- g_return_val_if_fail (CAMEL_IS_IMAP_STREAM (stream), -1);
- g_return_val_if_fail (stream->mode != CAMEL_IMAP_STREAM_MODE_LITERAL, -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
+ g_return_val_if_fail (stream->mode != CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (token != NULL, -1);
if (stream->unget) {
- memcpy (token, stream->unget, sizeof (camel_imap_token_t));
+ memcpy (token, stream->unget, sizeof (camel_imap4_token_t));
g_free (stream->unget);
stream->unget = NULL;
return 0;
@@ -355,11 +355,11 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
do {
if (inptr == inend) {
- if ((ret = imap_fill (stream)) < 0) {
- token->token = CAMEL_IMAP_TOKEN_ERROR;
+ if ((ret = imap4_fill (stream)) < 0) {
+ token->token = CAMEL_IMAP4_TOKEN_ERROR;
return -1;
} else if (ret == 0) {
- token->token = CAMEL_IMAP_TOKEN_NO_DATA;
+ token->token = CAMEL_IMAP4_TOKEN_NO_DATA;
return 0;
}
@@ -411,7 +411,7 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
/* nul-terminate the atom token */
token_save (stream, "", 1);
- token->token = CAMEL_IMAP_TOKEN_QSTRING;
+ token->token = CAMEL_IMAP4_TOKEN_QSTRING;
token->v.qstring = stream->tokenbuf;
d(fprintf (stderr, "token: \"%s\"\n", token->v.qstring));
@@ -462,12 +462,12 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
/* skip over '\n' */
inptr++;
- token->token = CAMEL_IMAP_TOKEN_LITERAL;
+ token->token = CAMEL_IMAP4_TOKEN_LITERAL;
token->v.literal = literal;
d(fprintf (stderr, "token: {%u}\n", literal));
- stream->mode = CAMEL_IMAP_STREAM_MODE_LITERAL;
+ stream->mode = CAMEL_IMAP4_STREAM_MODE_LITERAL;
stream->literal = literal;
stream->eol = FALSE;
@@ -489,7 +489,7 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
}
inptr = start;
- token->token = CAMEL_IMAP_TOKEN_NUMBER;
+ token->token = CAMEL_IMAP4_TOKEN_NUMBER;
token->v.number = nz_number;
d(fprintf (stderr, "token: %u\n", nz_number));
@@ -515,10 +515,10 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
if (!strcmp (stream->tokenbuf, "NIL")) {
/* special atom token */
- token->token = CAMEL_IMAP_TOKEN_NIL;
+ token->token = CAMEL_IMAP4_TOKEN_NIL;
d(fprintf (stderr, "token: NIL\n"));
} else {
- token->token = CAMEL_IMAP_TOKEN_ATOM;
+ token->token = CAMEL_IMAP4_TOKEN_ATOM;
token->v.atom = stream->tokenbuf;
d(fprintf (stderr, "token: %s\n", token->v.atom));
}
@@ -542,7 +542,7 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
/* nul-terminate the flag token */
token_save (stream, "", 1);
- token->token = CAMEL_IMAP_TOKEN_FLAG;
+ token->token = CAMEL_IMAP4_TOKEN_FLAG;
token->v.atom = stream->tokenbuf;
d(fprintf (stderr, "token: %s\n", token->v.atom));
} else {
@@ -562,8 +562,8 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
refill:
token_clear (stream);
- if (imap_fill (stream) <= 0) {
- token->token = CAMEL_IMAP_TOKEN_ERROR;
+ if (imap4_fill (stream) <= 0) {
+ token->token = CAMEL_IMAP4_TOKEN_ERROR;
return -1;
}
@@ -580,11 +580,11 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
/**
- * camel_imap_stream_unget_token:
- * @stream: imap stream
+ * camel_imap4_stream_unget_token:
+ * @stream: imap4 stream
* @token: token to 'unget'
*
- * Ungets an imap token (as in ungetc()).
+ * Ungets an imap4 token (as in ungetc()).
*
* Note: you may *ONLY* unget a single token. Trying to unget another
* token will fail.
@@ -592,16 +592,16 @@ camel_imap_stream_next_token (CamelIMAPStream *stream, camel_imap_token_t *token
* Returns 0 on success or -1 on fail.
**/
int
-camel_imap_stream_unget_token (CamelIMAPStream *stream, camel_imap_token_t *token)
+camel_imap4_stream_unget_token (CamelIMAP4Stream *stream, camel_imap4_token_t *token)
{
- camel_imap_token_t *unget;
+ camel_imap4_token_t *unget;
if (stream->unget)
return -1;
- if (token->token != CAMEL_IMAP_TOKEN_NO_DATA) {
- stream->unget = unget = g_new (camel_imap_token_t, 1);
- memcpy (unget, token, sizeof (camel_imap_token_t));
+ if (token->token != CAMEL_IMAP4_TOKEN_NO_DATA) {
+ stream->unget = unget = g_new (camel_imap4_token_t, 1);
+ memcpy (unget, token, sizeof (camel_imap4_token_t));
}
return 0;
@@ -609,12 +609,12 @@ camel_imap_stream_unget_token (CamelIMAPStream *stream, camel_imap_token_t *toke
/**
- * camel_imap_stream_readline:
- * @stream: imap stream
+ * camel_imap4_stream_readline:
+ * @stream: imap4 stream
* @line: line pointer
* @len: line length
*
- * Reads a single line from the imap stream and points @line at an
+ * Reads a single line from the imap4 stream and points @line at an
* internal buffer containing the line read and sets @len to the
* length of the line buffer.
*
@@ -622,19 +622,19 @@ camel_imap_stream_unget_token (CamelIMAPStream *stream, camel_imap_token_t *toke
* read is incomplete.
**/
int
-camel_imap_stream_line (CamelIMAPStream *stream, unsigned char **line, size_t *len)
+camel_imap4_stream_line (CamelIMAP4Stream *stream, unsigned char **line, size_t *len)
{
register unsigned char *inptr;
unsigned char *inend;
- g_return_val_if_fail (CAMEL_IS_IMAP_STREAM (stream), -1);
- g_return_val_if_fail (stream->mode != CAMEL_IMAP_STREAM_MODE_LITERAL, -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
+ g_return_val_if_fail (stream->mode != CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (line != NULL, -1);
g_return_val_if_fail (len != NULL, -1);
if ((stream->inend - stream->inptr) < 3) {
/* keep our buffer full to the optimal size */
- if (imap_fill (stream) == -1 && stream->inptr == stream->inend)
+ if (imap4_fill (stream) == -1 && stream->inptr == stream->inend)
return -1;
}
@@ -667,13 +667,13 @@ camel_imap_stream_line (CamelIMAPStream *stream, unsigned char **line, size_t *l
int
-camel_imap_stream_literal (CamelIMAPStream *stream, unsigned char **literal, size_t *len)
+camel_imap4_stream_literal (CamelIMAP4Stream *stream, unsigned char **literal, size_t *len)
{
unsigned char *inptr, *inend;
size_t nread;
- g_return_val_if_fail (CAMEL_IS_IMAP_STREAM (stream), -1);
- g_return_val_if_fail (stream->mode == CAMEL_IMAP_STREAM_MODE_LITERAL, -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
+ g_return_val_if_fail (stream->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (literal != NULL, -1);
g_return_val_if_fail (len != NULL, -1);
@@ -684,7 +684,7 @@ camel_imap_stream_literal (CamelIMAPStream *stream, unsigned char **literal, siz
if ((stream->inend - stream->inptr) < 1) {
/* keep our buffer full to the optimal size */
- if (imap_fill (stream) == -1 && stream->inptr == stream->inend)
+ if (imap4_fill (stream) == -1 && stream->inptr == stream->inend)
return -1;
}
@@ -699,7 +699,7 @@ camel_imap_stream_literal (CamelIMAPStream *stream, unsigned char **literal, siz
stream->literal -= nread;
if (stream->literal == 0) {
- stream->mode = CAMEL_IMAP_STREAM_MODE_TOKEN;
+ stream->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
stream->eol = TRUE;
return 0;
}
diff --git a/camel/providers/imap4/camel-imap4-stream.h b/camel/providers/imap4/camel-imap4-stream.h
new file mode 100644
index 0000000000..7ef8422008
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-stream.h
@@ -0,0 +1,124 @@
+/* -*- 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_STREAM_H__
+#define __CAMEL_IMAP4_STREAM_H__
+
+#include <camel/camel-stream.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define CAMEL_TYPE_IMAP4_STREAM (camel_imap4_stream_get_type ())
+#define CAMEL_IMAP4_STREAM(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP4_STREAM, CamelIMAP4Stream))
+#define CAMEL_IMAP4_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TYPE_IMAP4_STREAM, CamelIMAP4StreamClass))
+#define CAMEL_IS_IMAP4_STREAM(o) (CAMEL_CHECK_TYPE((o), CAMEL_TYPE_IMAP4_STREAM))
+
+typedef struct _CamelIMAP4Stream CamelIMAP4Stream;
+typedef struct _CamelIMAP4StreamClass CamelIMAP4StreamClass;
+
+#define IMAP4_READ_PRELEN 128
+#define IMAP4_READ_BUFLEN 4096
+
+enum {
+ CAMEL_IMAP4_TOKEN_NO_DATA = -8,
+ CAMEL_IMAP4_TOKEN_ERROR = -7,
+ CAMEL_IMAP4_TOKEN_NIL = -6,
+ CAMEL_IMAP4_TOKEN_ATOM = -5,
+ CAMEL_IMAP4_TOKEN_FLAG = -4,
+ CAMEL_IMAP4_TOKEN_NUMBER = -3,
+ CAMEL_IMAP4_TOKEN_QSTRING = -2,
+ CAMEL_IMAP4_TOKEN_LITERAL = -1,
+ /* CAMEL_IMAP4_TOKEN_CHAR would just be the char we got */
+ CAMEL_IMAP4_TOKEN_EOLN = '\n',
+ CAMEL_IMAP4_TOKEN_LPAREN = '(',
+ CAMEL_IMAP4_TOKEN_RPAREN = ')',
+ CAMEL_IMAP4_TOKEN_ASTERISK = '*',
+ CAMEL_IMAP4_TOKEN_PLUS = '+',
+ CAMEL_IMAP4_TOKEN_LBRACKET = '[',
+ CAMEL_IMAP4_TOKEN_RBRACKET = ']',
+};
+
+typedef struct _camel_imap4_token_t {
+ int token;
+ union {
+ char *atom;
+ char *flag;
+ char *qstring;
+ size_t literal;
+ guint32 number;
+ } v;
+} camel_imap4_token_t;
+
+enum {
+ CAMEL_IMAP4_STREAM_MODE_TOKEN = 0,
+ CAMEL_IMAP4_STREAM_MODE_LITERAL = 1,
+};
+
+struct _CamelIMAP4Stream {
+ CamelStream parent_object;
+
+ CamelStream *stream;
+
+ guint disconnected:1; /* disconnected state */
+ guint mode:1; /* TOKEN vs LITERAL */
+ guint eol:1; /* end-of-literal */
+
+ size_t literal;
+
+ /* i/o buffers */
+ unsigned char realbuf[IMAP4_READ_PRELEN + IMAP4_READ_BUFLEN + 1];
+ unsigned char *inbuf;
+ unsigned char *inptr;
+ unsigned char *inend;
+
+ /* token buffers */
+ unsigned char *tokenbuf;
+ unsigned char *tokenptr;
+ unsigned int tokenleft;
+
+ camel_imap4_token_t *unget;
+};
+
+struct _CamelIMAP4StreamClass {
+ CamelStreamClass parent_class;
+
+ /* Virtual methods */
+};
+
+
+/* Standard Camel function */
+CamelType camel_imap4_stream_get_type (void);
+
+CamelStream *camel_imap4_stream_new (CamelStream *stream);
+
+int camel_imap4_stream_next_token (CamelIMAP4Stream *stream, camel_imap4_token_t *token);
+int camel_imap4_stream_unget_token (CamelIMAP4Stream *stream, camel_imap4_token_t *token);
+
+int camel_imap4_stream_line (CamelIMAP4Stream *stream, unsigned char **line, size_t *len);
+int camel_imap4_stream_literal (CamelIMAP4Stream *stream, unsigned char **literal, size_t *len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CAMEL_IMAP4_STREAM_H__ */
diff --git a/camel/providers/imap4/camel-imap-summary.c b/camel/providers/imap4/camel-imap4-summary.c
index d97c93b66c..fdc1e3cd52 100644
--- a/camel/providers/imap4/camel-imap-summary.c
+++ b/camel/providers/imap4/camel-imap4-summary.c
@@ -36,45 +36,45 @@
#include <camel/camel-file-utils.h>
-#include "camel-imap-store.h"
-#include "camel-imap-engine.h"
-#include "camel-imap-folder.h"
-#include "camel-imap-stream.h"
-#include "camel-imap-command.h"
-#include "camel-imap-utils.h"
+#include "camel-imap4-store.h"
+#include "camel-imap4-engine.h"
+#include "camel-imap4-folder.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-command.h"
+#include "camel-imap4-utils.h"
-#include "camel-imap-summary.h"
+#include "camel-imap4-summary.h"
-#define IMAP_SUMMARY_VERSION 1
+#define IMAP4_SUMMARY_VERSION 1
-static void camel_imap_summary_class_init (CamelIMAPSummaryClass *klass);
-static void camel_imap_summary_init (CamelIMAPSummary *summary, CamelIMAPSummaryClass *klass);
-static void camel_imap_summary_finalize (CamelObject *object);
+static void camel_imap4_summary_class_init (CamelIMAP4SummaryClass *klass);
+static void camel_imap4_summary_init (CamelIMAP4Summary *summary, CamelIMAP4SummaryClass *klass);
+static void camel_imap4_summary_finalize (CamelObject *object);
-static int imap_header_load (CamelFolderSummary *summary, FILE *fin);
-static int imap_header_save (CamelFolderSummary *summary, FILE *fout);
-static CamelMessageInfo *imap_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header);
-static CamelMessageInfo *imap_message_info_load (CamelFolderSummary *summary, FILE *fin);
-static int imap_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info);
+static int imap4_header_load (CamelFolderSummary *summary, FILE *fin);
+static int imap4_header_save (CamelFolderSummary *summary, FILE *fout);
+static CamelMessageInfo *imap4_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header);
+static CamelMessageInfo *imap4_message_info_load (CamelFolderSummary *summary, FILE *fin);
+static int imap4_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info);
static CamelFolderSummaryClass *parent_class = NULL;
CamelType
-camel_imap_summary_get_type (void)
+camel_imap4_summary_get_type (void)
{
static CamelType type = 0;
if (!type) {
- type = camel_type_register (CAMEL_TYPE_IMAP_SUMMARY,
- "CamelIMAPSummary",
- sizeof (CamelIMAPSummary),
- sizeof (CamelIMAPSummaryClass),
- (CamelObjectClassInitFunc) camel_imap_summary_class_init,
+ type = camel_type_register (CAMEL_TYPE_IMAP4_SUMMARY,
+ "CamelIMAP4Summary",
+ sizeof (CamelIMAP4Summary),
+ sizeof (CamelIMAP4SummaryClass),
+ (CamelObjectClassInitFunc) camel_imap4_summary_class_init,
NULL,
- (CamelObjectInitFunc) camel_imap_summary_init,
- (CamelObjectFinalizeFunc) camel_imap_summary_finalize);
+ (CamelObjectInitFunc) camel_imap4_summary_init,
+ (CamelObjectFinalizeFunc) camel_imap4_summary_finalize);
}
return type;
@@ -82,91 +82,91 @@ camel_imap_summary_get_type (void)
static void
-camel_imap_summary_class_init (CamelIMAPSummaryClass *klass)
+camel_imap4_summary_class_init (CamelIMAP4SummaryClass *klass)
{
CamelFolderSummaryClass *summary_class = (CamelFolderSummaryClass *) klass;
parent_class = (CamelFolderSummaryClass *) camel_type_get_global_classfuncs (camel_folder_summary_get_type ());
- summary_class->summary_header_load = imap_header_load;
- summary_class->summary_header_save = imap_header_save;
- summary_class->message_info_new = imap_message_info_new;
- summary_class->message_info_load = imap_message_info_load;
- summary_class->message_info_save = imap_message_info_save;
+ summary_class->summary_header_load = imap4_header_load;
+ summary_class->summary_header_save = imap4_header_save;
+ summary_class->message_info_new = imap4_message_info_new;
+ summary_class->message_info_load = imap4_message_info_load;
+ summary_class->message_info_save = imap4_message_info_save;
}
static void
-camel_imap_summary_init (CamelIMAPSummary *summary, CamelIMAPSummaryClass *klass)
+camel_imap4_summary_init (CamelIMAP4Summary *summary, CamelIMAP4SummaryClass *klass)
{
CamelFolderSummary *folder_summary = (CamelFolderSummary *) summary;
- folder_summary->version += IMAP_SUMMARY_VERSION;
+ folder_summary->version += IMAP4_SUMMARY_VERSION;
folder_summary->flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN;
- folder_summary->message_info_size = sizeof (CamelIMAPMessageInfo);
+ folder_summary->message_info_size = sizeof (CamelIMAP4MessageInfo);
}
static void
-camel_imap_summary_finalize (CamelObject *object)
+camel_imap4_summary_finalize (CamelObject *object)
{
;
}
CamelFolderSummary *
-camel_imap_summary_new (CamelFolder *folder)
+camel_imap4_summary_new (CamelFolder *folder)
{
CamelFolderSummary *summary;
- summary = (CamelFolderSummary *) camel_object_new (CAMEL_TYPE_IMAP_SUMMARY);
- ((CamelIMAPSummary *) summary)->folder = folder;
+ summary = (CamelFolderSummary *) camel_object_new (CAMEL_TYPE_IMAP4_SUMMARY);
+ ((CamelIMAP4Summary *) summary)->folder = folder;
return summary;
}
static int
-imap_header_load (CamelFolderSummary *summary, FILE *fin)
+imap4_header_load (CamelFolderSummary *summary, FILE *fin)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_load (summary, fin) == -1)
return -1;
- if (camel_file_util_decode_uint32 (fin, &imap_summary->uidvalidity) == -1)
+ if (camel_file_util_decode_uint32 (fin, &imap4_summary->uidvalidity) == -1)
return -1;
return 0;
}
static int
-imap_header_save (CamelFolderSummary *summary, FILE *fout)
+imap4_header_save (CamelFolderSummary *summary, FILE *fout)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_save (summary, fout) == -1)
return -1;
- if (camel_file_util_encode_uint32 (fout, imap_summary->uidvalidity) == -1)
+ if (camel_file_util_encode_uint32 (fout, imap4_summary->uidvalidity) == -1)
return -1;
return 0;
}
static int
-envelope_decode_address (CamelIMAPEngine *engine, GString *addrs, CamelException *ex)
+envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
gboolean had_name = FALSE;
int part = 0;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token == CAMEL_IMAP_TOKEN_NIL) {
+ if (token.token == CAMEL_IMAP4_TOKEN_NIL) {
return 0;
} else if (token.token != '(') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -174,14 +174,14 @@ envelope_decode_address (CamelIMAPEngine *engine, GString *addrs, CamelException
g_string_append (addrs, ", ");
do {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
switch (token.token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
break;
- case CAMEL_IMAP_TOKEN_ATOM:
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
switch (part) {
case 0:
g_string_append_printf (addrs, "\"%s\" <", token.v.qstring);
@@ -196,18 +196,18 @@ envelope_decode_address (CamelIMAPEngine *engine, GString *addrs, CamelException
}
break;
default:
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
part++;
} while (part < 4);
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
if (token.token != ')') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -215,32 +215,32 @@ envelope_decode_address (CamelIMAPEngine *engine, GString *addrs, CamelException
}
static int
-envelope_decode_addresses (CamelIMAPEngine *engine, char **addrlist, CamelException *ex)
+envelope_decode_addresses (CamelIMAP4Engine *engine, char **addrlist, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
GString *addrs;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- if (token.token == CAMEL_IMAP_TOKEN_NIL) {
+ if (token.token == CAMEL_IMAP4_TOKEN_NIL) {
*addrlist = NULL;
return 0;
} else if (token.token != '(') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
addrs = g_string_new ("");
do {
- if (camel_imap_engine_next_token (engine, &token, ex) == -1) {
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_string_free (addrs, TRUE);
return -1;
}
if (token.token == '(') {
- camel_imap_stream_unget_token (engine->istream, &token);
+ camel_imap4_stream_unget_token (engine->istream, &token);
if (envelope_decode_address (engine, addrs, ex) == -1) {
g_string_free (addrs, TRUE);
@@ -249,7 +249,7 @@ envelope_decode_addresses (CamelIMAPEngine *engine, char **addrlist, CamelExcept
} else if (token.token == ')') {
break;
} else {
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
} while (1);
@@ -261,26 +261,26 @@ envelope_decode_addresses (CamelIMAPEngine *engine, char **addrlist, CamelExcept
}
static int
-envelope_decode_date (CamelIMAPEngine *engine, time_t *date, CamelException *ex)
+envelope_decode_date (CamelIMAP4Engine *engine, time_t *date, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
const char *nstring;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
switch (token.token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
*date = (time_t) -1;
return 0;
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
nstring = token.v.atom;
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
nstring = token.v.qstring;
break;
default:
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -290,25 +290,25 @@ envelope_decode_date (CamelIMAPEngine *engine, time_t *date, CamelException *ex)
}
static int
-envelope_decode_nstring (CamelIMAPEngine *engine, char **nstring, CamelException *ex)
+envelope_decode_nstring (CamelIMAP4Engine *engine, char **nstring, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
switch (token.token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
*nstring = NULL;
break;
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
*nstring = g_strdup (token.v.atom);
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
*nstring = g_strdup (token.v.qstring);
break;
default:
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -348,16 +348,16 @@ decode_references (const char *string)
}
static int
-decode_envelope (CamelIMAPEngine *engine, CamelMessageInfo *info, camel_imap_token_t *token, CamelException *ex)
+decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_token_t *token, CamelException *ex)
{
unsigned char md5sum[16];
char *nstring;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
if (token->token != '(') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
@@ -418,11 +418,11 @@ decode_envelope (CamelIMAPEngine *engine, CamelMessageInfo *info, camel_imap_tok
g_free (nstring);
}
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
if (token->token != ')') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
goto exception;
}
@@ -553,30 +553,30 @@ decode_internaldate (const char *in)
}
enum {
- IMAP_FETCH_ENVELOPE = (1 << 1),
- IMAP_FETCH_FLAGS = (1 << 2),
- IMAP_FETCH_INTERNALDATE = (1 << 3),
- IMAP_FETCH_RFC822SIZE = (1 << 4),
- IMAP_FETCH_UID = (1 << 5),
+ IMAP4_FETCH_ENVELOPE = (1 << 1),
+ IMAP4_FETCH_FLAGS = (1 << 2),
+ IMAP4_FETCH_INTERNALDATE = (1 << 3),
+ IMAP4_FETCH_RFC822SIZE = (1 << 4),
+ IMAP4_FETCH_UID = (1 << 5),
};
-#define IMAP_FETCH_ALL (IMAP_FETCH_ENVELOPE | IMAP_FETCH_FLAGS | IMAP_FETCH_INTERNALDATE | IMAP_FETCH_RFC822SIZE | IMAP_FETCH_UID)
+#define IMAP4_FETCH_ALL (IMAP4_FETCH_ENVELOPE | IMAP4_FETCH_FLAGS | IMAP4_FETCH_INTERNALDATE | IMAP4_FETCH_RFC822SIZE | IMAP4_FETCH_UID)
-struct imap_envelope_t {
+struct imap4_envelope_t {
CamelMessageInfo *info;
guint changed;
};
-struct imap_fetch_all_t {
+struct imap4_fetch_all_t {
CamelFolderSummary *summary;
GHashTable *uid_hash;
GPtrArray *added;
};
static void
-imap_fetch_all_free (struct imap_fetch_all_t *fetch)
+imap4_fetch_all_free (struct imap4_fetch_all_t *fetch)
{
- struct imap_envelope_t *envelope;
+ struct imap4_envelope_t *envelope;
int i;
for (i = 0; i < fetch->added->len; i++) {
@@ -594,9 +594,9 @@ imap_fetch_all_free (struct imap_fetch_all_t *fetch)
}
static void
-imap_fetch_all_add (struct imap_fetch_all_t *fetch)
+imap4_fetch_all_add (struct imap4_fetch_all_t *fetch)
{
- struct imap_envelope_t *envelope;
+ struct imap4_envelope_t *envelope;
CamelMessageInfo *info;
int i;
@@ -604,8 +604,8 @@ imap_fetch_all_add (struct imap_fetch_all_t *fetch)
if (!(envelope = fetch->added->pdata[i]))
continue;
- if (envelope->changed != IMAP_FETCH_ALL) {
- fprintf (stderr, "Hmmm, IMAP server didn't give us everything for message %d\n", i + 1);
+ if (envelope->changed != IMAP4_FETCH_ALL) {
+ fprintf (stderr, "Hmmm, IMAP4 server didn't give us everything for message %d\n", i + 1);
camel_folder_summary_info_free (fetch->summary, envelope->info);
g_free (envelope);
continue;
@@ -628,10 +628,10 @@ imap_fetch_all_add (struct imap_fetch_all_t *fetch)
}
static guint32
-imap_fetch_all_update (struct imap_fetch_all_t *fetch)
+imap4_fetch_all_update (struct imap4_fetch_all_t *fetch)
{
- CamelIMAPMessageInfo *iinfo, *new_iinfo;
- struct imap_envelope_t *envelope;
+ CamelIMAP4MessageInfo *iinfo, *new_iinfo;
+ struct imap4_envelope_t *envelope;
CamelMessageInfo *info;
guint32 first = 0;
int scount, i;
@@ -644,12 +644,12 @@ imap_fetch_all_update (struct imap_fetch_all_t *fetch)
camel_folder_summary_remove (fetch->summary, info);
scount--;
i--;
- } else if (envelope->changed & IMAP_FETCH_FLAGS) {
+ } else if (envelope->changed & IMAP4_FETCH_FLAGS) {
/* update it with the new flags */
- new_iinfo = (CamelIMAPMessageInfo *) envelope->info;
- iinfo = (CamelIMAPMessageInfo *) info;
+ new_iinfo = (CamelIMAP4MessageInfo *) envelope->info;
+ iinfo = (CamelIMAP4MessageInfo *) info;
- info->flags = camel_imap_merge_flags (iinfo->server_flags, info->flags, new_iinfo->server_flags);
+ info->flags = camel_imap4_merge_flags (iinfo->server_flags, info->flags, new_iinfo->server_flags);
iinfo->server_flags = new_iinfo->server_flags;
}
@@ -682,13 +682,13 @@ imap_fetch_all_update (struct imap_fetch_all_t *fetch)
}
static int
-untagged_fetch_all (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, camel_imap_token_t *token, CamelException *ex)
+untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
{
- struct imap_fetch_all_t *fetch = ic->user_data;
+ struct imap4_fetch_all_t *fetch = ic->user_data;
CamelFolderSummary *summary = fetch->summary;
- struct imap_envelope_t *envelope;
+ struct imap4_envelope_t *envelope;
GPtrArray *added = fetch->added;
- CamelIMAPMessageInfo *iinfo;
+ CamelIMAP4MessageInfo *iinfo;
CamelMessageInfo *info;
char uid[12];
@@ -696,81 +696,81 @@ untagged_fetch_all (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index
g_ptr_array_set_size (added, index);
if (!(envelope = added->pdata[index - 1])) {
- iinfo = (CamelIMAPMessageInfo *) info = camel_folder_summary_info_new (summary);
- envelope = g_new (struct imap_envelope_t, 1);
+ iinfo = (CamelIMAP4MessageInfo *) info = camel_folder_summary_info_new (summary);
+ envelope = g_new (struct imap4_envelope_t, 1);
added->pdata[index - 1] = envelope;
envelope->info = info;
envelope->changed = 0;
} else {
- iinfo = (CamelIMAPMessageInfo *) info = envelope->info;
+ iinfo = (CamelIMAP4MessageInfo *) info = envelope->info;
}
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
/* parse the FETCH response list */
if (token->token != '(') {
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
do {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
if (token->token == ')' || token->token == '\n')
break;
- if (token->token != CAMEL_IMAP_TOKEN_ATOM)
+ if (token->token != CAMEL_IMAP4_TOKEN_ATOM)
goto unexpected;
if (!strcmp (token->v.atom, "ENVELOPE")) {
if (decode_envelope (engine, info, token, ex) == -1)
goto exception;
- envelope->changed |= IMAP_FETCH_ENVELOPE;
+ envelope->changed |= IMAP4_FETCH_ENVELOPE;
} else if (!strcmp (token->v.atom, "FLAGS")) {
guint32 server_flags = 0;
- if (camel_imap_parse_flags_list (engine, &server_flags, ex) == -1)
+ if (camel_imap4_parse_flags_list (engine, &server_flags, ex) == -1)
return -1;
- info->flags = camel_imap_merge_flags (iinfo->server_flags, info->flags, server_flags);
+ info->flags = camel_imap4_merge_flags (iinfo->server_flags, info->flags, server_flags);
iinfo->server_flags = server_flags;
- envelope->changed |= IMAP_FETCH_FLAGS;
+ envelope->changed |= IMAP4_FETCH_FLAGS;
} else if (!strcmp (token->v.atom, "INTERNALDATE")) {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
switch (token->token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
info->date_received = (time_t) -1;
break;
- case CAMEL_IMAP_TOKEN_ATOM:
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
info->date_received = decode_internaldate (token->v.qstring);
break;
default:
goto unexpected;
}
- envelope->changed |= IMAP_FETCH_INTERNALDATE;
+ envelope->changed |= IMAP4_FETCH_INTERNALDATE;
} else if (!strcmp (token->v.atom, "RFC822.SIZE")) {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
- if (token->token != CAMEL_IMAP_TOKEN_NUMBER)
+ if (token->token != CAMEL_IMAP4_TOKEN_NUMBER)
goto unexpected;
info->size = token->v.number;
- envelope->changed |= IMAP_FETCH_RFC822SIZE;
+ envelope->changed |= IMAP4_FETCH_RFC822SIZE;
} else if (!strcmp (token->v.atom, "UID")) {
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
- if (token->token != CAMEL_IMAP_TOKEN_NUMBER || token->v.number == 0)
+ if (token->token != CAMEL_IMAP4_TOKEN_NUMBER || token->v.number == 0)
goto unexpected;
sprintf (uid, "%u", token->v.number);
@@ -786,7 +786,7 @@ untagged_fetch_all (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index
camel_message_info_set_uid (info, g_strdup (uid));
g_hash_table_insert (fetch->uid_hash, (void *) camel_message_info_uid (info), envelope);
- envelope->changed |= IMAP_FETCH_UID;
+ envelope->changed |= IMAP4_FETCH_UID;
} else {
/* wtf? */
fprintf (stderr, "huh? %s?...\n", token->v.atom);
@@ -800,25 +800,25 @@ untagged_fetch_all (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index
unexpected:
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
exception:
return -1;
}
-static CamelIMAPCommand *
-imap_summary_fetch_all (CamelFolderSummary *summary, guint32 first, guint32 last)
+static CamelIMAP4Command *
+imap4_summary_fetch_all (CamelFolderSummary *summary, guint32 first, guint32 last)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
- CamelFolder *folder = imap_summary->folder;
- struct imap_fetch_all_t *fetch;
- CamelIMAPEngine *engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
+ CamelFolder *folder = imap4_summary->folder;
+ struct imap4_fetch_all_t *fetch;
+ CamelIMAP4Engine *engine;
+ CamelIMAP4Command *ic;
- engine = ((CamelIMAPStore *) folder->parent_store)->engine;
+ engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
- fetch = g_new (struct imap_fetch_all_t, 1);
+ fetch = g_new (struct imap4_fetch_all_t, 1);
fetch->uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
fetch->added = g_ptr_array_new ();
fetch->summary = summary;
@@ -832,38 +832,38 @@ imap_summary_fetch_all (CamelFolderSummary *summary, guint32 first, guint32 last
**/
if (last != 0)
- ic = camel_imap_engine_queue (engine, folder, "FETCH %u:%u (UID ALL)\r\n", first, last);
+ ic = camel_imap4_engine_queue (engine, folder, "FETCH %u:%u (UID ALL)\r\n", first, last);
else
- ic = camel_imap_engine_queue (engine, folder, "FETCH %u:* (UID ALL)\r\n", first);
+ ic = camel_imap4_engine_queue (engine, folder, "FETCH %u:* (UID ALL)\r\n", first);
- camel_imap_command_register_untagged (ic, "FETCH", untagged_fetch_all);
+ camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch_all);
ic->user_data = fetch;
return ic;
}
-static CamelIMAPCommand *
-imap_summary_fetch_flags (CamelFolderSummary *summary, guint32 first, guint32 last)
+static CamelIMAP4Command *
+imap4_summary_fetch_flags (CamelFolderSummary *summary, guint32 first, guint32 last)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
- CamelFolder *folder = imap_summary->folder;
- struct imap_fetch_all_t *fetch;
- CamelIMAPEngine *engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
+ CamelFolder *folder = imap4_summary->folder;
+ struct imap4_fetch_all_t *fetch;
+ CamelIMAP4Engine *engine;
+ CamelIMAP4Command *ic;
- engine = ((CamelIMAPStore *) folder->parent_store)->engine;
+ engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
- fetch = g_new (struct imap_fetch_all_t, 1);
+ fetch = g_new (struct imap4_fetch_all_t, 1);
fetch->uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
fetch->added = g_ptr_array_new ();
fetch->summary = summary;
if (last != 0)
- ic = camel_imap_engine_queue (engine, folder, "FETCH %u:%u (UID FLAGS)\r\n", first, last);
+ ic = camel_imap4_engine_queue (engine, folder, "FETCH %u:%u (UID FLAGS)\r\n", first, last);
else
- ic = camel_imap_engine_queue (engine, folder, "FETCH %u:* (UID FLAGS)\r\n", first);
+ ic = camel_imap4_engine_queue (engine, folder, "FETCH %u:* (UID FLAGS)\r\n", first);
- camel_imap_command_register_untagged (ic, "FETCH", untagged_fetch_all);
+ camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch_all);
ic->user_data = fetch;
return ic;
@@ -871,59 +871,59 @@ imap_summary_fetch_flags (CamelFolderSummary *summary, guint32 first, guint32 la
#if 0
static int
-imap_build_summary (CamelFolderSummary *summary, guint32 first, guint32 last)
+imap4_build_summary (CamelFolderSummary *summary, guint32 first, guint32 last)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
- CamelFolder *folder = imap_summary->folder;
- struct imap_fetch_all_t *fetch;
- CamelIMAPEngine *engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
+ CamelFolder *folder = imap4_summary->folder;
+ struct imap4_fetch_all_t *fetch;
+ CamelIMAP4Engine *engine;
+ CamelIMAP4Command *ic;
int id;
- engine = ((CamelIMAPStore *) folder->store)->engine;
+ engine = ((CamelIMAP4Store *) folder->store)->engine;
- ic = imap_summary_fetch_all (summary, first, last);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ ic = imap4_summary_fetch_all (summary, first, last);
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
fetch = ic->user_data;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
- camel_imap_command_unref (ic);
- imap_fetch_all_free (fetch);
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
+ camel_imap4_command_unref (ic);
+ imap4_fetch_all_free (fetch);
return -1;
}
- imap_fetch_all_add (fetch);
+ imap4_fetch_all_add (fetch);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return 0;
}
#endif
static CamelMessageInfo *
-imap_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header)
+imap4_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header)
{
CamelMessageInfo *info;
info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_new (summary, header);
- ((CamelIMAPMessageInfo *) info)->server_flags = 0;
+ ((CamelIMAP4MessageInfo *) info)->server_flags = 0;
return info;
}
static CamelMessageInfo *
-imap_message_info_load (CamelFolderSummary *summary, FILE *fin)
+imap4_message_info_load (CamelFolderSummary *summary, FILE *fin)
{
- CamelIMAPMessageInfo *minfo;
+ CamelIMAP4MessageInfo *minfo;
CamelMessageInfo *info;
if (!(info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_load (summary, fin)))
return NULL;
- minfo = (CamelIMAPMessageInfo *) info;
+ minfo = (CamelIMAP4MessageInfo *) info;
if (camel_file_util_decode_uint32 (fin, &minfo->server_flags) == -1)
goto exception;
@@ -938,9 +938,9 @@ imap_message_info_load (CamelFolderSummary *summary, FILE *fin)
}
static int
-imap_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info)
+imap4_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info)
{
- CamelIMAPMessageInfo *minfo = (CamelIMAPMessageInfo *) info;
+ CamelIMAP4MessageInfo *minfo = (CamelIMAP4MessageInfo *) info;
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_save (summary, fout, info) == -1)
return -1;
@@ -953,69 +953,69 @@ imap_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInf
void
-camel_imap_summary_set_exists (CamelFolderSummary *summary, guint32 exists)
+camel_imap4_summary_set_exists (CamelFolderSummary *summary, guint32 exists)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
- imap_summary->exists = exists;
+ imap4_summary->exists = exists;
- imap_summary->exists_changed = TRUE;
+ imap4_summary->exists_changed = TRUE;
}
void
-camel_imap_summary_set_recent (CamelFolderSummary *summary, guint32 recent)
+camel_imap4_summary_set_recent (CamelFolderSummary *summary, guint32 recent)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
- imap_summary->recent = recent;
+ imap4_summary->recent = recent;
}
void
-camel_imap_summary_set_unseen (CamelFolderSummary *summary, guint32 unseen)
+camel_imap4_summary_set_unseen (CamelFolderSummary *summary, guint32 unseen)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
- imap_summary->unseen = unseen;
+ imap4_summary->unseen = unseen;
}
void
-camel_imap_summary_set_uidnext (CamelFolderSummary *summary, guint32 uidnext)
+camel_imap4_summary_set_uidnext (CamelFolderSummary *summary, guint32 uidnext)
{
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
summary->nextuid = uidnext;
}
void
-camel_imap_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidvalidity)
+camel_imap4_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidvalidity)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
- if (imap_summary->uidvalidity == uidvalidity)
+ if (imap4_summary->uidvalidity == uidvalidity)
return;
/* FIXME: emit a signal or something first? */
camel_folder_summary_clear (summary);
- imap_summary->uidvalidity = uidvalidity;
+ imap4_summary->uidvalidity = uidvalidity;
- imap_summary->uidvalidity_changed = TRUE;
+ imap4_summary->uidvalidity_changed = TRUE;
}
void
-camel_imap_summary_expunge (CamelFolderSummary *summary, int seqid)
+camel_imap4_summary_expunge (CamelFolderSummary *summary, int seqid)
{
CamelMessageInfo *info;
- g_return_if_fail (CAMEL_IS_IMAP_SUMMARY (summary));
+ g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
if (!(info = camel_folder_summary_index (summary, seqid)))
return;
@@ -1046,62 +1046,62 @@ info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
}
int
-camel_imap_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex)
+camel_imap4_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex)
{
- CamelIMAPSummary *imap_summary = (CamelIMAPSummary *) summary;
- CamelIMAPEngine *engine;
- CamelIMAPCommand *ic;
+ CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
+ CamelIMAP4Engine *engine;
+ CamelIMAP4Command *ic;
guint32 first = 0;
int scount, id;
- g_return_val_if_fail (CAMEL_IS_IMAP_SUMMARY (summary), -1);
+ g_return_val_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary), -1);
- engine = ((CamelIMAPStore *) imap_summary->folder->parent_store)->engine;
+ engine = ((CamelIMAP4Store *) imap4_summary->folder->parent_store)->engine;
- if (imap_summary->uidvalidity_changed) {
+ if (imap4_summary->uidvalidity_changed) {
first = 1;
- } else if (imap_summary->exists_changed) {
+ } else if (imap4_summary->exists_changed) {
scount = camel_folder_summary_count (summary);
- ic = imap_summary_fetch_flags (summary, 1, scount);
+ ic = imap4_summary_fetch_flags (summary, 1, scount);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
- imap_fetch_all_free (ic->user_data);
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
+ imap4_fetch_all_free (ic->user_data);
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return -1;
}
- if (!(first = imap_fetch_all_update (ic->user_data)) && imap_summary->exists > scount)
+ if (!(first = imap4_fetch_all_update (ic->user_data)) && imap4_summary->exists > scount)
first = scount + 1;
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
}
if (first != 0) {
- ic = imap_summary_fetch_all (summary, first, 0);
+ ic = imap4_summary_fetch_all (summary, first, 0);
- while ((id = camel_imap_engine_iterate (engine)) < ic->id && id != -1)
+ while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
- if (id == -1 || ic->status != CAMEL_IMAP_COMMAND_COMPLETE) {
- imap_fetch_all_free (ic->user_data);
+ if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
+ imap4_fetch_all_free (ic->user_data);
camel_exception_xfer (ex, &ic->ex);
- camel_imap_command_unref (ic);
+ camel_imap4_command_unref (ic);
return -1;
}
- imap_fetch_all_add (ic->user_data);
- camel_imap_command_unref (ic);
+ imap4_fetch_all_add (ic->user_data);
+ camel_imap4_command_unref (ic);
/* it's important for these to be sorted sequentially for EXPUNGE events to work */
g_ptr_array_sort (summary->messages, (GCompareFunc) info_uid_sort);
}
- imap_summary->exists_changed = FALSE;
- imap_summary->uidvalidity_changed = FALSE;
+ imap4_summary->exists_changed = FALSE;
+ imap4_summary->uidvalidity_changed = FALSE;
return 0;
}
diff --git a/camel/providers/imap4/camel-imap4-summary.h b/camel/providers/imap4/camel-imap4-summary.h
new file mode 100644
index 0000000000..6b5e906960
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-summary.h
@@ -0,0 +1,91 @@
+/* -*- 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_SUMMARY_H__
+#define __CAMEL_IMAP4_SUMMARY_H__
+
+#include <sys/types.h>
+
+#include <camel/camel-folder.h>
+#include <camel/camel-folder-summary.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define CAMEL_TYPE_IMAP4_SUMMARY (camel_imap4_summary_get_type ())
+#define CAMEL_IMAP4_SUMMARY(obj) (CAMEL_CHECK_CAST ((obj), CAMEL_TYPE_IMAP4_SUMMARY, CamelIMAP4Summary))
+#define CAMEL_IMAP4_SUMMARY_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_IMAP4_SUMMARY, CamelIMAP4SummaryClass))
+#define CAMEL_IS_IMAP4_SUMMARY(obj) (CAMEL_CHECK_TYPE ((obj), CAMEL_TYPE_IMAP4_SUMMARY))
+#define CAMEL_IS_IMAP4_SUMMARY_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), CAMEL_TYPE_IMAP4_SUMMARY))
+#define CAMEL_IMAP4_SUMMARY_GET_CLASS(obj) (CAMEL_CHECK_GET_CLASS ((obj), CAMEL_TYPE_FOLDER_SUMMARY, CamelIMAP4SummaryClass))
+
+typedef struct _CamelIMAP4MessageInfo CamelIMAP4MessageInfo;
+typedef struct _CamelIMAP4Summary CamelIMAP4Summary;
+typedef struct _CamelIMAP4SummaryClass CamelIMAP4SummaryClass;
+
+struct _CamelIMAP4MessageInfo {
+ CamelMessageInfo parent_info;
+
+ guint32 server_flags;
+};
+
+struct _CamelIMAP4Summary {
+ CamelFolderSummary parent_object;
+
+ CamelFolder *folder;
+
+ guint32 exists;
+ guint32 recent;
+ guint32 unseen;
+
+ guint32 uidvalidity;
+
+ guint uidvalidity_changed:1;
+ guint exists_changed:1;
+};
+
+struct _CamelIMAP4SummaryClass {
+ CamelFolderSummaryClass parent_class;
+
+};
+
+
+CamelType camel_imap4_summary_get_type (void);
+
+CamelFolderSummary *camel_imap4_summary_new (CamelFolder *folder);
+
+void camel_imap4_summary_set_exists (CamelFolderSummary *summary, guint32 exists);
+void camel_imap4_summary_set_recent (CamelFolderSummary *summary, guint32 recent);
+void camel_imap4_summary_set_unseen (CamelFolderSummary *summary, guint32 unseen);
+void camel_imap4_summary_set_uidnext (CamelFolderSummary *summary, guint32 uidnext);
+
+void camel_imap4_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidvalidity);
+
+void camel_imap4_summary_expunge (CamelFolderSummary *summary, int seqid);
+
+int camel_imap4_summary_flush_updates (CamelFolderSummary *summary, CamelException *ex);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CAMEL_IMAP4_SUMMARY_H__ */
diff --git a/camel/providers/imap4/camel-imap-utils.c b/camel/providers/imap4/camel-imap4-utils.c
index 129c7b83af..67dd828134 100644
--- a/camel/providers/imap4/camel-imap-utils.c
+++ b/camel/providers/imap4/camel-imap4-utils.c
@@ -26,17 +26,19 @@
#include <string.h>
#include <errno.h>
-#include "camel-imap-engine.h"
-#include "camel-imap-stream.h"
-#include "camel-imap-command.h"
+#include <camel/camel-store.h>
-#include "camel-imap-utils.h"
+#include "camel-imap4-engine.h"
+#include "camel-imap4-stream.h"
+#include "camel-imap4-command.h"
+
+#include "camel-imap4-utils.h"
#define d(x) x
void
-camel_imap_flags_diff (flags_diff_t *diff, guint32 old, guint32 new)
+camel_imap4_flags_diff (flags_diff_t *diff, guint32 old, guint32 new)
{
diff->changed = old ^ new;
diff->bits = new & diff->changed;
@@ -44,14 +46,14 @@ camel_imap_flags_diff (flags_diff_t *diff, guint32 old, guint32 new)
guint32
-camel_imap_flags_merge (flags_diff_t *diff, guint32 flags)
+camel_imap4_flags_merge (flags_diff_t *diff, guint32 flags)
{
return (flags & ~diff->changed) | diff->bits;
}
/**
- * camel_imap_merge_flags:
+ * camel_imap4_merge_flags:
* @original: original server flags
* @local: local flags (after changes)
* @server: new server flags (another client updated the server flags)
@@ -61,18 +63,18 @@ camel_imap_flags_merge (flags_diff_t *diff, guint32 flags)
* Returns the merged flags.
**/
guint32
-camel_imap_merge_flags (guint32 original, guint32 local, guint32 server)
+camel_imap4_merge_flags (guint32 original, guint32 local, guint32 server)
{
flags_diff_t diff;
- camel_imap_flags_diff (&diff, original, local);
+ camel_imap4_flags_diff (&diff, original, local);
- return camel_imap_flags_merge (&diff, server);
+ return camel_imap4_flags_merge (&diff, server);
}
void
-camel_imap_utils_set_unexpected_token_error (CamelException *ex, CamelIMAPEngine *engine, camel_imap_token_t *token)
+camel_imap4_utils_set_unexpected_token_error (CamelException *ex, CamelIMAP4Engine *engine, camel_imap4_token_t *token)
{
GString *errmsg;
@@ -84,25 +86,25 @@ camel_imap_utils_set_unexpected_token_error (CamelException *ex, CamelIMAPEngine
engine->url->host);
switch (token->token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
g_string_append (errmsg, "NIL");
break;
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
g_string_append (errmsg, token->v.atom);
break;
- case CAMEL_IMAP_TOKEN_FLAG:
+ case CAMEL_IMAP4_TOKEN_FLAG:
g_string_append (errmsg, token->v.flag);
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
g_string_append (errmsg, token->v.qstring);
break;
- case CAMEL_IMAP_TOKEN_LITERAL:
+ case CAMEL_IMAP4_TOKEN_LITERAL:
g_string_append_printf (errmsg, "{%u}", token->v.literal);
break;
- case CAMEL_IMAP_TOKEN_NUMBER:
+ case CAMEL_IMAP4_TOKEN_NUMBER:
g_string_append_printf (errmsg, "%u", token->v.number);
break;
- case CAMEL_IMAP_TOKEN_NO_DATA:
+ case CAMEL_IMAP4_TOKEN_NO_DATA:
g_string_append (errmsg, _("No data"));
break;
default:
@@ -119,7 +121,7 @@ camel_imap_utils_set_unexpected_token_error (CamelException *ex, CamelIMAPEngine
static struct {
const char *name;
guint32 flag;
-} imap_flags[] = {
+} imap4_flags[] = {
{ "\\Answered", CAMEL_MESSAGE_ANSWERED },
{ "\\Deleted", CAMEL_MESSAGE_DELETED },
{ "\\Draft", CAMEL_MESSAGE_DRAFT },
@@ -133,64 +135,64 @@ static struct {
static struct {
const char *name;
guint32 flag;
-} imap_user_flags[] = {
+} imap4_user_flags[] = {
{ "Forwarded", CAMEL_MESSAGE_FORWARDED },
};
#endif
int
-camel_imap_parse_flags_list (CamelIMAPEngine *engine, guint32 *flags, CamelException *ex)
+camel_imap4_parse_flags_list (CamelIMAP4Engine *engine, guint32 *flags, CamelException *ex)
{
- camel_imap_token_t token;
+ camel_imap4_token_t token;
guint32 new = 0;
int i;
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
if (token.token != '(') {
d(fprintf (stderr, "Expected to find a '(' token starting the flags list\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
- while (token.token == CAMEL_IMAP_TOKEN_ATOM || token.token == CAMEL_IMAP_TOKEN_FLAG) {
+ while (token.token == CAMEL_IMAP4_TOKEN_ATOM || token.token == CAMEL_IMAP4_TOKEN_FLAG) {
/* parse the flags list */
- for (i = 0; i < G_N_ELEMENTS (imap_flags); i++) {
- if (!strcasecmp (imap_flags[i].name, token.v.atom)) {
- new |= imap_flags[i].flag;
+ for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
+ if (!strcasecmp (imap4_flags[i].name, token.v.atom)) {
+ new |= imap4_flags[i].flag;
break;
}
}
#if 0
- if (i == G_N_ELEMENTS (imap_flags)) {
- for (i = 0; i < G_N_ELEMENTS (imap_user_flags); i++) {
- if (!strcasecmp (imap_user_flags[i].name, token.v.atom)) {
- new |= imap_user_flags[i].flag;
+ if (i == G_N_ELEMENTS (imap4_flags)) {
+ for (i = 0; i < G_N_ELEMENTS (imap4_user_flags); i++) {
+ if (!strcasecmp (imap4_user_flags[i].name, token.v.atom)) {
+ new |= imap4_user_flags[i].flag;
break;
}
}
- if (i == G_N_ELEMENTS (imap_user_flags))
+ if (i == G_N_ELEMENTS (imap4_user_flags))
fprintf (stderr, "Encountered unknown flag: %s\n", token.v.atom);
}
#else
- if (i == G_N_ELEMENTS (imap_flags))
+ if (i == G_N_ELEMENTS (imap4_flags))
fprintf (stderr, "Encountered unknown flag: %s\n", token.v.atom);
#endif
- if (camel_imap_engine_next_token (engine, &token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
}
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' token terminating the flags list\n"));
- camel_imap_utils_set_unexpected_token_error (ex, engine, &token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
@@ -204,19 +206,19 @@ struct {
const char *name;
guint32 flag;
} list_flags[] = {
- { "\\Marked", CAMEL_IMAP_FOLDER_MARKED },
- { "\\Unmarked", CAMEL_IMAP_FOLDER_UNMARKED },
- { "\\Noselect", CAMEL_IMAP_FOLDER_NOSELECT },
- { "\\Noinferiors", CAMEL_IMAP_FOLDER_NOINFERIORS },
- { "\\HasChildren", CAMEL_IMAP_FOLDER_HAS_CHILDREN },
- { "\\HasNoChildren", CAMEL_IMAP_FOLDER_HAS_NO_CHILDREN },
+ { "\\Marked", CAMEL_IMAP4_FOLDER_MARKED },
+ { "\\Unmarked", CAMEL_IMAP4_FOLDER_UNMARKED },
+ { "\\Noselect", CAMEL_FOLDER_NOSELECT },
+ { "\\Noinferiors", CAMEL_FOLDER_NOINFERIORS },
+ { "\\HasChildren", CAMEL_FOLDER_CHILDREN },
+ { "\\HasNoChildren", CAMEL_FOLDER_NOCHILDREN },
};
int
-camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32 index, camel_imap_token_t *token, CamelException *ex)
+camel_imap4_untagged_list (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
{
GPtrArray *array = ic->user_data;
- camel_imap_list_t *list;
+ camel_imap4_list_t *list;
unsigned char *buf;
guint32 flags = 0;
GString *literal;
@@ -224,17 +226,17 @@ camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32
size_t n;
int i;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
/* parse the flag list */
if (token->token != '(')
goto unexpected;
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
- while (token->token == CAMEL_IMAP_TOKEN_FLAG || token->token == CAMEL_IMAP_TOKEN_ATOM) {
+ while (token->token == CAMEL_IMAP4_TOKEN_FLAG || token->token == CAMEL_IMAP4_TOKEN_ATOM) {
for (i = 0; i < G_N_ELEMENTS (list_flags); i++) {
if (!g_ascii_strcasecmp (list_flags[i].name, token->v.atom)) {
flags |= list_flags[i].flag;
@@ -242,7 +244,7 @@ camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32
}
}
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
}
@@ -250,14 +252,14 @@ camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32
goto unexpected;
/* parse the path delimiter */
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
switch (token->token) {
- case CAMEL_IMAP_TOKEN_NIL:
+ case CAMEL_IMAP4_TOKEN_NIL:
delim = '\0';
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
delim = *token->v.qstring;
break;
default:
@@ -265,23 +267,23 @@ camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32
}
/* parse the folder name */
- if (camel_imap_engine_next_token (engine, token, ex) == -1)
+ if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
- list = g_new (camel_imap_list_t, 1);
+ list = g_new (camel_imap4_list_t, 1);
list->flags = flags;
list->delim = delim;
switch (token->token) {
- case CAMEL_IMAP_TOKEN_ATOM:
+ case CAMEL_IMAP4_TOKEN_ATOM:
list->name = g_strdup (token->v.atom);
break;
- case CAMEL_IMAP_TOKEN_QSTRING:
+ case CAMEL_IMAP4_TOKEN_QSTRING:
list->name = g_strdup (token->v.qstring);
break;
- case CAMEL_IMAP_TOKEN_LITERAL:
+ case CAMEL_IMAP4_TOKEN_LITERAL:
literal = g_string_new ("");
- while ((i = camel_imap_stream_literal (engine->istream, &buf, &n)) == 1)
+ while ((i = camel_imap4_stream_literal (engine->istream, &buf, &n)) == 1)
g_string_append_len (literal, buf, n);
if (i == -1) {
@@ -303,11 +305,11 @@ camel_imap_untagged_list (CamelIMAPEngine *engine, CamelIMAPCommand *ic, guint32
g_ptr_array_add (array, list);
- return camel_imap_engine_eat_line (engine, ex);
+ return camel_imap4_engine_eat_line (engine, ex);
unexpected:
- camel_imap_utils_set_unexpected_token_error (ex, engine, token);
+ camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
diff --git a/camel/providers/imap4/camel-imap4-utils.h b/camel/providers/imap4/camel-imap4-utils.h
new file mode 100644
index 0000000000..ace7b4cad0
--- /dev/null
+++ b/camel/providers/imap4/camel-imap4-utils.h
@@ -0,0 +1,67 @@
+/* -*- 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_UTILS_H__
+#define __CAMEL_IMAP4_UTILS_H__
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* IMAP4 flag merging */
+typedef struct {
+ guint32 changed;
+ guint32 bits;
+} flags_diff_t;
+
+void camel_imap4_flags_diff (flags_diff_t *diff, guint32 old, guint32 new);
+guint32 camel_imap4_flags_merge (flags_diff_t *diff, guint32 flags);
+guint32 camel_imap4_merge_flags (guint32 original, guint32 local, guint32 server);
+
+
+struct _CamelIMAP4Engine;
+struct _CamelIMAP4Command;
+struct _camel_imap4_token_t;
+
+void camel_imap4_utils_set_unexpected_token_error (CamelException *ex, struct _CamelIMAP4Engine *engine, struct _camel_imap4_token_t *token);
+
+int camel_imap4_parse_flags_list (struct _CamelIMAP4Engine *engine, guint32 *flags, CamelException *ex);
+
+/* Note: make sure these don't clash with any bit flags in camel-store.h */
+#define CAMEL_IMAP4_FOLDER_MARKED (1 << 17)
+#define CAMEL_IMAP4_FOLDER_UNMARKED (1 << 18)
+
+typedef struct {
+ guint32 flags;
+ char delim;
+ char *name;
+} camel_imap4_list_t;
+
+int camel_imap4_untagged_list (struct _CamelIMAP4Engine *engine, struct _CamelIMAP4Command *ic,
+ guint32 index, struct _camel_imap4_token_t *token, CamelException *ex);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CAMEL_IMAP4_UTILS_H__ */