On Wednesday 01 April 2009 02:22:39 am Chris Frey wrote:
> On Wed, Apr 01, 2009 at 02:02:50AM +0200, Daniel Gollub wrote:
> > > The Barry plugin relies on this function to store its cache and ID map.
> > > These are just simple text files at the moment: the cache is a list of
> > > known record ID's in the Blackberry, and the idmap is a map of
> > > Blackberry record ID's to opensync ID's (key/value).
> >
> > Whats the purpose of those IDs?
> > By record you mean the entry/change IDs?
>
> The record IDs are just numbers that the Blackberry uses to reference
> a contact or a calendar item. They are not guaranteed to be unique, but
> they almost always are, and Barry is careful to maintain that
> pseudo-uniqueness.
Hehe - interesting. I had a quick look on barry. The ID things is really crazy
it's defenitly not a UID thing. Does the 1st party software create multiple
records with the same ID? ;)
>
> > Why not use the native Mapping Table and just use the OSyncChange UID?
> > Is it due to the problem that if you commit
> > new entries to the BB, the BB creates it's own ID and not using the
> > original UID reported by OpenSync? If so - there is a way to "workaround"
> > this - without the need to have your own mapping table. Commit your
> > change - retrieve the assigned new ID from the BB, and update the
> > OSyncChange with BB's mapping ID. (But yeah - wild guess - i should check
> > your code ;))
>
> That sounds promising. A lot of this code is just ported from the 0.22
> plugin, where I either did things simply for implementation speed, or
> just didn't realize the API existed. I decided back then to keep BB and
> opensync ID's strictly separate.
>
> I'll do some more research on OSyncChange UID. I was under the impression
> that opensync could handle alphanumeric ID's, while the BB can only do
> numeric.
No - it's just a "string" (const char*) - if you overwrite/change the in your
commit function thats perfectly fine for OpenSync. It will be only changed for
the member which is using your plugin - not for the other plugins. So the
"UID" thing of OSyncChange is not really _unique_ internally. For this we have
"mappings" and "mapping ids" which are stored in the ..... "mapping table" ;)
dgollub@marvin:~> sqlite3 ~/.opensync/group1/archive.db .dump tbl_changes
BEGIN TRANSACTION;
CREATE TABLE tbl_changes (objtype VARCHAR(64) NOT NULL, id INTEGER PRIMARY KEY
AUTOINCREMENT, uid VARCHAR NOT NULL, memberid INTEGER NOT NULL, mappingid
INTEGER NOT NULL, objengine VARCHAR(64) NOT NULL );
INSERT INTO "tbl_changes" VALUES('contact',17,'4',2,1,'contact');
INSERT INTO "tbl_changes" VALUES('contact',18,'7',2,2,'contact');
INSERT INTO "tbl_changes" VALUES('contact',19,'5',2,3,'contact');
INSERT INTO "tbl_changes" VALUES('contact',25,'foo3',1,1,'contact');
INSERT INTO "tbl_changes" VALUES('contact',26,'foo2',1,2,'contact');
INSERT INTO "tbl_changes" VALUES('contact',27,'foo1',1,3,'contact');
(Hmmm... the naming is not really consisting - the mapping table get
persistent stored with OSyncMappingTable which is using also OSyncArchive and
ends up in a table "tbl_changes" - maybe some cleanup after 0.39 is required
;))
>
> As for adding new records via Barry, we generate the ID, so that's not a
> problem. I was more concerned with preserving the existing ID's from
> BB-added records.
>
> Time to study the API some more! :-)
>
> > We have this OSyncStateDB (format OSyncAnchor) which is since yesterday
> > also a key=value interface. In case those are independent of
> > changes/entries.
>
> Once an ID is mapped, it stays mapped until the record is deleted. So if I
> understand correctly, this StateDB would work for me.
Actually the StateDB is only for "device states". The mapping table is
supposed to be used for stuff like that. Your plugin doesn't need to deal with
the mapping table directly.
Just delete all your mapping database code and call osync_change_set_uid() in
your plugin commit function when the changetype is ADDED. Once you have
genearted your new uniqe ID. Thats it - after the commit plugin function the
engine would look into this OSyncChagne again and stores your changed UID
isntead of the orignally reported.
>
>
> Let me do some more research before I waste too much of your time. :-)
Sure.
Best Regards,
Daniel
------------------------------------------------------------------------------
_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel