Thursday, February 25, 2010

Pidgin, Google Talk, and XMPP

The Pidgin IM client supports just about every instant messaging protocol ever conceived, including many poorly-designed and undocumented proprietary protocols, such as those used by AOL, Yahoo!, and MSN.  It also supports  XMPP (aka Jabber), the open-standard protocol on which Google Talk is based.

There are some interesting technical and political issues surrounding the implementation of Google Talk's XMPP extensions...

XMPP presence and the Shared Status extension

The XMPP protocol core supports users' signing in from multiple locations simultaneously: each client normally picks a different resource name, which is appended to the user's Jabber ID to distinguish them.  For example, I might be logged in as dlenski@gmail.com/Gmail via the GMail chat interface, and as dlenski@gmail.com/Pidgin via Pidgin.  Each of these resources can maintain independent presence, which encompasses status (e.g. Available/Away) and message ("Dude check out my latest YouTube video").

Google Talk/Gmail Chat (is there an official name encompassing both of these?) offers a few non-standard client- and server-side extensions to XMPP.  The most notable of these is the Shared Status extension (for which Google provides some very helpful documentation).  With the extension, clients automatically synchronize their presence with each other.  Try it out: open GMail in two separate windows, and adjust your chat status in one window... it will be immediately reflected in the other.

Invisible Mode

In addition to presence sharing, Google Talk also offers users "Invisible Mode."  When this mode is enabled by the client, the Google Talk servers don't report presence information to the user's contacts.  So the user can send and receive messages, and see their own contact list, but they will not show up in anyone else's list of online contacts (often called a roster for XMPP).

Invisible Mode, though a seemingly separate feature, is inextricably linked to Shared Status: a Google Talk client can't go Invisible except via the mechanism of Shared Status.

Why did Google make this design choice?  It's not very clear to me... the XMPP standards body has drafted a proposed mechanism for invisibility (XEP-0186), but it's quite complex in the demands that makes of compliant servers, which must carefully manage presence information in order to maintain the illusion of invisibility for specific resources, while still allowing invisible clients to communicate.  My guess is that Google's engineers decided this was just too complicated, and tacked on a simple shared-invisibility mechanism as a quick hack.

Enter Pidgin...

As mentioned above, Pidgin supports XMPP, so users can connect to Google Talk's servers and chat with their friends seemlessly.

Officially, however, Pidgin does not support Google's Shared Status and Invisibility extension.  A lot of reasons have been given for this:
  • It's not part of the standard XMPP protocol.
  • Some users find it annoying... if you change your presence in one location (e.g. home computer), you might not want it changed in another location (e.g. work computer).
  • There's already a proposed standard invisibility mechanism for XMPP (the aforementioned XEP-0186).
This causes a lot of confusion, however.  New Pidgin users sign on to their Google Talk accounts and find that Invisibility doesn't work and their status messages aren't propagated when logged in from multiple locations.  There have been lots and lots of bug reports about this problem, and someone always asks, "Why not support it?" and inevitably some of the above reasons are mentioned.

A large number of badly-conceived hacks and correct but laborious workarounds and partially functional Pidgin plugins have been devised to enable Invisible mode for Google Talk accounts in Pidgin.

Put it all together

A few months ago, Ayan Chakrabarti wrote a patch for Purple (the library on which Pidgin is based) that actually provides a complete implementation of Google's Shared Status and Invisibility extension.
With this patch, Pidgin works very much like GMail chat!  You update your status in one place, and it's reflected on other computers where you're logged in.  You can go Invisible, and come back.  Awesome!

I updated AyanC's patch to work with the latest version of Pidgin, 2.6.6.  I also built packages of this patched version for Ubuntu, found here, so Ubuntu users can easily upgrade to this version.

There's still some ongoing debate about whether Pidgin should officially support Google Shared status, but it appears that momentum is now moving in that direction.  A few of the good arguments for inclusion (not originally mine):
  • The developers may not like Google's non-standard Invisibility mechanism, but Pidgin supports a lot of worse-designed and worse-documented protocols.
  • Google Talk's implementation may be non-standard, but Google Talk is by far the most widely-adopted implementation of Jabber, so it deserves some consideration.
  • Some users don't want Shared Status, but it can be a configurable option.
  • Pidgin confuses new users by not supporting the same status semantics as Google Talk's official clients.

3 comments:

  1. dan,
    this blog post is the bset post i've found regarding the annoying inability to set invisible in pidgin. sadly this post has not so good SEO and doesnt show up in the first page or so of google (and i tried a bunch!). well, i'm really happy about it, but i'm wondering if you could give me a brief instruction on which patch to implement for pidgin 2.7.1 and HOW to do it (on windows 7). it would be muh appreciated!

    ReplyDelete
  2. Social, you can try porting the patch I wrote (http://developer.pidgin.im/attachment/ticket/4509/gtalk-sharedstatus-2.6.6.patch) to the Pidgin 2.7.1 code.

    I have no time to do this now, but may get around to it eventually. I don't use Windows, and don't know much about building Pidgin on it.

    ReplyDelete
  3. Hi on this page ( http://fahhem.com/blog/2009/02/google-talk-invisible/ ) you sent a modified version of gtalkinvisible pidgin plugin, but the URL that you provide ( http://tonquil.homeip.net/~dlenski/gtalkinvisible.c ) is not available anymore. Did you have this file? If yes can you send me please (tiago156@gmail.com)?

    Thank you in advice.

    ReplyDelete