X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-search.c;h=32f387f49e8e348da8cc7cb8306452e56541932f;hb=7cf7d40552d4509091984e1d647a4983a3205fe4;hp=3ed4ed6bf2abb18a0ccf3107b1b71d219ed29217;hpb=7303a1091352b0745cad4f59ca0ff193c616cf99;p=modest diff --git a/src/modest-search.c b/src/modest-search.c index 3ed4ed6..32f387f 100644 --- a/src/modest-search.c +++ b/src/modest-search.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include @@ -50,8 +52,10 @@ #include "modest-account-mgr.h" #include "modest-tny-account-store.h" #include "modest-tny-account.h" +#include "modest-tny-folder.h" #include "modest-search.h" #include "modest-runtime.h" +#include "modest-platform.h" static gchar * g_strdup_or_null (const gchar *str) @@ -65,7 +69,6 @@ g_strdup_or_null (const gchar *str) return string; } - static GList* add_hit (GList *list, TnyHeader *header, TnyFolder *folder) { @@ -109,7 +112,7 @@ add_hit (GList *list, TnyHeader *header, TnyFolder *folder) hit->msize = tny_header_get_message_size (header); hit->has_attachment = flags & TNY_HEADER_FLAG_ATTACHMENTS; hit->is_unread = ! (flags & TNY_HEADER_FLAG_SEEN); - hit->timestamp = tny_header_get_date_received (header); + hit->timestamp = MIN (tny_header_get_date_received (header), tny_header_get_date_sent (header)); return g_list_prepend (list, hit); } @@ -295,7 +298,7 @@ search_mime_part_strcmp (TnyMimePart *part, ModestSearch *search) buffer, TRUE); - if (found) { + if ((found)||(nread == 0)) { break; } @@ -386,8 +389,15 @@ 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 && strlen (search->folder) && (strcmp (tny_folder_get_id (folder), search->folder) != 0)) - return NULL; + if (search->folder && strlen (search->folder)) { + if (!strcmp (search->folder, "outbox")) { + if (modest_tny_folder_guess_folder_type (folder) != TNY_FOLDER_TYPE_OUTBOX) { + return NULL; + } + } else if (strcmp (tny_folder_get_id (folder), search->folder) != 0) { + return NULL; + } + } GList *retval = NULL; TnyIterator *iter = NULL; @@ -428,11 +438,11 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search) goto go_next; if (search->flags & MODEST_SEARCH_BEFORE) - if (!(t <= search->before)) + if (!(t <= search->end_date)) goto go_next; if (search->flags & MODEST_SEARCH_AFTER) - if (!(t >= search->after)) + if (!(t >= search->start_date)) goto go_next; if (search->flags & MODEST_SEARCH_SIZE) @@ -588,6 +598,13 @@ modest_search_all_accounts (ModestSearch *search) if (account) { /* g_debug ("DEBUG: %s: Searching account %s", __FUNCTION__, tny_account_get_name (account)); */ + + /* Give the account time to go online if necessary, + * for instance if this is immediately after startup, + * after D-Bus activation: */ + modest_platform_check_and_wait_for_account_is_online (account); + + /* Search: */ res = modest_search_account (account, search); if (res != NULL) {