/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
gpointer data);
-#include "folder_item_prefs.h"
-
-#include "procmsg.h"
-#include "msgcache.h"
+#include "proctypes.h"
#include "xml.h"
#include "prefs_account.h"
+#include "matchertypes.h"
+
+struct _MsgCache;
struct _Folder
{
GHashTable *newsart;
};
+/**
+ * Callback used to convey progress information of a specific search.
+ *
+ * \param data User-provided data
+ * \param on_server Whether or not the current progress information originated from the
+ * server
+ * \param at Number of the last message processed
+ * \param matched Number of messages with definitive matches found so far
+ * \param total Number of messages to be processed
+ *
+ * \note
+ * Even if the mailserver does not support progress reports, an instance of this type
+ * should be invoked when serverside search starts and ends, with \c at set to \c 0 and
+ * \c total, respectively.
+ */
+typedef gboolean (*SearchProgressNotify)(gpointer data, gboolean on_server, guint at, guint matched, guint total);
+
struct _FolderClass
{
/**
* user. Can be upper and lowercase unlike the idstr.
*/
gchar *uistr;
+ /**
+ * A boolean to indicate whether or not the FolderClass supports search on the
+ * server. If \c TRUE, setting \c on_server in \c search_msgs offloads search to
+ * the server.
+ */
+ gboolean supports_server_search;
+
/* virtual functions */
FolderItem *dest,
MsgInfoList *msglist,
GHashTable *relation);
+
+ /**
+ * Search the given FolderItem for messages matching \c predicate.
+ * The search may be offloaded to the server if the \c folder
+ * supports server side search, as indicated by \c supports_server_search.
+ *
+ * \param folder The \c Folder of the container FolderItem
+ * \param container The \c FolderItem containing the messages to be searched
+ * \param msgs The \c MsgNumberList results will be saved to.
+ * If <tt>*msgs != NULL</tt>, the search will be restricted to
+ * messages whose numbers are contained therein.
+ * If \c on_server is considered \c FALSE, messages are guaranteed to
+ * be processed in the order they are listed in \c msgs.
+ * On error, \c msgs will not be changed.
+ * \param on_server Whether or not the search should be offloaded to the server.
+ * If \c on_server is not \c NULL and points to a \c TRUE value,
+ * search will be done on the server. If \c predicate contains
+ * one or more atoms the server does not support, the value
+ * pointed to by \c on_server will be set to \c FALSE upon return.
+ * In this case, \c msgs must still contain a valid superset of
+ * messages actually matched by \c predicate, or this method must
+ * return an error.
+ * \c on_server may only point to a \c TRUE value if
+ * \c supports_server_search is also \c TRUE.
+ * \c NULL and pointer to \c FALSE are considered equivalent and
+ * will start a client-only search.
+ * \param predicate The \c MatcherList to use in the search
+ * \param progress_cb Called for every message searched.
+ * When search is offloaded to the server, this function
+ * may or may not be called, depending on the implementation.
+ * The second argument of this function will be the number of
+ * messages already processed.
+ * Return \c FALSE from this function to end the search.
+ * May be \c NULL, no calls will be made in this case.
+ * \param progress_data First argument value for \c progress_cb
+ * \return Number of messages that matched \c predicate on success, a negative
+ * number otherwise.
+ *
+ * \note
+ * When search is stopped by returning \c FALSE from \c progress_cb, \c msgs will
+ * contain all messages found until the point of cancellation. The number of
+ * messages found will be returned as indicated above.
+ */
+ gint (*search_msgs) (Folder *folder,
+ FolderItem *container,
+ MsgNumberList **msgs,
+ gboolean *on_server,
+ MatcherList *predicate,
+ SearchProgressNotify progress_cb,
+ gpointer progress_data);
+
+
/**
* Remove a message from a \c FolderItem.
*
ITEM_SCANNING
};
+struct _FolderItemPrefs;
+
struct _FolderItem
{
SpecialFolderItemType stype;
gint last_num;
- MsgCache *cache;
+ struct _MsgCache *cache;
gboolean cache_dirty;
gboolean mark_dirty;
gboolean tags_dirty;
guint ret_rcpt : 1; /* return receipt */
guint search_match : 1;
guint hide_del_msgs : 1; /* hide deleted messages */
+ guint hide_read_threads : 1; /* hide threads with only read messages */
gint op_count;
guint opened : 1; /* opened by summary view */
gpointer data;
- FolderItemPrefs * prefs;
+ struct _FolderItemPrefs * prefs;
/* for faster search of special parents */
SpecialFolderItemType parent_stype;
guint hide_read_msgs : 1; /* CLAWS */
guint ret_rcpt : 1; /* CLAWS */
guint hide_del_msgs : 1; /* CLAWS */
+ guint hide_read_threads : 1;
};
struct _FolderUpdateData
gchar *folder_get_status (GPtrArray *folders,
gboolean full);
+Folder *folder_find_from_identifier (const gchar *identifier);
Folder *folder_find_from_path (const gchar *path);
Folder *folder_find_from_name (const gchar *name,
FolderClass *klass);
MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem *item,
const gchar *msgid);
GSList *folder_item_get_msg_list (FolderItem *item);
+MsgNumberList *folder_item_get_number_list(FolderItem *item);
+
/* return value is locale charset */
gchar *folder_item_fetch_msg (FolderItem *item,
gint num);
MsgInfo *msginfo);
gint folder_item_copy_msgs (FolderItem *dest,
GSList *msglist);
+gint folder_item_search_msgs (Folder *folder,
+ FolderItem *container,
+ MsgNumberList **msgs,
+ gboolean *on_server,
+ MatcherList *predicate,
+ SearchProgressNotify progress_cb,
+ gpointer progress_data);
gint folder_item_remove_msg (FolderItem *item,
gint num);
gint folder_item_remove_msgs (FolderItem *item,
void folder_item_update_thaw (void);
void folder_item_set_batch (FolderItem *item, gboolean batch);
gboolean folder_has_parent_of_type (FolderItem *item, SpecialFolderItemType type);
+gboolean folder_is_child_of (FolderItem *item, FolderItem *possibleChild);
void folder_synchronise (Folder *folder);
gboolean folder_want_synchronise (Folder *folder);
gboolean folder_subscribe (const gchar *uri);
void folder_item_discard_cache (FolderItem *item);
void folder_item_commit_tags(FolderItem *item, MsgInfo *msginfo, GSList *tags_set, GSList *tags_unset);
+
+
+gint folder_item_search_msgs_local (Folder *folder,
+ FolderItem *container,
+ MsgNumberList **msgs,
+ gboolean *on_server,
+ MatcherList *predicate,
+ SearchProgressNotify progress_cb,
+ gpointer progress_data);
+
+gchar *folder_get_list_path (void);
#endif /* __FOLDER_H__ */