[evolution-data-server/openismus-work: 3/5] Forward the 'requested_fields' of e_book_get_book_view() through dbus apis.



commit 708cae940dcffc06e06443c34ad4437d1606564d
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Jun 15 20:43:59 2011 +0900

    Forward the 'requested_fields' of e_book_get_book_view() through dbus apis.
    
    Create an array of strings from the passed GList and pass the array
    through the newly added parameter of the getBookView dbus api.

 addressbook/libebook/e-book.c |   47 ++++++++++++++++++++++++++++++++++------
 1 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index b747bcc..fbfac59 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -1780,6 +1780,24 @@ e_book_remove_contacts_async (EBook              *book,
 	return TRUE;
 }
 
+static gchar **
+string_array_from_list (GList *list)
+{
+	gchar **array = NULL;
+	gint    size, i;
+	GList  *l;
+
+	if (list) {
+		size = g_list_length (list);
+		array = g_new0 (gchar *, size + 1);
+
+		for (l = list, i = 0; l; l = l->next, i++)
+			array[i] = (gchar *)l->data;
+	}
+
+	return array;
+}
+
 /**
  * e_book_get_book_view:
  * @book: an #EBook
@@ -1806,17 +1824,21 @@ e_book_get_book_view (EBook       *book,
 	GError *err = NULL;
 	EGdbusBookView *gdbus_bookview;
 	gchar *sexp, *view_path;
+	gchar **fields_array = NULL;
 	gboolean ret = TRUE;
 
 	e_return_error_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
 	e_return_error_if_fail (book->priv->gdbus_book, E_BOOK_ERROR_REPOSITORY_OFFLINE);
 
-	sexp = e_book_query_to_string (query);
+	sexp         = e_book_query_to_string (query);
+	fields_array = string_array_from_list (requested_fields);
 
-	if (!e_gdbus_book_call_get_book_view_sync (book->priv->gdbus_book, sexp, max_results, &view_path, NULL, &err)) {
+	if (!e_gdbus_book_call_get_book_view_sync (book->priv->gdbus_book, sexp, 
+						   (const gchar * const *)fields_array, 
+						   max_results, &view_path, NULL, &err)) {
 		*book_view = NULL;
 		g_free (sexp);
-
+		g_free (fields_array);
 		return unwrap_gerror (err, error);
 	}
 
@@ -1838,6 +1860,7 @@ e_book_get_book_view (EBook       *book,
 
 	g_free (view_path);
 	g_free (sexp);
+	g_free (fields_array);
 
 	return ret;
 }
@@ -1911,6 +1934,7 @@ e_book_async_get_book_view (EBook                 *book,
 			    gpointer               closure)
 {
 	AsyncData *data;
+	gchar **fields_array = NULL;
 	gchar *sexp;
 
 	e_return_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
@@ -1922,11 +1946,15 @@ e_book_async_get_book_view (EBook                 *book,
 	data->callback = cb;
 	data->closure = closure;
 
-	sexp = e_book_query_to_string (query);
+	sexp         = e_book_query_to_string (query);
+	fields_array = string_array_from_list (requested_fields);
 
-	e_gdbus_book_call_get_book_view (book->priv->gdbus_book, sexp, max_results, NULL, get_book_view_reply, data);
+	e_gdbus_book_call_get_book_view (book->priv->gdbus_book, sexp,
+					 (const gchar * const *)fields_array,
+					 max_results, NULL, get_book_view_reply, data);
 
 	g_free (sexp);
+	g_free (fields_array);
 	return 0;
 }
 #endif
@@ -1956,6 +1984,7 @@ e_book_get_book_view_async (EBook                      *book,
 			    gpointer                    closure)
 {
 	AsyncData *data;
+	gchar **fields_array = NULL;
 	gchar *sexp;
 
 	e_return_ex_async_error_val_if_fail (E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
@@ -1967,11 +1996,15 @@ e_book_get_book_view_async (EBook                      *book,
 	data->excallback = cb;
 	data->closure = closure;
 
-	sexp = e_book_query_to_string (query);
+	sexp         = e_book_query_to_string (query);
+	fields_array = string_array_from_list (requested_fields);
 
-	e_gdbus_book_call_get_book_view (book->priv->gdbus_book, sexp, max_results, NULL, get_book_view_reply, data);
+	e_gdbus_book_call_get_book_view (book->priv->gdbus_book, sexp,
+					 (const gchar * const *)fields_array,
+					 max_results, NULL, get_book_view_reply, data);
 
 	g_free (sexp);
+	g_free (fields_array);
 
 	return TRUE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]