sync with 0.8.11cvs12
authorPaul Mangan <paul@claws-mail.org>
Tue, 25 Mar 2003 17:45:32 +0000 (17:45 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 25 Mar 2003 17:45:32 +0000 (17:45 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
src/common/session.c
src/pop.c
src/pop.h
src/send_message.c

index b5b2c78..ac90e4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-26
+
+       * src/pop.[ch]
+         src/session.c: fixed breakage of POP3 retrieval.
+         session_recv_data_from_sock_unescape(): read until terminator
+         appears and also return the actual size.
+
 2003-03-25
 
        * src/automaton.[ch]: removed.
index 99226b1..1b87983 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-25 [paul]      0.8.11claws45
+
+       * sync with 0.8.11cvs12
+               see ChangeLog 2003-03-26
+
 2003-03-25 [paul]      0.8.11claws44
 
        * sync with 0.8.11cvs11
index 8a8cf42..a91028a 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-26
+
+       * src/pop.[ch]
+         src/session.c: POP3 ¤Î¼õ¿®¤¬²õ¤ì¤Æ¤¤¤¿¤Î¤ò½¤Àµ¡£
+         session_recv_data_from_sock_unescape(): ½ªÃ¼µ­¹æ¤¬¸½¤ì¤ë¤Þ¤ÇÆɤß
+         ¤³¤ß¡¢¼ÂºÝ¤Î¥µ¥¤¥º¤âÊÖ¤¹¤è¤¦¤Ë¤·¤¿¡£
+
 2003-03-25
 
        * src/automaton.[ch]: ºï½ü¡£
index a47c17b..878cba1 100644 (file)
@@ -51,7 +51,8 @@ static guchar *session_recv_data_from_sock    (Session        *session,
                                                 guint           size);
 
 static guchar *session_recv_data_from_sock_unescape    (Session *session,
-                                                        guint    size);
+                                                        guint    size,
+                                                        guint   *actual_size);
 
 gboolean session_parent_input_cb       (GIOChannel     *source,
                                         GIOCondition    condition,
@@ -509,52 +510,43 @@ static guchar *session_recv_data_from_sock(Session *session, guint size)
 }
 
 static guchar *session_recv_data_from_sock_unescape(Session *session,
-                                                   guint size)
+                                                   guint size,
+                                                   guint *actual_size)
 {
-       guchar *data;
-       guchar *cur;
+       GString *data;
+       guchar *ret_data;
        gint bytes_read;
-       gint total_read_len = 0;
-       guint left = size;
        gchar buf[BUFFSIZE];
        gchar *msg;
        struct timeval tv_prev, tv_cur;
 
        gettimeofday(&tv_prev, NULL);
 
-       cur = data = g_malloc(size);
+       data = g_string_sized_new(size + 1);
+       *actual_size = 0;
 
        while (1) {
                bytes_read = sock_gets(session->sock, buf, sizeof(buf));
                if (bytes_read <= 0) {
-                       g_free(data);
+                       g_string_free(data, TRUE);
                        return NULL;
                }
 
-               if (buf[0] == '.' && buf[1] == '.') {
-                       bytes_read--;
-                       if (left < bytes_read)
-                               bytes_read = left;
-                       memcpy(cur, buf + 1, bytes_read);
-               } else {
-                       if (left < bytes_read)
-                               bytes_read = left;
-                       memcpy(cur, buf, bytes_read);
-               }
-               left -= bytes_read;
-               cur += bytes_read;
-               total_read_len += bytes_read;
-               if (left == 0)
+               if (buf[0] == '.' && buf[1] == '\r' && buf[2] == '\n')
                        break;
+               if (buf[0] == '.' && buf[1] == '.')
+                       g_string_append(data, buf + 1);
+               else
+                       g_string_append(data, buf);
 
                gettimeofday(&tv_cur, NULL);
                if (tv_cur.tv_sec - tv_prev.tv_sec > 0 ||
                    tv_cur.tv_usec - tv_prev.tv_usec > UI_REFRESH_INTERVAL) {
                        g_snprintf(buf, sizeof(buf), "DATARECVINPROG %d %d",
-                                  total_read_len, size);
+                                  data->len, MAX(data->len, size));
                        session_send_msg(session, SESSION_MSG_CONTROL, buf);
                        if ((msg = session_recv_msg(session)) == NULL) {
-                               g_free(data);
+                               g_string_free(data, TRUE);
                                return NULL;
                        }
                        g_free(msg);
@@ -562,7 +554,11 @@ static guchar *session_recv_data_from_sock_unescape(Session *session,
                }
        }
 
-       return data;
+       ret_data = data->str;
+       *actual_size = data->len;
+       g_string_free(data, FALSE);
+
+       return ret_data;
 }
 
 static SessionMsgType session_get_msg_type(const gchar *str)
@@ -705,6 +701,7 @@ gboolean session_child_input(Session *session)
        guchar *send_data;
        guchar *recv_data;
        guint size;
+       guint actual_size;
 
        if ((msg = session_recv_msg(session)) == NULL) {
                session_send_msg(session, SESSION_MSG_ERROR,
@@ -764,10 +761,11 @@ gboolean session_child_input(Session *session)
                msg_data = msg + strlen("RECVDATA ");
                size = atoi(msg_data);
                session->state = SESSION_RECV;
-               if (strstr(msg_data, "UNESCAPE") != NULL)
+               if (strstr(msg_data, "UNESCAPE") != NULL) {
                        recv_data = session_recv_data_from_sock_unescape
-                               (session, size);
-               else
+                               (session, size, &actual_size);
+                       size = actual_size;
+               } else
                        recv_data = session_recv_data_from_sock(session, size);
                if (!recv_data) {
                        session_send_msg(session, SESSION_MSG_ERROR,
index 09de1e1..81e0167 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -67,8 +67,6 @@ static gint pop3_retr_send            (Pop3Session *session);
 static gint pop3_retr_recv             (Pop3Session *session,
                                         const gchar *data,
                                         guint        len);
-static gint pop3_retr_eom_recv         (Pop3Session *session,
-                                        const gchar *msg);
 static gint pop3_delete_send           (Pop3Session *session);
 static gint pop3_delete_recv           (Pop3Session *session);
 static gint pop3_logout_send           (Pop3Session *session);
@@ -394,19 +392,6 @@ static gint pop3_retr_recv(Pop3Session *session, const gchar *data, guint len)
        return PS_SUCCESS;
 }
 
-static gint pop3_retr_eom_recv(Pop3Session *session, const gchar *msg)
-{
-       if (msg[0] == '.' && msg[1] == '\0')
-               return PS_SUCCESS;
-       else {
-               g_warning("pop3_retr_eom_recv(): "
-                         "invalid end of message: '%s'.\n"
-                         "Maybe given size and actual one is different?\n",
-                         msg);
-               return PS_PROTOCOL;
-       }
-}
-
 static gint pop3_delete_send(Pop3Session *session)
 {
        session->state = POP3_DELETE;
@@ -872,8 +857,7 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg)
 
        body = msg;
        if (pop3_session->state != POP3_GETRANGE_UIDL_RECV &&
-           pop3_session->state != POP3_GETSIZE_LIST_RECV &&
-           pop3_session->state != POP3_RETR_EOM) {
+           pop3_session->state != POP3_GETSIZE_LIST_RECV) {
                log_print("POP3< %s\n", msg);
                val = pop3_ok(pop3_session, msg);
                if (val != PS_SUCCESS) {
@@ -971,20 +955,6 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg)
                        (session,
                         pop3_session->msg[pop3_session->cur_msg].size, TRUE);
                break;
-       case POP3_RETR_EOM:
-               if (pop3_retr_eom_recv(pop3_session, body) != PS_SUCCESS)
-                       return -1;
-               if (pop3_session->ac_prefs->rmmail &&
-                   pop3_session->ac_prefs->msg_leave_time == 0)
-                       pop3_delete_send(pop3_session);
-               else if (pop3_session->cur_msg == pop3_session->count)
-                       pop3_logout_send(pop3_session);
-               else {
-                       pop3_session->cur_msg++;
-                       if (pop3_lookup_next(pop3_session) == POP3_ERROR)
-                               return -1;
-               }
-               break;
        case POP3_DELETE:
                pop3_delete_recv(pop3_session);
                if (pop3_session->cur_msg == pop3_session->count)
@@ -1017,7 +987,16 @@ static gint pop3_session_recv_data_finished(Session *session, guchar *data,
        if (pop3_retr_recv(pop3_session, data, len) < 0)
                return -1;
 
-       pop3_session->state = POP3_RETR_EOM;
+       if (pop3_session->ac_prefs->rmmail &&
+           pop3_session->ac_prefs->msg_leave_time == 0)
+               pop3_delete_send(pop3_session);
+       else if (pop3_session->cur_msg == pop3_session->count)
+               pop3_logout_send(pop3_session);
+       else {
+               pop3_session->cur_msg++;
+               if (pop3_lookup_next(pop3_session) == POP3_ERROR)
+                       return -1;
+       }
 
-       return 1;
+       return 0;
 }
index 08a8abd..20b8bbc 100644 (file)
--- a/src/pop.h
+++ b/src/pop.h
@@ -52,8 +52,8 @@ typedef enum {
        POP3_GETSIZE_LIST_RECV,
        POP3_RETR,
        POP3_TOP,                   
+       POP3_TOP_RECV,                    
        POP3_RETR_RECV,
-       POP3_RETR_EOM,
        POP3_DELETE,
        POP3_LOGOUT,
        POP3_ERROR,
index c091b9d..ad32d26 100644 (file)
@@ -485,14 +485,7 @@ static gint send_send_data_progressive(Session *session, guint cur_len,
 
 static gint send_send_data_finished(Session *session, guint len, gpointer data)
 {
-       SendProgressDialog *dialog = (SendProgressDialog *)data;
-       gchar buf[BUFFSIZE];
-
-       g_snprintf(buf, sizeof(buf), _("Sending message (%d / %d bytes)"),
-                  len, len);
-       progress_dialog_set_label(dialog->dialog, buf);
-       progress_dialog_set_percentage(dialog->dialog, 1.0);
-
+       send_send_data_progressive(session, len, len, data);
        return 0;
 }