X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=blobdiff_plain;f=cmd%2Fsend.pl;h=8667d0cc35edf80ae0e21ea4a088e469c9c37bfc;hp=aabf21725d5b71e935418fbf4638392ccc4cce85;hb=57b5e464bc44ae8eee23ab94c1f499f527595dc9;hpb=23d995215379c4786c2cb1d930a09c734c2472aa diff --git a/cmd/send.pl b/cmd/send.pl index aabf2172..8667d0cc 100644 --- a/cmd/send.pl +++ b/cmd/send.pl @@ -1,7 +1,112 @@ # # send a message # +# this should handle +# +# send [ .. ] +# send private [ .. ] +# send private rr [ .. ] +# send rr [ .. ] +# send noprivate [ .. ] +# send b [ .. ] +# send copy [ .. ] +# send copy rr [ .. ] +# # Copyright (c) Dirk Koopman G1TLH # # $Id$ # +my ($self, $line) = @_; +my @out; +my $loc; + +#$DB::single = 1; + +if ($self->state eq "prompt") { + + my @f = split /\s+/, $line; + + $f[0] = uc $f[0]; + + # first deal with copies + if ($f[0] eq 'C' || $f[0] eq 'CC' || $f[0] eq 'COPY') { + my $i = 1; + my $rr = '0'; + if (uc $f[$i] eq 'RR') { + $rr = '1'; + $i++; + } + my $oref = DXMsg::get($f[$i]); + #return (0, $self->msg('esend1', $f[$i])) if !$oref; + #return (0, $self->msg('esend2')) if $i+1 > @f; + return (0, "msgno $f[$i] not found") if !$oref; + return (0, "need a callsign") if $i+1 > @f; + + # separate copy to everyone listed + for ($i++ ; $i < @f; $i++) { + my $msgno = DXMsg::next_transno('Msgno'); + my $newsubj = "CC: " . $oref->subject; + my $nref = DXMsg->alloc($msgno, + uc $f[$i], + $self->call, + $main::systime, + '1', + $newsubj, + $main::mycall, $rr); + my @list; + my $from = $oref->from; + my $to = $oref->to; + my $date = cldate($oref->t); + my $time = ztime($oref->t); + my $buf = "Original from: $from To: $to Date: $date $time"; + push @list, $buf; + push @list, $oref->read_msg_body(); + $nref->store(\@list); + $nref->add_dir(); + #push @out, $self->msg('sendcc', $oref->msgno, $f[$i]); + push @out, "copy of msg $oref->{msgno} sent to $to"; + } + DXMsg::queue_msg(); + return (1, @out); + } + + # now deal with real message inputs + # parse out send line for various possibilities + $loc = $self->{loc} = {}; + + my $i = 0; + $f[0] = uc $f[0]; + $loc->{private} = '1'; + if ($f[0] eq 'B' || $f[0] =~ /^NOP/oi) { + $loc->{private} = '0'; + $i += 1; + } elsif ($f[0] eq 'P' || $f[0] =~ /^PRI/oi) { + $i += 1; + } + + $loc->{rrreq} = '0'; + if (uc $f[$i] eq 'RR') { + $loc->{rrreq} = '1'; + $i++; + } + + # check we have some callsigns + if ($i > @f) { + delete $self->{loc}; + #return (0, $self->msg('esend2')); + return (0, "need a callsign"); + } + + # now save all the 'to' callsigns for later + my @to = @f[ $i..$#f ]; + $loc->{to} = \@to; + + # find me and set the state and the function on my state variable to + # keep calling me for every line until I relinquish control + $self->func("DXMsg::do_send_stuff"); + $self->state('send1'); + #push @out, $self->msg('sendsubj'); + push @out, "Enter Subject (30 characters) >"; +} + +return (1, @out);