On Fri, 2002-05-10 at 23:18, Stephan wrote:
> Hi there
> 
> I'm trying to write some basic code that will allow me to iterate over 
> the addressbook entries. The code is in c++ and I'm using gtkmm.
>  From reading the source it seems that the way to obtain a list of all 
> ECards in the addressbook is as follows:
> 
> 1) call "e_book_load_default_book()" and pass in a callback function eg. 
> "book_open_cb"
> 
> 2) "book_open_cb()" is called asynchronously when the AddressBook has 
> been successfully opened
> 
> 3) "inside book_open_cb()" obtain a cursor to the AddressBook by calling 
> e_book_get_cursor() and passing
>       a callback method eg. "cursor_cb()"
> 
> 4) once your cursor_cb() is called you're golden :-)
> 
> The problem with my code seems to be that I can never get past point 1) 
> above. My book_open_cb is never called,
> and hence I never get to the point where I can iterate over the 
> addressbook entries. Below is my main() method along with initialisation 
> code as well as the code for the initial open_cb() callback function.

So, I read your code.

The thing is this.  Your callback function isn't necessarily going to be
called before e_book_load_default_book returns.  In fact, it probably
isn't going to be.  You have to start a gtk main loop (In Gtk+ this is
done by calling gtk_main().  I don't know how it's done in Gtk--.)  This
is the main problem.  Your callback will be called some time during the
gtk main loop.

The second thing is e_book_get_cursor.  I would really recommend using
e_book_simple_query.  This function takes your book and a query string
and calls a single function with a GList of cards once it has received
them all.  The query string you should use to receive all the cards is
(in C notation)

"(contains \"x-evolution-any-field\" \"\")"


One thing you don't have to do in your book_open_cb function is start
another gtk main loop.  Since book_open_cb was called from within the
gtk main loop you started in your main() function, returning will return
the system to that gtk main loop.  gtk_main_quit is the function that
will make the gtk main loop return control to your main() function.

If you have any other questions, don't hesitate to write back.  Good
luck with your code.

Thanks,
    Chris

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to