Wed, 13 May 2009 20:29:03 +0000
Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.
| 11170 | 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 | 4 | %PLUGIN_INFO = ( |
| 5 | perl_api_version => 2, | |
| 12364 | 6 | name => "Perl: $MODULE_NAME", |
| 11170 | 7 | version => "0.1", |
| 8 | summary => "Test plugin for the Perl interpreter.", | |
| 12364 | 9 | description => "Implements a set of test proccedures to ensure all " . |
| 10 | "functions that work in the C API still work in the " . | |
| 11 | "Perl plugin interface. As XSUBs are added, this " . | |
| 12 | "*should* be updated to test the changes. " . | |
| 13 | "Furthermore, this will function as the tutorial perl " . | |
| 14 | "plugin.", | |
| 11170 | 15 | author => "John H. Kelm <johnhkelm\@gmail.com>", |
| 16 | url => "http://sourceforge.net/users/johnhkelm/", | |
| 17 | ||
| 18 | load => "plugin_load", | |
| 19 | unload => "plugin_unload", | |
| 20 | prefs_info => "foo" | |
| 21 | ); | |
| 22 | ||
| 23 | # These names must already exist | |
| 24 | my $GROUP = "UIUC Buddies"; | |
| 25 | my $USERNAME = "johnhkelm2"; | |
| 26 | ||
| 27 | # We will create these on load then destroy them on unload | |
| 28 | my $TEST_GROUP = "perlTestGroup"; | |
| 29 | my $TEST_NAME = "perlTestName"; | |
| 30 | my $TEST_ALIAS = "perlTestAlias"; | |
| 31 | my $PROTOCOL_ID = "prpl-oscar"; | |
| 32 | ||
| 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 | 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 | 37 | $frame->add($ppref); |
| 11170 | 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 | 40 | "/plugins/core/perl_test/bool", "Boolean Preference"); |
| 41 | $frame->add($ppref); | |
| 11170 | 42 | |
| 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 | 45 | "/plugins/core/perl_test/choice", "Choice Preference"); |
| 46 | $ppref->set_type(1); | |
|
23930
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
47 | $ppref->add_choice("ch0", "ch0-val"); |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
48 | $ppref->add_choice("ch1", "ch1-val"); |
| 12364 | 49 | $frame->add($ppref); |
| 11170 | 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 | 52 | "/plugins/core/perl_test/text", "Text Box Preference"); |
| 53 | $ppref->set_max_length(16); | |
| 54 | $frame->add($ppref); | |
| 11170 | 55 | |
| 56 | return $frame; | |
| 57 | } | |
| 58 | ||
|
23930
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
59 | sub pref_cb { |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
60 | my ($pref, $type, $value, $data) = @_; |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
61 | |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
62 | print "pref changed: [$pref]($type)=$value data=$data\n"; |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
63 | } |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
64 | |
| 11170 | 65 | sub plugin_init { |
| 66 | ||
| 67 | return %PLUGIN_INFO; | |
| 68 | } | |
| 69 | ||
| 70 | # This is the sub defined in %PLUGIN_INFO to be called when the plugin is loaded | |
| 71 | # Note: The plugin has a reference to itself on top of the argument stack. | |
| 72 | sub plugin_load { | |
| 73 | my $plugin = shift; | |
| 74 | print "#" x 80 . "\n\n"; | |
| 75 | ||
| 76 | ||
| 77 | ######### TEST CODE HERE ########## | |
| 78 | ||
|
15894
765ec644ac47
Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | Purple::Prefs::add_string("/plugins/core/perl_test/text", "Foobar"); |
|
23930
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
83 | |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
84 | Purple::Prefs::connect_callback($plugin, "/plugins/core/perl_test", \&pref_cb, "none"); |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
85 | Purple::Prefs::connect_callback($plugin, "/plugins/core/perl_test/bool", \&pref_cb, "bool"); |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
86 | Purple::Prefs::connect_callback($plugin, "/plugins/core/perl_test/choice", \&pref_cb, "choice"); |
|
c1c3d7cab338
Add support to the Perl plugin loader for listing for pref changes.
Daniel Atallah <datallah@pidgin.im>
parents:
15894
diff
changeset
|
87 | Purple::Prefs::connect_callback($plugin, "/plugins/core/perl_test/text", \&pref_cb, "text"); |
| 11170 | 88 | |
| 89 | print "\n\n" . "#" x 80 . "\n\n"; | |
| 90 | } | |
| 91 | ||
| 92 | sub plugin_unload { | |
| 93 | my $plugin = shift; | |
| 94 | ||
| 95 | print "#" x 80 . "\n\n"; | |
| 96 | ||
| 97 | ||
| 98 | ######### TEST CODE HERE ########## | |
| 99 | ||
| 100 | ||
| 101 | print "\n\n" . "#" x 80 . "\n\n"; | |
| 102 | } | |
| 103 |