[Kde-pim] Akonadi::ResourceBase - API questions

Tobias Koenig tokoe at kde.org
Sun May 13 14:17:08 BST 2007


On Sun, May 13, 2007 at 09:20:59PM +1000, Brad Hards wrote:
> G'day,
Hi Brad,

> I've been looking at Akonadi with the view to making a microsoft exchange 
> resource (based on http://www.openchange.org) - no promises though...
Sounds good :)

> 1. It seems a bit strange for Akonadi::ResourceBase to inherit from 
> Akonadi::Resource. What is the rationale for this?
Well, Akonadi::Resource is only the interface which is available via
DBus, maybe we should rename it to Akonadi::ResourceInterface indeed.

> 2. The method naming seems a bit strange in a couple of places. For example, I 
> expected that the method to add an Item to a Collection would be called 
> addItem(). If I'm understanding the code correctly, it is called itemAdded(), 
> which feels like a signal that would be emitted. I think I understand the 
> logic, but the name should still be with respect to the resource, not Akonadi 
> as a whole. Same issue for itemChanged, itemRemoved, collectionAdded, 
> collectionChanged, collectionRemoved.
I think you missunderstood the concept here.

The methods which you mention here are called via dbus from the store
when the user adds new items, so the resource can put the new/changed
items further to the groupware server.

If the resource wants to store new items into the storage it must use
ItemStoreJob.

> 5. I'm not sure what the "partIdentifiers" argument to itemChanged() is 
> intended to do. Any suggestions?
PIM Items can have several parts, e.g. an email consists of the
envelope, the body and possible attachments. So when the user changes
only the body, you don't have to upload the whole changed item to the
groupware server but only the changed item part.

PartIdentifiers are strings which identifies these parts. For Envelope
and AllParts we have already some constants.

> 6.. status() returns an int. The apidox says the possible return values are 0, 
> 1 or 2. If so, why does it not return the Status enum type?
This method is inherited from the DBus interface, no idea whether dbus
can work with enums.

> 7. collectionAdded(), collectionChanged() and collectionRemoved() are inline 
> and virtual, which looks a bit strange.
You shall reimplement it in your resource to create, modify or remove
folders from your groupware server.

> 8. Noting my concerns about how to tell the difference between 
> enableChangeRecording() and setOnline(), why isn't setOnline a slot?
Because it is called via DBus from the user or the solid networkmanager.

> 9. the knut resource has this function:
> virtual bool requestItemDelivery( const Akonadi::DataReference &ref, int type, 
> const QDBusMessage &msg )
> while the ResourceBase has this:
> virtual bool requestItemDelivery( int uid, const QString &remoteId, int 
> type );
> Are these related?
Yes, the one in ResourceBase calls the one in the subclasses (Template
Method Design Pattern)

> More on akonadi/resources/knut/:
> 10. This is a fragment from  KnutResource::loadData()
>   element = element.firstChildElement();
>   while ( !element.isNull() ) {
>     if ( element.tagName() == QLatin1String( "collection" ) ) {
>       addCollection( element, parentCollection );
>     } else if ( element.tagName() == QLatin1String( "item" ) ) {
>       if ( element.attribute( "mimetype" ) == QLatin1String( "text/vcard" ) )
>         addAddressee( element, entry );
>       else if ( element.attribute( "mimetype" ) == 
> QLatin1String( "text/calendar" ) )
>         addIncidence( element, entry );
>     }
> 
>     element = element.nextSiblingElement();
>   }
> 
>   mCollections.insert( entry.collection.remoteId(), entry );
> 
> Why isn't that last line inside the while loop?
Well, you want to insert the 'entry' only once to the mCollections map,
not several times.

Ciao,
Tobias
-- 
Separate politics from religion and economy!
The Council of the European Union is an undemocratic and illegal institution!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070513/108fa7e1/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