12. added an 'auto rcmd <node> for/oper <call>' for people I can see on the
[spider.git] / perl / DXProt.pm
index a7cf9e6f9d96952db58fd4b9c4b41f493f51833f..7a2ca91036c396001b8ba557f4e08f2e2c656bb6 100644 (file)
@@ -222,8 +222,8 @@ sub normal
                        }
 
                        # are any of the crucial fields invalid?
-            if ($field[2] =~ /[a-z]/ || $field[6] =~ /[a-z]/ || $field[7] =~ /[a-z]/) {
-                               dbg('chan', "Spot contains lower case callsigns, rejected");
+            if ($field[2] =~ /(?:^\s*$|[a-z])/ || $field[6] =~ /(?:^\s*$|[a-z])/ || $field[7] =~ /(?:^\s*$|[a-z])/) {
+                               dbg('chan', "Spot contains lower case callsigns or blanks, rejected");
                                return;
                        }
                        
@@ -243,6 +243,40 @@ sub normal
                        # you should be able to route on any of these
             #
                        
+                       # fix up qra locators of known users 
+                       my $user = DXUser->get_current($spot[4]);
+                       if ($user) {
+                               my $qra = $user->qra;
+                               unless ($qra && DXBearing::is_qra($qra)) {
+                                       my $lat = $user->lat;
+                                       my $long = $user->long;
+                                       if (defined $lat && defined $long) {
+                                               $user->qra(DXBearing::lltoqra($lat, $long)); 
+                                               $user->put;
+                                       }
+                               }
+
+                               # send a remote command to a distant cluster if it is visible and there is no
+                               # qra locator and we havn't done it for a month.
+
+                               unless ($user->qra) {
+                                       my $node;
+                                       my $to = $user->homenode;
+                                       my $last = $user->lastoper || 0;
+                                       if ($main::systime > $last + $DXUser::lastoperinterval && $to && ($node = DXCluster->get_exact($to)) ) {
+                                               my $cmd = "forward/opernam $spot[4]";
+                                               # send the rcmd but we aren't interested in the replies...
+                                               if ($node && $node->dxchan && $node->dxchan->is_clx) {
+                                                       route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
+                                               } else {
+                                                       route(undef, $to, pc34($main::mycall, $to, $cmd));
+                                               }
+                                               $user->lastoper($main::systime);
+                                               $user->put;
+                                       }
+                               }
+                       }
+                               
                        # local processing 
                        my $r;
                        eval {
@@ -654,6 +688,9 @@ sub normal
                                my ($lat, $long) = DXBearing::stoll($field[3]);
                                $user->lat($lat);
                                $user->long($long);
+                               my $qra = $user->qra || DXBearing::lltoqra($lat, $long);
+                               $qra = DXBearing::lltoqra($lat, $long) unless $qra && DXBearing::is_qra($qra);
+                               $user->qra($qra) if $qra ne $user->qra;
                        } elsif ($field[2] == 4) {
                                $user->homenode($field[3]);
                        }
@@ -941,7 +978,7 @@ sub send_dx_spot
                                $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
                        }
                } elsif ($dxchan->is_user && $dxchan->{dx}) {
-                       my $buf = Spot::formatb($_[0], $_[1], $_[2], $_[3], $_[4]);
+                       my $buf = Spot::formatb($dxchan->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
                        $buf .= "\a\a" if $dxchan->{beep};
                        if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
                                $dxchan->send($buf);