2005-06-12 [colin] 1.9.11cvs61
authorColin Leroy <colin@colino.net>
Sun, 12 Jun 2005 18:59:21 +0000 (18:59 +0000)
committerColin Leroy <colin@colino.net>
Sun, 12 Jun 2005 18:59:21 +0000 (18:59 +0000)
* src/folder.c
* src/folder.h
Add a remove_msgs function to remove a
list of messages
* src/imap.c
Implement that.

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/imap.c

index 2f8c4573b6ea9b2cbe245a9085d0e1c9c2f91cad..2e144c68ecd9fd344b270bbd1ef5d17f49b8a106 100644 (file)
@@ -1,3 +1,12 @@
+2005-06-12 [colin]     1.9.11cvs61
+
+       * src/folder.c
+       * src/folder.h
+               Add a remove_msgs function to remove a 
+               list of messages
+       * src/imap.c
+               Implement that.
+
 2005-06-12 [colin]     1.9.11cvs60
 
        * src/imap.c
index 3c8a2564dcd4d2df10c6a1037ee2b729ce8137c1..bbea1109cad8bdd99ad7aac54d09da81e61b16db 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.25 -r 1.179.2.26 src/imap.c;  ) > 1.9.11cvs58.patchset
 ( cvs diff -u -r 1.179.2.26 -r 1.179.2.27 src/imap.c;  ) > 1.9.11cvs59.patchset
 ( cvs diff -u -r 1.179.2.27 -r 1.179.2.28 src/imap.c;  ) > 1.9.11cvs60.patchset
+( cvs diff -u -r 1.213.2.29 -r 1.213.2.30 src/folder.c;  cvs diff -u -r 1.87.2.10 -r 1.87.2.11 src/folder.h;  cvs diff -u -r 1.179.2.28 -r 1.179.2.29 src/imap.c;  ) > 1.9.11cvs61.patchset
index 5c8695d55a03e8a814c13d6d7c6a9863e531b641..e073af9fa04f4c0e2252a7ac9d7412b2cb442963 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=60
+EXTRA_VERSION=61
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 16357e922a4804bf303f47f54815b5f3c40a884d..20249f9836ab11317124a642cc713420190aea7f 100644 (file)
@@ -2666,14 +2666,22 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
        }
 
        if (remove_source) {
+               MsgInfo *msginfo = (MsgInfo *) msglist->data;
+               FolderItem *item = msginfo->folder;
                /*
                 * Remove source messages from their folders if
                 * copying was successfull and update folder
                 * message counts
                 */
+               if (item->folder->klass->remove_msgs) {
+                       item->folder->klass->remove_msgs(item->folder,
+                                                               msginfo->folder,
+                                                               msglist,
+                                                               relation);
+               }
                for (l = msglist; l != NULL; l = g_slist_next(l)) {
-                       MsgInfo *msginfo = (MsgInfo *) l->data;
-                       FolderItem *item = msginfo->folder;
+                       msginfo = (MsgInfo *) l->data;
+                       item = msginfo->folder;
                        GTuples *tuples;
 
                        tuples = g_relation_select(relation, msginfo, 0);
@@ -2681,7 +2689,8 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                        g_tuples_destroy(tuples);
 
                        if ((num >= 0) && (item->folder->klass->remove_msg != NULL)) {
-                               item->folder->klass->remove_msg(item->folder,
+                               if (!item->folder->klass->remove_msgs)
+                                       item->folder->klass->remove_msg(item->folder,
                                                                msginfo->folder,
                                                                msginfo->msgnum);
                                remove_msginfo_from_cache(item, msginfo);
index 0ce56304640bedbeea35a0cf1d0c1efeb21a27b7..dcbe47c24ff7116973e63ed772e9a49248246913 100644 (file)
@@ -503,6 +503,10 @@ struct _FolderClass
        gint            (*remove_msg)           (Folder         *folder,
                                                 FolderItem     *item,
                                                 gint            num);
+       gint            (*remove_msgs)          (Folder         *folder,
+                                                FolderItem     *item,
+                                                MsgInfoList    *msglist,
+                                                GRelation      *relation);
        /**
         * Remove all messages in a \ c FolderItem
         *
index 39f12f35cc7b660c8206d9946abcd19eae2b72bc..9b3c9f66ddeaae60c59c47545ad1b6e8d1595f8e 100644 (file)
@@ -204,6 +204,10 @@ static gint        imap_copy_msgs          (Folder         *folder,
 static gint    imap_remove_msg         (Folder         *folder, 
                                         FolderItem     *item, 
                                         gint            uid);
+static gint    imap_remove_msgs        (Folder         *folder, 
+                                        FolderItem     *dest, 
+                                        MsgInfoList    *msglist, 
+                                        GRelation      *relation);
 static gint    imap_remove_all_msg     (Folder         *folder, 
                                         FolderItem     *item);
 
@@ -563,6 +567,7 @@ FolderClass *imap_get_class(void)
                imap_class.copy_msg = imap_copy_msg;
                imap_class.copy_msgs = imap_copy_msgs;
                imap_class.remove_msg = imap_remove_msg;
+               imap_class.remove_msgs = imap_remove_msgs;
                imap_class.remove_all_msg = imap_remove_all_msg;
                imap_class.is_msg_changed = imap_is_msg_changed;
                imap_class.change_flags = imap_change_flags;
@@ -1183,6 +1188,80 @@ static gint imap_copy_msgs(Folder *folder, FolderItem *dest,
        return ret;
 }
 
+static gint imap_do_remove_msgs(Folder *folder, FolderItem *dest, 
+                               MsgInfoList *msglist, GRelation *relation)
+{
+       gchar *destdir;
+       GSList *seq_list = NULL, *cur;
+       MsgInfo *msginfo;
+       IMAPSession *session;
+       gint ok = IMAP_SUCCESS;
+       GRelation *uid_mapping;
+       
+       g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(dest != NULL, -1);
+       g_return_val_if_fail(msglist != NULL, -1);
+
+       session = imap_session_get(folder);
+       if (!session) {
+               return -1;
+       }
+       msginfo = (MsgInfo *)msglist->data;
+
+       ok = imap_select(session, IMAP_FOLDER(folder), msginfo->folder->path,
+                        NULL, NULL, NULL, NULL, FALSE);
+       if (ok != IMAP_SUCCESS) {
+               return ok;
+       }
+
+       destdir = imap_get_real_path(IMAP_FOLDER(folder), dest->path);
+       for (cur = msglist; cur; cur = cur->next) {
+               msginfo = (MsgInfo *)cur->data;
+               seq_list = g_slist_append(seq_list, GINT_TO_POINTER(msginfo->msgnum));
+       }
+
+       uid_mapping = g_relation_new(2);
+       g_relation_index(uid_mapping, 0, g_direct_hash, g_direct_equal);
+
+       ok = imap_set_message_flags
+               (IMAP_SESSION(REMOTE_FOLDER(folder)->session),
+               seq_list, IMAP_FLAG_DELETED, TRUE);
+       if (ok != IMAP_SUCCESS) {
+               log_warning(_("can't set deleted flags\n"));
+               return ok;
+       }
+       ok = imap_cmd_expunge(session, NULL);
+       if (ok != IMAP_SUCCESS) {
+               log_warning(_("can't expunge\n"));
+               return ok;
+       }
+       
+       g_relation_destroy(uid_mapping);
+       g_list_free(seq_list);
+
+       g_free(destdir);
+
+       if (ok == IMAP_SUCCESS)
+               return 0;
+       else
+               return -1;
+}
+
+static gint imap_remove_msgs(Folder *folder, FolderItem *dest, 
+                   MsgInfoList *msglist, GRelation *relation)
+{
+       MsgInfo *msginfo;
+printf("removing %d messages\n", g_slist_length(msglist));
+       g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(dest != NULL, -1);
+       g_return_val_if_fail(msglist != NULL, -1);
+
+       msginfo = (MsgInfo *)msglist->data;
+       g_return_val_if_fail(msginfo->folder != NULL, -1);
+
+       return imap_do_remove_msgs(folder, dest, msglist, relation);
+}
+
 static gint imap_remove_all_msg(Folder *folder, FolderItem *item)
 {
        gint ok;
@@ -2436,7 +2515,7 @@ static gchar *imap_get_header(SockInfo *sock, gchar *cur_pos, gchar **headers,
                g_free(nextline);
        } while (block_len < len);
 
-       debug_print("IMAP4< [contents of RFC822.HEADER]\n");
+       debug_print("IMAP4< [contents of BODY.PEEK[HEADER_FIELDS (...)]\n");
 
        *headers = g_strndup(cur_pos, len);
        cur_pos += len;
@@ -2545,10 +2624,23 @@ static MsgInfo *imap_parse_envelope(SockInfo *sock, FolderItem *item,
                } else if (!strncmp(cur_pos, "RFC822.SIZE ", 12)) {
                        cur_pos += 12;
                        size = strtol(cur_pos, &cur_pos, 10);
-               } else if (!strncmp(cur_pos, "RFC822.HEADER ", 14)) {
+               } else if (!strncmp(cur_pos, "BODY[HEADER.FIELDS ", 19)) {
                        gchar *headers;
 
-                       cur_pos += 14;
+                       cur_pos += 19;
+                       if (*cur_pos != '(') {
+                               g_warning("*cur_pos != '('\n");
+                               procmsg_msginfo_free(msginfo);
+                               return NULL;
+                       }
+                       cur_pos++;
+                       PARSE_ONE_ELEMENT(')');
+                       if (*cur_pos != ']') {
+                               g_warning("*cur_pos != ']'\n");
+                               procmsg_msginfo_free(msginfo);
+                               return NULL;
+                       }
+                       cur_pos++;
                        cur_pos = imap_get_header(sock, cur_pos, &headers,
                                                  line_str);
                        msginfo = procheader_parse_str(headers, flags, FALSE, FALSE);
@@ -3387,9 +3479,12 @@ static gint imap_cmd_copy(IMAPSession *session, const gchar *seq_set,
 
 gint imap_cmd_envelope(IMAPSession *session, IMAPSet set)
 {
+       static gchar *header_fields = 
+               "Date From To Cc Subject Message-ID References In-Reply-To" ;
+
        imap_gen_send
-               (session, "UID FETCH %s (UID FLAGS RFC822.SIZE RFC822.HEADER)",
-                set);
+               (session, "UID FETCH %s (UID FLAGS RFC822.SIZE BODY.PEEK[HEADER.FIELDS (%s)])",
+                set, header_fields);
 
        return IMAP_SUCCESS;
 }