Christian W. Zuckschwerdt wrote:
Hi Mika,

some real-world perl example would be much appreciated. Don't hesitate to rant on the API. Perhaps you can outline the requirements from a perl coders point of view. Or even improve it

There is obexftp-0.19/apps/perl_example.pl to get you started.

Bleh. I looked on the website, the documentation and the swig subdirectory but missed that one. Thanks for pointing it out. My error was in calling OBEXFTP::client::new(...) instead of new OBEXFTP::client, which produced plausible error messages and returned something, but that something didn't work right. My perl skills are still mostly non-OO perl...

So this script works. Couple of notes:
+ using the script my phone (N70) copes with multiple USB connections (as in connect physically - run script - disconnect, repeat), while the obexftp app does something in a way that leaves the N70 unable to talk USB after disconnect-connect (both Linux and OS-X) - there's no error handling in the 'list' command: if you give it a non-existent directory, it'll happily return a list of the previous directory. Easily fixed by using chpath (which does have error handling) and then calling list(".")

On the API: the first thing to come to mind is the XML. Anybody wanting to do something will have to parse that. A more perlish way would be to return a list of hashes (or somesuch). Maybe a higher level package that does that on top of the low-level one? So that OBEXFTP wouldn't have to require an XML package.

Can I set the Type of the Obex request, so that I can retrieve the OBEX capability object?

I had to tweak the Makefile.PL to get it to compile on OS-X (it needs something like '-bundle -bundle_loader /usr/bin/perl -L/System/Library/Perl/5.8/lib -lperl' in the LDDFLAGS. Neither are CFLAGS from the top-level ./configure propagated to the Makefile.PL, so that I had to add -I/opt/local/include (darwinports) to it manually. I haven't looked at how that should be actually done in the package.

Libusb has an environment variable for debug output (USB_DEBUG), while openobex has a compile time define. I tweaked my copy to do something like

if (getenv("OBEX_DEBUG")) obex_debug=atoi(getenv("OBEX_DEBUG"));

in obex.c instead of obex_debug=OBEX_DEBUG;. Might be a nice thing to have in general.


Thanks for the help. I'll keep you posted when I get some actual code done. My ultimate aim is to sync folders to the phone (either directories from the filesystem or playlists from iTunes). I'll try to create a re-usable perl script that just does the sync from input that defines the folders and files to be synced.

    Mika

(and on Python: I admit my perl skills are very 1995, but my Python is non-existent. And in 1995 Python was not quite the alternative to perl it is now, which is why perl is what I learned for cross-platform development.)


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to