1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#-*- perl -*-
#
# Copyright (C) 2006 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: Message.pm,v 1.3 2006/03/05 08:08:36 fukachan Exp $
#
package FML::Command::Message;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
=head1 NAME
FML::Command::Message - utility for command message handling.
=head1 SYNOPSIS
use FML::Command::Message;
my $_msg = new FML::Command::Message;
my $sc_args = {
command => "chaddr",
rm_args => $optargs,
};
$_msg->send_confirmation($curproc, $command_context, $confirm, $sc_args)
=head1 DESCRIPTION
This class provides utility function for command message handling.
=head1 METHODS
=head2 new()
constructor.
=cut
# Descriptions: constructor.
# Arguments: OBJ($self)
# Side Effects: none
# Return Value: OBJ
sub new
{
my ($self) = @_;
my ($type) = ref($self) || $self;
my $me = {};
return bless $me, $type;
}
=head2 send_confirmation($curproc, $command_context, $confirm, $sc_args)
send back confirmation message.
1. if $XXX_command_auth_type == confirmation,
1.1 send back confirmation to address (From:).
2. if $XXX_command_auth_type == manual,
2.1 notify "forwarded request to maintainer(s)." to sender.
2.2 notify request to maintainer(s).
=cut
# Descriptions: send back confirmation message.
# 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_context, $confirm, $sc_args) = @_;
my $config = $curproc->config();
my $id = $confirm->assign_id;
my $command = $sc_args->{ command } || "";
my $rm_args = $sc_args->{ rm_args } || {};
my $varname = "${command}_command_auth_type";
my $mode = $config->{ $varname } || 'confirmation';
# 1. send back confirmation to address (From:) by default.
# if XXX_command_auth_type == confirmation
# send back confirmation to $sender.
# $sender send back again the confirmation to fml8.
# fml8 do actual subscription et.al. automatically.
# So, $maintainer do nothing.
if ($mode eq 'confirmation') {
my $default_msg = "please reply and send back this message.";
$curproc->reply_message_nl('command.confirm', $default_msg, $rm_args);
$curproc->reply_message("\n$id\n", $rm_args);
}
# 2. forward request to maintainer(s) "without confirmation".
# if XXX_command_auth_type == manual
# forward the request to $maintainer.
# The maintainer do actual subscription et.al. automatically.
# So, fml8 do nothing.
elsif ($mode eq 'manual') {
my $msg = $curproc->incoming_message();
my $maintainer = $config->{ maintainer };
my $_rm_args = {
recipient => $maintainer,
_arg_command => $command,
};
my $default = "send back the following confirmation.";
# 2.1 notify "forwarded request to maintainer(s)." to sender.
$curproc->reply_message_nl('command.forward_request_to_admin',
"",
$rm_args);
# 2.2 notify request to maintainer(s).
$curproc->reply_message_nl('command.receive_request', "", $_rm_args);
$curproc->reply_message_nl('command.confirm', $default, $_rm_args);
$curproc->reply_message("\n$id\n", $_rm_args);
$curproc->reply_message($msg, $_rm_args);
}
# 3. fatal error if neither of automatic nor manual.
else {
$curproc->logerror("unknown operation mode");
croak("unknown operation mode");
}
}
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.
=head1 AUTHOR
Ken'ichi Fukamachi
=head1 COPYRIGHT
Copyright (C) 2006 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.
=head1 HISTORY
FML::Command::Message appeared in fml8 mailing list driver package.
See C<http://www.fml.org/> for more details.
=cut
1;
|