It’s been a too-busy-to-write week, but I found some time the last few evenings to brush up my C coding (only hacking at this point, really) to make Asterisk 1.8 do something I’ve wanted from the beginning: Google Talk’s invisible mode for the Google Voice integration.
Quick background: Google wrote a variety of XMPP extensions to make Google Talk do voice and a bunch of other non-standard XMPP things. One of those things is what Google calls “shared statuses,” which also includes invisible mode–the ability to be online but set your client as invisible so that others can’t see you, but could chat with you.
You might want to use this feature if, like me, your Google Voice number is attached to your main GMail account. I don’t use the chat features but I appear online to anyone who has me in their contact list, as long as Asterisk is logged in, and that has the potential to draw unwanted instant messages (that will never get answered).
Note: I want to reinforce that this is a hack. The code is clean enough, but this is only useful for Google Talk and is only implemented as a set of Asterisk CLI commands. Furthermore, this functionality would probably never be implemented in Asterisk’s res_jabber because it’s Google-proprietary. On the other hand, if any Asterisk developers want to run with this, go for it! I don’t guarantee that this code will work for you and if your Asterisk process segfaults, stop using it.
Apply this patch against Asterisk 18.104.22.168’s (or trunk, currently) res/res_jabber.c by downloading the patch to your Asterisk source directory and running
patch < res_jabber.patch . You may have to tell it to apply the patch to
Rebuild (or build) Asterisk. If you are rebuilding, just run
make after applying the patch. You should see make build the res_jabber module. Then
make install and restart Asterisk.
At the CLI, you can issue
jabber set invisible on asterisk to turn on invisibility for the Jabber connection named “asterisk.” If you don’t know what your Google Talk XMPP connection is called, just issue
jabber show connections and find out. You can set your connection visible again with
jabber set invisible off asterisk.
Now, here’s another thing that is really hacky: Google Talk only seems to apply the visibility/invisibility change if you are toggling. Here’s what I mean: if you were invisible, and logged out, then logged back in, Google still thinks you are invisible–but you’re not! So in that case, if you
jabber set invisible on ..., it doesn’t do anything, until you first set it off and then back on again. I think I know why this is happening and it has to do with res_jabber sending standard <presence> information at login rather than Google’s special shared-status presence scheme. If you want to be sure you are invisible, just start off by setting invisible off and then set it on. For me, that works every time. (I’d be grateful for someone who really knows all about this to fix it up and make it work right, the first time.)
I got the idea from this year-old blog posting about enabling Google Talk invisibility in Pidgin, which refers to the official documents published by Google on how it works.