Gnome 3.10 released

Gnome 3.10 is released and it has some cool features. It feels good that Geolocation and Maps application are part of it.
I wrote the client and server for GeoIP based GeoLocation when I was doing my OPW internship with Gnome Foundation. Initially the libraries were part of geocode-glib, but the code for GeoIP has been moved to GeoClue.

And that reminds me (quite shamefully) I have been sitting on the Wi-Fi code for a long time. It’s time to get that code out.

Gnome 3.10 released

Last month of OPW internship

More than 2 months have passed since I started working on GeoIP server and client libraries. The libraries are now ready to use. They provide IP address based Geolocation information.

To use the client library, all you have to do is – create a GeocodeIpclient object and perform a search for Geolocation information. The search function has both synchronous and asynchronous versions –

void geocode_ipclient_search_async (GeocodeIpclient *ipclient,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);

char *geocode_ipclient_search (GeocodeIpclient *ipclient,
GError **error);

To have a better look at how to call these functions visit test-geoip.c

Since we do not have a web service yet, you have to run the GeoIP server at your localhost before you use the client to query for geolocation.

Last week, I’ve added support to update Maxmind city and country databases. Since IP addresses are reassigned, the databases need to be updated. If they are not updated, they loose about 1.5% accuracy each month.

Maxmind update their databases on first Tuesday of every month. So all you need to do is to run the updater (we call it geoip-update) from a cron job. That way you don’t have to worry about downloading the databases manually.
If you are interested to know how accurate the Geolocation data is then visit this link

If you use the Geocode GeoIP libraries now, you will see that the geolocation information based on IP is not as accurate as your google map shows in your smart phone or firefox shows if you enable location sharing from it. That’s because they use a lot of other information e.g. WiFi access point data, cell tower ids etc. to provide you a very accurate location.

The next task that I am working upon now is to increase accuracy of GeoLocation information provided by Geocode GeoIP libraries.

Last month of OPW internship

Gnome internship – my experience so far

I am 22 days old as a Gnome OPW intern¬†and it has been a very nice experience so far. I was supposed to write at least one blog post in every two weeks. But, sometimes I get this writer’s block when words simply fail me. Besides,in the last few weeks, I really enjoyed writing code and I rarely wanted to write anything other than that! ūüôā

So, what am I working on?
I am writing server and client libraries for GeoIP and WiFi geolocation service.

What have I done so far?
I have written the server side code. You can find it here
It looks up the GeoLiteCity database¬†which provides free geolocation data for an IP address and returns the geolocation data in JSON format. So if you query with an IP eg., you will get a JSON output like the following –

[sourcecode language=”text” gutter=”false”]
{"results":{"":[{"location":{"latitude":32.807201385498047,"longitude":-117.16490173339844},"address":[{"name":"San Diego","type":"city"},{"name":"California","code":"CA","type":"region"},{"code":"92111","type":"postalcode"},{"name":"United States","code":"US","type":"country"}],"timezone":"America/Los_Angeles","accuracy":"city","attribution":"This product includes GeoLite data created by MaxMind, available from\n"}]}}

What new stuff did I learn?
Oh! A lot of things!¬†Setting up the Apache web server, using¬†Git and the Glib libraries were new to me. But What wasn’t new yet I had to relearn and give importance to was coding style. Initially I was not paying much attention to the existing conventions. I made my mistakes and shamefully I confess, more than once (which is REALLY very embarrassing!). But on the brighter side, now I have become more cautious about it.

What next?
I have started working on the client side. I have already written a synchronous function to fetch data from the server. But I need to make it an object. So at present I am trying to learn Gobject. I am planning to write the asynchronous version of the function in this week as well.

Gnome internship – my experience so far

Building Geocode-glib

I was trying to build Geocode-glib on Ubuntu 12.04. But I was getting the following error while running ./configure –
[sourcecode language=”text” gutter=”false”]
configure: error: Package requirements (gio-2.0 >= 2.34
  json-glib-1.0 >= 0.14
  libsoup-2.4) were not met:
Requested ‘gio-2.0 >= 2.34’ but version of GIO is 2.32.3
Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.
Alternatively, you may set the environment variables GEOCODE_CFLAGS
and GEOCODE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Initially I solved the above problem with jhbuild. I used –

[sourcecode language=”shell” gutter=”false”]
jhbuild buildone glib geocode-glib

And jhbuild took care of the version mismatch problem by picking up the gio library from where jhbuild installed it.
I looked into the config.log file in the directory where jhbuild successfully built geocode-glib. It had set ¬†–

[sourcecode language=”bash” gutter=”false”]

So if you want to build without jhbuild on Ubuntu 12.04, first get the latest glib from¬†and install it. Then¬†you can either do –

[sourcecode language=”shell” gutter=”false”]
./configure <the_flags_you_want_to_set> ¬†PKG_CONFIG_PATH='<where_you_installed_latest_glib>/gnome/lib/pkgconfig:<where_you_installed_latest_glib>/gnome/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig’

you can set the¬†environment variables GEOCODE_CFLAGS¬†and GEOCODE_LIBS –

[sourcecode language=”shell” gutter=”false”]
./configure <the_flags_you_want_to_set> GEOCODE_CFLAGS=’-pthread -l<where_you_installed_latest_glib>/gnome/include/glib-2.0 -I<where_you_installed_latest_glib>/gnome/lib/glib-2.0/include -I/usr/include/json-glib-1.0 -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 ¬†‘ GEOCODE_LIBS=’-L<where_you_installed_latest_glib>/gnome/lib -ljson-glib-1.0 -lsoup-2.4 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ¬†‘

Note that, the json-glib and libsoup libraries are taken from the default libraries that Ubuntu provides.
Building Geocode-glib

Contributing to Geocode-glib in Gnome

I recently to contributed a small patch to Geocode-glib library. It was my first patch and it was definitely thrilling to see my name as the author in the repository. So, let me give you a walk through on what is Geocode-glib and what I did in it.

What is Geocode-glib?

It’s a convenience library for the Yahoo! Place Finder and GeoPlanet APIs. The Place Finder Web service allows to do geo-coding and reverse geo-coding. It’s used by Empathy and Evolution.

What did I do in Geocode-glib?

I hacked on the library’s test program. The test-program earlier did not have any feature to differentiate search results with same name. e.g. if you search with a “Delhi” it would show you results with only latitudes and longitudes. And from that result, you could not differentiate the search results with name “Delhi”.

I came up with a way which would show relevant information along with the place name and its latitude and longitude so that the place can be differentiated. So now if you search with Delhi, it would show –


Thus you can differentiate between the places now. Here’s the link to my commit

It was really great to code after such a long time! And now I am wondering, why the hell didn’t I contribute to such projects earlier! But, you know what they say – ¬†better late than never! ūüėÄ

Contributing to Geocode-glib in Gnome