diff options
Diffstat (limited to 'libsylph/pop.h')
| -rw-r--r-- | libsylph/pop.h | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/libsylph/pop.h b/libsylph/pop.h new file mode 100644 index 0000000..050caf5 --- /dev/null +++ b/libsylph/pop.h | |||
| @@ -0,0 +1,157 @@ | |||
| 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 | #include "utils.h" | ||
| 33 | |||
| 34 | typedef struct _Pop3MsgInfo Pop3MsgInfo; | ||
| 35 | typedef struct _Pop3Session Pop3Session; | ||
| 36 | |||
| 37 | #define POP3_SESSION(obj) ((Pop3Session *)obj) | ||
| 38 | |||
| 39 | typedef enum { | ||
| 40 | POP3_READY, | ||
| 41 | POP3_GREETING, | ||
| 42 | POP3_STLS, | ||
| 43 | POP3_GETAUTH_USER, | ||
| 44 | POP3_GETAUTH_PASS, | ||
| 45 | POP3_GETAUTH_APOP, | ||
| 46 | POP3_GETRANGE_STAT, | ||
| 47 | POP3_GETRANGE_LAST, | ||
| 48 | POP3_GETRANGE_UIDL, | ||
| 49 | POP3_GETRANGE_UIDL_RECV, | ||
| 50 | POP3_GETSIZE_LIST, | ||
| 51 | POP3_GETSIZE_LIST_RECV, | ||
| 52 | POP3_RETR, | ||
| 53 | POP3_RETR_RECV, | ||
| 54 | POP3_DELETE, | ||
| 55 | POP3_LOGOUT, | ||
| 56 | POP3_DONE, | ||
| 57 | POP3_ERROR, | ||
| 58 | |||
| 59 | N_POP3_STATE | ||
| 60 | } Pop3State; | ||
| 61 | |||
| 62 | typedef enum { | ||
| 63 | PS_SUCCESS = 0, /* command successful */ | ||
| 64 | PS_NOMAIL = 1, /* no mail available */ | ||
| 65 | PS_SOCKET = 2, /* socket I/O woes */ | ||
| 66 | PS_AUTHFAIL = 3, /* user authorization failed */ | ||
| 67 | PS_PROTOCOL = 4, /* protocol violation */ | ||
| 68 | PS_SYNTAX = 5, /* command-line syntax error */ | ||
| 69 | PS_IOERR = 6, /* file I/O error */ | ||
| 70 | PS_ERROR = 7, /* protocol error */ | ||
| 71 | PS_EXCLUDE = 8, /* client-side exclusion error */ | ||
| 72 | PS_LOCKBUSY = 9, /* server responded lock busy */ | ||
| 73 | PS_SMTP = 10, /* SMTP error */ | ||
| 74 | PS_DNS = 11, /* fatal DNS error */ | ||
| 75 | PS_BSMTP = 12, /* output batch could not be opened */ | ||
| 76 | PS_MAXFETCH = 13, /* poll ended by fetch limit */ | ||
| 77 | |||
| 78 | PS_NOTSUPPORTED = 14, /* command not supported */ | ||
| 79 | |||
| 80 | /* leave space for more codes */ | ||
| 81 | |||
| 82 | PS_CONTINUE = 128 /* more responses may follow */ | ||
| 83 | } Pop3ErrorValue; | ||
| 84 | |||
| 85 | typedef enum { | ||
| 86 | RECV_TIME_NONE = 0, | ||
| 87 | RECV_TIME_RECEIVED = 1, | ||
| 88 | RECV_TIME_KEEP = 2, | ||
| 89 | RECV_TIME_DELETE = 3 | ||
| 90 | } RecvTime; | ||
| 91 | |||
| 92 | typedef enum { | ||
| 93 | DROP_OK = 0, | ||
| 94 | DROP_DONT_RECEIVE = 1, | ||
| 95 | DROP_DELETE = 2, | ||
| 96 | DROP_ERROR = -1 | ||
| 97 | } Pop3DropValue; | ||
| 98 | |||
| 99 | struct _Pop3MsgInfo | ||
| 100 | { | ||
| 101 | gint size; | ||
| 102 | gchar *uidl; | ||
| 103 | stime_t recv_time; | ||
| 104 | guint received : 1; | ||
| 105 | guint deleted : 1; | ||
| 106 | }; | ||
| 107 | |||
| 108 | struct _Pop3Session | ||
| 109 | { | ||
| 110 | Session session; | ||
| 111 | |||
| 112 | Pop3State state; | ||
| 113 | |||
| 114 | PrefsAccount *ac_prefs; | ||
| 115 | |||
| 116 | gchar *greeting; | ||
| 117 | gchar *user; | ||
| 118 | gchar *pass; | ||
| 119 | gint count; | ||
| 120 | gint64 total_bytes; | ||
| 121 | gint cur_msg; | ||
| 122 | gint cur_total_num; | ||
| 123 | gint64 cur_total_bytes; | ||
| 124 | gint64 cur_total_recv_bytes; | ||
| 125 | gint skipped_num; | ||
| 126 | |||
| 127 | Pop3MsgInfo *msg; | ||
| 128 | |||
| 129 | GHashTable *uidl_table; | ||
| 130 | |||
| 131 | gboolean auth_only; | ||
| 132 | |||
| 133 | gboolean new_msg_exist; | ||
| 134 | gboolean uidl_is_valid; | ||
| 135 | |||
| 136 | stime_t current_time; | ||
| 137 | |||
| 138 | Pop3ErrorValue error_val; | ||
| 139 | gchar *error_msg; | ||
| 140 | |||
| 141 | gpointer data; | ||
| 142 | |||
| 143 | /* virtual method to drop message */ | ||
| 144 | gint (*drop_message) (Pop3Session *session, | ||
| 145 | const gchar *file); | ||
| 146 | }; | ||
| 147 | |||
| 148 | #define POPBUFSIZE 512 | ||
| 149 | /* #define IDLEN 128 */ | ||
| 150 | #define IDLEN POPBUFSIZE | ||
| 151 | |||
| 152 | Session *pop3_session_new (PrefsAccount *account); | ||
| 153 | |||
| 154 | GHashTable *pop3_get_uidl_table (PrefsAccount *account); | ||
| 155 | gint pop3_write_uidl_list (Pop3Session *session); | ||
| 156 | |||
| 157 | #endif /* __POP_H__ */ | ||
