Pidgin IM patch for IRC 352 (who) parsing

Pidgin is a multi-protocol IM client (formerly known as “Gaim”) that is available on various platforms (Linux, Win32).

Recently, someone asked in #pidgin about a feature request to make libpurple parse the IRC 352 messages, which are returned in response to a WHO command. I said I could throw together a quick patch to make this happen and I’ve got something working now.

Currently, this is what a IRC chat in Pidgin might look like:

Pidgin IRC chat, before patch

After the patch, you can issue a “/quote who #channel” which will send the literal command “who #channel” to the IRC server, to which it will send the 352 response messages. My patch makes libpurple parse these messages and set the PURPLE_CBFLAGS_AWAY flag on the appropriate user’s PuprleConvChatBuddyFlags record. The result looks like this:

Pidgin IRC chat, after patch

You can now see user “Dossy_” is set away by the status icon (the clock, cirlcled in green in the screenshot).

Of course, there’s a few big caveats with this patch:

  • Only users set “away” who have no other meaningful PurpleConvChatBuddyFlags (i.e., chan op, voiced) will display the away status icon, as it has lowest precedence, since only one buddy status icon is displayed at a time. (See pidgin/gtkconv.c:get_chat_buddy_status_icon() to see what I mean.)
  • The server does not send regular status update notifications with 352 messages. It only sends them in response to a “who” command. Therefore, if you want the status data to be updated, you’ll need to periodically poll the server by issuing a “who” command. This is inefficient and for large IRC channels it can be quite resource intensive. If you want periodic updates, you’ll need to issue the “who” command manually, or write a Pidgin plugin that periodically polls by issuing the command for you.

Here’s the patch against the Pidgin 2.1.1 source tarball:

If you have any questions about or issues with the patch, leave them in the comments below.

Tags: , ,

Speak Your Mind