Change DXUser->get* to DXUser::get*
[spider.git] / cmd / set / qra.pl
1 #
2 # set the qra locator field
3 #
4 # Copyright (c) 1998 - Dirk Koopman
5 #
6 #
7 #
8
9 my ($self, $line) = @_;
10 my $call = $self->call;
11 my $user;
12
13 # remove leading and trailing spaces
14 $line =~ s/^\s+//;
15 $line =~ s/\s+$//;
16
17 return (1, $self->msg('qrae1')) if !$line;
18 return (1, $self->msg('qrae2', $line)) unless is_qra($line);
19
20 $user = DXUser::get_current($call);
21 if ($user) {
22         my $qra = uc $line;
23         my $oldqra = $user->qra || "";
24         if ($oldqra ne $qra) {
25                 $user->qra($qra);
26                 my $s = DXProt::pc41($call, 5, $qra);
27                 DXProt::eph_dup($s);
28                 DXChannel::broadcast_all_nodes($s, $main::me);
29         }
30         my ($lat, $long) = DXBearing::qratoll($qra);
31         my $oldlat = $user->lat || 0;
32         my $oldlong = $user->long || 0;
33         if ($oldlat != $lat || $oldlong != $long) {
34                 $user->lat($lat);
35                 $user->long($long);
36                 my $l = DXBearing::lltos($lat, $long);
37                 my $s = DXProt::pc41($call, 3, $l);
38                 DXProt::eph_dup($s);
39                 DXChannel::broadcast_all_nodes($s, $main::me) ;
40         }
41         
42         $user->put();
43         return (1, $self->msg('qra', $line));
44 } else {
45         return (1, $self->msg('namee2', $call));
46 }
47