mutt stable branch with some hacks
1/*
2 * Copyright (C) 2000-2003 Vsevolod Volkov <vvv@mutt.org.ua>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef _POP_H
20#define _POP_H 1
21
22#include "mailbox.h"
23#include "mutt_socket.h"
24#include "mutt_curses.h"
25#include "bcache.h"
26
27#define POP_PORT 110
28#define POP_SSL_PORT 995
29
30/* number of entries in the hash table */
31#define POP_CACHE_LEN 10
32
33/* maximal length of the server response (RFC1939) */
34#define POP_CMD_RESPONSE 512
35
36enum
37{
38 /* Status */
39 POP_NONE = 0,
40 POP_CONNECTED,
41 POP_DISCONNECTED,
42 POP_BYE
43};
44
45typedef enum
46{
47 POP_A_SUCCESS = 0,
48 POP_A_SOCKET,
49 POP_A_FAILURE,
50 POP_A_UNAVAIL
51} pop_auth_res_t;
52
53typedef struct
54{
55 unsigned int index;
56 char *path;
57} POP_CACHE;
58
59typedef struct
60{
61 CONNECTION *conn;
62 unsigned int status : 2;
63 unsigned int capabilities : 1;
64 unsigned int use_stls : 2;
65 unsigned int cmd_capa : 1; /* optional command CAPA */
66 unsigned int cmd_stls : 1; /* optional command STLS */
67 unsigned int cmd_user : 2; /* optional command USER */
68 unsigned int cmd_uidl : 2; /* optional command UIDL */
69 unsigned int cmd_top : 2; /* optional command TOP */
70 unsigned int resp_codes : 1; /* server supports extended response codes */
71 unsigned int expire : 1; /* expire is greater than 0 */
72 unsigned int clear_cache : 1;
73 size_t size;
74 time_t check_time;
75 time_t login_delay; /* minimal login delay capability */
76 char *auth_list; /* list of auth mechanisms */
77 char *timestamp;
78 body_cache_t *bcache; /* body cache */
79 char err_msg[POP_CMD_RESPONSE];
80 POP_CACHE cache[POP_CACHE_LEN];
81} POP_DATA;
82
83typedef struct
84{
85 /* do authentication, using named method or any available if method is NULL */
86 pop_auth_res_t (*authenticate) (POP_DATA *, const char *);
87 /* name of authentication method supported, NULL means variable. If this
88 * is not null, authenticate may ignore the second parameter. */
89 const char* method;
90} pop_auth_t;
91
92/* pop_auth.c */
93int pop_authenticate (POP_DATA *);
94void pop_apop_timestamp (POP_DATA *, char *);
95
96/* pop_lib.c */
97#define pop_query(A,B,C) pop_query_d(A,B,C,NULL)
98int pop_parse_path (const char *, ACCOUNT *);
99int pop_connect (POP_DATA *);
100int pop_open_connection (POP_DATA *);
101int pop_query_d (POP_DATA *, char *, size_t, char *);
102int pop_fetch_data (POP_DATA *, char *, progress_t *, int (*funct) (char *, void *), void *);
103int pop_reconnect (CONTEXT *);
104void pop_logout (CONTEXT *);
105void pop_error (POP_DATA *, char *);
106
107/* pop.c */
108int pop_close_mailbox (CONTEXT *);
109void pop_fetch_mail (void);
110
111extern struct mx_ops mx_pop_ops;
112
113#endif