--- /dev/null
+from evolution import ebook
+import pygobject
+import ctypes
+import sys
+#from wrapper import *
+
+
+#ebook = CDLL('libebook-1.2.so.5')
+E_CONTACT_HOMEPAGE_URL = 42
+E_CONTACT_PHOTO = 94
+E_CONTACT_EMAIL = 97
+E_CONTACT_BIRTHDAY_DATE = 107
+
+class address_book:
+
+ def populateNames(self, recvLst, sentLst):
+
+ addresses = ebook.open_addressbook('default')
+ contacts = addresses.get_all_contacts()
+
+ listX=[]
+
+ for contact in contacts:
+
+ try:
+ phones = contact.get_property('phone')
+ phones_p=int(str(phones)[13:-1],16)
+ phoneList = pygobject.GList.new(phones_p)
+
+ while phoneList.has_next():
+ currPhone = ctypes.string_at(phoneList.next())
+ for msg in recvLst:
+ if currPhone[-7:] == msg.fromNum[-7:]:
+ msg.setSenderName(contact.get_name())
+ photo = contact.get_property('photo')
+ pi = ctypes.cast(ctypes.c_void_p(hash(photo)), ctypes.POINTER(pygobject.EContactPhoto))
+
+ if pi.contents.data.uri.startswith("image/"):
+ #data = string_at(pi.contents.data.inlined.data)
+ data = ctypes.string_at(pi.contents.data.inlined.data, pi.contents.data.inlined.length)
+ length = pi.contents.data.inlined.length
+ msg.setImageData(data, length)
+ else:
+ print contact.get_name()+" : "+pi.contents.data.uri
+
+ for msg in sentLst:
+ if currPhone[-7:] == msg.toNum[-7:]:
+ msg.setRecName(contact.get_name())
+ photo = contact.get_property('photo')
+ pi = ctypes.cast(ctypes.c_void_p(hash(photo)), ctypes.POINTER(pygobject.EContactPhoto))
+
+ if pi.contents.data.uri.startswith("image/"):
+ #data = string_at(pi.contents.data.inlined.data)
+ data = ctypes.string_at(pi.contents.data.inlined.data, pi.contents.data.inlined.length)
+ length = pi.contents.data.inlined.length
+ msg.setImageData(data, length)
+
+
+ except:
+ #print sys.exc_info()
+ continue