1. Added set/name, set/qra, set/location, set/qth, set/homenode, set/bbs,
authordjk <djk>
Mon, 7 Dec 1998 00:59:04 +0000 (00:59 +0000)
committerdjk <djk>
Mon, 7 Dec 1998 00:59:04 +0000 (00:59 +0000)
set/email
2. changed the Msg socket close to a shutdown (hopefully more reliable), this
should stop clients hanging on exit.
3. Added Alias support for help
4. Added lltos and stoll routines to DXBearing

15 files changed:
Changes
cmd/Commands_en.hlp
cmd/help.pl
cmd/set/email.pl
cmd/set/homebbs.pl
cmd/set/homenode.pl
cmd/set/location.pl
cmd/set/name.pl
cmd/set/qra.pl
cmd/set/qth.pl
perl/CmdAlias.pm
perl/DXBearing.pm
perl/DXProt.pm
perl/Messages
perl/Msg.pm

diff --git a/Changes b/Changes
index 9d1930aff4194c591ba313fc2da663f257919b3c..982e9dd6e05342b340b85ed1a14ada0dfbaecec8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+07Dec98========================================================================
+1. Added set/name, set/qra, set/location, set/qth, set/homenode
+2. changed the Msg socket close to a shutdown (hopefully more reliable), this 
+should stop clients hanging on exit.
+3. Added Alias support for help
 06Dec98========================================================================
 1. Fixed DXBearing::is_qra so that it correctly detects full QRA locators
 2. Added sh/qra for doing locator distances and bearings
index 74f73f7a9cdd85725a7b5d74ae56939685c6d043..aee33924df02508b312054d62cd768dfaf23e387 100644 (file)
@@ -167,6 +167,9 @@ You can have multiple qualifiers so that you can have for example:-
 
 which should send a copy of message 123 to G1TLH and G0RDI and you will
 receive a read receipt when they have read the message.
+
+SB is an alias for SEND NOPRIVATE
+SP is an alias for SEND PRIVATE
   
 === 0^SHOW/DXCC <prefix>^Interrogate the spot database by country
 This command takes the <prefix> (which can be a full or partial 
index c74fad166ba4a073f70cf2d025be99040b99fcf4..6f60c05f03718470efb172565925d0c61512c725 100644 (file)
@@ -43,6 +43,12 @@ my $in;
 
 $line =~ s/![\w\/]//og;
 $line =~ s/\//\.\*\//og;
+$line =~ s/^\s+//og;
+$line =~ s/\s+$//og;
+
+# sort out aliases
+my $alias = CmdAlias::get_hlp($line);
+$line = $alias if $alias;
 
 my $include;
 foreach $in (<$h>) {
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8748df1f1bed75b21e9e56696ce3bdb01ff5915b 100644 (file)
@@ -0,0 +1,27 @@
+#
+# set the email address  of the user
+#
+# Copyright (c) 1998 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('emaile1')) if !$line;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $user->email($line);
+       $user->put();
+       return (1, $self->msg('emaila', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3ab08f25a2d53d8583c62c93df7d196ea88463ce 100644 (file)
@@ -0,0 +1,28 @@
+#
+# set the home mail bbs  of the user
+#
+# Copyright (c) 1998 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('bbse1')) if !$line;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $line = uc $line;
+       $user->bbs($line);
+       $user->put();
+       return (1, $self->msg('bbs', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index 2c7c6c9f65d0340720ba240f199bd5e10af8bc5d..d85c893229cecd36da68707a5b024231cc5c9677 100644 (file)
@@ -5,3 +5,25 @@
 #
 # $Id$
 #
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('hnodee1')) if !$line;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $line = uc $line;
+       $user->homenode($line);
+       $user->put();
+       DXProt::broadcast_ak1a(DXProt::pc41($call, 4, $line), $DXProt::me);
+       return (1, $self->msg('hnode', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a1df5ede26e1d0b556df716756d046c5754d8779 100644 (file)
@@ -0,0 +1,37 @@
+#
+# set the latitude and longtitude field
+#
+# Copyright (c) 1998 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('loce1')) if !$line;
+return (1, $self->msg('loce2', $line)) unless $line =~ /\d+ \d+ [NnSs] \d+ \d+ [EeWw]/o;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $line = uc $line;
+       $user->qra($line);
+       my ($lat, $long) = DXBearing::stoll($line);
+       $user->lat($lat);
+       $user->long($long);
+       DXProt::broadcast_ak1a(DXProt::pc41($call, 3, $line), $DXProt::me);
+       if (!$user->qra) {
+               my $qra = DXBearing::lltos($lat, $long);
+               $user->qra($qra);
+       }
+       
+       $user->put();
+       return (1, $self->msg('loc', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..30b1dc7184c5f22d51cea9a11c9c1d44daf55b6a 100644 (file)
@@ -0,0 +1,28 @@
+#
+# set the name of the user
+#
+# Copyright (c) 1998 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('namee1')) if !$line;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $user->name($line);
+       $user->put();
+       DXProt::broadcast_ak1a(DXProt::pc41($call, 1, $line), $DXProt::me);
+       return (1, $self->msg('name', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index 0b13524e3ac1145d03689d86ad18dcbfea606465..a60415c351c6b5e642b8e591dc688880e1d75407 100644 (file)
@@ -1,8 +1,37 @@
 #
 # set the qra locator field
 #
+# Copyright (c) 1998 - Dirk Koopman
+#
 # $Id$
 #
-my ($self, $args)  = @_;
-my $user = $self->user;
-return (1, "qra locator is now ", $user->qra($args));
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('qrae1')) if !$line;
+return (1, $self->msg('qrae2', $line)) unless DXBearing::is_qra($line);
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $line = uc $line;
+       $user->qra($line);
+       if (!$user->lat && !$user->long) {
+               my ($lat, $long) = DXBearing::qratoll($line);
+               $user->lat($lat);
+               $user->long($long);
+               my $s = DXBearing::lltos($lat, $long);
+               DXProt::broadcast_ak1a(DXProt::pc41($call, 3, $s), $DXProt::me);
+       }
+       
+       $user->put();
+       return (1, $self->msg('qra', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index 93407a2a76899d2680119b6a4b409da404e8e75e..90d784e14ffc9cf936eb56574068826911b4a10d 100644 (file)
@@ -1,8 +1,28 @@
 #
-# set the qth field
+# set the name of the user
+#
+# Copyright (c) 1998 - Dirk Koopman
 #
 # $Id$
 #
-my ($self, $args)  = @_;
-my $user = $self->user;
-return (1, "qth is now ", $user->qth($args));
+
+my ($self, $line) = @_;
+my $call = $self->call;
+my $user;
+
+# remove leading and trailing spaces
+$line =~ s/^\s+//;
+$line =~ s/\s+$//;
+
+return (1, $self->msg('qthe1')) if !$line;
+
+$user = DXUser->get_current($call);
+if ($user) {
+       $user->qth($line);
+       $user->put();
+       DXProt::broadcast_ak1a(DXProt::pc41($call, 2, $line), $DXProt::me);
+       return (1, $self->msg('qth', $line));
+} else {
+       return (1, $self->msg('namee2', $call));
+}
+
index 8e7f8834ea4503f03fc1b9b805672026d2246982..a424f8e861ebb5a00cb15f415293be47bb8db3fa 100644 (file)
@@ -85,7 +85,7 @@ sub get_cmd
   $n = @{$ref};
   for ($i = 0; $i < $n; $i += 3) {
     if ($s =~ /$ref->[$i]/i) {
-         my $ri = qq{\$ro = "$ref->[$i+1]"};
+         my $ri = qq{\$ro = "$ref->[$i+1]"};
          my $ro;
          eval $ri;
          return $ro;
@@ -105,16 +105,16 @@ sub get_hlp
 
   $let = lc $let;
   
-  checkfiles();
-  
   $ref = $alias{$let};
   return undef if !$ref;
   
   $n = @{$ref};
   for ($i = 0; $i < $n; $i += 3) {
     if ($s =~ /$ref->[$i]/i) {
-         my $ri = qq{$ref->[$i+2]};
-         return $ri;
+         my $ri = qq{\$ro = "$ref->[$i+2]"};
+         my $ro;
+         eval $ri;
+         return $ro;
        }
   }
   return undef;
index ea17c2a4221e58d5143f4786ec9d160e9acfb033..4c8c3eea2a9ce22abbd89b96536dcd4c68bf8c3e 100644 (file)
@@ -112,4 +112,36 @@ sub bdist
        $az = $az+2*$pi if $az < 0;
        return (rd($az), $dx);
 }
+
+# turn a lat long string into floating point lat and long
+sub stoll
+{
+       my ($latd, $latm, $latl, $longd, $longm, $longl) = split /\s+/, shift;
+       
+       $longd += ($longm/60);
+       $longd = 0-$longd if (uc $longl) eq 'W'; 
+       $latd += ($latm/60);
+       $latd = 0-$latd if (uc $latl) eq 'S';
+       return ($latd, $longd);
+}
+
+# turn a lat and long into a string
+sub lltos
+{
+       my ($lat, $long) = @_;
+       my ($latd, $latm, $longd, $longm);
+       my $latl = $lat > 0 ? 'N' : 'S';
+       my $longl = $long > 0 ? 'E' : 'W';
+       
+       $lat = abs $lat;
+       $latd = int $lat;
+       $lat -= $latd;
+       $latm = int (60 * $lat);
+       
+       $long = abs $long;
+       $longd = int $long;
+       $long -= $longd;
+       $longm = int (60 * $long);
+       return "$latd $latm $latl $longd $longm $longl";
+}
 1;
index 5fb684189dc67811db0e8df4eb9aafce30cbf8db..35aae2e5ed6a4b6114c7aa7c10eeefca2e57501d 100644 (file)
@@ -388,13 +388,9 @@ sub normal
                        } elsif ($field[2] == 2) {
                                $user->qth($field[3]);
                        } elsif ($field[2] == 3) {
-                               my ($latd, $latm, $latl, $longd, $longm, $longl) = split /\s+/, $field[3];
-                               $longd += ($longm/60);
-                               $longd = 0-$longd if (uc $longl) eq 'W'; 
-                               $user->long($longd);
-                               $latd += ($latm/60);
-                               $latd = 0-$latd if (uc $latl) eq 'S';
-                               $user->lat($latd);
+                               my ($lat, $long) = DXBearing::stoll($field[3]);
+                               $user->lat($lat);
+                               $user->long($long);
                        } elsif ($field[2] == 4) {
                                $user->homenode($field[3]);
                        }
index 74bf3943389dc8d5175c5d35da80804ec8f50b42..6cd9bcd750318e814aba30b3932c777ac4475dce 100644 (file)
@@ -14,6 +14,8 @@ package DXM;
                 already => '$_[0] already connnected',
                                anns => 'Announce flag set on $_[0]',
                                annu => 'Announce flag unset on $_[0]',
+                               bbse1 => 'Please try again, set/bbs <your bbs address>',
+                               bbs => 'Your BBS Address is now \"$_[0]\"',
                                beepoff => 'Beeps are now off',
                                beepon => 'Beeps are now on',
                                conother => 'Sorry $_[0] you are connected on another port',
@@ -37,6 +39,8 @@ package DXM;
                                e8 => 'Need a callsign and some text',
                                e9 => 'Need at least some text',
                                e10 => '$_[0] not connected locally',
+                               emaile1 => 'Please try again, set/email <your e-mail address>',
+                               emaila => 'Your E-Mail Address is now \"$_[0]\"',
                                email => 'E-mail address set to: $_[0]',
                                helpe1 => 'Help system unavailable, tell sysop',
                                helpe2 => 'No help available on $_[0]',
@@ -45,9 +49,17 @@ package DXM;
                                hereu => 'Here unset on $_[0]',
                                homebbs => 'Home BBS set to: $_[0]',
                                homenode => 'Home Node set to: $_[0]',
+                               hnodee1 => 'Please try again, set/homenode <your home DX Cluster>',
+                               hnode => 'Your Homenode is now \"$_[0]\"',
                                l1 => 'Sorry $_[0], you are already logged on on another channel',
                                l2 => 'Hello $_[0], this is $main::mycall in $main::myqth running DXSpider V$main::version',
+                               loce1 => 'Please try again, set/location <latitude longitude>',
+                               loce2 => 'Don\'t recognise \"$_[0]\" as a Lat/Long (eg 52 20 N 0 16 E)',
+                               loc => 'Your Lat/Long is now \"$_[0]\"',
                                m2 => '$_[0] Information: $_[1]',
+                               namee1 => 'Please try again, set/name <your name>',
+                               namee2 => 'Can\'t find user $_[0]!',
+                               name => 'Your name is now \"$_[0]\"',
                                node => '$_[0] set as AK1A style Node',
                                nodec => '$_[0] created as AK1A style Node',
                                nodee1 => 'You cannot use this command whilst your target ($_[0]) is on-line',
@@ -59,6 +71,11 @@ package DXM;
                                pr => '$_[0] de $main::mycall $main::cldate $main::ztime >',
                                priv => 'Privilege level changed on $_[0]',
                                prx => '$main::mycall >',
+                               qthe1 => 'Please try again, set/qth <your qth>',
+                               qth => 'Your QTH is now \"$_[0]\"',
+                               qrae1 => 'Please try again, set/qra <qra locator>',
+                               qrae2 => 'Don\'t recognise \"$_[0]\" as a QRA locator (eg JO02LQ)',
+                               qra => 'Your QRA Locator is now \"$_[0]\"',
                                rcmdo => 'RCMD \"$_[0]\" sent to $_[1]',
                                read1 => 'Sorry, no new messages for you',
                                read2 => 'Msg $_[0] not found',
index 20e000334ca5d72d103d51e63f17694ea643bc88..65a32a662c64e7e1ec82df62d2bc94ba19cd848f 100644 (file)
@@ -67,7 +67,7 @@ sub disconnect {
     my $sock = delete $conn->{sock};
     return unless defined($sock);
     set_event_handler ($sock, "read" => undef, "write" => undef);
-    close($sock);
+    shutdown($sock, 3);
 }
 
 sub send_now {