Statistics
| Revision:

root / src / pop.h @ 1

History | View | Annotate | Download (3.4 kB)

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