put pc16/17 handling back the way it was
[spider.git] / perl / DXProt.pm
index 712f933e833f29bd8a4508f79be4df614d4d9dec..886099f2cc15759824888249e88a9a796d0c3485 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,11 @@ sub new
        my $pkg = shift;
        my $call = shift;
        $main::routeroot->add($call, '5000', Route::here(1)) if $call ne $main::mycall;
-
+       if ($self->{call} ne $main::mycall) {
+               my $thing = Thingy::Hello->new(user=>$call);
+               $thing->broadcast($self);
+       }
+       
        return $self;
 }
 
@@ -533,9 +537,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 +597,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
@@ -707,14 +697,14 @@ sub handle_16
                return;
        }
 
-       RouteDB::update($ncall, $origin);
+       RouteDB::update($ncall, $self->{call});
 
        # do we believe this call? 
-       unless ($ncall eq $origin || $self->is_believed($ncall)) {
-               if (my $ivp = Investigate::get($ncall, $origin)) {
+       unless ($ncall eq $self->{call} || $self->is_believed($ncall)) {
+               if (my $ivp = Investigate::get($ncall, $self->{call})) {
                        $ivp->store_pcxx($pcno,$line,$origin,@_);
                } else {
-                       dbg("PCPROT: We don't believe $ncall on $origin") if isdbg('chanerr');
+                       dbg("PCPROT: We don't believe $ncall on $self->{call}") if isdbg('chanerr');
                }
                return;
        }
@@ -754,10 +744,10 @@ sub handle_16
                                                $parent = Route::Node::get($_->[0]);
                                                $dxchan = $parent->dxchan if $parent;
                                                if ($dxchan && $dxchan ne $self) {
-                                                       dbg("PCPROT: PC19 from $origin trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
+                                                       dbg("PCPROT: PC19 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
                                                        $parent = undef;
                                                }
-                                               if ($parent) {
+       if ($parent) {
                                                        my $r = $parent->add($ncall, $_->[1], $_->[2]);
                                                        push @nrout, $r unless @nrout;
                                                }
@@ -783,25 +773,25 @@ sub handle_16
                        return;
                }
        } else {
-                               
+
                $dxchan = $parent->dxchan;
                if ($dxchan && $dxchan ne $self) {
-                       dbg("PCPROT: PC16 from $origin trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
+                       dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
                        return;
                }
 
                # input filter if required
                return unless $self->in_filter_route($parent);
        }
-
-       my $i;
+               
+               my $i;
        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);
-               next if $call eq $main::mycall;
-
-               eph_del_regex("^PC17\\^$call\\^$ncall");
+               for ($i = 2; $i < $#_; $i++) {
+                       my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
+                       next unless $call && $conf && defined $here && is_callsign($call);
+                       next if $call eq $main::mycall;
+                       
+                       eph_del_regex("^PC17\\^$call\\^$ncall");
                                
                $conf = $conf eq '*';
 
@@ -812,18 +802,18 @@ sub handle_16
                        dbg("PCPROT: $call is a node") if isdbg('chanerr');
                        next;
                }
-                               
+               
                $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 {
+       } else {
                        push @rout, $parent->add_user($call, $flags);
                }
                
@@ -855,7 +845,7 @@ sub handle_17
                        
        # do I want users from this channel?
        unless ($self->user->wantpc16) {
-               dbg("PCPROT: don't send users to $origin") if isdbg('chanerr');
+               dbg("PCPROT: don't send users to $self->{call}") if isdbg('chanerr');
                return;
        }
        if ($ncall eq $main::mycall) {
@@ -863,14 +853,14 @@ sub handle_17
                return;
        }
 
-       RouteDB::delete($ncall, $origin);
+       RouteDB::delete($ncall, $self->{call});
 
        # do we believe this call? 
-       unless ($ncall eq $origin || $self->is_believed($ncall)) {
-               if (my $ivp = Investigate::get($ncall, $origin)) {
+       unless ($ncall eq $self->{call} || $self->is_believed($ncall)) {
+               if (my $ivp = Investigate::get($ncall, $self->{call})) {
                        $ivp->store_pcxx($pcno,$line,$origin,@_);
                } else {
-                       dbg("PCPROT: We don't believe $ncall on $origin") if isdbg('chanerr');
+                       dbg("PCPROT: We don't believe $ncall on $self->{call}") if isdbg('chanerr');
                }
                return;
        }
@@ -886,7 +876,7 @@ sub handle_17
 
        $dxchan = $parent->dxchan if $parent;
        if ($dxchan && $dxchan ne $self) {
-               dbg("PCPROT: PC17 from $origin trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
+               dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
                return;
        }
 
@@ -2301,6 +2291,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;
        }