2 # Query the QRZ Database server for a callsign
4 # from an idea by Steve Franke K9AN and information from Angel EA7WA
5 # and finally (!) modified to use the XML interface
7 # Then made asyncronous...
9 # Copyright (c) 2001-2013 Dirk Koopman G1TLH
12 use vars qw (%allowed);
14 %allowed = qw(call 1 fname 1 name 1 addr2 1 state 1 country 1 lat 1 lon 1 county 1 moddate 1 qslmgr 1 grid 1 Error 1 );
22 my ($tag, $data) = $msg =~ m|^\s*<(\w+)>(.*)</|;
24 my $prefix = $conn->{prefix} || ' ';
25 $dxchan->send($prefix . sprintf("%-10s: $data", $tag));
33 $dxchan->send("Data provided by www.qrz.com");
42 my $state = $conn->{state};
44 dbg("qrz: $state $msg") if isdbg('qrz');
46 if ($state eq 'blank') {
47 if ($msg =~ /^\s*<Callsign>/) {
48 $conn->{state} = 'go';
49 } elsif ($msg =~ /^\s*<Error>/) {
50 _send($conn, $msg, $dxchan);
52 } elsif ($state eq 'go') {
53 if ($msg =~ m|</Callsign>|) {
54 $conn->{state} = 'skip';
58 _send($conn, $msg, $dxchan);
64 my ($self, $line) = @_;
65 my $call = $self->call;
68 return (1, $self->msg('e24')) unless $Internet::allow;
69 return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless $line;
70 my $target = $Internet::qrz_url || 'xmldata.qrz.com';
72 my $path = qq{/xml/current/?callsign=$line;username=$Internet::qrz_uid;password=$Internet::qrz_pw;agent=dxspider};
73 dbg("qrz: $target:$port$path") if isdbg('qrz');
75 Log('call', "$call: show/qrz \U$line");
76 my $conn = AsyncMsg->get($self, $target, $port, $path, filter=>\&filter, prefix=>'qrz> ', on_disc=>\&_on_disc);
78 $conn->{state} = 'blank';
79 push @out, $self->msg('m21', "show/qrz");
81 push @out, $self->msg('e18', 'QRZ.com');