3 # DialCentral - Front end for Google's Grand Central service.
4 # Copyright (C) 2008 Eric Warnke ericew AT gmail DOT com
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 Maemo Contacts Support
34 import evolution.ebook as ebook
39 class MaemoAddressBook(object):
41 @note Combined the factory and the addressbook for "simplicity" and "cutting down" the number of allocations/deallocations
44 def __init__(self, contextName, context):
45 if not self.is_supported():
48 abook.init_with_name(contextName, context)
49 self._book = abook.all_group_get()
52 def is_supported(cls):
53 return abook is not None and ebook is not None
55 def get_addressbooks(self):
57 @returns Iterable of (Address Book Factory, Book Id, Book Name)
59 if not self.is_supported():
64 def open_addressbook(self, bookId):
68 def contact_source_short_name(contactId):
75 def get_contacts(self):
77 @returns Iterable of (contact id, contact name)
79 if not self.is_supported():
83 def get_contact_details(self, contactId):
85 @returns Iterable of (Phone Type, Phone Number)
90 def print_maemobooks():
92 Included here for debugging.
94 Either insert it into the code or launch python with the "-i" flag
96 if not MaemoAddressBook.is_supported():
97 print "No GMail Support"
100 mab = MaemoAddressBook()
101 for book in mab.get_addressbooks():
102 mab = mab.open_addressbook(book[1])
104 for contact in mab.get_contacts():
106 for details in mab.get_contact_details(contact[0]):
107 print "\t\t", details
108 print mab._gmailContacts