View Single Post
Posts: 9 | Thanked: 12 times | Joined on Dec 2009
#8
Something like this should work (in C):

Code:
#include <libosso-abook/osso-abook.h>

static gchar *phone_number = NULL;

static void
aggregator_ready_cb (OssoABookWaitable *aggregator,
                     const GError      *error,
                     gpointer           user_data)
{
    GList *contacts;
    GList *l;
    OssoABookContact *contact;

    contacts = osso_abook_aggregator_find_contacts_for_phone_number (
            OSSO_ABOOK_AGGREGATOR (aggregator), phone_number, TRUE);


    if (contacts) {
        g_print ("Contacts with phone number %s:\n", phone_number);
        for (l = contacts; l; l = l->next) {
            contact = l->data;
            g_print ("    %s\n",
                    osso_abook_contact_get_display_name (contact));
        }
    }
    else {
        g_print ("No contacts found with phone number %s.\n",
                phone_number);
    }

    g_list_free (contacts);

    gtk_main_quit ();
}

int
main (int argc, char **argv)
{
    osso_context_t *osso_cxt;

    osso_cxt = osso_initialize (argv[0], "0.1", FALSE, NULL);
    osso_abook_init (&argc, &argv, osso_cxt);

    if (argc > 1)
        phone_number = argv[1];
    else
        phone_number = "1234567";

    osso_abook_waitable_call_when_ready (
            OSSO_ABOOK_WAITABLE (osso_abook_aggregator_get_default (NULL)),
            aggregator_ready_cb, NULL, NULL);

    gtk_main ();

    return 0;
}
 

The Following 4 Users Say Thank You to barisione For This Useful Post: