|
2010-02-19
, 17:56
|
Posts: 53 |
Thanked: 90 times |
Joined on Nov 2009
@ Manaus, Brazil
|
#2
|
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
The Following 3 Users Say Thank You to lizardo For This Useful Post: | ||
|
2010-04-12
, 00:11
|
Posts: 53 |
Thanked: 90 times |
Joined on Nov 2009
@ Manaus, Brazil
|
#3
|
The Following 3 Users Say Thank You to lizardo For This Useful Post: | ||
|
2010-04-12
, 10:43
|
Posts: 246 |
Thanked: 2,574 times |
Joined on Jan 2010
@ Egypt, Cairo
|
#4
|
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.
|
2010-04-12
, 10:55
|
Posts: 9 |
Thanked: 12 times |
Joined on Dec 2009
|
#5
|
|
2010-04-12
, 10:58
|
Posts: 246 |
Thanked: 2,574 times |
Joined on Jan 2010
@ Egypt, Cairo
|
#6
|
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).
|
2010-04-12
, 11:07
|
Posts: 53 |
Thanked: 90 times |
Joined on Nov 2009
@ Manaus, Brazil
|
#7
|
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).
|
2010-04-12
, 11:19
|
Posts: 9 |
Thanked: 12 times |
Joined on Dec 2009
|
#8
|
#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; }
|
2010-04-12
, 12:33
|
Posts: 883 |
Thanked: 980 times |
Joined on Jul 2007
@ Bern, Switzerland
|
#9
|
|
2010-04-12
, 14:22
|
Posts: 53 |
Thanked: 90 times |
Joined on Nov 2009
@ Manaus, Brazil
|
#10
|
However, forget about python, can someone just point me out to the correct steps get a contact from his/her number? Thanks a lot