remove mx_{pop,nntp,imap}.[hc]
[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 <lib-ui/curses.h>
14 #include <lib-sys/mutt_socket.h>
15
16 #include "mx.h"
17
18 extern mx_t const pop_mx;
19
20
21 #define POP_PORT 110
22 #define POP_SSL_PORT 995
23
24 /* number of entries in the hash table */
25 #define POP_CACHE_LEN 10
26
27 /* maximal length of the server response (RFC1939) */
28 #define POP_CMD_RESPONSE 512
29
30 enum {
31   /* Status */
32   POP_NONE = 0,
33   POP_CONNECTED,
34   POP_DISCONNECTED,
35   POP_BYE
36 };
37
38 typedef enum {
39   POP_A_SUCCESS = 0,
40   POP_A_SOCKET,
41   POP_A_FAILURE,
42   POP_A_UNAVAIL
43 } pop_auth_res_t;
44
45 typedef struct {
46   int index;
47   char *path;
48 } POP_CACHE;
49
50 typedef enum pop_query_status_e {
51   PFD_FUNCT_ERROR = -3, /* pop_fetch_data uses pop_query_status and this return value */
52   PQ_ERR = -2,
53   PQ_NOT_CONNECTED = -1,
54   PQ_OK = 0
55 } pop_query_status;
56
57 typedef enum cmd_status_e {
58   CMD_NOT_AVAILABLE = 0,
59   CMD_AVAILABLE,
60   CMD_UNKNOWN /* unknown whether it is available or not */
61 } cmd_status;
62
63 typedef struct {
64   CONNECTION *conn;
65   unsigned int status:2;
66   unsigned int capabilities:1;
67   unsigned int use_stls:2;
68   cmd_status cmd_capa;      /* optional command CAPA */
69   cmd_status cmd_stls;      /* optional command STLS */
70   cmd_status cmd_user;      /* optional command USER */
71   cmd_status cmd_uidl;      /* optional command UIDL */
72   cmd_status cmd_top;       /* optional command TOP */
73   unsigned int resp_codes:1;    /* server supports extended response codes */
74   unsigned int expire:1;        /* expire is greater than 0 */
75   unsigned int clear_cache:1;
76   size_t size;
77   time_t check_time;
78   time_t login_delay;           /* minimal login delay  capability */
79   char *auth_list;              /* list of auth mechanisms */
80   char *timestamp;
81   char err_msg[POP_CMD_RESPONSE];
82   POP_CACHE cache[POP_CACHE_LEN];
83 } POP_DATA;
84
85 typedef struct {
86   /* do authentication, using named method or any available if method is NULL */
87   pop_auth_res_t (*authenticate) (POP_DATA *, const char *);
88   /* name of authentication method supported, NULL means variable. If this
89    * is not null, authenticate may ignore the second parameter. */
90   const char *method;
91 } pop_auth_t;
92
93 /* pop_auth.c */
94 int pop_authenticate (POP_DATA *);
95 void pop_apop_timestamp (POP_DATA *, char *);
96
97 /* pop_lib.c */
98 int pop_parse_path (const char *, ACCOUNT *);
99 int pop_connect (POP_DATA *);
100 pop_query_status pop_open_connection (POP_DATA *);
101 pop_query_status pop_query (POP_DATA *, char *, size_t);
102 pop_query_status pop_fetch_data (POP_DATA *, const char *, progress_t*,
103                                  int (*funct) (char *, void *), void *);
104 pop_query_status pop_reconnect (CONTEXT *);
105 void pop_logout (CONTEXT *);
106 void pop_error (POP_DATA *, char *);
107
108 /* pop.c */
109 int pop_fetch_message (MESSAGE *, CONTEXT *, int);
110 void pop_fetch_mail (void);
111
112 #endif