received-im-msg signal - no conversation

View: New views
2 Messages — Rating Filter:   Alert me  

received-im-msg signal - no conversation

by mowsen@googlemail.com :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

hey there.

i'm want to extract the received text of an im message and then close
the conversation. the code is very simple and looks like this:

sub received_im_msg_cb {
    my ($account, $sender, $msg, $conv, $flags) = @_;
    Purple::Debug::info("testplugin", "Account \"" .
$account->get_username() . "\" has a new message from ".$sender.":
".$msg." Conversation: ".$conv."\n");
  Purple::Conversation::destroy($conv);
}

sub plugin_load {
    my $plugin = shift;
    $data = "";
    my $accounts_handle = Purple::Conversations::get_handle();
    Purple::Signal::connect($accounts_handle, "received-im-msg",
$plugin, \&received_im_msg_cb, $data);
}

the problem now is, that $conv is empty. after sending a second
message from the same sender $conv exists. how can i close the
conversation right after the first received message?

thanks alot,
mowsen

_______________________________________________
Devel mailing list
Devel@...
http://pidgin.im/cgi-bin/mailman/listinfo/devel

Re: received-im-msg signal - no conversation

by Etan Reisner-2 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 25, 2009 at 10:48:45AM +0200, mowsen wrote:
<snip>
> the problem now is, that $conv is empty. after sending a second
> message from the same sender $conv exists. how can i close the
> conversation right after the first received message?

received-im-msg fires before the conversation window is created on the
first message in a new conversation, you can use the gtkconv
displayed-im-msg signal to catch it later (though that will catch both
incoming and outgoing messages so you'll need to watch for that) or set up
a short timer to destroy the conversation after the signal has finished
being processed and libpurple has created the conversation.

> thanks alot,
> mowsen

    -Etan

_______________________________________________
Devel mailing list
Devel@...
http://pidgin.im/cgi-bin/mailman/listinfo/devel