[PyKDE] Kontact Plugins

Jim Bublitz jbublitz at nwinternet.com
Sat May 22 17:22:01 BST 2004

On Saturday 22 May 2004 02:55, Peter Clark wrote:
>     Are there any guides to developing a Kontact plugin? I'd like to write
> a PyQt program that a.) gets a list of the mail servers and fetch the
> headers for new messages and b.) offers the option of deleting specific
> messages. I know that similar programs exist, but none offer integration
> with KMail/Kontact. I don't need anything specific for PyQt and Kontact 
>  (since  I'm fairly certain such documentation doesn't exist), but even
>  general C++  might be helpful.

>     Also, if anyone happens to know how to grab a list of ther servers that
> KMail checks for mail, that would also be helpful.
> DCOP:kmail->KMailIface->accounts() displays the list of servers, but not
> the specific information that I would need (i.e. username, password, server
> address, port, etc.). Worse comes to worse, I can just write a dialog that
> duplicates Settings->Configure Kmail->Network->Receiving, but I'd rather
> just use what's already setup in KMail.

You'll definitely need to write some C++ to accomplish this. Look at the KDE 
kdelibs API docs for KLibLoader and KLibFactory (in kdecore) to see how KDE 
handles plugins generally. If you have an rpm based distro, those docs are 
usually in the kdelibs-devel-doc-* rpm, or they're available at kde.org 
(somewhere in the "developers" section). There are kmail plugins you can look 
at for the plugin code itself. You can also grep the kmail source for the 
plugin loader code (which will use KLibLoader somewhere). 

As far as actually being able to do this from Python, the method would depend 
on whether you want to do your work from within kmail itself (similar to a 
KParts type of interface), or from an independent process (using DCOP or some 
other form of IPC like sockets). 

The DCOP/IPC approach is easier - you can write your plugin to export more of 
kmail via DCOP for example. In that case, you only need to write C++ on the 
kmail side, and Python on your app side. PyKDE should have better DCOP 
support in one of the upcoming releases.

If you want to integrate your Python code into kmail itself (via some some 
menu entry/KParts, for example), you need some way to load the Python 
interpreter and communicate with it. You also need some small bindings to 
make the kmail API available to Python scripts so you can call the methods 
you need. It isn't a lot of code and it isn't that complex, but it is tricky 
to accomplish.


More information about the PyQt mailing list