2010-08-25 20:40:07 +02:00
|
|
|
/*
|
2013-03-30 10:32:07 +01:00
|
|
|
** Copyright (C) 2008-2013 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.
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2011-05-01 14:00:28 +02:00
|
|
|
*/
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
struct _MuMsgIter;
|
|
|
|
typedef struct _MuMsgIter MuMsgIter;
|
|
|
|
|
2011-05-18 22:51:52 +02:00
|
|
|
|
2012-12-16 13:17:58 +01:00
|
|
|
enum _MuMsgIterFlags {
|
2012-12-16 14:08:03 +01:00
|
|
|
MU_MSG_ITER_FLAG_NONE = 0,
|
|
|
|
/* sort Z->A (only for threads) */
|
2012-12-25 16:32:43 +01:00
|
|
|
MU_MSG_ITER_FLAG_DESCENDING = 1 << 0,
|
2012-12-16 13:17:58 +01:00
|
|
|
/* ignore results for which there is no existing
|
|
|
|
* readable message-file? */
|
2012-12-25 16:32:43 +01:00
|
|
|
MU_MSG_ITER_FLAG_SKIP_UNREADABLE = 1 << 1,
|
2012-12-17 21:29:39 +01:00
|
|
|
/* ignore duplicate messages? */
|
2012-12-27 10:07:52 +01:00
|
|
|
MU_MSG_ITER_FLAG_SKIP_DUPS = 1 << 2,
|
|
|
|
/* calculate threads? */
|
|
|
|
MU_MSG_ITER_FLAG_THREADS = 1 << 3
|
2012-12-16 13:17:58 +01:00
|
|
|
};
|
|
|
|
typedef unsigned MuMsgIterFlags;
|
|
|
|
|
2011-05-18 22:51:52 +02:00
|
|
|
/**
|
|
|
|
* create a new MuMsgIter -- basically, an iterator over the search
|
|
|
|
* results
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2011-05-18 22:51:52 +02:00
|
|
|
* @param enq a Xapian::Enquire* cast to XapianEnquire* (because this
|
|
|
|
* is C, not C++),providing access to search results
|
2012-12-16 13:17:58 +01:00
|
|
|
* @param maxnum the maximum number of results
|
2012-12-25 16:32:43 +01:00
|
|
|
* @param sortfield field to sort by
|
2012-12-16 13:17:58 +01:00
|
|
|
* @param flags flags for this iterator (see MsgIterFlags)
|
|
|
|
|
|
|
|
* @param err receives error information. if the error is
|
|
|
|
* MU_ERROR_XAPIAN_MODIFIED, the database should be reloaded.
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2011-05-18 22:51:52 +02:00
|
|
|
* @return a new MuMsgIter, or NULL in case of error
|
|
|
|
*/
|
|
|
|
MuMsgIter *mu_msg_iter_new (XapianEnquire *enq,
|
2012-12-16 13:17:58 +01:00
|
|
|
size_t maxnum,
|
2012-12-25 16:32:43 +01:00
|
|
|
MuMsgFieldId sortfield,
|
2012-12-16 13:17:58 +01:00
|
|
|
MuMsgIterFlags flags,
|
2012-08-19 08:57:49 +02:00
|
|
|
GError **err) G_GNUC_WARN_UNUSED_RESULT;
|
2011-05-18 22:51:52 +02:00
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
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)
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2010-08-25 20:40:07 +02:00
|
|
|
* @param iter a valid MuMsgIter iterator
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2010-08-25 20:40:07 +02:00
|
|
|
* @return TRUE if it succeeded, FALSE otherwise (e.g., because there
|
|
|
|
* are no more messages in the query result)
|
|
|
|
*/
|
2012-07-12 14:47:11 +02:00
|
|
|
gboolean mu_msg_iter_next (MuMsgIter *iter);
|
2010-08-25 20:40:07 +02:00
|
|
|
|
2018-11-11 11:11:06 +01:00
|
|
|
/**
|
|
|
|
* Does this iterator point to the first item?
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return TRUE or FALSE
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_iter_is_first (MuMsgIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this iterator point to the last item?
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return TRUE or FALSE
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_iter_is_last (MuMsgIter *iter);
|
|
|
|
|
2011-06-02 17:13:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* reset the iterator to the beginning
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2011-06-02 17:13:17 +02:00
|
|
|
* @param iter a valid MuMsgIter iterator
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2011-06-02 17:13:17 +02:00
|
|
|
* @return TRUE if it succeeded, FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_iter_reset (MuMsgIter *iter);
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
2010-09-08 23:09:00 +02:00
|
|
|
* does this iterator point past the end of the list?
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2010-08-25 20:40:07 +02:00
|
|
|
* @param iter a valid MuMsgIter iterator
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
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
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2010-08-25 20:40:07 +02:00
|
|
|
* @param msg a valid MuMsgIter message or NULL
|
|
|
|
*/
|
|
|
|
void mu_msg_iter_destroy (MuMsgIter *iter);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-05-18 23:26:14 +02:00
|
|
|
* get the corresponding MuMsg for this iter; this instance is owned
|
|
|
|
* by MuMsgIter, and becomes invalid after either mu_msg_iter_destroy
|
2011-08-30 21:01:30 +02:00
|
|
|
* or mu_msg_iter_next. _do not_ unref it; it's a floating reference.
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter instance*
|
|
|
|
*
|
2011-05-18 23:26:14 +02:00
|
|
|
* @return a MuMsg instance, or NULL in case of error
|
2010-08-25 20:40:07 +02:00
|
|
|
*/
|
2011-08-30 21:01:30 +02:00
|
|
|
MuMsg* mu_msg_iter_get_msg_floating (MuMsgIter *iter)
|
2011-05-18 23:26:14 +02:00
|
|
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
2011-03-21 00:55:11 +01:00
|
|
|
|
2012-12-28 13:48:00 +01:00
|
|
|
/**
|
|
|
|
* Provide a preferred_hash, which is a hashtable msgid->docid to
|
|
|
|
* indicate the messages which should /not/ be seen as duplicates.
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
* @param preferred_hash a hashtable msgid->docid of message /not/ to
|
|
|
|
* mark as duplicates, or NULL
|
|
|
|
*/
|
|
|
|
void mu_msg_iter_set_preferred (MuMsgIter *iter, GHashTable *preferred_hash);
|
|
|
|
|
2010-08-25 20:40:07 +02:00
|
|
|
/**
|
|
|
|
* get the document id for the current message
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
2010-08-25 20:40:07 +02:00
|
|
|
* @param iter a valid MuMsgIter iterator
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
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
|
|
|
*/
|
2015-03-05 23:12:34 +01:00
|
|
|
guint mu_msg_iter_get_docid (MuMsgIter *iter);
|
2010-08-25 20:40:07 +02:00
|
|
|
|
|
|
|
|
2011-06-19 20:04:40 +02:00
|
|
|
/**
|
|
|
|
* calculate the message threads
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2019-11-06 16:13:39 +01:00
|
|
|
* @return TRUE if it worked, FALSE otherwise.
|
2011-06-19 20:04:40 +02:00
|
|
|
*/
|
|
|
|
gboolean mu_msg_iter_calculate_threads (MuMsgIter *iter);
|
|
|
|
|
2011-06-18 17:47:46 +02:00
|
|
|
|
2011-06-23 23:21:54 +02:00
|
|
|
enum _MuMsgIterThreadProp {
|
2013-06-13 22:56:35 +02:00
|
|
|
MU_MSG_ITER_THREAD_PROP_NONE = 0 << 0,
|
|
|
|
|
2011-06-23 23:21:54 +02:00
|
|
|
MU_MSG_ITER_THREAD_PROP_ROOT = 1 << 0,
|
|
|
|
MU_MSG_ITER_THREAD_PROP_FIRST_CHILD = 1 << 1,
|
2018-04-22 07:18:57 +02:00
|
|
|
MU_MSG_ITER_THREAD_PROP_LAST_CHILD = 1 << 2,
|
|
|
|
MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT = 1 << 3,
|
|
|
|
MU_MSG_ITER_THREAD_PROP_DUP = 1 << 4,
|
|
|
|
MU_MSG_ITER_THREAD_PROP_HAS_CHILD = 1 << 5
|
2011-06-23 23:21:54 +02:00
|
|
|
};
|
|
|
|
typedef guint8 MuMsgIterThreadProp;
|
|
|
|
|
|
|
|
struct _MuMsgIterThreadInfo {
|
2019-11-06 16:13:39 +01:00
|
|
|
gchar *threadpath; /* a string describing the thread-path in
|
2011-11-20 00:20:38 +01:00
|
|
|
* such a way that we can sort by this
|
|
|
|
* string to get the right order. */
|
|
|
|
guint level; /* thread-depth -- [0...] */
|
2011-06-23 23:21:54 +02:00
|
|
|
MuMsgIterThreadProp prop;
|
|
|
|
};
|
|
|
|
typedef struct _MuMsgIterThreadInfo MuMsgIterThreadInfo;
|
|
|
|
|
2011-06-19 20:04:40 +02:00
|
|
|
/**
|
2011-07-01 19:52:09 +02:00
|
|
|
* get a the MuMsgThreaderInfo struct for this message; this only
|
|
|
|
* works when you created the mu-msg-iter with threading enabled
|
2013-03-16 17:25:19 +01:00
|
|
|
* (otherwise, return NULL)
|
2011-08-30 21:01:30 +02:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2011-06-23 23:21:54 +02:00
|
|
|
* @return an info struct
|
2011-06-19 20:04:40 +02:00
|
|
|
*/
|
2011-06-23 23:21:54 +02:00
|
|
|
const MuMsgIterThreadInfo* mu_msg_iter_get_thread_info (MuMsgIter *iter);
|
2011-06-18 17:47:46 +02:00
|
|
|
|
2012-12-24 13:59:48 +01:00
|
|
|
/**
|
2012-12-25 16:32:43 +01:00
|
|
|
* get the message-id for this message
|
2012-12-24 13:59:48 +01:00
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2015-03-05 23:12:34 +01:00
|
|
|
* @return the message-id; free with g_free().
|
2012-12-24 13:59:48 +01:00
|
|
|
*/
|
2015-03-05 23:12:34 +01:00
|
|
|
char* mu_msg_iter_get_msgid (MuMsgIter *iter)
|
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2012-12-24 13:59:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the list of references for this messages as a NULL-terminated
|
|
|
|
* string array
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
|
|
|
* @return a NULL-terminated string array. free with g_strfreev when
|
|
|
|
* it's no longer needed.
|
|
|
|
*/
|
2015-03-05 23:12:34 +01:00
|
|
|
char** mu_msg_iter_get_refs (MuMsgIter *iter)
|
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2012-12-24 13:59:48 +01:00
|
|
|
|
|
|
|
|
2012-12-25 16:32:43 +01:00
|
|
|
/**
|
|
|
|
* get the thread-id for this message
|
|
|
|
*
|
|
|
|
* @param iter a valid MuMsgIter iterator
|
|
|
|
*
|
2015-03-05 23:12:34 +01:00
|
|
|
* @return the thread-id; free with g_free().
|
2012-12-25 16:32:43 +01:00
|
|
|
*/
|
2015-03-05 23:12:34 +01:00
|
|
|
char* mu_msg_iter_get_thread_id (MuMsgIter *iter)
|
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2012-12-24 13:59:48 +01:00
|
|
|
|
|
|
|
|
2011-08-30 21:01:30 +02:00
|
|
|
/* FIXME */
|
|
|
|
const char* mu_msg_iter_get_path (MuMsgIter *iter);
|
2010-08-25 20:40:07 +02:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /*__MU_MSG_ITER_H__*/
|