[Kde-pim] Setting Akonadi agents' mime types

Volker Krause vkrause at kde.org
Fri Sep 11 08:09:59 BST 2009


On Friday 11 September 2009 01:38:40 David Jarvie wrote:
> I'm trying to create a new Akonadi agent and then set its mime type to one
> out of the 4 possible mime types for the resource type. (KAlarm Akonadi
> resources are defined to have 4 mime types, but any one resource will
> normally only have a single mime type.) I've only managed to come up with a
> fairly complex way of doing this, and judging by AkonadiConsole, setting
> the mime type doesn't work.
>
> The method used is:
>
> - Use AgentInstanceCreateJob to create the agent
> - Use Monitor::collectionAdded signal to determine when the agent creation
> has completed.
> - Because Monitor::collectionAdded has a const Collection parameter, this
> can't be modified, so the next 2 steps are needed to fetch the same
> Collection, but as a non-const:

That can be simplified by just making a copy of the const Collection, ie.
Collection col( constCol );

> - Use CollectionFetchJob to fetch the Collection list
> - When its result() signal triggers, search the list by ID for the newly
> created Collection.
> - Use Collection::setContentMimeTypes() to set the single mime type.

Keep in mind that changes to local objects will not be persisted until you run 
a Item/CollectionModifyJob on them. Seems that's the part you are missing 
here.

> Questions:
> Is there a shorter way of doing this operation?
> Why doesn't the Collection show just a single mime type in AkonadiConsole?
> - is it necessary to do something else to save the new setting?

I'm wondering why you try to modify the content mimetype from within the 
application at all. Usually it's something only the resource should do, as it 
is the only thing that knows what types it can handle. If possible any 
resource-specific knowledge should be avoided in the application, it will 
fail once you exchange the resources at some point.

regards
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090911/d7320f8b/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