Cannot use chat-cb, pass enum in plugin

Adam Tistler atistler at gmail.com
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 gmail.com/home4CDD9991" type="chat"
id="D5E2C4CE8EA07AB7_14"

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
seeing:

g_log: purple_conversation_new: assertion `type !=  
PURPLE_CONV_TYPE_UNKNOWN' failed




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()));
    &log(Dumper($conv));
    my $type = Purple::Conversation::get_type($conv);
    my $im = Purple::Conversation::get_im_data($conv);
    &log(Dumper($im));
    my $aim_acct = Purple::Accounts::find("adam5882", "prpl-oscar");
    &log(Dumper(Purple::Conversation::Type::CHAT));
    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()));
    &log(Dumper($conv));
    my $chat = Purple::Conversation::get_chat_data($conv);
    &log(Dumper($chat));
    $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 gmail.com/home";
     my @accounts = Purple::Accounts::get_all();
     foreach my $account (@accounts) {
         &log(Dumper($account->get_username()));
     }
     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  
Unloaded.\n");
}




Adam Tistler
1(732)718-2631
atistler at gmail.com






More information about the Devel mailing list