plugins/perl/scripts/conversation.pl

changeset 12340
04baa672c79e
parent 11457
e787f1445e64
child 12364
42b44fed7423
equal deleted inserted replaced
12339:9333237efc4f 12340:04baa672c79e
3 use Gaim; 3 use Gaim;
4 4
5 # All the information Gaim gets about our nifty plugin 5 # All the information Gaim gets about our nifty plugin
6 %PLUGIN_INFO = ( 6 %PLUGIN_INFO = (
7 perl_api_version => 2, 7 perl_api_version => 2,
8 name => " Perl: $MODULE_NAME", 8 name => "Perl: $MODULE_NAME",
9 version => "0.1", 9 version => "0.1",
10 summary => "Test plugin for the Perl interpreter.", 10 summary => "Test plugin for the Perl interpreter.",
11 description => "Implements a set of test proccedures to ensure all functions that work in the C API still work in the Perl plugin interface. As XSUBs are added, this *should* be updated to test the changes. Furthermore, this will function as the tutorial perl plugin.", 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.",
12 author => "John H. Kelm <johnhkelm\@gmail.com>", 17 author => "John H. Kelm <johnhkelm\@gmail.com>",
13 url => "http://sourceforge.net/users/johnhkelm/", 18 url => "http://sourceforge.net/users/johnhkelm/",
14 19
15 load => "plugin_load", 20 load => "plugin_load",
16 unload => "plugin_unload" 21 unload => "plugin_unload"
41 46
42 print "PERL: Finding account.\n"; 47 print "PERL: Finding account.\n";
43 $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID); 48 $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID);
44 49
45 ######### TEST CODE HERE ########## 50 ######### TEST CODE HERE ##########
46 print "Testing Gaim::Conv::new()..."; 51 # First we create two new conversations.
47 $conv1 = Gaim::Conv::new(1, $account, "Test Conv. 1"); 52 print "Testing Gaim::Conversation::new()...";
48 if ($conv) { print "ok.\n"; } else { print "fail.\n"; } 53 $conv1 = Gaim::Conversation::new(1, $account, "Test Conversation 1");
54 if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }
49 55
50 print "Testing Gaim::Conv::new()..."; 56 print "Testing Gaim::Conversation::new()...";
51 $conv2 = Gaim::Conv::new(1, $account, "Test Conv. 2"); 57 $conv2 = Gaim::Conversation::new(1, $account, "Test Conversation 2");
52 if ($conv) { print "ok.\n"; } else { print "fail.\n"; } 58 if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
53 59
54 print "Testing Gaim::Conv::Window::new()...\n"; 60 # Second we create a window to display the conversations in.
55 $win = Gaim::Conv::Window::new(); 61 # Note that the package here is Gaim::Conversation::Window
56 62 print "Testing Gaim::Conversation::Window::new()...\n";
57 print "Testing Gaim::Conv::Window::add_conversation()..."; 63 $win = Gaim::Conversation::Window::new();
58 $conv_count = Gaim::Conv::Window::add_conversation($win, $conv1);
59 if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; }
60 64
61 print "Testing Gaim::Conv::Window::add_conversation()..."; 65 # The third thing to do is to add the two conversations to the windows.
62 $conv_count = Gaim::Conv::Window::add_conversation($win, $conv2); 66 # The subroutine add_conversation() returns the number of conversations
63 if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; } 67 # present in the window.
64 68 print "Testing Gaim::Conversation::Window::add_conversation()...";
65 print "Testing Gaim::Conv::Window::show()...\n"; 69 $conv_count = $conv1->add_conversation();
66 Gaim::Conv::Window::show($win); 70 if ($conv_count) {
67 71 print "ok..." . $conv_count . " conversations...\n";
68 print "Testing Gaim::Conv::get_im_data()...\n"; 72 } else {
69 $im = Gaim::Conv::get_im_data($conv1); 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();
70 if ($im) { print "ok.\n"; } else { print "fail.\n"; } 91 if ($im) { print "ok.\n"; } else { print "fail.\n"; }
71 92
72 print "Testing Gaim::Conv::IM::send()...\n"; 93 # Here we send messages to the conversation
73 Gaim::Conv::IM::send($im, "Message Test."); 94 print "Testing Gaim::Conversation::IM::send()...\n";
74 95 $im->send("Message Test.");
75 print "Testing Gaim::Conv::IM::write()...\n"; 96
76 Gaim::Conv::IM::write($im, "sendingUser", "<b>Message</b> Test.", 0, 0); 97 print "Testing Gaim::Conversation::IM::write()...\n";
98 $im->write("SENDER", "<b>Message</b> Test.", 0, 0);
77 99
78 print "#" x 80 . "\n\n"; 100 print "#" x 80 . "\n\n";
79 } 101 }
80 102
81 sub plugin_unload { 103 sub plugin_unload {
82 my $plugin = shift; 104 my $plugin = shift;
83 105
84 print "#" x 80 . "\n\n"; 106 print "#" x 80 . "\n\n";
85 ######### TEST CODE HERE ########## 107 ######### TEST CODE HERE ##########
86 108
87 109 print "Testing Gaim::Conversation::Window::get_conversation_count()...\n";
88 110 $conv_count = $win->get_conversation_count();
89 print "Testing Gaim::Conv::Window::get_conversation_count()...\n"; 111 print "...and it returned $conv_count.\n";
90 $conv_count = Gaim::Conv::Window::get_conversation_count($win);
91 print $conv_count;
92 if ($conv_count > 0) { 112 if ($conv_count > 0) {
93 print "Testing Gaim::Conv::Window::destroy()...\n"; 113 print "Testing Gaim::Conversation::Window::destroy()...\n";
94 Gaim::Conv::Window::destroy($win); 114 $win->destroy();
95 } 115 }
96 116
97 print "\n\n" . "#" x 80 . "\n\n"; 117 print "\n\n" . "#" x 80 . "\n\n";
98 } 118 }
99 119

mercurial