Skip to content. Skip to navigation

Ian Lawrence

Sections
Personal tools
You are here: Home Blog Location Services on Ubuntu Mobile

Location Services on Ubuntu Mobile

GeoClue a geographic information framework for Linux. It is a Free Software service/library that usually runs on a mobile computer. Here it is running on Ubuntu Mobile


Its recommended to have a look on
this  post if you are not familiar with
Moblin, before getting started.

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:

vern@N800-hacker:~$ mkdir flash;cd flash
vern@N800-hacker:~/flash$
vern@N800-hacker:~/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:
vern@N800-hacker:~/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:
vern@N800-hacker:~/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
vern@N800-hacker:~/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:
vern@N800-hacker:~/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:
Location Services





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)
vern@N800-hacker:~$ git clone git://anongit.freedesktop.org/git/geoclue
vern@N800-hacker:~$ cd geoclue
vern@N800-hacker:~/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:
vern@N800-hacker:~/geoclue$ sudo apt-get install gpsd
try again:
vern@N800-hacker:~/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:
vern@N800-hacker:~/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:
vern@N800-hacker:~/geoclue$ sudo ./autogen.sh 
vern@N800-hacker:~/geoclue$ sudo make
vern@N800-hacker:~/geoclue$ sudo make install
Fire up pyphantom the hildon desktop
IDE and create the following Home 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 some parsing
bug in the hostip API):
Geoclue Debug Output




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.
vern@N800-hacker:~/geoclue/src$ sudo cp geoclue.py /home/vern/moblin/image/targets/target/fs/usr/lib/hildon-desktop/
vern@N800-hacker:~/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.

Mapufacture

_____
tags:
Friday, August 03, 2007 in Code  | Permalink |  Comments (1)
del.icio.us   Digg   Yahoo   Google   Spurl

Executing Python Apps

Posted by vern at 2007-07-30 08:52


Mobile player is also a python application.
Maybe it's not the best way to launch python application, but it can be a reference.
1. create an exe file under /usr/bin -- mobile-player
#!/bin/sh
Cd /usr/share/mobile-player
Python media_gui.py
2. add mobile-player in *.desktop file
Exec=mobile-player
Type=Application
...
3. add mobile-player in conf.xml
<app id="6" title="Media Player" desc="Mobile media player" icon="icons/media.png"
path="/usr/bin/mobile-player" />
Blog
« January 2018 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Categories:
Borala (4)
Bricolabs (12)
Code (57)
Estudiolivre (12)
Life (26)
MetaReciclagem (9)
Thoughts (16)
Work (41)