Re: [Request] Evolution AddressBook plugin



2010/1/26 Francesco Marella <francesco marella gmail com>:
> Hi all,
>
> wondering if someone could add a plugin to Kupfer to access the contacts
> inside the Evolution addressbook.
> It could be done via Dbus, I've found some related info:
> http://wiki.openmoko.org/wiki/Org_gnome_evolution_dataserver_AddressBook._org_gnome_evolution_dataserver_addressbook_BookFactory
> http://wiki.openmoko.org/wiki/Org_gnome_evolution_dataserver_AddressBook._org_gnome_evolution_dataserver_addressbook_file_3a_2f_2f_2f_home_2f_root_2f_2e_evolution_2f_addressbook_2f_local_2f_system
>
> or via the evolution.ebook module.
>
> Thanks in advance.

Hi,

given the complexity of evolution's address book and calendar API,
it's a godsend with a good python package for evolution for the person
wanting to build an evolution plugin.

I don't have evolution installed, but you can install python-evolution
anyway, so I made the following simplest possible evolution plugin
that will extract all primary mail addresses and nothing more.
Something to build on for interested people. It might even be useful,
but bear in mind that the evolution address book has a ton of
information that could be used.

Ulrik
# -*- coding: UTF-8 -*-
from __future__ import absolute_import

__kupfer_name__ = _("Evolution")
__kupfer_sources__ = ("ContactsSource", )
__kupfer_actions__ = ()
__description__ = _("Evolution contacts")
__version__ = "2010-02-03"
__author__ = "<Insert your name here>"

import evolution

from kupfer.objects import TextLeaf, RunnableLeaf
from kupfer.obj.apps import AppLeafContentMixin
from kupfer.obj.grouping import ToplevelGroupingSource
from kupfer.obj.contacts import EmailContact


class ContactsSource(AppLeafContentMixin, ToplevelGroupingSource):
	appleaf_content_id = 'evolution'

	def __init__(self, name=_("Evolution Address Book")):
		super(ContactsSource, self).__init__(name, "Contacts")

	def get_items(self):
		for bookname, id_ in evolution.ebook.list_addressbooks():
			ebook = evolution.ebook.open_addressbook(id_)
			for contact in ebook.get_all_contacts():
				name = contact.get_name()
				email = contact.get_property("email-1")
				if email:
					yield EmailContact(email, name)

	def should_sort_lexically(self):
		return True

	def get_description(self):
		return _("Evolution contacts")

	def get_icon_name(self):
		return "evolution"

	def provides(self):
		yield RunnableLeaf
		yield EmailContact





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]