From 4dd479982d0fe583a3266205ca6423c0e063a319 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Tue, 1 Dec 2009 15:34:10 -0500
Subject: [PATCH] [#2467] Search for string longer than 3 fasten addressbook
 queries

---
 .../src/contacts/addressbook.c                | 39 +++++++++++--------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/sflphone-client-gnome/src/contacts/addressbook.c b/sflphone-client-gnome/src/contacts/addressbook.c
index 60557d04f6..d9b987c634 100644
--- a/sflphone-client-gnome/src/contacts/addressbook.c
+++ b/sflphone-client-gnome/src/contacts/addressbook.c
@@ -32,17 +32,21 @@ void
 addressbook_search(GtkEntry* entry)
 {
 
-  AddressBook_Config *addressbook_config;
+    gchar* query = gtk_entry_get_text(GTK_ENTRY (entry));
+    if (strlen(query) >= 3) {
 
-  // Activate waiting layer
-  activateWaitingLayer();
+        AddressBook_Config *addressbook_config;
+	
+	// Activate waiting layer
+	activateWaitingLayer();
 
-  // Load the address book parameters
-  addressbook_config_load_parameters(&addressbook_config);
+	// Load the address book parameters
+	addressbook_config_load_parameters(&addressbook_config);
+      
+	// Start the asynchronous search as soon as we have an entry */
+	search_async(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
 
-  // Start the asynchronous search as soon as we have an entry */
-  search_async(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search,
-      addressbook_config);
+    }
 }
 
 /**
@@ -84,6 +88,7 @@ addressbook_is_active()
 static void
 addressbook_config_books()
 {
+
   gchar **config_book_uid;
   book_data_t *book_data;
   gchar **list;
@@ -91,21 +96,21 @@ addressbook_config_books()
   // Retrieve list of books
   list = (gchar **) dbus_get_addressbook_list();
 
-  if (list)
-    {
-      for (config_book_uid = list; *config_book_uid; config_book_uid++)
-        {
+  if (list) {
+
+      for (config_book_uid = list; *config_book_uid; config_book_uid++) {
+
           // Get corresponding book data
           book_data = books_get_book_data_by_uid(*config_book_uid);
 
           // If book_data exists
-          if (book_data != NULL)
-            {
+          if (book_data != NULL) {
+
               book_data->active = TRUE;
-            }
-        }
+	  }
+      }
       g_strfreev(list);
-    }
+  }
 
   // Update buttons
   update_actions ();
-- 
GitLab