Statistics
| Revision:

root / libsylph / pop.h @ 1916

History | View | Annotate | Download (3.4 kB)

1
/*
2
 * LibSylph -- E-Mail client library
3
 * Copyright (C) 1999-2006 Hiroyuki Yamamoto
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library 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 GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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
        POP3_STLS,
42
        POP3_GETAUTH_USER,
43
        POP3_GETAUTH_PASS,
44
        POP3_GETAUTH_APOP,
45
        POP3_GETRANGE_STAT,
46
        POP3_GETRANGE_LAST,
47
        POP3_GETRANGE_UIDL,
48
        POP3_GETRANGE_UIDL_RECV,
49
        POP3_GETSIZE_LIST,
50
        POP3_GETSIZE_LIST_RECV,
51
        POP3_RETR,
52
        POP3_RETR_RECV,
53
        POP3_DELETE,
54
        POP3_LOGOUT,
55
        POP3_DONE,
56
        POP3_ERROR,
57
58
        N_POP3_STATE
59
} Pop3State;
60
61
typedef enum {
62
        PS_SUCCESS        = 0,        /* command successful */
63
        PS_NOMAIL        = 1,        /* no mail available */
64
        PS_SOCKET        = 2,        /* socket I/O woes */
65
        PS_AUTHFAIL        = 3,        /* user authorization failed */
66
        PS_PROTOCOL        = 4,        /* protocol violation */
67
        PS_SYNTAX        = 5,        /* command-line syntax error */
68
        PS_IOERR        = 6,        /* file I/O error */
69
        PS_ERROR        = 7,        /* protocol error */
70
        PS_EXCLUDE        = 8,        /* client-side exclusion error */
71
        PS_LOCKBUSY        = 9,        /* server responded lock busy */
72
        PS_SMTP                = 10,        /* SMTP error */
73
        PS_DNS                = 11,        /* fatal DNS error */
74
        PS_BSMTP        = 12,        /* output batch could not be opened */
75
        PS_MAXFETCH        = 13,        /* poll ended by fetch limit */
76
77
        PS_NOTSUPPORTED        = 14,        /* command not supported */
78
79
        /* leave space for more codes */
80
81
        PS_CONTINUE        = 128        /* more responses may follow */
82
} Pop3ErrorValue;
83
84
typedef enum {
85
        RECV_TIME_NONE     = 0,
86
        RECV_TIME_RECEIVED = 1,
87
        RECV_TIME_KEEP     = 2,
88
        RECV_TIME_DELETE   = 3
89
} RecvTime;
90
91
typedef enum {
92
        DROP_OK = 0,
93
        DROP_DONT_RECEIVE = 1,
94
        DROP_DELETE = 2,
95
        DROP_ERROR = -1
96
} Pop3DropValue;
97
98
struct _Pop3MsgInfo
99
{
100
        gint size;
101
        gchar *uidl;
102
        time_t recv_time;
103
        guint received : 1;
104
        guint deleted  : 1;
105
};
106
107
struct _Pop3Session
108
{
109
        Session session;
110
111
        Pop3State state;
112
113
        PrefsAccount *ac_prefs;
114
115
        gchar *greeting;
116
        gchar *user;
117
        gchar *pass;
118
        gint count;
119
        gint64 total_bytes;
120
        gint cur_msg;
121
        gint cur_total_num;
122
        gint64 cur_total_bytes;
123
        gint64 cur_total_recv_bytes;
124
        gint skipped_num;
125
126
        Pop3MsgInfo *msg;
127
128
        GHashTable *uidl_table;
129
130
        gboolean auth_only;
131
132
        gboolean new_msg_exist;
133
        gboolean uidl_is_valid;
134
135
        time_t current_time;
136
137
        Pop3ErrorValue error_val;
138
        gchar *error_msg;
139
140
        gpointer data;
141
142
        /* virtual method to drop message */
143
        gint (*drop_message)        (Pop3Session        *session,
144
                                 const gchar        *file);
145
};
146
147
#define POPBUFSIZE        512
148
/* #define IDLEN        128 */
149
#define IDLEN                POPBUFSIZE
150
151
Session *pop3_session_new        (PrefsAccount        *account);
152
GHashTable *pop3_get_uidl_table        (PrefsAccount        *account);
153
gint pop3_write_uidl_list        (Pop3Session        *session);
154
155
#endif /* __POP_H__ */