UPPER CASED all the callsigns on send
[spider.git] / cmd / send.pl
1 #
2 # send a message
3 #
4 # this should handle
5 #
6 # send <call> [<call> .. ]
7 # send private <call> [<call> .. ]
8 # send private rr <call> [<call> .. ]
9 # send rr <call> [<call> .. ]
10 # send noprivate <call> [<call> .. ]
11 # send b <call> [<call> .. ]
12 # send copy <call> [<call> .. ]
13 # send copy rr <call> [<call> .. ]
14
15 # Copyright (c) Dirk Koopman G1TLH
16 #
17 # $Id$
18 #
19 my ($self, $line) = @_;
20 my @out;
21 my $loc;
22
23 #$DB::single = 1;
24
25 if ($self->state eq "prompt") {
26
27         my @f = split /\s+/, $line;
28
29         # any thing after send?
30         return (1, $self->msg('e6')) if !@f;
31   
32         $f[0] = uc $f[0];
33   
34         # first deal with copies
35         if ($f[0] eq 'C' || $f[0] eq 'CC' || $f[0] eq 'COPY') {
36                 my $i = 1;
37                 my $rr = '0';
38                 if (uc $f[$i] eq 'RR') {
39                         $rr = '1';
40                         $i++;
41                 }
42                 my $oref = DXMsg::get($f[$i]);
43                 #return (0, $self->msg('esend1', $f[$i])) if !$oref;
44                 #return (0, $self->msg('esend2')) if $i+1 >  @f;
45                 return (0, "msgno $f[$i] not found") if !$oref;
46                 return (0, "need a callsign") if $i+1 >  @f;
47       
48                 # separate copy to everyone listed
49                 for ($i++ ; $i < @f; $i++) {
50                         my $msgno = DXMsg::next_transno('Msgno');
51                         my $newsubj = "CC: " . $oref->subject;
52                         my $nref = DXMsg->alloc($msgno, 
53                                                                         uc $f[$i], 
54                                                                         $self->call,  
55                                                                         $main::systime, 
56                                                                         '1',  
57                                                                         $newsubj, 
58                                                                         $main::mycall,
59                                                                         '0',
60                                                                         $rr);
61                         my @list;
62                         my $from = $oref->from;
63                         my $to = $oref->to;
64                         my $date = cldate($oref->t);
65                         my $time = ztime($oref->t);
66                         my $buf = "Original from: $from To: $to Date: $date $time";
67                         push @list, $buf; 
68                         push @list, $oref->read_msg_body();
69                         $nref->store(\@list);
70                         $nref->add_dir();
71                         #push @out, $self->msg('sendcc', $oref->msgno, $f[$i]);
72                         push @out, "copy of msg $oref->{msgno} sent to $to";
73                 }
74                 DXMsg::queue_msg();
75                 return (1, @out);
76         }
77
78         # now deal with real message inputs 
79         # parse out send line for various possibilities
80         $loc = $self->{loc} = {};
81   
82         my $i = 0;
83         $f[0] = uc $f[0];
84         $loc->{private} = '1';
85         if ($f[0] eq 'B' || $f[0] =~ /^NOP/oi) {
86                 $loc->{private} = '0';
87                 $i += 1;
88         } elsif ($f[0] eq 'P' || $f[0] =~ /^PRI/oi) {
89                 $i += 1;
90         }
91   
92         $loc->{rrreq} = '0';
93         if (uc $f[$i] eq 'RR') {
94                 $loc->{rrreq} = '1';
95                 $i++;
96         }
97   
98         # check we have some callsigns
99         if ($i  >=  @f) {
100                 delete $self->{loc};
101                 return (1, $self->msg('e6'));
102         }
103   
104         # now save all the 'to' callsigns for later
105         my @to = map {uc $_} @f[ $i..$#f ];
106         $loc->{to} = \@to;
107
108         # find me and set the state and the function on my state variable to
109         # keep calling me for every line until I relinquish control
110         $self->func("DXMsg::do_send_stuff");
111         $self->state('send1');
112         #push @out, $self->msg('sendsubj');
113         push @out, "Enter Subject (30 characters) >";
114 }
115
116 return (1, @out);