From 63e2cf2d938cf8253b3e54b3cdcc892c0a6d1d89 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 1 Feb 2010 16:33:45 -0500 Subject: [PATCH] Process extra plugin config in Thrasher::Start instead of Protocol. --- perl/lib/Thrasher.pm | 12 ++++++++++++ perl/lib/Thrasher/Protocol.pm | 14 +------------- perl/thrasherbird.pl | 21 +++++++++++++++------ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/perl/lib/Thrasher.pm b/perl/lib/Thrasher.pm index a3b3a5f..23ed7b9 100644 --- a/perl/lib/Thrasher.pm +++ b/perl/lib/Thrasher.pm @@ -57,6 +57,7 @@ sub start { my $protocol_configuration = shift || {}; my $component_name_base = shift; $SERVER_NAME = shift; + my $plugins = shift || []; my $event_loop_module; @@ -111,6 +112,17 @@ sub start { ."the following:\n\n$@"; exit; } + + for my $plugin_module (@{$plugins}) { + eval("use ${plugin_module};"); + if ($@) { + print + "While trying to load the $plugin_module plugin, an error\n" + . " was encountered. The developers will want to know about\n" + . " the following:\n\n$@\n"; + exit(1); + } + } } my $retry = 0; diff --git a/perl/lib/Thrasher/Protocol.pm b/perl/lib/Thrasher/Protocol.pm index 6e23bcf..c64f4d4 100644 --- a/perl/lib/Thrasher/Protocol.pm +++ b/perl/lib/Thrasher/Protocol.pm @@ -73,8 +73,7 @@ Only the top-level configuration file will call: C($configuration, $backend): The configuration argument hash is what is passed in by component.pl. -The default implementation copies these into keys of $self and loads -any plugin packages named in the C<$configuration->{'plugins'}> arrayref. +The default implementation copies these into keys of $self. =back @@ -94,17 +93,6 @@ sub new { $self->{configuration} = shift; $self->{backend} = shift; - $self->{'configuration'}->{'plugins'} ||= []; - for my $plugin_module (@{$self->{'configuration'}->{'plugins'}}) { - eval("use $plugin_module;"); - if ($@) { - print "While trying to load the $plugin_module plugin, an error\n" - ."was encountered. The developers will want to know about\n" - ."the following:\n\n$@\n"; - exit(1); - } - } - return $self; } diff --git a/perl/thrasherbird.pl b/perl/thrasherbird.pl index e5d80d7..78cecc7 100644 --- a/perl/thrasherbird.pl +++ b/perl/thrasherbird.pl @@ -44,11 +44,7 @@ ## The "Test" protocol does very little for you. # # $protocol = Test; -# my $protocol_configuration = { -# plugins => [ qw( -# Thrasher::Plugin::ProxyFileTransfer -# ) ], -# }; +# my $protocol_configuration = {}; ####### ## CONNECTION INFO @@ -75,6 +71,17 @@ $server_secret = 'secret'; # which means you should set this as the domain name of your server. $component_name_base = 'localhost'; +####### +## PLUGINS +####### + +my $plugins = []; + +# ProxyFileTransfer (currently must be used with a Purple protocol) +# enables file transfers to and from contacts on the transport. +# push(@{$plugins}, 'Thrasher::Plugin::ProxyFileTransfer'); + + #### THRASHER BIRD PROGRAM # If you are just configuring the program, ignore everything after # this. @@ -86,4 +93,6 @@ use Thrasher; # Networks.) Thrasher::start($backend, $protocol, $server_ip, $server_port, $server_secret, $backend_configuration, - $protocol_configuration, $component_name_base); + $protocol_configuration, $component_name_base, + $plugins, + ); -- 2.11.4.GIT