fix eph_dup
[spider.git] / perl / DXProt.pm
index b9d00a3786fdf910fc68885bd750f6d15b189b57..0484d8fc5773c9012501c728c1b2eea8ea1ba6a6 100644 (file)
@@ -40,14 +40,14 @@ use Thingy::Dx;
 use Thingy::Rt;
 use Thingy::Ping;
 use Thingy::T;
+use Thingy::Hello;
+use Thingy::Bye;
 
 use strict;
 
 use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /^\d+\.\d+(?:\.(\d+)\.(\d+))?$/  || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
+
+main::mkver($VERSION = q$Revision$);
 
 use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restime $eph_pc34_restime
                        $last_hour $last10 %eph  %pings %rcmds $ann_to_talk
@@ -239,7 +239,9 @@ sub new
        my $pkg = shift;
        my $call = shift;
        $main::routeroot->add($call, '5000', Route::here(1)) if $call ne $main::mycall;
-
+       my $thing = Thingy::Hello->new(user=>$call);
+       $thing->broadcast($self);
+       
        return $self;
 }
 
@@ -533,9 +535,9 @@ sub handle_11
        
        my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $_[6], $_[7]);
 
-       my $thing = Thingy::Dx->new(origin=>$main::mycall, group=>'DX');
+       my $thing = Thingy::Dx->new(origin=>$main::mycall);
        $thing->from_DXProt(DXProt=>$line,spotdata=>\@spot);
-       $thing->queue($self);
+       $thing->process($self);
 
        # this goes after the input filtering, but before the add
        # so that if it is input filtered, it isn't added to the dup
@@ -593,20 +595,6 @@ sub handle_11
                        }
                }
        }
-                               
-       # local processing 
-       my $r;
-       eval {
-               $r = Local::spot($self, @spot);
-       };
-       #                       dbg("Local::spot1 error $@") if isdbg('local') if $@;
-       return if $r;
-
-       # DON'T be silly and send on PC26s!
-       return if $pcno == 26;
-
-       # send out the filtered spots
-#      send_dx_spot($self, $line, @spot) if @spot;
 }
                
 # announces
@@ -739,7 +727,7 @@ sub handle_16
 
                
                my $i;
-               my @rout;
+               my $rout;
                for ($i = 2; $i < $#_; $i++) {
                        my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
                        next unless $call && $conf && defined $here && is_callsign($call);
@@ -747,40 +735,21 @@ sub handle_16
                        
                        eph_del_regex("^PC17\\^$call\\^$ncall");
                                
-                       $conf = 1;
-                               
-                       my $r = Route::User::get($call);
-                       my $flags = Route::here($here)|Route::conf($conf);
-                               
-                       if ($r) {
-                               my $au = $r->addparent($parent);                                        
-                               if ($r->flags != $flags) {
-                                       $r->flags($flags);
-                                       $au = $r;
-                               }
-                               push @rout, $r if $au;
-                       } else {
-                               push @rout, $parent->add_user($call, $flags);
-                       }
-               
-                               
-                       # add this station to the user database, if required
-                       $call =~ s/-\d+$//o;    # remove ssid for users
-                       my $user = DXUser->get_current($call);
-                       $user = DXUser->new($call) if !$user;
-                       $user->homenode($parent->call) if !$user->homenode;
-                       $user->node($parent->call);
-                       $user->lastin($main::systime) unless DXChannel->get($call);
-                       $user->put;
+                       my $flags = $here ? 1 : 0;
+                       $rout .= "$flags$call:";
                }
+               
 
-               if (@rout) {
-                       my $thing = Thingy::Dx->new(origin=>$main::mycall);
-                       $thing->from_DXProt(DXProt=>$line,originref=>$parent);
-                       $thing->queue($self);
+               if ($rout) {
+                       chop $rout;
+                       my $thing = Thingy::Rt->new(origin=>$main::mycall, user=>$self->{call});
+                       $thing->from_DXProt(t=>'au', $ncall eq $self->{call} ? () : ('n', "1$ncall"), u=>$rout, DXProt=>$line);
+                       $thing->process($self);
                } else {
                        dbg("PCPROT: No usable users") if isdbg('chanerr');
                }
+       } else {
+               dbg("PCPROT: no PC19 seen for $ncall" ) if isdbg('chanerr');
        }
 }
                
@@ -834,21 +803,15 @@ sub handle_17
                return;
        }
 
-       # input filter if required and then remove user if present
-       if ($parent) {
-#              return unless $self->in_filter_route($parent);  
-               $parent->del_user($uref) if $uref;
-       } else {
-               $parent = Route->new($ncall);  # throw away
-       }
-
        if (eph_dup($line)) {
                dbg("PCPROT: dup PC17 detected") if isdbg('chanerr');
                return;
        }
 
        $uref = Route->new($ucall) unless $uref; # throw away
-       $self->route_pc17($origin, $line, $parent, $uref);
+       my $thing = Thingy::Rt->new(origin=>$main::mycall, user=>$self->{call});
+       $thing->from_DXProt(t=>'du', $ncall eq $self->{call} ? () : ('n', "1$ncall"), u=>"1$ucall", DXProt=>$line);
+       $thing->process($self);
 }
                
 # link request
@@ -2245,6 +2208,9 @@ sub disconnect
        
        # broadcast to all other nodes that all the nodes connected to via me are gone
        unless ($pc39flag && $pc39flag == 2) {
+               my $thing = Thingy::Bye->new(user=>$call);
+               $thing->broadcast($self);
+
                $self->route_pc21($main::mycall, undef, @rout) if @rout;
        }