5

I have an old machine in my house and one of the things this machine does is detect whether a particular door in the house has just opened or closed.

Right now, I have that machine post a tweet on a private Twitter account.

I would now like to give this machine its own AIM account and have it send me a message on AIM. The only messages that will be sent are literally "front door open" and "front door closed."

It appears that libpurple is a commonly used library for dealing with various instant messaging protocols and is even used in Adium, but it is terribly complicated and I can't figure out how to use it.

Does anybody have or know of a simple code sample that uses libpurple?

Frank Puccino
  • 51
  • 1
  • 2

4 Answers4

3

I personally found the source code of Pidgin to be straightforward to read. There are many more IM clients that use libpurple, though, you can check Wikipedia for more details.

smf68
  • 988
  • 1
  • 9
  • 16
1

I've done this sort of thing in a bash script before. Unfortunately the code is lost, but you may want to look at dbus as a piece of the solution. The code was relatively straightforward.

This page on updating pidgin status might be a good starting point.

For your application, it might be as easy as:

purple-remote uri 'aim:goim?screenname=yourimhandle&message="front door open"'

(Watch the quoting!)

See purple-remote(1).

bstpierre
  • 30,042
  • 15
  • 70
  • 103
1

I fought through dragons^Wnonexistent documentations and it seems to be plausible:-) Having some time to hack some stuff together, I think it may worth a quick check.

Important and good to know, that to use the internal DBus services,

  1. run this in e.g. screen for a long time :),
  2. the purple-remote should be run in the same dbus session. I made a script that starts a session at boot and exports DBUS_SESSION_BUS_ADDRESS in all user's bashrc. Feels hacky?:)

Anyone with better skills with libpurple, please halp us out! :-)

Koshinae
  • 2,240
  • 2
  • 30
  • 40
0

You should definitely take a look into the nullclient.c provided in the libpurple sources (libpurple/example/nullclient.c). It performs logging into server and adds some useful callbacks. To send a message, add this to (for example) the function signed_on:

PurpleConvIm im;
im.conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, "other@example.com");
purple_conv_im_send(&im, "open door");
Fabian Pedregosa
  • 6,329
  • 1
  • 22
  • 20