2010-08-25 20:40:07 +02:00
|
|
|
/*
|
2011-05-17 22:24:29 +02:00
|
|
|
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2010-08-25 20:40:07 +02:00
|
|
|
**
|
|
|
|
** 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MU_MSG_ITER_H__
|
|
|
|
#define __MU_MSG_ITER_H__
|
|
|
|
|
2010-11-30 07:32:59 +01:00
|
|
|
#include <glib.h>
|
|
|
|
#include <mu-msg.h>
|
2010-08-25 20:40:07 +02:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2011-05-01 14:00:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MuMsgIter is a structure to iterate over the results of a
|
|
|
|
* query. You can iterate only in one-direction, and you can do it
|
|
|
|
* only once.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
struct _MuMsgIter;
|
|
|
|
typedef struct _MuMsgIter MuMsgIter;
|
|
|
|
|
|
|
|
/**
|
2010-11-25 20:49:25 +01:00
|
|
|
* get the next message (which you got from
|
2010-08-25 20:40:07 +02:00
|
|
|
* e.g. mu_query_run)
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return TRUE if it succeeded, FALSE otherwise (e.g., because there
|
|
|
|
* are no more messages in the query result)
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_iter_next (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2010-09-08 23:09:00 +02:00
|
|
|
* does this iterator point past the end of the list?
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2010-09-08 23:09:00 +02:00
|
|
|
* @return TRUE if the iter points past end of the list, FALSE
|
|
|
|
* otherwise
|
2010-08-25 20:40:07 +02:00
|
|
|
*/
|
2010-09-08 23:09:00 +02:00
|
|
|
gboolean mu_msg_iter_is_done (MuMsgIter *iter);
|
2010-08-25 20:40:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* destroy the sequence of messages; ie. /all/ of them
|
|
|
|
*
|
|
|
|
* @param msg a valid MuMsgIter message or NULL
|
|
|
|
*/
|
|
|
|
void mu_msg_iter_destroy (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-05-01 14:00:28 +02:00
|
|
|
* get the corresponding MuMsg for this iter; this requires the actual
|
|
|
|
* message file to be present at the expected place in the maildir in
|
|
|
|
* the file system. Note, it's faster to use the database fields (the
|
|
|
|
* various mu_msg_iter_get_... functions), so MuMsg should use only
|
|
|
|
* when information is needed that is not provided from the iter).
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
2010-11-25 20:49:25 +01:00
|
|
|
* @param iter a valid MuMsgIter instance
|
|
|
|
* @param err which receives error info or NULL. err is only filled
|
|
|
|
* when the function returns NULL
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
|
|
|
* @return a MuMsgGMime instance, or NULL in case of error. Use
|
|
|
|
* mu_msg_gmime_destroy when the instance is no longer needed
|
|
|
|
*/
|
2010-11-30 07:32:59 +01:00
|
|
|
MuMsg* mu_msg_iter_get_msg (MuMsgIter *iter, GError **err)
|
|
|
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
2011-03-21 00:55:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
|
|
|
* get the document id for the current message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2010-12-18 09:44:27 +01:00
|
|
|
* @return the docid or (unsigned int)-1 in case of error
|
2010-08-25 20:40:07 +02:00
|
|
|
*/
|
|
|
|
unsigned int mu_msg_iter_get_docid (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
2011-03-19 09:11:13 +01:00
|
|
|
|
2011-05-01 14:00:28 +02:00
|
|
|
/**
|
2011-03-19 09:11:13 +01:00
|
|
|
* get the index for this iterator (ie. somewhere between [0..n-1],
|
|
|
|
* with being the number of matches, and increasing 1 for each
|
|
|
|
* iter_next)
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter
|
|
|
|
*
|
|
|
|
* @return the index or (unsigned int)-1 in case of error
|
|
|
|
|
|
|
|
*/
|
|
|
|
unsigned int mu_msg_iter_get_index (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
2010-11-07 17:01:04 +01:00
|
|
|
* get the full path of the message file
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the path, or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_path (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
2010-11-07 17:01:04 +01:00
|
|
|
/**
|
|
|
|
* get the maildir of the message - e.g., a message file
|
|
|
|
* /home/user/Maildir/foo/bar/cur/abc123 would have maildir
|
|
|
|
* "/foo/bar"
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
2011-03-21 00:55:11 +01:00
|
|
|
* * @return the path, or NULL in case of error
|
2010-11-07 17:01:04 +01:00
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_maildir (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
2011-01-05 21:46:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the msgid of the message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the msgid or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_msgid (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
2011-01-05 21:46:10 +01:00
|
|
|
* get the size of the message in Kb
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the size, or 0 in case of error
|
|
|
|
*/
|
|
|
|
size_t mu_msg_iter_get_size (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the timestamp (ctime) of the message file
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the size, or 0 in case of error
|
|
|
|
*/
|
|
|
|
time_t mu_msg_iter_get_timestamp (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the sent time of the message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the time, or 0 in case of error
|
|
|
|
*/
|
|
|
|
time_t mu_msg_iter_get_date (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the message sender(s) of the message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the time, or 0 in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_from (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the message recipient (To:) of the message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the To-recipient(s), or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_to (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-05-01 17:31:00 +02:00
|
|
|
* get the 'carbon-copy' recipient(s) (Cc:) of the message
|
2010-08-25 20:40:07 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the Cc-recipient(s), or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_cc (MuMsgIter *iter);
|
|
|
|
|
2011-05-01 17:31:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the 'blind carbon-copy' message recipient(s) (Bcc:) of the
|
|
|
|
* message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the Bcc-recipient(s), or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_bcc (MuMsgIter *iter);
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
|
|
|
* get the subject of the message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the subject, or NULL in case of error
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_subject (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the message flags
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the message flags, or MU_MSG_FLAG_UNKNOWN
|
|
|
|
*/
|
|
|
|
MuMsgFlags mu_msg_iter_get_flags (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the message priority
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the message priority, or MU_MSG_PRIO_NONE
|
|
|
|
*/
|
|
|
|
MuMsgPrio mu_msg_iter_get_prio (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
2011-05-03 07:18:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the references (References: and Reply-To:) as a comma-separated
|
|
|
|
* string, with the last one pointing at the parent
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return the message references, or NULL in case of error or if
|
|
|
|
* there is none
|
|
|
|
*/
|
|
|
|
const char* mu_msg_iter_get_refs (MuMsgIter *iter);
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
|
|
|
* get some message field
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
* @param field the string field to retrieve
|
|
|
|
*
|
|
|
|
* @return the field value, or NULL
|
|
|
|
*/
|
|
|
|
const gchar* mu_msg_iter_get_field (MuMsgIter *iter,
|
2010-11-20 13:43:04 +01:00
|
|
|
MuMsgFieldId mfid);
|
2010-08-25 20:40:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get some numeric message field
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
* @param field the numeric field to retrieve
|
|
|
|
*
|
|
|
|
* @return the field value, or -1 in case of error
|
|
|
|
*/
|
|
|
|
gint64 mu_msg_iter_get_field_numeric (MuMsgIter *iter,
|
2010-11-20 13:43:04 +01:00
|
|
|
MuMsgFieldId mfid);
|
2010-08-25 20:40:07 +02:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /*__MU_MSG_ITER_H__*/
|