Andreas Krennmair:
[apps/madmutt.git] / pop.h
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 #ifndef _POP_H
20 #define _POP_H 1
21
22 #include "mailbox.h"
23 #include "mutt_socket.h"
24
25 #define POP_PORT 110
26 #define POP_SSL_PORT 995
27
28 /* number of entries in the hash table */
29 #define POP_CACHE_LEN 10
30
31 /* maximal length of the server response (RFC1939) */
32 #define POP_CMD_RESPONSE 512
33
34 enum {
35   /* Status */
36   POP_NONE = 0,
37   POP_CONNECTED,
38   POP_DISCONNECTED,
39   POP_BYE
40 };
41
42 typedef enum {
43   POP_A_SUCCESS = 0,
44   POP_A_SOCKET,
45   POP_A_FAILURE,
46   POP_A_UNAVAIL
47 } pop_auth_res_t;
48
49 typedef struct {
50   unsigned int index;
51   char *path;
52 } POP_CACHE;
53
54 typedef struct {
55   CONNECTION *conn;
56   unsigned int status:2;
57   unsigned int capabilities:1;
58   unsigned int use_stls:2;
59   unsigned int cmd_capa:1;      /* optional command CAPA */
60   unsigned int cmd_stls:1;      /* optional command STLS */
61   unsigned int cmd_user:2;      /* optional command USER */
62   unsigned int cmd_uidl:2;      /* optional command UIDL */
63   unsigned int cmd_top:2;       /* optional command TOP */
64   unsigned int resp_codes:1;    /* server supports extended response codes */
65   unsigned int expire:1;        /* expire is greater than 0 */
66   unsigned int clear_cache:1;
67   size_t size;
68   time_t check_time;
69   time_t login_delay;           /* minimal login delay  capability */
70   char *auth_list;              /* list of auth mechanisms */
71   char *timestamp;
72   char err_msg[POP_CMD_RESPONSE];
73   POP_CACHE cache[POP_CACHE_LEN];
74 } POP_DATA;
75
76 typedef struct {
77   /* do authentication, using named method or any available if method is NULL */
78   pop_auth_res_t (*authenticate) (POP_DATA *, const char *);
79   /* name of authentication method supported, NULL means variable. If this
80    * is not null, authenticate may ignore the second parameter. */
81   const char *method;
82 } pop_auth_t;
83
84 /* pop_auth.c */
85 int pop_authenticate (POP_DATA *);
86 void pop_apop_timestamp (POP_DATA *, char *);
87
88 /* pop_lib.c */
89 #define pop_query(A,B,C) pop_query_d(A,B,C,NULL)
90 int pop_parse_path (const char *, ACCOUNT *);
91 int pop_connect (POP_DATA *);
92 int pop_open_connection (POP_DATA *);
93 int pop_query_d (POP_DATA *, char *, size_t, char *);
94 int pop_fetch_data (POP_DATA *, char *, char *, int (*funct) (char *, void *),
95                     void *);
96 int pop_reconnect (CONTEXT *);
97 void pop_logout (CONTEXT *);
98 void pop_error (POP_DATA *, char *);
99
100 /* pop.c */
101 int pop_check_mailbox (CONTEXT *, int *);
102 int pop_open_mailbox (CONTEXT *);
103 int pop_sync_mailbox (CONTEXT *, int *);
104 int pop_fetch_message (MESSAGE *, CONTEXT *, int);
105 void pop_close_mailbox (CONTEXT *);
106 void pop_fetch_mail (void);
107
108 #endif