Skip navigation

Following up with Retro Conversations, I’ve struggled yesterday for about 11 hours trying to find fetch a contact in address book using his/her number. I originally thought this would be an easy task, but it appears not as I found it that there are no python bindings for libabook yet.

I also found that the PyMaemo team were kind enough to write this tutorial on how to access APIs using ctypes for which there are no Python bindings yet that uses libosso-abook as an example. I read through the tutorial quickly which much of were very new to me and did not really understand.  So I  decided to explore Hermes’s source code to learn how it accesses contacts and I ended up writing this function:

def getContactNameFromPhone(self, phoneNum):
		addresses = evolution.ebook.open_addressbook('default')
		contacts = addresses.get_all_contacts()

		 #ai =, E_CONTACT_EMAIL))

		for econtact in contacts:

				#print econtact.get_name()
				phones = econtact.get_property('phone')
				phoneList =

				while phoneList.has_next():
					currPhone = string_at(

					if currPhone == phoneNum:
						return econtact.get_name()

which works, but if you examine the code, you’ll find that this is the worst solution ever! The app now takes about 2 or 3 minutes to start up. I also borrowed from Hermes to use its GList that is based on the PyMaemo tutorial I mentioned above.  I’m pretty sure things can be much simpler, I just didn’t get the whole ctypes things yet.. I guess I’m going to spend this night reading that PyMaemo tutorial again


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: