F-spot patch supporting Picasa Web

Amazing. While I was sleeping, Stephane Delcroix implemented a plug-in for f-spot that uses Mono.Google assembly to allow exporting pictures to Picasa Web.

The patch is attached to http://bugzilla.gnome.org/show_bug.cgi?id=344851.

Google-sharp

There's a new assembly available in the mono svn repository, module google-sharp. The classes it contains lets you authenticate to a Google service and there also support for managing your Picasa web galleries. As a plus, it also contains monodoc documentation.

Authenticating

The authentication process logs securely into the service as a web browser would do and retrieves the cookies needed. Once we those cookies, we can access the service over HTTP.

using Mono.Google;
class Test {
     public GoogleConnection Connect (string user, string passwd)
     {
          GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
          ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
          conn.Authenticate (user, passwd);
          return conn;
     }
}

In the example, we create a GoogleConnection to be used with Picasa web and do the authentication for the given user and password. Setting the CertificatePolicy to that value will make it accept any server certificate when using an HTTPS connection. To know more about why that is needed (and other ways of achieving the same) see the Mono security FAQ.

Managing a Picasa Web gallery

Once you're authenticated, you can create an album:

PicasaWeb picasa = new PicasaWeb (conn);
string unique_id = picasa.CreateAlbum ("My first album");
PicasaAlbumCollection coll = picasa.GetAlbums ();
PicasaAlbum album = coll [unique_id];

Download all the pictures in it:

PicasaPictureCollection pics = album.GetPictures ();
foreach (PicasaPicture picture in pics.AllValues) {
     using (Stream stream = File.OpenWrite (picture.Title)) {
          picture.DownloadToStream (stream);
     }
}

Upload a new picture to an album:

album.UploadPicture ("some-picture.jpg");

Of course, there's a caveat: currently the authentication process fails when running under MS.NET (too many redirections), so that means that:

  1. We have a bug in Mono that I'm not going to fix by now.
  2. I have to figure out how to make that work on MS

Hopefully, this will open the door for a Picasa Web plugin for f-spot, as Picasa for linux lacks support for Picasa Web. A command-line tool for uploading pictures is on the way.

Enjoy!

FileSystemWatcher breaking news

As gamin used inotify when available, I hesitated adding a backend for Inotify to our FileSystemWatcher.

Things started to change when gnome-vfs added inotify support. Now it's possible that your brand-new linux distro does not have FAM or gamin, as gnome-vfs will trigger file system events directly from data provided by the kernel.

So, yeah, the new backend is already in SVN and you just need to update to get it working (rerunning autogen.sh might be needed, kernel 2.6.?? needed).

Enjoy.

This is a personal web page. Things said here do not represent the position of my employer.