+2007-06-25 Murray Cumming <murrayc@murrayc.com>
+
+ * src/dbus_api/modest-dbus-callbacks.c: (on_dbus_method_search):
+ * src/modest-search.c: (modest_search_folder),
+ (modest_search_all_accounts): Actually search only in the specified folder,
+ doing a simple match on the folder ID.
+ * src/modest-search.h: Added a folder field to the ModestSearch struct,
+ and added some documentation.
+
2007-06-22 Armin Burgmeier <armin@openismus.com>
* src/maemo/modest-maemo-utils.h:
on_dbus_method_search (DBusConnection *con, DBusMessage *message)
{
ModestDBusSearchFlags dbus_flags;
- ModestSearch search;
DBusMessage *reply = NULL;
dbus_bool_t res;
dbus_int64_t sd_v;
dbus_int64_t ed_v;
dbus_int32_t flags_v;
dbus_uint32_t size_v;
- char *folder;
- char *query;
+ const char *folder;
+ const char *query;
time_t start_date;
time_t end_date;
GList *hits;
res = dbus_message_get_args (message,
&error,
DBUS_TYPE_STRING, &query,
- DBUS_TYPE_STRING, &folder,
+ DBUS_TYPE_STRING, &folder, /* e.g. "INBOX/drafts": TODO: Use both an ID and a display name. */
DBUS_TYPE_INT64, &sd_v,
DBUS_TYPE_INT64, &ed_v,
DBUS_TYPE_INT32, &flags_v,
start_date = (time_t) sd_v;
end_date = (time_t) ed_v;
+ ModestSearch search;
memset (&search, 0, sizeof (search));
+
+ /* Remember what folder we are searching in:
+ *
+ * Note that we don't copy the strings,
+ * because this struct will only be used for the lifetime of this function.
+ */
+ search.folder = folder;
+
+ /* Remember the text to search for: */
#ifdef MODEST_HAVE_OGS
search.query = query;
#endif
+
+ /* Other criteria: */
search.before = start_date;
search.after = end_date;
search.flags = 0;
+ /* Text to serach for in various parts of the message: */
if (dbus_flags & MODEST_DBUS_SEARCH_SUBJECT) {
search.flags |= MODEST_SEARCH_SUBJECT;
search.subject = query;
* @folder: a #TnyFolder instance
* @search: a #ModestSearch query
*
- * This operation will search @folder for headers that match the query @search.
+ * This operation will search @folder for headers that match the query @search,
+ * if the folder itself matches the query.
* It will return a doubly linked list with URIs that point to the message.
**/
GList *
modest_search_folder (TnyFolder *folder, ModestSearch *search)
{
+ /* Check that we should be searching this folder. */
+ /* Note that we don't try to search sub-folders.
+ * Maybe we should, but that should be specified. */
+ if (search->folder && (strcmp (tny_folder_get_id (folder), search->folder) != 0))
+ return NULL;
+
GList *retval = NULL;
TnyIterator *iter = NULL;
TnyList *list = NULL;
GList *
modest_search_all_accounts (ModestSearch *search)
{
+ /* printf ("DEBUG: %s: query=%s\n", __FUNCTION__, search->query); */
ModestTnyAccountStore *astore;
TnyList *accounts;
TnyIterator *iter;
} ModestSearchFlags;
typedef struct {
- gchar *subject, *from, *recipient, *body;
+ const gchar *folder; /* The folder to search in */
+
+ /* Text to search for in various parts: */
+ const gchar *subject;
+ const gchar *from;
+ const gchar *recipient;
+ const gchar *body;
+
+ /* Other criteria: */
time_t before, after;
guint32 minsize;
ModestSearchFlags flags;
#ifdef MODEST_HAVE_OGS
- const gchar *query;
+ const gchar *query; /* The text to search for. */
OgsTextSearcher *text_searcher;
#endif
} ModestSearch;