sync with 0.8.11cvs11
[claws.git] / src / pop.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2003 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __POP_H__
21 #define __POP_H__
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <glib.h>
28 #include <time.h>
29
30 #include "session.h"
31 #include "prefs_account.h"
32
33 typedef struct _Pop3MsgInfo     Pop3MsgInfo;
34 typedef struct _Pop3Session     Pop3Session;
35
36 #define POP3_SESSION(obj)       ((Pop3Session *)obj)
37
38 typedef enum {
39         POP3_READY,
40         POP3_GREETING,
41 #if USE_OPENSSL
42         POP3_STLS,
43 #endif
44         POP3_GETAUTH_USER,
45         POP3_GETAUTH_PASS,
46         POP3_GETAUTH_APOP,
47         POP3_GETRANGE_STAT,
48         POP3_GETRANGE_LAST,
49         POP3_GETRANGE_UIDL,
50         POP3_GETRANGE_UIDL_RECV,
51         POP3_GETSIZE_LIST,
52         POP3_GETSIZE_LIST_RECV,
53         POP3_RETR,
54         POP3_TOP,                   
55         POP3_RETR_RECV,
56         POP3_RETR_EOM,
57         POP3_DELETE,
58         POP3_LOGOUT,
59         POP3_ERROR,
60
61         N_POP3_STATE
62 } Pop3State;
63
64 typedef enum {
65         RECV_TIME_NONE     = 0,
66         RECV_TIME_RECEIVED = 1,
67         RECV_TIME_KEEP     = 2
68 } RecvTime;
69
70 struct _Pop3MsgInfo
71 {
72         gint size;
73         gchar *uidl;
74         time_t recv_time;
75         guint received : 1;
76         guint deleted  : 1;
77 };
78
79 struct _Pop3Session
80 {
81         Session session;
82
83         Pop3State state;
84         gchar *prev_folder;
85
86         PrefsAccount *ac_prefs;
87
88         gchar *greeting;
89         gchar *user;
90         gchar *pass;
91         gint count;
92         gint total_bytes;
93         gint cur_msg;
94         gint cur_total_num;
95         gint cur_total_bytes;
96         gint cur_total_recv_bytes;
97
98         Pop3MsgInfo *msg;
99
100         GHashTable *uidl_table;
101
102         gboolean new_msg_exist;
103         gboolean uidl_is_valid;
104
105         time_t current_time;
106
107         gint error_val;
108
109         gpointer data;
110 };
111
112 #define POPBUFSIZE      512
113 #define IDLEN           128
114
115 /* exit code values */
116 #define         PS_SUCCESS      0       /* successful receipt of messages */
117 #define         PS_NOMAIL       1       /* no mail available */
118 #define         PS_SOCKET       2       /* socket I/O woes */
119 #define         PS_AUTHFAIL     3       /* user authorization failed */
120 #define         PS_PROTOCOL     4       /* protocol violation */
121 #define         PS_SYNTAX       5       /* command-line syntax error */
122 #define         PS_IOERR        6       /* bad permissions on rc file */
123 #define         PS_ERROR        7       /* protocol error */
124 #define         PS_EXCLUDE      8       /* client-side exclusion error */
125 #define         PS_LOCKBUSY     9       /* server responded lock busy */
126 #define         PS_SMTP         10      /* SMTP error */
127 #define         PS_DNS          11      /* fatal DNS error */
128 #define         PS_BSMTP        12      /* output batch could not be opened */
129 #define         PS_MAXFETCH     13      /* poll ended by fetch limit */
130 /* leave space for more codes */
131 #define         PS_UNDEFINED    23      /* something I hadn't thought of */
132 #define         PS_TRANSIENT    24      /* transient failure (internal use) */
133 #define         PS_REFUSED      25      /* mail refused (internal use) */
134 #define         PS_RETAINED     26      /* message retained (internal use) */
135 #define         PS_TRUNCATED    27      /* headers incomplete (internal use) */
136
137 #define         PS_CONTINUE     128
138
139 Session *pop3_session_new       (PrefsAccount   *account);
140 GHashTable *pop3_get_uidl_table (PrefsAccount   *account);
141 gint pop3_write_uidl_list       (Pop3Session    *session);
142
143 #endif /* __POP_H__ */