X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fevo_backend.py;h=0b71ebf31e56ace86871c591261ec1544fa5ff72;hb=07a86815a501921bab5adbfca7a4402bb0fe25be;hp=85452ae52178c5be82520fd2cd91f71bfc41f067;hpb=97958f9f40a578befa452f4d1769d752693a72e6;p=gc-dialer diff --git a/src/evo_backend.py b/src/evo_backend.py index 85452ae..0b71ebf 100644 --- a/src/evo_backend.py +++ b/src/evo_backend.py @@ -1,25 +1,29 @@ #!/usr/bin/python -# GC Dialer - Front end for Google's Grand Central service. -# Copyright (C) 2008 Eric Warnke ericew AT gmail DOT com -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +""" +DialCentral - Front end for Google's Grand Central service. +Copyright (C) 2008 Eric Warnke ericew AT gmail DOT com +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -""" Evolution Contact Support + +@bug It seems the evolution contact API used is specific to the desktop. evolution.ebook combined with abook is what is needed for Maemo. + http://maemo.org/maemo_release_documentation/maemo4.1.x/node8.html#SECTION00870000000000000000 + https://garage.maemo.org/svn/pymaemo/packages/python-abook/trunk/tests/ especially contact_get_iter amd filter_model + http://pymaemo.garage.maemo.org/documentation/api/abook/index.html """ @@ -39,9 +43,20 @@ class EvolutionAddressBook(object): return self._phoneTypes = None - self._bookId = bookId if bookId is not None else self.get_addressbooks().next()[1] + if bookId is not None: + self._bookId = bookId + else: + try: + self._bookId = [ + bookData[1] + for bookData in self.get_addressbooks() + ][0] + except IndexError: + global evolution + evolution = None + return self._book = evolution.ebook.open_addressbook(self._bookId) - + @classmethod def is_supported(cls): return evolution is not None @@ -53,18 +68,25 @@ class EvolutionAddressBook(object): if not self.is_supported(): return + if len(evolution.ebook.list_addressbooks()) == 0 and evolution.ebook.open_addressbook('default') is not None: + # It appears that Maemo's e-d-s does not always list the default addressbook, so we're faking it being listed + yield self, "default", "Maemo" + for bookId in evolution.ebook.list_addressbooks(): yield self, bookId[1], bookId[0] - + def open_addressbook(self, bookId): self._bookId = bookId self._book = evolution.ebook.open_addressbook(self._bookId) return self @staticmethod - def factory_short_name(): + def contact_source_short_name(contactId): return "Evo" + def clear_caches(self): + pass + @staticmethod def factory_name(): return "Evolution" @@ -77,13 +99,13 @@ class EvolutionAddressBook(object): return for contact in self._book.get_all_contacts(): - yield contact.get_uid(), contact.props.full_name - + yield str(contact.get_uid()), contact.props.full_name + def get_contact_details(self, contactId): """ @returns Iterable of (Phone Type, Phone Number) """ - contact = self._book.get_contact(contactId) + contact = self._book.get_contact(int(contactId)) if self._phoneTypes is None and contact is not None: self._phoneTypes = [pt for pt in dir(contact.props) if "phone" in pt.lower()] @@ -93,7 +115,8 @@ class EvolutionAddressBook(object): if isinstance(phoneNumber, str): yield phoneType, phoneNumber -def print_addressbooks(): + +def print_evobooks(): """ Included here for debugging.