PyMaemo/Accessing APIs without Python bindings/More examples

More examples

This page contains some other example code using ctypes. Note that they are not complete, and assume some code already shown on the main article.

Searching contacts by phone number

Searching contacts by phone number can be done using the osso_abook_query_phone_number() and e_book_get_contacts() functions:

ebook = ctypes.CDLL('libebook-1.2.so.5')

err = ctypes.c_void_p()
c_book = ebook.e_book_new_default_addressbook(ctypes.byref(err)) 
if not ebook.e_book_open(c_book, 1, 0):
    print >>sys.stderr, "Couldn't load addressbook."
    sys.exit(1)
c_query = osso_abook.osso_abook_query_phone_number("12345678", 0)

contacts = ctypes.c_void_p()
if not ebook.e_book_get_contacts(c_book, c_query, ctypes.byref(contacts), err):
    print >>sys.stderr, "Couldn't get query results."
    sys.exit(1)