1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/* -*- 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 <libedataserver/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__ */
|