Fun with GTalk/Pidgin: Changing your status messages programatically

We have always seen people trying to come up with catchy one-liners and cool slogans as their gtalk status messages. On being unable to come up with cool, funky and _original_ status messages to impress friends and colleagues, I decided to put on the programmer’s hat and came up with ways to set these status messages through a simple program. Advantages? Well, enormous. Once you can control the status message string through a program, you can basically rotate it (Rotating status messages do look cool :) ), update it automatically every 1 minute, write a scripts that ‘copies’ your friends status messages periodically :P… Seriously, the opportunities are limitless and only await your imagination! GTalk status messages can be thought on the lines of a Publish-Subscribe Messaging. To understand this, think of a simple newspaper. It publishes some information everyday and its reader in a way subscribe to this information. In the same way your messenger status message is published by youand it is “subscibed” by your friends. This can be thought of as a kind of Multicasting group. So, as part of this blog, I will basically discuss the Google Talk XMPP protocol and will focus on 2 popular IM that use this: GTalk for Windows and Pidgin for Linux (actually pidgin is multi platform)

Configuring Pidgin (in Linux):

For this you will need libpurple-bin to be installed on your system. You can find this in all common linux repositories. For eg. in Ubuntu, this can be done by a simple command:

$ sudo apt-get install libpurple-bin

Once this is done, we need a simple shell script to change our status message. For eg. the script below, makes the current date/time being set up in the status message in case you are “available” in the format :

Wed Jul 2 13:46:53 EDT 2008

and updates it every 30 seconds.

sleep_time=30
while test 1 = 1; do
msg=`date`
if test "`purple-remote getstatus`" = "available"; then
purple-remote "setstatus?status=available&message=${msg}"
oldmsg="$msg"
fi
sleep "${sleep_time}s"
done

This file can be downloaded here.

Let us call it status.sh

Now what remains is just to execute this status.sh with pidgin running and you are done! The status messages will keep on changing every 30 seconds and I guarantee it will be fun :) Please don’t tamper much with the sleep time because while you are chatting, your status message is displayed on your friend’s side whenever it is changed. So you can imagine that it becomes quite irksome for your friend to continuously notice your status message change.

Configuring GTalk (in Windows):

Configrung GTalk messages programatically in Windows is a little tricky (another reason to switch to open source linux:) ) . For this, you need to have a Java Development environment in your system as we need to write XMPP application code using a well known API called Smack API which is in Java.

So, first of all, let us start with installing Java on the system (if you donot already have it) which you can get here. Once this is done, we need to get the Smack API which is an open source, pure Java library for working with XMPP (clients only). The API can be downloaded from http://www.igniterealtime.org/downloads/index.jsp#smack. The source code for this can be obtained from http://www.igniterealtime.org/downloads/source.jsp.Just download the appropriate libraries and put the JAR files in your classpath. If you can’t figure out how it is done, please Google your way around or refer this.

Now, we get down on writing the code!

The java file will look like:

// Import appropriate headers and packages
XMPPConnection connection = new XMPPConnection("gmail.com");
try
{
connection.connect();
connection.login("username", "password");
Presence presence = new Presence(Presence.Type.available);
presence.setStatus("Hello Friends!");
presence.setPriority(24);
presence.setMode(Presence.Mode.available);
connection.sendPacket(presence);
Thread.sleep(30000); // Sleeps for 30 seconds
}
catch (XMPPException e)
{
System.out.println(e.toString());
}

The thing to notice here is that the argument of setStatus is a String. So, to rotate your status message, just use the following function:

    private static String rotate(String input)
{
return input.substring(1) + input.charAt(0);
}

which takes in a simple string as input and rotates it one character at a time:

eg. CORNELL

ORNELLC

RNELLCO etc.

So, get down to it and Enjoy!

Google Health

With Google Health, you can store and manage all your health information in one place. And it's completely free. All you need to get started is a Google user name and password.

So is it safe? Yes! We believe that your health information belongs to you, and you should decide how much you share and whom you share it with. We will never sell your data. We store your information securely and privately. Check out our privacy policy to learn more.

So what are you waiting for???Follow these steps to record your health records.

1. Sign up for Google Health

2.Start tracking a medical history and learn about your conditions

3. Import your medical records.

4. View your medical history

5. Find out how medications might interact

6. Make your health information work for you

7. Search for doctors and hospitals



Welcome 2009



Another New Year is coming tonight.Year 2008 has been my toughest year so far I have seen in my life, with lots of things happened around me and finally its coming to an end this brings some relax to me.Those tough and horrible days can't be forgotten so easily with many of sleepless nights.Even such things happened I was staying with my constant mind and was always thinking and daring to beat those.I think I have got a good resistance power to those sorrows but fear to check out my limit as no body wants it.



With New Year coming on its way I hope My Happy Days will return back which I had lost in 2008.Wish you a Very Birth Day 2009...

Smile

It seems like it’s just been yesterday
When I had met you on the way
We laughed and talked all day
But today we are all miles away

You are all in my memory never to be cast away
For we love each other and can never betray
Believe me my friends today
We are actually just smiles away

A smile that I truly mean and also the smile that make me feel lonely even when I am amongst a crowd.

Just an ordinary day

Today began as just another day and somehow is ending that way. Nothing exciting or interesting, still have my TODO list which never seems to get completed. Just hoping that tomorrow might turn out to be a little more interesting.