diff options
author | Chris Toshok <toshok@ximian.com> | 2001-07-19 05:24:26 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-07-19 05:24:26 +0800 |
commit | a5ae0cd4770257bd7fae678f46396d4248460e85 (patch) | |
tree | c845cf6d531ac0733247b84c279deb364aac210d /addressbook/backend | |
parent | 6142029e7eabd1b78cc3cc477484f26477627c63 (diff) | |
download | gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar.gz gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar.bz2 gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar.lz gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar.xz gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.tar.zst gsoc2013-evolution-a5ae0cd4770257bd7fae678f46396d4248460e85.zip |
prune the list of cards that match our query using the avoid list here,
2001-07-18 Chris Toshok <toshok@ximian.com>
* backend/ebook/e-card-compare.c (simple_query_cb): prune the list
of cards that match our query using the avoid list here, instead
of using the avoid list in the query itself, since ldap can't
handle that.
(use_common_book_cb): remove the block of code including the avoid
list in the query sent to wombat.
svn path=/trunk/; revision=11211
Diffstat (limited to 'addressbook/backend')
-rw-r--r-- | addressbook/backend/ebook/e-card-compare.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/addressbook/backend/ebook/e-card-compare.c b/addressbook/backend/ebook/e-card-compare.c index d4aa89c4cc..19352e4755 100644 --- a/addressbook/backend/ebook/e-card-compare.c +++ b/addressbook/backend/ebook/e-card-compare.c @@ -364,6 +364,7 @@ simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, MatchSearchInfo *info = (MatchSearchInfo *) closure; ECardMatchType best_match = E_CARD_MATCH_NONE; ECard *best_card = NULL; + GList *remaining_cards = NULL; const GList *i; if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) { @@ -372,8 +373,25 @@ simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, return; } + /* remove the cards we're to avoid from the list, if they're present */ for (i = cards; i != NULL; i = g_list_next (i)) { ECard *this_card = E_CARD (i->data); + GList *iterator; + gboolean avoid = FALSE; + for (iterator = info->avoid; iterator; iterator = iterator->next) { + if (!strcmp (e_card_get_id (iterator->data), e_card_get_id (this_card))) { + avoid = TRUE; + break; + } + } + if (!avoid) + remaining_cards = g_list_prepend (remaining_cards, this_card); + } + + remaining_cards = g_list_reverse (remaining_cards); + + for (i = remaining_cards; i != NULL; i = g_list_next (i)) { + ECard *this_card = E_CARD (i->data); ECardMatchType this_match = e_card_compare (info->card, this_card); if ((gint)this_match > (gint)best_match) { best_match = this_match; @@ -381,6 +399,8 @@ simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, } } + g_list_free (remaining_cards); + info->cb (info->card, best_card, best_match, info->closure); match_search_info_free (info); } @@ -450,23 +470,6 @@ use_common_book_cb (EBook *book, gpointer closure) query = qj; } - if (info->avoid) { - GList *iterator; - p = 0; - query_parts[p++] = query; - for (iterator = info->avoid; iterator; iterator = iterator->next) { - query_parts[p++] = g_strdup_printf("(not (is \"id\" \"%s\"))", e_card_get_id (iterator->data)); - } - query_parts[p] = 0; - qj = g_strjoinv (" ", query_parts); - for(i = 0; query_parts[i] != NULL; i++) - g_free(query_parts[i]); - query = g_strdup_printf ("(and %s)", qj); - g_list_foreach (info->avoid, (GFunc) gtk_object_unref, NULL); - g_list_free (info->avoid); - info->avoid = NULL; - } - e_book_simple_query (book, query, simple_query_cb, info); g_free (query); |