plugins/perl/scripts/conversation.pl

Mon, 16 Apr 2007 00:43:53 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Mon, 16 Apr 2007 00:43:53 +0000
changeset 13071
b98e72d4089a
parent 12364
42b44fed7423
permissions
-rw-r--r--

Commit a proper copy of this binary file. The old one was corrupted,
probably due to missing SVN attributes.

This was retrieved from the following URL, though we may have it in CVS:
http://dev.openwengo.com/trac/openwengo/trac.cgi/browser/vendors/gaim/trunk/doc/oscar/On_Sending_Files_via_OSCAR.odt?rev=4273

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

mercurial