Showing the User Relevant Information Based on their Location

This is a work in progress and pulls from upstream code such as Moblin and GeoClue.

Flash UI

Begin by checking the UI out from the repo:

user@host:~$ mkdir flash;cd flash


user@host:~/flash$


user@host:~/flash$ git clone rsync://moblin.org/repos/projects/mobile-basic-flash.git

[you need git-core if you do not have it ... apt-get install git-core] the above commands create a folder mobile-basic-flash:

user@host:~/flash$ cd mobile-basic-flash

This folder has the structure:

autogen.sh

configure.ac

content

COPYING

debian

Makefile.am

po

src

Inside the 'src' folder are the source .fla and Action Script .as files. Inside the 'content' folder are the compiled .swf files, the HTML page which embeds the flash movie (called flash_home.html), and 'backgrounds' and 'icons' folders which should be obvious. There is also the file conf.xml which is read at compile time and 'configures' the flash movie.

For my plugin I changed this file to look like this.

....snip


<app id="8" title="TBD Camera" desc="Camera App" icon="icons/camera.png" path="" />


<app id="9" title="Control Panel" desc="Control Panel" icon="icons/controlpanel.png" path="/usr/bin/controlpanel" />


<app id="10" title="Location Services" desc="" icon="icons/geoclue.png" path="/usr/bin/geoclue" />


...snip

We are telling Flash to make an XML socket call and execute the file /usr/bin/geoclue. We will to create this file later on Put you application icon inside the 'icons' folder and run:

user@host:~/flash/mobile-basic-flash$ ./autogen.sh

this 'loads' the conf.xml into the flash movie then we need to copy the movie, the conf.xml file and the icon to the correct place inside moblin

user@host:~/flash/mobile-basic-flash/content$ sudo cp conf.xml flash_home.swf /home/vern/moblin/image/targets/target/fs/usr/share/mobile-basic-flash/


Password:


user@host:~/flash/mobile-basic-flash/content/icons$ sudo cp geoclue.png /home/vern/moblin/image/targets/target/fs/usr/share/mobile-basic-flash/icons/

The UI now looks like this with our

Location Services icon:

The GeoClue backend.

GeoClue is a D-Bus API and library and it uses several backends to get geographic data from various sources and abstracts the differences of those data sources as much as possible, so applications can just ask for e.g. current coordinates and not care where the coordinates come from (current options for coordinates are GPS and hostip.info). The following APIs (and backend types) are supported or planned:

* Positioning

* Routing

* Geocoding

* Map

* Track Logs

For this example we will use a backend called hostip.info which returns a city based on your IP.

(need git-core)


user@host:~$ git clone git://anongit.freedesktop.org/git/geoclue


user@host:~$ cd geoclue


user@host:~/geoclue$  sudo ./autogen.sh 


configure: error: Install gpsd Debian package or its source-code equivalent:

a quick apt-cache search reveals:

gpsd - GPS (Global Positioning System) daemon

so:

user@host:~/geoclue$ sudo apt-get install gpsd

try again:

user@host:~/geoclue$  sudo ./autogen.sh





checking for HTTPXML... configure: error: Package requirements (libsoup-2.2 libxml-2.0) were not met:





No package 'libsoup-2.2' found





Consider adjusting the PKG_CONFIG_PATH environment variable if you


installed software in a non-standard prefix.





Alternatively, you may set the environment variables HTTPXML_CFLAGS


and HTTPXML_LIBS to avoid the need to call pkg-config.


See the pkg-config man page for more details.

It seems like we are missing some development libraries:

user@host:~/pyphantom_b4Brazil/geoclue$ sudo apt-get install libglib2.0-dev libgtk2.0-dev libsoup2.2-dev libgconf2-dev libxml++2.6c2a

and now it works:

user@host:~/geoclue$ sudo ./autogen.sh


user@host:~/geoclue$ sudo make


user@host:~/geoclue$ sudo make install

Fire up pyphantom the hildon desktop IDE and create the following plugin:

import gtk


import pygtk


import hildondesktop


import dbus


import os





class GeocluePlugin(hildondesktop.StatusbarItem):


    def __init__(self):


        hildondesktop.StatusbarItem.__init__(self)


        # Start with getting position from GeoClue


        bus = dbus.SessionBus()


        # TODO: Get the GeoClue interface to use from /schemas/apps/geoclue/position/defaultpath


        # and /schemas/apps/geoclue/position/defaultserviceGConf keys


        proxy_obj = bus.get_object('org.foinse_project.geoclue.position.hostip', '/org/foinse_project/geoclue/position/hostip')


        geoclue_iface = dbus.Interface(proxy_obj, 'org.foinse_project.geoclue.position')





        # Get the coordinates from the service


        coordinates = geoclue_iface.current_position()


        #location = geoclue_iface.current_location()


        # We can also use hardcoded


        #coordinates[0] = 60.158806494564


        #coordinates[1] = 24.9426341056824





        print "According to GeoClue you are in %s %s." % (coordinates[0], coordinates[1])





def hd_plugin_get_objects():


    plugin = GeocluePlugin()


    return [plugin]]


and this will show user coordinates

in the Debug I/O (you may need to try a few times as there is a parsing bug in the hostip API):

Inside the plugin 'src' folder there will be 2 files: geoclue.py and geoclue.desktop and we need to copy these to the correct areas inside our image.

user@host:~/geoclue/src$ sudo cp geoclue.py /home/vern/moblin/image/targets/target/fs/usr/lib/hildon-desktop/


user@host:~/geoclue/src$ sudo cp geoclue.desktop /home/vern/moblin/image/targets/target/fs/usr/share/applications/hildon-marquee

in the file:

/etc/hildon-desktop/marquee.conf

add the following line:

/usr/share/applications/hildon-marquee/geoclue.desktop

Now we need to create our /usr/bin/geoclue file:

        #!/bin/sh


        cd /usr/lib/hildon-desktop/


        python geoclue.py


and then do:

chmod +x geoclue.py

we then need to start moblin and choose our application in the UI. It executes and presents the user with some info about their current location.