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 %convert);
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 dxcc 1 );
15 %convert = qw(dxcc ADIF);
23 my ($tag, $data) = $msg =~ m|^\s*<(\w+)>(.*)</|;
25 $tag = $convert{$tag} if exists $convert{$tag};
26 my $prefix = $conn->{prefix} || ' ';
27 $dxchan->send($prefix . sprintf("%-10s: $data", $tag));
35 $dxchan->send("Data provided by www.qrz.com");
44 my $state = $conn->{state};
46 dbg("qrz: $state $msg") if isdbg('qrz');
48 if ($state eq 'blank') {
49 if ($msg =~ /^\s*<Callsign>/) {
50 $conn->{state} = 'go';
51 } elsif ($msg =~ /^\s*<Error>/) {
52 _send($conn, $msg, $dxchan);
54 } elsif ($state eq 'go') {
55 if ($msg =~ m|</Callsign>|) {
56 $conn->{state} = 'skip';
60 _send($conn, $msg, $dxchan);
66 my ($self, $line) = @_;
67 my $call = $self->call;
70 return (1, $self->msg('e24')) unless $Internet::allow;
71 return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless $line;
72 my $target = $Internet::qrz_url || 'xml.qrz.com';
74 my $path = qq{/xml/current/?callsign=$line;username=$Internet::qrz_uid;password=$Internet::qrz_pw;agent=dxspider};
75 dbg("qrz: $target:$port$path") if isdbg('qrz');
77 Log('call', "$call: show/qrz \U$line");
78 my $conn = AsyncMsg->get($self, $target, $path, filter=>\&filter, prefix=>'qrz> ', on_disc=>\&_on_disc);
80 $conn->{state} = 'blank';
81 push @out, $self->msg('m21', "show/qrz");
83 push @out, $self->msg('e18', 'QRZ.com');