sync with main 0.9.11cvs2
authorPaul Mangan <paul@claws-mail.org>
Tue, 8 Jun 2004 10:55:38 +0000 (10:55 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 8 Jun 2004 10:55:38 +0000 (10:55 +0000)
13 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/defs.h
src/common/session.c
src/common/session.h
src/imap.c
src/inc.c
src/inc.h
src/news.c
src/pop.h
src/send_message.c

index e4ffb39..aaa8da9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-06-08
+
+       * src/inc.[ch]
+         src/send_message.c
+         src/session.[ch]: implemented session timeout.
+       * src/pop.h: removed unused values from Pop3ErrorValue.
+
 2004-06-07
 
        * src/inc.c: inc_all_account_mail(): code cleanup.
index 3ae6efe..da83788 100644 (file)
@@ -1,3 +1,14 @@
+2004-06-08 [paul]      0.9.11cvs6
+
+       * sync with main 0.9.11cvs2
+               see ChangeLog 2004-06-08
+
+2004-06-07 [christoph] 0.9.11cvs5
+
+       * configure.ac
+       * src/common/Makefile.am
+               detect library providing 'encrypt' function
+
 2004-06-07 [paul]      0.9.11cvs4
 
        * src/inc.c
index 595943b..fa93e7c 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-08
+
+       * src/inc.[ch]
+         src/send_message.c
+         src/session.[ch]: ¥»¥Ã¥·¥ç¥ó¤Î¥¿¥¤¥à¥¢¥¦¥È¤ò¼ÂÁõ¡£
+       * src/pop.h: Pop3ErrorValue ¤«¤é̤»ÈÍѤÎÃͤòºï½ü¡£
+
 2004-06-07
 
        * src/inc.c: inc_all_account_mail(): ¥³¡¼¥É¤ÎÀ°Íý¡£
index f3d4392..0320c31 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=4
+EXTRA_VERSION=6
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index adefdef..6b5716c 100644 (file)
 #define UI_REFRESH_INTERVAL            50000   /* usec */
 #define FOLDER_UPDATE_INTERVAL         1500    /* msec */
 #define PROGRESS_UPDATE_INTERVAL       200     /* msec */
-#define SESSION_TIMEOUT                        60      /* sec */
+#define SESSION_TIMEOUT_INTERVAL       60      /* sec */
 #define MAX_HISTORY_SIZE               16
 
 #define NORMAL_FONT prefs_common.normalfont
index 6c34156..22feccc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 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
@@ -42,6 +42,8 @@ static gint session_connect_cb                (SockInfo       *sock,
                                         gpointer        data);
 static gint session_close              (Session        *session);
 
+static gboolean session_timeout_cb     (gpointer        data);
+
 static gboolean session_recv_msg_idle_cb       (gpointer        data);
 static gboolean session_recv_data_idle_cb      (gpointer        data);
 
@@ -88,6 +90,9 @@ void session_init(Session *session)
        session->write_buf_p = NULL;
        session->write_buf_len = 0;
 
+       session->timeout_tag = 0;
+       session->timeout_interval = 0;
+
        session->data = NULL;
 }
 
@@ -200,6 +205,34 @@ gboolean session_is_connected(Session *session)
                session->state == SESSION_RECV);
 }
 
+void session_set_timeout(Session *session, guint interval)
+{
+       if (session->timeout_tag > 0)
+               g_source_remove(session->timeout_tag);
+
+       session->timeout_interval = interval;
+       if (interval > 0)
+               session->timeout_tag =
+                       g_timeout_add(interval, session_timeout_cb, session);
+}
+
+static gboolean session_timeout_cb(gpointer data)
+{
+       Session *session = SESSION(data);
+
+       g_warning("session timeout.\n");
+
+       if (session->io_tag > 0) {
+               g_source_remove(session->io_tag);
+               session->io_tag = 0;
+       }
+
+       session->timeout_tag = 0;
+       session->state = SESSION_TIMEOUT;
+
+       return FALSE;
+}
+
 void session_set_recv_message_notify(Session *session,
                                     RecvMsgNotify notify_func, gpointer data)
 {
@@ -253,8 +286,11 @@ static gint session_close(Session *session)
        if (session->conn_id > 0) {
                sock_connect_async_cancel(session->conn_id);
                session->conn_id = 0;
+               debug_print("session (%p): connection cancelled\n", session);
        }
 
+       session_set_timeout(session, 0);
+
        if (session->io_tag > 0) {
                g_source_remove(session->io_tag);
                session->io_tag = 0;
@@ -264,10 +300,9 @@ static gint session_close(Session *session)
                sock_close(session->sock);
                session->sock = NULL;
                session->state = SESSION_DISCONNECTED;
+               debug_print("session (%p): closed\n", session);
        }
 
-       debug_print("session (%p): closed\n", session);
-
        return 0;
 }
 
@@ -431,6 +466,8 @@ static gboolean session_read_msg_cb(SockInfo *source, GIOCondition condition,
 
        g_return_val_if_fail(condition == G_IO_IN, FALSE);
 
+       session_set_timeout(session, session->timeout_interval);
+
        if (session->read_buf_len == 0) {
                gint read_len;
 
@@ -515,6 +552,8 @@ static gboolean session_read_data_cb(SockInfo *source, GIOCondition condition,
 
        g_return_val_if_fail(condition == G_IO_IN, FALSE);
 
+       session_set_timeout(session, session->timeout_interval);
+
        if (session->read_buf_len == 0) {
                gint read_len;
 
@@ -704,6 +743,7 @@ static gboolean session_write_data_cb(SockInfo *source,
                if (tv_cur.tv_sec - session->tv_prev.tv_sec > 0 ||
                    tv_cur.tv_usec - session->tv_prev.tv_usec >
                    UI_REFRESH_INTERVAL) {
+                       session_set_timeout(session, session->timeout_interval);
                        session->send_data_progressive_notify
                                (session,
                                 session->write_buf_p - session->write_buf,
index d747a14..6dcb794 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 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
@@ -51,6 +51,7 @@ typedef enum {
        SESSION_SEND,
        SESSION_RECV,
        SESSION_EOF,
+       SESSION_TIMEOUT,
        SESSION_ERROR,
        SESSION_DISCONNECTED
 } SessionState;
@@ -119,6 +120,9 @@ struct _Session
        gchar *write_buf_p;
        gint write_buf_len;
 
+       guint timeout_tag;
+       guint timeout_interval;
+
        gpointer data;
 
        /* virtual methods to parse server responses */
@@ -155,6 +159,9 @@ gint session_disconnect             (Session        *session);
 void session_destroy           (Session        *session);
 gboolean session_is_connected  (Session        *session);
 
+void session_set_timeout       (Session        *session,
+                                guint           interval);
+
 void session_set_recv_message_notify   (Session        *session,
                                         RecvMsgNotify   notify_func,
                                         gpointer        data);
index 58d3568..deaf8ae 100644 (file)
@@ -659,7 +659,7 @@ static IMAPSession *imap_session_get(Folder *folder)
         * A better solution than sending a NOOP every time would be
         * for every command to be prepared to retry until it is
         * successfully sent. -- mbp */
-       if (time(NULL) - session->last_access_time > SESSION_TIMEOUT) {
+       if (time(NULL) - session->last_access_time > SESSION_TIMEOUT_INTERVAL) {
                /* verify that the session is still alive */
                if (imap_cmd_noop(session) != IMAP_SUCCESS) {
                        /* Check if this is the first try to establish a
index 69372f8..3a62b59 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -583,6 +583,9 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                case INC_EOF:
                        SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask, _("Error"));
                        break;
+               case INC_TIMEOUT:
+                       SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask, _("Timeout"));
+                       break;
                case INC_CANCEL:
                        SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, _("Cancelled"));
                        break;
@@ -622,8 +625,6 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                }
                g_slist_free(msglist);
 
-               statusbar_pop_all();
-
                new_msgs += pop3_session->cur_total_num;
 
                if (pop3_session->error_val == PS_AUTHFAIL &&
@@ -736,6 +737,9 @@ static IncState inc_pop3_session_do(IncSession *session)
        progress_dialog_set_label(inc_dialog->dialog, buf);
        g_free(buf);
 
+       session_set_timeout(SESSION(pop3_session),
+                           prefs_common.io_timeout_secs * 1000);
+
        if (session_connect(SESSION(pop3_session), server, port) < 0) {
                log_warning(_("Can't connect to POP3 server: %s:%d\n"),
                            server, port);
@@ -757,20 +761,26 @@ static IncState inc_pop3_session_do(IncSession *session)
               session->inc_state != INC_CANCEL)
                gtk_main_iteration();
 
-       statusbar_pop_all();
-
        if (session->inc_state == INC_SUCCESS) {
                switch (pop3_session->error_val) {
                case PS_SUCCESS:
-                       if (SESSION(pop3_session)->state == SESSION_ERROR) {
+                       switch (SESSION(pop3_session)->state) {
+                       case SESSION_ERROR:
                                if (pop3_session->state == POP3_READY)
                                        session->inc_state = INC_CONNECT_ERROR;
                                else
                                        session->inc_state = INC_ERROR;
-                       } else if (SESSION(pop3_session)->state == SESSION_EOF)
+                               break;
+                       case SESSION_EOF:
                                session->inc_state = INC_EOF;
-                       else
+                               break;
+                       case SESSION_TIMEOUT:
+                               session->inc_state = INC_TIMEOUT;
+                               break;
+                       default:
                                session->inc_state = INC_SUCCESS;
+                               break;
+                       }
                        break;
                case PS_AUTHFAIL:
                        session->inc_state = INC_AUTH_FAILED;
@@ -790,6 +800,9 @@ static IncState inc_pop3_session_do(IncSession *session)
                }
        }
 
+       session_disconnect(SESSION(pop3_session));
+       statusbar_pop_all();
+
        return session->inc_state;
 }
 
@@ -1108,6 +1121,12 @@ static void inc_put_error(IncState istate, const gchar *msg)
                else
                        err_msg = g_strdup(log_msg);
                break;
+       case INC_TIMEOUT:
+               log_msg = _("Session timed out.");
+               if (prefs_common.no_recv_err_panel)
+                       break;
+               err_msg = g_strdup(log_msg);
+               break;
        default:
                break;
        }
index 1d46882..507b815 100644 (file)
--- a/src/inc.h
+++ b/src/inc.h
@@ -48,6 +48,7 @@ typedef enum
        INC_IO_ERROR,
        INC_SOCKET_ERROR,
        INC_EOF,
+       INC_TIMEOUT,
        INC_CANCEL
 } IncState;
 
index 40fb340..d6b4031 100644 (file)
@@ -266,7 +266,7 @@ static NNTPSession *news_session_get(Folder *folder)
                return NNTP_SESSION(rfolder->session);
        }
 
-       if (time(NULL) - rfolder->session->last_access_time < SESSION_TIMEOUT) {
+       if (time(NULL) - rfolder->session->last_access_time < SESSION_TIMEOUT_INTERVAL) {
                rfolder->session->last_access_time = time(NULL);
                return NNTP_SESSION(rfolder->session);
        }
index bf62212..9672c74 100644 (file)
--- a/src/pop.h
+++ b/src/pop.h
@@ -87,12 +87,6 @@ typedef enum {
 
        /* leave space for more codes */
 
-       PS_UNDEFINED    = 23,   /* something I hadn't thought of */
-       PS_TRANSIENT    = 24,   /* transient failure (internal use) */
-       PS_REFUSED      = 25,   /* mail refused (internal use) */
-       PS_RETAINED     = 26,   /* message retained (internal use) */
-       PS_TRUNCATED    = 27,   /* headers incomplete (internal use) */
-
        PS_CONTINUE     = 128   /* more responses may follow */
 } Pop3ErrorValue;
 
index 0327d37..547d109 100644 (file)
@@ -414,6 +414,7 @@ gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp)
                ret = -1;
        } else if (session->state == SESSION_ERROR ||
                   session->state == SESSION_EOF ||
+                  session->state == SESSION_TIMEOUT ||
                   SMTP_SESSION(session)->state == SMTP_ERROR ||
                   SMTP_SESSION(session)->error_val != SM_OK)
                ret = -1;
@@ -594,13 +595,22 @@ static void send_put_error(Session *session)
                        err_msg = g_strdup(log_msg);
                break;
        default:
-               if (session->state == SESSION_ERROR) {
+               switch (session->state) {
+               case SESSION_ERROR:
                        log_msg =
                                _("Error occurred while sending the message.");
                        err_msg = g_strdup(log_msg);
-               } else if (session->state == SESSION_EOF) {
+                       break;
+               case SESSION_EOF:
                        log_msg = _("Connection closed by the remote host.");
                        err_msg = g_strdup(log_msg);
+                       break;
+               case SESSION_TIMEOUT:
+                       log_msg = _("Session timed out.");
+                       err_msg = g_strdup(log_msg);
+                       break;
+               default:
+                       break;
                }
                break;
        }