Andreas Krennmair:
[apps/madmutt.git] / pop / pop.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 2000-2003 Vsevolod Volkov <vvv@mutt.org.ua>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifndef _POP_H
11 #define _POP_H 1
12
13 #include "mailbox.h"
14 #include "mutt_socket.h"
15
16 #define POP_PORT 110
17 #define POP_SSL_PORT 995
18
19 /* number of entries in the hash table */
20 #define POP_CACHE_LEN 10
21
22 /* maximal length of the server response (RFC1939) */
23 #define POP_CMD_RESPONSE 512
24
25 enum {
26   /* Status */
27   POP_NONE = 0,
28   POP_CONNECTED,
29   POP_DISCONNECTED,
30   POP_BYE
31 };
32
33 typedef enum {
34   POP_A_SUCCESS = 0,
35   POP_A_SOCKET,
36   POP_A_FAILURE,
37   POP_A_UNAVAIL
38 } pop_auth_res_t;
39
40 typedef struct {
41   unsigned int index;
42   char *path;
43 } POP_CACHE;
44
45 typedef struct {
46   CONNECTION *conn;
47   unsigned int status:2;
48   unsigned int capabilities:1;
49   unsigned int use_stls:2;
50   unsigned int cmd_capa:1;      /* optional command CAPA */
51   unsigned int cmd_stls:1;      /* optional command STLS */
52   unsigned int cmd_user:2;      /* optional command USER */
53   unsigned int cmd_uidl:2;      /* optional command UIDL */
54   unsigned int cmd_top:2;       /* optional command TOP */
55   unsigned int resp_codes:1;    /* server supports extended response codes */
56   unsigned int expire:1;        /* expire is greater than 0 */
57   unsigned int clear_cache:1;
58   size_t size;
59   time_t check_time;
60   time_t login_delay;           /* minimal login delay  capability */
61   char *auth_list;              /* list of auth mechanisms */
62   char *timestamp;
63   char err_msg[POP_CMD_RESPONSE];
64   POP_CACHE cache[POP_CACHE_LEN];
65 } POP_DATA;
66
67 typedef struct {
68   /* do authentication, using named method or any available if method is NULL */
69   pop_auth_res_t (*authenticate) (POP_DATA *, const char *);
70   /* name of authentication method supported, NULL means variable. If this
71    * is not null, authenticate may ignore the second parameter. */
72   const char *method;
73 } pop_auth_t;
74
75 /* pop_auth.c */
76 int pop_authenticate (POP_DATA *);
77 void pop_apop_timestamp (POP_DATA *, char *);
78
79 /* pop_lib.c */
80 #define pop_query(A,B,C) pop_query_d(A,B,C,NULL)
81 int pop_parse_path (const char *, ACCOUNT *);
82 int pop_connect (POP_DATA *);
83 int pop_open_connection (POP_DATA *);
84 int pop_query_d (POP_DATA *, char *, size_t, char *);
85 int pop_fetch_data (POP_DATA *, char *, char *, int (*funct) (char *, void *),
86                     void *);
87 int pop_reconnect (CONTEXT *);
88 void pop_logout (CONTEXT *);
89 void pop_error (POP_DATA *, char *);
90
91 /* pop.c */
92 int pop_check_mailbox (CONTEXT *, int *);
93 int pop_open_mailbox (CONTEXT *);
94 int pop_sync_mailbox (CONTEXT *, int *);
95 int pop_fetch_message (MESSAGE *, CONTEXT *, int);
96 void pop_close_mailbox (CONTEXT *);
97 void pop_fetch_mail (void);
98
99 #endif