From f7d9f635db0b3375f31bfa8d7984032dad87c5d1 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 18 Oct 2001 19:20:44 +0000 Subject: Added. Check if our book is local or networked. 2001-10-18 Jon Trowbridge * gui/component/select-names/e-select-names-completion.c (check_capabilities): Added. Check if our book is local or networked. (e_select_names_completion_book_ready): Call check_capabilities. (e_select_names_completion_new): Call check_capabilities. (e_select_names_completion_do_query): If we have a networked book, keep trying if we haven't been able to cache any cards --- our earlier attempts could have failed due to too many matches. (Bug #12932) svn path=/trunk/; revision=13762 --- .../component/select-names/e-select-names-completion.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index 7f4a89af54..403173caa8 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -65,6 +65,8 @@ struct _ESelectNamesCompletionPrivate { gboolean match_contact_lists; gboolean primary_only; + + gboolean can_fail_due_to_too_many_hits; /* like LDAP, for example... */ }; static void e_select_names_completion_class_init (ESelectNamesCompletionClass *); @@ -967,6 +969,7 @@ e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *q fprintf (out, "cached: %s\n", comp->priv->cached_query_text); can_reuse_cached_cards = (comp->priv->cached_query_text + && (!comp->priv->can_fail_due_to_too_many_hits || comp->priv->cached_cards != NULL) && (strlen (comp->priv->cached_query_text) <= strlen (clean)) && !g_utf8_strncasecmp (comp->priv->cached_query_text, clean, strlen (comp->priv->cached_query_text))); @@ -1110,6 +1113,14 @@ e_select_names_completion_cancel (ECompletion *comp) fprintf (out, "completion cancelled\n"); } +static void +check_capabilities (ESelectNamesCompletion *comp, EBook *book) +{ + gchar *cap = e_book_get_static_capabilities (book); + comp->priv->can_fail_due_to_too_many_hits = !strcmp (cap, "net"); + g_free (cap); +} + static void e_select_names_completion_book_ready (EBook *book, EBookStatus status, ESelectNamesCompletion *comp) { @@ -1118,6 +1129,8 @@ e_select_names_completion_book_ready (EBook *book, EBookStatus status, ESelectNa g_return_if_fail (E_IS_BOOK (book)); g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); + check_capabilities (comp, book); + /* If waiting_query is non-NULL, someone tried to start a query before the book was ready. Now that it is, get started. */ if (comp->priv->waiting_query) { @@ -1163,6 +1176,8 @@ e_select_names_completion_new (EBook *book, ESelectNamesModel *model) gtk_object_ref (GTK_OBJECT (comp->priv->book)); comp->priv->book_ready = TRUE; + check_capabilities (comp, book); + } comp->priv->model = model; -- cgit v1.2.3