0.9.3claws68
[claws.git] / src / procmsg.c
index 48afc450f35d9368ba71cebfe8d02356ffb85c82..19cd8878329f2cd47b9584dca98504ca51e9a851 100644 (file)
@@ -382,6 +382,50 @@ gchar *procmsg_get_message_file(MsgInfo *msginfo)
        return filename;
 }
 
+GSList *procmsg_get_message_file_list(GSList *mlist)
+{
+        GSList *file_list = NULL;
+        MsgInfo *msginfo;
+        MsgFileInfo *fileinfo;
+        gchar *file;
+
+        while (mlist != NULL) {
+                msginfo = (MsgInfo *)mlist->data;
+                file = procmsg_get_message_file(msginfo);
+                if (!file) {
+                        procmsg_message_file_list_free(file_list);
+                        return NULL;
+                }
+                fileinfo = g_new(MsgFileInfo, 1);
+               fileinfo->msginfo = procmsg_msginfo_new_ref(msginfo);
+                fileinfo->file = file;
+                fileinfo->flags = g_new(MsgFlags, 1);
+                *fileinfo->flags = msginfo->flags;
+                file_list = g_slist_prepend(file_list, fileinfo);
+                mlist = mlist->next;
+        }
+
+        file_list = g_slist_reverse(file_list);
+
+        return file_list;
+}
+
+void procmsg_message_file_list_free(MsgInfoList *file_list)
+{
+       GSList *cur;
+       MsgFileInfo *fileinfo;
+
+       for (cur = file_list; cur != NULL; cur = cur->next) {
+               fileinfo = (MsgFileInfo *)cur->data;
+               procmsg_msginfo_free(fileinfo->msginfo);
+               g_free(fileinfo->file);
+               g_free(fileinfo->flags);
+               g_free(fileinfo);
+       }
+
+       g_slist_free(file_list);
+}
+
 FILE *procmsg_open_message(MsgInfo *msginfo)
 {
        FILE *fp;
@@ -705,14 +749,14 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                        return -1;
 
                folder_item_scan(outbox);
-               if ((num = folder_item_add_msg(outbox, tmp, TRUE)) < 0) {
+               if ((num = folder_item_add_msg(outbox, tmp, NULL, TRUE)) < 0) {
                        g_warning("can't save message\n");
                        unlink(tmp);
                        return -1;
                }
        } else {
                folder_item_scan(outbox);
-               if ((num = folder_item_add_msg(outbox, file, FALSE)) < 0) {
+               if ((num = folder_item_add_msg(outbox, file, NULL, FALSE)) < 0) {
                        g_warning("can't save message\n");
                        return -1;
                }
@@ -851,21 +895,11 @@ MsgInfo *procmsg_msginfo_copy(MsgInfo *msginfo)
 
 MsgInfo *procmsg_msginfo_get_full_info(MsgInfo *msginfo)
 {
-#if 0
        MsgInfo *full_msginfo;
        gchar *file;
-#endif
 
        if (msginfo == NULL) return NULL;
 
-       /* 
-        * In Claws we simply return a new reference to the same msginfo.
-        * otherwise the new msginfo has wrong flags and causes incorrect
-        * msgcounts... TODO: fill in data from full_msginfo into msginfo,
-        * we can then keep the new data in the cache
-         */
-       return procmsg_msginfo_new_ref(msginfo);
-#if 0
        file = procmsg_get_message_file(msginfo);
        if (!file) {
                g_warning("procmsg_msginfo_get_full_info(): can't get message file.\n");
@@ -876,6 +910,20 @@ MsgInfo *procmsg_msginfo_get_full_info(MsgInfo *msginfo)
        g_free(file);
        if (!full_msginfo) return NULL;
 
+       /* CLAWS: make sure we add the missing members; see: 
+        * procheader.c::procheader_get_headernames() */
+       if (!msginfo->xface)
+               msginfo->xface = g_strdup(full_msginfo->xface);
+       if (!msginfo->dispositionnotificationto)
+               msginfo->dispositionnotificationto = 
+                       g_strdup(full_msginfo->dispositionnotificationto);
+       if (!msginfo->returnreceiptto)
+               msginfo->returnreceiptto = g_strdup
+                       (full_msginfo->returnreceiptto);
+       procmsg_msginfo_free(full_msginfo);
+
+       return procmsg_msginfo_new_ref(msginfo);
+#if 0
        full_msginfo->msgnum = msginfo->msgnum;
        full_msginfo->size = msginfo->size;
        full_msginfo->mtime = msginfo->mtime;