libpurple/plugins/perl/scripts/plugin_pref.pl

Mon, 19 Mar 2007 17:02:24 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 19 Mar 2007 17:02:24 +0000
changeset 15894
765ec644ac47
parent 15435
4b933b06d75e
child 16238
33bf2fd32108
child 18068
b6554e3c8224
child 20478
46933dc62880
child 23930
c1c3d7cab338
permissions
-rw-r--r--

Perl fixes for s/gaim/purple/. This hasn't really been tested yet.

11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
1 $MODULE_NAME = "Prefs Functions Test";
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
2 use Purple;
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
3 # All the information Purple gets about our nifty plugin
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
4 %PLUGIN_INFO = (
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
5 perl_api_version => 2,
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
6 name => "Perl: $MODULE_NAME",
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
7 version => "0.1",
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
8 summary => "Test plugin for the Perl interpreter.",
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
9 description => "Implements a set of test proccedures to ensure all " .
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
10 "functions that work in the C API still work in the " .
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
11 "Perl plugin interface. As XSUBs are added, this " .
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
12 "*should* be updated to test the changes. " .
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
13 "Furthermore, this will function as the tutorial perl " .
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
14 "plugin.",
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
15 author => "John H. Kelm <johnhkelm\@gmail.com>",
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
16 url => "http://sourceforge.net/users/johnhkelm/",
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
17
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
18 load => "plugin_load",
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
19 unload => "plugin_unload",
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
20 prefs_info => "foo"
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
21 );
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 # These names must already exist
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
24 my $GROUP = "UIUC Buddies";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
25 my $USERNAME = "johnhkelm2";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
26
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
27 # We will create these on load then destroy them on unload
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
28 my $TEST_GROUP = "perlTestGroup";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
29 my $TEST_NAME = "perlTestName";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
30 my $TEST_ALIAS = "perlTestAlias";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
31 my $PROTOCOL_ID = "prpl-oscar";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
32
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
33 sub foo {
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
34 $frame = Purple::PluginPref::Frame->new();
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
35
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
36 $ppref = Purple::PluginPref->new_with_label("boolean");
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
37 $frame->add($ppref);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
38
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
39 $ppref = Purple::PluginPref->new_with_name_and_label(
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
40 "/plugins/core/perl_test/bool", "Boolean Preference");
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
41 $frame->add($ppref);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
42
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
43
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
44 $ppref = Purple::PluginPref->new_with_name_and_label(
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
45 "/plugins/core/perl_test/choice", "Choice Preference");
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
46 $ppref->set_type(1);
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
47 $ppref->add_choice("ch0", $frame);
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
48 $ppref->add_choice("ch1", $frame);
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
49 $frame->add($ppref);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
50
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
51 $ppref = Purple::PluginPref->new_with_name_and_label(
12364
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
52 "/plugins/core/perl_test/text", "Text Box Preference");
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
53 $ppref->set_max_length(16);
42b44fed7423 [gaim-migrate @ 14668]
Will Thompson <resiak@pidgin.im>
parents: 11170
diff changeset
54 $frame->add($ppref);
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
55
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
56 return $frame;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
57 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
58
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
59 sub plugin_init {
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
60
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
61 return %PLUGIN_INFO;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
62 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
63
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
64
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
65 # 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
66 # 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
67 sub plugin_load {
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
68 my $plugin = shift;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
69 print "#" x 80 . "\n\n";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
70
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
71
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
72 ######### TEST CODE HERE ##########
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
73
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
74 Purple::Prefs::add_none("/plugins/core/perl_test");
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
75 Purple::Prefs::add_bool("/plugins/core/perl_test/bool", 1);
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
76 Purple::Prefs::add_string("/plugins/core/perl_test/choice", "ch1");
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
77 Purple::Prefs::add_string("/plugins/core/perl_test/text", "Foobar");
11170
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
78
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
79
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
80 print "\n\n" . "#" x 80 . "\n\n";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
81 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
82
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
83 sub plugin_unload {
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
84 my $plugin = shift;
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
85
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
86 print "#" x 80 . "\n\n";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
87
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
88
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
89 ######### TEST CODE HERE ##########
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
90
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
91
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
92 print "\n\n" . "#" x 80 . "\n\n";
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
93 }
d8941580d87f [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
94

mercurial