| |
1 $MODULE_NAME = "Request Functions 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 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.", |
| |
12 author => "John H. Kelm <johnhkelm\@gmail.com>", |
| |
13 url => "http://sourceforge.net/users/johnhkelm/", |
| |
14 |
| |
15 load => "plugin_load", |
| |
16 unload => "plugin_unload", |
| |
17 plugin_action_sub => "plugin_action_names" |
| |
18 ); |
| |
19 |
| |
20 %plugin_actions = ( |
| |
21 "Plugin Action Test Label" => \&plugin_action_test, |
| |
22 ); |
| |
23 |
| |
24 sub plugin_action_names { |
| |
25 foreach $key (keys %plugin_actions) { |
| |
26 push @array, $key; |
| |
27 } |
| |
28 |
| |
29 return @array; |
| |
30 } |
| |
31 |
| |
32 sub plugin_init { |
| |
33 return %PLUGIN_INFO; |
| |
34 } |
| |
35 |
| |
36 sub ok_cb_test { |
| |
37 $fields = shift; |
| |
38 |
| |
39 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: BEGIN\n"); |
| |
40 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: BEGIN\n"); |
| |
41 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Button Click\n"); |
| |
42 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Field Type: $fields \n"); |
| |
43 $account = Gaim::Request::Fields::get_account($fields, "acct_test"); |
| |
44 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Username of selected account: " . Gaim::Account::get_username($account) . "\n"); |
| |
45 $int = Gaim::Request::Fields::get_integer($fields, "int_test"); |
| |
46 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Integer Value: $int \n"); |
| |
47 $choice = Gaim::Request::Fields::get_choice($fields, "ch_test"); |
| |
48 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: Choice Value: $choice \n"); |
| |
49 Gaim::Debug::info($MODULE_NAME, "ok_cb_test: END\n"); |
| |
50 } |
| |
51 |
| |
52 sub cancel_cb_test { |
| |
53 Gaim::Debug::info($MODULE_NAME, "cancel_cb_test: Button Click\n"); |
| |
54 } |
| |
55 |
| |
56 sub plugin_action_test { |
| |
57 $plugin = shift; |
| |
58 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: BEGIN\n"); |
| |
59 plugin_request($plugin); |
| |
60 Gaim::Debug::info($MODULE_NAME, "plugin_action_cb_test: END\n"); |
| |
61 } |
| |
62 |
| |
63 sub plugin_load { |
| |
64 my $plugin = shift; |
| |
65 ######### TEST CODE HERE ########## |
| |
66 |
| |
67 |
| |
68 } |
| |
69 |
| |
70 sub plugin_request { |
| |
71 $group = Gaim::Request::Field::Group::new("Group Name"); |
| |
72 $field = Gaim::Request::Field::account_new("acct_test", "Account Text", undef); |
| |
73 Gaim::Request::Field::account_set_show_all($field, 0); |
| |
74 Gaim::Request::Field::Group::add_field($group, $field); |
| |
75 |
| |
76 $field = Gaim::Request::Field::int_new("int_test", "Integer Text", 33); |
| |
77 Gaim::Request::Field::Group::add_field($group, $field); |
| |
78 |
| |
79 # Test field choice |
| |
80 $field = Gaim::Request::Field::choice_new("ch_test", "Choice Text", 1); |
| |
81 Gaim::Request::Field::choice_add($field, "Choice 0"); |
| |
82 Gaim::Request::Field::choice_add($field, "Choice 1"); |
| |
83 Gaim::Request::Field::choice_add($field, "Choice 2"); |
| |
84 |
| |
85 Gaim::Request::Field::Group::add_field($group, $field); |
| |
86 |
| |
87 |
| |
88 $request = Gaim::Request::Fields::new(); |
| |
89 Gaim::Request::Fields::add_group($request, $group); |
| |
90 |
| |
91 Gaim::Request::fields( |
| |
92 $plugin, |
| |
93 "Request Title!", |
| |
94 "Primary Title", |
| |
95 "Secondary Title", |
| |
96 $request, |
| |
97 "Ok Text", "ok_cb_test", |
| |
98 "Cancel Text", "cancel_cb_test"); |
| |
99 } |
| |
100 |
| |
101 sub plugin_unload { |
| |
102 my $plugin = shift; |
| |
103 Gaim::Debug::info($MODULE_NAME, "#" x 80 . "\n"); |
| |
104 ######### TEST CODE HERE ########## |
| |
105 |
| |
106 |
| |
107 Gaim::Debug::info($MODULE_NAME, "\n" . "#" x 80 . "\n"); |
| |
108 } |
| |
109 |