Mercurial > pidgin
annotate libgaim/plugins/perl/scripts/request.pl @ 14449:74cdcd0c58b5
[gaim-migrate @ 17163]
Make Gaim::Gtk actually work in wingaim.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 05 Sep 2006 02:09:17 +0000 |
parents | e88aae4f4c40 |
children |
rev | line source |
---|---|
14192 | 1 $MODULE_NAME = "Request Functions Test"; |
2 | |
3 use Gaim; | |
4 | |
5 # All the information Gaim gets about our nifty plugin | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
6 %PLUGIN_INFO = ( |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
7 perl_api_version => 2, |
14449
74cdcd0c58b5
[gaim-migrate @ 17163]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14447
diff
changeset
|
8 name => "Perl: $MODULE_NAME", |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
9 version => "0.1", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
10 summary => "Test plugin for the Perl interpreter.", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
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.", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
12 author => "John H. Kelm <johnhkelm\@gmail.com>", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
13 url => "http://sourceforge.net/users/johnhkelm/", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
14 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
15 load => "plugin_load", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
16 unload => "plugin_unload", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
17 plugin_action_sub => "plugin_action_names" |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
18 ); |
14192 | 19 |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
20 %plugin_actions = ( |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
21 "Plugin Action Test Label" => \&plugin_action_test, |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
22 ); |
14192 | 23 |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
24 sub plugin_action_names { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
25 foreach $key (keys %plugin_actions) { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
26 push @array, $key; |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
27 } |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
28 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
29 return @array; |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
30 } |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
31 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
32 sub plugin_init { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
33 return %PLUGIN_INFO; |
14192 | 34 } |
35 | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
36 sub ok_cb_test { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
37 $fields = shift; |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
38 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
39 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: BEGIN\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
40 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: BEGIN\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
41 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Button Click\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
42 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Field Type: $fields \n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
43 $account = Gaim::Request::Fields::get_account($fields, "acct_test"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
44 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Username of selected account: " . Gaim::Account::get_username($account) . "\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
45 $int = Gaim::Request::Fields::get_integer($fields, "int_test"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
46 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Integer Value: $int \n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
47 $choice = Gaim::Request::Fields::get_choice($fields, "ch_test"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
48 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Choice Value: $choice \n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
49 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: END\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
50 } |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
51 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
52 sub cancel_cb_test { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
53 Gaim::Debug::info($MODULE_NAME, "cancel_cb_test: Button Click\n"); |
14192 | 54 } |
55 | |
56 sub plugin_action_test { | |
57 $plugin = shift; | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
58 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: BEGIN\n"); |
14192 | 59 plugin_request($plugin); |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
60 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: END\n"); |
14192 | 61 } |
62 | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
63 sub plugin_load { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
64 my $plugin = shift; |
14192 | 65 ######### TEST CODE HERE ########## |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
66 |
14192 | 67 |
68 } | |
69 | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
70 sub plugin_request { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
71 $group = Gaim::Request::Field::Group::new("Group Name"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
72 $field = Gaim::Request::Field::account_new("acct_test", "Account Text", undef); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
73 Gaim::Request::Field::account_set_show_all($field, 0); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
74 Gaim::Request::Field::Group::add_field($group, $field); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
75 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
76 $field = Gaim::Request::Field::int_new("int_test", "Integer Text", 33); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
77 Gaim::Request::Field::Group::add_field($group, $field); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
78 |
14192 | 79 # Test field choice |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
80 $field = Gaim::Request::Field::choice_new("ch_test", "Choice Text", 1); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
81 Gaim::Request::Field::choice_add($field, "Choice 0"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
82 Gaim::Request::Field::choice_add($field, "Choice 1"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
83 Gaim::Request::Field::choice_add($field, "Choice 2"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
84 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
85 Gaim::Request::Field::Group::add_field($group, $field); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
86 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
87 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
88 $request = Gaim::Request::Fields::new(); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
89 Gaim::Request::Fields::add_group($request, $group); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
90 |
14192 | 91 Gaim::Request::fields( |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
92 $plugin, |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
93 "Request Title!", |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
94 "Primary Title", |
14192 | 95 "Secondary Title", |
96 $request, | |
97 "Ok Text", "ok_cb_test", | |
98 "Cancel Text", "cancel_cb_test"); | |
99 } | |
100 | |
14378
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
101 sub plugin_unload { |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
102 my $plugin = shift; |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
103 Gaim::Debug::info($MODULE_NAME, "#" x 80 . "\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
104 ######### TEST CODE HERE ########## |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
105 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
106 |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
107 Gaim::Debug::info($MODULE_NAME, "\n" . "#" x 80 . "\n"); |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
108 } |
d1d275a95d02
[gaim-migrate @ 17084]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
109 |