|
14192
|
1 $MODULE_NAME = "Conversation Test";
|
|
|
2
|
|
|
3 use Gaim;
|
|
|
4
|
|
|
5 # All the information Gaim gets about our nifty plugin
|
|
|
6 %PLUGIN_INFO = (
|
|
|
7 perl_api_version => 2,
|
|
|
8 name => "Perl: $MODULE_NAME",
|
|
|
9 version => "0.1",
|
|
|
10 summary => "Test plugin for the Perl interpreter.",
|
|
|
11 description => "Implements a set of test proccedures to ensure all " .
|
|
|
12 "functions that work in the C API still work in the " .
|
|
|
13 "Perl plugin interface. As XSUBs are added, this " .
|
|
|
14 "*should* be updated to test the changes. " .
|
|
|
15 "Furthermore, this will function as the tutorial perl " .
|
|
|
16 "plugin.",
|
|
|
17 author => "John H. Kelm <johnhkelm\@gmail.com>",
|
|
|
18 url => "http://sourceforge.net/users/johnhkelm/",
|
|
|
19
|
|
|
20 load => "plugin_load",
|
|
|
21 unload => "plugin_unload"
|
|
|
22 );
|
|
|
23
|
|
|
24
|
|
|
25 # These names must already exist
|
|
|
26 my $GROUP = "UIUC Buddies";
|
|
|
27 my $USERNAME = "johnhkelm2";
|
|
|
28
|
|
|
29 # We will create these on load then destroy them on unload
|
|
|
30 my $TEST_GROUP = "UConn Buddies";
|
|
|
31 my $TEST_NAME = "johnhkelm";
|
|
|
32 my $TEST_ALIAS = "John Kelm";
|
|
|
33 my $PROTOCOL_ID = "prpl-oscar";
|
|
|
34
|
|
|
35
|
|
|
36 sub plugin_init {
|
|
|
37 return %PLUGIN_INFO;
|
|
|
38 }
|
|
|
39
|
|
|
40
|
|
|
41 # This is the sub defined in %PLUGIN_INFO to be called when the plugin is loaded
|
|
|
42 # Note: The plugin has a reference to itself on top of the argument stack.
|
|
|
43 sub plugin_load {
|
|
|
44 my $plugin = shift;
|
|
|
45 print "#" x 80 . "\n\n";
|
|
|
46
|
|
|
47 print "PERL: Finding account.\n";
|
|
|
48 $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID);
|
|
|
49
|
|
|
50 ######### TEST CODE HERE ##########
|
|
|
51 # First we create two new conversations.
|
|
|
52 print "Testing Gaim::Conversation::new()...";
|
|
|
53 $conv1 = Gaim::Conversation->new(1, $account, "Test Conversation 1");
|
|
|
54 if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }
|
|
|
55
|
|
|
56 print "Testing Gaim::Conversation::new()...";
|
|
|
57 $conv2 = Gaim::Conversation->new(1, $account, "Test Conversation 2");
|
|
|
58 if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
|
|
|
59
|
|
|
60 # Second we create a window to display the conversations in.
|
|
|
61 # Note that the package here is Gaim::Conversation::Window
|
|
|
62 print "Testing Gaim::Conversation::Window::new()...\n";
|
|
|
63 $win = Gaim::Conversation::Window::new();
|
|
|
64
|
|
|
65 # The third thing to do is to add the two conversations to the windows.
|
|
|
66 # The subroutine add_conversation() returns the number of conversations
|
|
|
67 # present in the window.
|
|
|
68 print "Testing Gaim::Conversation::Window::add_conversation()...";
|
|
|
69 $conv_count = $conv1->add_conversation();
|
|
|
70 if ($conv_count) {
|
|
|
71 print "ok..." . $conv_count . " conversations...\n";
|
|
|
72 } else {
|
|
|
73 print "fail.\n";
|
|
|
74 }
|
|
|
75
|
|
|
76 print "Testing Gaim::Conversation::Window::add_conversation()...";
|
|
|
77 $conv_count = $win->add_conversation($conv2);
|
|
|
78 if ($conv_count) {
|
|
|
79 print "ok..." . $conv_count . " conversations...\n";
|
|
|
80 } else {
|
|
|
81 print "fail.\n";
|
|
|
82 }
|
|
|
83
|
|
|
84 # Now the window is displayed to the user.
|
|
|
85 print "Testing Gaim::Conversation::Window::show()...\n";
|
|
|
86 $win->show();
|
|
|
87
|
|
|
88 # Use get_im_data() to get a handle for the conversation
|
|
|
89 print "Testing Gaim::Conversation::get_im_data()...\n";
|
|
|
90 $im = $conv1->get_im_data();
|
|
|
91 if ($im) { print "ok.\n"; } else { print "fail.\n"; }
|
|
|
92
|
|
|
93 # Here we send messages to the conversation
|
|
|
94 print "Testing Gaim::Conversation::IM::send()...\n";
|
|
|
95 $im->send("Message Test.");
|
|
|
96
|
|
|
97 print "Testing Gaim::Conversation::IM::write()...\n";
|
|
|
98 $im->write("SENDER", "<b>Message</b> Test.", 0, 0);
|
|
|
99
|
|
|
100 print "#" x 80 . "\n\n";
|
|
|
101 }
|
|
|
102
|
|
|
103 sub plugin_unload {
|
|
|
104 my $plugin = shift;
|
|
|
105
|
|
|
106 print "#" x 80 . "\n\n";
|
|
|
107 ######### TEST CODE HERE ##########
|
|
|
108
|
|
|
109 print "Testing Gaim::Conversation::Window::get_conversation_count()...\n";
|
|
|
110 $conv_count = $win->get_conversation_count();
|
|
|
111 print "...and it returned $conv_count.\n";
|
|
|
112 if ($conv_count > 0) {
|
|
|
113 print "Testing Gaim::Conversation::Window::destroy()...\n";
|
|
|
114 $win->destroy();
|
|
|
115 }
|
|
|
116
|
|
|
117 print "\n\n" . "#" x 80 . "\n\n";
|
|
|
118 }
|
|
|
119
|