X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=bak%2FcontactsServ.py;fp=bak%2FcontactsServ.py;h=95aa7f99d7e5b3cf37bbd3c8edb6147d4dffa4d7;hb=d001770946053c4d60f9f9b9362f713287013079;hp=0000000000000000000000000000000000000000;hpb=3a76135cf3477fc8e8e0508ff8fd1026c21c6281;p=retroconv diff --git a/bak/contactsServ.py b/bak/contactsServ.py new file mode 100644 index 0000000..95aa7f9 --- /dev/null +++ b/bak/contactsServ.py @@ -0,0 +1,104 @@ +import evolution +from pygobject import * +from ctypes import * +#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 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') + 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) + + + + + + + + + + while phoneList.has_next(): + currPhone = string_at(phoneList.next()) + for msg in recvLst: + if currPhone[-7:] == msg.fromNum[-7:]: + msg.setSenderName(contact.get_name()) + + 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)) + + 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) + length = pi.contents.data.inlined.length + msg.setImageData(data, length) + + + except: + continue