[Kde-pim] Hooks for Akonadi resource using Python

Kevin Krammer kevin.krammer at gmx.at
Wed Aug 17 17:30:22 BST 2011


Hi Mario,

On Wednesday, 2011-08-17, Mario Santagiuliana wrote:
> Hi,
> I'm trying to write an akonadi resource using python, like you know...
> 
> In the standard cpp akonadi resource template I see that there is an hook,
> if I understand correctly:
> 
> AKONADI_RESOURCE_MAIN( ResourceBase )

This is just a simple marco which creates the C++ main function of the 
program. It is just for convenience and looks more or less like this:

  int main( int argc, char **argv ) 
  {                                                           
    return Akonadi::ResourceBase::init<resourceClass>( argc, argv );
  }

The init method called here is the one which then creates the KApplication 
instance, i.e. the one I had in one of my previous postings.

So you already have the necessary parts for that.

> I don't understand how I can reproduce an hook for python...I can create my
> python class, I can create various methods, for example "configure" (which
> should be call if I create my resource using akonadi panel and I click on
> Edit button for the configuration), just to understand:
> 
> class Test( Akonadi.ResourceBase)
> 	def __init__( self, id ):
> 		#code
> 
> 	def configure( self, id ):
> 		#code
> 
> def main():
> 	#code
> #code
> 
> the main function is similar to main function in my attachment of my
> previous email:
> http://markmail.org/message/trbs2ikk2fw6hn5r
> 
> How can I create this hook?

configure is a method in AgentBase (superclass of ResourceBase) and it is 
called through D-Bus. The D-Bus code for that is in AgentBase's internals so a 
resource author like yourself just has to override the method.

> Does akonadi call the resource and pass to them options like in command
> line? For example to call the configuration:
> 
> akonadi_mypythonresource_resource --configure opts opts

The only thing the resource gets on the commandline is its identifier.
All other requests, such as configure(), are handled through D-Bus: the code 
in AgentBase registers a D-Bus object which exports methods such as 
configure() and D-Bus calls to that object then result in calls to the 
configure override in the AgentBase/ResourceBase subclass.

> Thank you and sorry for my bad English...

Not bad at all :)

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110817/6b4c4678/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list