* refactor: add mu_msg_iter_xapian_get_msg_gmime and use it
This commit is contained in:
@ -119,16 +119,10 @@ sort_field_from_string (const char* fieldstr)
|
|||||||
static void
|
static void
|
||||||
print_summary (MuMsgIterXapian *iter, size_t summary_len)
|
print_summary (MuMsgIterXapian *iter, size_t summary_len)
|
||||||
{
|
{
|
||||||
const char *path, *summ;
|
const char *summ;
|
||||||
MuMsgGMime *msg;
|
MuMsgGMime *msg;
|
||||||
|
|
||||||
path = mu_msg_iter_xapian_get_path (iter);
|
msg = mu_msg_iter_xapian_get_msg_gmime (iter);
|
||||||
if (!path) {
|
|
||||||
g_warning ("%s: no path for message", __FUNCTION__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = mu_msg_gmime_new (path, NULL);
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
g_warning ("%s: failed to create msg object", __FUNCTION__);
|
g_warning ("%s: failed to create msg object", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -63,6 +63,7 @@ mu_msg_iter_xapian_new (const Xapian::Enquire& enq, size_t batchsize)
|
|||||||
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
|
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_msg_iter_xapian_destroy (MuMsgIterXapian *iter)
|
mu_msg_iter_xapian_destroy (MuMsgIterXapian *iter)
|
||||||
{
|
{
|
||||||
@ -78,6 +79,31 @@ mu_msg_iter_xapian_destroy (MuMsgIterXapian *iter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MuMsgGMime*
|
||||||
|
mu_msg_iter_xapian_get_msg_gmime (MuMsgIterXapian *iter)
|
||||||
|
{
|
||||||
|
const char *path;
|
||||||
|
MuMsgGMime *msg;
|
||||||
|
|
||||||
|
g_return_val_if_fail (iter, NULL);
|
||||||
|
|
||||||
|
path = mu_msg_iter_xapian_get_path (iter);
|
||||||
|
if (!path) {
|
||||||
|
g_warning ("%s: no path for message", __FUNCTION__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = mu_msg_gmime_new (path, NULL);
|
||||||
|
if (!msg) {
|
||||||
|
g_warning ("%s: failed to create msg object", __FUNCTION__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
message_is_readable (MuMsgIterXapian *iter)
|
message_is_readable (MuMsgIterXapian *iter)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#define __MU_MSG_ITER_XAPIAN_H__
|
#define __MU_MSG_ITER_XAPIAN_H__
|
||||||
|
|
||||||
#include "mu-msg.h"
|
#include "mu-msg.h"
|
||||||
|
#include "mu-msg-gmime.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ typedef struct _MuMsgIterXapian MuMsgIterXapian;
|
|||||||
* get the next next message (which you got from
|
* get the next next message (which you got from
|
||||||
* e.g. mu_query_xapian_run)
|
* e.g. mu_query_xapian_run)
|
||||||
*
|
*
|
||||||
* @param msg a valid MuMsgIterXapian message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return TRUE if it succeeded, FALSE otherwise (e.g., because there
|
* @return TRUE if it succeeded, FALSE otherwise (e.g., because there
|
||||||
* are no more messages in the query result)
|
* are no more messages in the query result)
|
||||||
@ -43,23 +44,36 @@ gboolean mu_msg_iter_xapian_next (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* does the iter point to a real message?
|
* does the iter point to a real message?
|
||||||
*
|
*
|
||||||
* @param msg a valid MuMsgIterXapian iter
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return TRUE if the iterator points to a message, FALSE other
|
* @return TRUE if the iterator points to a message, FALSE other
|
||||||
*/
|
*/
|
||||||
gboolean mu_msg_iter_xapian_is_null (MuMsgIterXapian *iter);
|
gboolean mu_msg_iter_xapian_is_null (MuMsgIterXapian *iter);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy the sequence of messages
|
* destroy the sequence of messages; ie. /all/ of them
|
||||||
*
|
*
|
||||||
* @param msg a valid MuMsgIterXapian message or NULL
|
* @param msg a valid MuMsgIterXapian message or NULL
|
||||||
*/
|
*/
|
||||||
void mu_msg_iter_xapian_destroy (MuMsgIterXapian *iter);
|
void mu_msg_iter_xapian_destroy (MuMsgIterXapian *iter);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the corresponding GMime message for this iter; this requires
|
||||||
|
* the corresponding message file to be present at the expected place
|
||||||
|
*
|
||||||
|
* @param iter a valid MuMsgIterXapian instance
|
||||||
|
*
|
||||||
|
* @return a MuMsgGMime instance, or NULL in case of error. Use
|
||||||
|
* mu_msg_gmime_destroy when the instance is no longer needed
|
||||||
|
*/
|
||||||
|
MuMsgGMime* mu_msg_iter_xapian_get_msg_gmime (MuMsgIterXapian *iter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the document id for the current message
|
* get the document id for the current message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the docid or 0 in case of error
|
* @return the docid or 0 in case of error
|
||||||
*/
|
*/
|
||||||
@ -69,7 +83,7 @@ unsigned int mu_msg_iter_xapian_get_docid (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the directory path of the message
|
* get the directory path of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the path, or NULL in case of error
|
* @return the path, or NULL in case of error
|
||||||
*/
|
*/
|
||||||
@ -79,7 +93,7 @@ const char* mu_msg_iter_xapian_get_path (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the size of the message
|
* get the size of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the size, or 0 in case of error
|
* @return the size, or 0 in case of error
|
||||||
*/
|
*/
|
||||||
@ -88,7 +102,7 @@ size_t mu_msg_iter_xapian_get_size (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the timestamp (ctime) of the message file
|
* get the timestamp (ctime) of the message file
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the size, or 0 in case of error
|
* @return the size, or 0 in case of error
|
||||||
*/
|
*/
|
||||||
@ -97,7 +111,7 @@ time_t mu_msg_iter_xapian_get_timestamp (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the sent time of the message
|
* get the sent time of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the time, or 0 in case of error
|
* @return the time, or 0 in case of error
|
||||||
*/
|
*/
|
||||||
@ -106,7 +120,7 @@ time_t mu_msg_iter_xapian_get_date (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the message sender(s) of the message
|
* get the message sender(s) of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the time, or 0 in case of error
|
* @return the time, or 0 in case of error
|
||||||
*/
|
*/
|
||||||
@ -115,7 +129,7 @@ const char* mu_msg_iter_xapian_get_from (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the message recipient (To:) of the message
|
* get the message recipient (To:) of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the To-recipient(s), or NULL in case of error
|
* @return the To-recipient(s), or NULL in case of error
|
||||||
*/
|
*/
|
||||||
@ -125,7 +139,7 @@ const char* mu_msg_iter_xapian_get_to (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the message recipient (Cc:) of the message
|
* get the message recipient (Cc:) of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the Cc-recipient(s), or NULL in case of error
|
* @return the Cc-recipient(s), or NULL in case of error
|
||||||
*/
|
*/
|
||||||
@ -134,7 +148,7 @@ const char* mu_msg_iter_xapian_get_cc (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the subject of the message
|
* get the subject of the message
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the subject, or NULL in case of error
|
* @return the subject, or NULL in case of error
|
||||||
*/
|
*/
|
||||||
@ -143,7 +157,7 @@ const char* mu_msg_iter_xapian_get_subject (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the message flags
|
* get the message flags
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the message flags, or MU_MSG_FLAG_UNKNOWN
|
* @return the message flags, or MU_MSG_FLAG_UNKNOWN
|
||||||
*/
|
*/
|
||||||
@ -153,7 +167,7 @@ MuMsgFlags mu_msg_iter_xapian_get_flags (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get the message priority
|
* get the message priority
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
*
|
*
|
||||||
* @return the message priority, or MU_MSG_PRIORITY_NONE
|
* @return the message priority, or MU_MSG_PRIORITY_NONE
|
||||||
*/
|
*/
|
||||||
@ -163,7 +177,7 @@ MuMsgPriority mu_msg_iter_xapian_get_priority (MuMsgIterXapian *iter);
|
|||||||
/**
|
/**
|
||||||
* get some message field
|
* get some message field
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
* @param field the string field to retrieve
|
* @param field the string field to retrieve
|
||||||
*
|
*
|
||||||
* @return the field value, or NULL
|
* @return the field value, or NULL
|
||||||
@ -174,7 +188,7 @@ const gchar* mu_msg_iter_xapian_get_field (MuMsgIterXapian *iter,
|
|||||||
/**
|
/**
|
||||||
* get some numeric message field
|
* get some numeric message field
|
||||||
*
|
*
|
||||||
* @param iter a message
|
* @param iter a valid MuMsgIterXapian iterator
|
||||||
* @param field the numeric field to retrieve
|
* @param field the numeric field to retrieve
|
||||||
*
|
*
|
||||||
* @return the field value, or -1 in case of error
|
* @return the field value, or -1 in case of error
|
||||||
|
|||||||
Reference in New Issue
Block a user