X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=contactsServ.py;fp=contactsServ.py;h=d1a42fc90276cd50cee84de5744dcbb7f9f452ec;hb=39b7e1e9a1d3e90acae7d9a300b849f5f9a202d8;hp=93e5fa3ea5e84b6a6a0512d2749ad87f50bf8a70;hpb=e6f144ca963a86ab23ee5337750eba928d898406;p=retroconv diff --git a/contactsServ.py b/contactsServ.py index 93e5fa3..d1a42fc 100644 --- a/contactsServ.py +++ b/contactsServ.py @@ -1,112 +1,61 @@ -import evolution -from pygobject import * -from ctypes import * +from evolution import ebook +import pygobject +import ctypes +import sys #from wrapper import * -ebook = CDLL('libebook-1.2.so.9') +#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 getContactNameFromPhone(self, phoneNum): - - - addresses = evolution.ebook.open_addressbook('default') - contacts = addresses.get_all_contacts() - - - #ai = GList.new(ebook.e_contact_get_attributes(hash(self._contact), E_CONTACT_EMAIL)) - - for econtact in contacts: - - try: - #print econtact.get_name() - phones = econtact.get_property('phone') - - phones_p=int(str(phones)[13:-1],16) - phoneList = GList.new(phones_p) - - while phoneList.has_next(): - currPhone = string_at(phoneList.next()) - - if currPhone == phoneNum: - return econtact.get_name() - except: - continue - - - def populateNames(self, recvLst, sentLst): - addresses = evolution.ebook.open_addressbook('default') + addresses = ebook.open_addressbook('default') contacts = addresses.get_all_contacts() listX=[] - - - """"for msg in recvLst: - for contact in contacts: - try: - phones = contact.get_property('phone') - phones_p=int(str(phones)[13:-1],16) - except: - continue - - phoneList = GList.new(phones_p) - - while phoneList.has_next(): - currPhone = string_at(phoneList.next()) - if currPhone[-7:] == msg.fromNum[-7:]: - msg.setSenderName(contact.get_name()) - break - """ - + for contact in contacts: try: phones = contact.get_property('phone') phones_p=int(str(phones)[13:-1],16) - phoneList = GList.new(phones_p) - - - - - - - - + phoneList = pygobject.GList.new(phones_p) while phoneList.has_next(): - currPhone = string_at(phoneList.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 = cast(c_void_p(hash(photo)), POINTER(EContactPhoto)) + 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 = string_at(pi.contents.data.inlined.data, pi.contents.data.inlined.length) + 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 = cast(c_void_p(hash(photo)), POINTER(EContactPhoto)) + 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 = string_at(pi.contents.data.inlined.data, pi.contents.data.inlined.length) + 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