Friday, November 19, 2010

Foray into Qt Models with libferris

Version 1.5.2 of libferris, released yesterday, includes both a QAbstractTableModel and QSortFilterProxyModel targeted at exposing libferris to the world of all things Qt. In libferris a great amount of information is exposed as virtual Extended Attributes for a file. As you can see in the below shot, the md5 as well as "ls -lh" size is available directly as attributes. Before you wonder, the md5 is only calculated on demand and is then cached relative to the mtime of the file.

Each file has thousands of attributes on my machine, these include tagging, geospatial information, extracted metadata, and RDF. In my GTK+2 model/view pair I allow the user to "sort" on a column but really have the view sort on another one. For example, as you see below, sorting on size-human-readable either means Qt or some class you provide needs to know how to properly sort on size strings like 14.2k etc. Instead of this, the QSortFilterProxyModel converts some column names into others, so a size-human-readable sort becomes a sort on the "size" column. As the latter is simply a number Qt knows how to do the right thing (TM). Although both columns are shown in the example shot, there is no need to have the size column visible too.

The mtime is actually converted to a QDateTime by the model. It is stored internally as an epoch integer. Thus the mtime-display column was added in libferris which shows you a human readable version. This is handy for command line tools and others which do not want to know about presentation etc and just want something nice to show the user. Most of these attributes in libferris have schema information, which makes it possible to pass them on to Qt in a nice way. Tags should come through as checkboxes etc.

The next logical step is to get at this from QML. I'll wait until I update to Fedora 14 which has Qt 4.7 in it. With the model, and some way to play back audio I should be able to make an audio player in QML. Two things help here; searches can return their results as a virtual filesystem which can then be shown in the QAbstractTableModel, and filesystem "selections" can be built as filesystems which can also be then displayed in the same way. So I have search and playlist support already from that and ffmpeg or some low battery way to make ogg into air oscillation then completes the loop.

Monday, November 15, 2010

Sharing is Caring...

My repository now contains a steaming ferris-sharing-plugin_0.2_armel.deb which will hook up libferris to the Nokia sharing system on the n900. This lets you click the funky Brussels atom building "sharing" icon from many places and copy images to flickr, 23hq, facebook.

There isn't much feedback at the moment, that is planned for "the future". You might also like to install the ImageMagick from my repo. Simply expand it to /opt and make a link /usr/lib/ImageMagick-6.6.0 -> /opt/ImageMagick-6.6.0/lib/ImageMagick-6.6.0. This gives you proper handling of exif orientation during scaling prior to upload with libferris.

I also have some tweaks to libferris itself which will be in the upcoming 1.5.1 release to help with annotations etc during upload. The next step is to get vimeo and youtube upload support happening too, since libferris can already upload to those.

Friday, November 12, 2010

Pop Quiz Hot Shot - ssh

You have ssh'ed into a host via three others and just noticed a file(s) you would like on the laptop you started all this merriment from, what do you do? Of course you don't have a control connection or tunnelling already setup because its a "once off" multi hop connection.

A solution that is not quite as widely known as I'd thought is to use the sz and rz pair. Hurrah the zmodem programs are still just as useful today as they were in the years of yore. The snag is that your local terminal needs to have some knowledge of this, konsole works nicely and will pop up a dialog asking where to save files "sent" to it. So doing ssh server; date >/tmp/df; sz /tmp/df will result in a dialog appearing on your local display asking where to save the df file to. Note that this works over multiple intermediate ssh hops. Just perfect for when you have routed your way into a protected network via 4 hops and find out that /etc/foo.conf which is 8kb would be *really* nice to have on the laptop.

This is packaged as lrzsz for Fedora and I've made an lszrz tarball available in my n900 repository. Let the zmodem goodness rain down...

Monday, November 8, 2010

Clawmotia and QML: Moving the TV

Some may know that Clawmotia is my MythTV remote control which started back in the n810 days. For a bit of fun while recovering from jet lag I decided to port Clawmotia over to using QML and take advantage of some of the n900's capabilities such as the accelerometer. Shown below is controlling the playback speed by moving the device. Apologies for the flicking video, it seems mythtv doesn't like the mov file in software playback much, but the Bunny is free to use so he made the audition.

Controlling MythTV with an n900 accelerometer from Ben Martin on Vimeo.

The normal functions from the older qedje remote are also available on the main page shown in the video below. I have now put the cursor keys into a submenu which is opened by both the joystick and menu buttons, the latter first getting mythtv to open the menu and then changing the remote configuration to show the cursor key submenu. This explains the vacant positions in the grid in the new design -- submenu shuffle has given me a few extra spots to play with. Also the settings can be set in the program itself now instead of the old edit the launcher file and set environment variables. I would like to make the volume adjustment use a popup slider and also route the hardware vol +/- keys to mythtv, but I'm still working out how to do the later.

Clawmotia QML: The Qt MythTV remote control from Ben Martin on Vimeo.

Interestingly, the big "oh no" moments came when I tried to do trivial things from QML such as reading a file (the accelerometer in /sys). I would have thought that QFile was available but it seems not. Perhaps it is from dedicated javascript files or I'm just doing it wrong^TM. I also notice that the simulator doesn't update that /sys file so you have to test that on the device :/

I also bumped into other things like hooking up signals bidirectionally which would need pass by reference or similar to make it useful in custom QML elements. I might also make some data bound classes to use with QSettings, it seems like an idea for a QString like class to update the QSettings automatically when you assign new data to it.

I also tinkered in Nokias SDK environment for this but reverted to emacs and js-mode because there are just too many things my hands are used to happening that don't in the SDK editor. Though for QML stuff I suspect I need to update my elisp to have better "add property" support so the get/set/signal/member declarations are all added from a "QString foo" input. I have part of that done but need to revisit it.

Monday, November 1, 2010

CRUD, metadata, indexing and Trees, please

For those in Australia who want to hear about libferris and doing interesting things with data using a everything is a file paradigm then you might like to drop by OSDC later in November and LCA in Brisbane in late January 2011. Both of these events will include a session with me talking about not only strange but also hopefully interesting and useful things you can do with your data using libferris.

Examples include mounting flickr, facebook, youtube, gstreamer et al. Just "cp" your image to upload. With gstreamer just "cp" from the camera on the n900 to your web service of choice. And heavier data manipulation like interfacing with SQLite and XQuery to get at any data the filesystem exposes such as these web services, berkeley db, relational data, dbus, running applications, composite files etc. I might also throw in some ODF processing such as using document forms to edit postgresql databases through virtual documents. Though what is in the main talk and what is in the post amble at the pub is yet to be delineated.