Rocco Rutte:
[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 "mx.h"
14 #include "mutt_socket.h"
15 #include "mutt_curses.h"
16
17 #define POP_PORT 110
18 #define POP_SSL_PORT 995
19
20 /* number of entries in the hash table */
21 #define POP_CACHE_LEN 10
22
23 /* maximal length of the server response (RFC1939) */
24 #define POP_CMD_RESPONSE 512
25
26 enum {
27   /* Status */
28   POP_NONE = 0,
29   POP_CONNECTED,
30   POP_DISCONNECTED,
31   POP_BYE
32 };
33
34 typedef enum {
35   POP_A_SUCCESS = 0,
36   POP_A_SOCKET,
37   POP_A_FAILURE,
38   POP_A_UNAVAIL
39 } pop_auth_res_t;
40
41 typedef struct {
42   unsigned int index;
43   char *path;
44 } POP_CACHE;
45
46 typedef enum pop_query_status_e {
47   PFD_FUNCT_ERROR = -3, /* pop_fetch_data uses pop_query_status and this return value */
48   PQ_ERR = -2,
49   PQ_NOT_CONNECTED = -1,
50   PQ_OK = 0
51 } pop_query_status;
52
53 typedef enum cmd_status_e {
54   CMD_NOT_AVAILABLE = 0,
55   CMD_AVAILABLE,
56   CMD_UNKNOWN /* unknown whether it is available or not */
57 } cmd_status;
58
59 typedef struct {
60   CONNECTION *conn;
61   unsigned int status:2;
62   unsigned int capabilities:1;
63   unsigned int use_stls:2;
64   cmd_status cmd_capa;      /* optional command CAPA */
65   cmd_status cmd_stls;      /* optional command STLS */
66   cmd_status cmd_user;      /* optional command USER */
67   cmd_status cmd_uidl;      /* optional command UIDL */
68   cmd_status cmd_top;       /* optional command TOP */
69   unsigned int resp_codes:1;    /* server supports extended response codes */
70   unsigned int expire:1;        /* expire is greater than 0 */
71   unsigned int clear_cache:1;
72   size_t size;
73   time_t check_time;
74   time_t login_delay;           /* minimal login delay  capability */
75   char *auth_list;              /* list of auth mechanisms */
76   char *timestamp;
77   char err_msg[POP_CMD_RESPONSE];
78   POP_CACHE cache[POP_CACHE_LEN];
79 } POP_DATA;
80
81 typedef struct {
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 pop_query_status pop_open_connection (POP_DATA *);
98 pop_query_status pop_query_d (POP_DATA *, char *, size_t, char *);
99 pop_query_status pop_fetch_data (POP_DATA *, char *, progress_t*, int (*funct) (char *, void *),
100                     void *);
101 pop_query_status pop_reconnect (CONTEXT *);
102 void pop_logout (CONTEXT *);
103 void pop_error (POP_DATA *, char *);
104
105 /* pop.c */
106 int pop_check_mailbox (CONTEXT *, int *, int);
107 int pop_open_mailbox (CONTEXT *);
108 pop_query_status pop_sync_mailbox (CONTEXT *, int, int *);
109 int pop_fetch_message (MESSAGE *, CONTEXT *, int);
110 void pop_close_mailbox (CONTEXT *);
111 void pop_fetch_mail (void);
112
113 #endif