Mercurial > pidgin
changeset 12364:6fd82071a7b8
[gaim-migrate @ 14668]
sf patch #1373688, from Will Thompson
"Make the Perl bindings more Perl-ish"
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 05 Dec 2005 23:54:34 +0000 |
parents | f758af0373cb |
children | 7f1c4630799c |
files | doc/PERL-HOWTO.dox plugins/perl/common/Account.xs plugins/perl/common/AccountOpts.xs plugins/perl/common/Conversation.xs plugins/perl/common/FT.xs plugins/perl/common/Gaim.xs plugins/perl/common/PluginPref.xs plugins/perl/common/Stringref.xs plugins/perl/common/XMLNode.xs plugins/perl/common/module.h plugins/perl/common/typemap plugins/perl/scripts/account.pl plugins/perl/scripts/conversation.pl plugins/perl/scripts/count_down.pl plugins/perl/scripts/plugin_pref.pl |
diffstat | 15 files changed, 235 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/PERL-HOWTO.dox Mon Dec 05 23:41:29 2005 +0000 +++ b/doc/PERL-HOWTO.dox Mon Dec 05 23:54:34 2005 +0000 @@ -48,11 +48,27 @@ @section account-api Account and Account Option Functions -The Account API is in the @c Gaim::Account:: and @c Gaim::Accounts:: packages and both are nearly identical to their C counterparts @c gaim_account_ and @c gaim_accounts_. The Account Option API is in the package @c Gaim::Account::Option and is identical to its C implementation @c gaim_account_option . +The Account API is in the @c Gaim::Account:: and @c Gaim::Accounts:: packages +and both are nearly identical to their C counterparts @c gaim_account_ and @c +gaim_accounts_. The Account Option API is in the package @c +Gaim::Account::Option and is identical to its C implementation @c +gaim_account_option. -The Account* APIs allow for scripts to create, remove, and edit accounts of the type GaimAccount. (Note: Gaim type have no real meaning in perl scripts other than the types of the arguments of the perl subroutines need to be of the expected type.) This section will not go into detail about the @c Gaim::Account::Option package for its use in building protocol plugins which are outside the scope of this document. However, most of the API calls for the @c Gaim::Account::Option package should function as expected so if there is a need to access any of the Account Options the function calls necessary are avaialbe in the Gaim perl API. +The Account* APIs allow for scripts to create, remove, and edit accounts of the +type GaimAccount. (Note: Gaim types have no real meaning in perl scripts other +than the types of the arguments of the perl subroutines need to be of the +expected type.) This section will not go into detail about the @c +Gaim::Account::Option package for its use in building protocol plugins which +are outside the scope of this document. However, most of the API calls for the +@c Gaim::Account::Option package should function as expected so if there is a +need to access any of the Account Options the function calls necessary are +avaialbe in the Gaim perl API. -To reduce redundant code the following code examples are going to use the template shown in the previous section. To highlight some of the more useful features of the Account API we will be replacing the @c plugin_load perl subroutine. For testing purposes we will display output on the command line by using perl @c print commands. +To reduce redundant code the following code examples are going to use the +template shown in the previous section. To highlight some of the more useful +features of the Account API we will be replacing the @c plugin_load perl +subroutine. For testing purposes we will display output on the command line by +using perl @c print commands. @code sub plugin_load { @@ -62,9 +78,9 @@ my $protocol = "prpl-oscar"; # Create a new Account - print "Testing: Gaim::Account::new()..."; - $account = Gaim::Account::new("TEST_NAME", $protocol); - if ($account) { print "ok.\n"; } else { print "fail.\n"; } + print "Testing: Gaim::Account::new()... "; + $account = Gaim::Account->new($TEST_NAME, $PROTOCOL_ID); + if ($account) { print "ok.\n"; } else { print "fail.\n"; } # Add a new Account print "Testing: Gaim::Account::add()..."; @@ -77,32 +93,51 @@ if ($account) { print "ok.\n"; } else { print "fail.\n"; } # Return the username - print "Testing: Gaim::Account::get_username()..."; - $user_name = Gaim::Account::get_username($account); - if ($user_name) { print $user_name . "...ok.\n"; } else { print "fail.\n"; } - + print "Testing: Gaim::Account::get_username()... "; + $user_name = $account->get_username(); + if ($user_name) { + print "Success: $user_name.\n"; + } else { + print "Failed!\n"; + } # Verify if the user is connected - print "Testing: Gaim::Account::is_connected()"; - $user_connected = Gaim::Account::is_connected($account); - if (!($user_connected)) { print "...not connected...ok..\n"; } else { print "...connected...ok.\n"; } + print "Testing: Gaim::Account::is_connected()"; + if ($account->is_connected()) { + print " Connected.\n"; + } else { + print " Disconnected.\n"; + } - # The status mechanism is how users are Connected, set Away, Disconnected (status set to Offline), etc + # The status mechanism is how users are Connected, set Away, + # Disconnected (status set to Offline), etc # $status is now a Gaim::Status perl type. - print "Testing: Gaim::Accounts::get_active_status()..."; - $status = Gaim::Account::get_active_status($account); - if ($status) { print "ok.\n"; } else { print "fail.\n"; } + print "Testing: Gaim::Accounts::get_active_status()... "; + if ($account->get_active_status()) { + print "Okay.\n"; + } else { + print "Failed!\n"; + } - # It follows that to connect a user you mest set the account status to "available" - # similarly we can disconnect a user by setting the account status to "offline" + # It follows that to connect a user you mest set the account status to + # "available" similarly we can disconnect a user by setting the account + # status to "offline" + $account = Gaim::Accounts::find("TEST_NAME", $protocol); print "Testing: Gaim::Accounts::connect()...pending...\n"; - Gaim::Account::set_status($account, "available", TRUE); - Gaim::Account::connect($account); + $account->set_status("available", TRUE); + $account->connect(); + } @endcode -For the most part the code listed above is explained by the comments, however there are a few other points to make. The variables above are all specialized Perl types that contain pointers to the actual Gaim types. They can be reasigned at will just like any other variable in Perl. The only way to edit the values of a Gaim type from within perl are through accessor methods such as @c Gaim::Account::get_username(). For arguments that you would make @c NULL in C should be set to @c undef in Perl. +For the most part the code listed above is explained by the comments, however +there are a few other points to make. The variables above are all specialized +Perl types that contain pointers to the actual Gaim types. They can be +reasigned at will just like any other variable in Perl. The only way to edit +the values of a Gaim type from within perl are through accessor methods such as +@c Gaim::Account::get_username(). For arguments that you would make @c NULL in +C should be set to @c undef in Perl. @section buddylist-api Buddylist, Group and Chat API @@ -284,28 +319,33 @@ @code sub prefs_info_cb { # The first step is to initialize the Gaim::Pref::Frame that will be returned - $frame = Gaim::Pref::frame_new(); + $frame = Gaim::PluginPref::Frame->new(); - # Create a new boolean option with a label "Boolean Label" and then add it to the frame - $ppref = Gaim::Pref::new_with_label("Boolean Label"); - Gaim::Pref::frame_add($frame, $ppref); + # Create a new boolean option with a label "Boolean Label" and then add + # it to the frame + $ppref = Gaim::Pref->new_with_label("Boolean Label"); + $frame->add($ppref); - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/bool", "Boolean Preference"); - Gaim::Pref::frame_add($frame, $ppref); + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/bool", "Boolean Preference"); + $frame->add($ppref); - # Create a set of choices. To do so we must set the type to 1 which is the numerical equivelant of - # the GaimPrefType for choice. - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/choice", "Choice Preference"); - Gaim::Pref::set_type($ppref, 1); - Gaim::Pref::add_choice($ppref, "ch0", $frame); + # Create a set of choices. To do so we must set the type to 1 which is + # the numerical equivelant of the GaimPrefType for choice. + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/choice", "Choice Preference"); + $ppref->set_type(1); + $ppref->add_choice("ch0", $frame); # The following will be the default value as set from plugin_load - Gaim::Pref::add_choice($ppref, "ch1", $frame); - Gaim::Pref::frame_add($frame, $ppref); + $ppref->add_choice("ch1", $frame); + $frame->add($ppref); - # Create a text box. The default value will be "Foobar" as set by plugin_load - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/text", "Text Box Preference"); - Gaim::Pref::set_max_length($ppref, 16); - Gaim::Pref::frame_add($frame, $ppref); + # Create a text box. The default value will be "Foobar" as set by + # plugin_load + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/text", "Text Box Preference"); + $ppref->set_max_length(16); + $frame->add($ppref); return $frame; }
--- a/plugins/perl/common/Account.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/Account.xs Mon Dec 05 23:54:34 2005 +0000 @@ -8,9 +8,11 @@ Gaim::Account account Gaim::Account -gaim_account_new(username, protocol_id) +gaim_account_new(class, username, protocol_id) const char * username const char * protocol_id + C_ARGS: + username, protocol_id void gaim_account_destroy(account)
--- a/plugins/perl/common/AccountOpts.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/AccountOpts.xs Mon Dec 05 23:54:34 2005 +0000 @@ -33,7 +33,7 @@ gboolean value Gaim::Account::Option -gaim_account_option_list_new(text, pref_name, values) +gaim_account_option_list_new(class, text, pref_name, values) const char * text const char * pref_name SV * values @@ -53,28 +53,36 @@ RETVAL Gaim::Account::Option -gaim_account_option_string_new(text, pref_name, default_value) +gaim_account_option_string_new(class, text, pref_name, default_value) const char * text const char * pref_name const char * default_value + C_ARGS: + text, pref_name, default_value Gaim::Account::Option -gaim_account_option_int_new(text, pref_name, default_value) +gaim_account_option_int_new(class, text, pref_name, default_value) const char * text const char * pref_name gboolean default_value + C_ARGS: + text, pref_name, default_value Gaim::Account::Option -gaim_account_option_bool_new(text, pref_name, default_value) +gaim_account_option_bool_new(class, text, pref_name, default_value) const char * text const char * pref_name gboolean default_value + C_ARGS: + text, pref_name, default_value Gaim::Account::Option -gaim_account_option_new(type, text, pref_name) +gaim_account_option_new(class, type, text, pref_name) Gaim::PrefType type const char * text const char * pref_name + C_ARGS: + type, text, pref_name void gaim_account_option_get_list(option) @@ -137,10 +145,12 @@ PROTOTYPES: ENABLE Gaim::Account::UserSplit -gaim_account_user_split_new(text, default_value, sep) +gaim_account_user_split_new(class, text, default_value, sep) const char * text const char * default_value char sep + C_ARGS: + text, default_value, sep char gaim_account_user_split_get_separator(split)
--- a/plugins/perl/common/Conversation.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/Conversation.xs Mon Dec 05 23:54:34 2005 +0000 @@ -124,10 +124,12 @@ Gaim::ConvUpdateType type Gaim::Conversation -gaim_conversation_new(type, account, name) +gaim_conversation_new(class, type, account, name) Gaim::ConversationType type Gaim::Account account const char *name + C_ARGS: + type, account, name void gaim_conversation_set_account(conv, account);
--- a/plugins/perl/common/FT.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/FT.xs Mon Dec 05 23:54:34 2005 +0000 @@ -3,6 +3,14 @@ MODULE = Gaim::Xfer PACKAGE = Gaim::Xfer PREFIX = gaim_xfer_ PROTOTYPES: ENABLE +Gaim::Xfer +gaim_xfer_new(class, account, type, who) + Gaim::Account account + Gaim::XferType type + const char *who + C_ARGS: + account, type, who + void gaim_xfer_add(xfer) Gaim::Xfer xfer
--- a/plugins/perl/common/Gaim.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/Gaim.xs Mon Dec 05 23:54:34 2005 +0000 @@ -96,7 +96,7 @@ GAIM_PERL_BOOT(Network); GAIM_PERL_BOOT(Notify); GAIM_PERL_BOOT(Plugin); - GAIM_PERL_BOOT(Pref); + GAIM_PERL_BOOT(PluginPref); GAIM_PERL_BOOT(Pounce); GAIM_PERL_BOOT(Prefs); GAIM_PERL_BOOT(Privacy);
--- a/plugins/perl/common/PluginPref.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/PluginPref.xs Mon Dec 05 23:54:34 2005 +0000 @@ -1,30 +1,20 @@ #include "module.h" -MODULE = Gaim::Pref PACKAGE = Gaim::Pref PREFIX = gaim_plugin_pref_ +MODULE = Gaim::PluginPref PACKAGE = Gaim::PluginPref::Frame PREFIX = gaim_plugin_pref_frame_ PROTOTYPES: ENABLE -void -gaim_plugin_pref_add_choice(pref, label, choice) - Gaim::PluginPref pref - char *label - gpointer choice - -void -gaim_plugin_pref_destroy(pref) - Gaim::PluginPref pref - -void +void gaim_plugin_pref_frame_add(frame, pref) - Gaim::PluginPrefFrame frame + Gaim::PluginPref::Frame frame Gaim::PluginPref pref void gaim_plugin_pref_frame_destroy(frame) - Gaim::PluginPrefFrame frame + Gaim::PluginPref::Frame frame void gaim_plugin_pref_frame_get_prefs(frame) - Gaim::PluginPrefFrame frame + Gaim::PluginPref::Frame frame PREINIT: GList *l; PPCODE: @@ -32,11 +22,26 @@ XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListItem"))); } -Gaim::PluginPrefFrame -gaim_plugin_pref_frame_new() +Gaim::PluginPref::Frame +gaim_plugin_pref_frame_new(class) + C_ARGS: /* void */ -void +MODULE = Gaim::PluginPref PACKAGE = Gaim::PluginPref PREFIX = gaim_plugin_pref_ +PROTOTYPES: ENABLE + +void +gaim_plugin_pref_add_choice(pref, label, choice) + Gaim::PluginPref pref + char *label + gpointer choice + +void +gaim_plugin_pref_destroy(pref) + Gaim::PluginPref pref + + +void gaim_plugin_pref_get_bounds(pref, min, max) Gaim::PluginPref pref int *min @@ -73,21 +78,28 @@ Gaim::PluginPref pref Gaim::PluginPref -gaim_plugin_pref_new() +gaim_plugin_pref_new(class) + C_ARGS: /* void */ Gaim::PluginPref -gaim_plugin_pref_new_with_label(label) +gaim_plugin_pref_new_with_label(class, label) char *label + C_ARGS: + label Gaim::PluginPref -gaim_plugin_pref_new_with_name(name) +gaim_plugin_pref_new_with_name(class, name) char *name + C_ARGS: + name Gaim::PluginPref -gaim_plugin_pref_new_with_name_and_label(name, label) +gaim_plugin_pref_new_with_name_and_label(class, name, label) char *name char *label + C_ARGS: + name, label void gaim_plugin_pref_set_bounds(pref, min, max)
--- a/plugins/perl/common/Stringref.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/Stringref.xs Mon Dec 05 23:54:34 2005 +0000 @@ -13,12 +13,16 @@ Gaim::Stringref stringref Gaim::Stringref -gaim_stringref_new(value) +gaim_stringref_new(class, value) const char *value + C_ARGS: + value Gaim::Stringref -gaim_stringref_new_noref(value) +gaim_stringref_new_noref(class, value) const char *value + C_ARGS: + value
--- a/plugins/perl/common/XMLNode.xs Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/XMLNode.xs Mon Dec 05 23:54:34 2005 +0000 @@ -4,30 +4,34 @@ PROTOTYPES: ENABLE -xmlnode * -xmlnode_copy(src) +Gaim::XMLNode +xmlnode_copy(class, src) xmlnode *src + C_ARGS: + src void xmlnode_free(node) xmlnode *node -xmlnode * -xmlnode_from_str(str, size) +Gaim::XMLNode +xmlnode_from_str(class, str, size) const char *str gssize size + C_ARGS: + str, size const char * xmlnode_get_attrib(node, attr) xmlnode *node const char *attr -xmlnode * +Gaim::XMLNode xmlnode_get_child(parent, name) const xmlnode *parent const char *name -xmlnode * +Gaim::XMLNode xmlnode_get_child_with_namespace(parent, name, xmlns) const xmlnode *parent const char *name @@ -37,7 +41,7 @@ xmlnode_get_data(node) xmlnode *node -xmlnode * +Gaim::XMLNode xmlnode_get_next_twin(node) xmlnode *node @@ -52,11 +56,13 @@ const char *data gssize size -xmlnode * -xmlnode_new(name) +Gaim::XMLNode +xmlnode_new(class, name) const char *name + C_ARGS: + name -xmlnode * +Gaim::XMLNode xmlnode_new_child(parent, name) xmlnode *parent const char *name
--- a/plugins/perl/common/module.h Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/module.h Mon Dec 05 23:54:34 2005 +0000 @@ -178,7 +178,7 @@ typedef GaimPluginAction * Gaim__Plugin__Action; /* pluginpref.h */ -typedef GaimPluginPrefFrame * Gaim__PluginPrefFrame; +typedef GaimPluginPrefFrame * Gaim__PluginPref__Frame; typedef GaimPluginPref * Gaim__PluginPref; typedef GaimPluginPrefType Gaim__PluginPrefType; @@ -250,6 +250,7 @@ typedef GaimValue * Gaim__Value; /* xmlnode.h */ +typedef xmlnode * Gaim__XMLNode; typedef XMLNodeType XMLNode__Type;
--- a/plugins/perl/common/typemap Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/common/typemap Mon Dec 05 23:54:34 2005 +0000 @@ -115,7 +115,7 @@ Gaim::Plugin::Protocol::Info T_GaimObj Gaim::PluginType T_IV Gaim::PrefType T_IV -Gaim::PluginPrefFrame T_GaimObj +Gaim::PluginPref::Frame T_GaimObj Gaim::PluginPref T_GaimObj Gaim::PluginPrefType T_IV Gaim::Pounce T_GaimObj @@ -169,6 +169,8 @@ Gaim::XferType T_IV Gaim::XferStatusType T_IV Gaim::XferUiOps T_IV + +Gaim::XMLNode T_GaimObj XMLNode::Type T_IV
--- a/plugins/perl/scripts/account.pl Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/scripts/account.pl Mon Dec 05 23:54:34 2005 +0000 @@ -8,7 +8,12 @@ name => " Perl: $MODULE_NAME", version => "0.1", summary => "Test plugin for the Perl interpreter.", - 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.", + 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.", author => "John H. Kelm <johnhkelm\@gmail.com>", url => "http://sourceforge.net/users/johnhkelm/", @@ -48,9 +53,9 @@ # # ################################# - print "Testing: Gaim::Account::Option::new...\n"; - $account_opt = Gaim::Account::Option::new(1, "TEXT", "pref_name"); - Gaim::Account::Option::bool_new("TeXt", "MYprefName", 1); + print "Testing: Gaim::Account::Option::new()...\n"; + $acc_opt = Gaim::Account::Option->new(1, "TEXT", "pref_name"); + $acc_opt2 = Gaim::Account::Option->bool_new("TeXt", "MYprefName", 1); ################################# # # @@ -59,37 +64,45 @@ ################################# - print "Testing: Gaim::Account::new()..."; - $account = Gaim::Account::new($TEST_NAME, $PROTOCOL_ID); + print "Testing: Gaim::Account::new()... "; + $account = Gaim::Account->new($TEST_NAME, $PROTOCOL_ID); if ($account) { print "ok.\n"; } else { print "fail.\n"; } - print "Testing: Gaim::Account::add()..."; + print "Testing: Gaim::Accounts::add()..."; Gaim::Accounts::add($account); - print "pending find...\n"; + print "pending find...\n"; print "Testing: Gaim::Accounts::find()..."; $account = Gaim::Accounts::find($TEST_NAME, $PROTOCOL_ID); if ($account) { print "ok.\n"; } else { print "fail.\n"; } - print "Testing: Gaim::Account::get_username()..."; - $user_name = Gaim::Account::get_username($account); - if ($user_name) { print $user_name . "...ok.\n"; } else { print "fail.\n"; } - + print "Testing: Gaim::Account::get_username()... "; + $user_name = $account->get_username(); + if ($user_name) { + print "Success: $user_name.\n"; + } else { + print "Failed!\n"; + } - print "Testing: Gaim::Account::is_connected()"; - $user_connected = Gaim::Account::is_connected($account); - if (!($user_connected)) { print "...not connected...ok..\n"; } else { print "...connected...ok.\n"; } + print "Testing: Gaim::Account::is_connected()... "; + if ($account->is_connected()) { + print " Connected.\n"; + } else { + print " Disconnected.\n"; + } - - print "Testing: Gaim::Accounts::get_active_status()..."; - $status = Gaim::Account::get_active_status($account); - if ($status) { print "ok.\n"; } else { print "fail.\n"; } + print "Testing: Gaim::Accounts::get_active_status()... "; + if ($account->get_active_status()) { + print "Okay.\n"; + } else { + print "Failed!\n"; + } $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID); print "Testing: Gaim::Accounts::connect()...pending...\n"; - Gaim::Account::set_status($account, "available", TRUE); - Gaim::Account::connect($account); + $account->set_status("available", TRUE); + $account->connect(); print "\n\n"; Gaim::debug_info("plugin_load()", "Testing $MODULE_NAME Completed.");
--- a/plugins/perl/scripts/conversation.pl Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/scripts/conversation.pl Mon Dec 05 23:54:34 2005 +0000 @@ -50,11 +50,11 @@ ######### TEST CODE HERE ########## # First we create two new conversations. print "Testing Gaim::Conversation::new()..."; - $conv1 = Gaim::Conversation::new(1, $account, "Test Conversation 1"); + $conv1 = Gaim::Conversation->new(1, $account, "Test Conversation 1"); if ($conv1) { print "ok.\n"; } else { print "fail.\n"; } print "Testing Gaim::Conversation::new()..."; - $conv2 = Gaim::Conversation::new(1, $account, "Test Conversation 2"); + $conv2 = Gaim::Conversation->new(1, $account, "Test Conversation 2"); if ($conv2) { print "ok.\n"; } else { print "fail.\n"; } # Second we create a window to display the conversations in.
--- a/plugins/perl/scripts/count_down.pl Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/scripts/count_down.pl Mon Dec 05 23:54:34 2005 +0000 @@ -34,7 +34,7 @@ # Search each account's user info for our tag foreach $acc (@accounts) { print "IN ACCOUNTS\n"; - $user_info = Gaim::Account::get_user_info($acc); + $user_info = $acc->get_user_info(); print "USER INFO 1: " . $user_info . "\n"; # Find <countdown> and replace $user_info =~ /countdown([0-9]+).([0-9]+).([0-9]+)/; @@ -42,7 +42,7 @@ $days = count_days($1, $2, $3); $user_info =~ s/countdown(\d\d\d\d).(\d\d).(\d\d)/$days/; print "USER INFO 2: " . $user_info . "\n"; - # Gaim::Account::set_user_info($acc, $user_info); + # $acc->set_user_info($user_info); } @@ -70,7 +70,7 @@ print "Test var: " . $GLOBAL_TEST_VAR . " \n"; @accounts = Gaim::Accounts::get_all(); $acc = $accounts[0]; - $user_info = Gaim::Account::get_user_info($acc); + $user_info = $acc->get_user_info(); print "USER INFO from sub hello: " . $user_info . "\n"; $window->destroy; }
--- a/plugins/perl/scripts/plugin_pref.pl Mon Dec 05 23:41:29 2005 +0000 +++ b/plugins/perl/scripts/plugin_pref.pl Mon Dec 05 23:54:34 2005 +0000 @@ -3,10 +3,15 @@ # All the information Gaim gets about our nifty plugin %PLUGIN_INFO = ( perl_api_version => 2, - name => " Perl: $MODULE_NAME", + name => "Perl: $MODULE_NAME", version => "0.1", summary => "Test plugin for the Perl interpreter.", - 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.", + 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.", author => "John H. Kelm <johnhkelm\@gmail.com>", url => "http://sourceforge.net/users/johnhkelm/", @@ -26,24 +31,27 @@ my $PROTOCOL_ID = "prpl-oscar"; sub foo { - $frame = Gaim::Pref::frame_new(); + $frame = Gaim::PluginPref::Frame->new(); - $ppref = Gaim::Pref::new_with_label("boolean"); - Gaim::Pref::frame_add($frame, $ppref); + $ppref = Gaim::PluginPref->new_with_label("boolean"); + $frame->add($ppref); - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/bool", "Boolean Preference"); - Gaim::Pref::frame_add($frame, $ppref); + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/bool", "Boolean Preference"); + $frame->add($ppref); - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/choice", "Choice Preference"); - Gaim::Pref::set_type($ppref, 1); - Gaim::Pref::add_choice($ppref, "foo", $frame); - Gaim::Pref::add_choice($ppref, "bar", $frame); - Gaim::Pref::frame_add($frame, $ppref); + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/choice", "Choice Preference"); + $ppref->set_type(1); + $ppref->add_choice("ch0", $frame); + $ppref->add_choice("ch1", $frame); + $frame->add($ppref); - $ppref = Gaim::Pref::new_with_name_and_label("/plugins/core/perl_test/text", "Text Box Preference"); - Gaim::Pref::set_max_length($ppref, 16); - Gaim::Pref::frame_add($frame, $ppref); + $ppref = Gaim::PluginPref->new_with_name_and_label( + "/plugins/core/perl_test/text", "Text Box Preference"); + $ppref->set_max_length(16); + $frame->add($ppref); return $frame; } @@ -65,8 +73,8 @@ Gaim::Prefs::add_none("/plugins/core/perl_test"); Gaim::Prefs::add_bool("/plugins/core/perl_test/bool", 1); - Gaim::Prefs::add_string("/plugins/core/perl_test/choice", "bar"); - Gaim::Prefs::add_string("/plugins/core/perl_test/text", "Foo"); + Gaim::Prefs::add_string("/plugins/core/perl_test/choice", "ch1"); + Gaim::Prefs::add_string("/plugins/core/perl_test/text", "Foobar"); print "\n\n" . "#" x 80 . "\n\n";