* configure.in
[claws.git] / src / procmsg.h
index f4e80e8f06c527961f4ef20a304bd4c0fce27982..eddd6a20335b5209b7b4a6b70d9f19140236042c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  * 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
 #ifndef __PROCMSG_H__
 #define __PROCMSG_H__
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <glib.h>
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
 
 typedef struct _MsgInfo                MsgInfo;
+typedef struct _MsgFlags       MsgFlags;
 
 #include "folder.h"
+#include "procmime.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,            /* mbox stuff */
+
+#define MSG_CLABEL_SBIT        (7)             /* start bit of color label */
+#define MAKE_MSG_CLABEL(h, m, l)       (((h) << (MSG_CLABEL_SBIT + 2)) | \
+                                        ((m) << (MSG_CLABEL_SBIT + 1)) | \
+                                        ((l) << (MSG_CLABEL_SBIT + 0)))
+
+       MSG_CLABEL_NONE = MAKE_MSG_CLABEL(0, 0, 0),
+       MSG_CLABEL_1    = MAKE_MSG_CLABEL(0, 0, 1),
+       MSG_CLABEL_2    = MAKE_MSG_CLABEL(0, 1, 0),
+       MSG_CLABEL_3    = MAKE_MSG_CLABEL(0, 1, 1),
+       MSG_CLABEL_4    = MAKE_MSG_CLABEL(1, 0, 0),
+       MSG_CLABEL_5    = MAKE_MSG_CLABEL(1, 0, 1),
+       MSG_CLABEL_6    = MAKE_MSG_CLABEL(1, 1, 0),
+       MSG_CLABEL_7    = MAKE_MSG_CLABEL(1, 1, 1),
+
+#define MSG_CLABEL_ORANGE      MSG_CLABEL_1
+#define MSG_CLABEL_RED         MSG_CLABEL_2
+#define MSG_CLABEL_PINK                MSG_CLABEL_3
+#define MSG_CLABEL_SKYBLUE     MSG_CLABEL_4
+#define MSG_CLABEL_BLUE                MSG_CLABEL_5
+#define MSG_CLABEL_GREEN       MSG_CLABEL_6
+#define MSG_CLABEL_BROWN       MSG_CLABEL_7
+
+       MSG_IGNORE_THREAD   = 1 << 10,   /* ignore threads */
+       MSG_LOCKED          = 1 << 11,   /* msg is locked  */
+       MSG_RETRCPT_PENDING = 1 << 12,   /* return receipt pending */
+
+       /* RESERVED */
+       MSG_RESERVED_CLAWS  = 1 << 30,  /* for sylpheed-claws */
+       MSG_RESERVED_MAIN   = 1 << 31   /* for sylpheed-main  */
+} MsgPermFlags;
+
+#define MSG_CLABEL_FLAG_MASK   (MSG_CLABEL_7)
 
-       /* temporary flags (0xffff0000) */
-       MSG_MOVE        = 1 << 16,
-       MSG_COPY        = 1 << 17,
+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_QUEUED      = 1 << 25,
-       MSG_DRAFT       = 1 << 26,
-       MSG_ENCRYPTED   = 1 << 27,
-       MSG_IMAP        = 1 << 28,
        MSG_MIME        = 1 << 29,
-       MSG_NEWS        = 1 << 30,
+
        MSG_CACHED      = 1 << 31
-} MsgFlags;
+} MsgTmpFlags;
 
-#define MSG_PERMANENT_FLAG_MASK                (MSG_NEW       | \
-                                        MSG_UNREAD    | \
-                                        MSG_MARKED    | \
-                                        MSG_DELETED   | \
-                                        MSG_REPLIED   | \
-                                        MSG_FORWARDED)
-#define MSG_CACHED_FLAG_MASK           (MSG_MIME)
+#define MSG_CACHED_FLAG_MASK   (MSG_MIME | MSG_ENCRYPTED)
 
 #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_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_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_LOCKED(msg)             (((msg).perm_flags & MSG_LOCKED) != 0)
+#define MSG_IS_FORWARDED(msg)          (((msg).perm_flags & MSG_FORWARDED) != 0)
+
+#define MSG_GET_COLORLABEL(msg)                (((msg).perm_flags & MSG_CLABEL_FLAG_MASK))
+#define MSG_GET_COLORLABEL_VALUE(msg)  (MSG_GET_COLORLABEL(msg) >> MSG_CLABEL_SBIT)
+#define MSG_SET_COLORLABEL_VALUE(msg, val) \
+       MSG_SET_PERM_FLAGS(msg, ((((guint)(val)) & 7) << MSG_CLABEL_SBIT))
+
+#define MSG_COLORLABEL_TO_FLAGS(val) ((((guint)(val)) & 7) << MSG_CLABEL_SBIT)
+#define MSG_COLORLABEL_FROM_FLAGS(val) (val >> MSG_CLABEL_SBIT)
+
+#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_IS_RETRCPT_PENDING(msg)    (((msg).perm_flags & MSG_RETRCPT_PENDING) != 0)
+
 
 #define WRITE_CACHE_DATA_INT(n, fp) \
        fwrite(&n, sizeof(n), 1, fp)
@@ -98,12 +159,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;
@@ -111,11 +179,11 @@ struct _MsgInfo
        gchar *date;
        gchar *from;
        gchar *to;
+       gchar *cc;
        gchar *newsgroups;
        gchar *subject;
        gchar *msgid;
        gchar *inreplyto;
-       gchar *cc;
 
        FolderItem *folder;
        FolderItem *to_folder;
@@ -123,8 +191,13 @@ struct _MsgInfo
        gchar *xface;
 
        gchar *dispositionnotificationto;
+       gchar *returnreceiptto;
 
-       int score;
+       gchar *references;
+       gchar *fromspace;
+
+       gint score;
+       gint threadscore;
 
        /* used only for encrypted messages */
        gchar *plaintext_file;
@@ -141,6 +214,7 @@ GSList *procmsg_read_cache          (FolderItem     *item,
 void   procmsg_set_flags               (GSList         *mlist,
                                         FolderItem     *item);
 gint   procmsg_get_last_num_in_cache   (GSList         *mlist);
+void   procmsg_msg_list_free           (GSList         *mlist);
 void   procmsg_write_cache             (MsgInfo        *msginfo,
                                         FILE           *fp);
 void   procmsg_write_flags             (MsgInfo        *msginfo,
@@ -148,16 +222,25 @@ void      procmsg_write_flags             (MsgInfo        *msginfo,
 void   procmsg_get_mark_sum            (const gchar    *folder,
                                         gint           *new,
                                         gint           *unread,
-                                        gint           *total);
+                                        gint           *total,
+                                        gint           *min,
+                                        gint           *max,
+                                        gint            first);
 FILE   *procmsg_open_mark_file         (const gchar    *folder,
                                         gboolean        append);
 
+GNode  *procmsg_get_thread_tree                (GSList         *mlist);
+
 void   procmsg_move_messages           (GSList         *mlist);
 void   procmsg_copy_messages           (GSList         *mlist);
 
 gchar  *procmsg_get_message_file_path  (MsgInfo        *msginfo);
 gchar  *procmsg_get_message_file       (MsgInfo        *msginfo);
 FILE   *procmsg_open_message           (MsgInfo        *msginfo);
+#if USE_GPGME
+FILE   *procmsg_open_message_decrypted (MsgInfo        *msginfo,
+                                        MimeInfo      **mimeinfo);
+#endif
 gboolean procmsg_msg_exist             (MsgInfo        *msginfo);
 
 void   procmsg_empty_trash             (void);
@@ -170,5 +253,13 @@ void        procmsg_msginfo_free           (MsgInfo        *msginfo);
 
 gint procmsg_cmp_msgnum_for_sort       (gconstpointer   a,
                                         gconstpointer   b);
+gint procmsg_send_message_queue                (const gchar *file);
+
+void procmsg_msginfo_set_flags         (MsgInfo *msginfo,
+                                        MsgPermFlags perm_flags,
+                                         MsgTmpFlags tmp_flags);
+void procmsg_msginfo_unset_flags       (MsgInfo *msginfo,
+                                        MsgPermFlags perm_flags,
+                                         MsgTmpFlags tmp_flags);
 
 #endif /* __PROCMSG_H__ */