sync with Hiroyuki's 0.5.0cvs5; back up claws to 0.5.0claws5
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Tue, 17 Jul 2001 20:05:22 +0000 (20:05 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Tue, 17 Jul 2001 20:05:22 +0000 (20:05 +0000)
20 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/compose.c
src/filtering.c
src/folder.c
src/imap.c
src/inc.c
src/mbox_folder.c
src/mbox_folder.h
src/messageview.c
src/mh.c
src/news.c
src/procheader.c
src/procmsg.c
src/procmsg.h
src/summaryview.c
src/utils.c
src/utils.h

index 56217a3..930e01c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2001-07-17
+
+       * src/procmsg.[ch]: separated the permanent flags and temporary
+         flags into two variables, and made MsgFlags a structure that
+         includes them.
+         MSG_SET_PERM_FLAGS()
+         MSG_SET_TMP_FLAGS()
+         MSG_UNSET_PERM_FLAGS()
+         MSG_UNSET_TMP_FLAGS(): new macros.
+       * src/compose.c
+         src/imap.c
+         src/inc.c
+         src/messageview.c
+         src/mh.c
+         src/news.c
+         src/procheader.c
+         src/summaryview.c: modified for the new MsgFlags.
+       * src/utils.[ch]: hash_free_value_mem(): new. It frees the values
+         of hash table.
+
 2001-07-16
 
        * src/inc.c: inc_pop3_recv_func(), inc_progress_update():
index f5928b7..0760a18 100644 (file)
@@ -1,3 +1,22 @@
+2001-07-17 [alfons]
+
+       0.5.0claws5
+
+       * sync with Hiroyuki's 0.5.0cvs5; this version allows us to put more 
+         bits in the mark file, without affecting either branch. Lots of
+         files changed, also in claws branch.
+
+         UNTESTED: use of mbox folders
+
+       * src/summaryview.c
+               added mark all read; however this was a quick hack used for
+               cleaning up mess after initial merge with Hiroyuki
+
+       * configure.in
+               change claws version number back to 0.5.0claws5 to clear up 
+               confusion & pretension (recent release was technically 
+               0.5.0claws4, so we neatly align with Hiroyuki :-)
+
 2001-07-16 [alfons]
 
        sync with Hiroyuki's 0.5.0cvs4
index ae1cb58..8a6cf8f 100644 (file)
@@ -1,3 +1,22 @@
+2001-07-17
+
+       * src/procmsg.[ch]: ±Ê³¥Õ¥é¥°¤È°ì»þ¥Õ¥é¥°¤ò2¤Ä¤ÎÊÑ¿ô¤ËʬΥ¤·¡¢
+         MsgFlags ¤ò¤½¤ì¤é¤ò´Þ¤à¹½Â¤ÂΤˤ·¤¿¡£
+         MSG_SET_PERM_FLAGS()
+         MSG_SET_TMP_FLAGS()
+         MSG_UNSET_PERM_FLAGS()
+         MSG_UNSET_TMP_FLAGS(): ¿·µ¬¥Þ¥¯¥í¡£
+       * src/compose.c
+         src/imap.c
+         src/inc.c
+         src/messageview.c
+         src/mh.c
+         src/news.c
+         src/procheader.c
+         src/summaryview.c: ¿·¤·¤¤ MsgFlags ¤Î¤¿¤á¤ËÊѹ¹¡£
+       * src/utils.[ch]: hash_free_value_mem(): ¿·µ¬¡£¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤Î
+         Ãͤò²òÊü¤¹¤ë¡£
+
 2001-07-16
 
        * src/inc.c: inc_pop3_recv_func(), inc_progress_update():
index e2801f3..bcb460a 100644 (file)
@@ -5,10 +5,10 @@ PACKAGE=sylpheed
 dnl version number
 MAJOR_VERSION=0
 MINOR_VERSION=5
-MICRO_VERSION=1
+MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws3
+EXTRA_VERSION=claws5
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 4342849..edd6164 100644 (file)
@@ -572,9 +572,8 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                        return;
        } else
                reply_account = account;
-
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_FORWARDED);
-       MSG_SET_FLAGS(msginfo->flags, MSG_REPLIED);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
+       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
 
        CHANGE_FLAGS(msginfo);
 
@@ -715,7 +714,7 @@ static void compose_attach_parts(Compose * compose,
 
                if (!MSG_IS_ENCRYPTED(msginfo->flags) &&
                    rfc2015_is_encrypted(mimeinfo)) {
-                       MSG_SET_FLAGS(msginfo->flags, MSG_ENCRYPTED);
+                       MSG_SET_TMP_FLAGS(msginfo->flags, MSG_ENCRYPTED);
                }
                if (MSG_IS_ENCRYPTED(msginfo->flags) &&
                    !msginfo->plaintext_file  &&
@@ -881,9 +880,8 @@ Compose * compose_forward(PrefsAccount * account, MsgInfo *msginfo,
        }
        g_return_val_if_fail(account != NULL, NULL);
 
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_REPLIED);
-       MSG_SET_FLAGS(msginfo->flags, MSG_FORWARDED);
-
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
+       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
        CHANGE_FLAGS(msginfo);
 
        compose = compose_create(account);
@@ -1936,6 +1934,8 @@ gint compose_send(Compose *compose)
                        ac = compose->account;
                else if (compose->orig_account->protocol != A_NNTP)
                        ac = compose->orig_account;
+               else if (cur_account && cur_account->protocol != A_NNTP)
+                       ac = cur_account;
                else {
                        ac = compose_current_mail_account();
                        if (!ac) {
@@ -2191,7 +2191,8 @@ static gint compose_save_to_outbox(Compose *compose, const gchar *file)
                MsgInfo newmsginfo;
 
                newmsginfo.msgnum = num;
-               newmsginfo.flags = 0;
+               newmsginfo.flags.perm_flags = 0;
+               newmsginfo.flags.tmp_flags = 0;
                procmsg_write_flags(&newmsginfo, fp);
                fclose(fp);
        }
@@ -2301,7 +2302,8 @@ static gint compose_queue(Compose *compose, const gchar *file)
                MsgInfo newmsginfo;
 
                newmsginfo.msgnum = num;
-               newmsginfo.flags = 0;
+               newmsginfo.flags.perm_flags = 0;
+               newmsginfo.flags.tmp_flags = 0;
                procmsg_write_flags(&newmsginfo, fp);
                fclose(fp);
        }
@@ -2404,7 +2406,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                get_rfc822_date(buf, sizeof(buf));
                fprintf(fp, "Date: %s\n", buf);
        }
-       
+
        /* From */
        if (!IS_IN_CUSTOM_HEADER("From")) {
                if (compose->account->name && *compose->account->name) {
@@ -2439,7 +2441,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                        }
                }
        }
-       
+
        slist_free_strings(compose->newsgroup_list);
        g_slist_free(compose->newsgroup_list);
        compose->newsgroup_list = NULL;
@@ -2483,7 +2485,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                        }
                }
        }
-       
+
        /* Bcc */
        if (compose->use_bcc) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
@@ -2613,7 +2615,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                                fprintf(fp, "%s: %s\n", chdr->name, buf);
                }
        }
-       
+
        /* MIME */
        fprintf(fp, "Mime-Version: 1.0\n");
        if (compose->use_attach) {
@@ -2997,7 +2999,7 @@ static Compose *compose_create(PrefsAccount *account)
 
        style = gtk_widget_get_style(text);
 
-       /* workaround for the slow down of GtkSText when using Pixmap theme */
+       /* workaround for the slow down of GtkText when using Pixmap theme */
        if (style->engine) {
                GtkThemeEngine *engine;
 
index 9f6ea62..9113f03 100644 (file)
@@ -420,7 +420,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                info->flags = 0;
                filteringaction_update_mark(info);
                 */
-               
                if (folder_table) {
                        val = GPOINTER_TO_INT(g_hash_table_lookup
                                              (folder_table, dest_folder));
@@ -437,7 +436,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                                                    GINT_TO_POINTER(1));
                        }
                }
-
                return TRUE;
 
        case MATCHING_ACTION_COPY:
@@ -480,7 +478,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return TRUE;
 
        case MATCHING_ACTION_MARK:
-               MSG_SET_FLAGS(info->flags, MSG_MARKED);
+               MSG_SET_PERM_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
                CHANGE_FLAGS(info);
@@ -488,7 +486,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return TRUE;
 
        case MATCHING_ACTION_UNMARK:
-               MSG_UNSET_FLAGS(info->flags, MSG_MARKED);
+               MSG_UNSET_PERM_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
                CHANGE_FLAGS(info);
@@ -496,7 +494,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return TRUE;
                
        case MATCHING_ACTION_MARK_AS_READ:
-               MSG_UNSET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
+               MSG_UNSET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
                CHANGE_FLAGS(info);
@@ -504,7 +502,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                return TRUE;
 
        case MATCHING_ACTION_MARK_AS_UNREAD:
-               MSG_SET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
+               MSG_SET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
                CHANGE_FLAGS(info);
@@ -669,6 +667,7 @@ void filter_message(GSList * filtering_list, FolderItem * item,
 {
        MsgInfo * msginfo;
        gchar * filename;
+       MsgFlags  msgflags = { 0, 0 };
 
        if (item == NULL) {
                g_warning(_("folderitem not set"));
@@ -682,8 +681,8 @@ void filter_message(GSList * filtering_list, FolderItem * item,
                return;
        }
 
-       msginfo = procheader_parse(filename, 0, TRUE);
-
+       msginfo = procheader_parse(filename, msgflags, TRUE);
+       
        g_free(filename);
 
        if (msginfo == NULL) {
index 85f07c2..44bc44b 100644 (file)
@@ -613,10 +613,12 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
        src_folder = msginfo->folder->folder;
 
        num = folder->copy_msg(folder, dest, msginfo);
-       if (num != -1)
+
+       if (num != -1) {
                src_folder->remove_msg(src_folder,
                                       msginfo->folder,
                                       msginfo->msgnum);
+       }                                      
        
        if (folder->finished_copy)
                folder->finished_copy(folder, dest);
index 7e4f31c..3daad45 100644 (file)
@@ -1496,20 +1496,20 @@ static MsgFlags imap_parse_flags(const gchar *flag_str)
        const gchar *p = flag_str;
        MsgFlags flags;
 
-       flags = 0;
-       MSG_SET_FLAGS(flags, MSG_UNREAD|MSG_IMAP);
+       flags.perm_flags = MSG_UNREAD;
+       flags.tmp_flags  = MSG_IMAP;
 
        while ((p = strchr(p, '\\')) != NULL) {
                p++;
 
                if (g_strncasecmp(p, "Recent", 6) == 0) {
-                       MSG_SET_FLAGS(flags, MSG_NEW|MSG_UNREAD);
+                       MSG_SET_PERM_FLAGS(flags, MSG_NEW|MSG_UNREAD);
                } else if (g_strncasecmp(p, "Seen", 4) == 0) {
-                       MSG_UNSET_FLAGS(flags, MSG_NEW|MSG_UNREAD);
+                       MSG_UNSET_PERM_FLAGS(flags, MSG_NEW|MSG_UNREAD);
                } else if (g_strncasecmp(p, "Deleted", 7) == 0) {
-                       MSG_SET_FLAGS(flags, MSG_DELETED);
+                       MSG_SET_PERM_FLAGS(flags, MSG_DELETED);
                } else if (g_strncasecmp(p, "Flagged", 7) == 0) {
-                       MSG_SET_FLAGS(flags, MSG_MARKED);
+                       MSG_SET_PERM_FLAGS(flags, MSG_MARKED);
                }
        }
 
@@ -1536,7 +1536,7 @@ static MsgInfo *imap_parse_envelope(SockInfo *sock, GString *line_str)
        gchar *to = NULL;
        gchar *inreplyto = NULL;
        gchar *msgid = NULL;
-       MsgFlags flags = 0;
+       MsgFlags flags = {0, 0};
 
        g_return_val_if_fail(line_str != NULL, NULL);
        g_return_val_if_fail(line_str->str[0] == '*' &&
index 5b46361..1a5faa4 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -861,10 +861,6 @@ void inc_progress_update(Pop3State *state, Pop3Phase phase)
                           state->cur_msg, state->count,
                           to_human_readable(state->cur_total_bytes),
                           total_size);
-               //g_snprintf(buf, sizeof(buf),
-               //         _("Retrieving message (%d / %d) (%d / %d bytes)"),
-               //         state->cur_msg, state->count,
-               //         state->cur_total_bytes, state->total_bytes);
                progress_dialog_set_label(dialog, buf);
                progress_dialog_set_percentage
                        (dialog,
index 374a353..e125383 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <glib.h>
@@ -301,6 +320,11 @@ struct _message
        gboolean fetched;
 };
 
+#define MSG_IS_INVALID(msg) \
+       ((msg).perm_flags == (msg).tmp_flags && (msg).tmp_flags == -1)
+
+#define MSG_SET_INVALID(msg) \
+       ((msg).perm_flags = (msg).tmp_flags = -1)
 
 static int startFrom(char * s)
 {
@@ -381,8 +405,8 @@ static mailfile * mailfile_init_from_file(FILE * f, gchar * filename)
                                data->content = 0;
                                data->messageid = NULL;
                                data->fromspace = NULL;
-                               data->flags = -1;
-                               data->old_flags = -1;
+                               MSG_SET_INVALID(data->flags);
+                               MSG_SET_INVALID(data->old_flags);
                                data->fetched = FALSE;
                                msg_list = g_list_append(msg_list,
                                                         (gpointer) data);
@@ -655,15 +679,17 @@ static MsgInfo *mbox_parse_msg(FILE * fp, struct _message * msg,
                               FolderItem *item)
 {
        MsgInfo *msginfo;
-       MsgFlags flags = MSG_NEW|MSG_UNREAD;
+       MsgFlags flags = { 0, 0 };
+
+       MSG_SET_PERM_FLAGS(flags, MSG_NEW | MSG_UNREAD);
 
        g_return_val_if_fail(fp != NULL, NULL);
 
        if (item != NULL) {
                if (item->stype == F_QUEUE) {
-                       MSG_SET_FLAGS(flags, MSG_QUEUED);
+                       MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
                } else if (item->stype == F_DRAFT) {
-                       MSG_SET_FLAGS(flags, MSG_DRAFT);
+                       MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
                }
        }
 
@@ -880,9 +906,7 @@ static void mbox_cache_synchronize_lists(GList * old_msg_list,
 
                        if ((strcmp(msg->messageid, msg2->messageid) == 0) &&
                            (strcmp(msg->fromspace, msg2->fromspace) == 0)) {
-                               if ((msg2->flags & MSG_PERMANENT_FLAG_MASK) !=
-                                   (msg2->old_flags &
-                                    MSG_PERMANENT_FLAG_MASK)) {
+                               if (msg2->flags.perm_flags != msg2->old_flags.perm_flags) {
                                        msg->flags = msg2->flags;
                                        break;
                                }
@@ -1140,12 +1164,12 @@ GSList *mbox_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
 
                msg = (struct _message *) l->data;
 
-               if (msg->flags == -1 || !MSG_IS_REALLY_DELETED(msg->flags)) {
+               if (MSG_IS_INVALID(msg->flags) || !MSG_IS_REALLY_DELETED(msg->flags)) {
                        fseek(fp, msg->header, SEEK_SET);
 
                        msginfo = mbox_parse_msg(fp, msg, item);
 
-                       if (msg->flags != -1)
+                       if (!MSG_IS_INVALID(msg->flags))
                                msginfo->flags = msg->flags;
                        else {
                                msg->old_flags = msginfo->flags;
@@ -1155,7 +1179,7 @@ GSList *mbox_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
                        mlist = g_slist_append(mlist, msginfo);
                }
                else {
-                       msg->flags = MSG_REALLY_DELETED;
+                       MSG_SET_PERM_FLAGS(msg->flags, MSG_REALLY_DELETED);
                }
        }
 
@@ -1446,7 +1470,7 @@ gint mbox_remove_msg(Folder *folder, FolderItem *item, gint num)
        g_free(mbox_path);
        
        if (msg != NULL)
-               MSG_SET_FLAGS(msg->flags, MSG_REALLY_DELETED);
+               MSG_SET_PERM_FLAGS(msg->flags, MSG_REALLY_DELETED);
 
        return 0;
 }
@@ -1803,7 +1827,7 @@ static gboolean mbox_write_message(FILE * mbox_fp, FILE * new_fp,
 
        g_ptr_array_free(headers, FALSE);
 
-       if (msg->flags != -1) {
+       if (!MSG_IS_INVALID(msg->flags)) {
                /* Status header */
                fwrite("Status: ", strlen("Status: "), 1, new_fp);
                if (!MSG_IS_UNREAD(msg->flags))
@@ -1812,9 +1836,11 @@ static gboolean mbox_write_message(FILE * mbox_fp, FILE * new_fp,
                fwrite("\n", 1, 1, new_fp);
                
                /* X-Status header */
-               if (msg->flags & 
-                   (MSG_REALLY_DELETED | MSG_MARKED | MSG_DELETED
-                    | MSG_REPLIED | MSG_FORWARDED)) {
+               if (MSG_IS_REALLY_DELETED(msg->flags)
+               ||  MSG_IS_MARKED(msg->flags)
+               ||  MSG_IS_DELETED(msg->flags)
+               ||  MSG_IS_REPLIED(msg->flags)
+               ||  MSG_IS_FORWARDED(msg->flags)) {
                        fwrite("X-Status: ", strlen("X-Status: "), 1, new_fp);
                        if (MSG_IS_REALLY_DELETED(msg->flags))
                                fwrite("D", 1, 1, new_fp); /* really deleted */
@@ -1982,7 +2008,7 @@ static gboolean mbox_purge_deleted(gchar * mbox)
 
        for(l = msg_list ; l != NULL ; l = g_list_next(l)) {
                struct _message * msg = (struct _message *) l->data;
-               if (msg->flags != -1 && MSG_IS_REALLY_DELETED(msg->flags)) {
+               if (MSG_IS_INVALID(msg->flags) && MSG_IS_REALLY_DELETED(msg->flags)) {
                        modification = TRUE;
                        break;
                }
@@ -2016,7 +2042,7 @@ static gboolean mbox_purge_deleted(gchar * mbox)
        msg_list = mbox_cache_get_msg_list(mbox);
        for(l = msg_list ; l != NULL ; l = g_list_next(l)) {
                struct _message * msg = (struct _message *) l->data;
-               if (msg->flags == -1 || !MSG_IS_REALLY_DELETED(msg->flags)) {
+               if (MSG_IS_INVALID(msg->flags) || !MSG_IS_REALLY_DELETED(msg->flags)) {
                        if (!mbox_write_message(mbox_fp, new_fp, new, msg)) {
                                result = FALSE;
                                break;
index bc513bd..44a6913 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
 #ifndef MBOX_FOLDER_H
 
 #define MBOX_FOLDER_H
index 5d6d03d..eee4f99 100644 (file)
@@ -263,7 +263,7 @@ static gint disposition_notification_queue(PrefsAccount * account,
                MsgInfo newmsginfo;
 
                newmsginfo.msgnum = num;
-               newmsginfo.flags = 0;
+               newmsginfo.flags.perm_flags = newmsginfo.flags.tmp_flags = 0;
                procmsg_write_flags(&newmsginfo, fp);
                fclose(fp);
        }
@@ -377,7 +377,7 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo)
 
                if (!MSG_IS_ENCRYPTED(msginfo->flags) &&
                    rfc2015_is_encrypted(mimeinfo)) {
-                       MSG_SET_FLAGS(msginfo->flags, MSG_ENCRYPTED);
+                       MSG_SET_TMP_FLAGS(msginfo->flags, MSG_ENCRYPTED);
                }
                if (MSG_IS_ENCRYPTED(msginfo->flags) &&
                    !msginfo->plaintext_file  &&
index 1c032b7..7de12b7 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -229,8 +229,8 @@ gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
                    dest->stype == F_QUEUE  ||
                    dest->stype == F_DRAFT  ||
                    dest->stype == F_TRASH)
-                       MSG_UNSET_FLAGS(newmsginfo.flags,
-                                       MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                       MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
+                                            MSG_NEW|MSG_UNREAD|MSG_DELETED);
 
                procmsg_write_flags(&newmsginfo, fp);
                fclose(fp);
@@ -294,8 +294,9 @@ gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
                            dest->stype == F_QUEUE  ||
                            dest->stype == F_DRAFT  ||
                            dest->stype == F_TRASH)
-                               MSG_UNSET_FLAGS(newmsginfo.flags,
-                                               MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                               MSG_UNSET_PERM_FLAGS
+                                       (newmsginfo.flags,
+                                        MSG_NEW|MSG_UNREAD|MSG_DELETED);
 
                        procmsg_write_flags(&newmsginfo, fp);
                }
@@ -371,8 +372,8 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
                    dest->stype == F_QUEUE  ||
                    dest->stype == F_DRAFT  ||
                    dest->stype == F_TRASH)
-                       MSG_UNSET_FLAGS(newmsginfo.flags,
-                                       MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                       MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
+                                            MSG_NEW|MSG_UNREAD|MSG_DELETED);
                procmsg_write_flags(&newmsginfo, fp);
                fclose(fp);
        }
@@ -491,8 +492,9 @@ gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
                            dest->stype == F_QUEUE  ||
                            dest->stype == F_DRAFT  ||
                            dest->stype == F_TRASH)
-                               MSG_UNSET_FLAGS(newmsginfo.flags,
-                                               MSG_NEW|MSG_UNREAD|MSG_DELETED);
+                               MSG_UNSET_PERM_FLAGS
+                                       (newmsginfo.flags,
+                                        MSG_NEW|MSG_UNREAD|MSG_DELETED);
                        procmsg_write_flags(&newmsginfo, fp);
                }
        }
@@ -883,15 +885,18 @@ static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
 {
        struct stat s;
        MsgInfo *msginfo;
-       MsgFlags flags = MSG_NEW|MSG_UNREAD;
+       MsgFlags flags;
+
+       flags.perm_flags = MSG_NEW|MSG_UNREAD;
+       flags.tmp_flags = 0;
 
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(file != NULL, NULL);
 
        if (item->stype == F_QUEUE) {
-               MSG_SET_FLAGS(flags, MSG_QUEUED);
+               MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
        } else if (item->stype == F_DRAFT) {
-               MSG_SET_FLAGS(flags, MSG_DRAFT);
+               MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
        }
 
        msginfo = procheader_parse(file, flags, FALSE);
index 973909a..77db067 100644 (file)
@@ -538,7 +538,8 @@ static GSList *news_get_uncached_articles(NNTPSession *session,
                }
 
                msginfo->folder = item;
-               msginfo->flags = MSG_NEW|MSG_UNREAD|MSG_NEWS;
+               msginfo->flags.perm_flags = MSG_NEW|MSG_UNREAD;
+               msginfo->flags.tmp_flags = MSG_NEWS;
                msginfo->newsgroups = g_strdup(item->path);
 
                if (!newlist)
index e40fc11..6b6159a 100644 (file)
@@ -508,7 +508,12 @@ MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
        }
 
        msginfo = g_new0(MsgInfo, 1);
-       msginfo->flags = flags != 0 ? flags : MSG_NEW|MSG_UNREAD;
+       
+       if (flags.tmp_flags || flags.perm_flags) 
+               msginfo->flags = flags;
+       else 
+               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
+       
        msginfo->inreplyto = NULL;
 
        while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, hentry))
@@ -595,11 +600,11 @@ MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
                        break;
                case H_CONTENT_TYPE:
                        if (!strncasecmp(hp, "multipart", 9))
-                               msginfo->flags |= MSG_MIME;
+                               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MIME);
                        break;
                case H_SEEN:
                        /* mnews Seen header */
-                       MSG_UNSET_FLAGS(msginfo->flags, MSG_NEW|MSG_UNREAD);
+                       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW|MSG_UNREAD);
                        break;
                case H_X_FACE:
                        if (msginfo->xface) break;
@@ -615,24 +620,24 @@ MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
                        break;
                case H_STATUS:
                        if (strchr(hp, 'R') != NULL)
-                               MSG_UNSET_FLAGS(msginfo->flags, MSG_UNREAD);
+                               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
                        if (strchr(hp, 'O') != NULL)
-                               MSG_UNSET_FLAGS(msginfo->flags, MSG_NEW);
+                               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW);
                        if (strchr(hp, 'U') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags, MSG_UNREAD);
+                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
                        break;
                case H_X_STATUS:
                        if (strchr(hp, 'D') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags,
+                               MSG_SET_PERM_FLAGS(msginfo->flags,
                                              MSG_REALLY_DELETED);
                        if (strchr(hp, 'F') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags, MSG_MARKED);
+                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
                        if (strchr(hp, 'd') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags, MSG_DELETED);
+                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
                        if (strchr(hp, 'r') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags, MSG_REPLIED);
+                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
                        if (strchr(hp, 'f') != NULL)
-                               MSG_SET_FLAGS(msginfo->flags, MSG_FORWARDED);
+                               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
                        break;
                case H_FROM_SPACE:
                        if (msginfo->fromspace) break;
index e5095af..a22c92e 100644 (file)
@@ -174,17 +174,18 @@ GSList *procmsg_read_cache(FolderItem *item, gboolean scan_file)
        g_return_val_if_fail(item->folder != NULL, NULL);
        type = item->folder->type;
 
-       default_flags = MSG_NEW|MSG_UNREAD|MSG_CACHED;
+       default_flags.perm_flags = MSG_NEW|MSG_UNREAD;
+       default_flags.tmp_flags = MSG_CACHED;
        if (type == F_MH) {
                if (item->stype == F_QUEUE) {
-                       MSG_SET_FLAGS(default_flags, MSG_QUEUED);
+                       MSG_SET_TMP_FLAGS(default_flags, MSG_QUEUED);
                } else if (item->stype == F_DRAFT) {
-                       MSG_SET_FLAGS(default_flags, MSG_DRAFT);
+                       MSG_SET_TMP_FLAGS(default_flags, MSG_DRAFT);
                }
        } else if (type == F_IMAP) {
-               MSG_SET_FLAGS(default_flags, MSG_IMAP);
+               MSG_SET_TMP_FLAGS(default_flags, MSG_IMAP);
        } else if (type == F_NEWS) {
-               MSG_SET_FLAGS(default_flags, MSG_NEWS);
+               MSG_SET_TMP_FLAGS(default_flags, MSG_NEWS);
        }
 
        if (type == F_MH) {
@@ -222,7 +223,7 @@ GSList *procmsg_read_cache(FolderItem *item, gboolean scan_file)
                READ_CACHE_DATA_INT(msginfo->size, fp);
                READ_CACHE_DATA_INT(msginfo->mtime, fp);
                READ_CACHE_DATA_INT(msginfo->date_t, fp);
-               READ_CACHE_DATA_INT(msginfo->flags, fp);
+               READ_CACHE_DATA_INT(msginfo->flags.tmp_flags, fp);
 
                READ_CACHE_DATA(msginfo->fromname, fp);
 
@@ -236,7 +237,8 @@ GSList *procmsg_read_cache(FolderItem *item, gboolean scan_file)
                READ_CACHE_DATA(msginfo->inreplyto, fp);
                READ_CACHE_DATA(msginfo->references, fp);
 
-               MSG_SET_FLAGS(msginfo->flags, default_flags);
+               MSG_SET_PERM_FLAGS(msginfo->flags, default_flags.perm_flags);
+               MSG_SET_TMP_FLAGS(msginfo->flags, default_flags.tmp_flags);
 
                /* if the message file doesn't exist or is changed,
                   don't add the data */
@@ -272,7 +274,7 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
        gchar *markdir;
        MsgInfo *msginfo;
        GHashTable *mark_table;
-       MsgFlags flags;
+       MsgFlags *flags;
 
        if (!mlist) return;
        g_return_if_fail(item != NULL);
@@ -295,25 +297,22 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
                if (lastnum < msginfo->msgnum)
                        lastnum = msginfo->msgnum;
 
-               flags = GPOINTER_TO_UINT(g_hash_table_lookup(mark_table,
-                                        GUINT_TO_POINTER(msginfo->msgnum)));
+               flags = g_hash_table_lookup
+                       (mark_table, GUINT_TO_POINTER(msginfo->msgnum));
 
-               if (flags != 0) {
+               if (flags != NULL) {
                        /* add the permanent flags only */
-                       MSG_UNSET_FLAGS(msginfo->flags,
-                                       MSG_PERMANENT_FLAG_MASK);
-                       MSG_SET_FLAGS(msginfo->flags,
-                                     flags & MSG_PERMANENT_FLAG_MASK);
+                       msginfo->flags.perm_flags = flags->perm_flags;
                        if (item->folder->type == F_IMAP) {
-                               MSG_SET_FLAGS(msginfo->flags, MSG_IMAP);
+                               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_IMAP);
                        } else if (item->folder->type == F_NEWS) {
-                               MSG_SET_FLAGS(msginfo->flags, MSG_NEWS);
+                               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_NEWS);
                        }
                } else {
                        /* not found (new message) */
                        if (newmsg == 0) {
                                for (tmp = mlist; tmp != cur; tmp = tmp->next)
-                                       MSG_UNSET_FLAGS
+                                       MSG_UNSET_PERM_FLAGS
                                                (((MsgInfo *)tmp->data)->flags,
                                                 MSG_NEW);
                        }
@@ -327,6 +326,7 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
        if (newmsg)
                debug_print(_("\t%d new message(s)\n"), newmsg);
 
+       hash_free_value_mem(mark_table);
        g_hash_table_destroy(mark_table);
 }
 
@@ -361,7 +361,7 @@ void procmsg_msg_list_free(GSList *mlist)
 
 void procmsg_write_cache(MsgInfo *msginfo, FILE *fp)
 {
-       MsgFlags flags = msginfo->flags & MSG_CACHED_FLAG_MASK;
+       MsgTmpFlags flags = msginfo->flags.tmp_flags & MSG_CACHED_FLAG_MASK;
 
        WRITE_CACHE_DATA_INT(msginfo->msgnum, fp);
        WRITE_CACHE_DATA_INT(msginfo->size, fp);
@@ -384,9 +384,7 @@ void procmsg_write_cache(MsgInfo *msginfo, FILE *fp)
 
 void procmsg_write_flags(MsgInfo *msginfo, FILE *fp)
 {
-       MsgFlags flags;
-
-       flags = msginfo->flags & MSG_PERMANENT_FLAG_MASK;
+       MsgPermFlags flags = msginfo->flags.perm_flags;
 
        WRITE_CACHE_DATA_INT(msginfo->msgnum, fp);
        WRITE_CACHE_DATA_INT(flags, fp);
@@ -400,11 +398,11 @@ struct MarkSum {
 
 static void mark_sum_func(gpointer key, gpointer value, gpointer data)
 {
-       MsgFlags flags = GPOINTER_TO_UINT(value);
+       MsgFlags *flags = value;
        struct MarkSum *marksum = data;
 
-       if (MSG_IS_NEW(flags) && !MSG_IS_IGNORE_THREAD(flags)) (*marksum->new)++;
-       if (MSG_IS_UNREAD(flags) && !MSG_IS_IGNORE_THREAD(flags)) (*marksum->unread)++;
+       if (MSG_IS_NEW(*flags) && !MSG_IS_IGNORE_THREAD(*flags)) (*marksum->new)++;
+       if (MSG_IS_UNREAD(*flags) && !MSG_IS_IGNORE_THREAD(*flags)) (*marksum->unread)++;
        (*marksum->total)++;
 }
 
@@ -432,7 +430,8 @@ static GHashTable *procmsg_read_mark_file(const gchar *folder)
        FILE *fp;
        GHashTable *mark_table = NULL;
        gint num;
-       MsgFlags flags;
+       MsgFlags *flags;
+       MsgPermFlags perm_flags;
 
        if ((fp = procmsg_open_mark_file(folder, FALSE)) == NULL)
                return NULL;
@@ -440,12 +439,12 @@ static GHashTable *procmsg_read_mark_file(const gchar *folder)
        mark_table = g_hash_table_new(NULL, g_direct_equal);
 
        while (fread(&num, sizeof(num), 1, fp) == 1) {
-               if (fread(&flags, sizeof(flags), 1, fp) != 1) break;
+               if (fread(&perm_flags, sizeof(flags), 1, fp) != 1) break;
+
+               flags = g_new0(MsgFlags, 1);
+               flags->perm_flags = perm_flags;
 
-               MSG_SET_FLAGS(flags, MSG_CACHED);
-               g_hash_table_insert(mark_table,
-                                   GUINT_TO_POINTER(num),
-                                   GUINT_TO_POINTER(flags));
+               g_hash_table_insert(mark_table, GUINT_TO_POINTER(num), flags);
        }
 
        fclose(fp);
@@ -575,7 +574,6 @@ gchar *procmsg_get_message_file_path(MsgInfo *msginfo)
                file = g_strdup(msginfo->plaintext_file);
        else {
                path = folder_item_get_path(msginfo->folder);
-
                file = g_strconcat(path, G_DIR_SEPARATOR_S,
                                   itos(msginfo->msgnum), NULL);
                g_free(path);
index 7a16adc..1becc14 100644 (file)
 #include <string.h>
 
 typedef struct _MsgInfo                MsgInfo;
+typedef struct _MsgFlags       MsgFlags;
 
 #include "folder.h"
 
 typedef enum
 {
-       /* permanent flags (0x0000ffff) */
        MSG_NEW         = 1 << 0,
        MSG_UNREAD      = 1 << 1,
        MSG_MARKED      = 1 << 2,
        MSG_DELETED     = 1 << 3,
        MSG_REPLIED     = 1 << 4,
        MSG_FORWARDED   = 1 << 5,
-       MSG_REALLY_DELETED = 1 << 6,
-
-       MSG_LABEL         = 1 << 9 | 1 << 8 | 1 << 7,
-       MSG_LABEL_NONE    = 0 << 9 | 0 << 8 | 0 << 7,
-       MSG_LABEL_ORANGE  = 0 << 9 | 0 << 8 | 1 << 7,
-       MSG_LABEL_RED     = 0 << 9 | 1 << 8 | 0 << 7,
-       MSG_LABEL_PINK    = 0 << 9 | 1 << 8 | 1 << 7,
-       MSG_LABEL_SKYBLUE = 1 << 9 | 0 << 8 | 0 << 7,
-       MSG_LABEL_BLUE    = 1 << 9 | 0 << 8 | 1 << 7,
-       MSG_LABEL_GREEN   = 1 << 9 | 1 << 8 | 0 << 7,
-       MSG_LABEL_BROWN   = 1 << 9 | 1 << 8 | 1 << 7,
-
-       MSG_IGNORE_THREAD = 1 << 10,
-
-       /* temporary flags (0xffff0000) */
-       MSG_MOVE        = 1 << 16,
-       MSG_COPY        = 1 << 17,
-
-       MSG_QUEUED      = 1 << 25,
-       MSG_DRAFT       = 1 << 26,
-       MSG_ENCRYPTED   = 1 << 27,
-       MSG_IMAP        = 1 << 28,
+       
+       MSG_REALLY_DELETED = 1 << 6,            /* mbox stuff */
+
+#define MSG_LABEL_SBIT (7)             /* start bit message label */
+#define MAKE_MSG_LABEL(h, m, l) ((h) << (MSG_LABEL_SBIT+2)) | \
+                               ((m) << (MSG_LABEL_SBIT+1)) | \
+                               ((l) << (MSG_LABEL_SBIT+0))
+                               
+       MSG_LABEL       = MAKE_MSG_LABEL(1, 1, 1),
+       MSG_LABEL_NONE  = MAKE_MSG_LABEL(0, 0, 0),
+       MSG_LABEL_1     = MAKE_MSG_LABEL(0, 0, 1),
+       MSG_LABEL_2     = MAKE_MSG_LABEL(0, 1, 0),
+       MSG_LABEL_3     = MAKE_MSG_LABEL(0, 1, 1),
+       MSG_LABEL_4     = MAKE_MSG_LABEL(1, 0, 0),
+       MSG_LABEL_5     = MAKE_MSG_LABEL(1, 0, 1),
+       MSG_LABEL_6     = MAKE_MSG_LABEL(1, 1, 0),
+       MSG_LABEL_7     = MAKE_MSG_LABEL(1, 1, 1),
+
+#define MSG_LABEL_ORANGE   (MSG_LABEL_1)
+#define MSG_LABEL_RED      (MSG_LABEL_2)
+#define MSG_LABEL_PINK     (MSG_LABEL_3)
+#define MSG_LABEL_SKYBLUE  (MSG_LABEL_4)
+#define MSG_LABEL_BLUE     (MSG_LABEL_5)
+#define MSG_LABEL_GREEN    (MSG_LABEL_6)
+#define MSG_LABEL_BROWN    (MSG_LABEL_7)
+
+       MSG_IGNORE_THREAD   = 1 << 10,   /* ignore threads */
+
+       /* RESERVED */
+       MSG_RESERVED_CLAWS  = 1 << 30,  /* for sylpheed-claws */
+       MSG_RESERVED_MAIN   = 1 << 31   /* for sylpheed-main  */
+} MsgPermFlags;
+
+typedef enum
+{
+       MSG_MOVE        = 1 << 0,
+       MSG_COPY        = 1 << 1,
+       
+       MSG_QUEUED      = 1 << 16,
+       MSG_DRAFT       = 1 << 17,
+       MSG_ENCRYPTED   = 1 << 18,
+       MSG_IMAP        = 1 << 19,
+       MSG_NEWS        = 1 << 20,
+
        MSG_MIME        = 1 << 29,
-       MSG_NEWS        = 1 << 30,
        MSG_CACHED      = 1 << 31
-} MsgFlags;
-
-#define MSG_PERMANENT_FLAG_MASK                (MSG_NEW       | \
-                                        MSG_UNREAD    | \
-                                        MSG_MARKED    | \
-                                        MSG_DELETED   | \
-                                        MSG_REPLIED   | \
-                                        MSG_FORWARDED | \
-                                         MSG_REALLY_DELETED | \
-                                         MSG_LABEL     | \
-                                        MSG_IGNORE_THREAD)
+} MsgTmpFlags;
+
 #define MSG_CACHED_FLAG_MASK           (MSG_MIME)
 
 #define MSG_SET_FLAGS(msg, flags)      { (msg) |= (flags); }
 #define MSG_UNSET_FLAGS(msg, flags)    { (msg) &= ~(flags); }
-#define MSG_IS_NEW(msg)                        ((msg & MSG_NEW) != 0)
-#define MSG_IS_UNREAD(msg)             ((msg & MSG_UNREAD) != 0)
-#define MSG_IS_MARKED(msg)             ((msg & MSG_MARKED) != 0)
-#define MSG_IS_DELETED(msg)            ((msg & MSG_DELETED) != 0)
-#define MSG_IS_REPLIED(msg)            ((msg & MSG_REPLIED) != 0)
-#define MSG_IS_FORWARDED(msg)          ((msg & MSG_FORWARDED) != 0)
-
-#define MSG_IS_MOVE(msg)               ((msg & MSG_MOVE) != 0)
-#define MSG_IS_COPY(msg)               ((msg & MSG_COPY) != 0)
-#define MSG_IS_REALLY_DELETED(msg)     ((msg & MSG_REALLY_DELETED) != 0)
-
-#define MSG_IS_QUEUED(msg)             ((msg & MSG_QUEUED) != 0)
-#define MSG_IS_DRAFT(msg)              ((msg & MSG_DRAFT) != 0)
-#define MSG_IS_ENCRYPTED(msg)          ((msg & MSG_ENCRYPTED) != 0)
-#define MSG_IS_IMAP(msg)               ((msg & MSG_IMAP) != 0)
-#define MSG_IS_MIME(msg)               ((msg & MSG_MIME) != 0)
-#define MSG_IS_NEWS(msg)               ((msg & MSG_NEWS) != 0)
-#define MSG_IS_CACHED(msg)             ((msg & MSG_CACHED) != 0)
-#define MSG_GET_LABEL(msg)             (msg & MSG_LABEL)
-#define MSG_IS_IGNORE_THREAD(msg)      ((msg & MSG_IGNORE_THREAD) != 0)
+#define MSG_SET_PERM_FLAGS(msg, flags) \
+       MSG_SET_FLAGS((msg).perm_flags, flags)
+#define MSG_SET_TMP_FLAGS(msg, flags) \
+       MSG_SET_FLAGS((msg).tmp_flags, flags)
+#define MSG_UNSET_PERM_FLAGS(msg, flags) \
+       MSG_UNSET_FLAGS((msg).perm_flags, flags)
+#define MSG_UNSET_TMP_FLAGS(msg, flags) \
+       MSG_UNSET_FLAGS((msg).tmp_flags, flags)
+
+#define MSG_IS_NEW(msg)                        (((msg).perm_flags & MSG_NEW) != 0)
+#define MSG_IS_UNREAD(msg)             (((msg).perm_flags & MSG_UNREAD) != 0)
+#define MSG_IS_MARKED(msg)             (((msg).perm_flags & MSG_MARKED) != 0)
+#define MSG_IS_DELETED(msg)            (((msg).perm_flags & MSG_DELETED) != 0)
+#define MSG_IS_REPLIED(msg)            (((msg).perm_flags & MSG_REPLIED) != 0)
+#define MSG_IS_FORWARDED(msg)          (((msg).perm_flags & MSG_FORWARDED) != 0)
+
+#define MSG_IS_MOVE(msg)               (((msg).tmp_flags & MSG_MOVE) != 0)
+#define MSG_IS_COPY(msg)               (((msg).tmp_flags & MSG_COPY) != 0)
+
+#define MSG_IS_QUEUED(msg)             (((msg).tmp_flags & MSG_QUEUED) != 0)
+#define MSG_IS_DRAFT(msg)              (((msg).tmp_flags & MSG_DRAFT) != 0)
+#define MSG_IS_ENCRYPTED(msg)          (((msg).tmp_flags & MSG_ENCRYPTED) != 0)
+#define MSG_IS_IMAP(msg)               (((msg).tmp_flags & MSG_IMAP) != 0)
+#define MSG_IS_NEWS(msg)               (((msg).tmp_flags & MSG_NEWS) != 0)
+#define MSG_IS_MIME(msg)               (((msg).tmp_flags & MSG_MIME) != 0)
+#define MSG_IS_CACHED(msg)             (((msg).tmp_flags & MSG_CACHED) != 0)
+
+/* Claws related flags */
+#define MSG_IS_REALLY_DELETED(msg)     (((msg).perm_flags & MSG_REALLY_DELETED) != 0)
+#define MSG_IS_IGNORE_THREAD(msg)      (((msg).perm_flags & MSG_IGNORE_THREAD) != 0)
+#define MSG_GET_LABEL(msg)             (((msg).perm_flags & MSG_LABEL))
+#define MSG_GET_LABEL_VALUE(msg)       (MSG_GET_LABEL(msg) >> MSG_LABEL_SBIT)
+/* 7 == nr. of colors excl. none */
+#define MSG_SET_LABEL_VALUE(msg, val)  MSG_SET_PERM_FLAGS(msg, ((((int)(val)) & 7) << MSG_LABEL_SBIT))
 
 #define WRITE_CACHE_DATA_INT(n, fp) \
        fwrite(&n, sizeof(n), 1, fp)
@@ -117,12 +143,19 @@ typedef enum
        } \
 }
 
+struct _MsgFlags
+{
+       MsgPermFlags perm_flags;
+       MsgTmpFlags  tmp_flags;
+};
+
 struct _MsgInfo
 {
        guint  msgnum;
        off_t  size;
        time_t mtime;
        time_t date_t;
+
        MsgFlags flags;
 
        gchar *fromname;
index 5c86205..c883e42 100644 (file)
@@ -309,6 +309,8 @@ static gint summary_cmp_by_label    (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
 
+static void summary_mark_all_read (SummaryView *summaryview);                                   
+
 GtkTargetEntry summary_drag_types[1] =
 {
        {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
@@ -326,6 +328,7 @@ static GtkItemFactoryEntry summary_popup_entries[] =
        {N_("/_Mark/---"),              NULL, NULL,             0, "<Separator>"},
        {N_("/_Mark/Mark as unr_ead"),  NULL, summary_mark_as_unread, 0, NULL},
        {N_("/_Mark/Mark as rea_d"),    NULL, summary_mark_as_read, 0, NULL},
+       {N_("/_Mark/Mark all read"),    NULL, summary_mark_all_read, 0, NULL},
        {N_("/_Mark/Ignore thread"),    NULL, summary_ignore_thread, 0, NULL},
        {N_("/_Mark/Unignore thread"),  NULL, summary_unignore_thread, 0, NULL},
 
@@ -384,8 +387,6 @@ static void label_menu_item_activate_cb(GtkWidget *widget, gpointer data)
        if (gtk_object_get_data(GTK_OBJECT(view->label_menu), "dont_toggle"))
                return;
                
-       color <<= 7;
-
        summary_set_label(view, color, NULL);
 }
 
@@ -397,7 +398,9 @@ void summary_set_label_color(GtkCTree *ctree, GtkCTreeNode *node,
        GdkColor  color;
        GtkStyle *style, *prev_style, *ctree_style;
        MsgInfo  *msginfo;
-       gint     color_index = ((gint)(labelcolor >> 7)) - 1;
+       gint     color_index; 
+
+       color_index = (gint) labelcolor - 1;
 
        ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
 
@@ -409,7 +412,7 @@ void summary_set_label_color(GtkCTree *ctree, GtkCTreeNode *node,
        style = gtk_style_copy(prev_style);
 
        if (color_index < 0 || color_index >= LABEL_COLORS_ELEMS) {
-               labelcolor = 0;
+               color_index = 0;
                color.red = ctree_style->fg[GTK_STATE_NORMAL].red;
                color.green = ctree_style->fg[GTK_STATE_NORMAL].green;
                color.blue = ctree_style->fg[GTK_STATE_NORMAL].blue;
@@ -421,13 +424,14 @@ void summary_set_label_color(GtkCTree *ctree, GtkCTreeNode *node,
                style->fg[GTK_STATE_SELECTED] = color;
                gtk_ctree_node_set_row_style(ctree, node, style);
        }
-       else
+       else {
                color = label_colors[color_index].color;
+       }               
 
        msginfo = gtk_ctree_node_get_row_data(ctree, node);
 
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_LABEL);
-       MSG_SET_FLAGS(msginfo->flags, labelcolor);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_LABEL);
+       MSG_SET_LABEL_VALUE(msginfo->flags, labelcolor);
 
        if ( style ) {
                style->fg[GTK_STATE_NORMAL] = color;
@@ -539,7 +543,7 @@ static void label_menu_item_activate_item_cb(GtkMenuItem *label_menu_item, gpoin
                                                GTK_CTREE_NODE(sel->data));
                        gint menu_item;                         
                        if (msginfo) {
-                               menu_item = ((msginfo->flags & MSG_LABEL) >> 7);
+                               menu_item = MSG_GET_LABEL_VALUE(msginfo->flags);
                                if (!items[menu_item]->active)
                                        gtk_check_menu_item_set_state(items[menu_item], TRUE);
                        }
@@ -616,7 +620,7 @@ static void summary_create_label_menu(SummaryView *summaryview)
                gtk_menu_append(GTK_MENU(label_menu), item);
                gtk_signal_connect(GTK_OBJECT(item), "activate", 
                                   GTK_SIGNAL_FUNC(label_menu_item_activate_cb),
-                                  GUINT_TO_POINTER(i + 1));
+                                  GUINT_TO_POINTER(i + 1)); /* color index + 1 */
                gtk_object_set_data(GTK_OBJECT(item), "view", summaryview);
                gtk_widget_show(item);
 
@@ -822,8 +826,6 @@ SummaryView *summary_create(void)
        summaryview->sort_mode = SORT_BY_NONE;
        summaryview->sort_type = GTK_SORT_ASCENDING;
 
-//     summary_create_label_menu(summaryview);
-
        summary_change_display_item(summaryview);
 
        gtk_widget_show_all(vbox);
@@ -1128,7 +1130,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                (summaryview->mainwin, summaryview->selected ? TRUE : FALSE);
 
        debug_print("\n");
-       STATUSBAR_PUSH(summaryview->mainwin, _("done."));
+       STATUSBAR_PUSH(summaryview->mainwin, _("Done."));
 
        main_window_cursor_normal(summaryview->mainwin);
 
@@ -1223,7 +1225,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
                menu_set_insensitive_all
                        (GTK_MENU_SHELL(summaryview->popupmenu));
                return;
-       } 
+       }
 
        if (summaryview->folder_item->folder->type != F_NEWS) {
                if (summaryview->folder_item->stype != F_TRASH)
@@ -1260,6 +1262,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
 
        menu_set_sensitive(ifactory, "/Mark/Mark as unread", TRUE);
        menu_set_sensitive(ifactory, "/Mark/Mark as read",   TRUE);
+       menu_set_sensitive(ifactory, "/Mark/Mark all read", TRUE);
        menu_set_sensitive(ifactory, "/Mark/Ignore thread",   TRUE);
        menu_set_sensitive(ifactory, "/Mark/Unignore thread", TRUE);
 
@@ -1898,7 +1901,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                                        if (MSG_IS_UNREAD(msginfo->flags))
                                                summaryview->unread--;
 */
-                                       MSG_SET_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+                                       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
                                }
                        }
 
@@ -1910,7 +1913,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                        summary_set_marks_func(ctree, node, summaryview);
                        
                        if ( MSG_GET_LABEL(msginfo->flags) )
-                         summary_set_label_color(ctree, node, (msginfo->flags & MSG_LABEL));
+                         summary_set_label_color(ctree, node, MSG_GET_LABEL_VALUE(msginfo->flags));
 
                        /* preserve previous node if the message is
                           duplicated */
@@ -1975,7 +1978,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                        summary_set_marks_func(ctree, node, summaryview);
 
                        if ( MSG_GET_LABEL(msginfo->flags) )
-                         summary_set_label_color(ctree, node, (msginfo->flags & MSG_LABEL));
+                         summary_set_label_color(ctree, node, MSG_GET_LABEL_VALUE(msginfo->flags));
 
                        if (msginfo->msgid && *msginfo->msgid &&
                            g_hash_table_lookup(msgid_table, msginfo->msgid)
@@ -2202,10 +2205,8 @@ static void summary_display_msg(SummaryView *summaryview, GtkCTreeNode *row,
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
        if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
-               MSG_UNSET_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-
+               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
                CHANGE_FLAGS(msginfo);
-
                summary_set_row_marks(summaryview, row);
                gtk_clist_thaw(GTK_CLIST(ctree));
                summary_status_show(summaryview);
@@ -2394,8 +2395,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
        else if ((global_scoring ||
                  summaryview->folder_item->prefs->scoring) &&
                 (msginfo->score >= summaryview->important_score) &&
-                ((msginfo->flags &
-                  (MSG_MARKED | MSG_MOVE | MSG_COPY)) == 0)) {
+                (MSG_IS_MARKED(msginfo->flags) || MSG_IS_MOVE(msginfo->flags) || MSG_IS_COPY(msginfo->flags))) {
                gtk_ctree_node_set_text(ctree, row, S_COL_MARK, "!");
                gtk_ctree_node_set_foreground(ctree, row,
                                              &summaryview->color_important);
@@ -2429,11 +2429,10 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->moved--;
        if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_DELETED | MSG_MOVE | MSG_COPY);
-       MSG_SET_FLAGS(msginfo->flags, MSG_MARKED);
-
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
+       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
+       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
        CHANGE_FLAGS(msginfo);
-
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is marked\n"), msginfo->msgnum);
 }
@@ -2463,10 +2462,8 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
                summaryview->unread--;
        if (MSG_IS_NEW(msginfo->flags) ||
            MSG_IS_UNREAD(msginfo->flags)) {
-               MSG_UNSET_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-
+               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
                CHANGE_FLAGS(msginfo);
-               
                summary_set_row_marks(summaryview, row);
                debug_print(_("Message %d is marked as read\n"),
                            msginfo->msgnum);
@@ -2485,6 +2482,13 @@ void summary_mark_as_read(SummaryView *summaryview)
        summary_status_show(summaryview);
 }
 
+static void summary_mark_all_read(SummaryView *summaryview)
+{
+       summary_select_all(summaryview);
+       summary_mark_as_read(summaryview);
+       summary_unselect_all(summaryview);
+}
+
 static void summary_mark_row_as_unread(SummaryView *summaryview,
                                       GtkCTreeNode *row)
 {
@@ -2494,12 +2498,12 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags)) {
                msginfo->to_folder = NULL;
-               MSG_UNSET_FLAGS(msginfo->flags, MSG_DELETED);
+               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
                summaryview->deleted--;
        }
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_REPLIED | MSG_FORWARDED);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED | MSG_FORWARDED);
        if (!MSG_IS_UNREAD(msginfo->flags)) {
-               MSG_SET_FLAGS(msginfo->flags, MSG_UNREAD);
+               MSG_SET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
                gtk_ctree_node_set_pixmap(ctree, row, S_COL_UNREAD,
                                          unreadxpm, unreadxpmmask);
                summaryview->unread++;
@@ -2538,14 +2542,10 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->moved--;
        if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-       MSG_UNSET_FLAGS(msginfo->flags,
-                       MSG_MARKED |
-                       MSG_MOVE |
-                       MSG_COPY);
-       MSG_SET_FLAGS(msginfo->flags, MSG_DELETED);
-
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
+       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
        CHANGE_FLAGS(msginfo);
-
        summaryview->deleted++;
 
        if (!prefs_common.immediate_exec)
@@ -2632,14 +2632,9 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->moved--;
        if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-       MSG_UNSET_FLAGS(msginfo->flags,
-                       MSG_MARKED |
-                       MSG_DELETED |
-                       MSG_MOVE |
-                       MSG_COPY);
-
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        CHANGE_FLAGS(msginfo);
-
        summary_set_row_marks(summaryview, row);
 
        debug_print(_("Message %s/%d is unmarked\n"),
@@ -2670,13 +2665,12 @@ static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
        msginfo->to_folder = to_folder;
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
-       MSG_UNSET_FLAGS(msginfo->flags,
-                       MSG_MARKED | MSG_DELETED | MSG_COPY);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
-               MSG_SET_FLAGS(msginfo->flags, MSG_MOVE);
+               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
                summaryview->moved++;
        }
-
        if (!prefs_common.immediate_exec)
                summary_set_row_marks(summaryview, row);
 
@@ -2732,13 +2726,12 @@ static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
        msginfo->to_folder = to_folder;
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
-       MSG_UNSET_FLAGS(msginfo->flags,
-                       MSG_MARKED | MSG_DELETED | MSG_MOVE);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
-               MSG_SET_FLAGS(msginfo->flags, MSG_COPY);
+               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_COPY);
                summaryview->copied++;
        }
-
        if (!prefs_common.immediate_exec)
                summary_set_row_marks(summaryview, row);
 
@@ -2859,7 +2852,7 @@ void summary_print(SummaryView *summaryview)
                        (ctree, GTK_CTREE_NODE(cur->data));
                if (msginfo) procmsg_print_message(msginfo, cmdline);
        }
-       
+
        g_free(cmdline);
 }
 
@@ -3012,8 +3005,7 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
 
-               MSG_UNSET_FLAGS(msginfo->flags, MSG_COPY);
-               
+               MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
                summary_set_row_marks(summaryview, node);
        }
 }
@@ -3038,7 +3030,7 @@ static void summary_execute_delete(SummaryView *summaryview)
 
        for(cur = summaryview->mlist ; cur != NULL ; cur = cur->next) {
                MsgInfo * msginfo = cur->data;
-               MSG_UNSET_FLAGS(msginfo->flags, MSG_DELETED);
+               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
        }
 
        folder_item_move_msgs_with_dest(trash, summaryview->mlist);
@@ -3546,10 +3538,8 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        switch (column) {
        case S_COL_MARK:
                if (MSG_IS_MARKED(msginfo->flags)) {
-                       MSG_UNSET_FLAGS(msginfo->flags, MSG_MARKED);
-
+                       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
                        CHANGE_FLAGS(msginfo);
-                       
                        summary_set_row_marks(summaryview, row);
                } else
                        summary_mark_row(summaryview, row);
@@ -3959,7 +3949,7 @@ static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpoin
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread--;
-       MSG_SET_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
 
        CHANGE_FLAGS(msginfo);
                
@@ -3990,7 +3980,7 @@ static void summary_unignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpo
                summaryview->newmsgs++;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread++;
-       MSG_UNSET_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
 
        CHANGE_FLAGS(msginfo);
                
index b9c66d1..0f75c41 100644 (file)
@@ -81,6 +81,17 @@ void hash_free_strings(GHashTable *table)
        g_hash_table_foreach(table, hash_free_strings_func, NULL);
 }
 
+static void hash_free_value_mem_func(gpointer key, gpointer value,
+                                    gpointer data)
+{
+       g_free(value);
+}
+
+void hash_free_value_mem(GHashTable *table)
+{
+       g_hash_table_foreach(table, hash_free_value_mem_func, NULL);
+}
+
 void ptr_array_free_strings(GPtrArray *array)
 {
        gint i;
@@ -2067,4 +2078,9 @@ void log_error(const gchar *format, ...)
 
        g_warning("%s", buf);
        log_window_append(buf, LOG_ERROR);
+       if (log_fp) {
+               fputs("*** error: ", log_fp);
+               fputs(buf, log_fp);
+               fflush(log_fp);
+       }
 }
index 9a64cf6..9501547 100644 (file)
@@ -125,6 +125,7 @@ void list_free_strings              (GList          *list);
 void slist_free_strings                (GSList         *list);
 
 void hash_free_strings         (GHashTable     *table);
+void hash_free_value_mem       (GHashTable     *table);
 
 void ptr_array_free_strings    (GPtrArray      *array);