diff options
| author | fukachan <fukachan> | 2001-09-13 11:53:29 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-09-13 11:53:29 +0000 |
| commit | c3307a0e7d62812228bb45f6e24609c5f4e9c6c4 (patch) | |
| tree | dd580cf8b666dfc9b3c1f8e93025a3826a0139ae /fml | |
| parent | 85b1f018ab875341f53e6f73b654ed69ff90cb0a (diff) | |
| download | fml8-c3307a0e7d62812228bb45f6e24609c5f4e9c6c4.tar.gz fml8-c3307a0e7d62812228bb45f6e24609c5f4e9c6c4.tar.bz2 fml8-c3307a0e7d62812228bb45f6e24609c5f4e9c6c4.zip | |
new hier: makefml uses Command::Admin
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Command.pm | 37 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/bye.pm | 4 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/get.pm | 40 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/subscribe.pm | 16 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/unsubscribe.pm | 19 |
5 files changed, 81 insertions, 35 deletions
diff --git a/fml/lib/FML/Command.pm b/fml/lib/FML/Command.pm index a7d2ef4e..00ff1bad 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.5 2001/05/27 14:27:53 fukachan Exp $ +# $FML: Command.pm,v 1.6 2001/07/15 12:03:37 fukachan Exp $ # package FML::Command; @@ -21,9 +21,11 @@ FML::Command - dispacher of fml commands =head1 DESCRIPTION -C<FML::Commands> is a wrapper and dispathcer for fml commands. +C<FML::Command> is a wrapper and dispathcer for fml commands. AUTOLOAD() picks up the command request and dispatches -C<FML::Command::somoting> for the request. +C<FML::Command::User::somoting> for the request. +Also, C<FML::Command::Admin::somoting> for the admin command request. + =head1 METHODS @@ -55,27 +57,36 @@ sub DESTROY { ;} sub AUTOLOAD { my ($self, $curproc, $optargs) = @_; + my $mode = $optargs->{ 'command_mode' } =~ /admin/i ? 'Admin' : 'User'; return if $AUTOLOAD =~ /DESTROY/; - my $command = $AUTOLOAD; - $command =~ s/.*:://; - - my $pkg = "FML::Command::${command}"; + my $comname = $AUTOLOAD; + $comname =~ s/.*:://; + my $pkg = "FML::Command::${mode}::${comname}"; eval qq{ require $pkg; $pkg->import();}; unless ($@) { - if ($pkg->can($command)) { - $curproc->lock() if $self->require_lock($command); - $pkg->$command($curproc, $optargs); - $curproc->unlock() if $self->require_lock($command); + my $command = $pkg->new(); + + if ($command->can('auth')) { + $command->auth($curproc, $optargs); + } + + if ($command->can('process')) { + $curproc->lock() if $self->require_lock($comname); + $command->process($curproc, $optargs); + $curproc->unlock() if $self->require_lock($comname); + + if ($command->error()) { Log($command->error());} } else { - Log("$pkg module has no $command method"); + LogError("${pkg} has no process method"); } } else { - Log("$pkg module is not found"); + LogError("$pkg module is not found"); + LogError($@); } } diff --git a/fml/lib/FML/Command/Admin/bye.pm b/fml/lib/FML/Command/Admin/bye.pm index 09494de0..d4e7d7ce 100644 --- a/fml/lib/FML/Command/Admin/bye.pm +++ b/fml/lib/FML/Command/Admin/bye.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: bye.pm,v 1.2 2001/08/26 07:59:03 fukachan Exp $ +# $FML: bye.pm,v 1.1.1.1 2001/08/26 08:01:04 fukachan Exp $ # package FML::Command::Admin::bye; @@ -12,7 +12,7 @@ use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; -FML::Command::Utils; +use FML::Command::Utils; use FML::Command::Admin::unsubscribe; @ISA = qw(FML::Command::Admin::unsubscribe FML::Command::Utils); diff --git a/fml/lib/FML/Command/Admin/get.pm b/fml/lib/FML/Command/Admin/get.pm index 4a44ddbe..a20a9e1d 100644 --- a/fml/lib/FML/Command/Admin/get.pm +++ b/fml/lib/FML/Command/Admin/get.pm @@ -1,10 +1,10 @@ #-*- perl -*- -f# +# # Copyright (C) 2001 Ken'ichi Fukamachi # 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.2 2001/08/26 07:59:03 fukachan Exp $ +# $FML: get.pm,v 1.1.1.1 2001/08/26 08:01:04 fukachan Exp $ # package FML::Command::Admin::get; @@ -28,17 +28,41 @@ not yet implemented =head1 METHODS -=head2 C<new()> - =cut sub process { - my ($self) = @_; - my ($type) = ref($self) || $self; - my $me = {}; - return bless $me, $type; + my ($self, $curproc, $optargs) = @_; + my $options = $optargs->{ 'options' }; + my $config = $curproc->{ 'config' }; + my $spool_dir = $config->{ 'spool_dir' }; + my @options = @$options; + my $recipient = shift @options; + my @files; + + for my $id (@options) { + use File::Spec; + my $f = File::Spec->catfile($spool_dir, $id); + if (-f $f) { + $curproc->reply_message( { + type => "message/rfc822", + path => $f, + filename => $id, + disposition => "article $id", + }); + } + else { + use FML::Log qw(Log); + &Log("article $id not found"); + } + } + + $curproc->queue_in('reply_message', { + 'sender' => 'fukachan', + 'subject' => 'get result', + 'recipient' => $recipient, + }); } diff --git a/fml/lib/FML/Command/Admin/subscribe.pm b/fml/lib/FML/Command/Admin/subscribe.pm index 837854a1..f555da32 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.1.1.1 2001/08/26 08:01:04 fukachan Exp $ +# $FML: subscribe.pm,v 1.2 2001/08/26 13:09:29 fukachan Exp $ # package FML::Command::Admin::subscribe; @@ -48,20 +48,24 @@ sub process croak("\$recipient_map is not specified") unless $recipient_map; use IO::Adapter; - my $obj = new IO::Adapter $member_map; - $obj->touch(); - use FML::Credential; + use FML::Log qw(Log LogWarn LogError); for my $map ($member_map, $recipient_map) { my $cred = new FML::Credential; unless ($cred->has_address_in_map($map, $address)) { - $obj = new IO::Adapter $map; + my $obj = new IO::Adapter $map; $obj->touch(); $obj->add( $address ); + unless ($obj->error()) { + Log("added $address to map=$map"); + } + else { + LogError("fail to add $address to map=$map"); + } } else { - $self->error_set( "$address is member (map=$map)" ); + $self->error_set( "$address is already member (map=$map)" ); return undef; } } diff --git a/fml/lib/FML/Command/Admin/unsubscribe.pm b/fml/lib/FML/Command/Admin/unsubscribe.pm index 3eef88ac..85c10c72 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.2 2001/08/26 07:59:03 fukachan Exp $ +# $FML: unsubscribe.pm,v 1.1.1.1 2001/08/26 08:01:04 fukachan Exp $ # package FML::Command::Admin::unsubscribe; @@ -47,11 +47,18 @@ sub process croak("\$recipient_map is not specified") unless $recipient_map; use IO::Adapter; - my $obj = new IO::Adapter $member_map; - $obj->delete( $address ); - - $obj = new IO::Adapter $recipient_map; - $obj->delete( $address ); + use FML::Log qw(Log LogWarn LogError); + + for my $map ($member_map, $recipient_map) { + my $obj = new IO::Adapter $map; + $obj->delete( $address ); + unless ($obj->error()) { + Log("removed $address from map=$map"); + } + else { + LogError("fail to remove $address from map=$map"); + } + } } |
