talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

pop.h (3532B)


      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
      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 3 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, see <http://www.gnu.org/licenses/>.
     17  */
     18 
     19 #ifndef _POP_H_
     20 #define _POP_H_
     21 
     22 #include <glib.h>
     23 #include <time.h>
     24 
     25 #include "session.h"
     26 #include "prefs_account.h"
     27 
     28 typedef struct _Pop3MsgInfo	Pop3MsgInfo;
     29 typedef struct _Pop3Session	Pop3Session;
     30 
     31 #define POP3_SESSION(obj)	((Pop3Session *)obj)
     32 
     33 #define MAIL_RECEIVE_HOOKLIST	"mail_receive_hooklist"
     34 struct _MailReceiveData
     35 {
     36 	Pop3Session *session;
     37 	char *data;
     38 	guint data_len;
     39 };
     40 typedef struct _MailReceiveData	MailReceiveData;
     41 
     42 typedef enum {
     43 	POP3_READY,
     44 	POP3_GREETING,
     45 	POP3_STLS,
     46 	POP3_GETAUTH_USER,
     47 	POP3_GETAUTH_USER_PHASE2,
     48 	POP3_GETAUTH_PASS,
     49 	POP3_GETAUTH_OAUTH2,
     50 	POP3_GETRANGE_STAT,
     51 	POP3_GETRANGE_LAST,
     52 	POP3_GETRANGE_UIDL,
     53 	POP3_GETRANGE_UIDL_RECV,
     54 	POP3_GETSIZE_LIST,
     55 	POP3_GETSIZE_LIST_RECV,
     56 	POP3_RETR,
     57 	POP3_RETR_RECV,
     58 	POP3_TOP,
     59 	POP3_TOP_RECV,
     60 	POP3_DELETE,
     61 	POP3_LOGOUT,
     62 	POP3_DONE,
     63 	POP3_ERROR,
     64 
     65 	N_POP3_STATE
     66 } Pop3State;
     67 
     68 typedef enum {
     69 	PS_SUCCESS	= 0,	/* command successful */
     70 	PS_NOMAIL	= 1,	/* no mail available */
     71 	PS_SOCKET	= 2,	/* socket I/O woes */
     72 	PS_AUTHFAIL	= 3,	/* user authorization failed */
     73 	PS_PROTOCOL	= 4,	/* protocol violation */
     74 	PS_SYNTAX	= 5,	/* command-line syntax error */
     75 	PS_IOERR	= 6,	/* file I/O error */
     76 	PS_ERROR	= 7,	/* protocol error */
     77 	PS_EXCLUDE	= 8,	/* client-side exclusion error */
     78 	PS_LOCKBUSY	= 9,	/* server responded lock busy */
     79 	PS_SMTP		= 10,	/* SMTP error */
     80 	PS_DNS		= 11,	/* fatal DNS error */
     81 	PS_BSMTP	= 12,	/* output batch could not be opened */
     82 	PS_MAXFETCH	= 13,	/* poll ended by fetch limit */
     83 
     84 	PS_NOTSUPPORTED	= 14,	/* command not supported */
     85 
     86 	/* leave space for more codes */
     87 
     88 	PS_CONTINUE	= 128	/* more responses may follow */
     89 } Pop3ErrorValue;
     90 
     91 typedef enum {
     92 	RECV_TIME_NONE     = 0,
     93 	RECV_TIME_RECEIVED = 1,
     94 	RECV_TIME_KEEP     = 2
     95 } RecvTime;
     96 
     97 struct _Pop3MsgInfo
     98 {
     99 	gint size;
    100 	gchar *uidl;
    101 	time_t recv_time;
    102 	guint received     : 1;
    103 	guint deleted      : 1;
    104 	guint partial_recv : 2;
    105 };
    106 
    107 struct _Pop3Session
    108 {
    109 	Session session;
    110 
    111 	Pop3State state;
    112 	gchar *prev_folder;
    113 
    114 	PrefsAccount *ac_prefs;
    115 	gboolean pop_before_smtp;
    116 
    117 	gchar *greeting;
    118 	gchar *user;
    119 	gchar *pass;
    120 	gint count;
    121 	gint total_bytes;
    122 	gint cur_msg;
    123 	gint cur_total_num;
    124 	gint cur_total_bytes;
    125 	gint cur_total_recv_bytes;
    126 
    127         gint two_stage_pop;
    128 
    129 	Pop3MsgInfo *msg;
    130 
    131 	GHashTable *uidl_table;
    132 	GHashTable *partial_recv_table;
    133 
    134 	gboolean new_msg_exist;
    135 	gboolean uidl_is_valid;
    136 
    137 	time_t current_time;
    138 
    139 	Pop3ErrorValue error_val;
    140 	gchar *error_msg;
    141 
    142 	gpointer data;
    143 
    144 	/* virtual method to drop message */
    145 	gint (*drop_message)	(Pop3Session	*session,
    146 				 const gchar	*file);
    147 };
    148 
    149 #define POPBUFSIZE	8192
    150 /* #define IDLEN	128 */
    151 #define IDLEN		POPBUFSIZE
    152 
    153 Session *pop3_session_new	(PrefsAccount	*account);
    154 gint pop3_write_uidl_list	(Pop3Session	*session);
    155 
    156 #endif /* _POP_H_ */