~ubuntu-branches/ubuntu/vivid/dovecot/vivid

« back to all changes in this revision

Viewing changes to src/imap/client.h

  • Committer: Bazaar Package Importer
  • Author(s): Jaldhar H. Vyas
  • Date: 2005-11-05 23:19:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051105231919-ydujs4y7687fpor2
Tags: upstream-1.0.alpha4
ImportĀ upstreamĀ versionĀ 1.0.alpha4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef __CLIENT_H
2
2
#define __CLIENT_H
3
3
 
 
4
#include "commands.h"
 
5
 
4
6
struct client;
5
7
struct mail_storage;
6
8
struct imap_parser;
7
9
struct imap_arg;
8
10
 
9
 
typedef int command_func_t(struct client *client);
10
 
 
11
 
struct mailbox_custom_flags {
 
11
struct mailbox_keywords {
12
12
        pool_t pool; /* will be p_clear()ed when changed */
13
13
 
14
 
        char **custom_flags;
15
 
        unsigned int custom_flags_count;
 
14
        array_t ARRAY_DEFINE(keywords, const char *);
 
15
};
 
16
 
 
17
struct client_command_context {
 
18
        struct client *client;
 
19
 
 
20
        pool_t pool;
 
21
        const char *tag;
 
22
        const char *name;
 
23
 
 
24
        command_func_t *func;
 
25
        void *context;
 
26
 
 
27
        unsigned int uid:1; /* used UID command */
 
28
        unsigned int param_error:1;
16
29
};
17
30
 
18
31
struct client {
21
34
        struct istream *input;
22
35
        struct ostream *output;
23
36
 
24
 
        struct mail_storage *storage;
 
37
        struct namespace *namespaces;
25
38
        struct mailbox *mailbox;
26
 
        struct mailbox_custom_flags mailbox_flags;
 
39
        struct mailbox_keywords keywords;
27
40
        unsigned int select_counter; /* increased when mailbox is changed */
 
41
        uint32_t messages_count, recent_count;
28
42
 
29
 
        time_t last_input;
 
43
        time_t last_input, last_output;
30
44
        unsigned int bad_counter;
31
45
 
32
46
        struct imap_parser *parser;
33
 
        const char *cmd_tag; /* tag of command (allocated from parser pool), */
34
 
        const char *cmd_name; /* command name (allocated from parser pool) */
35
 
        command_func_t *cmd_func;
36
 
 
37
 
        struct timeout *idle_to;
38
 
        unsigned int idle_expunge;
39
 
 
40
 
        unsigned int cmd_error:1;
41
 
        unsigned int cmd_uid:1; /* used UID command */
42
 
        unsigned int sync_flags_send_uid:1;
 
47
        struct client_command_context cmd;
 
48
 
 
49
        unsigned int command_pending:1;
 
50
        unsigned int input_pending:1;
 
51
        unsigned int output_pending:1;
43
52
        unsigned int rawlog:1;
44
53
        unsigned int input_skip_line:1; /* skip all the data until we've
45
54
                                           found a new line */
47
56
 
48
57
/* Create new client with specified input/output handles. socket specifies
49
58
   if the handle is a socket. */
50
 
struct client *client_create(int hin, int hout, struct mail_storage *storage);
 
59
struct client *client_create(int hin, int hout, struct namespace *namespaces);
51
60
void client_destroy(struct client *client);
52
61
 
53
62
/* Disconnect client connection */
54
63
void client_disconnect(struct client *client);
55
64
void client_disconnect_with_error(struct client *client, const char *msg);
56
65
 
57
 
/* Send a line of data to client */
58
 
void client_send_line(struct client *client, const char *data);
 
66
/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
 
67
   -1 if error */
 
68
int client_send_line(struct client *client, const char *data);
59
69
/* Send line of data to client, prefixed with client->tag */
60
 
void client_send_tagline(struct client *client, const char *data);
 
70
void client_send_tagline(struct client_command_context *cmd, const char *data);
61
71
 
62
72
/* Send BAD command error to client. msg can be NULL. */
63
 
void client_send_command_error(struct client *client, const char *msg);
 
73
void client_send_command_error(struct client_command_context *cmd,
 
74
                               const char *msg);
64
75
 
65
76
/* Read a number of arguments. Returns TRUE if everything was read or
66
 
   FALSE if either needs more data or error occured. */
67
 
int client_read_args(struct client *client, unsigned int count,
 
77
   FALSE if either needs more data or error occurred. */
 
78
int client_read_args(struct client_command_context *cmd, unsigned int count,
68
79
                     unsigned int flags, struct imap_arg **args);
69
80
/* Reads a number of string arguments. ... is a list of pointers where to
70
81
   store the arguments. */
71
 
int client_read_string_args(struct client *client, unsigned int count, ...);
 
82
int client_read_string_args(struct client_command_context *cmd,
 
83
                            unsigned int count, ...);
72
84
 
73
85
void clients_init(void);
74
86
void clients_deinit(void);
75
87
 
 
88
void _client_reset_command(struct client *client);
76
89
void _client_input(void *context);
77
 
void _client_reset_command(struct client *client);
 
90
int _client_output(void *context);
78
91
 
79
92
#endif