[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coldsync-hackers] ColdSync::PDB - Palm::PDB over DLP/SPC



Hi all. Me again.

I've spent the last week or so working away at a perl module that enhances 
the whole SPC/DLP remote database protocol for sync conduits to use the 
"helper" concept from Palm::PDB and just generally make it a little nicer 
to write sync conduits.

I think I've got most of it working now - certainly everything I need - so I 
thought I'd throw it out there and see if there's anyone interested in 
playing with/breaking it.

The meat of it is the ColdSync::PDB module (the name is tentative... 
ColdSync::SPC::PDB might be more appropriate), which provides for things 
like loading databases, reading records, writing records, deleting, etc. It 
directly uses the Palm::PDB helpers (Palm::Mail, Palm::ToDo, etc) to handle 
the conversion of records to and from something a bit more meaningful than 
a raw C structure.

Perhaps a before and after might be appropriate here. Here's how you'd 
iterate through mail records using ColdSync::SPC:

  my $dbh = &dlp_OpenDB("MailDB",0x80);
  while( my $recordraw = &dlp_ReadNextRecInCategory( $dbh,$catno ) ) {
  	# turn it into a Mail record
  	my $record = Palm::Mail->ParseRecord(%$recordraw);
	die "501 Record $recordraw->{'id'} isn't mail!" unless defined $record;

	print "$record->{subject} from $record->{from}\n";
  }
  &dlp_CloseDB( $dbh );

Here's the corresponding ColdSync::PDB code:

  my $db = ColdSync::PDB->Load("MailDB","r");
  while( my $record = $db->nextRecInCategory( $catno ) ) {
	print "$record->{subject} from $record->{from}\n";
  }

In terms of style, I've tried to mostly stick with Palm::PDB conventions 
where possible. I'm not convinced that this is such a good idea, however. 
Confusing a DLP database with a local database is asking for pain. For one 
thing, ColdSync::PDB changes are immediate while Palm::PDB doesn't commit 
until an explicit Write() method call. Performance wise, there are things 
you can do with a local database that are just silly with a 1000 record 
remote database.

Included in the module are a couple of (barely tested) example sync conduits 
to demo some of the capabilities. I'm also attaching a ColdSync::PDB 
version of send-mail.

A bunch of caveats:

- this is built and tested on Red Hat 8.0. This particular Red Hat distro 
has given nothing but grief with respect to perl, so I wouldn't be terribly 
surprised if things just plain don't work.

- you NEED the latest CVS version of coldsync. Any version older than this 
morning WILL NOT WORK. I'm serious. In order to get the feature set for I 
needed for this module I've spent the last week pummeling Alessandro with a 
stream of assorted bugfixes/enhancements. This morning we reached a point 
where I slowed down and he caught up.

I could say more, but I have to go break up a dog fight... Enjoy.

c.

Attachment: ColdSync-PDB-1.10.tar.gz
Description: application/tgz

Attachment: send-mail
Description: Perl program