Hashtable API changes - porting instruction

View: New views
1 Messages — Rating Filter:   Alert me  

Hashtable API changes - porting instruction

by Daniel Gollub :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

hashtable API changed and hopefully the speed of the hashtable as well. I
already ported file-sync and gnokii-sync. file-sync is hopefully a good
reference porting for this API changes. I'm going to provide patches also for
other plugins within the OpenSync ASAP. kdepim is next ...

file-sync hashtable port:
http://opensync.org/changeset/3299

Porting your OpenSync plugin to latest API changes in 10 steps:

 1. osync_hashtable_free() -> osync_hashtable_unref()
 2. add osync_hashtable_load() in plugin initialize function, right after
 osync_hashtable_new()
 
 3. remove osync_hashtable_report() and osync_hashtable_reset_reports(),
 they're deprecated.
 
 4. osync_hashtable_update_hash() -> osync_hashtable_update_change()
 Parameter list now takes just the hashtable object and the change
 object.
 
 5. Order functions in get_changes() plugin function so
 osync_hashtable_update_change() get called with the new OSyncChange, when
 the change entry got uid, hash and changetype set.
 
 6. Make sure osync_hashtable_update_change() get called for every entry.
 Don't skip this call, even if the changetype is UNMODIFIED.
 
 7. osync_hashtable_get_deleted() returns now instead of a char* array,
 an OSyncList. The entries are (const char*) strings which store the
 UID. No need to free the UIDs.
 
 8. Iterate over the list like this:

 OSyncList *u, *uids = osync_hashtable_get_deleted(YourHashtable?);
 for (u = uids; u; u = u->next) {
 const char *uid = u->data;
 ...
 }
 osync_list_free(uids);
 ...
 (RFC: Maybe we should provide for this a generic function to do the    
           osync_context_report_change() - since this should be the same
           for all plugins - right?)

 9. Call osync_hashtable_save() in your sync_done() function.
 10. Test your plugin :)


PS: You might want to test if everything works smoothy this way:

# regular sync
osyncplugin -p file-sync -c /full/path/file-sync.conf \
-C /tmp/ --initialize --connect --sync --syncdone --disconnect --finalize

# force slowsync
osyncplugin -p file-sync -c /full/path/file-sync.conf \
-C /tmp/ --initialize --connect --slowsync --syncdone --disconnect --finalize

... without --syncdone or missing osync_hashtable_save() you'll discover
strange effects, since the hashtable didn't got dumped. You'll find your
hashtable in /tmp/ ... -C stands for the plugin configuration directory. You
can open the hashtable with sqlite3 commandline tool.

Happy testing!

best regards,
Daniel

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel