Reply
Thread Tools
Posts: 246 | Thanked: 2,574 times | Joined on Jan 2010 @ Egypt, Cairo
#1
So I've been struggling for 3 days now trying to do only one thing! Given a phone number, I want to fetch the contact name associated with that number! 3 days switching back and forth between osso abook and ebook libraries. Not to mention that I'm developing in python and have to use ctypes as there are no bindings yet.

However, forget about python, can someone just point me out to the correct steps get a contact from his/her number? Thanks a lot
 
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#2
Originally Posted by tgalal View Post
So I've been struggling for 3 days now trying to do only one thing! Given a phone number, I want to fetch the contact name associated with that number! 3 days switching back and forth between osso abook and ebook libraries. Not to mention that I'm developing in python and have to use ctypes as there are no bindings yet.

However, forget about python, can someone just point me out to the correct steps get a contact from his/her number? Thanks a lot
I did not try, but take a look at these functions:

http://maemo.org/api_refs/5.0/5.0-fi...r-phone-number

http://maemo.org/api_refs/5.0/5.0-fi...y-phone-number

Hope that helps.
__________________
Anderson Lizardo
 

The Following 3 Users Say Thank You to lizardo For This Useful Post:
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#3
I recently added this new wiki page:

http://wiki.maemo.org/PyMaemo/Access.../More_examples

It contains sample source code (using ctypes) to do what you want.

Hope that helps.
__________________
Anderson Lizardo
 

The Following 3 Users Say Thank You to lizardo For This Useful Post:
Posts: 246 | Thanked: 2,574 times | Joined on Jan 2010 @ Egypt, Cairo
#4
Originally Posted by lizardo View Post
I recently added this new wiki page:

http://wiki.maemo.org/PyMaemo/Access.../More_examples

It contains sample source code (using ctypes) to do what you want.

Hope that helps.
Thanks a lot! I'm your sure your wiki article would be helpful for a lot of people too
 
Posts: 9 | Thanked: 12 times | Joined on Dec 2009
#5
The example uses directly libebook, you should not do that.
You have to get the default aggregator (osso_abook_aggregator_get_default), wait for it until it's ready (osso_abook_waitable_call_when_ready) and then search for the matching contacts (osso_abook_aggregator_find_contacts_for_phone_num ber).
 
Posts: 246 | Thanked: 2,574 times | Joined on Jan 2010 @ Egypt, Cairo
#6
Originally Posted by barisione View Post
The example uses directly libebook, you should not do that.
You have to get the default aggregator (osso_abook_aggregator_get_default), wait for it until it's ready (osso_abook_waitable_call_when_ready) and then search for the matching contacts (osso_abook_aggregator_find_contacts_for_phone_num ber).
Could you post an example that does that ?
 
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#7
Originally Posted by barisione View Post
The example uses directly libebook, you should not do that.
You have to get the default aggregator (osso_abook_aggregator_get_default), wait for it until it's ready (osso_abook_waitable_call_when_ready) and then search for the matching contacts (osso_abook_aggregator_find_contacts_for_phone_num ber).
While I know it is not the recommended way, the example is still useful for simple cases... you lack some additional information or even contacts, but for some use cases that's enough.

I'll see if I can add another example using the recommended API, but if you can provide one (even in C) that will be great!
__________________
Anderson Lizardo
 
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:
Posts: 883 | Thanked: 980 times | Joined on Jul 2007 @ Bern, Switzerland
#9
A quick tip to find a library.
__________________
-Tom (N900, N810, N800)

"the idea of truly having a computer in your pocket just moved a big step closer."
 
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#10
Originally Posted by barisione View Post
Something like this should work (in C):
...
I updated the wiki pages based on your example code. Thanks!
__________________
Anderson Lizardo
 
Reply


 
Forum Jump


All times are GMT. The time now is 13:49.