comparison libpurple/plugins/perl/scripts/signals-test.pl @ 17101:dae18f23a09d

A signals-test plugin for perl. This should help plugin developers get an idea of how signals work in purple.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 16 May 2007 02:34:56 +0000
parents
children 0fb8f1b1f0e9
comparison
equal deleted inserted replaced
17099:bee4ea11e299 17101:dae18f23a09d
1 $MODULE_NAME = "Signals Test Script in Perl";
2
3 use Purple;
4
5 %PLUGIN_INFO = (
6 perl_api_version => 2,
7 name => "Perl: $MODULE_NAME",
8 version => "0.1",
9 summary => "Signals Test plugin for the Perl interpreter.",
10 description => "Demonstrate the user of purple signals from " .
11 "a perl plugin.",
12 author => "Sadrul Habib Chowdhury <sadrul\@pidgin.im>",
13 url => "http://developer.pidgin.im/wiki/sadrul/",
14
15 load => "plugin_load",
16 unload => "plugin_unload"
17 );
18
19 # Accounts
20 sub account_connecting_cb
21 {
22 my $account = shift;
23 Purple::Debug::misc("signals test in perl", "account-connecting (" . $account->get_username() . ")\n");
24 }
25
26 # Buddylist
27 sub buddy_signed_on
28 {
29 my $buddy = shift;
30 Purple::Debug::misc("signals test in perl", "buddy-signed-on (" . $buddy->get_name() . ")\n");
31 }
32
33 # Connections
34 sub signed_on
35 {
36 my $conn = shift;
37 Purple::Debug::misc("signals test in perl", "signed-on (" . $conn->get_account()->get_username() . ")\n");
38 }
39
40 # Conversations
41 sub conv_received_msg
42 {
43 my ($account, $sender, $message, $conv, $flags, $data) = @_;
44 Purple::Debug::misc("signals test in perl", "$data (" . $account->get_username() . ", $sender, $message, $flags)\n");
45 }
46
47 sub plugin_load
48 {
49 my $plugin = shift;
50
51 # Hook to the signals
52
53 # Accounts
54 $act_handle = Purple::Accounts::get_handle();
55 Purple::Signal::connect($act_handle, "account-connecting", $plugin,
56 \&account_connecting_cb, 0);
57
58 # Buddy List
59 $blist = Purple::BuddyList::get_handle();
60 Purple::Signal::connect($blist, "buddy-signed-on", $plugin,
61 \&buddy_signed_on, 0);
62
63 # Connections
64 $conn = Purple::Connections::get_handle();
65 Purple::Signal::connect($conn, "signed-on", $plugin,
66 \&signed_on, 0);
67
68 # Conversations
69 $conv = Purple::Conversations::get_handle();
70 Purple::Signal::connect($conv, "received-im-msg", $plugin,
71 \&conv_received_msg, "received im message");
72 Purple::Signal::connect($conv, "received-chat-msg", $plugin,
73 \&conv_received_msg, "received chat message");
74 }
75
76 sub plugin_unload
77 {
78 # Nothing to do here for this plugin.
79 }
80