~couchNerd ~serialOutrager ~puts2In42 ~makesPigsFly

TIP: A Post For Pidgin Plugin Developers

Recently I wrote a small autoreply-answering-machine app for pidgin with a simple premise. Send custom automatic replies to different people when they message you and came across a strange bug. It never sent the reply when you received the first message from someone. I was using the “ReceivedImMessage” signal over d-bus (or “received-im-message” for the plugin writers). What I found initially looked to be a gross and basic error by pidgin developers, but later found that it is indeed a good design and thought that I’ll make a post about it for the benefit of fellow pidgin plugin/app developers.

After a bit of debugging I saw that when I received the ReceivedImMessage signal for the first message, the “Conversation ID” field is not a valid value but 0. Thereafter, I got the correct value every time. Searching on the google didn’t reveal much except a few other people complaining about the same and someone saying that this is a bug because pidgin first sends the signal and then creates the conversation while it should be the other way round.  Fair enough. But then…

Then I came across a short explanation by a pidgin developer, seanegen, (sorry lost the link somewhere). Basically, the reason behind this is that all the checks (e.g. Blacklists etc) are performed after one gets this signal, and hence they dont create the window otherwise it might be created even if you have blocked the person who is sending you the message. Perfect explanation.

But, what’s the solution. Simple..Use the “DisplayedImMessage” (or “displayed-im-message” signal) which is sent, once the conversation has been created. That’s it. Hope that this post benefit you.

Comments