recognise font/* and chemical/* mime types
[claws.git] / src / pop.h
blob07208646002eac22c523d4cf843c286f1000672c
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
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 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef __POP_H__
20 #define __POP_H__
22 #ifdef HAVE_CONFIG_H
23 #include "claws-features.h"
24 #endif
26 #include <glib.h>
27 #include <time.h>
29 #include "session.h"
30 #include "prefs_account.h"
32 typedef struct _Pop3MsgInfo Pop3MsgInfo;
33 typedef struct _Pop3Session Pop3Session;
35 #define POP3_SESSION(obj) ((Pop3Session *)obj)
37 #define MAIL_RECEIVE_HOOKLIST "mail_receive_hooklist"
38 struct _MailReceiveData
40 Pop3Session *session;
41 char *data;
42 guint data_len;
44 typedef struct _MailReceiveData MailReceiveData;
46 typedef enum {
47 POP3_READY,
48 POP3_GREETING,
49 #ifdef USE_GNUTLS
50 POP3_STLS,
51 #endif
52 POP3_GETAUTH_USER,
53 POP3_GETAUTH_USER_PHASE2,
54 POP3_GETAUTH_PASS,
55 POP3_GETAUTH_APOP,
56 POP3_GETAUTH_OAUTH2,
57 POP3_GETRANGE_STAT,
58 POP3_GETRANGE_LAST,
59 POP3_GETRANGE_UIDL,
60 POP3_GETRANGE_UIDL_RECV,
61 POP3_GETSIZE_LIST,
62 POP3_GETSIZE_LIST_RECV,
63 POP3_RETR,
64 POP3_RETR_RECV,
65 POP3_TOP,
66 POP3_TOP_RECV,
67 POP3_DELETE,
68 POP3_LOGOUT,
69 POP3_DONE,
70 POP3_ERROR,
72 N_POP3_STATE
73 } Pop3State;
75 typedef enum {
76 PS_SUCCESS = 0, /* command successful */
77 PS_NOMAIL = 1, /* no mail available */
78 PS_SOCKET = 2, /* socket I/O woes */
79 PS_AUTHFAIL = 3, /* user authorization failed */
80 PS_PROTOCOL = 4, /* protocol violation */
81 PS_SYNTAX = 5, /* command-line syntax error */
82 PS_IOERR = 6, /* file I/O error */
83 PS_ERROR = 7, /* protocol error */
84 PS_EXCLUDE = 8, /* client-side exclusion error */
85 PS_LOCKBUSY = 9, /* server responded lock busy */
86 PS_SMTP = 10, /* SMTP error */
87 PS_DNS = 11, /* fatal DNS error */
88 PS_BSMTP = 12, /* output batch could not be opened */
89 PS_MAXFETCH = 13, /* poll ended by fetch limit */
91 PS_NOTSUPPORTED = 14, /* command not supported */
93 /* leave space for more codes */
95 PS_CONTINUE = 128 /* more responses may follow */
96 } Pop3ErrorValue;
98 typedef enum {
99 RECV_TIME_NONE = 0,
100 RECV_TIME_RECEIVED = 1,
101 RECV_TIME_KEEP = 2
102 } RecvTime;
104 struct _Pop3MsgInfo
106 gint size;
107 gchar *uidl;
108 time_t recv_time;
109 guint received : 1;
110 guint deleted : 1;
111 guint partial_recv : 2;
114 struct _Pop3Session
116 Session session;
118 Pop3State state;
119 gchar *prev_folder;
121 PrefsAccount *ac_prefs;
122 gboolean pop_before_smtp;
124 gchar *greeting;
125 gchar *user;
126 gchar *pass;
127 gint count;
128 gint total_bytes;
129 gint cur_msg;
130 gint cur_total_num;
131 gint cur_total_bytes;
132 gint cur_total_recv_bytes;
134 Pop3MsgInfo *msg;
136 GHashTable *uidl_table;
137 GHashTable *partial_recv_table;
139 gboolean new_msg_exist;
140 gboolean uidl_is_valid;
142 time_t current_time;
144 Pop3ErrorValue error_val;
145 gchar *error_msg;
147 gpointer data;
149 /* virtual method to drop message */
150 gint (*drop_message) (Pop3Session *session,
151 const gchar *file);
154 #define POPBUFSIZE 8192
155 /* #define IDLEN 128 */
156 #define IDLEN POPBUFSIZE
158 Session *pop3_session_new (PrefsAccount *account);
159 gint pop3_write_uidl_list (Pop3Session *session);
161 #endif /* __POP_H__ */