/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <glib.h>
#include <time.h>
-#include "socket.h"
+#include "session.h"
#include "prefs_account.h"
typedef struct _Pop3MsgInfo Pop3MsgInfo;
-typedef struct _Pop3State Pop3State;
+typedef struct _Pop3Session Pop3Session;
+
+#define POP3_SESSION(obj) ((Pop3Session *)obj)
+
+#define MAIL_RECEIVE_HOOKLIST "mail_receive_hooklist"
+struct _MailReceiveData
+{
+ Pop3Session *session;
+ char *data;
+ guint data_len;
+};
+typedef struct _MailReceiveData MailReceiveData;
typedef enum {
- POP3_GREETING_RECV,
-#if USE_SSL
- POP3_STLS_SEND,
- POP3_STLS_RECV,
+ POP3_READY,
+ POP3_GREETING,
+#if USE_OPENSSL
+ POP3_STLS,
#endif
- POP3_GETAUTH_USER_SEND,
- POP3_GETAUTH_USER_RECV,
- POP3_GETAUTH_PASS_SEND,
- POP3_GETAUTH_PASS_RECV,
- POP3_GETAUTH_APOP_SEND,
- POP3_GETAUTH_APOP_RECV,
- POP3_GETRANGE_STAT_SEND,
- POP3_GETRANGE_STAT_RECV,
- POP3_GETRANGE_LAST_SEND,
- POP3_GETRANGE_LAST_RECV,
- POP3_GETRANGE_UIDL_SEND,
+ POP3_GETAUTH_USER,
+ POP3_GETAUTH_PASS,
+ POP3_GETAUTH_APOP,
+ POP3_GETRANGE_STAT,
+ POP3_GETRANGE_LAST,
+ POP3_GETRANGE_UIDL,
POP3_GETRANGE_UIDL_RECV,
- POP3_GETSIZE_LIST_SEND,
+ POP3_GETSIZE_LIST,
POP3_GETSIZE_LIST_RECV,
- POP3_TOP_SEND,
- POP3_TOP_RECV,
- POP3_RETR_SEND,
+ POP3_RETR,
POP3_RETR_RECV,
- POP3_DELETE_SEND,
- POP3_DELETE_RECV,
- POP3_LOGOUT_SEND,
- POP3_LOGOUT_RECV,
+ POP3_TOP,
+ POP3_TOP_RECV,
+ POP3_DELETE,
+ POP3_LOGOUT,
+ POP3_DONE,
+ POP3_ERROR,
+
+ N_POP3_STATE
+} Pop3State;
- N_POP3_PHASE
-} Pop3Phase;
+typedef enum {
+ PS_SUCCESS = 0, /* command successful */
+ PS_NOMAIL = 1, /* no mail available */
+ PS_SOCKET = 2, /* socket I/O woes */
+ PS_AUTHFAIL = 3, /* user authorization failed */
+ PS_PROTOCOL = 4, /* protocol violation */
+ PS_SYNTAX = 5, /* command-line syntax error */
+ PS_IOERR = 6, /* file I/O error */
+ PS_ERROR = 7, /* protocol error */
+ PS_EXCLUDE = 8, /* client-side exclusion error */
+ PS_LOCKBUSY = 9, /* server responded lock busy */
+ PS_SMTP = 10, /* SMTP error */
+ PS_DNS = 11, /* fatal DNS error */
+ PS_BSMTP = 12, /* output batch could not be opened */
+ PS_MAXFETCH = 13, /* poll ended by fetch limit */
+
+ PS_NOTSUPPORTED = 14, /* command not supported */
+
+ /* leave space for more codes */
+
+ PS_CONTINUE = 128 /* more responses may follow */
+} Pop3ErrorValue;
typedef enum {
RECV_TIME_NONE = 0,
gint size;
gchar *uidl;
time_t recv_time;
- guint received : 1;
- guint deleted : 1;
+ guint received : 1;
+ guint deleted : 1;
+ guint partial_recv : 2;
};
-struct _Pop3State
+struct _Pop3Session
{
- PrefsAccount *ac_prefs;
+ Session session;
+ Pop3State state;
gchar *prev_folder;
- SockInfo *sockinfo;
+ PrefsAccount *ac_prefs;
+ gboolean pop_before_smtp;
gchar *greeting;
gchar *user;
gchar *pass;
gint count;
- gint new;
gint total_bytes;
gint cur_msg;
gint cur_total_num;
Pop3MsgInfo *msg;
GHashTable *uidl_table;
-
+ GHashTable *partial_recv_table;
+
+ gboolean new_msg_exist;
gboolean uidl_is_valid;
- gboolean cancelled;
time_t current_time;
- gint error_val;
+ Pop3ErrorValue error_val;
+ gchar *error_msg;
gpointer data;
+
+ /* virtual method to drop message */
+ gint (*drop_message) (Pop3Session *session,
+ const gchar *file);
};
#define POPBUFSIZE 512
-#define IDLEN 128
-
-/* exit code values */
-#define PS_SUCCESS 0 /* successful receipt of messages */
-#define PS_NOMAIL 1 /* no mail available */
-#define PS_SOCKET 2 /* socket I/O woes */
-#define PS_AUTHFAIL 3 /* user authorization failed */
-#define PS_PROTOCOL 4 /* protocol violation */
-#define PS_SYNTAX 5 /* command-line syntax error */
-#define PS_IOERR 6 /* bad permissions on rc file */
-#define PS_ERROR 7 /* protocol error */
-#define PS_EXCLUDE 8 /* client-side exclusion error */
-#define PS_LOCKBUSY 9 /* server responded lock busy */
-#define PS_SMTP 10 /* SMTP error */
-#define PS_DNS 11 /* fatal DNS error */
-#define PS_BSMTP 12 /* output batch could not be opened */
-#define PS_MAXFETCH 13 /* poll ended by fetch limit */
-/* leave space for more codes */
-#define PS_UNDEFINED 23 /* something I hadn't thought of */
-#define PS_TRANSIENT 24 /* transient failure (internal use) */
-#define PS_REFUSED 25 /* mail refused (internal use) */
-#define PS_RETAINED 26 /* message retained (internal use) */
-#define PS_TRUNCATED 27 /* headers incomplete (internal use) */
-
-gint pop3_greeting_recv (SockInfo *sock, gpointer data);
-gint pop3_getauth_user_send (SockInfo *sock, gpointer data);
-gint pop3_getauth_user_recv (SockInfo *sock, gpointer data);
-gint pop3_getauth_pass_send (SockInfo *sock, gpointer data);
-gint pop3_getauth_pass_recv (SockInfo *sock, gpointer data);
-gint pop3_getauth_apop_send (SockInfo *sock, gpointer data);
-gint pop3_getauth_apop_recv (SockInfo *sock, gpointer data);
-#if USE_SSL
-gint pop3_stls_send (SockInfo *sock, gpointer data);
-gint pop3_stls_recv (SockInfo *sock, gpointer data);
-#endif
-gint pop3_getrange_stat_send (SockInfo *sock, gpointer data);
-gint pop3_getrange_stat_recv (SockInfo *sock, gpointer data);
-gint pop3_getrange_last_send (SockInfo *sock, gpointer data);
-gint pop3_getrange_last_recv (SockInfo *sock, gpointer data);
-gint pop3_getrange_uidl_send (SockInfo *sock, gpointer data);
-gint pop3_getrange_uidl_recv (SockInfo *sock, gpointer data);
-gint pop3_getsize_list_send (SockInfo *sock, gpointer data);
-gint pop3_getsize_list_recv (SockInfo *sock, gpointer data);
-gint pop3_top_send (SockInfo *sock, gpointer data);
-gint pop3_top_recv (SockInfo *sock, gpointer data);
-gint pop3_retr_send (SockInfo *sock, gpointer data);
-gint pop3_retr_recv (SockInfo *sock, gpointer data);
-gint pop3_delete_send (SockInfo *sock, gpointer data);
-gint pop3_delete_recv (SockInfo *sock, gpointer data);
-gint pop3_logout_send (SockInfo *sock, gpointer data);
-gint pop3_logout_recv (SockInfo *sock, gpointer data);
-
-Pop3State *pop3_state_new (PrefsAccount *account);
-void pop3_state_destroy (Pop3State *state);
-GHashTable *pop3_get_uidl_table (PrefsAccount *account);
-gint pop3_write_uidl_list (Pop3State *state);
+/* #define IDLEN 128 */
+#define IDLEN POPBUFSIZE
+
+Session *pop3_session_new (PrefsAccount *account);
+void pop3_get_uidl_table (PrefsAccount *account, Pop3Session *session);
+gint pop3_write_uidl_list (Pop3Session *session);
#endif /* __POP_H__ */