Change DXUser->get* to DXUser::get*
[spider.git] / cmd / set / location.pl
1 #
2 # set the latitude and longtitude 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('loce1')) if !$line;
18 return (1, $self->msg('loce3', uc $line)) if is_qra($line);
19 return (1, $self->msg('loce2', $line)) unless is_latlong($line);
20
21 $user = DXUser::get_current($call);
22 if ($user) {
23         $line = uc $line;
24         my ($lat, $long) = DXBearing::stoll($line);
25         my $oldlat = $user->lat || 0;
26         my $oldlong = $user->long || 0;
27         if ($oldlat != $lat || $oldlong != $long) {
28                 $user->lat($lat);
29                 $user->long($long);
30                 my $l = DXBearing::lltos($lat, $long);
31                 my $s = DXProt::pc41($call, 3, $l);
32                 DXProt::eph_dup($s);
33                 DXChannel::broadcast_all_nodes($s, $main::me) ;
34         }
35         my $qra = DXBearing::lltoqra($lat, $long);
36         my $oldqra = $user->qra || "";
37         if ($oldqra ne $qra) {
38                 $user->qra($qra);
39                 my $s = DXProt::pc41($call, 5, $qra);
40                 DXProt::eph_dup($s);
41                 DXChannel::broadcast_all_nodes($s, $main::me);
42         }
43         
44         $user->put();
45         return (1, $self->msg('loc', $line));
46 } else {
47         return (1, $self->msg('namee2', $call));
48 }