Using WhatsApp with Pidgin

I only recently got intrigued by the idea of using WhatsApp on my laptop mainly because of some proxy issues in my college, WhatsApp doesn’t really work on my android phone because of limited network configuration options. I could use bluestacks or just install WhatsApp in my android emulator on my laptop. While those are 2 existing workarounds, I wanted to integrate WhatsApp into some existing chat client so that I get a consistent experience across all my social networks.

I am big fan of opensource technologies and I use pidgin as my primary chat client. The sheer contribution by the community in the development of this universal chat client is just enormous. I stumbled upon whatsapp-purple which is a pidgin plugin providing full functionality for WhatsApp. Now I am not going to go through the details of setting up Pidgin and installing third party plugins specifically whatsapp-purple because all this is heavily documented and fairly easy to get started with. So when you install the plugin in pidgin, you will have to create a new account. You should be presented with a window like this:

Create Whatsapp account in Pidgin

Now it requires two fields: Your username is just your phone number prefixed with your country code. In the github readme , you can find some relevant links to projects which can help you ‘sniff’ out your passwords or register new ones. There can be two possibilities:

1.  You are creating a new WhatsApp account and registering a new number (like I did). For that, I used yowsup which according to the developer is

The open source cross platform Whatsapp library powering Wazapp

I chose this project because it is very well maintained and documented. It requires python to run so it should be fairly simple to get started with it. The best part about this project according to me was the command line interface provided by it where you can actually chat with your WhatsApp contacts right from the terminal! (Definitely try and explore this library, it is really versatile). Ok, so registering a new number is fairly simple (documentation):

2. You already are using whatsapp on a device and you want to use the same number on your laptop too in which case you don’t want to register the number again as then you wouldn’t be able to use it on your device. So for this particular case you will have to ‘sniff’ out the password of your whatsapp account. I will list a method that worked for me and is pretty reliable and again well maintained by the XDA Community. It’s called the Xposed Framework and quite simply it allows you to modify any apk without having to decompile it and reflash it into your device. It’s highly customizable and there are user defined code snippets called ‘Modules’ which you can integrate within your Xposed Framework to get the most of your ROM. It obviosuly requires ROOT access because the /system/bin/app_process executable is extended  to load a JAR file on startup.

For those on an Xperia, you can download the Xposed Framework from this XDA Thread

Ok, so after you have installed the Xposed Framework successfully on your Android device, the module you want to install is WhatsPwd and then you will have to reboot your device for it to take affect. If all goes well, on restart you should see a screen popup with your username and password which you can straightaway punch in while adding a new account in Pidgin.

So the hard part is over, if you have gotten till here following all the steps, you should have successfully configured pidgin to use Whatsapp. If you have you will immediately notice a shortcoming! No Contacts! That’s right. WhatsApp doesn’t store your contacts aka your aliases for the phone numbers with which you have had conversations and therefore it is not very easy to use then because obviously you will have to manually add contacts with alias names. yada yada.. Lots of work- boring! Let’s automate this!

Getting WhatsApp Contacts from your Android Device

This should have been another post but it is really relevant here and very straight forward so I am going to fit it in here. So, atleast on my Xperia device I don’t see an option of exporting filtered contacts directly from the Contacts app. On doing a quick search on google play you get WhatsApp Contacts Export and it does exactly what the name suggests. The only catch is you can only export around 100 contacts for free and will have to pay for more which I personally think is preposterous. It is possible to circumvent this limit with the use of the apktool and any IDE for that matter and this simple Zip Signer Utility if need be (You see where I’m headed :P, try it out yourself- it should be enlightening).

In any case, assuming you have installed the app and run it, you should see a export.csv file generated on your device. Now we have to import that list of contacts into pidgin. You can’t however do it as is, going through the wiki, all you require is the Purple Plugin Pack for your particular Operating System which has a host of plugins. The one that we would want is the “List Handler” Plugin. Ok, so create a group if you want your WhatsApp contacts to be organised in a separate group and then try to export your contacts using the listhandler plugin like so

Goto Tools->List Handler->Export Generic Buddy list file and select the appropriate account and click export:

export contacts from Pidgin

You should see an xml file generated that looks like:

Here the 3 groups we see are Facebook Friends, Buddies and Chats. Let’s get back to the export.csv file that we had obtained in our android devices from WhatsApp export. I wrote a simple java program that just reads the file line by line and generates a buddy list that we can simply plug into the contacts.xml template.

Please replace the paths of output.txt and export.csv files with your own (this would obviously require you to copy the export.csv file from your android device your PC)

Once you get the alias – phone number pairs in the output.txt file, just plug it into the contacts.xml file like so:

Here for instance I added the 2 buddies into the group Buddies. So the program would generate output like:

Once you have the final import.xml file ready with you, just go to Tools->List Handler->Import Generic Buddy list file (.xml) and choose the relevant xml file that you generated out of the template.

You should see your contacts with the aliases in your buddy list and now you have a fully functioning WhatsApp account (or may be more than 1 accounts) with all the contacts configured properly in Pidgin.