German translation
[claws.git] / src / pop.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 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 "socket.h"
31 #include "prefs_account.h"
32
33 typedef struct _Pop3MsgInfo     Pop3MsgInfo;
34 typedef struct _Pop3State       Pop3State;
35
36 typedef enum {
37         POP3_GREETING_RECV,
38 #if USE_OPENSSL
39         POP3_STLS_SEND,
40         POP3_STLS_RECV,
41 #endif
42         POP3_GETAUTH_USER_SEND,
43         POP3_GETAUTH_USER_RECV,
44         POP3_GETAUTH_PASS_SEND,
45         POP3_GETAUTH_PASS_RECV,
46         POP3_GETAUTH_APOP_SEND,
47         POP3_GETAUTH_APOP_RECV,
48         POP3_GETRANGE_STAT_SEND,
49         POP3_GETRANGE_STAT_RECV,
50         POP3_GETRANGE_LAST_SEND,
51         POP3_GETRANGE_LAST_RECV,
52         POP3_GETRANGE_UIDL_SEND,
53         POP3_GETRANGE_UIDL_RECV,
54         POP3_GETSIZE_LIST_SEND,
55         POP3_GETSIZE_LIST_RECV,
56         POP3_TOP_SEND,                   
57         POP3_TOP_RECV,                    
58         POP3_RETR_SEND,
59         POP3_RETR_RECV,
60         POP3_DELETE_SEND,
61         POP3_DELETE_RECV,
62         POP3_LOGOUT_SEND,
63         POP3_LOGOUT_RECV,
64
65         N_POP3_PHASE
66 } Pop3Phase;
67
68 typedef enum {
69         RECV_TIME_NONE     = 0,
70         RECV_TIME_RECEIVED = 1,
71         RECV_TIME_KEEP     = 2
72 } RecvTime;
73
74 struct _Pop3MsgInfo
75 {
76         gint size;
77         gchar *uidl;
78         time_t recv_time;
79         guint received : 1;
80         guint deleted  : 1;
81 };
82
83 struct _Pop3State
84 {
85         PrefsAccount *ac_prefs;
86
87         gchar *prev_folder;
88
89         SockInfo *sockinfo;
90
91         gchar *greeting;
92         gchar *user;
93         gchar *pass;
94         gint count;
95         gint new;
96         gint total_bytes;
97         gint cur_msg;
98         gint cur_total_num;
99         gint cur_total_bytes;
100         gint cur_total_recv_bytes;
101
102         Pop3MsgInfo *msg;
103
104         GHashTable *uidl_table;
105
106         gboolean uidl_is_valid;
107         gboolean cancelled;
108
109         time_t current_time;
110
111         gint error_val;
112
113         gpointer data;
114 };
115
116 #define POPBUFSIZE      512
117 #define IDLEN           128
118
119 /* exit code values */
120 #define         PS_SUCCESS      0       /* successful receipt of messages */
121 #define         PS_NOMAIL       1       /* no mail available */
122 #define         PS_SOCKET       2       /* socket I/O woes */
123 #define         PS_AUTHFAIL     3       /* user authorization failed */
124 #define         PS_PROTOCOL     4       /* protocol violation */
125 #define         PS_SYNTAX       5       /* command-line syntax error */
126 #define         PS_IOERR        6       /* bad permissions on rc file */
127 #define         PS_ERROR        7       /* protocol error */
128 #define         PS_EXCLUDE      8       /* client-side exclusion error */
129 #define         PS_LOCKBUSY     9       /* server responded lock busy */
130 #define         PS_SMTP         10      /* SMTP error */
131 #define         PS_DNS          11      /* fatal DNS error */
132 #define         PS_BSMTP        12      /* output batch could not be opened */
133 #define         PS_MAXFETCH     13      /* poll ended by fetch limit */
134 /* leave space for more codes */
135 #define         PS_UNDEFINED    23      /* something I hadn't thought of */
136 #define         PS_TRANSIENT    24      /* transient failure (internal use) */
137 #define         PS_REFUSED      25      /* mail refused (internal use) */
138 #define         PS_RETAINED     26      /* message retained (internal use) */
139 #define         PS_TRUNCATED    27      /* headers incomplete (internal use) */
140
141 gint pop3_greeting_recv         (SockInfo *sock, gpointer data);
142 gint pop3_getauth_user_send     (SockInfo *sock, gpointer data);
143 gint pop3_getauth_user_recv     (SockInfo *sock, gpointer data);
144 gint pop3_getauth_pass_send     (SockInfo *sock, gpointer data);
145 gint pop3_getauth_pass_recv     (SockInfo *sock, gpointer data);
146 gint pop3_getauth_apop_send     (SockInfo *sock, gpointer data);
147 gint pop3_getauth_apop_recv     (SockInfo *sock, gpointer data);
148 #if USE_OPENSSL
149 gint pop3_stls_send             (SockInfo *sock, gpointer data);
150 gint pop3_stls_recv             (SockInfo *sock, gpointer data);
151 #endif
152 gint pop3_getrange_stat_send    (SockInfo *sock, gpointer data);
153 gint pop3_getrange_stat_recv    (SockInfo *sock, gpointer data);
154 gint pop3_getrange_last_send    (SockInfo *sock, gpointer data);
155 gint pop3_getrange_last_recv    (SockInfo *sock, gpointer data);
156 gint pop3_getrange_uidl_send    (SockInfo *sock, gpointer data);
157 gint pop3_getrange_uidl_recv    (SockInfo *sock, gpointer data);
158 gint pop3_getsize_list_send     (SockInfo *sock, gpointer data);
159 gint pop3_getsize_list_recv     (SockInfo *sock, gpointer data);
160 gint pop3_top_send              (SockInfo *sock, gpointer data);
161 gint pop3_top_recv              (SockInfo *sock, gpointer data);
162 gint pop3_retr_send             (SockInfo *sock, gpointer data);
163 gint pop3_retr_recv             (SockInfo *sock, gpointer data);
164 gint pop3_delete_send           (SockInfo *sock, gpointer data);
165 gint pop3_delete_recv           (SockInfo *sock, gpointer data);
166 gint pop3_logout_send           (SockInfo *sock, gpointer data);
167 gint pop3_logout_recv           (SockInfo *sock, gpointer data);
168
169 Pop3State *pop3_state_new       (PrefsAccount   *account);
170 void pop3_state_destroy         (Pop3State      *state);
171 GHashTable *pop3_get_uidl_table (PrefsAccount   *account);
172 gint pop3_write_uidl_list       (Pop3State      *state);
173
174 #endif /* __POP_H__ */