annotate plugins/perl/scripts/account.pl @ 13253:87a7c3077c19

[gaim-migrate @ 15619] More cleaning up of oscar. Renamed some functions to be more clear. Got rid of some stuff that wasn't used. Inlined some small things in conn.c that were only used once. The goals of all this are 1. Non-blocking I/O for all connections 2. p2p stuff won't use the same struct as oscar connections, because that's stupid 3. The oscar PRPL should be less scary committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Feb 2006 21:27:04 +0000
parents 6fd82071a7b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
1 $MODULE_NAME = "Account Functions Test";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
2
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
3 use Gaim;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
4
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
5 # All the information Gaim gets about our nifty plugin
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
6 %PLUGIN_INFO = (
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
7 perl_api_version => 2,
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
8 name => " Perl: $MODULE_NAME",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
9 version => "0.1",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
10 summary => "Test plugin for the Perl interpreter.",
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
11 description => "Implements a set of test proccedures to ensure all " .
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
12 "functions that work in the C API still work in the " .
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
13 "Perl plugin interface. As XSUBs are added, this " .
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
14 "*should* be updated to test the changes. " .
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
15 "Furthermore, this will function as the tutorial perl " .
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
16 "plugin.",
11457
4d9686e7c234 [gaim-migrate @ 13696]
Richard Laager <rlaager@wiktel.com>
parents: 11170
diff changeset
17 author => "John H. Kelm <johnhkelm\@gmail.com>",
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
18 url => "http://sourceforge.net/users/johnhkelm/",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
19
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
20 load => "plugin_load",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
21 unload => "plugin_unload"
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
22 );
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
23
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
24
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
25 # These names must already exist
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
26 my $GROUP = "UIUC Buddies";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
27 my $USERNAME = "johnhkelm2";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
28
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
29 # We will create these on load then destroy them on unload
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
30 my $TEST_GROUP = "perlTestGroup";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
31 my $TEST_NAME = "perlTestName";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
32 my $TEST_ALIAS = "perlTestAlias";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
33 my $PROTOCOL_ID = "prpl-oscar";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
34
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
35
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
36 sub plugin_init {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
37 return %PLUGIN_INFO;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
38 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
39
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
40
0e9e2b923d09 [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
0e9e2b923d09 [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.
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
43 sub plugin_load {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
44 my $plugin = shift;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
45 print "#" x 80 . "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
46 Gaim::debug_info("plugin_load()", "Testing $MODULE_NAME Started.");
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
47 print "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
48
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
49
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
50 #################################
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
51 # #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
52 # Gaim::Account::Option #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
53 # #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
54 #################################
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
55
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
56 print "Testing: Gaim::Account::Option::new()...\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
57 $acc_opt = Gaim::Account::Option->new(1, "TEXT", "pref_name");
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
58 $acc_opt2 = Gaim::Account::Option->bool_new("TeXt", "MYprefName", 1);
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
59
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
60 #################################
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
61 # #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
62 # Gaim::Account #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
63 # #
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
64 #################################
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
65
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
66
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
67 print "Testing: Gaim::Account::new()... ";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
68 $account = Gaim::Account->new($TEST_NAME, $PROTOCOL_ID);
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
69 if ($account) { print "ok.\n"; } else { print "fail.\n"; }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
70
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
71 print "Testing: Gaim::Accounts::add()...";
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
72 Gaim::Accounts::add($account);
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
73 print "pending find...\n";
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
74
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
75 print "Testing: Gaim::Accounts::find()...";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
76 $account = Gaim::Accounts::find($TEST_NAME, $PROTOCOL_ID);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
77 if ($account) { print "ok.\n"; } else { print "fail.\n"; }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
78
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
79 print "Testing: Gaim::Account::get_username()... ";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
80 $user_name = $account->get_username();
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
81 if ($user_name) {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
82 print "Success: $user_name.\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
83 } else {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
84 print "Failed!\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
85 }
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
86
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
87 print "Testing: Gaim::Account::is_connected()... ";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
88 if ($account->is_connected()) {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
89 print " Connected.\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
90 } else {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
91 print " Disconnected.\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
92 }
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
93
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
94 print "Testing: Gaim::Accounts::get_active_status()... ";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
95 if ($account->get_active_status()) {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
96 print "Okay.\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
97 } else {
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
98 print "Failed!\n";
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
99 }
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
100
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
101 $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
102 print "Testing: Gaim::Accounts::connect()...pending...\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
103
12364
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
104 $account->set_status("available", TRUE);
6fd82071a7b8 [gaim-migrate @ 14668]
Mark Doliner <mark@kingant.net>
parents: 11457
diff changeset
105 $account->connect();
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
106
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
107 print "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
108 Gaim::debug_info("plugin_load()", "Testing $MODULE_NAME Completed.");
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
109 print "\n\n" . "#" x 80 . "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
110 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
111
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
112 sub plugin_unload {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
113 my $plugin = shift;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
114
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
115 print "#" x 80 . "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
116 Gaim::debug_info("plugin_unload()", "Testing $MODULE_NAME Started.");
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
117 print "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
118
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
119 ######### TEST CODE HERE ##########
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
120
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
121 print "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
122 Gaim::debug_info("plugin_unload()", "Testing $MODULE_NAME Completed.");
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
123 print "\n\n" . "#" x 80 . "\n\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
124 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
125