[Kde-pim] Can't access attributes in serializer

David Jarvie djarvie at kde.org
Sat Nov 23 00:33:22 GMT 2013


On Friday 15 Nov 2013 22:34:43 Volker Krause wrote:
> On Monday 28 October 2013 12:46:53 David Jarvie wrote:
> > Is it possible to reliably access Item attributes in ItemSerializerPlugin
> > classes? I've found that calling AttributeFactory::registerAttribute() in
> > the deserialize() method, to register the Attribute class, doesn't have
> > any effect - it seems to depend on whether the *application* has called
> > registerAttribute() as to whether deserialize() can access the relevant
> > Attribute class.
> 
> attributes need to be registered before the item is retrieved from the server, 
> deserialization happens afterwards. What should work is static initialization 
> in the library they are defined in, an example can be found here: 
> kdepimlibs/akonadi/kmime/attributeregistrar.cpp (you can probably ignore the 
> static lib part). This will automatically register your attributes when the 
> corresponding library is loaded.

Unfortunately this doesn't seem to work after all. It fails in the following circumstances.

KOrganizer is configured to use a KAlarm calendar. The calendar has a KAlarmCal::EventAttribute for certain events. There is no problem until the calendar attribute is updated by KAlarm. At that point, the SerializerPluginKAlarm is loaded by KOrganizer, which causes the kalarmcal library to be loaded. The serializer then does not recognise the attribute type.

I've added a static initialisation as you suggested to register KAlarmCal::EventAttribute into both kalarmcal library and into the serialiser plugin, and debug output confirms that the registration is executed.

I suspect the fault occurs because the plugin (and hence the library) may only be loaded after the item is retrieved from the server. If this is the case, it looks as if it's impossible (if the attribute has to be registered before retrieving the item from the server) to ensure that an attribute can be registered in time, if the application itself doesn't use the library or attribute, and only the plugin uses them.

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
_______________________________________________
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