1. I believe I have fixed all the login/logout 'broken pipe' errors
[spider.git] / perl / DXCommandmode.pm
index 99e2bfe5fe55692b5d70adc418f6e1b235ff7719..ca6a1c4e989cbc264c4b72cf698a6197bf7a6c93 100644 (file)
@@ -24,9 +24,10 @@ use DXLogPrint;
 use DXBearing;
 use CmdAlias;
 use Filter;
-use Carp;
 use Minimuf;
 use DXDb;
+use AnnTalk;
+use WCY;
 use Sun;
 
 use strict;
@@ -45,7 +46,6 @@ $scriptbase = "$main::root/scripts"; # the place where all users start scripts g
 sub new 
 {
        my $self = DXChannel::alloc(@_);
-       $self->{'sort'} = 'U';          # in absence of how to find out what sort of an object I am
        return $self;
 }
 
@@ -66,7 +66,7 @@ sub start
        $self->state('prompt');         # a bit of room for further expansion, passwords etc
        $self->{priv} = $user->priv;
        $self->{lang} = $user->lang;
-       $self->{pagelth} = 20;
+       $self->{pagelth} = $user->pagelth || 20;
        $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later
        $self->{consort} = $line;       # save the connection type
        
@@ -74,17 +74,19 @@ sub start
        $self->{beep} = $user->wantbeep;
        $self->{ann} = $user->wantann;
        $self->{wwv} = $user->wantwwv;
+       $self->{wcy} = $user->wantwcy;
        $self->{talk} = $user->wanttalk;
        $self->{wx} = $user->wantwx;
        $self->{dx} = $user->wantdx;
        $self->{logininfo} = $user->wantlogininfo;
        $self->{here} = 1;
        
+
        # add yourself to the database
        my $node = DXNode->get($main::mycall) or die "$main::mycall not allocated in DXNode database";
        my $cuser = DXNodeuser->new($self, $node, $call, 0, 1);
        $node->dxchan($self) if $call eq $main::myalias; # send all output for mycall to myalias
-       
+
        # issue a pc16 to everybody interested
        my $nchan = DXChannel->get($main::mycall);
        my @pc16 = DXProt::pc16($nchan, $cuser);
@@ -102,6 +104,12 @@ sub start
        $self->send($self->msg('hnodee1')) if !$user->qth;
        $self->send($self->msg('m9')) if DXMsg::for_me($call);
        $self->send($self->msg('pr', $call));
+
+       # decide on echo
+       if (!$user->wantecho) {
+               $self->send_now('E', "0");
+               $self->send($self->msg('echow'));
+       }
        
        $self->tell_login('loginu');
        
@@ -246,7 +254,7 @@ sub run_cmd
                                        unless (exists $Cache{$package}->{'sub'}) {
                                                $c = eval $Cache{$package}->{'eval'};
                                                if ($@) {
-                                                       return ("Syserr: Syntax error in $package", $@);
+                                                       return DXDebug::shortmess($@);
                                                }
                                                $Cache{$package}->{'sub'} = $c;
                                        }
@@ -255,7 +263,10 @@ sub run_cmd
                                                @ans = &{$c}($self, $args);
                                    };
                                        
-                                       return ($@) if $@;
+                                       if ($@) {
+                                               cluck($@);
+                                               return (DXDebug::shortmess($@));
+                                       };
                                }
                        } else {
                                dbg('command', "cmd: $cmd not found");
@@ -295,10 +306,14 @@ sub process
 sub finish
 {
        my $self = shift;
+       my $conn = shift;
        my $call = $self->call;
 
+       # I was the last node visited
+    $self->user->node($main::mycall);
+               
        # log out text
-       if (-e "$main::data/logout") {
+       if ($conn && -e "$main::data/logout") {
                open(I, "$main::data/logout") or confess;
                my @in = <I>;
                close(I);