[evolution-data-server/wip/camel-more-gobject: 41/62] Revert "Early work on porting CamelMessageInfo to GObject"



commit 5c41230a504d102562c0457576699e8626dd6c3d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 30 10:59:48 2016 +0200

    Revert "Early work on porting CamelMessageInfo to GObject"
    
    Let's make this in smaller steps, with kept the branch buildable.
    Most of the new changes will be copied to the code later.
    
    This reverts commit a771565f0b25b458d8b2f0bdc2d3227ec351f738.

 camel/Makefile.am            |    2 -
 camel/camel-folder-summary.c |  554 +++++++++++++++++++++++++
 camel/camel-folder-summary.h |  253 ++++++++++++-
 camel/camel-message-info.c   |  925 ------------------------------------------
 camel/camel-message-info.h   |  211 ----------
 5 files changed, 806 insertions(+), 1139 deletions(-)
---
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 1bc66f4..dc7bb1d 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -92,7 +92,6 @@ libcamel_1_2_la_SOURCES = \
        camel-medium.c \
        camel-memchunk.c \
        camel-mempool.c \
-       camel-message-info.c \
        camel-mime-filter-basic.c \
        camel-mime-filter-bestenc.c \
        camel-mime-filter-canon.c \
@@ -211,7 +210,6 @@ libcamelinclude_HEADERS = \
        camel-medium.h \
        camel-memchunk.h \
        camel-mempool.h \
-       camel-message-info.h \
        camel-mime-filter-basic.h \
        camel-mime-filter-bestenc.h \
        camel-mime-filter-canon.h \
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 39aa3e6..eb46cfe 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -4594,6 +4594,26 @@ camel_message_info_new (CamelFolderSummary *summary)
 }
 
 /**
+ * camel_message_info_ref:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Reference an info.
+ * Returns: (transfer full) (type CamelMessageInfo):
+ **/
+gpointer
+camel_message_info_ref (gpointer o)
+{
+       CamelMessageInfo *mi = o;
+
+       g_return_val_if_fail (mi != NULL, NULL);
+       g_return_val_if_fail (mi->refcount > 0, NULL);
+
+       g_atomic_int_inc (&mi->refcount);
+
+       return o;
+}
+
+/**
  * camel_message_info_new_from_header:
  * @summary: a #CamelFolderSummary object or %NULL
  * @header: raw header
@@ -4615,6 +4635,44 @@ camel_message_info_new_from_header (CamelFolderSummary *summary,
 }
 
 /**
+ * camel_message_info_unref:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Unref's and potentially frees a #CamelMessageInfo and its contents.
+ **/
+void
+camel_message_info_unref (gpointer o)
+{
+       CamelMessageInfo *mi = o;
+
+       g_return_if_fail (mi != NULL);
+       g_return_if_fail (mi->refcount > 0);
+
+       if (g_atomic_int_dec_and_test (&mi->refcount)) {
+               if (mi->summary != NULL) {
+                       CamelFolderSummaryClass *class;
+
+                       /* FIXME This is kinda busted, should really
+                        *       be handled by message_info_free(). */
+                       if (mi->summary->priv->build_content
+                           && ((CamelMessageInfoBase *) mi)->content) {
+                               camel_folder_summary_content_info_free (
+                                       mi->summary,
+                                       ((CamelMessageInfoBase *) mi)->content);
+                               ((CamelMessageInfoBase *) mi)->content = NULL;
+                       }
+
+                       class = CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary);
+                       g_return_if_fail (class->message_info_free != NULL);
+
+                       class->message_info_free (mi->summary, mi);
+               } else {
+                       message_info_free (NULL, mi);
+               }
+       }
+}
+
+/**
  * camel_message_info_clone:
  * @info: (type CamelMessageInfo): a #CamelMessageInfo
  *
@@ -4633,6 +4691,502 @@ camel_message_info_clone (gconstpointer o)
                return message_info_clone (NULL, mi);
 }
 
+/**
+ * camel_message_info_get_ptr:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ * @id: info to get
+ *
+ * Generic accessor method for getting pointer data.
+ *
+ * Returns: (transfer none): the pointer data
+ *
+ * Since: 3.22
+ **/
+gconstpointer
+camel_message_info_get_ptr (gconstpointer info,
+                           gint id)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, NULL);
+
+       if (nfo->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (nfo->summary)->info_ptr (nfo, id);
+       else
+               return info_ptr (nfo, id);
+}
+
+/**
+ * camel_message_info_get_uint32:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ * @id: info to get
+ *
+ * Generic accessor method for getting 32bit unsigned integer data.
+ *
+ * Returns: the guint32 data
+ *
+ * Since: 3.22
+ **/
+guint32
+camel_message_info_get_uint32 (gconstpointer info,
+                              gint id)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, 0);
+
+       if (nfo->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (nfo->summary)->info_uint32 (nfo, id);
+       else
+               return info_uint32 (nfo, id);
+}
+
+/**
+ * camel_message_info_get_time:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ * @id: info to get
+ *
+ * Generic accessor method for getting time_t data.
+ *
+ * Returns: the time_t data
+ *
+ * Since: 3.22
+ **/
+time_t
+camel_message_info_get_time (gconstpointer info,
+                            gint id)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, (time_t) 0);
+
+       if (nfo->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (nfo->summary)->info_time (nfo, id);
+       else
+               return info_time (nfo, id);
+}
+
+/**
+ * camel_message_info_get_uid:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the uid of the #CamelMessageInfo
+ *
+ * Returns: the uid
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_uid (gconstpointer info)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return nfo->uid;
+}
+
+/**
+ * camel_message_info_get_subject:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the subject of the #CamelMessageInfo
+ *
+ * Returns: the subject
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_subject (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_SUBJECT);
+}
+
+/**
+ * camel_message_info_get_preview:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the preview of the #CamelMessageInfo
+ *
+ * Returns: the preview
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_preview (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_PREVIEW);
+}
+
+/**
+ * camel_message_info_get_from:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the from field of the #CamelMessageInfo
+ *
+ * Returns: the from field
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_from (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_FROM);
+}
+
+/**
+ * camel_message_info_get_to:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the to field of the #CamelMessageInfo
+ *
+ * Returns: the to field
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_to (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_TO);
+}
+
+/**
+ * camel_message_info_get_cc:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the cc field of the #CamelMessageInfo
+ *
+ * Returns: the cc field
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_cc (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_CC);
+}
+
+/**
+ * camel_message_info_get_mlist:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the mlist of the #CamelMessageInfo
+ *
+ * Returns: the mlist
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_mlist (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_MLIST);
+}
+
+/**
+ * camel_message_info_get_flags:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the flags of the #CamelMessageInfo
+ *
+ * Returns: the flags
+ *
+ * Since: 3.22
+ **/
+guint32
+camel_message_info_get_flags (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, 0);
+
+       return camel_message_info_get_uint32 (info, CAMEL_MESSAGE_INFO_FLAGS);
+}
+
+/**
+ * camel_message_info_get_size:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the size of the #CamelMessageInfo
+ *
+ * Returns: the size
+ *
+ * Since: 3.22
+ **/
+guint32
+camel_message_info_get_size (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, 0);
+
+       return camel_message_info_get_uint32 (info, CAMEL_MESSAGE_INFO_SIZE);
+}
+
+/**
+ * camel_message_info_get_date_sent:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the sent date of the #CamelMessageInfo
+ *
+ * Returns: the sent date
+ *
+ * Since: 3.22
+ **/
+time_t
+camel_message_info_get_date_sent (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, (time_t) 0);
+
+       return camel_message_info_get_time (info, CAMEL_MESSAGE_INFO_DATE_SENT);
+}
+
+/**
+ * camel_message_info_get_date_received:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the received date of the #CamelMessageInfo
+ *
+ * Returns: the received date
+ *
+ * Since: 3.22
+ **/
+time_t
+camel_message_info_get_date_received (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, (time_t) 0);
+
+       return camel_message_info_get_time (info, CAMEL_MESSAGE_INFO_DATE_RECEIVED);
+}
+
+/**
+ * camel_message_info_get_user_flag:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ * @id: user flag to get
+ *
+ * Get the state of a user flag named @id.
+ *
+ * Returns: the state of the user flag
+ *
+ * Since: 3.22
+ **/
+gboolean
+camel_message_info_get_user_flag (gconstpointer info,
+                                 const gchar *id)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, FALSE);
+
+       if (nfo->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (nfo->summary)->info_user_flag (nfo, id);
+       else
+               return info_user_flag (nfo, id);
+}
+
+/**
+ * camel_message_info_get_user_tag:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ * @id: user tag to get
+ *
+ * Get the value of a user tag named @id.
+ *
+ * Returns: the value of the user tag
+ *
+ * Since: 3.22
+ **/
+const gchar *
+camel_message_info_get_user_tag (gconstpointer info,
+                                const gchar *id)
+{
+       const CamelMessageInfo *nfo = info;
+
+       g_return_val_if_fail (info != NULL, NULL);
+
+       if (nfo->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (nfo->summary)->info_user_tag (nfo, id);
+       else
+               return info_user_tag (nfo, id);
+}
+
+/**
+ * camel_message_info_get_message_id:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelSummaryMessageID of the #CamelMessageInfo
+ *
+ * Returns: the id of the message
+ *
+ * Since: 3.22
+ **/
+const CamelSummaryMessageID *
+camel_message_info_get_message_id (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_MESSAGE_ID);
+}
+
+/**
+ * camel_message_info_get_references:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelSummaryReferences of the #CamelMessageInfo
+ *
+ * Returns: the references of the message
+ *
+ * Since: 3.22
+ **/
+const CamelSummaryReferences *
+camel_message_info_get_references (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_REFERENCES);
+}
+
+/**
+ * camel_message_info_get_user_flags:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelFlag of the #CamelMessageInfo
+ *
+ * Returns: the flags of the message
+ *
+ * Since: 3.22
+ **/
+const CamelFlag *
+camel_message_info_get_user_flags (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_USER_FLAGS);
+}
+
+/**
+ * camel_message_info_get_user_tags:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelTag of the #CamelMessageInfo
+ *
+ * Returns: the tags of the message
+ *
+ * Since: 3.22
+ **/
+const CamelTag *
+camel_message_info_get_user_tags (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_USER_TAGS);
+}
+
+/**
+ * camel_message_info_get_headers:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelHeaderParam of the #CamelMessageInfo
+ *
+ * Returns: the headers of the message
+ *
+ * Since: 3.22
+ **/
+const CamelHeaderParam *
+camel_message_info_get_headers (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_HEADERS);
+}
+
+/**
+ * camel_message_info_get_content:
+ * @info: (type CamelMessageInfo): a #CamelMessageInfo
+ *
+ * Get the #CamelMessageContentInfo of the #CamelMessageInfo
+ *
+ * Returns: the content of the message
+ *
+ * Since: 3.22
+ **/
+const CamelMessageContentInfo *
+camel_message_info_get_content (gconstpointer info)
+{
+       g_return_val_if_fail (info != NULL, NULL);
+
+       return camel_message_info_get_ptr (info, CAMEL_MESSAGE_INFO_CONTENT);
+}
+
+/**
+ * camel_message_info_set_flags:
+ * @info: a #CamelMessageInfo
+ * @flags: mask of flags to change
+ * @set: state the flags should be changed to
+ *
+ * Change the state of the system flags on the #CamelMessageInfo
+ *
+ * Returns: %TRUE if any of the flags changed or %FALSE otherwise
+ **/
+gboolean
+camel_message_info_set_flags (CamelMessageInfo *info,
+                              CamelMessageFlags flags,
+                              guint32 set)
+{
+       if (info->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (info->summary)->info_set_flags (info, flags, set);
+       else
+               return info_set_flags (info, flags, set);
+}
+
+/**
+ * camel_message_info_set_user_flag:
+ * @info: a #CamelMessageInfo
+ * @id: name of the user flag to set
+ * @state: state to set the flag to
+ *
+ * Set the state of a user flag on a #CamelMessageInfo.
+ *
+ * Returns: %TRUE if the state changed or %FALSE otherwise
+ **/
+gboolean
+camel_message_info_set_user_flag (CamelMessageInfo *info,
+                                  const gchar *id,
+                                  gboolean state)
+{
+       if (info->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (info->summary)->info_set_user_flag (info, id, state);
+       else
+               return info_set_user_flag (info, id, state);
+}
+
+/**
+ * camel_message_info_set_user_tag:
+ * @info: a #CamelMessageInfo
+ * @id: name of the user tag to set
+ * @val: value to set
+ *
+ * Set the value of a user tag on a #CamelMessageInfo.
+ *
+ * Returns: %TRUE if the value changed or %FALSE otherwise
+ **/
+gboolean
+camel_message_info_set_user_tag (CamelMessageInfo *info,
+                                 const gchar *id,
+                                 const gchar *val)
+{
+       if (info->summary)
+               return CAMEL_FOLDER_SUMMARY_GET_CLASS (info->summary)->info_set_user_tag (info, id, val);
+       else
+               return info_set_user_tag (info, id, val);
+}
+
 void
 camel_content_info_dump (CamelMessageContentInfo *ci,
                          gint depth)
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index b265639..d6dfff0 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -29,7 +29,6 @@
 
 #include <camel/camel-index.h>
 #include <camel/camel-memchunk.h>
-#include <camel/camel-message-info.h>
 #include <camel/camel-mime-message.h>
 #include <camel/camel-mime-parser.h>
 
@@ -61,6 +60,9 @@ typedef struct _CamelFolderSummary CamelFolderSummary;
 typedef struct _CamelFolderSummaryClass CamelFolderSummaryClass;
 typedef struct _CamelFolderSummaryPrivate CamelFolderSummaryPrivate;
 
+typedef struct _CamelMessageInfo CamelMessageInfo;
+typedef struct _CamelMessageInfoBase CamelMessageInfoBase;
+
 typedef struct _CamelMessageContentInfo CamelMessageContentInfo;
 
 /* A tree of message content info structures
@@ -78,6 +80,136 @@ struct _CamelMessageContentInfo {
        guint32 size;
 };
 
+/* system flag bits */
+typedef enum _CamelMessageFlags {
+       CAMEL_MESSAGE_ANSWERED = 1 << 0,
+       CAMEL_MESSAGE_DELETED = 1 << 1,
+       CAMEL_MESSAGE_DRAFT = 1 << 2,
+       CAMEL_MESSAGE_FLAGGED = 1 << 3,
+       CAMEL_MESSAGE_SEEN = 1 << 4,
+
+       /* these aren't really system flag bits, but are convenience flags */
+       CAMEL_MESSAGE_ATTACHMENTS = 1 << 5,
+       CAMEL_MESSAGE_ANSWERED_ALL = 1 << 6,
+       CAMEL_MESSAGE_JUNK = 1 << 7,
+       CAMEL_MESSAGE_SECURE = 1 << 8,
+       CAMEL_MESSAGE_NOTJUNK = 1 << 9,
+       CAMEL_MESSAGE_FORWARDED = 1 << 10,
+
+       /* following flags are for the folder, and are not really permanent flags */
+       CAMEL_MESSAGE_FOLDER_FLAGGED = 1 << 16, /* for use by the folder implementation */
+       /* flags after 1 << 16 are used by camel providers,
+ *         if adding non permanent flags, add them to the end  */
+
+       CAMEL_MESSAGE_JUNK_LEARN = 1 << 30, /* used when setting CAMEL_MESSAGE_JUNK flag
+                                            * to say that we request junk plugin
+                                            * to learn that message as junk/non junk */
+       CAMEL_MESSAGE_USER = 1 << 31 /* supports user flags */
+} CamelMessageFlags;
+
+/* Changes to system flags will NOT trigger a folder changed event */
+#define CAMEL_MESSAGE_SYSTEM_MASK (0xffff << 16)
+
+typedef struct _CamelFlag {
+       struct _CamelFlag *next;
+       gchar name[1];          /* name allocated as part of the structure */
+} CamelFlag;
+
+typedef struct _CamelTag {
+       struct _CamelTag *next;
+       gchar *value;
+       gchar name[1];          /* name allocated as part of the structure */
+} CamelTag;
+
+/* a summary messageid is a 64 bit identifier (partial md5 hash) */
+typedef struct _CamelSummaryMessageID {
+       union {
+               guint64 id;
+               guchar hash[8];
+               struct {
+                       guint32 hi;
+                       guint32 lo;
+               } part;
+       } id;
+} CamelSummaryMessageID;
+
+/* summary references is a fixed size array of references */
+typedef struct _CamelSummaryReferences {
+       gint size;
+       CamelSummaryMessageID references[1];
+} CamelSummaryReferences;
+
+/* accessor id's */
+enum {
+       CAMEL_MESSAGE_INFO_SUBJECT,
+       CAMEL_MESSAGE_INFO_FROM,
+       CAMEL_MESSAGE_INFO_TO,
+       CAMEL_MESSAGE_INFO_CC,
+       CAMEL_MESSAGE_INFO_MLIST,
+
+       CAMEL_MESSAGE_INFO_FLAGS,
+       CAMEL_MESSAGE_INFO_SIZE,
+
+       CAMEL_MESSAGE_INFO_DATE_SENT,
+       CAMEL_MESSAGE_INFO_DATE_RECEIVED,
+
+       CAMEL_MESSAGE_INFO_MESSAGE_ID,
+       CAMEL_MESSAGE_INFO_REFERENCES,
+       CAMEL_MESSAGE_INFO_USER_FLAGS,
+       CAMEL_MESSAGE_INFO_USER_TAGS,
+
+       CAMEL_MESSAGE_INFO_HEADERS,
+       CAMEL_MESSAGE_INFO_PREVIEW,
+       CAMEL_MESSAGE_INFO_CONTENT,
+       CAMEL_MESSAGE_INFO_LAST
+};
+
+/* information about a given message, use accessors */
+struct _CamelMessageInfo {
+       CamelFolderSummary *summary;
+
+       volatile gint refcount;
+       const gchar *uid;
+       /*FIXME: Make it work with the CAMEL_MESSADE_DB_DIRTY flag instead of another 4 bytes*/
+       guint dirty : 1;
+};
+
+/* For classes wishing to do the provided i/o, or for anonymous users,
+ * they must subclass or use this messageinfo structure */
+/* Otherwise they can do their own thing entirely */
+struct _CamelMessageInfoBase {
+       CamelFolderSummary *summary;
+
+       volatile gint refcount;
+       const gchar *uid;
+       /*FIXME: Make it work with the CAMEL_MESSADE_DB_DIRTY flag instead of another 4 bytes*/
+       guint dirty : 1;
+
+       const gchar *subject;
+       const gchar *from;
+       const gchar *to;
+       const gchar *cc;
+       const gchar *mlist;
+
+       CamelMessageFlags flags;
+       guint32 size;
+
+       time_t date_sent;
+       time_t date_received;
+
+       CamelSummaryMessageID message_id;
+       CamelSummaryReferences *references;/* from parent to root */
+
+       struct _CamelFlag *user_flags;
+       struct _CamelTag *user_tags;
+
+       /* tree of content description - NULL if it is not available */
+       CamelMessageContentInfo *content;
+       struct _camel_header_param *headers;
+       gchar *preview;
+       gchar *bodystructure;
+};
+
 /**
  * CamelFolderSummaryFlags:
  * @CAMEL_FOLDER_SUMMARY_DIRTY:
@@ -367,6 +499,125 @@ void              camel_folder_summary_prepare_fetch_all
 void           camel_folder_summary_lock       (CamelFolderSummary *summary);
 void           camel_folder_summary_unlock     (CamelFolderSummary *summary);
 
+/* message flag operations */
+gboolean       camel_flag_get                  (CamelFlag **list,
+                                                const gchar *name);
+gboolean       camel_flag_set                  (CamelFlag **list,
+                                                const gchar *name,
+                                                gboolean value);
+gboolean       camel_flag_list_copy            (CamelFlag **to,
+                                                CamelFlag **from);
+gint           camel_flag_list_size            (CamelFlag **list);
+void           camel_flag_list_free            (CamelFlag **list);
+
+CamelMessageFlags
+               camel_system_flag               (const gchar *name);
+gboolean       camel_system_flag_get           (CamelMessageFlags flags,
+                                                const gchar *name);
+
+/* message tag operations */
+const gchar *  camel_tag_get                   (CamelTag **list,
+                                                const gchar *name);
+gboolean       camel_tag_set                   (CamelTag **list,
+                                                const gchar *name,
+                                                const gchar *value);
+gboolean       camel_tag_list_copy             (CamelTag **to,
+                                                CamelTag **from);
+gint           camel_tag_list_size             (CamelTag **list);
+void           camel_tag_list_free             (CamelTag **list);
+
+/* Summary may be null */
+/* Use anonymous pointers to avoid tons of cast crap */
+GType          camel_message_info_get_type     (void) G_GNUC_CONST;
+gpointer       camel_message_info_new          (CamelFolderSummary *summary);
+gpointer       camel_message_info_ref          (gpointer info);
+CamelMessageInfo *
+               camel_message_info_new_from_header
+                                               (CamelFolderSummary *summary,
+                                                struct _camel_header_raw *header);
+void           camel_message_info_unref        (gpointer info);
+gpointer       camel_message_info_clone        (gconstpointer info);
+
+/* These will be fully removed soon, left only for a backward compatibility */
+#define camel_message_info_ptr                 camel_message_info_get_ptr
+#define camel_message_info_uint32              camel_message_info_get_uint32
+#define camel_message_info_time                        camel_message_info_get_time
+#define camel_message_info_uid                 camel_message_info_get_uid
+#define camel_message_info_subject             camel_message_info_get_subject
+#define camel_message_info_preview             camel_message_info_get_preview
+#define camel_message_info_from                        camel_message_info_get_from
+#define camel_message_info_to                  camel_message_info_get_to
+#define camel_message_info_cc                  camel_message_info_get_cc
+#define camel_message_info_mlist               camel_message_info_get_mlist
+#define camel_message_info_flags               camel_message_info_get_flags
+#define camel_message_info_size                        camel_message_info_get_size
+#define camel_message_info_date_sent           camel_message_info_get_date_sent
+#define camel_message_info_date_received       camel_message_info_get_date_received
+#define camel_message_info_message_id          camel_message_info_get_message_id
+#define camel_message_info_references          camel_message_info_get_references
+#define camel_message_info_user_flags          camel_message_info_get_user_flags
+#define camel_message_info_user_tags           camel_message_info_get_user_tags
+#define camel_message_info_headers             camel_message_info_get_headers
+#define camel_message_info_content             camel_message_info_get_content
+#define camel_message_info_user_flag           camel_message_info_get_user_flag
+#define camel_message_info_user_tag            camel_message_info_get_user_tag
+
+/* accessors */
+gconstpointer  camel_message_info_get_ptr      (gconstpointer info,
+                                                gint id);
+guint32                camel_message_info_get_uint32   (gconstpointer info,
+                                                gint id);
+time_t         camel_message_info_get_time     (gconstpointer info,
+                                                gint id);
+
+const gchar *  camel_message_info_get_uid      (gconstpointer info);
+const gchar *  camel_message_info_get_subject  (gconstpointer info);
+const gchar *  camel_message_info_get_preview  (gconstpointer info);
+const gchar *  camel_message_info_get_from     (gconstpointer info);
+const gchar *  camel_message_info_get_to       (gconstpointer info);
+
+const gchar *  camel_message_info_get_cc       (gconstpointer info);
+const gchar *  camel_message_info_get_mlist    (gconstpointer info);
+guint32                camel_message_info_get_flags    (gconstpointer info);
+guint32                camel_message_info_get_size     (gconstpointer info);
+
+time_t         camel_message_info_get_date_sent
+                                               (gconstpointer info);
+time_t         camel_message_info_get_date_received
+                                               (gconstpointer info);
+
+const CamelSummaryMessageID *
+               camel_message_info_get_message_id
+                                               (gconstpointer info);
+const CamelSummaryReferences *
+               camel_message_info_get_references
+                                               (gconstpointer info);
+const CamelFlag *
+               camel_message_info_get_user_flags
+                                               (gconstpointer info);
+const CamelTag *
+               camel_message_info_get_user_tags
+                                               (gconstpointer info);
+const CamelHeaderParam *
+               camel_message_info_get_headers  (gconstpointer info);
+const CamelMessageContentInfo *
+               camel_message_info_get_content  (gconstpointer info);
+gboolean       camel_message_info_get_user_flag(gconstpointer info,
+                                                const gchar *id);
+const gchar *  camel_message_info_get_user_tag (gconstpointer info,
+                                                const gchar *id);
+
+gboolean       camel_message_info_set_flags    (CamelMessageInfo *info,
+                                                CamelMessageFlags flags,
+                                                guint32 set);
+gboolean       camel_message_info_set_user_flag
+                                               (CamelMessageInfo *info,
+                                                const gchar *id,
+                                                gboolean state);
+gboolean       camel_message_info_set_user_tag (CamelMessageInfo *info,
+                                                const gchar *id,
+                                                const gchar *val);
+
 /* debugging functions */
 void           camel_content_info_dump         (CamelMessageContentInfo *ci,
                                                 gint depth);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]