sync with sylpheed 0.7.2cvs18
authorPaul Mangan <paul@claws-mail.org>
Wed, 27 Feb 2002 08:15:53 +0000 (08:15 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 27 Feb 2002 08:15:53 +0000 (08:15 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/codeconv.c
src/inc.c
src/inc.h
src/pop.c
src/pop.h

index 85dafa8b6f5dd559c521419bbf180746d4786f2f..95098120e73de7ab869304123ee105c13ea87017 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,22 @@
+2002-02-27
+
+       * src/inc.c: get_spool(): fixed a bug that failed to unlock mbox
+         if copy_mbox() failed (thanks to Alexander Kabaev).
+
+2002-02-26
+
+       * src/inc.[ch]
+         src/pop.[ch]: refactored the UIDL management.
+         store the information of messages into the array of Pop3MsgInfo
+         structure, and do full scanning of not retrieved messages.
+
 2002-02-26
 
        * src/filesel.c
          src/foldersel.c
          src/mainwindow.c: set WMCLASS for window/dialog.
+       * src/codeconv.c: conv_codeset_strdup(): return source string
+         when jconv_alloc_conv() failed.
 
 2002-02-25
 
index 34bc06b8e9140709f69fb627baea0812250c3a39..7d82e06cb7d099609881c19b8c37f2a70a9804ba 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-27 [paul]      0.7.2claws18
+
+       * sync with sylpheed 0.7.2cvs18
+               see ChangeLog entries 2002-02-26 and 2002-02-27
+
 2002-02-26 [alfons]    0.7.2claws17
 
        * src/procheader.c
@@ -18,9 +23,9 @@
                * the checking of plaintext signatures always comes up in 
                  a popup box
                * it doesn't work for multipart messages 
-               * the mail headers and first lines of a pgptext signed message 
-                 (e.g. -----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1)
-                 are not displayed
+               * all lines above "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1",
+                 including the msg headers and these 2 line themselves, are 
+                 not displayed
 
        * src/mainwindow.c
                "View/Folder Tree" becomes "View/Separate Folder View"
index 4ddb20b45485e77d0fad641d21111c6446b8298d..2160f59a1740a19489d260b0ed4d8bb72a14b327 100644 (file)
@@ -1,8 +1,22 @@
+2002-02-27
+
+       * src/inc.c: get_spool(): copy_mbox() ¤Ë¼ºÇÔ¤·¤¿¤È¤­ mbox ¤ò¥í¥Ã¥¯
+         ²ò½ü¤·¤Æ¤¤¤Ê¤«¤Ã¤¿¥Ð¥°¤ò½¤Àµ(Alexander Kabaev ¤µ¤ó thanks)¡£
+
+2002-02-26
+
+       * src/inc.[ch]
+         src/pop.[ch]: UIDL ´ÉÍý¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡£
+         ¥á¥Ã¥»¡¼¥¸¤Î¾ðÊó¤ò Pop3MsgInfo ¹½Â¤ÂΤÎÇÛÎó¤ËÊÝ»ý¤·¡¢Ì¤¼èÆÀ
+         ¥á¥Ã¥»¡¼¥¸¤ò´°Á´¤ËÄ´¤Ù¤ë¤è¤¦¤Ë¤·¤¿¡£
+
 2002-02-26
 
        * src/filesel.c
          src/foldersel.c
          src/mainwindow.c: ¥¦¥£¥ó¥É¥¦/¥À¥¤¥¢¥í¥°¤Î WMCLASS ¤ò¥»¥Ã¥È¡£
+       * src/codeconv.c: conv_codeset_strdup(): jconv_alloc_conv() ¤¬
+         ¼ºÇÔ¤·¤¿¤é¸µ¤Îʸ»úÎó¤òÊÖ¤¹¤è¤¦¤Ë¤·¤¿¡£
 
 2002-02-25
 
index 35e23143dc78fd23327addc783f479ffc77957fe..032caaf994eaaf3b3a0cce14762d0bfa2c6ea2cb 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws17
+EXTRA_VERSION=claws18
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 566efdda66c98083fac7b7b1bbccaddd4fad32d9..093054ff2d3b87da09c702a722f464b80525d769 100644 (file)
@@ -374,8 +374,12 @@ gchar *conv_codeset_strdup(const gchar *inbuf,
                             &actual_codeset, dest_codeset)
            == 0)
                return buf;
-       else
+       else {
+               g_warning("code conversion from %s to %s failed\n",
+                         codesets && codesets[0] ? codesets[0] : "(unknown)",
+                         dest_codeset);
                return g_strdup(inbuf);
+       }
 #else /* !HAVE_LIBJCONV */
        if (src_codeset) {
                if (!strcasecmp(src_codeset, CS_EUC_JP) ||
index 3aa76aca1a6dcfb2874ab094f913047ce8e5f1ac..91903b8f35335de6d370710c7eaec58aa3779299 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -389,8 +389,6 @@ static Pop3State *inc_pop3_state_new(PrefsAccount *account)
        state->ac_prefs = account;
        state->folder_table = g_hash_table_new(NULL, NULL);
        state->id_table = inc_get_uidl_table(account);
-       state->id_list = NULL;
-       state->new_id_list = NULL;
        state->inc_state = INC_SUCCESS;
 
        return state;
@@ -398,17 +396,18 @@ static Pop3State *inc_pop3_state_new(PrefsAccount *account)
 
 static void inc_pop3_state_destroy(Pop3State *state)
 {
+       gint n;
+
        g_hash_table_destroy(state->folder_table);
-       g_free(state->sizes);
+
+       for (n = 1; n <= state->count; n++)
+               g_free(state->msg[n].uidl);
+       g_free(state->msg);
 
        if (state->id_table) {
                hash_free_strings(state->id_table);
                g_hash_table_destroy(state->id_table);
        }
-       slist_free_strings(state->id_list);
-       slist_free_strings(state->new_id_list);
-       g_slist_free(state->id_list);
-       g_slist_free(state->new_id_list);
 
        g_free(state->greeting);
        g_free(state->user);
@@ -766,9 +765,7 @@ static void inc_write_uidl_list(Pop3State *state)
 {
        gchar *path;
        FILE *fp;
-       GSList *cur;
-
-       if (!state->id_list) return;
+       gint n;
 
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                           "uidl-", state->ac_prefs->recv_server,
@@ -779,14 +776,17 @@ static void inc_write_uidl_list(Pop3State *state)
                return;
        }
 
-       for (cur = state->id_list; cur != NULL; cur = cur->next) {
-               if (fputs((gchar *)cur->data, fp) == EOF) {
-                       FILE_OP_ERROR(path, "fputs");
-                       break;
-               }
-               if (fputc('\n', fp) == EOF) {
-                       FILE_OP_ERROR(path, "fputc");
-                       break;
+       for (n = 1; n <= state->count; n++) {
+               if (state->msg[n].uidl && state->msg[n].received &&
+                   !state->msg[n].deleted) {
+                       if (fputs(state->msg[n].uidl, fp) == EOF) {
+                               FILE_OP_ERROR(path, "fputs");
+                               break;
+                       }
+                       if (fputc('\n', fp) == EOF) {
+                               FILE_OP_ERROR(path, "fputc");
+                               break;
+                       }
                }
        }
 
@@ -1065,8 +1065,10 @@ static gint get_spool(FolderItem *dest, const gchar *mbox)
        g_snprintf(tmp_mbox, sizeof(tmp_mbox), "%s%ctmpmbox%d",
                   get_rc_dir(), G_DIR_SEPARATOR, (gint)mbox);
 
-       if (copy_mbox(mbox, tmp_mbox) < 0)
+       if (copy_mbox(mbox, tmp_mbox) < 0) {
+               unlock_mbox(mbox, lockfd, LOCK_FLOCK);
                return -1;
+       }
 
        debug_print(_("Getting new messages from %s into %s...\n"),
                    mbox, dest->path);
index 1460fde97c36b2047a6b14f8a24c7b1c40a404f7..6809109f2697dafd78f00eecba86d8b451056b0d 100644 (file)
--- a/src/inc.h
+++ b/src/inc.h
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 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
@@ -85,12 +85,10 @@ struct _Pop3State
        gint cur_msg;
        gint cur_total_num;
        gint cur_total_bytes;
-       gint *sizes;
 
-       /* UIDL */
+       Pop3MsgInfo *msg;
+
        GHashTable *id_table;
-       GSList *id_list;
-       GSList *new_id_list;
 
        gint error_val;
        IncState inc_state;
index fd6e882e585b26a0698ca87d019cf2a560133139..43ed30808cec1eeaaeb647de2098079965572e11 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
 
 #define LOOKUP_NEXT_MSG() \
        for (;;) { \
-               gint size = state->sizes[state->cur_msg]; \
- \
-               if (size == 0 || \
+               gint size = state->msg[state->cur_msg].size; \
+               gboolean size_limit_over = \
                    (state->ac_prefs->enable_size_limit && \
                     state->ac_prefs->size_limit > 0 && \
-                    size > state->ac_prefs->size_limit * 1024)) { \
-                       log_print(_("Skipping message %d\n"), state->cur_msg); \
-                       if (size > 0) { \
+                    size > state->ac_prefs->size_limit * 1024); \
+ \
+               if (size_limit_over) \
+                       log_print(_("POP3: Skipping message %d (%d bytes)\n"), \
+                                 state->cur_msg, size); \
+ \
+               if (size == 0 || state->msg[state->cur_msg].received || \
+                   size_limit_over) { \
+                       if (size > 0) \
                                state->cur_total_bytes += size; \
-                               state->cur_total_num++; \
-                               if (state->new_id_list) { \
-                                       state->id_list = g_slist_append(state->id_list, state->new_id_list->data); \
-                                       state->new_id_list = g_slist_remove(state->new_id_list, state->new_id_list->data); \
-                               } \
-                       } \
                        if (state->cur_msg == state->count) \
                                return POP3_LOGOUT_SEND; \
                        else \
@@ -220,13 +219,10 @@ gint pop3_getrange_stat_recv(SockInfo *sock, gpointer data)
                        if (state->count == 0)
                                return POP3_LOGOUT_SEND;
                        else {
+                               state->msg = g_new0
+                                       (Pop3MsgInfo, state->count + 1);
                                state->cur_msg = 1;
-                               state->new = state->count;
-                               if (state->ac_prefs->rmmail ||
-                                   state->ac_prefs->getall)
-                                       return POP3_GETSIZE_LIST_SEND;
-                               else
-                                       return POP3_GETRANGE_UIDL_SEND;
+                               return POP3_GETRANGE_UIDL_SEND;
                        }
                }
        } else if (ok == PS_PROTOCOL)
@@ -261,7 +257,6 @@ gint pop3_getrange_last_recv(SockInfo *sock, gpointer data)
                        if (state->count == last)
                                return POP3_LOGOUT_SEND;
                        else {
-                               state->new = state->count - last;
                                state->cur_msg = last + 1;
                                return POP3_GETSIZE_LIST_SEND;
                        }
@@ -285,12 +280,15 @@ gint pop3_getrange_uidl_recv(SockInfo *sock, gpointer data)
 {
        Pop3State *state = (Pop3State *)data;
        gboolean new = FALSE;
+       gboolean get_all = FALSE;
        gchar buf[POPBUFSIZE];
        gchar id[IDLEN + 1];
 
        if (pop3_ok(sock, NULL) != PS_SUCCESS) return POP3_GETRANGE_LAST_SEND;
 
        if (!state->id_table) new = TRUE;
+       if (state->ac_prefs->rmmail || state->ac_prefs->getall)
+               get_all = TRUE;
 
        while (sock_gets(sock, buf, sizeof(buf)) >= 0) {
                gint num;
@@ -298,20 +296,21 @@ gint pop3_getrange_uidl_recv(SockInfo *sock, gpointer data)
                if (buf[0] == '.') break;
                if (sscanf(buf, "%d %" Xstr(IDLEN) "s", &num, id) != 2)
                        continue;
+               if (num <= 0 || num > state->count) continue;
 
-               if (new == FALSE &&
-                   g_hash_table_lookup(state->id_table, id) == NULL) {
-                       state->new = state->count - num + 1;
-                       state->cur_msg = num;
-                       new = TRUE;
-               }
+               state->msg[num].uidl = g_strdup(id);
 
-               if (new == TRUE)
-                       state->new_id_list = g_slist_append
-                               (state->new_id_list, g_strdup(id));
-               else
-                       state->id_list = g_slist_append
-                               (state->id_list, g_strdup(id));
+               if (state->id_table) {
+                       if (!get_all &&
+                           g_hash_table_lookup(state->id_table, id) != NULL)
+                               state->msg[num].received = TRUE;
+                       else {
+                               if (new == FALSE) {
+                                       state->cur_msg = num;
+                                       new = TRUE;
+                               }
+                       }
+               }
        }
 
        if (new == TRUE)
@@ -338,7 +337,6 @@ gint pop3_getsize_list_recv(SockInfo *sock, gpointer data)
 
        if (pop3_ok(sock, NULL) != PS_SUCCESS) return POP3_LOGOUT_SEND;
 
-       state->sizes = g_new0(gint, state->count + 1);
        state->cur_total_bytes = 0;
 
        while (sock_gets(sock, buf, sizeof(buf)) >= 0) {
@@ -349,7 +347,7 @@ gint pop3_getsize_list_recv(SockInfo *sock, gpointer data)
                        return -1;
 
                if (num > 0 && num <= state->count)
-                       state->sizes[num] = size;
+                       state->msg[num].size = size;
                if (num > 0 && num < state->cur_msg)
                        state->cur_total_bytes += size;
        }
@@ -400,7 +398,7 @@ gint pop3_top_recv(SockInfo *sock, gpointer data)
           note: overwrites first line  --> this is dirty */
        if ( (fp = fopen(filename, "r+")) != NULL ) {
                gchar *buf = g_strdup_printf("%s%i", SIZE_HEADER, 
-                                            state->sizes[state->cur_msg]);
+                                            state->msg[state->cur_msg].size);
        
                if (change_file_mode_rw(fp, filename) == 0) 
                        fprintf(fp, "%s\n", buf);
@@ -446,19 +444,13 @@ gint pop3_retr_recv(SockInfo *sock, gpointer data)
                        return -1;
                }
 
-               state->cur_total_bytes += state->sizes[state->cur_msg];
+               state->cur_total_bytes += state->msg[state->cur_msg].size;
                state->cur_total_num++;
 
                if (drop_ok == 0 && state->ac_prefs->rmmail)
                        return POP3_DELETE_SEND;
 
-               if (state->new_id_list) {
-                       state->id_list = g_slist_append
-                               (state->id_list, state->new_id_list->data);
-                       state->new_id_list =
-                               g_slist_remove(state->new_id_list,
-                                              state->new_id_list->data);
-               }
+               state->msg[state->cur_msg].received = TRUE;
 
                if (state->cur_msg < state->count) {
                        state->cur_msg++;
@@ -489,7 +481,7 @@ gint pop3_delete_recv(SockInfo *sock, gpointer data)
        gint ok;
 
        if ((ok = pop3_ok(sock, NULL)) == PS_SUCCESS) {
-
+               state->msg[state->cur_msg].deleted = TRUE;
                if (pop3_delete_header(state) == TRUE) 
                        return POP3_DELETE_SEND;
 
index 0d8e93069803d7b4dd500f66f85963910c37cbe8..394f32a73e0ad965a7b747b325515873370a3c73 100644 (file)
--- a/src/pop.h
+++ b/src/pop.h
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 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
@@ -24,6 +24,8 @@
 
 #include "socket.h"
 
+typedef struct _Pop3MsgInfo    Pop3MsgInfo;
+
 typedef enum {
        POP3_GREETING_RECV,
        POP3_GETAUTH_USER_SEND,
@@ -52,7 +54,14 @@ typedef enum {
        N_POP3_PHASE
 } Pop3Phase;
 
-#define MAX_HEADER_LEN  5000
+struct _Pop3MsgInfo
+{
+       gint size;
+       gchar *uidl;
+       guint received : 1;
+       guint deleted  : 1;
+};
+
 #define POPBUFSIZE     512
 #define IDLEN          128