[Evolution-hackers] problem with ebook in Evo 1.4.6



Hi,

I'm trying trying, from my shell component for Evo 1.4, to read the
local AddressBook content with e-book APIs, but each time I get the
cursor, it is empty (length == 0).

I know that I have 2 cards in it.

Attached is a sample code extracted from my code, that ressemble much to
what Evo does. (compilation line is in the first line comment)

Any clues ?

Thanks a lot for any help.

Hub
/* gcc `pkg-config --cflags --libs  evolution-addressbook` ebooktest.c -o ebooktest */
#include <glib.h>
#include <bonobo/bonobo-i18n.h>
#include <bonobo/bonobo-main.h>
#include <libgnome/gnome-init.h>

#include <ebook/e-book.h>




/** Just a callback from e_book_get_cursor() to initiate the merge
 */

static void merge_get_cursor_cb (EBook *book, EBookStatus status, 
                           ECardCursor *cursor, gpointer data)
{
    long i;
    long length = e_card_cursor_get_length(cursor);

    if (length == 0)
    {
        g_message("Local contact list is empty !");
    }
    for ( i = 0; i < length; i++ ) 
    {
        ECard *card = e_card_cursor_get_nth(cursor, i);
        if (card)
        {
            g_message("Found a card\n");
            g_object_unref(card);
        }
    }
}


static void import_ebook_opened_cb(EBook *book, EBookStatus status, 
                                   gpointer data)
{
    if (status != E_BOOK_STATUS_SUCCESS)
    {
        g_message("failed to open ebook\n");
        g_object_unref(book);
        return;
    }
    e_book_get_cursor(book, "", merge_get_cursor_cb, NULL);
}


gboolean ebook_create(gpointer data)
{
    EBook *book = e_book_new();
    gchar ebook_uri[256];
    
    g_snprintf(ebook_uri, sizeof(ebook_uri), 
               "file://%s/evolution/local/Contacts/addressbook.db", g_get_home_dir());

    e_book_load_uri(book, ebook_uri, import_ebook_opened_cb, NULL);

    
}

static void
init_bonobo (int *argc, char **argv)
{
        if (bonobo_init (argc, argv) == FALSE)
                g_error (_("Could not initialize Bonobo"));
}

int
main (int argc, char **argv)
{
    gnome_program_init("ebooktest", "0.0", LIBGNOME_MODULE, argc, argv, NULL);
    
    init_bonobo (&argc, argv);
    
    g_idle_add (ebook_create, NULL);
    
    bonobo_main ();
    
    return 0;
}


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