Re: [Evolution-hackers] ebook API



On Sat, 2003-12-13 at 22:40, Chris Toshok wrote:
> > > > e_book_async_get_book_view(...) doesn't allow me to specify the maximum
> > > > number of records, whereas e_book_get_book_view(...) does.  Should the
> > > > async version be extended to take the extra argument?  This looks like a
> > > > trivial patch to me.

> > > Yeah, that was basically laziness on my part.  I didn't expect many
> > > people (anyone, really) to use the async api so I figured it'd be less
> > > work to not change the parameters from the old get_book_view ebook call.

> > Would you accept a patch to change this?
> absolutely.

Attached.  The only problem with this patch is that is doesn't clone the
list or anything.  I guess it should g_list_copy the requested_fields
parameter, or maybe do a deep-copy.  It's a shame you can't refcount a
GList... 

I've also changed e_book_query_ref() so that it returns the object (same
as g_object_ref).

I think I've extracted the relevant changes from my diffs :) I really
should poke someone again about the patches I've got locally. Hopefully
after the holidays...

Ross
-- 
Ross Burton                                 mail: ross burtonini com
                                          jabber: ross burtonini com
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF
Index: e-book-async.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-async.c,v
retrieving revision 1.3
diff -u -r1.3 e-book-async.c
--- e-book-async.c	1 Dec 2003 06:49:54 -0000	1.3
+++ e-book-async.c	15 Dec 2003 11:22:38 -0000
@@ -970,6 +970,8 @@
 
 	EBook *book;
 	EBookQuery *query;
+	GList *requested_fields;
+	int max_results;
 	EBookBookViewCallback cb;
 	gpointer closure;
 } GetBookViewMsg;
@@ -1014,7 +1016,7 @@
 	e_book_msg_init ((EBookMsg*)response, _get_book_view_response_handler, _get_book_view_response_dtor);
 
 	response->status = E_BOOK_ERROR_OK;
-	if (!e_book_get_book_view (view_msg->book, view_msg->query, NULL, -1, &response->book_view, &error)) {
+	if (!e_book_get_book_view (view_msg->book, view_msg->query, view_msg->requested_fields, view_msg->max_results, &response->book_view, &error)) {
 		response->status = error->code;
 		g_error_free (error);
 	}
@@ -1029,14 +1031,16 @@
 _get_book_view_dtor (EBookMsg *msg)
 {
 	GetBookViewMsg *view_msg = (GetBookViewMsg *)msg;
-	
+	/* TODO: handle requested_fields */
 	e_book_query_unref (view_msg->query);
 	g_free (view_msg);
 }
 
 guint
 e_book_async_get_book_view (EBook                 *book,
-			    const gchar           *query,
+			    EBookQuery            *query,
+			    GList                 *requested_fields,
+			    int                    max_results,
 			    EBookBookViewCallback  cb,
 			    gpointer               closure)
 {
@@ -1048,7 +1052,9 @@
 	e_book_msg_init ((EBookMsg*)msg, _get_book_view_handler, _get_book_view_dtor);
 
 	msg->book = g_object_ref (book);
-	msg->query = e_book_query_from_string (query);
+	msg->query = e_book_query_ref (query);
+	msg->requested_fields = requested_fields; /* TODO: clone? ref? */
+	msg->max_results = max_results;
 	msg->cb = cb;
 	msg->closure = closure;
 
@@ -1129,7 +1135,7 @@
 
 guint
 e_book_async_get_contacts (EBook                 *book,
-			   const gchar           *query,
+			   EBookQuery            *query,
 			   EBookContactsCallback  cb,
 			   gpointer              closure)
 {
@@ -1141,7 +1147,8 @@
 	e_book_msg_init ((EBookMsg*)msg, _get_contacts_handler, _get_contacts_dtor);
 
 	msg->book = g_object_ref (book);
-	msg->query = e_book_query_from_string (query);
+	e_book_query_ref (query);
+	msg->query = query;
 	msg->cb = cb;
 	msg->closure = closure;
 
Index: e-book-async.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-async.h,v
retrieving revision 1.2
diff -u -r1.2 e-book-async.h
--- e-book-async.h	1 Dec 2003 06:49:54 -0000	1.2
+++ e-book-async.h	15 Dec 2003 11:22:38 -0000
@@ -71,7 +71,7 @@
 						 gpointer               closure);
 
 guint     e_book_async_get_contacts             (EBook                 *book,
-						 const char            *query,
+						 EBookQuery            *query,
 						 EBookContactsCallback  cb,
 						 gpointer               closure);
 
@@ -103,7 +103,9 @@
 						 gpointer               closure);
 
 guint     e_book_async_get_book_view            (EBook                 *book,
-						 const gchar           *query, /* XXX this needs to change to an EBookQuery */
+						 EBookQuery            *query,
+						 GList                 *requested_fields,
+						 int                    max_results,
 						 EBookBookViewCallback  cb,
 						 gpointer               closure);
 
Index: e-book-query.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-query.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 e-book-query.c
--- e-book-query.c	3 Nov 2003 18:23:57 -0000	1.1.1.1
+++ e-book-query.c	15 Dec 2003 11:22:38 -0000
@@ -201,10 +280,18 @@
 	g_free (q);
 }
 
-void
+/**
+ * e_book_query_ref:
+ * @q: a #EBookQuery
+ *
+ * Increment the reference count on @q.
+ * Return value: @q
+ */
+EBookQuery *
 e_book_query_ref (EBookQuery *q)
 {
 	q->ref_count++;
+	return q;
 }
 
 static ESExpResult *
Index: e-book-query.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-query.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 e-book-query.h
--- e-book-query.h	3 Nov 2003 18:23:57 -0000	1.1.1.1
+++ e-book-query.h	15 Dec 2003 11:22:38 -0000
@@ -23,10 +23,10 @@
 #endif
 } EBookQueryTest;
 
-EBookQuery* e_book_query_from_string  (const char *sexp);
+EBookQuery* e_book_query_from_string  (const char *sexp);
 char*       e_book_query_to_string    (EBookQuery *q);
 
-void        e_book_query_ref          (EBookQuery *q);
+EBookQuery* e_book_query_ref          (EBookQuery *q);
 void        e_book_query_unref        (EBookQuery *q);
 
 EBookQuery* e_book_query_and          (int nqs, EBookQuery **qs, gboolean unref);


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