Question about serv_got_im() and signal order

Toby Schaffer jts at
Thu Jul 17 01:04:33 EDT 2008

While working on My Very First Plugin which connects to received-im-msg, 
I saw that for the first message in a conversation the 
PurpleConversation * argument was null. This appears to be a result of 
the following in serv_got_im() (lines 693-706 of 2.4.3's 
libpurple/server.c), which emits received-im-msg before creating the 

"received-im-msg", gc->account,
                     name, message, conv, flags);

    /* search for conversation again in case it was created by 
received-im-msg handler */
    if (conv == NULL)
        conv = 
purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, 

     * XXX: Should we be setting this here, or relying on prpls to set it?

    if (conv == NULL)
        conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);

This was causing problems since the callback wanted to reply with 
purple_conv_im_send(), which requires a PurpleConversation.

Is there any reason not to create the conversation first? I reordered 
the code to try this, and in my extensive testing :) it didn't appear to 
break anything...


More information about the Devel mailing list