X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-search.c;h=726715c170196f5e52b1c8d8ccd3848f4d9a124d;hb=ea4ea3a0785d1f668a3d898d6bac8e47720b0927;hp=89914a709ee39c1f98acf4a27534db27e2dc6da4;hpb=bccb0e89564f2c643d457c2e68a61f6ca788e969;p=modest diff --git a/src/modest-search.c b/src/modest-search.c index 89914a7..726715c 100644 --- a/src/modest-search.c +++ b/src/modest-search.c @@ -1,3 +1,32 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -24,10 +53,10 @@ #include "modest-search.h" #include "modest-runtime.h" -static char * -g_strdup_or_null (const char *str) +static gchar * +g_strdup_or_null (const gchar *str) { - char *string = NULL; + gchar *string = NULL; if (str != NULL) { string = g_strdup (str); @@ -50,8 +79,21 @@ add_hit (GList *list, TnyHeader *header, TnyFolder *folder) hit = g_slice_new0 (ModestSearchHit); furl = tny_folder_get_url_string (folder); + if (!furl) { + g_warning ("%s: tny_folder_get_url_string(): returned NULL for folder. Folder name=%s\n", __FUNCTION__, tny_folder_get_name (folder)); + } + + /* Make sure that we use the short UID instead of the long UID, + * and/or find out what UID form is used when finding, in camel_data_cache_get(). + * so we can find what we get. Philip is working on this. + */ uid = tny_header_get_uid (header); + if (!furl) { + g_warning ("%s: tny_header_get_uid(): returned NULL for message with subject=%s\n", __FUNCTION__, tny_header_get_subject (header)); + } + msg_url = g_strdup_printf ("%s/%s", furl, uid); + subject = tny_header_get_subject (header); sender = tny_header_get_from (header); @@ -60,12 +102,12 @@ add_hit (GList *list, TnyHeader *header, TnyFolder *folder) hit->msgid = msg_url; hit->subject = g_strdup_or_null (subject); hit->sender = g_strdup_or_null (sender); - hit->folder = furl; + hit->folder = furl; /* We just provide our new instance instead of copying it and freeing it. */ 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); - + return g_list_prepend (list, hit); } @@ -147,7 +189,7 @@ search_mime_part_ogs (TnyMimePart *part, ModestSearch *search) return found; } -#endif +#endif /*MODEST_HAVE_OGS*/ static gboolean search_mime_part_strcmp (TnyMimePart *part, ModestSearch *search) @@ -155,8 +197,8 @@ search_mime_part_strcmp (TnyMimePart *part, ModestSearch *search) TnyStream *stream; char buffer[8193]; char *chunk[2]; - gsize len; - gssize nread; + gssize len; + gsize nread; gboolean found; gboolean res; @@ -318,11 +360,12 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search) } if (!found && search->flags & MODEST_SEARCH_SENDER) { - const char *str = tny_header_get_from (cur); + char *str = g_strdup (tny_header_get_from (cur)); - if ((found = search_string (search->from, str, search))) { + if ((found = search_string (search->from, (const gchar *) str, search))) { retval = add_hit (retval, cur, folder); } + g_free (str); } if (!found && search->flags & MODEST_SEARCH_RECIPIENT) { @@ -349,7 +392,7 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search) msg = tny_folder_get_msg (folder, cur, &err); if (err != NULL || msg == NULL) { - g_warning ("Could not get message\n"); + g_warning ("%s: Could not get message.\n", __FUNCTION__); g_error_free (err); if (msg) { @@ -460,8 +503,8 @@ modest_search_all_accounts (ModestSearch *search) account = TNY_ACCOUNT (tny_iterator_get_current (iter)); - g_debug ("Searching account %s", - tny_account_get_name (account)); + g_debug ("DEBUG: %s: Searching account %s", + __FUNCTION__, tny_account_get_name (account)); res = modest_search_account (account, search); if (res != NULL) { @@ -478,6 +521,7 @@ modest_search_all_accounts (ModestSearch *search) } g_object_unref (accounts); + g_object_unref (iter); return hits; }