root / libsylph / pop.h @ 578
History | View | Annotate | Download (3.3 kB)
| 1 | /*
|
|---|---|
| 2 | * LibSylph -- E-Mail client library |
| 3 | * Copyright (C) 1999-2005 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_ERROR, |
| 56 | |
| 57 | N_POP3_STATE |
| 58 | } Pop3State; |
| 59 | |
| 60 | typedef enum { |
| 61 | PS_SUCCESS = 0, /* command successful */ |
| 62 | PS_NOMAIL = 1, /* no mail available */ |
| 63 | PS_SOCKET = 2, /* socket I/O woes */ |
| 64 | PS_AUTHFAIL = 3, /* user authorization failed */ |
| 65 | PS_PROTOCOL = 4, /* protocol violation */ |
| 66 | PS_SYNTAX = 5, /* command-line syntax error */ |
| 67 | PS_IOERR = 6, /* file I/O error */ |
| 68 | PS_ERROR = 7, /* protocol error */ |
| 69 | PS_EXCLUDE = 8, /* client-side exclusion error */ |
| 70 | PS_LOCKBUSY = 9, /* server responded lock busy */ |
| 71 | PS_SMTP = 10, /* SMTP error */ |
| 72 | PS_DNS = 11, /* fatal DNS error */ |
| 73 | PS_BSMTP = 12, /* output batch could not be opened */ |
| 74 | PS_MAXFETCH = 13, /* poll ended by fetch limit */ |
| 75 | |
| 76 | PS_NOTSUPPORTED = 14, /* command not supported */ |
| 77 | |
| 78 | /* leave space for more codes */
|
| 79 | |
| 80 | PS_CONTINUE = 128 /* more responses may follow */ |
| 81 | } Pop3ErrorValue; |
| 82 | |
| 83 | typedef enum { |
| 84 | RECV_TIME_NONE = 0,
|
| 85 | RECV_TIME_RECEIVED = 1,
|
| 86 | RECV_TIME_KEEP = 2,
|
| 87 | RECV_TIME_DELETE = 3
|
| 88 | } RecvTime; |
| 89 | |
| 90 | typedef enum { |
| 91 | DROP_OK = 0,
|
| 92 | DROP_DONT_RECEIVE = 1,
|
| 93 | DROP_DELETE = 2,
|
| 94 | DROP_ERROR = -1
|
| 95 | } Pop3DropValue; |
| 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 | }; |
| 105 | |
| 106 | struct _Pop3Session
|
| 107 | {
|
| 108 | Session session; |
| 109 | |
| 110 | Pop3State state; |
| 111 | |
| 112 | PrefsAccount *ac_prefs; |
| 113 | |
| 114 | gchar *greeting; |
| 115 | gchar *user; |
| 116 | gchar *pass; |
| 117 | gint count; |
| 118 | gint total_bytes; |
| 119 | gint cur_msg; |
| 120 | gint cur_total_num; |
| 121 | gint cur_total_bytes; |
| 122 | gint cur_total_recv_bytes; |
| 123 | |
| 124 | Pop3MsgInfo *msg; |
| 125 | |
| 126 | GHashTable *uidl_table; |
| 127 | |
| 128 | gboolean new_msg_exist; |
| 129 | gboolean uidl_is_valid; |
| 130 | |
| 131 | time_t current_time; |
| 132 | |
| 133 | Pop3ErrorValue error_val; |
| 134 | gchar *error_msg; |
| 135 | |
| 136 | gpointer data; |
| 137 | |
| 138 | /* virtual method to drop message */
|
| 139 | gint (*drop_message) (Pop3Session *session, |
| 140 | const gchar *file);
|
| 141 | }; |
| 142 | |
| 143 | #define POPBUFSIZE 512 |
| 144 | /* #define IDLEN 128 */
|
| 145 | #define IDLEN POPBUFSIZE
|
| 146 | |
| 147 | Session *pop3_session_new (PrefsAccount *account); |
| 148 | GHashTable *pop3_get_uidl_table (PrefsAccount *account); |
| 149 | gint pop3_write_uidl_list (Pop3Session *session); |
| 150 | |
| 151 | #endif /* __POP_H__ */ |