summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/command/internal.sgml
blob: a7872c48081051bfd21af50578b65e80f55b9b18 (plain)
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
<!--
   $FML: internal.sgml,v 1.4 2005/07/20 10:37:42 fukachan Exp $
   $jaFML: internal.sgml,v 1.6 2003/04/15 14:51:36 fukachan Exp $
-->

<sect1 id="fml.command.internal.change">
	<title>
	How Differ Coding Style Among &fml4; And &fml8;
	</title>

<para>
Consider localization of "help" command as an example of an fml
command, which sends back help message to the sender.
</para>

<para>
In the case of &fml4;, 
prepare myProcHelpFileSendBack() function and 
register it at %LocalProcedure hash to enable it.
<screen>
%LocalProcedure = (
                    'help',     'myProcHelpFileSendBack',
                );
</screen>
myProcHelpFileSendBack as follows:
<screen>
sub myProcHelpFileSendBack
{
    local($proc, *Fld, *e, *misc) = @_;
    my $UJA_FILE = "/some/where/help";
    &amp;SendFile($Envelope{'Addr2Reply:'}, "UJA $ML_FN", $UJA_FILE);
}
</screen>
</para>

<para>
In the case of &fml8;, the main code of help command locates at
FML::Command::User::help class. This class is called by
FML::Process::Command via AUTOLOAD of FML::Command.
</para>

<warning>
<para>
All &fml8; commands are implemented at either of FML::Command::User or
FML::Command::Admin classes. Both CUI (makefml, fml) and GUI (CGI)
uses FML::Command::Admin class. Instead command mail users both
classes according to the context.
</para>
</warning>

<para>
The real content of help command is process() method in
FML::Command::User::help class.
<screen>
sub process
{
    my ($self, $curproc, $optargs) = @_;
    my $config    = $curproc->{ config };
    my $charset   = $config->{ report_mail_charset_ja };
    my $help_file = $config->{ help_file };

    # template substitution: kanji code, $varname expansion et. al.
    my $params = {
        src         => $help_file,
        charset_out => $charset,
    };
    my $help_template = $curproc->reply_message_prepare_template( $params );

    if (-f $help_template) {
        $curproc->reply_message( {
            type        => "text/plain; charset=$charset",
            path        => $help_template,
            filename    => "help",
            disposition => "help",
        });
    }
    else {
        croak("no help file ($help_template)\n");
    }
}
</screen>
where $curproc is an object, which type is hash reference.
It corresponds to %Envelope of &fml4;.
It contains several references to objects for this process.
For exmple, variable $config is an object holding configuration variables.
</para>

<para>
All variables of &fml4; are global. 
Instead variables of &fml8; locates within configuration space
accessed via $config object.
</para>

<para>
reply_message_prepare_template() converts the message language and
expands the arguments in the message templates.
 </para>

<para>
$curproc->reply_message() inserts the specified mesage string into the
message queue of this process on memory.
</para>

<para>
The error/log messages queued in on memory are aggergated to one
message at the last of the current process. Mail::Delivery class
handles the aggregation and send it. If needed, the aggregator handles
text strings or multipart properly to build one message.
</para>

<para>
This mechanism is same as Notify() of &fml4; but the last aggregator
which handles all at the last is different.
</para>

<para>
FYI: commands such as "get" for the file manipulation uses the same
message queuing mechanism. &fml4;'s Notify() sends back
immediately. Instead &fml8;'s mechanism is queuing based always. This
&fml8; mechanism is different from &fml4;'s Notify() fundamentally.
</para>

</sect1>