Editing PyMaemo/Accessing APIs without Python bindings/More examples
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
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]]. | 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 | + | == Searching contacts by phone number == |
- | Searching | + | Searching contacts by phone number can be done using the [http://maemo.org/api_refs/5.0/5.0-final/libosso-abook/libosso-abook-osso-abook-util.html#osso-abook-query-phone-number osso_abook_query_phone_number()] and [http://maemo.org/api_refs/5.0/5.0-final/libebook/EBook.html#e-book-get-contacts 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." | |
- | osso_abook. | + | 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) |
Learn more about Contributing to the wiki.