Thursday, April 29, 2010

Setup WeaveSync test server on localhost

Google requires us to keep track of our GSoC project work, therefore I decided to use my dear old (or maybe not so old..) blog to report my weekly work :) This is my first report..

GSoC work : Week 1 (26th Apr to 2nd May)

I had two options for a test server for Weave. The Weave 1.0 full server, which comes in two parts (sync server and registration server) or the Weave Minimal server. Since the Weave wiki itself mentions that the full server is complicated to setup and advises people to try the minimal server instead, I decided to setup the minimal server first and then try my luck with the full server.

The full server can be setup with a MySQL database, however the minimal server requires SQLite. Both servers require SSL setup on the webserver (i am using Apache2).

How to setup SSL on Apache2

SSL (new version is TLS) is a cryptographic protocol for providing end-to-end security for communication over the Internet. While looking for a tutorial to setup SSL I came across this article http://www.symantec.com/connect/articles/apache-2-ssltls-step-step-part-1 which gives a good explanation of how SSL works.

For setting up SSL I referred the tutorials http://beeznest.wordpress.com/2008/04/25/how-to-configure-https-on-apache-2/ & http://www.debian-administration.org/article/Setting_up_an_SSL_server_with_Apache2.

The steps were:

1. Enable SSL on apache2
2. Generate key and certificate
3. Edit my virtual hosts configuration file ( /etc/apache2/sites-available/default ).

This gave me the following configuration: http://pastebin.mozilla.org/720065

Now I can access https://localhost from the browser (first time you do this you get a security warning, then you need to add an exception and save the server certificate).


Setup Weave Minimal Server on localhost

I got the server from here : http://tobyelliott.wordpress.com/2009/09/11/weave-minimal-server/ and setup after following the instructions in the ReadMe file. I had to install SQLite3 which I did by using 'apt-get install sqlite3'.

Now I could run weave extension using my custom test server. For the server URL i specified https://localhost/weave_minimal/ and everything worked (well not the first time, because I hadn't added an exception for https://localhost the first time!) just as if I were using the Mozilla server.

The SQLite database is the weave_db file and to view the data I used the SQlite database browser application.


Setup Weave 1.0 full server

I setup the full server on locahost as well in case I require it for future testing. This was harder to setup than the minimal server.

I setup the database with MySQL and followed the installation guides https://wiki.mozilla.org/Labs/Weave/Sync/1.0/Setup (for sync server) & https://wiki.mozilla.org/Labs/Weave/User/1.0/Setup (for registration server). The server requires php to support both PDO & JSON. I had to add PDO support to my existing php5 installation to get the server working.

To run weavesync addon with full server, I specified the server URL as https://localhost/ (end '/' is always required).

I could browse the sync data using the MySQL Query Browser program.

Right now I'm using the minimal server, because there is still an error with the sync server of the full server installation (the sync server test doesn't run - it gives Authentication error and although syncing happens with the extension there is an error in the 'id' field that specifies the type of payload (history, tabs, prefs etc.) being synchronized. I hope to fix this problem soon.

This week I also got to know some of the Seamonkey developers and how they communicate over IRC:) I also had my first official meeting with my mentor, Robert Kaiser to discuss the project. During this meeting it was decided to complete feed status syncing first before working on mail status syncing due to the problems that will arise in mail status sync especially for POP3 mail downloads. Since tab sync is already functional, it was decided have a suitable overlay for 'Tabs from other computers' and test the functionality with it. I will be working on this next week.

So how was my first week as a GSoC student? Definitely exciting!:) It's my first time working with the opensource community and the Seamonkey community was very kind and welcoming:) I also had the opportunity to reply to some Seamonkey user queries this week and try out some IRC commands like /me !:D

That's it for week no. 1 but hope to have much more to report in the coming weeks (15 more to go!):)

Monday, April 26, 2010

Google Summer Of Code 2010!

Wow. I'm selected to Google Summer Of Code 2010! This is my first time applying and since its my final year in university, i thought it would probably be my last chance too! So I was so afraid to check results and see a rejection. I didn't check email until 12.30am (the time of announcement in local time), and I couldn't believe it when i saw the Congratulations email! I checked on the gsoc site as well just to make sure the Google mail program hadn't got it wrong smehw!:D

Then I did a quick chat with my other friends who got selected and thanked my mentor(Robert Kaiser) for selecting me and also thanked Igor Velkov(my assistant mentor of sorts:)). I still have a long list of people to thank though! Everyone who has encouraged me in anyway to enroll for Google Summer Of Code!

GSoC is a big step for me, because I hope to learn all about Opensource programming from it and hopefully it will help me achieve my long term goals and ambitions in life:)

The project I am selected to participate in is a Mozilla project for the Seamonkey internet application suite, which is a browser and email and news all rolled into one. It's just like using Firefox with Email and News built in. And even better the project is an addon and still better its about data synchronization! This is so relevant to my final year project in university that it seems like just the perfect project for me!:)

The project is about implementing tabs and mailnews status sync engines for WeaveSync addon for Seamonkey. I have already started up some work on this and hosted it here (http://svn2.xp-dev.com/svn/smread/trunk/).

So what is a Seamonkey? This is one of the first questions I had when deciding to apply for this project. Seamonkey is a kind of shrimp and it was a code name for the original Mozilla Netscape suite. This later became Seamonkey. There are pics of seamonkeys on wikipedia but I prefer the Seamonkey icon which is quite lovely:)



If you haven't tried Seamonkey yet I suggest you check it out now. You can download it here. http://www.seamonkey-project.org/. It's the perfect solution for keeping track of all the blogs and new sites you follow and keeping track of your email properly:) And with the WeaveSync addon for tabs and mailnews sync coming up soon its gonna get a whole lot better!;)

Thank you to the Seamonkey, Mozilla and Google opensource communities for giving me this wonderful opportunity!

Saturday, April 17, 2010

Turn your laptop into a wireless router in Ubuntu

It is easy to setup an ad-hoc wireless network on Windows (http://www.kombitz.com/2009/02/09/windows-7-how-to-create-an-ad-hoc-network/) to share your internet connection with another pc over a wireless connection but doing the same on Ubuntu is complicated. No wizards here, just plain old terminal commands.

Converting your laptop into a wireless router is an easy way to share your internet connection (broadband) with another laptop without requiring a multi port router or a wirless router or any cable connections. See diagram below..

Here's how I did it on Ubuntu 9.04. Took a lot of experimenting to find the right method but the following steps finally got it working.

-First, install the packages dnsmasq, ipmasq, and dhcp3-server

sudo apt-get install dnsmasq
sudo apt-get install ipmasq
sudo apt-get install dhcp3-server

-Assign a static IP address for the wireless card on the desktop machine by editing the file /etc/network/interfaces. Add these lines to the end of the file (if you already see wlan0 somewhere else, delete that first):

auto wlan0
iface wlan0 inet static
address 192.168.0.1
netmask 255.255.255.0
broadcast 192.168.0.255
wireless-mode ad-hoc
wireless-essid YOUR-NETWORK-SSID-HERE
wireless-key YOUR-NETWORK-KEY

-Next edit the file /etc/default/dhcp3-server by finding the line with INTERFACES="" and replacing it with

INTERFACES="wlan0"
(This tells the DHCP server to listen on the local network for connections)

-Now open the file /etc/dhcp3/dhcpd.conf. Find the following lines:

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

and replace them with:

#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

#default-lease-time 600;
#max-lease-time 7200;

Then paste this at the end of the file:

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option domain-name-servers 192.168.0.1;
# option domain-name "internal.example.org";
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 600;
max-lease-time 7200;
}

-Set up IP masquerading and forwarding:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo dpkg-reconfigure ipmasq

The default answers should be fine.

-Set up DNS masquerading:

sudo dpkg-reconfigure dnsmasq

-Now start everything up!

sudo ifdown wlan0
sudo ifup wlan0
sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/dhcp3-server restart

Now if everything went well you would be able to see the newly setup netowrk in the list of wireless networks of your other pc and you can connect to it:)

However when running sudo ifdown wlan0 I got the error..

Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Invalid argument.Error for wireless request "Set ESSID" (8B1A) : SET failed on device wlan0 ; Invalid argument.
sudo modprobe ndiswrapper

I think this is because my wireless network card did not have a native Linux driver. I fixed this by running..

sudo modprobe ndiswrapper

Ndiswrapper is a Linux module which allows Ubuntu to use the Windows driver for wireless cards (in most cases).

Everything is working fine now and I'm sharing my broadband internet connection with another laptop via a wireless connection now.

References:




Tuesday, April 13, 2010

How to show/hide desktop icons on ubuntu.

If your desktop ever looks as cluttered as the 'Before' pic below you will definitely find this method useful!

Sometime back I wrote a blog post on how to do the same thing for windows http://hariniachala.blogspot.com/2009/11/hide-messy-looking-desktop-icons-with.html. When looking for a similar method for my ubuntu desktop i came across this..

http://bayu.freelancer.web.id/2009/05/03/showhide-desktop-icon-on-ubuntu/

Follow the instructions in the link and soon your desktop will be magically free of all clutter!

Before



After



If you like my wallpaper you can get it here (http://bit.ly/35rzNB). The word at the bottom means 'Spring'. I've put it in Greek to add a touch of mystery to the wallpaper:)