Sunday, August 30, 2009

Plugins and extensions

Yesterday I worked to put an example together on how to use plugins and extensions together to make useful things.

Since I was going to code, I decided to make something useful, so I took the advice of my friend peyisar who said to me that he liked the main window of emesene 1.x over the current one. I made a plugin that register an extension to add the old status combo at the bottom of the main window.

It's really easy to make, you can look at the code here:


here is a screencast showing how to enable the new plugin and extension:






you may ask what's the difference between a plugin and an extension, well:

  • plugins add functionality that wan't there before
  • extensions replace functionality that was there but you may not like as it is
in emesene 2, all parts are extensions that are registered in a category, you can check which categories exist going to the extension tab on preferences, almost all of them right now come with only one implementation, except conversation output that has the webkit and the gtk output options and the session category that has msn, jabber and dummy implementations.

but since you may want to write a new extension for a given category the most common place to transport your extension and register it is a plugin.
you code a plugin that only registers an extension when it's activated, and since on emesene 2 we can code plugins in folders we can have a lot of files to implement one or multiple functionalities.

This is just one example of what can be achieved, just think on extensions as a way to change the behavior of emesene 2 without needing to understand all the code or the need to have svn access.


5 comments:

Anonymous said...

Hey mariano,

I noticed that, it`s been a long time that when I try to 'svn up' the emesene2 code, it stays always the same (and the revision i the same as emesene 1.5)

I`m using the subversion link you posted on an old post...
has it changed?

Anonymous said...

Bellini, emesene2 is developed in git now.
Take a look here: http://github.com/marianoguerra/emesene/tree/2c49ddd0d3c525763ed8bc0b95824e25b183ad31/mesinyer

ExAzor said...

hey mariano, take a look at my "register decorator": it allows you to use a class-decorator similar to:

@extension.implements('below userlist')
class StatusCombo(blablabl).

As by now it will just add some metadata to the class, but I'll shortly add
extension.register('category you said', thisclass)

This way, extensions will automatically register themself, and nothing else is needed ;)

Cyanotic said...

Hi there Mariano,
here we're trying to use papyon library for msn protocol (cloud implemented conversation & login)...but we need some clean stuff that we cannot create as clean as you do:
1 - Avatar choooser
2 - Caching custom emoticon system
3 - Conversation custom emoticon support

we'll be happy to make a little branch and add papyon support (you'll decide if merging it to the master branch)

Unknown said...

I am with this problem:

Traceback (most recent call last):
File "emesene.py", line 20, in module
import e3dummy
ImportError: No module named e3dummy