2006-10-20 [colin] 2.5.6cvs3
authorColin Leroy <colin@colino.net>
Fri, 20 Oct 2006 16:51:50 +0000 (16:51 +0000)
committerColin Leroy <colin@colino.net>
Fri, 20 Oct 2006 16:51:50 +0000 (16:51 +0000)
* configure.ac
Bump up libetpan requirement
*** THIS COMMIT REQUIRES LIBETPAN CVS ***
* src/common/utils.c
* src/common/utils.h
Add convenience get_file_mtime()
* src/imap.c
* src/etpan/imap-thread.c
* src/etpan/imap-thread.h
Implement UIDPLUS support if the server
supports it - faster sending in this case

ChangeLog
PATCHSETS
configure.ac
src/common/utils.c
src/common/utils.h
src/etpan/imap-thread.c
src/etpan/imap-thread.h
src/imap.c

index fea6188eae1a10fd6bf3344165f5f55d5904708e..8a555bb4fe708d2eaad07cf034daaeda51bc1666 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-10-20 [colin]     2.5.6cvs3
+
+       * configure.ac
+               Bump up libetpan requirement
+               *** THIS COMMIT REQUIRES LIBETPAN CVS ***
+       * src/common/utils.c
+       * src/common/utils.h
+               Add convenience get_file_mtime()
+       * src/imap.c
+       * src/etpan/imap-thread.c
+       * src/etpan/imap-thread.h
+               Implement UIDPLUS support if the server
+               supports it - faster sending in this case
+
 2006-10-19 [colin]     2.5.6cvs2
 
        * src/gtk/quicksearch.c
index a6c5b05b801b2b4d1cdf201fc38828f7c956d7ef..279d7d9e9d0e2280ddc85880af23157df16a4845 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.48 -r 1.1.2.49 src/gtk/quicksearch.c;  ) > 2.5.5cvs17.patchset
 ( cvs diff -u -r 1.1.2.12 -r 1.1.2.13 manual/handling.xml;  ) > 2.5.5cvs18.patchset
 ( cvs diff -u -r 1.274.2.152 -r 1.274.2.153 src/mainwindow.c;  cvs diff -u -r 1.39.2.24 -r 1.39.2.25 src/mainwindow.h;  cvs diff -u -r 1.1.2.49 -r 1.1.2.50 src/gtk/quicksearch.c;  cvs diff -u -r 1.4.2.6 -r 1.4.2.7 src/plugins/trayicon/Makefile.am;  diff -u /dev/null src/plugins/trayicon/newmail.offline.xpm;  diff -u /dev/null src/plugins/trayicon/newmarkedmail.offline.xpm;  diff -u /dev/null src/plugins/trayicon/nomail.offline.xpm;  cvs diff -u -r 1.14.2.39 -r 1.14.2.40 src/plugins/trayicon/trayicon.c;  diff -u /dev/null src/plugins/trayicon/unreadmail.offline.xpm;  diff -u /dev/null src/plugins/trayicon/unreadmarkedmail.offline.xpm;  ) > 2.5.6cvs2.patchset
+( cvs diff -u -r 1.654.2.2059 -r 1.654.2.2060 configure.ac;  cvs diff -u -r 1.179.2.133 -r 1.179.2.134 src/imap.c;  cvs diff -u -r 1.36.2.85 -r 1.36.2.86 src/common/utils.c;  cvs diff -u -r 1.20.2.39 -r 1.20.2.40 src/common/utils.h;  cvs diff -u -r 1.1.4.52 -r 1.1.4.53 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.11 -r 1.1.4.12 src/etpan/imap-thread.h;  ) > 2.5.6cvs3.patchset
index ddca1935a1006a14b7972fabb2e7ed5f3118bf5f..c8ed5ec0f060b2d00d2ad036c268ce46bc32a3dc 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=2
+EXTRA_VERSION=3
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -792,18 +792,18 @@ if test x"$ac_cv_enable_libetpan" = xyes; then
           LIBETPAN_CPPFLAGS="`$libetpanconfig --cflags`"
           LIBETPAN_LIBS="`$libetpanconfig --libs`"
           LIBETPAN_VERSION=`$libetpanconfig --version | sed "s/\.//g" | sed "s/-.*$//"`
-          if test "$LIBETPAN_VERSION" -lt "046"; then
-               AC_MSG_RESULT([*** Sylpheed requires libetpan 0.46 or newer. See http://www.etpan.org/])
+          if test "$LIBETPAN_VERSION" -lt "047"; then
+               AC_MSG_RESULT([*** Sylpheed requires libetpan 0.47 or newer. See http://www.etpan.org/])
                AC_MSG_RESULT([*** You can use --disable-libetpan if you don't need IMAP4 support.])
-                AC_MSG_ERROR([libetpan 0.46 not found])
+                AC_MSG_ERROR([libetpan 0.47 not found])
           fi
           AC_SUBST(LIBETPAN_FLAGS)
           AC_SUBST(LIBETPAN_LIBS)
           AC_DEFINE(HAVE_LIBETPAN, 1, Define if you want IMAP support.)
        else
-          AC_MSG_RESULT([*** Sylpheed requires libetpan 0.46 or newer. See http://www.etpan.org/ ])
+          AC_MSG_RESULT([*** Sylpheed requires libetpan 0.47 or newer. See http://www.etpan.org/ ])
           AC_MSG_RESULT([*** You can use --disable-libetpan if you don't need IMAP4 support.])
-           AC_MSG_ERROR([libetpan 0.46 not found])
+           AC_MSG_ERROR([libetpan 0.47 not found])
        fi
 else
        AC_MSG_RESULT(no)
index c015fc6f26c7fda8644483ea8856e23712bc8e41..dcd0375036ca71b0862f4c55e663dc566eeac63f 100644 (file)
@@ -2048,6 +2048,18 @@ off_t get_file_size(const gchar *file)
        return s.st_size;
 }
 
+time_t get_file_mtime(const gchar *file)
+{
+       struct stat s;
+
+       if (g_stat(file, &s) < 0) {
+               FILE_OP_ERROR(file, "stat");
+               return -1;
+       }
+
+       return s.st_mtime;
+}
+
 off_t get_file_size_as_crlf(const gchar *file)
 {
        FILE *fp;
index 824c980f51eb0acae51459c8cff3739089f8083d..4d1f118aef4039fad09eae40b6e82e19966e20bd 100644 (file)
@@ -382,6 +382,8 @@ off_t get_file_size         (const gchar    *file);
 off_t get_file_size_as_crlf    (const gchar    *file);
 off_t get_left_file_size       (FILE           *fp);
 
+time_t get_file_mtime          (const gchar *file);
+
 gboolean file_exist            (const gchar    *file,
                                 gboolean        allow_fifo);
 gboolean is_relative_filename   (const gchar *file);
index c0f8081be204c22667fe8b2f07e3a47fc760677a..af55ecdc71ac89d1dda4bf8d779d441306d71a71 100644 (file)
@@ -2207,7 +2207,8 @@ static void append_run(struct etpan_thread_op * op)
        char * data;
        size_t size;
        struct stat stat_buf;
-       int fd, uid = 0;
+       int fd;
+       guint32 uid = 0, val = 0;
        
        param = op->param;
        result = op->result;
@@ -2234,9 +2235,9 @@ static void append_run(struct etpan_thread_op * op)
        
        mailstream_logger = imap_logger_append;
        
-       r = mailimap_append(param->imap, param->mailbox,
+       r = mailimap_uidplus_append(param->imap, param->mailbox,
                            param->flag_list, NULL,
-                           data, size/*, &uid */);
+                           data, size, &val, &uid);
 
        mailstream_logger = imap_logger_cmd;
        
@@ -2327,6 +2328,8 @@ struct copy_param {
 
 struct copy_result {
        int error;
+       struct mailimap_set *source;
+       struct mailimap_set *dest;
 };
 
 static void copy_run(struct etpan_thread_op * op)
@@ -2334,19 +2337,25 @@ static void copy_run(struct etpan_thread_op * op)
        struct copy_param * param;
        struct copy_result * result;
        int r;
-       
+       guint32 val;
        param = op->param;
+       struct mailimap_set *source = NULL, *dest = NULL;
        
-       r = mailimap_uid_copy(param->imap, param->set, param->mb);
+       r = mailimap_uidplus_uid_copy(param->imap, param->set, param->mb,
+               &val, &source, &dest);
        
        result = op->result;
        result->error = r;
-       
+
+       result->source = source;
+       result->dest = dest;
+
        debug_print("imap copy run - end %i\n", r);
 }
 
 int imap_threaded_copy(Folder * folder, struct mailimap_set * set,
-                      const char * mb)
+                      const char * mb, struct mailimap_set **source,
+                      struct mailimap_set **dest)
 {
        struct copy_param param;
        struct copy_result result;
@@ -2360,10 +2369,15 @@ int imap_threaded_copy(Folder * folder, struct mailimap_set * set,
        param.mb = mb;
        
        threaded_run(folder, &param, &result, copy_run);
+       *source = NULL;
+       *dest = NULL;
        
        if (result.error != MAILIMAP_NO_ERROR)
                return result.error;
        
+       *source = result.source;
+       *dest = result.dest;
+
        debug_print("imap copy - end\n");
        
        return result.error;
index ee59d62a0858c12409ba95070312b2eb1b0de7bd..d16c0ca4761bc3c3c61ba44f0541dee5431fd871 100644 (file)
@@ -86,7 +86,8 @@ int imap_threaded_append(Folder * folder, const char * mailbox,
 int imap_threaded_expunge(Folder * folder);
 
 int imap_threaded_copy(Folder * folder, struct mailimap_set * set,
-                      const char * mb);
+                      const char * mb, struct mailimap_set **source,
+                      struct mailimap_set **dest);
 
 int imap_threaded_store(Folder * folder, struct mailimap_set * set,
                        struct mailimap_store_att_flags * store_att_flags);
index 0efe2e799d5b6efba70a4fd364d8be24a73f7a42..ecfeead3e7f3a9b4fcf28c060b9abaa510ccfebe 100644 (file)
@@ -346,7 +346,9 @@ static gint imap_cmd_append (IMAPSession    *session,
 static gint imap_cmd_copy       (IMAPSession *session,
                                 struct mailimap_set * set,
                                 const gchar *destfolder,
-                                GRelation *uid_mapping);
+                                GRelation *uid_mapping,
+                                struct mailimap_set ** source,
+                                struct mailimap_set ** dest);
 static gint imap_cmd_store     (IMAPSession    *session,
                                 struct mailimap_set * set,
                                 IMAPFlags flags,
@@ -987,8 +989,8 @@ static gchar *imap_fetch_msg_full(Folder *folder, FolderItem *item, gint uid,
                        procmsg_msginfo_free(msginfo);
                        file_strip_crs(filename);
                        return filename;
-               } else if (!cached) {
-                       debug_print("message not cached, considering file complete\n");
+               } else if (!cached && time(NULL) - get_file_mtime(filename) < 60) {
+                       debug_print("message not cached and file recent, considering file complete\n");
                        procmsg_msginfo_free(msginfo);
                        file_strip_crs(filename);
                        return filename;
@@ -1169,6 +1171,7 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
        gint ok = IMAP_SUCCESS;
        GRelation *uid_mapping;
        gint last_num = 0;
+       gboolean single = FALSE;
 
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(dest != NULL, -1);
@@ -1181,7 +1184,8 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
        }
        lock_session();
        msginfo = (MsgInfo *)msglist->data;
-
+       if (msglist->next == NULL)
+               single = TRUE;
        src = msginfo->folder;
        if (src == dest) {
                g_warning("the src folder is identical to the dest.\n");
@@ -1225,12 +1229,36 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
        statusbar_print_all(_("Copying messages..."));
        for (cur = seq_list; cur != NULL; cur = g_slist_next(cur)) {
                struct mailimap_set * seq_set;
+               struct mailimap_set * source;
+               struct mailimap_set * dest;
                seq_set = cur->data;
 
                debug_print("Copying messages from %s to %s ...\n",
                            src->path, destdir);
 
-               ok = imap_cmd_copy(session, seq_set, destdir, uid_mapping);
+               ok = imap_cmd_copy(session, seq_set, destdir, uid_mapping,
+                       &source, &dest);
+               
+               if (ok == IMAP_SUCCESS) {
+                       if (single && relation && source && dest) {
+                               clistiter *l = clist_begin(source->set_list);
+                               struct mailimap_set_item *i = (struct mailimap_set_item *)clist_content(l);
+                               int snum = i->set_first;
+                               int dnum = 0;
+                               l = clist_begin(dest->set_list);
+                               i = (struct mailimap_set_item *)clist_content(l);
+                               dnum = i->set_first;
+                               g_relation_insert(uid_mapping, GINT_TO_POINTER(snum), 
+                                       GINT_TO_POINTER(dnum));
+                       }
+               }
+
+
+               if (source)
+                       mailimap_set_free(source);
+               if (dest)
+                       mailimap_set_free(dest);
+
                if (ok != IMAP_SUCCESS) {
                        g_relation_destroy(uid_mapping);
                        imap_lep_set_free(seq_list);
@@ -1252,6 +1280,30 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
                                          GPOINTER_TO_INT(num));
                        if (num > last_num)
                                last_num = num;
+                       debug_print("copied new message as %d\n", num);
+                       /* put the local file in the imapcache, so that we don't
+                        * have to fetch it back later. */
+                       if (num > 0) {
+                               gchar *cache_path = folder_item_get_path(msginfo->folder);
+                               gchar *real_file = g_strconcat(
+                                       cache_path, G_DIR_SEPARATOR_S, 
+                                       itos(msginfo->msgnum), NULL);
+                               gchar *cache_file = NULL;
+                               g_free(cache_path);
+                               cache_path = folder_item_get_path(dest);
+                               cache_file = g_strconcat(
+                                       cache_path, G_DIR_SEPARATOR_S, 
+                                       itos(num), NULL);
+                               if (!is_dir_exist(cache_path))
+                                       make_dir_hier(cache_path);
+                               if (is_file_exist(real_file) && is_dir_exist(cache_path)) {
+                                       copy_file(real_file, cache_file, TRUE);
+                                       debug_print("copied to cache: %s\n", cache_file);
+                               }
+                               g_free(real_file);
+                               g_free(cache_file);
+                               g_free(cache_path);
+                       }
                } else
                        g_relation_insert(relation, msginfo,
                                          GPOINTER_TO_INT(0));
@@ -2719,7 +2771,8 @@ static gint imap_cmd_append(IMAPSession *session, const gchar *destfolder,
 }
 
 static gint imap_cmd_copy(IMAPSession *session, struct mailimap_set * set,
-                         const gchar *destfolder, GRelation *uid_mapping)
+                         const gchar *destfolder, GRelation *uid_mapping,
+                         struct mailimap_set **source, struct mailimap_set **dest)
 {
        int r;
        
@@ -2727,7 +2780,7 @@ static gint imap_cmd_copy(IMAPSession *session, struct mailimap_set * set,
        g_return_val_if_fail(set != NULL, IMAP_ERROR);
        g_return_val_if_fail(destfolder != NULL, IMAP_ERROR);
 
-       r = imap_threaded_copy(session->folder, set, destfolder);
+       r = imap_threaded_copy(session->folder, set, destfolder, source, dest);
        if (r != MAILIMAP_NO_ERROR) {
                
                return IMAP_ERROR;