Motorcycle Adventures and Free Software
Henri Bergius
Biker, free software consultant, neogeographer

There is a total of 768 posts.

Weblog: category "mobility"

Getting started with the Midgard content repository

Posted on 2010-03-09 15:50:26 UTC in 3° 3.806 S 60° 6.420 W 10km NW of Manaus, BR to . 3 comments.

I'm doing a talk today in the Bossa Conference about using Midgard as a content repository for mobile applications. As part of my presentation I wrote some simple example code for using the Midgard APIs in Python, and thought they would be good to share to those not attending the event as well.

The idea of a content repository is that instead of coming up with new, isolated file formats or database setups for your application you can just work with objects and signals, and let Midgard handle the rest. This is something that lots of people are doing with CouchDB as well, but we feel Midgard, with its light footprint and native APIs for languages like Python, C, Vala and PHP fits better in the mobile applications context.

Installing Midgard

Midgard packages are available for many different Linux distributions through the OpenSuse Build Service. To find the right repository for your setup, go to the OBS project page. For example, on my Ubuntu Karmic netbook the URL to add to apt sources.list is deb http://download.opensuse.org/repositories/home:/midgardproject:/mjolnir/xUbuntu_9.10/ ./. Then I just:

sudo apt-get update
sudo apt-get install python-midgard2

Midgard is also available in Maemo extras and for OS X on MacPorts.

Defining a schema

The first thing when developing a Midgard application is to define your storage objects. This is done using the MgdSchema XML format. In this case we're doing a simple "attendee" object that amends Midgard's built-in person record with information related to the conference:

<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.midgard-project.org/repligard/1.4">
    <type name="openbossa_attendee" table="openbossa_attendee">
        <property name="id" type="unsigned integer" primaryfield="id">
            <description>Local non-replication-safe database identifier</description>
        </property>
        <property name="person" type="unsigned integer" link="midgard_person:id">
            <description>Person attending the event</description>
        </property>
        <property name="registration" type="datetime">
            <description>Registration date of the attendee</description>
        </property>
        <property name="likesbeer" type="boolean">
            <description>Whether the attendee likes beer</description>
        </property>
    </type>
</Schema>

Then we just save this XML file into /usr/share/midgard2/schema/ so that Midgard will find it.

Initiating the repository connection

Once the MgdSchema is in place it is time to import antigravity and start hacking in Python. The code works pretty much in the same way in other languages Midgard is available for, but Python is used here for the sake of simplicity. First we load the Midgard extension:

import _midgard as midgard

Then we setup the repository connection. With these settings we will store our content into an SQLite database located in ~/.midgard2/data/midgardexample.db:

configuration = midgard.config()
configuration.dbtype = 'SQLite'
configuration.database = 'midgardexample'

# Open a Midgard repository connection with our config
connection = midgard.connection()
connection.open_config(configuration)

As this is the first time we're interacting with the repository we need to tell Midgard to prepare the storage for itself and also for our new openbossa_attendee class:

midgard.storage.create_base_storage()
midgard.storage.create_class_storage('midgard_person')
midgard.storage.create_class_storage('midgard_parameter')
midgard.storage.create_class_storage('openbossa_attendee')

Interacting with data

First we create a person object with our attendee:

person = midgard.mgdschema.midgard_person()
person.firstname = 'Leif'
person.lastname = 'Eriksson'
person.create()

Then we create our attendee object and link that with the person we just created:

attendee = midgard.mgdschema.openbossa_attendee()
attendee.person = person.id
attendee.likesbeer = True
attendee.create()

Querying data

Later we'll want to find out about all Leifs attending the event. We do this by using the Midgard query builder:

qb = midgard.query_builder('openbossa_attendee')
qb.add_constraint('person.firstname', '=', 'Leif')
attendees = qb.execute()

The query builder returns us a list of matching attendee objects. We can go through them and also fetch the associated persons:

for attendee in attendees:
    person = midgard.mgdschema.midgard_person()
    person.get_by_id(attendee.person)
    if attendee.likesbeer:
        print "%s, %s is attending the event" % (person.lastname, person.firstname)

Then we can update the persons with their email addresses:

    person.email = 'leif@vinland.no'
    person.update()

For basic data handling, that's it! When you need more, you can extend objects with file attachments or parameters. You can also create joined records using Midgard views. Midgard provides D-Bus signals, transactions, centralized metadata, synchronization and many other things.

Sponsored links

Microsoft Certification Exams โนเกีย Nokia มือถือ Online Project Management save money using, phone card
Reviews มือถือ Mobile All Apps

Register and log into meego.com using your maemo.org account

Posted on 2010-02-24 13:57:09 UTC in 60° 10.080 N 24° 55.578 E Helsinki, FI to . 4 comments.

MeeGo is the new mobile Linux platform developed by Nokia and Intel. As the community is forming up, we thought that it would be good to enable people to use their maemo.org identities also on the MeeGo web services (as well as on any other OpenID enabled website). For this, let me introduce Maemo's OpenID provider.

First of all, go to meego.com and click login:

meego-login.png

Select the "Log in using OpenID" option, and provide your maemo.org OpenID URL:

meego-maemo-openid.png

Then the request will be redirected to maemo.org where the site will check your credentials and ask whether to relay your information on to meego.com:

maemo-openid-meego.png

And that's it, suddenly you can use your maemo.org account with meego.com!

 

The same OpenID provider component can also be utilized on any other Midgard-powered website.

Going to the Bossa Conference

Posted on 2010-02-23 12:38:44 UTC in 60° 10.194 N 24° 56.304 E Helsinki, FI to . 0 comments.

Bossa Conference, an event about mobile development with free software technologies will be held on March 7th-10th in Manaus, Brazil. This year I'm speaking about using Midgard as a replicated storage layer in mobile applications, with examples for multiple programming languages and toolkits.

The idea behind the Midgard content repository is that instead of coming up with your own file formats you can just keep working with objects and signals, and let the repository deal with the rest.

bossaconference-small.png

It is always fun to go to Brazil and meet the vibrant free software community there. The plan is to fly over this weekend, spend a few days in Sao Paulo and then head for the Amazon. Feel free to ping me if you're around.

Maemo's community involvement infrastructure is what MeeGo needs

Posted on 2010-02-16 09:39:35 UTC in 60° 10.566 N 24° 55.206 E Helsinki, FI to . 1 comments.

Nokia's Maemo and Intel's Moblin are merging to form MeeGo, a development environment for a new class of internet-connected devices ranging from smartphones through netbooks to TV sets. This may be finally what provides the free software world with a consistent and modern alternative to the iPhones and iPads that the proprietary world has come up with, the "magical user experiences" Linux Foundation's Jim Zemlin was asking for.

meego-small.png

Unlike Android, both Moblin and Maemo stacks have been very promising in the sense that they've been closely aligned with existing and well-known Linux desktop technologies. All RPC communications happen through D-Bus, Qt or Clutter is used as the GUI toolkit, there is Telepathy for integrated VoIP and IM communications, and Moblin even comes with the GeoClue location service.

So far the discussion about this merge has very much focused on technical terms: what toolkit to use (Qt is recommended), what package manager (RPM) and so forth. However, what hasn't been discussed yet is what will happen to Maemo's excellent infrastructure for community involvement:

  • Brainstorm is a tool for proposing ideas and solutions to them, and then voting to qualify them. This is a very good way to gather ideas and feedback from the community, and some brainstorms have even ended up having community-led free implementations available, freeing Nokia from having to write all platform functionality
  • Talk is the very popular forum for both Maemo end users and developers. Having an open forum to discuss it all, and having also people from Nokia and Intel there would help to communicate the aims and decisions around the platform a lot better
  • Packages and Downloads provide a fully open and crowdsourced "app store experience" where the community is free to develop, upload and install Maemo applications through a consistent service that provides quality control, nice installers and a free API for browsing the software available
  • Community Council and the Sprint process have been the way Maemo's community infrastructure has been designed and developed out in the open. The various tasks have been documented in the Wiki, and people have been able to follow the progress through a Qaiku workstream
  • Karma is a way to credit community members for their involvement. The involvement can be technical (for instance, developing a popular Maemo application) or social (publishing popular blog posts or helping people on Talk), and has been used as a criteria for Community Council and other elections. Karma also helps Nokia to qualify community members, to find the people who should have access the developer devices for instance. In a large community it is hard to identify the people who are just loud and the people who are doing actual valuable contributions from each other without such tools
  • Social News and Planet are a way for the community to aggregate and promote important posts around the project. We look at things like social bookmarking, blog links and votes happening on the Maemo site to determine the most important stories of the day, to provide an "automatic newspaper" for the project

Providing all or some of these services as part of the MeeGo infrastructure would enable the community to feel involvement, and even ownership in the new project that is shaping up. This is critical for a project that has such a big reliance on new innovation and connectivity with the upstream, especially at the time of such big change.

Google's Near Me Now: not quite there

Posted on 2010-01-08 11:50:11 UTC in 60° 10.290 N 24° 56.796 E Helsinki, FI to . 0 comments.

Google launched a new mobile web service called Near Me Now that can recommend things like restaurants, bars and ATMs near you. This uses browser geolocation to provide only results relevant to where you are.

googlenearme.jpg

The idea is quite good: to replace business directories like Yelp or eat.fi with something that is easily accessible from Google's homepage and uses Google's great relevancy algorithms.

However, the implementation is not quite there yet. My main gripe is that they implemented this using browser sniffing so that the feature can be accessed only with iPhones and Android devices. Even though I'm using N900, a mobile device that has GPS and provides geolocation through the browser I cannot access that site. That reeks of the bad old times of IE-only websites.

Lesson: if you need browser sniffing to provide some feature, implement it based on browser capabilities, not the user agent (which can anyway be spoofed easily).

Posting to Qaiku via ping.fm

Posted on 2009-12-07 10:47:02 UTC in 60° 9.798 N 24° 55.674 E Helsinki, FI to . 1 comments.

Ping.fm is a useful tool if you have friends on many social networks as it allows you to write updates to all of them via a single interface. In addition to the web interface there are many tools that allow posting to ping.fm, including SMS and applications for Android handsets and the iPhone.

So far a problem with ping.fm has been that it doesn't support Qaiku, the conversational microblogging tool that we're using to handle workstreaming in Maemo.org Sprints. But now it is possible thanks to the Custom URL functionality on ping.fm.

If you already have a Qaiku account you can start posting to it via ping.fm in the following way:

  1. Enable Qaiku API in your settings and copy the API key
  2. Register to ping.fm
  3. Add a Custom URL to send statuses to
    pingfm-customurl1.png
  4. Enter the URL http://www.qaiku.com/api/statuses/update.json?apikey=xx where xx is your API key as the Custom URL
    pingfm-customurl2.png
  5. Testing posting via the ping.fm web interface:
    pingfm-post.png
  6. See your new post on Qaiku:
    pingfm-qaiku-shown.png
  7. If you want to post to a channel, just begin your message with #channelname

If ping.fm is not your thing, there are also other non-web ways to use Qaiku. For example Mauku for N900 and Gwibber for the Linux desktop work nicely with the service. Qaiku also has an XMPP bot that you can use by simply adding qaiku@jabber.org as your instant messaging contact.

Microfeed could be to status updates what Telepathy is to instant messaging

Posted on 2009-10-26 09:12:23 UTC in 60° 9.816 N 24° 55.686 E Helsinki, FI to . 0 comments.

Microfeed is a new D-Bus service for handling status updating and microblogging entries from various services. Just like Telepathy allows various applications to utilize instant messaging connections, Microfeed does the same for microblogging:

Microfeed is a specification and a reference implementation of client-server architecture providing access to various information sources that have a feed-type interface. Examples of those feed sources include micro-blogging services, such as Twitter, Facebook, Jaiku, Qaiku, and Laconi.ca. By utilizing Microfeed architecture, a client application can focus on user interface, while the actual feed fetching is done in the background independently. The communication between a local Microfeed server publishing information about feeds and a client application displaying that information to an user is done with the D-Bus messaging following the publisher-subscriber principle.

microfeed.png

Microfeed service already is the power behind Henrik Hedberg's new Mauku microblogging interface for Maemo 5. Here you can see a stream of updates from both Qaiku and Twitter:

mauku_twitter_qaiku.png

If you're implementing a tool that deals with microblogging services, please consider using microfeed for it. Advantages from this include:

  • User accounts to various services need to be entered only once and can be reused
  • You don't need to concern yourself with the particular features or quirks of a microblogging service API, just use the D-Bus interfaces provided by Microfeed
  • Twitter? Qaiku? StatusNet? Facebook? You can let your users choose what services they want to use, without overhead of having to implement the protocols for each of them

More information from http://microfeed.org/

Fall conference schedule

Posted on 2009-09-27 15:58:47 UTC in 60° 10.272 N 24° 55.956 E Helsinki, FI to . 3 comments.

After a brief summer motorcycling break the fall is shaping up to be quite full with conferences. Here is the current list:

Explaining signals at Gran Canaria Desktop Summit

Looking forward to all the interesting discussions and ideas that will surely come up from these events. If you will be around in one of those, make sure to look me up and we can chat. The events will also be covered in my Qaiku stream.

Will content repositories kill the file?

Posted on 2009-07-30 17:10:24 UTC in 60° 10.524 N 24° 55.146 E Helsinki, FI to . 0 comments.

MDK laments the demise of the simple file in the onslaught of storage services:

Sure, the applications still give you a way to share things and take them out of the storage. You can export a contact out of your address book as a vcard file. But the role of The File here is slowly being reduced to a role of an intermediate storage medium. The business card is temporarily put in the .vcf file before it gets injected into somebody else’s database (another address book?).

As more and more applications operate on databases, the computer is becoming a monolithic black-box that “has things”. How exactly (and where) the data is stored is becoming less clear. The application and the interface becomes united with the user data. It becomes one.

This echos the sentiments of Alex Payne when he warned against what he calls Everything Buckets:

Computers work best with structured data. Everything Buckets discourage the use of structured data by providing a convenient place to commingle “structureless” data like RTF and PDF documents. Rather than forcing the user to figure out the rhyme and reason of their data (for example, by putting receipts in a financial management application and addresses in an address book), Everything Buckets cry: “throw it all in here! Search it! Maybe I’ll corrupt my proprietary database, but maybe I won’t and you’ll have the joy of sifting through a mire of RTF documents. Doesn’t that sound great?”

And yes, I agree that obscure application-specific databases are not really better than obscure proprietary file formats.

This is exactly why I've been talking about content repositories, services like Midgard2 and CouchDb that not only can provide superior content storage and organization, but do it in a way that multiple applications can share. You can easily write your own scripts to perform batch operations on the data, and receive D-Bus notifications when something changes.

And good repositories also provide easy synchronization tools so you can have your data available on all of your computers, and even on the web. If they can also do peer-to-peer sharing, we're close to achieving the fully free cloud.

Technorati Tags: , ,

OSM2Go: wonderful mapping tool for Maemo

Posted on 2009-07-12 13:13:01 UTC in 52° 21.774 N 4° 54.416 E Amsterdam, NL to . 0 comments.

Today in the State of the Map conference I gave a lightning talk introducing Till Harbaum's OSM2Go, a wonderfully simple tool for contributing to OpenStreetMap.

OSM2Go editing Hietalahti, Helsinki

If you want to contribute to a freely available map of the world, download OSM2Go to your tablet and start mapping! My slides are available on SlideShare.

See also my Qaiku notes for SoTM day 1 and SotM day 2. Really amazing to see how far the project has advanced since the 2007 conference. Much of Western countries is already mapped, and many NGOs are working to get the developing world mapped, in many places for the first time ever in digital format.

Technorati Tags: , ,