2007-08-07 [colin] 2.10.0cvs98
authorColin Leroy <colin@colino.net>
Tue, 7 Aug 2007 18:37:51 +0000 (18:37 +0000)
committerColin Leroy <colin@colino.net>
Tue, 7 Aug 2007 18:37:51 +0000 (18:37 +0000)
* src/imap.c
fix bug 1275, 'auto-saved draft messages not
always being removed'
* src/messageview.c
Don't try to reshow deleted mail
* src/msgcache.c
Fix leak on error path

ChangeLog
PATCHSETS
configure.ac
src/imap.c
src/messageview.c
src/msgcache.c

index aee5cf3a0052eaf284b2ab25a651cb2e708511b6..180e9d4b79ff7ce110a16d442faaa4d060333c07 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-08-07 [colin]     2.10.0cvs98
+
+       * src/imap.c
+               fix bug 1275, 'auto-saved draft messages not 
+               always being removed'
+       * src/messageview.c
+               Don't try to reshow deleted mail
+       * src/msgcache.c
+               Fix leak on error path
+
 2007-08-07 [wwp]       2.10.0cvs97
 
        * manual/account.xml
index 3c2778124fd5e46c9f06d0d19617dd2054890a34..cc946cc6167e87d19221fe5511888b86bc53f6ac 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.399 -r 1.382.2.400 src/compose.c;  cvs diff -u -r 1.50.2.40 -r 1.50.2.41 src/compose.h;  ) > 2.10.0cvs95.patchset
 ( cvs diff -u -r 1.204.2.144 -r 1.204.2.145 src/prefs_common.c;  cvs diff -u -r 1.103.2.90 -r 1.103.2.91 src/prefs_common.h;  cvs diff -u -r 1.96.2.180 -r 1.96.2.181 src/textview.c;  ) > 2.10.0cvs96.patchset
 ( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 manual/account.xml;  cvs diff -u -r 1.1.2.39 -r 1.1.2.40 manual/advanced.xml;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 manual/fr/account.xml;  cvs diff -u -r 1.1.2.15 -r 1.1.2.16 manual/fr/advanced.xml;  ) > 2.10.0cvs97.patchset
+( cvs diff -u -r 1.179.2.177 -r 1.179.2.178 src/imap.c;  cvs diff -u -r 1.94.2.143 -r 1.94.2.144 src/messageview.c;  cvs diff -u -r 1.16.2.53 -r 1.16.2.54 src/msgcache.c;  ) > 2.10.0cvs98.patchset
index 1e921c94f8e6355846da59de349a3a0afb8640c3..724a8a44cfe5c5a48f958850d63cb642f3ced1db 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=10
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=97
+EXTRA_VERSION=98
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8ac260084e1025a4eb8e7bf1233cdd933acd6ac5..ae40420c2f9610d5affc37c7457b5cced6c58d62 100644 (file)
@@ -1175,6 +1175,30 @@ static gint imap_add_msg(Folder *folder, FolderItem *dest,
        return ret;
 }
 
+static gint imap_get_msg_from_local(Folder *folder, FolderItem *dest, const gchar *real_file)
+{
+       /* don't get session, already done. */
+       MsgInfo *msginfo, *r_msginfo;
+       MsgFlags flags = {0, 0};
+       gint msgnum = 0;
+       msginfo = procheader_parse_file(real_file, flags, FALSE, FALSE);
+       unlock_session(IMAP_SESSION(REMOTE_FOLDER(folder)->session));
+       folder_item_scan_full(dest, FALSE);
+       lock_session(IMAP_SESSION(REMOTE_FOLDER(folder)->session));
+       if (msginfo && msginfo->msgid) {
+               r_msginfo = folder_item_get_msginfo_by_msgid(dest, msginfo->msgid);
+               if (r_msginfo) {
+                       msgnum = r_msginfo->msgnum;
+                       debug_print("get msgnum from msgid %s: %d\n", msginfo->msgid, msgnum);
+                       procmsg_msginfo_free(r_msginfo);
+               } else {
+                       debug_print("no msgnum\n");
+               }
+       }
+       procmsg_msginfo_free(msginfo);
+       return msgnum;
+}
+
 static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
                   GRelation *relation)
 {
@@ -1186,7 +1210,6 @@ static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
        gint ok;
        gint curnum = 0, total = 0;
 
-
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(file_list != NULL, -1);
@@ -1242,6 +1265,10 @@ static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
                        debug_print("appended new message as %d\n", new_uid);
                        /* put the local file in the imapcache, so that we don't
                         * have to fetch it back later. */
+                       if (new_uid == 0 && !(cur->next)) {
+                               debug_print("didn't get uid, last in list: scanning\n");
+                               new_uid = imap_get_msg_from_local(folder, dest, real_file);
+                       }
                        if (new_uid > 0) {
                                gchar *cache_path = folder_item_get_path(dest);
                                if (!is_dir_exist(cache_path))
@@ -1261,10 +1288,7 @@ static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
                if (relation != NULL)
                        g_relation_insert(relation, fileinfo->msginfo != NULL ? 
                                          (gpointer) fileinfo->msginfo : (gpointer) fileinfo,
-                                         GINT_TO_POINTER(dest->last_num + 1));
-               if (new_uid == 0) {
-                       new_uid = dest->last_num+1;
-               }
+                                         GINT_TO_POINTER(new_uid));
                if (last_uid < new_uid) {
                        last_uid = new_uid;
                }
@@ -1274,7 +1298,6 @@ static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
        statusbar_progress_all(0,0,0);
        statusbar_pop_all();
        
-       imap_cmd_expunge(session);
        unlock_session(session);
        
        g_free(destdir);
@@ -1282,6 +1305,32 @@ static gint imap_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
        return last_uid;
 }
 
+static GSList *flatten_mailimap_set(struct mailimap_set * set) 
+{
+       GSList *result = NULL;
+       clistiter *list;
+       int start, end, t;
+       GSList *cur;
+
+       for (list = clist_begin(set->set_list); list; list = clist_next(list)) {
+               struct mailimap_set_item *item = (struct mailimap_set_item *)clist_content(list);
+               start = item->set_first;
+               end = item->set_last;
+               for (t = start; t <= end; t++) {
+                       result = g_slist_prepend(result, GINT_TO_POINTER(t));
+               }
+       }
+       result = g_slist_reverse(result);
+       if (debug_get_mode()) {
+               debug_print("flat imap set: ");
+               for (cur = result; cur; cur = cur->next) {
+                       debug_print("%d ", GPOINTER_TO_INT(cur->data));
+               }
+               debug_print("\n");
+       }
+       
+       return result;
+}
 static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest, 
                              MsgInfoList *msglist, GRelation *relation)
 {
@@ -1364,16 +1413,23 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
                        &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 (relation && source && dest) {
+                               GSList *s_list = flatten_mailimap_set(source);
+                               GSList *d_list = flatten_mailimap_set(dest);
+                               GSList *s_cur, *d_cur;
+                               if (g_slist_length(s_list) == g_slist_length(d_list)) {
+
+                                       for (s_cur = s_list, d_cur = d_list; 
+                                            s_cur && d_cur; 
+                                            s_cur = s_cur->next, d_cur = d_cur->next) {
+                                               g_relation_insert(uid_mapping, s_cur->data, d_cur->data);
+                                       }
+
+                               } else {
+                                       debug_print("hhhmm, source list length != dest list length.\n");
+                               }
+                               g_slist_free(s_list);
+                               g_slist_free(d_list);
                        }
                }
 
@@ -1405,7 +1461,7 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
                                          GINT_TO_POINTER(num));
                        if (num > last_num)
                                last_num = num;
-                       debug_print("copied new message as %d\n", num);
+                       debug_print("copied message %d as %d\n", msginfo->msgnum, num);
                        /* put the local file in the imapcache, so that we don't
                         * have to fetch it back later. */
                        if (num > 0) {
@@ -3678,8 +3734,9 @@ GSList *imap_get_msginfos(Folder *folder, FolderItem *item,
                                int i;
                                for (i = startnum; i <= lastnum; ++i) {
                                        gchar *file;
-                       
+                                       unlock_session(session);
                                        file = imap_fetch_msg(folder, item, i);
+                                       lock_session(session);
                                        if (file != NULL) {
                                                MsgInfo *msginfo = imap_parse_msg(file, item);
                                                if (msginfo != NULL) {
index 2ad85b02426ed2f7cb2cb5d5b79b43f54cbf3c70..e11fdd6c5ce020ba340b0fcb1b87befc6c1cba8a 100644 (file)
@@ -153,7 +153,8 @@ static void open_urls_cb            (gpointer        data,
 static void about_cb                   (gpointer        data,
                                         guint           action,
                                         GtkWidget      *widget);
-static void messageview_update         (MessageView *msgview);
+static void messageview_update         (MessageView    *msgview,
+                                        MsgInfo        *old_msginfo);
 static gboolean messageview_update_msg (gpointer source, gpointer data);
 
 static GList *msgview_list = NULL;
@@ -1051,7 +1052,7 @@ void messageview_delete(MessageView *msgview)
  *        leave unchanged if summaryview is empty
  * \param pointer to MessageView
  */    
-static void messageview_update(MessageView *msgview)
+static void messageview_update(MessageView *msgview, MsgInfo *old_msginfo)
 {
        SummaryView *summaryview = (SummaryView*)msgview->mainwin->summaryview;
 
@@ -1059,7 +1060,7 @@ static void messageview_update(MessageView *msgview)
        
        if (summaryview->selected) {
                MsgInfo *msginfo = summary_get_selected_msg(summaryview);
-               if (msginfo == NULL)
+               if (msginfo == NULL || msginfo == old_msginfo)
                        return;
 
                messageview_show(msgview, msginfo, 
@@ -1807,8 +1808,9 @@ static gboolean messageview_update_msg(gpointer source, gpointer data)
                return FALSE;
 
        if (msginfo_update->flags & MSGINFO_UPDATE_DELETED) {
+               MsgInfo *old_msginfo = messageview->msginfo;
                messageview_clear(messageview);
-               messageview_update(messageview);
+               messageview_update(messageview, old_msginfo);
        }
 
        return FALSE;
index 493bd4170253d50dc6f876f9bcdd0ff86c519b35..4ab562ce6cf31f066d2713b2576945edb48827cf 100644 (file)
@@ -1175,6 +1175,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
        if (write_fps.cache_fp == NULL) {
                g_free(new_cache);
                g_free(new_mark);
+               g_free(new_tags);
                return -1;
        }