diff options
| author | fukachan <fukachan> | 2006-03-05 08:08:36 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2006-03-05 08:08:36 +0000 |
| commit | 6940f468f92ec8044c1982a4f7b12b4f4637a418 (patch) | |
| tree | 507b8dad59bc6b405872ddebb274cdfed52eba27 | |
| parent | 5ebcb0b781221838b47e8492d1e057b093490604 (diff) | |
| download | fml8-6940f468f92ec8044c1982a4f7b12b4f4637a418.tar.gz fml8-6940f468f92ec8044c1982a4f7b12b4f4637a418.tar.bz2 fml8-6940f468f92ec8044c1982a4f7b12b4f4637a418.zip | |
changed to command_context object based.
48 files changed, 572 insertions, 332 deletions
diff --git a/fml/lib/FML/Article/Spool.pm b/fml/lib/FML/Article/Spool.pm index ae6372a8..5adcc610 100644 --- a/fml/lib/FML/Article/Spool.pm +++ b/fml/lib/FML/Article/Spool.pm @@ -3,7 +3,7 @@ # Copyright (C) 2003,2004 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Spool.pm,v 1.9 2004/04/23 04:10:26 fukachan Exp $ +# $FML: Spool.pm,v 1.10 2004/07/23 04:13:04 fukachan Exp $ # package FML::Article::Spool; @@ -71,17 +71,17 @@ sub get_lock_channel_name # Descriptions: convert files at src_dir/ into dst_dir/. -# Arguments: OBJ($self) OBJ($curproc) HASH_RER($command_args) +# Arguments: OBJ($self) OBJ($curproc) HASH_RER($command_context) # Side Effects: none # Return Value: none sub convert { - my ($self, $curproc, $command_args) = @_; - my $wh = $command_args->{ _output_channel } || \*STDOUT; + my ($self, $curproc, $command_context) = @_; + my $wh = $command_context->{ _output_channel } || \*STDOUT; my $article = $self->{ _article }; - my $src_dir = $command_args->{ _src_dir } || ''; - my $dst_dir = $command_args->{ _dst_dir } || ''; - my $ml_name = $command_args->{ ml_name }; + my $src_dir = $command_context->{ _src_dir } || ''; + my $dst_dir = $command_context->{ _dst_dir } || ''; + my $ml_name = $command_context->get_ml_name(); my $channel = $self->get_lock_channel_name(); my $use_link = 0; @@ -166,14 +166,14 @@ sub convert # Descriptions: show information on spool and articles. -# Arguments: OBJ($self) OBJ($curproc) HASH_RER($command_args) +# Arguments: OBJ($self) OBJ($curproc) HASH_RER($command_context) # Side Effects: none # Return Value: none sub status { - my ($self, $curproc, $command_args) = @_; - my $wh = $command_args->{ _output_channel } || \*STDOUT; - my $dst_dir = $command_args->{ _dst_dir }; + my ($self, $curproc, $command_context) = @_; + my $wh = $command_context->{ _output_channel } || \*STDOUT; + my $dst_dir = $command_context->{ _dst_dir }; my $suffix = ''; my ($num_file, $num_dir) = $self->_scan_dir( $dst_dir ); diff --git a/fml/lib/FML/CGI/List.pm b/fml/lib/FML/CGI/List.pm index 111ed91e..026cfab5 100644 --- a/fml/lib/FML/CGI/List.pm +++ b/fml/lib/FML/CGI/List.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: List.pm,v 1.13 2004/07/23 13:16:33 fukachan Exp $ +# $FML: List.pm,v 1.14 2005/05/27 03:03:33 fukachan Exp $ # package FML::CGI::List; @@ -28,18 +28,18 @@ sub new # Descriptions: show address list. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub cgi_menu { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $target = $curproc->cgi_var_frame_target(); my $action = $curproc->cgi_var_action(); my $map_default = $curproc->cgi_var_address_map(); my $map_list = $curproc->cgi_var_address_map_list(); - my $ml_name = $command_args->{ ml_name }; + my $ml_name = $command_context->get_ml_name(); use FML::Restriction::Base; my $safe = new FML::Restriction::Base; diff --git a/fml/lib/FML/CGI/ML.pm b/fml/lib/FML/CGI/ML.pm index 03e097f6..99a0fc3e 100644 --- a/fml/lib/FML/CGI/ML.pm +++ b/fml/lib/FML/CGI/ML.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: ML.pm,v 1.10 2005/08/23 09:34:19 fukachan Exp $ +# $FML: ML.pm,v 1.11 2005/08/23 09:56:12 fukachan Exp $ # package FML::CGI::ML; @@ -28,21 +28,21 @@ sub new # Descriptions: show menu for subscribe/unsubscribe commands. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub cgi_menu { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $target = $curproc->cgi_var_frame_target(); my $action = $curproc->cgi_var_action(); my $ml_domain = $curproc->cgi_var_ml_domain(); my $ml_list = $curproc->cgi_var_ml_name_list(); my $address = $curproc->safe_param_address() || ''; - my $comname = $command_args->{ comname }; + my $comname = $command_context->get_cooked_command(); my $command_list = [ 'newml', 'rmml', 'reviveml' ]; - # XXX-TODO: who verified comname ? ($command_args verified?) + # XXX-TODO: who verified comname ? ($command_context verified?) unless ($curproc->cgi_var_cgi_mode() eq "admin") { # XXX-TODO: nl ? diff --git a/fml/lib/FML/CGI/Skin/Base.pm b/fml/lib/FML/CGI/Skin/Base.pm index 919d22d5..d0d18ddd 100644 --- a/fml/lib/FML/CGI/Skin/Base.pm +++ b/fml/lib/FML/CGI/Skin/Base.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Base.pm,v 1.2 2005/08/17 10:33:16 fukachan Exp $ +# $FML: Base.pm,v 1.3 2005/08/17 12:08:42 fukachan Exp $ # package FML::CGI::Skin::Base; @@ -137,7 +137,7 @@ sub run_cgi_main if (($command eq 'newml' && $ml_name) || ($command eq 'rmml' && $ml_name)) { print "<br>* case 1 <br>\n" if $debug; - my $command_args = { + my $command_context = { command_mode => $mode, comname => $command, command => $command, @@ -147,13 +147,13 @@ sub run_cgi_main args => undef, }; - $pcb->set('cgi', 'command_args', $command_args); - $curproc->cgi_execute_command($command_args); + $pcb->set('cgi', 'command_context', $command_context); + $curproc->cgi_execute_command($command_context); } elsif ($command && $address) { print "<br>* case 2 <br>\n" if $debug; - my $command_args = { + my $command_context = { command_mode => $mode, comname => $command, command => $command, @@ -163,13 +163,13 @@ sub run_cgi_main args => undef, }; - $pcb->set('cgi', 'command_args', $command_args); - $curproc->cgi_execute_command($command_args); + $pcb->set('cgi', 'command_context', $command_context); + $curproc->cgi_execute_command($command_context); } elsif ($navi_command) { print "<br>* case 3 <br>\n" if $debug; - my $command_args = { + my $command_context = { command_mode => $mode, comname => $navi_command, command => $navi_command, @@ -179,12 +179,12 @@ sub run_cgi_main args => undef, }; - $pcb->set('cgi', 'command_args', $command_args); + $pcb->set('cgi', 'command_context', $command_context); } elsif ($command) { print "<br>* case 4 <br>\n" if $debug; - my $command_args = { + my $command_context = { command_mode => $mode, comname => $command, command => $command, @@ -194,12 +194,12 @@ sub run_cgi_main args => undef, }; - $pcb->set('cgi', 'command_args', $command_args); + $pcb->set('cgi', 'command_context', $command_context); } else { print "<br>* case 5 <br>\n" if $debug; - $pcb->set('cgi', 'command_args', undef); + $pcb->set('cgi', 'command_context', undef); } } diff --git a/fml/lib/FML/CGI/User.pm b/fml/lib/FML/CGI/User.pm index 3364dc9d..71504fc2 100644 --- a/fml/lib/FML/CGI/User.pm +++ b/fml/lib/FML/CGI/User.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: User.pm,v 1.13 2005/06/04 08:51:28 fukachan Exp $ +# $FML: User.pm,v 1.14 2005/06/26 00:44:32 fukachan Exp $ # package FML::CGI::User; @@ -29,25 +29,25 @@ sub new # Descriptions: show menu for user control commands such as # subscribe, unsubscribe, addadmin, byeadmin, ... -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub cgi_menu { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $target = $curproc->cgi_var_frame_target(); my $action = $curproc->cgi_var_action(); my $ml_list = $curproc->cgi_var_ml_name_list(); my $address = $curproc->safe_param_address() || ''; - my $ml_name = $command_args->{ ml_name }; - my $comname = $command_args->{ comname }; + my $ml_name = $command_context->get_ml_name(); + my $comname = $command_context->get_cooked_command(); my $address_list = []; my $selected_key = ''; # # XXX $comman_args are checked already. - # $command_args are passed in the following way: - # FML::CGI::Menu::run_cgi_main et.al. builds/checks $command_args. + # $command_context are passed in the following way: + # FML::CGI::Menu::run_cgi_main et.al. builds/checks $command_context. # FML::CGI::Menu -(via PCB)-> cgi_execute_cgi_menu() -> cgi_menu(). # diff --git a/fml/lib/FML/Command.pm b/fml/lib/FML/Command.pm index 23945daa..bf6c6d0a 100644 --- a/fml/lib/FML/Command.pm +++ b/fml/lib/FML/Command.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Command.pm,v 1.50 2005/12/18 11:37:48 fukachan Exp $ +# $FML: Command.pm,v 1.51 2005/12/18 12:26:30 fukachan Exp $ # # XXX @@ -30,7 +30,7 @@ FML::Command - fml command dispatcher. use FML::Command; my $obj = new FML::Command; - $obj->rewrite_prompt($curproc, $command_args, \$orig_command); + $obj->rewrite_prompt($curproc, $command_context, \$orig_command); =head1 DESCRIPTION @@ -69,11 +69,11 @@ sub new sub DESTROY { ;} -=head2 set_mode($curproc, $command_args) +=head2 set_mode($curproc, $command_context) set the current mode, either of "admin" or "user". -=head2 get_mode($curproc, $command_args) +=head2 get_mode($curproc, $command_context) return the current mode, either of "admin" or "user". @@ -82,50 +82,38 @@ return the current mode, either of "admin" or "user". # Descriptions: set the current mode, either of "admin" or "user". # set 'user' mode if invalid mode specified. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) STR($mode) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) STR($mode) # Side Effects: none # Return Value: STR sub set_mode { - my ($self, $curproc, $command_args, $mode) = @_; + my ($self, $curproc, $command_context, $mode) = @_; # always 'user' if invalid mode specified. # XXX use capital letter for module name used latter (module loading). if ($mode =~ /admin/i) { - $command_args->{'command_mode'} = 'Admin'; + $command_context->set_mode("Admin"); } else { - $command_args->{'command_mode'} = 'User'; + $command_context->set_mode("User"); } } # Descriptions: return the current mode, either of "admin" or "user". -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: STR sub get_mode { - my ($self, $curproc, $command_args) = @_; - - if (defined $command_args->{ command_mode }) { - # XXX use capital letter for module name used latter (module loading). - if ($command_args->{'command_mode'} =~ /^(Admin)$/i) { - return 'Admin'; - } - else { - return 'User'; - } - } - else { - return 'User'; - } + my ($self, $curproc, $command_context) = @_; + return $command_context->get_mode(); } =head1 METHODS -=head2 rewrite_prompt($curproc, $command_args, $rbuf) +=head2 rewrite_prompt($curproc, $command_context, $rbuf) rewrite the specified buffer $rbuf (STR_REF). $rbuf is rewritten as a result. @@ -140,21 +128,21 @@ how to rewrite by rewrite_prompt() method in it. # Descriptions: rewrite prompt buffer. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) STR_REF($rbuf) +# OBJ($curproc) OBJ($command_context) STR_REF($rbuf) # Side Effects: none # Return Value: none sub rewrite_prompt { - my ($self, $curproc, $command_args, $rbuf) = @_; + my ($self, $curproc, $command_context, $rbuf) = @_; my $command = undef; - my $comname = $command_args->{ comname }; - my $mode = $self->get_mode($curproc, $command_args); + my $comname = $command_context->get_cooked_command(); + my $mode = $self->get_mode($curproc, $command_context); my $pkg = "FML::Command::${mode}::${comname}"; eval qq{ use $pkg; \$command = new $pkg;}; unless ($@) { if ($command->can('rewrite_prompt')) { - $command->rewrite_prompt($curproc, $command_args, $rbuf); + $command->rewrite_prompt($curproc, $command_context, $rbuf); } else { $curproc->logerror("$pkg not support rewrite_prompt()") if $debug; @@ -170,7 +158,7 @@ sub rewrite_prompt -=head2 notice_cc_recipient($curproc, $command_args, $rbuf) +=head2 notice_cc_recipient($curproc, $command_context, $rbuf) return addresses to inform for the command reply. @@ -181,21 +169,21 @@ recipients by notice_cc_recipient() method in it if needed. # Descriptions: return addresses to inform. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: ARRAY_REF sub notice_cc_recipient { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $command = undef; - my $comname = $command_args->{ comname }; - my $mode = $self->get_mode($curproc, $command_args); + my $comname = $command_context->get_cooked_command(); + my $mode = $self->get_mode($curproc, $command_context); my $pkg = "FML::Command::${mode}::${comname}"; eval qq{ use $pkg; \$command = new $pkg;}; unless ($@) { if ($command->can('notice_cc_recipient')) { - return $command->notice_cc_recipient($curproc, $command_args); + return $command->notice_cc_recipient($curproc, $command_context); } } @@ -203,7 +191,7 @@ sub notice_cc_recipient } -=head2 verify_syntax($curproc, $command_args) +=head2 verify_syntax($curproc, $command_context) verify the syntax command string. return 0 if it looks insecure. @@ -212,55 +200,55 @@ return 0 if it looks insecure. # Descriptions: verify the syntax command string. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: NUM(1 or 0) sub verify_syntax { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $command = undef; - my $comname = $command_args->{ comname }; - my $mode = $self->get_mode($curproc, $command_args); + my $comname = $command_context->get_cooked_command(); + my $mode = $self->get_mode($curproc, $command_context); my $pkg = "FML::Command::${mode}::${comname}"; eval qq{ use $pkg; \$command = new $pkg;}; unless ($@) { if ($command->can('verify_syntax')) { - return $command->verify_syntax($curproc, $command_args); + return $command->verify_syntax($curproc, $command_context); } } - return $self->simple_syntax_check($curproc, $command_args); + return $self->simple_syntax_check($curproc, $command_context); } # Descriptions: simple syntax checker. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: NUM(1 or 0) sub simple_syntax_check { - my ($self, $curproc, $command_args) = @_; - my $comname = $command_args->{ comname } || ''; - my $comsubname = $command_args->{ comsubname } || ''; - my $options = $command_args->{ options } || []; + my ($self, $curproc, $command_context) = @_; + my $comname = $command_context->get_cooked_command() || ''; + my $comsubname = $command_context->get_cooked_subcommand() || ''; + my $options = $command_context->get_options() || []; # test pattern my (@test) = @$options; unshift(@test, $comsubname); unshift(@test, $comname); - $self->safe_regexp_match($curproc, $command_args, \@test); + $self->safe_regexp_match($curproc, $command_context, \@test); } # Descriptions: simple syntax check by FML::Restriction::Command. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) ARRAY_REF($testlist) +# OBJ($curproc) OBJ($command_context) ARRAY_REF($testlist) # Side Effects: none # Return Value: NUM(1 or 0) sub safe_regexp_match { - my ($self, $curproc, $command_args, $testlist) = @_; + my ($self, $curproc, $command_context, $testlist) = @_; # simple command syntax check use FML::Restriction::Command; @@ -269,7 +257,7 @@ sub safe_regexp_match return 1; } else { - my $command = $command_args->{ masked_original_command }; + my $command = $command_context->get_masked_command(); $curproc->logerror("insecure command: $command"); $curproc->reply_message_nl('command.insecure', "insecure, so ignored."); @@ -288,12 +276,12 @@ C<FML::Command::$MODE::$command>. # Descriptions: run FML::Command::MODE::COMMAND(). -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: load appropriate module. # Return Value: none sub AUTOLOAD { - my ($self, $curproc, $command_args) = @_; + my ($self, $curproc, $command_context) = @_; my $myname = $curproc->myname(); my $default_lock_channel = 'command_serialize'; @@ -302,7 +290,7 @@ sub AUTOLOAD # user mode by default # XXX IMPORTANT: user mode if the given mode is invalid. - my $mode = $self->get_mode($curproc, $command_args); + my $mode = $self->get_mode($curproc, $command_context); my $comname = $AUTOLOAD; $comname =~ s/.*:://; @@ -318,18 +306,14 @@ sub AUTOLOAD # resource limit check. if ($command->can('check_limit')) { - my $n = $command->check_limit($curproc, $command_args); + my $n = $command->check_limit($curproc, $command_context); if ($n) { croak("exceed limit");} } # this command needs lock (currently giant lock) ? if ($command->can('need_lock')) { $need_lock = $command->need_lock($mode); - - # override lock() - if (defined $command_args->{ override_need_no_lock }) { - $need_lock = 0 if $command_args->{ override_need_no_lock }; - } + $need_lock = 0 unless $command_context->is_need_lock(); } else { $curproc->logerror("${pkg} has no need_lock method"); @@ -348,7 +332,7 @@ sub AUTOLOAD if ($command->can('process')) { $curproc->logdebug("$pkg lock") if $need_lock; $curproc->lock($lock_channel) if $need_lock; - $command->process($curproc, $command_args); + $command->process($curproc, $command_context); $curproc->logdebug("$pkg unlock") if $need_lock; $curproc->unlock($lock_channel) if $need_lock; } diff --git a/fml/lib/FML/Command/Admin/addadmin.pm b/fml/lib/FML/Command/Admin/addadmin.pm index 2fed81d6..f6d4da1c 100644 --- a/fml/lib/FML/Command/Admin/addadmin.pm +++ b/fml/lib/FML/Command/Admin/addadmin.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: addadmin.pm,v 1.22 2005/08/17 12:08:42 fukachan Exp $ +# $FML: addadmin.pm,v 1.23 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::addadmin; @@ -82,7 +82,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/addmember.pm b/fml/lib/FML/Command/Admin/addmember.pm index 08bc37f8..74e6d88d 100644 --- a/fml/lib/FML/Command/Admin/addmember.pm +++ b/fml/lib/FML/Command/Admin/addmember.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: addmember.pm,v 1.6 2005/11/30 23:30:38 fukachan Exp $ +# $FML: addmember.pm,v 1.7 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::addmember; @@ -83,7 +83,7 @@ sub process my $config = $curproc->config(); my $cred = $curproc->credential(); my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/addmoderator.pm b/fml/lib/FML/Command/Admin/addmoderator.pm index 9cc8bbda..9bc7db5f 100644 --- a/fml/lib/FML/Command/Admin/addmoderator.pm +++ b/fml/lib/FML/Command/Admin/addmoderator.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: addmoderator.pm,v 1.17 2005/08/17 12:08:42 fukachan Exp $ +# $FML: addmoderator.pm,v 1.18 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::addmoderator; @@ -82,7 +82,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/addrecipient.pm b/fml/lib/FML/Command/Admin/addrecipient.pm index 9ebe0ae2..5e41a12e 100644 --- a/fml/lib/FML/Command/Admin/addrecipient.pm +++ b/fml/lib/FML/Command/Admin/addrecipient.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: addrecipient.pm,v 1.6 2005/11/30 23:30:38 fukachan Exp $ +# $FML: addrecipient.pm,v 1.7 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::addrecipient; @@ -83,7 +83,7 @@ sub process my $config = $curproc->config(); my $cred = $curproc->credential(); my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/chaddr.pm b/fml/lib/FML/Command/Admin/chaddr.pm index dfbdd04b..c410a995 100644 --- a/fml/lib/FML/Command/Admin/chaddr.pm +++ b/fml/lib/FML/Command/Admin/chaddr.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: chaddr.pm,v 1.27 2004/06/29 10:02:42 fukachan Exp $ +# $FML: chaddr.pm,v 1.28 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::chaddr; @@ -127,11 +127,11 @@ sub process my $member_map = $config->{ 'primary_member_map' }; my $recipient_map = $config->{ 'primary_recipient_map' }; - my $old_address = ''; - my $new_address = ''; - if (defined $command_context->{ command_data }) { - my $x = $command_context->{ command_data }; - ($old_address, $new_address) = split(/\s+/, $x); + my $old_address = ''; + my $new_address = ''; + my $command_data = $command_context->get_data() || ''; + if ($command_data) { + ($old_address, $new_address) = split(/\s+/, $command_data); } else { $old_address = $options->[ 0 ]; diff --git a/fml/lib/FML/Command/Admin/deladmin.pm b/fml/lib/FML/Command/Admin/deladmin.pm index 7d148efa..e4acb825 100644 --- a/fml/lib/FML/Command/Admin/deladmin.pm +++ b/fml/lib/FML/Command/Admin/deladmin.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: deladmin.pm,v 1.21 2005/08/17 12:08:43 fukachan Exp $ +# $FML: deladmin.pm,v 1.22 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::deladmin; @@ -92,7 +92,7 @@ sub process my $member_map = $config->{ 'primary_admin_member_map' }; my $recipient_map = $config->{ 'primary_admin_recipient_map' }; my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # fundamental sanity check croak("address not undefined") unless defined $address; diff --git a/fml/lib/FML/Command/Admin/delmoderator.pm b/fml/lib/FML/Command/Admin/delmoderator.pm index 65042964..663f2be4 100644 --- a/fml/lib/FML/Command/Admin/delmoderator.pm +++ b/fml/lib/FML/Command/Admin/delmoderator.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: delmoderator.pm,v 1.20 2005/08/17 12:08:42 fukachan Exp $ +# $FML: delmoderator.pm,v 1.21 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::delmoderator; @@ -82,7 +82,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options(); - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/digest.pm b/fml/lib/FML/Command/Admin/digest.pm index a22e1df2..baa61530 100644 --- a/fml/lib/FML/Command/Admin/digest.pm +++ b/fml/lib/FML/Command/Admin/digest.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: digest.pm,v 1.25 2005/11/30 23:30:38 fukachan Exp $ +# $FML: digest.pm,v 1.26 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::digest; @@ -101,7 +101,7 @@ sub process my $digest_recipient_maps = $config->get_as_array_ref('digest_recipient_maps'); - my $address = $command_context->{ command_data } || $options->[ 0 ] || undef; + my $address = $command_context->get_data() || $options->[ 0 ] || undef; my $mode = $options->[ 1 ] || ''; # fundamental check diff --git a/fml/lib/FML/Command/Admin/digestoff.pm b/fml/lib/FML/Command/Admin/digestoff.pm index 2879ff70..73d4ecc9 100644 --- a/fml/lib/FML/Command/Admin/digestoff.pm +++ b/fml/lib/FML/Command/Admin/digestoff.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: digestoff.pm,v 1.12 2004/06/30 03:05:13 fukachan Exp $ +# $FML: digestoff.pm,v 1.13 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::digestoff; @@ -83,7 +83,7 @@ sub process { my ($self, $curproc, $command_context) = @_; my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ] || undef; + my $address = $command_context->get_data() || $options->[ 0 ] || undef; # mode off $options->[ 1 ] = "off"; diff --git a/fml/lib/FML/Command/Admin/digeston.pm b/fml/lib/FML/Command/Admin/digeston.pm index df5b3a8b..01816e1b 100644 --- a/fml/lib/FML/Command/Admin/digeston.pm +++ b/fml/lib/FML/Command/Admin/digeston.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: digeston.pm,v 1.12 2004/06/30 03:05:13 fukachan Exp $ +# $FML: digeston.pm,v 1.13 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::digeston; @@ -83,7 +83,7 @@ sub process { my ($self, $curproc, $command_context) = @_; my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ] || undef; + my $address = $command_context->get_data() || $options->[ 0 ] || undef; # mode on $options->[ 1 ] = "on"; diff --git a/fml/lib/FML/Command/Admin/get.pm b/fml/lib/FML/Command/Admin/get.pm index 7a01136d..50e2fcb7 100644 --- a/fml/lib/FML/Command/Admin/get.pm +++ b/fml/lib/FML/Command/Admin/get.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: get.pm,v 1.28 2005/08/17 12:08:43 fukachan Exp $ +# $FML: get.pm,v 1.29 2006/03/04 13:48:28 fukachan Exp $ # package FML::Command::Admin::get; @@ -63,7 +63,6 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $ml_home_dir = $config->{ ml_home_dir }; - my $command = $command_context->{ command }; my $options = $command_context->get_options(); my $recipient = ''; diff --git a/fml/lib/FML/Command/Admin/moderate.pm b/fml/lib/FML/Command/Admin/moderate.pm index 9543ee3e..d9e24232 100644 --- a/fml/lib/FML/Command/Admin/moderate.pm +++ b/fml/lib/FML/Command/Admin/moderate.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: moderate.pm,v 1.1 2005/12/18 12:03:17 fukachan Exp $ +# $FML: moderate.pm,v 1.2 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::moderate; @@ -76,7 +76,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; my $confirm_id = $command_context->{ _confirm_id } || undef; use FML::Confirm; diff --git a/fml/lib/FML/Command/Admin/newdomain.pm b/fml/lib/FML/Command/Admin/newdomain.pm index 2327a776..e242199c 100644 --- a/fml/lib/FML/Command/Admin/newdomain.pm +++ b/fml/lib/FML/Command/Admin/newdomain.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: newdomain.pm,v 1.8 2004/07/23 13:16:35 fukachan Exp $ +# $FML: newdomain.pm,v 1.9 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::newdomain; @@ -55,7 +55,7 @@ sub need_lock { 0;} sub process { my ($self, $curproc, $command_context) = @_; - my $canon_argv = $command_context->{ canon_argv }; + my $canon_argv = $command_context->get_canon_argv(); my $domain = $canon_argv->{ ml_name }; my $prefix = $canon_argv->{ options }->[ 0 ]; my $error = ''; diff --git a/fml/lib/FML/Command/Admin/newml.pm b/fml/lib/FML/Command/Admin/newml.pm index 78e4877a..c517256d 100644 --- a/fml/lib/FML/Command/Admin/newml.pm +++ b/fml/lib/FML/Command/Admin/newml.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: newml.pm,v 1.82 2006/02/04 08:10:08 fukachan Exp $ +# $FML: newml.pm,v 1.83 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::newml; @@ -68,8 +68,8 @@ sub process my ($self, $curproc, $command_context) = @_; my $options = $curproc->command_line_options(); my $config = $curproc->config(); - my $ml_name = $command_context->{ ml_name }; - my $ml_domain = $command_context->{ ml_domain }; + my $ml_name = $command_context->get_ml_name(); + my $ml_domain = $command_context->get_ml_domain(); my $ml_home_prefix = $curproc->ml_home_prefix($ml_domain); my $ml_home_dir = $curproc->ml_home_dir($ml_name, $ml_domain); my $owner = $config->{ newml_command_ml_admin_default_address }|| diff --git a/fml/lib/FML/Command/Admin/off.pm b/fml/lib/FML/Command/Admin/off.pm index 7cacf9b1..05c6418b 100644 --- a/fml/lib/FML/Command/Admin/off.pm +++ b/fml/lib/FML/Command/Admin/off.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: off.pm,v 1.24 2005/11/30 23:30:38 fukachan Exp $ +# $FML: off.pm,v 1.25 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::off; @@ -83,7 +83,7 @@ sub process my $config = $curproc->config(); my $cred = $curproc->credential(); my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/on.pm b/fml/lib/FML/Command/Admin/on.pm index eeed767a..6fa758b0 100644 --- a/fml/lib/FML/Command/Admin/on.pm +++ b/fml/lib/FML/Command/Admin/on.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: on.pm,v 1.24 2005/11/30 23:30:38 fukachan Exp $ +# $FML: on.pm,v 1.25 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::on; @@ -83,7 +83,7 @@ sub process my $config = $curproc->config(); my $cred = $curproc->credential(); my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ] || ''; + my $address = $command_context->get_data() || $options->[ 0 ] || ''; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/rmdomain.pm b/fml/lib/FML/Command/Admin/rmdomain.pm index 76350eef..a6f17809 100644 --- a/fml/lib/FML/Command/Admin/rmdomain.pm +++ b/fml/lib/FML/Command/Admin/rmdomain.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: rmdomain.pm,v 1.7 2004/07/26 01:10:54 fukachan Exp $ +# $FML: rmdomain.pm,v 1.8 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::rmdomain; @@ -55,7 +55,7 @@ sub need_lock { 0;} sub process { my ($self, $curproc, $command_context) = @_; - my $canon_argv = $command_context->{ canon_argv }; + my $canon_argv = $command_context->get_canon_argv(); my $domain = $canon_argv->{ ml_name }; if ($domain) { diff --git a/fml/lib/FML/Command/Admin/rmml.pm b/fml/lib/FML/Command/Admin/rmml.pm index 7c1fb13d..855840a3 100644 --- a/fml/lib/FML/Command/Admin/rmml.pm +++ b/fml/lib/FML/Command/Admin/rmml.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: rmml.pm,v 1.29 2006/02/15 13:44:03 fukachan Exp $ +# $FML: rmml.pm,v 1.30 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::rmml; @@ -68,8 +68,8 @@ sub process my ($self, $curproc, $command_context) = @_; my $options = $curproc->command_line_options(); my $config = $curproc->config(); - my $ml_name = $command_context->{ ml_name }; - my $ml_domain = $command_context->{ ml_domain }; + my $ml_name = $command_context->get_ml_name(); + my $ml_domain = $command_context->get_ml_domain(); my $ml_home_prefix = $curproc->ml_home_prefix($ml_domain); my $ml_home_dir = $curproc->ml_home_dir($ml_name, $ml_domain); my $params = { diff --git a/fml/lib/FML/Command/Admin/subscribe.pm b/fml/lib/FML/Command/Admin/subscribe.pm index 51ecd1a6..2583ea15 100644 --- a/fml/lib/FML/Command/Admin/subscribe.pm +++ b/fml/lib/FML/Command/Admin/subscribe.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: subscribe.pm,v 1.34 2005/08/17 12:08:44 fukachan Exp $ +# $FML: subscribe.pm,v 1.35 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::subscribe; @@ -84,7 +84,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Admin/unsubscribe.pm b/fml/lib/FML/Command/Admin/unsubscribe.pm index 134f406a..7a9afd91 100644 --- a/fml/lib/FML/Command/Admin/unsubscribe.pm +++ b/fml/lib/FML/Command/Admin/unsubscribe.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: unsubscribe.pm,v 1.35 2005/08/17 12:08:44 fukachan Exp $ +# $FML: unsubscribe.pm,v 1.36 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::Admin::unsubscribe; @@ -84,7 +84,7 @@ sub process my ($self, $curproc, $command_context) = @_; my $config = $curproc->config(); my $options = $command_context->get_options() || []; - my $address = $command_context->{ command_data } || $options->[ 0 ]; + my $address = $command_context->get_data() || $options->[ 0 ]; # XXX We should always add/rewrite only $primary_*_map maps via # XXX command mail, CUI and GUI. diff --git a/fml/lib/FML/Command/Auth.pm b/fml/lib/FML/Command/Auth.pm index f0182730..733b902c 100644 --- a/fml/lib/FML/Command/Auth.pm +++ b/fml/lib/FML/Command/Auth.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Auth.pm,v 1.40 2005/05/26 09:46:01 fukachan Exp $ +# $FML: Auth.pm,v 1.41 2005/11/30 23:30:38 fukachan Exp $ # package FML::Command::Auth; @@ -226,7 +226,7 @@ sub check_admin_member_password } -=head2 change_password($curproc, $command_args, $up_args) +=head2 change_password($curproc, $command_context, $up_args) $up_args = { maplist => $maps, @@ -239,12 +239,12 @@ sub check_admin_member_password # Descriptions: change password. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($up_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($up_args) # Side Effects: admin password modified. # Return Value: NUM(1 if success, 0 if fail) sub change_password { - my ($self, $curproc, $command_args, $up_args) = @_; + my ($self, $curproc, $command_context, $up_args) = @_; my $cred = $curproc->credential(); my $map = $up_args->{ map }; my $address = $up_args->{ address }; diff --git a/fml/lib/FML/Command/DirUtils.pm b/fml/lib/FML/Command/DirUtils.pm index 96adbbb2..59ebd78d 100644 --- a/fml/lib/FML/Command/DirUtils.pm +++ b/fml/lib/FML/Command/DirUtils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: DirUtils.pm,v 1.20 2004/07/23 15:59:03 fukachan Exp $ +# $FML: DirUtils.pm,v 1.21 2005/05/26 09:55:36 fukachan Exp $ # package FML::Command::DirUtils; @@ -52,12 +52,12 @@ sub new # Descriptions: show the result by executing "ls". # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($du_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($du_args) # Side Effects: none # Return Value: none sub dir { - my ($self, $curproc, $command_args, $du_args) = @_; + my ($self, $curproc, $command_context, $du_args) = @_; my $config = $curproc->config(); my $path_ls = $config->{ path_ls }; my $argv = $du_args->{ argv }; @@ -65,7 +65,7 @@ sub dir my $rm_args = {}; # inherit reply_message information. - my $recipient = $command_args->{ recipient } || ''; + my $recipient = $command_context->{ recipient } || ''; if ($recipient) { $rm_args->{ recipient } = $recipient;} # option: permit "ls [-A-Za-z]" syntax diff --git a/fml/lib/FML/Command/FileUtils.pm b/fml/lib/FML/Command/FileUtils.pm index ffae0c51..b06150c1 100644 --- a/fml/lib/FML/Command/FileUtils.pm +++ b/fml/lib/FML/Command/FileUtils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: FileUtils.pm,v 1.17 2004/04/23 04:10:30 fukachan Exp $ +# $FML: FileUtils.pm,v 1.18 2004/07/23 13:16:34 fukachan Exp $ # package FML::Command::FileUtils; @@ -47,11 +47,11 @@ sub new } -=head2 delete($curproc, $command_args, $du_aregs) +=head2 delete($curproc, $command_context, $du_aregs) same as remove() below. -=head2 remove($curproc, $command_args, $du_aregs) +=head2 remove($curproc, $command_context, $du_aregs) remove files specified in $du_args->{ options } if the file exsits and the file name matches safe file regexp defined @@ -73,12 +73,12 @@ sub delete # Descriptions: remove files. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($du_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($du_args) # Side Effects: none # Return Value: none sub remove { - my ($self, $curproc, $command_args, $du_args) = @_; + my ($self, $curproc, $command_context, $du_args) = @_; my $config = $curproc->config(); my $argv = $du_args->{ options }; my $is_error = 0; diff --git a/fml/lib/FML/Command/Message.pm b/fml/lib/FML/Command/Message.pm index 32bff683..174a508e 100644 --- a/fml/lib/FML/Command/Message.pm +++ b/fml/lib/FML/Command/Message.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Message.pm,v 1.1 2006/01/07 14:43:25 fukachan Exp $ +# $FML: Message.pm,v 1.2 2006/01/09 14:00:53 fukachan Exp $ # package FML::Command::Message; @@ -42,7 +42,7 @@ sub new } -=head2 send_confirmation($curproc, $command_args, $confirm, $sc_args) +=head2 send_confirmation($curproc, $command_context, $confirm, $sc_args) send back confirmation message. @@ -57,13 +57,13 @@ send back confirmation message. # Descriptions: send back confirmation message. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # OBJ($confirm) HASH_REF($sc_args) # Side Effects: messages sent. # Return Value: none sub send_confirmation { - my ($self, $curproc, $command_args, $confirm, $sc_args) = @_; + my ($self, $curproc, $command_context, $confirm, $sc_args) = @_; my $config = $curproc->config(); my $id = $confirm->assign_id; my $command = $sc_args->{ command } || ""; diff --git a/fml/lib/FML/Command/SendFile.pm b/fml/lib/FML/Command/SendFile.pm index 532b737d..5b25f06f 100644 --- a/fml/lib/FML/Command/SendFile.pm +++ b/fml/lib/FML/Command/SendFile.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: SendFile.pm,v 1.45 2005/08/11 04:11:27 fukachan Exp $ +# $FML: SendFile.pm,v 1.46 2005/08/17 10:33:17 fukachan Exp $ # package FML::Command::SendFile; @@ -27,8 +27,8 @@ L<FML::Command::Admin::get> on the usage detail. sub process { - my ($self, $curproc, $command_args) = @_; - $self->send_article($curproc, $command_args); + my ($self, $curproc, $command_context) = @_; + $self->send_article($curproc, $command_context); } =head1 DESCRIPTION @@ -38,7 +38,7 @@ and file(s) in C<$ml_home_dir>. =head1 METHODS -=head2 send_article($curproc, $command_args) +=head2 send_article($curproc, $command_context) send back articles where C<article> is a file named as /^\d+$/ in the ml spool $spool_dir. This is used in C<FML::Command::User> and @@ -47,14 +47,14 @@ C<FML::Command::Admin> modules. =cut -# Descriptions: return the number of files specified in $command_args. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Descriptions: return the number of files specified in $command_context. +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: NUM sub num_files_in_send_article_args { - my ($self, $curproc, $command_args) = @_; - my $command = $command_args->{ command }; + my ($self, $curproc, $command_context) = @_; + my $command = $command_context->get_clean_command(); my $count = 0; # command buffer = get 1 @@ -74,14 +74,14 @@ sub num_files_in_send_article_args # Descriptions: send back articles. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub send_article { - my ($self, $curproc, $command_args) = @_; - my $command = $command_args->{ command }; - my $recipient = $command_args->{ _recipient } || ''; + my ($self, $curproc, $command_context) = @_; + my $command = $command_context->get_clean_command(); + my $recipient = $command_context->{ _recipient } || ''; my $config = $curproc->config(); my $ml_name = $config->{ ml_name }; my $spool_dir = $config->{ spool_dir }; @@ -160,24 +160,24 @@ sub _get_valid_article_list } -=head2 send_file($curproc, $command_args) +=head2 send_file($curproc, $command_context) -send back file specified as C<$command_args->{ _filepath_to_send }>. +send back file specified as C<$command_context->{ _filepath_to_send }>. =cut # Descriptions: send arbitrary file in $ml_home_dir. # XXX we permit arbitrary file for admin to get. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub send_file { - my ($self, $curproc, $command_args) = @_; - my $filename = $command_args->{ _filename_to_send }; - my $filepath = $command_args->{ _filepath_to_send }; - my $recipient = $command_args->{ _recipient } || ''; + my ($self, $curproc, $command_context) = @_; + my $filename = $command_context->{ _filename_to_send }; + my $filepath = $command_context->{ _filepath_to_send }; + my $recipient = $command_context->{ _recipient } || ''; my $config = $curproc->config(); # XXX langinfo_get_charset() take Accpet-Language: header field into account. @@ -212,7 +212,7 @@ sub send_file } -=head2 send_user_xxx_message($curproc, $command_args, $type) +=head2 send_user_xxx_message($curproc, $command_context, $type) Send back a help file if "help" is found in $ml_home_dir (e.g. /var/spool/ml/elena) for backward compatibility. @@ -223,12 +223,12 @@ Sebd back the default help message if not found. # Descriptions: send back file file in $ml_home_dir if found. # return the default message if not found. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) STR($type) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) STR($type) # Side Effects: put the message into the mail queue # Return Value: none sub send_user_xxx_message { - my ($self, $curproc, $command_args, $type) = @_; + my ($self, $curproc, $command_context, $type) = @_; my $config = $curproc->config(); # XXX-TODO: care for non Japanese @@ -236,9 +236,9 @@ sub send_user_xxx_message # if "help" is found in $ml_home_dir (e.g. /var/spool/ml/elena), # send it. if (-f $config->{ "${type}_file" }) { - $command_args->{ _filepath_to_send } = $config->{ "${type}_file" }; - $command_args->{ _filename_to_send } = $type; - $self->send_file($curproc, $command_args); + $command_context->{ _filepath_to_send } = $config->{ "${type}_file" }; + $command_context->{ _filename_to_send } = $type; + $self->send_file($curproc, $command_context); } # if "help" is not found, use the default help message. else { diff --git a/fml/lib/FML/Command/Syntax.pm b/fml/lib/FML/Command/Syntax.pm index 97d2eb4c..bcd048b0 100644 --- a/fml/lib/FML/Command/Syntax.pm +++ b/fml/lib/FML/Command/Syntax.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Syntax.pm,v 1.1 2004/04/28 04:10:35 fukachan Exp $ +# $FML: Syntax.pm,v 1.2 2004/06/26 11:34:34 fukachan Exp $ # package FML::Command::Syntax; @@ -22,7 +22,7 @@ FML::Command::Syntax - common command syntax checker. =head1 METHODS -=head2 check_syntax_address_handler($curproc, $command_args) +=head2 check_syntax_address_handler($curproc, $command_context) verify the syntax command string. return 0 if it looks insecure. @@ -31,15 +31,15 @@ return 0 if it looks insecure. # Descriptions: verify the syntax command string. -# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: NUM(1 or 0) sub check_syntax_address_handler { - my ($self, $curproc, $command_args) = @_; - my $comname = $command_args->{ comname } || ''; - my $comsubname = $command_args->{ comsubname } || ''; - my $options = $command_args->{ options } || []; + my ($self, $curproc, $command_context) = @_; + my $comname = $command_context->get_cooked_command() || ''; + my $comsubname = $command_context->get_cooked_subcommand() || ''; + my $options = $command_context->get_options() || []; my (@test) = ($comname); my $ok = 0; @@ -64,7 +64,7 @@ sub check_syntax_address_handler # 2. check other comonents use FML::Command; my $dispatch = new FML::Command; - if ($dispatch->safe_regexp_match($curproc, $command_args, \@test)) { + if ($dispatch->safe_regexp_match($curproc, $command_context, \@test)) { $ok++; } else { diff --git a/fml/lib/FML/Command/User/admin.pm b/fml/lib/FML/Command/User/admin.pm index 56b77bdf..cd171b27 100644 --- a/fml/lib/FML/Command/User/admin.pm +++ b/fml/lib/FML/Command/User/admin.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: admin.pm,v 1.15 2006/03/04 12:56:58 fukachan Exp $ +# $FML: admin.pm,v 1.16 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::admin; @@ -136,7 +136,7 @@ sub process else { my $class = $command_context->get_cooked_subcommand() || ''; my $c = "admin $class ..."; - my $masked_command = $command_context->{ masked_original_command } || $c; + my $masked_command = $command_context->get_masked_command() || $c; $curproc->logerror("admin: not auth, cannot run \"$masked_command\""); $curproc->reply_message_nl("command.admin_auth_fail", "not authenticated."); @@ -285,7 +285,7 @@ sub _apply_new_admin_command_mail_restrictions sub _execute_admin_command { my ($self, $curproc, $command_context, $class) = @_; - my $args = $self->_prepare_command_args($curproc, $command_context); + my $args = $self->_prepare_command_context($curproc, $command_context); use FML::Command; my $dispatch = new FML::Command; @@ -297,7 +297,7 @@ sub _execute_admin_command # Arguments: OBJ($self) OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none -sub _prepare_command_args +sub _prepare_command_context { my ($self, $curproc, $command_context) = @_; diff --git a/fml/lib/FML/Command/User/chaddr.pm b/fml/lib/FML/Command/User/chaddr.pm index 895703d4..01d19314 100644 --- a/fml/lib/FML/Command/User/chaddr.pm +++ b/fml/lib/FML/Command/User/chaddr.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: chaddr.pm,v 1.37 2006/01/09 14:00:54 fukachan Exp $ +# $FML: chaddr.pm,v 1.38 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::chaddr; @@ -133,7 +133,7 @@ sub process my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; my $comname = $command_context->get_cooked_command(); - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $sender = $cred->sender(); # cheap sanity checks @@ -146,7 +146,7 @@ sub process # addresses we check and send back confirmation messages to my $optargs = {}; - my $x = $command_context->{ command }; + my $x = $command_context->get_clean_command(); $x =~ s/^.*$comname\s+//; my ($old_addr, $new_addr) = split(/\s+/, $x); $optargs->{ recipient } = [ $sender, $old_addr, $new_addr ]; diff --git a/fml/lib/FML/Command/User/confirm.pm b/fml/lib/FML/Command/User/confirm.pm index 420cf124..96e6b2aa 100644 --- a/fml/lib/FML/Command/User/confirm.pm +++ b/fml/lib/FML/Command/User/confirm.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: confirm.pm,v 1.38 2006/01/09 14:00:54 fukachan Exp $ +# $FML: confirm.pm,v 1.39 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::confirm; @@ -95,7 +95,7 @@ sub process my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; my $expire_limit = $config->{ confirm_expire_limit } || 14*24*3600; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); # XXX-TODO: sanity @@ -215,9 +215,9 @@ sub _switch_command $class eq 'on' || $class eq 'off' || $class eq 'moderate') { - $command_context->{ command_data } = $address; - $command_context->{ command_mode } = 'Admin'; - $command_context->{ override_need_no_lock } = 1; # already locked + $command_context->set_data($address); + $command_context->set_mode("Admin"); + $command_context->set_need_lock("no"); $obj->$class($curproc, $command_context); } else { diff --git a/fml/lib/FML/Command/User/digest.pm b/fml/lib/FML/Command/User/digest.pm index 584b4c4c..5cffdde7 100644 --- a/fml/lib/FML/Command/User/digest.pm +++ b/fml/lib/FML/Command/User/digest.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: digest.pm,v 1.17 2005/12/16 13:15:23 fukachan Exp $ +# $FML: digest.pm,v 1.18 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::digest; @@ -81,7 +81,7 @@ sub process my $recipient_map = $config->{ primary_recipient_map }; my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $address = $cred->sender(); my $mode = ''; @@ -107,9 +107,8 @@ sub process $curproc->log("digest $mode"); # emulate options ARRAY_REF. - $command_context->{ command_data } = $address; - $command_context->get_options()->[0] = $address; - $command_context->get_options()->[1] = $mode; + $command_context->set_data($address); + $command_context->set_options( [ $address, $mode ] ); # XXX-TODO: direct call of Admin::digest is correct? # XXX-TODO: confirmation ? diff --git a/fml/lib/FML/Command/User/off.pm b/fml/lib/FML/Command/User/off.pm index f45753f2..208e4525 100644 --- a/fml/lib/FML/Command/User/off.pm +++ b/fml/lib/FML/Command/User/off.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: off.pm,v 1.20 2005/11/30 23:34:45 fukachan Exp $ +# $FML: off.pm,v 1.21 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::off; @@ -83,7 +83,7 @@ sub process my $recipient_map = $config->{ primary_recipient_map }; my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $address = $cred->sender(); # cheap sanity checks diff --git a/fml/lib/FML/Command/User/on.pm b/fml/lib/FML/Command/User/on.pm index 2e9df071..79d3d456 100644 --- a/fml/lib/FML/Command/User/on.pm +++ b/fml/lib/FML/Command/User/on.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: on.pm,v 1.20 2005/11/30 23:34:45 fukachan Exp $ +# $FML: on.pm,v 1.21 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::on; @@ -83,7 +83,7 @@ sub process my $recipient_map = $config->{ primary_recipient_map }; my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $address = $cred->sender(); # fundamental check diff --git a/fml/lib/FML/Command/User/subscribe.pm b/fml/lib/FML/Command/User/subscribe.pm index f663010b..e69b781f 100644 --- a/fml/lib/FML/Command/User/subscribe.pm +++ b/fml/lib/FML/Command/User/subscribe.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: subscribe.pm,v 1.36 2006/01/08 03:06:59 fukachan Exp $ +# $FML: subscribe.pm,v 1.37 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::subscribe; @@ -83,7 +83,7 @@ sub process my $recipient_map = $config->{ primary_recipient_map }; my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $options = $command_context->get_options(); my $cui_options = $curproc->command_line_cui_specific_options() || {}; my $address = $cui_options->{ 'send-to' } || $cred->sender(); diff --git a/fml/lib/FML/Command/User/unsubscribe.pm b/fml/lib/FML/Command/User/unsubscribe.pm index 87e1a045..bd8cf794 100644 --- a/fml/lib/FML/Command/User/unsubscribe.pm +++ b/fml/lib/FML/Command/User/unsubscribe.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: unsubscribe.pm,v 1.37 2006/01/08 03:06:59 fukachan Exp $ +# $FML: unsubscribe.pm,v 1.38 2006/03/04 13:48:29 fukachan Exp $ # package FML::Command::User::unsubscribe; @@ -82,7 +82,7 @@ sub process my $recipient_map = $config->{ primary_recipient_map }; my $cache_dir = $config->{ db_dir }; my $keyword = $config->{ confirm_command_prefix }; - my $command = $command_context->{ command }; + my $command = $command_context->get_clean_command(); my $options = $command_context->get_options(); my $cui_options = $curproc->command_line_cui_specific_options() || {}; my $address = $cui_options->{ 'send-to' } || $cred->sender(); diff --git a/fml/lib/FML/Context/Command.pm b/fml/lib/FML/Context/Command.pm index 82dcc7b8..bb5a59cc 100644 --- a/fml/lib/FML/Context/Command.pm +++ b/fml/lib/FML/Context/Command.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: @template.pm,v 1.10 2006/01/07 13:16:41 fukachan Exp $ +# $FML: Command.pm,v 1.1 2006/03/04 12:56:58 fukachan Exp $ # package FML::Context::Command; @@ -38,12 +38,17 @@ sub new my $me = { _curproc => $curproc }; # save original string, set the command mode be "user" by default. - $me->{ command_mode } = "User"; + set_mode($me, "User"); return bless $me, $type; } +=head1 COMMAND INFO + +=cut + + # Descriptions: save original command string. # Arguments: OBJ($self) STR($command) # Side Effects: update $self. @@ -67,7 +72,7 @@ sub get_command } -# Descriptions: save cooked (cleaned) command string. +# Descriptions: save cooked (cleaned) primary command name. # Arguments: OBJ($self) STR($command) # Side Effects: update $self. # Return Value: none @@ -78,7 +83,7 @@ sub set_cooked_command } -# Descriptions: return cooked (cleaned) command string. +# Descriptions: return cooked (cleaned) primary command name. # Arguments: OBJ($self) # Side Effects: none # Return Value: STR @@ -89,7 +94,7 @@ sub get_cooked_command } -# Descriptions: save cooked (cleaned) sub command string. +# Descriptions: save cooked (cleaned) sub command name. # Arguments: OBJ($self) STR($command) # Side Effects: update $self. # Return Value: none @@ -100,7 +105,7 @@ sub set_cooked_subcommand } -# Descriptions: return cooked (cleaned) sub command string. +# Descriptions: return cooked (cleaned) sub command name. # Arguments: OBJ($self) # Side Effects: none # Return Value: STR @@ -111,6 +116,50 @@ sub get_cooked_subcommand } +# Descriptions: save cleaned command string. +# Arguments: OBJ($self) STR($command) +# Side Effects: update $self. +# Return Value: none +sub set_clean_command +{ + my ($self, $command) = @_; + $self->{ command } = $command || undef; +} + + +# Descriptions: return cleaned command string. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub get_clean_command +{ + my ($self) = @_; + return( $self->{ command } || undef ); +} + + +# Descriptions: save masked command string. +# Arguments: OBJ($self) STR($command) +# Side Effects: update $self. +# Return Value: none +sub set_masked_command +{ + my ($self, $command) = @_; + $self->{ masked_original_command } = $command || undef; +} + + +# Descriptions: return masked command string. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub get_masked_command +{ + my ($self) = @_; + return( $self->{ masked_original_command } || undef ); +} + + # Descriptions: build object. # Arguments: OBJ($self) # Side Effects: set up several $self parameters. @@ -149,14 +198,17 @@ sub _build_command_context_template my ($comname, $comsubname) = $check->parse_command_buffer($clean_command); my $options = $check->parse_command_arguments($clean_command, $comname); - $self->{ command } = $clean_command; + # build context object based on the current specifid command buffer. + $self->set_clean_command($clean_command); $self->set_cooked_command($comname); $self->set_cooked_subcommand($comsubname); $self->set_options($options); - $self->{ ml_name } = $ml_name; - $self->{ ml_domain } = $ml_domain; - $self->{ argv } = $argv; + $self->set_ml_name($ml_name); + $self->set_ml_domain($ml_domain); $self->set_msg_args( {} ); + + # ? + $self->{ argv } = $argv; } @@ -176,6 +228,145 @@ sub _cleanup } +=head1 ML INFO + +=cut + + +# Descriptions: set ml_name. +# Arguments: OBJ($self) STR($value) +# Side Effects: update $self. +# Return Value: none +sub set_ml_name +{ + my ($self, $value) = @_; + $self->{ ml_name } = $value; +} + + +# Descriptions: get ml_name. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub get_ml_name +{ + my ($self) = @_; + return $self->{ ml_name }; +} + + +# Descriptions: set ml_domain. +# Arguments: OBJ($self) STR($value) +# Side Effects: update $self. +# Return Value: none +sub set_ml_domain +{ + my ($self, $value) = @_; + $self->{ ml_domain } = $value; +} + + +# Descriptions: get ml_domain. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub get_ml_domain +{ + my ($self) = @_; + return $self->{ ml_domain }; +} + + +=head1 MODE + +=cut + + +# Descriptions: set command mode. +# Arguments: OBJ($self) STR($value) +# Side Effects: update $self. +# Return Value: none +sub set_mode +{ + my ($self, $value) = @_; + $self->{ command_mode } = $value || 'User'; +} + + +# Descriptions: get command mode. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub get_mode +{ + my ($self) = @_; + my $mode = $self->{ command_mode } || "User"; + + return( $mode =~ /^admin$/i ? "Admin" : "User"); +} + + +# Descriptions: is administrator mode currently ? +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: NUM +sub is_admin_mode +{ + my ($self) = @_; + my $mode = $self->get_mode(); + + return( $mode eq "Admin" ? 1 : 0 ); +} + + +# Descriptions: is user mode currently ? +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: NUM +sub is_user_mode +{ + my ($self) = @_; + my $mode = $self->get_mode(); + + return( $mode eq "User" ? 1 : 0 ); +} + + +=head1 LOCK + +=cut + + +sub set_need_lock +{ + my ($self, $value) = @_; + $self->{ _need_lock } = $value || ''; +} + + +sub get_need_lock +{ + my ($self) = @_; + + $self->{ _need_lock } ||= "yes"; + return( $self->{ _need_lock } eq "no" ? 0 : 1 ); +} + + +sub is_need_lock +{ + my ($self) = @_; + + return $self->get_need_lock(); +} + + + +=head1 MISC + +=cut + + # Descriptions: save message system parameters (HASH_REF). # Arguments: OBJ($self) HASH_REF($value) # Side Effects: update $self. @@ -242,6 +433,72 @@ sub get_admin_options } +# Descriptions: save temporary command specific data. +# Arguments: OBJ($self) HASH_REF($value) +# Side Effects: update $self. +# Return Value: none +sub set_data +{ + my ($self, $value) = @_; + $self->{ command_data } = $value || ''; +} + + +# Descriptions: get command specific data. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: HASH_REF +sub get_data +{ + my ($self) = @_; + return( $self->{ command_data } || '' ); +} + + +# Descriptions: save argument vector. +# Arguments: OBJ($self) HASH_REF($value) +# Side Effects: update $self. +# Return Value: none +sub set_argv +{ + my ($self, $value) = @_; + $self->{ argv } = $value || {}; +} + + +# Descriptions: get argument verctor. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: HASH_REF +sub get_argv +{ + my ($self) = @_; + return( $self->{ argv } || {} ); +} + + +# Descriptions: savecanonical argument vector. +# Arguments: OBJ($self) HASH_REF($value) +# Side Effects: update $self. +# Return Value: none +sub set_canon_argv +{ + my ($self, $value) = @_; + $self->{ canon_argv } = $value || {}; +} + + +# Descriptions: getcanonical argument verctor. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: HASH_REF +sub get_canon_argv +{ + my ($self) = @_; + return( $self->{ canon_argv } || {} ); +} + + =head1 CODING STYLE See C<http://www.fml.org/software/FNF/> on fml coding style guide. diff --git a/fml/lib/FML/Error.pm b/fml/lib/FML/Error.pm index beb7014d..6c3d1239 100644 --- a/fml/lib/FML/Error.pm +++ b/fml/lib/FML/Error.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Error.pm,v 1.37 2005/11/30 23:30:39 fukachan Exp $ +# $FML: Error.pm,v 1.38 2006/02/15 13:44:03 fukachan Exp $ # package FML::Error; @@ -405,16 +405,13 @@ sub delete_address # we call FML::Command::Admin::unsubscribe not FML::User::Control # since FML::User::Control is too raw. - my $method = 'unsubscribe'; - my $command_args = { - command_mode => 'admin', - comname => $method, - command => "$method $address", - ml_name => $ml_name, - options => [ $address ], - argv => undef, - args => undef, - }; + my $method = 'unsubscribe'; + my $command_context = $curproc->command_context_init("$method $address"); + $command_context->set_mode("Admin"); + $command_context->set_cooked_command($method); + $command_context->set_clean_command("$method $address"); + $command_context->set_ml_name($ml_name); + $command_context->set_options( [ $address ] ); # here we go require FML::Command; @@ -423,7 +420,7 @@ sub delete_address if (defined $obj) { # execute command ($comname method) under eval(). eval q{ - $obj->$method($curproc, $command_args); + $obj->$method($curproc, $command_context); }; unless ($@) { ; # log nothing. diff --git a/fml/lib/FML/Fault/Address.pm b/fml/lib/FML/Fault/Address.pm index efb3f760..25d73633 100644 --- a/fml/lib/FML/Fault/Address.pm +++ b/fml/lib/FML/Fault/Address.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: @template.pm,v 1.10 2006/01/07 13:16:41 fukachan Exp $ +# $FML: Address.pm,v 1.1 2006/02/04 07:42:24 fukachan Exp $ # package FML::Fault::Address; @@ -91,11 +91,11 @@ sub subscribe $curproc->log("subscribe $addr"); - my $command_args = $curproc->command_context_init("$method $addr"); - $command_args->{ command_mode } = "Admin"; - $command_args->{ comname } = $method; - $command_args->{ command } = "$method @options"; - $command_args->{ options } = \@options; + my $command_context = $curproc->command_context_init("$method $addr"); + $command_context->set_mode("Admin"); + $command_context->set_cooked_command($method); + $command_context->set_clean_command("$method @options"); + $command_context->set_options(\@options); require FML::Command; my $obj = new FML::Command; @@ -103,7 +103,7 @@ sub subscribe if (defined $obj) { # execute command ($comname method) under eval(). eval q{ - $obj->$method($curproc, $command_args); + $obj->$method($curproc, $command_context); }; unless ($@) { ; # not show anything diff --git a/fml/lib/FML/ML/Control.pm b/fml/lib/FML/ML/Control.pm index 6fd6e6ee..988bb220 100644 --- a/fml/lib/FML/ML/Control.pm +++ b/fml/lib/FML/ML/Control.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Control.pm,v 1.12 2006/02/04 07:52:30 fukachan Exp $ +# $FML: Control.pm,v 1.13 2006/02/15 13:44:04 fukachan Exp $ # package FML::ML::Control; @@ -50,12 +50,12 @@ sub new # Descriptions: generate _ml_name_xxx in $params. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($params) +# OBJ($curproc) OBJ($command_context) HASH_REF($params) # Side Effects: update $params # Return Value: none sub adjust_params_for_virtual_domain { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my ($ml_name_admin, $ml_name_ctl, $ml_name_error, $ml_name_post,$ml_name_request); my $ml_name = $params->{ _ml_name }; @@ -100,13 +100,13 @@ sub adjust_params_for_virtual_domain # Descriptions: create $ml_home_dir if needed. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: create $ml_home_dir dirctory if needed # Return Value: none sub init_ml_home_dir { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $ml_home_dir = $config->{ ml_home_dir }; @@ -138,13 +138,13 @@ sub init_ml_home_dir # Descriptions: install config.cf, include, include-ctl et. al. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: install config.cf, include, include-ctl et. al. # Return Value: none sub install_template_files { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $mode = $self->get_mode() || 'newml'; my $template_dir = $curproc->newml_command_template_files_dir(); @@ -180,13 +180,13 @@ sub install_template_files # Descriptions: install ONLY config.cf file. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: config.cf created if needed. # Return Value: none sub install_config_cf { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $template_dir = $curproc->newml_command_template_files_dir(); my $ml_home_dir = $params->{ ml_home_dir }; @@ -205,13 +205,13 @@ sub install_config_cf # Descriptions: update alias entries. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: update aliases entry # Return Value: none sub update_aliases { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $ml_name = $config->{ ml_name }; my $ml_domain = $config->{ ml_domain }; @@ -315,13 +315,13 @@ sub is_mta_alias_maps_has_ml_entry # Descriptions: set up ~fml/public_html/ for this mailing list. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: create directories for html articles # Return Value: none sub setup_mail_archive_dir { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $dir = $config->{ html_archive_dir }; @@ -336,13 +336,13 @@ sub setup_mail_archive_dir # disable it by default. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: create directories and install cgi scripts # Return Value: none sub setup_cgi_interface { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $template_dir = $curproc->newml_command_template_files_dir(); my $config = $curproc->config(); @@ -457,13 +457,13 @@ sub _install # Descriptions: set up information for this mailing list. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: create directories # Return Value: none sub setup_listinfo { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $template_dir = $config->{ listinfo_template_dir }; my $listinfo_dir = $config->{ listinfo_dir }; @@ -501,13 +501,13 @@ sub setup_listinfo # Descriptions: set up or fix create-on-post environment. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: fix include, virtual files. # Return Value: none sub install_createonpost { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $ml_name = $curproc->ml_name(); my $ml_domain = $curproc->ml_domain(); @@ -554,13 +554,13 @@ sub install_createonpost # Descriptions: disable create-on-post environment. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: fix include, virtual files. # Return Value: none sub delete_createonpost { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $ml_name = $config->{ ml_name }; my $list = $config->get_as_array_ref('newml_command_mta_config_list'); @@ -591,13 +591,13 @@ sub delete_createonpost # Descriptions: remove $ml_home_dir and update aliases if needed. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: remove ml_home_dir, update aliases entry # Return Value: none sub delete_ml_home_dir { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $ml_name = $params->{ ml_name }; my $ml_domain = $params->{ ml_domain }; my $ml_home_prefix = $params->{ ml_home_prefix }; @@ -623,13 +623,13 @@ sub delete_ml_home_dir # Descriptions: remove aliases entry. # Arguments: OBJ($self) # OBJ($curproc) -# HASH_REF($command_args) +# OBJ($command_context) # HASH_REF($params) # Side Effects: update aliases entry # Return Value: none sub delete_aliases { - my ($self, $curproc, $command_args, $params) = @_; + my ($self, $curproc, $command_context, $params) = @_; my $config = $curproc->config(); my $ml_name = $params->{ ml_name }; my $list = $config->get_as_array_ref('newml_command_mta_config_list'); diff --git a/fml/lib/FML/Process/CGI/Kernel.pm b/fml/lib/FML/Process/CGI/Kernel.pm index c4768b1f..a25303e6 100644 --- a/fml/lib/FML/Process/CGI/Kernel.pm +++ b/fml/lib/FML/Process/CGI/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.89 2005/08/19 11:23:03 fukachan Exp $ +# $FML: Kernel.pm,v 1.90 2006/01/09 14:00:55 fukachan Exp $ # package FML::Process::CGI::Kernel; @@ -410,7 +410,7 @@ sub _drive_cgi_by_table } -=head2 cgi_execute_command($command_args) +=head2 cgi_execute_command($command_context) execute specified command given as FML::Command::* @@ -418,18 +418,18 @@ execute specified command given as FML::Command::* # Descriptions: execute FML::Command. -# Arguments: OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($curproc) OBJ($command_context) # Side Effects: load module # Return Value: none sub cgi_execute_command { - my ($curproc, $command_args) = @_; + my ($curproc, $command_context) = @_; # XXX Only FML::CGI::Skin::Base calls cgi_execute_command() now. # XXX comname are the result returned by $curproc->safe_param_command(). # XXX command_mode is hard-coded in FML::CGI::Skin::Base. - my $commode = $command_args->{ command_mode }; - my $comname = $command_args->{ comname }; + my $commode = $command_context->get_mode(); + my $comname = $command_context->get_cooked_command(); my $config = $curproc->config(); # XXX $comname is one of strings defined in the config file, @@ -451,7 +451,7 @@ sub cgi_execute_command my $obj = new FML::Command; if (defined $obj) { eval q{ - $obj->$comname($curproc, $command_args); + $obj->$comname($curproc, $command_context); }; unless ($@) { # XXX-TODO: NL @@ -632,14 +632,14 @@ sub cgi_execute_cgi_menu { my ($curproc) = @_; my $pcb = $curproc->pcb(); - my $command_args = $pcb->get('cgi', 'command_args'); + my $command_context = $pcb->get('cgi', 'command_context'); # navigation to top menu. $curproc->cgi_menu_back_to_top(); - if (defined $command_args) { + if (defined $command_context) { # XXX-TODO: who validate $comname (in FML::CGI::Skin) ? - my $comname = $command_args->{ comname }; + my $comname = $command_context->get_cooked_command(); my $cmd = "FML::Command::Admin::$comname"; my $obj = undef; eval qq{ @@ -648,7 +648,7 @@ sub cgi_execute_cgi_menu }; if (defined $obj) { - $obj->cgi_menu($curproc, $command_args); + $obj->cgi_menu($curproc, $command_context); } } else { diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm index 8607bb71..3cf25301 100644 --- a/fml/lib/FML/Process/Command.pm +++ b/fml/lib/FML/Process/Command.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001,2002,2003,2004,2005,2006 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Command.pm,v 1.116 2006/03/04 12:56:58 fukachan Exp $ +# $FML: Command.pm,v 1.117 2006/03/04 13:58:21 fukachan Exp $ # package FML::Process::Command; @@ -37,7 +37,7 @@ C<FML::Process::Command> is a command wrapper and top level dispatcher for commands. It kicks off corresponding - FML::Command->$command($curproc, $command_args) + FML::Command->$command($curproc, $command_context) for the given C<$command>. @@ -418,17 +418,17 @@ sub _command_switch # Descriptions: actually execute command via FML::Command. -# Arguments: OBJ($curproc) HASH_REF($command_args) +# Arguments: OBJ($curproc) OBJ($command_context) # Side Effects: none # Return Value: none sub _command_execute { - my ($curproc, $command_args) = @_; + my ($curproc, $command_context) = @_; my $config = $curproc->config(); my $prompt = $config->{ command_mail_reply_prompt } || '>>>'; my $cred = $curproc->credential(); my $sender = $cred->sender(); - my $msg_args = $command_args->{ msg_args } || {}; + my $msg_args = $command_context->get_msg_args() || {}; use FML::Command; my $dispatch = new FML::Command; @@ -440,13 +440,14 @@ sub _command_execute } # command dependent rewrite prompt e.g. to hide the password - my $masked_command = $command_args->{ original_command }; - $dispatch->rewrite_prompt($curproc, $command_args, \$masked_command); - $command_args->{ masked_original_command } = $masked_command; + my $masked_command = $command_context->get_command(); + $dispatch->rewrite_prompt($curproc,$command_context,\$masked_command); + $command_context->set_masked_command($masked_command); + # recipients depends on each command. The list is defined in # each command module (e.g. FML::Command::User::*) - my $cclist = $dispatch->notice_cc_recipient($curproc, $command_args); + my $cclist = $dispatch->notice_cc_recipient($curproc, $command_context); if (defined $cclist && @$cclist) { my $primary_key = join("-", sort @$cclist); # XXX unique key. $msg_args->{ recipient } = $cclist; @@ -458,7 +459,7 @@ sub _command_execute $curproc->log("command: $masked_command"); # command dependent syntax checker. - unless ($dispatch->verify_syntax($curproc, $command_args)) { + unless ($dispatch->verify_syntax($curproc, $command_context)) { $curproc->reply_message_nl('command.insecure', "stopped due to insecure syntax.", $msg_args); @@ -470,9 +471,9 @@ sub _command_execute # 1) $dispatch = FML::Command NOT FML::Command::$mode::$command # 2) $comname must be valid since $comname is one of defined # command list in $config (see _command_switch() method). - my $comname = $command_args->get_cooked_command(); + my $comname = $command_context->get_cooked_command(); eval q{ - $dispatch->$comname($curproc, $command_args); + $dispatch->$comname($curproc, $command_context); }; unless ($@) { $num_processed++; diff --git a/fml/lib/FML/Process/Configure.pm b/fml/lib/FML/Process/Configure.pm index f395bdd3..da8f50be 100644 --- a/fml/lib/FML/Process/Configure.pm +++ b/fml/lib/FML/Process/Configure.pm @@ -3,7 +3,7 @@ # Copyright (C) 2001,2002,2003,2004,2005,2006 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Configure.pm,v 1.71 2006/01/09 14:00:54 fukachan Exp $ +# $FML: Configure.pm,v 1.72 2006/02/04 07:49:56 fukachan Exp $ # package FML::Process::Configure; @@ -267,7 +267,7 @@ C<@$argv> ( $argv = $args->{ ARGV } ). C<Caution:> C<$args> is passed from parrent libexec/loader. -We construct a new struct C<$command_args> here to pass parameters +We construct a new struct C<$command_context> here to pass parameters to the child objects. C<FML::Command::$command> object takes them as arguments not pure C<$args>. It is a little mess. Pay attention. @@ -304,24 +304,27 @@ sub _makefml # XXX-TODO: command = [ $method, @options ]; ? (no, used only for message?) my $option = $curproc->command_line_options(); my $command_mode = $curproc->__get_command_mode($option); - my $command_args = { - command_mode => $command_mode, - comname => $method, - command => "$method @options", - ml_name => $ml_name, - ml_domain => $ml_domain, - options => \@options, - argv => $argv, - - # save raw argv for {new,rm}domain commands, which need - # for some programs to interprete $ml_name as ml_domain. - canon_argv => { - ml_name => $argv_ml_name, - method => $method, - options => \@options, - }, + + # save raw argv for {new,rm}domain commands, which need + # for some programs to interprete $ml_name as ml_domain. + my $canon_argv = { + ml_name => $argv_ml_name, + method => $method, + options => \@options, }; + # prepare context. + use FML::Context::Command; + my $command_context = new FML::Context::Command $curproc; + $command_context->set_mode($command_mode); + $command_context->set_cooked_command($method); + $command_context->set_clean_command("$method @options"); + $command_context->set_ml_name($ml_name); + $command_context->set_ml_domain($ml_domain); + $command_context->set_options(\@options); + $command_context->set_argv($argv); + $command_context->set_canon_argv($canon_argv); + my $eval = $config->get_hook( 'makefml_run_start_hook' ); if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } @@ -332,7 +335,7 @@ sub _makefml if (defined $obj) { # execute command ($comname method) under eval(). eval q{ - $obj->$method($curproc, $command_args); + $obj->$method($curproc, $command_context); }; unless ($@) { ; # not show anything diff --git a/fml/lib/FML/User/Control.pm b/fml/lib/FML/User/Control.pm index 0e3cac9a..4f125e0c 100644 --- a/fml/lib/FML/User/Control.pm +++ b/fml/lib/FML/User/Control.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Control.pm,v 1.20 2006/01/08 03:06:59 fukachan Exp $ +# $FML: Control.pm,v 1.21 2006/02/18 08:36:49 fukachan Exp $ # package FML::User::Control; @@ -56,12 +56,12 @@ sub new # Descriptions: add user. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($uc_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($uc_args) # Side Effects: update maps, croak() if crical error. # Return Value: none sub user_add { - my ($self, $curproc, $command_args, $uc_args) = @_; + my ($self, $curproc, $command_context, $uc_args) = @_; my $config = $curproc->config(); my $address = $uc_args->{ address }; my $maplist = $uc_args->{ maplist }; @@ -76,7 +76,7 @@ sub user_add } # pass info into reply_message(). - my $msg_args = $command_args->{ msg_args }; + my $msg_args = $command_context->get_msg_args(); $msg_args->{ _arg_address } = $address; # for convenience. @@ -161,12 +161,12 @@ sub user_add # Descriptions: remove user. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($uc_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($uc_args) # Side Effects: update maps # Return Value: none sub user_del { - my ($self, $curproc, $command_args, $uc_args) = @_; + my ($self, $curproc, $command_context, $uc_args) = @_; my $config = $curproc->config(); my $address = $uc_args->{ address }; my $maplist = $uc_args->{ maplist }; @@ -180,7 +180,7 @@ sub user_del } # pass info to reply_message() - my $msg_args = $command_args->{ msg_args }; + my $msg_args = $command_context->get_msg_args(); $msg_args->{ _arg_address } = $address; # for convenience. @@ -256,12 +256,12 @@ sub user_del # Descriptions: dispatch chaddr operation. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($uc_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($uc_args) # Side Effects: none # Return Value: none sub user_chaddr { - my ($self, $curproc, $command_args, $uc_args) = @_; + my ($self, $curproc, $command_context, $uc_args) = @_; my $cred = new FML::Credential $curproc; my $level = $cred->get_compare_level(); my $maplist = $uc_args->{ maplist }; @@ -272,7 +272,7 @@ sub user_chaddr $curproc->lock($lock_channel); for my $map (@$maplist) { - $self->_try_chaddr_in_map($curproc, $command_args, $uc_args, + $self->_try_chaddr_in_map($curproc, $command_context, $uc_args, $cred, $map); } @@ -285,13 +285,13 @@ sub user_chaddr # Descriptions: real chaddr routine. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($uc_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($uc_args) # OBJ($cred) STR($map) # Side Effects: update member list # Return Value: none sub _try_chaddr_in_map { - my ($self, $curproc, $command_args, $uc_args, $cred, $map) = @_; + my ($self, $curproc, $command_context, $uc_args, $cred, $map) = @_; my $config = $curproc->config(); my $old_address = $uc_args->{ old_address }; my $new_address = $uc_args->{ new_address }; @@ -420,18 +420,18 @@ sub _try_chaddr_in_map # Descriptions: show list. # Arguments: OBJ($self) -# OBJ($curproc) HASH_REF($command_args) HASH_REF($uc_args) +# OBJ($curproc) OBJ($command_context) HASH_REF($uc_args) # Side Effects: none # Return Value: none sub print_userlist { - my ($self, $curproc, $command_args, $uc_args) = @_; + my ($self, $curproc, $command_context, $uc_args) = @_; my $config = $curproc->config(); my $maplist = $uc_args->{ maplist } || []; my $wh = $uc_args->{ wh } || undef; my $style = $curproc->output_get_print_style() || ''; my $is_mta = $curproc->is_under_mta_process() || 0; - my $msg_args = $command_args->{ msg_args }; + my $msg_args = $command_context->get_msg_args(); $curproc->lock($lock_channel); |
