[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[coldsync-hackers] Preference capabilities
I just sent a diff to Our Fearless Leader which does the following:
* Looks what preferences are needed and places them in a cache list.
* When a conduit is run, it gets the preference raw data from this list. If it
isn't downloaded yet, it is retrieved immediately.
* On the stdin of the conduit, all preferences are specified in headers:
Preference: mail/3/15
Preference: foox/8/88
which specifies the creator and id of the preference and the length of the
raw data. After the newline, indicating the end of headers, the conduit will
get the raw data in the same order as the preferences were specified. In the
conduit, %PREFERENCES will be defined, so that the conduit has access to
the raw data: $PREFERENCES{mail}{3} and $PREFERENCES{foox}{8}.
* Before the connection to the palm is dropped, the cache list is checked
for items that have not yet been downloaded. The thing is that the dump
conduits get run *after* the connection has been dropped. But if one of these
conduits would need a preference that wasn't in the cache list yet, it would
try to download it...
So checking and retrieving before disconnecting is done, even though it's
ugly.
* Before exiting, the cache list is freed.
So, where have I made the changes?
coldsync.c:
Now contains a global variable, which is a pointer to a preference item. This
is the first item of the cache, which is a linked list.
In main() cache list is created and freed. Also, before dropping the connection,
items are downloaded here.
Of course an #include "pref.h"
conduit.c:
run_conduit now has an array of pointers to preference items, namely those in
the cache. After the default headers are created, the preference items are
retrieved (either from the cache or the palm) and the Preference: headers are
created. After sending the newline to the conduit, the contents of the items
are `fwritten' in order of appearance. Before returning, the array is freed.
Now, this is the nasty bit: run_conduit doesn't know anything of the palm
connection (pconn), so how can it download on the fly? I had to add a pointer
to pconn in every preference item when I created the cache list. Oooh, very
ugly indeed, but it would even be uglier to give run_conduit pconn as an
argument. Any thoughts on this?
Of course an #include "pref.h"
Makefile:
Added pref.c and pref.h
pref.c, pref.h:
Contain the struct pref_item and routines for creating, finding and freeing
these structs and for creating and freeing the cache.
ColdSync.pm:
Now exports %PREFERENCES.
In sub ReadHeaders, before getting the line as a header into the hash, the line
is checked for being a preference. If so, it's added to %PREFERENCES.
After the newline, the raw data is read in order from stdin.
Also attempted to explain %PREFERENCES in the pod bit. However, as you have
seen from this email, I'm not the world's best documentation writer...
Greetsz
--
Sumant S.R. Oemrawsingh
sikander@stad.dsl.nl
Asleep at the switch! I wasn't asleep! I was drunk!
-- Homer Simpson
Homer the Vigilante
--
This message was sent through the coldsync-hackers mailing list. To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body. For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.