[akunambol] API design - FunambolSyncSource

Riccardo Iaconelli riccardo at kde.org
Sat Jan 22 13:02:39 CET 2011


Hi,
to get to some interesting details, today I finally managed to get back 
writing some code. To be precise I worked on the FunambolSyncSource class, 
implementing configuration handling the way Funambol requires it.

Now, I am working on integrating a Funambol::SyncSource. The first idea was to 
wrap it into FunambolSyncSource like I'm doing with the config, so essentially 
hiding the needed multi-classes code from the developer - but then I thought 
that there is a much cleaner approach, even if it requires one more class for 
the plugin developer.

The idea would result in code similar to this:

- A (minimal) class, the "manager", subclass of FunambolSyncSource, "main" 
class of the plugin.
 - Handle some "cosmetic" details, so e.g.
   - in the constructor, do things like:
     setSourceUID("plasma-contacts")
     setMimeTypeSync("text/x-vcard")
     setRemoteURI("contacts")
	 ...
   - take care of creating a QWidget for configuration
   - return a valid QString for the UI
   - ...

- Another class, subclass of FunambolBackend (random name), which is itself 
subclassing Funambol::SyncSource, that only takes care of getting and writing 
data, reimplementing methods such as:
  - void getItem(uid)
  - void deleteItem(uid)
  - void removeAllItems()
  - ...

In the FunambolSyncSource class you would then do something like:

    this->setBackend(new PlasmaContacts);

where PlasmaContacts inherits FunambolBackend.

Thoughts? I think that this leads to cleaner and easier to write code, even if 
it requires the plugin developer to write two classes. The "manager" class 
would become pretty small and I suppose it would be easy to add multithreading 
to the sync process. Do you think it's a good idea?

You can check out the relevant code in akunambol/library.

Bye,
-Riccardo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/akunambol/attachments/20110122/c75e702b/attachment.sig 


More information about the akunambol mailing list