Cannot use chat-cb, pass enum in plugin

Adam Tistler atistler at
Tue Mar 17 00:32:13 EDT 2009

Hi all,

I am attempting to use the received-chat-msg callback in my plugin
however it does not seem to be called.  Received-im-msg does get  
called however.

According to the xml, this is a chat conversation:
<message to="xxxxxx at" type="chat"

I think that I am confused as to the difference between what finch
thinks is a "chat" and "im".  Can someone elaborate.  Also, is there
an easy way to refer to C enums with the perl plugin,
Purple::Conversation::Type::CHAT is defined and set to 1, however I  
keep on

g_log: purple_conversation_new: assertion `type !=  

void purple_conv_chat_add_user(PurpleConvChat *chat, const char *user,
                                const char *extra_msg,
PurpleConvChatBuddyFlags flags,
                                gboolean new_arrival);

sub recieved_im_msg_cb {
    my ($account, $sender, $message, $conv, $flags) = @_;
    &log(sprintf("Got message: %s from %s on account %s\n", $message,  
$sender, $account->get_username()));
    my $type = Purple::Conversation::get_type($conv);
    my $im = Purple::Conversation::get_im_data($conv);
    my $aim_acct = Purple::Accounts::find("adam5882", "prpl-oscar");
    my $new_conv =  
Purple::Conversation::new(Purple::Conversation::Type::CHAT, $aim_acct,  
"test", 0);
    $new_conv->write($message, "chatproxyaim01");

sub recieved_chat_msg_cb {
    my ($account, $sender, $message, $conv, $flags) = @_;
    &log(sprintf("Got message: %s from %s on account %s\n", $message,  
$sender, $account->get_username()));
    my $chat = Purple::Conversation::get_chat_data($conv);
    $chat->add_user("chatproxyaim01", "resend: $message", 0, 0);

sub plugin_init {
     return %PLUGIN_INFO;
sub plugin_load {
     my $plugin = shift;
     &log("Plugin loaded");
     my $protocol = "prpl-xmpp";
     my $account_name = "atistler at";
     my @accounts = Purple::Accounts::get_all();
     foreach my $account (@accounts) {
     my $conversation_handle = Purple::Conversations::get_handle();
     my $data = "hello";
     Purple::Signal::connect($conversation_handle, "received-im-msg",  
$plugin, \&recieved_im_msg_cb, $data);
#    Purple::Signal::connect($conversation_handle, "received-chat- 
msg", $plugin, \&recieved_chat_msg_cb, $data);
sub plugin_unload {
     my $plugin = shift;
     Purple::Debug::info("testplugin", "plugin_unload() - Test Plugin  

Adam Tistler
atistler at

More information about the Devel mailing list