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