2
# -*- encoding: utf-8 -*-
4
# Copyright 2013 Canonical Ltd.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU Lesser General Public License as published by
8
# the Free Software Foundation; version 3.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU Lesser General Public License for more details.
15
# You should have received a copy of the GNU Lesser General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
TEL;TYPE=WORK,VOICE;PID=1.1:(111) 555-1212
28
TEL;TYPE=HOME,VOICE;PID=1.2:(404) 555-1212
29
EMAIL;TYPE=PREF,INTERNET;PID=1.1:forrestgump@example.com
33
class Contacts(object):
37
self.addr_iface = None
40
self.bus = dbus.SessionBus()
41
self.addr = self.bus.get_object('com.canonical.pim',
42
'/com/canonical/pim/AddressBook')
43
self.addr_iface = dbus.Interface(self.addr,
44
dbus_interface='com.canonical.pim.AddressBook')
46
def query(self, fields = '', query = '', sources = []):
47
view_path = self.addr_iface.query(fields, query, [])
48
view = self.bus.get_object('com.canonical.pim',
50
view_iface = dbus.Interface(view,
51
dbus_interface='com.canonical.pim.AddressBookView')
52
contacts = view_iface.contactsDetails([], 0, -1)
56
def update(self, vcard):
57
return self.addr_iface.updateContacts([vcard])
59
def create(self, vcard):
60
return self.addr_iface.createContact(vcard, "")
62
def delete(self, ids):
63
return self.addr_iface.removeContacts(ids)