X-Git-Url: http://scm.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fdb0sdx.pl;h=64c6f3bfdf585534d552a6ffbdb0717c6eabfa30;hb=63f0fc26e717837bc7c6990f27d26de91d65eb7e;hp=2c5700448d7beb454f404650d4d2fc2edb48f64e;hpb=ed64ea9b9a101013cebeafaf76da0fc1a17722bf;p=spider.git
diff --git a/cmd/show/db0sdx.pl b/cmd/show/db0sdx.pl
index 2c570044..64c6f3bf 100644
--- a/cmd/show/db0sdx.pl
+++ b/cmd/show/db0sdx.pl
@@ -2,81 +2,94 @@
# Query the DB0SDX QSL server for a callsign
#
# Copyright (c) 2003 Dirk Koopman G1TLH
+# Modified Dec 9, 2004 for new website and xml schema by David Spoelstra N9KT
+# and tidied up by me (Dirk)
#
-# $Id$
#
+#
+
+sub on_disc
+{
+ my $conn = shift;
+ my $dxchan = shift;
+ my @out;
+
+# $DB::single = 1;
+
+ dbg("db0sdx in: $conn->{sdxin}") if isdbg('db0sdx');
+
+ my ($info) = $conn->{sdxin} =~ m|([^<]*)|;
+# dbg("db0sdx info: $info");
+ my $prefix = $conn->{prefix} || '';
+
+ my @in = split /[\r\n]/, $info if $info;
+ if (@in && $in[0]) {
+# dbg("db0sdx: in qsl");
+ push @out, map {"$prefix$_"} @in;
+ } else {
+# dbg("db0sdx: in fault");
+ ($info) = $conn->{sdxin} =~ m|([^<]*)|;
+ push @out, "$prefix$info" if $info;
+ push @out, $dxchan->msg('e3', 'DB0SDX', $conn->{sdxline}) unless @out;
+ }
+ $dxchan->send(@out);
+}
-my ($self, $line) = @_;
-my $call = $self->call;
-my @out;
+sub process
+{
+ my $conn = shift;
+ my $msg = shift;
+
+# $DB::single = 1;
+
+ $conn->{sdxin} .= "$msg\n";
+
+ dbg("db0sdx in: $conn->{sdxin}") if isdbg('db0sdx');
+}
-$line = uc $line;
-return (1, $self->msg('e24')) unless $Internet::allow;
-return (1, "SHOW/DB0SDX , e.g. SH/DB0SDX ea7wa") unless $line && is_callsign($line);
-my $target = 'dotnet.grossmann.com';
-my $port = 80;
-my $cmdprompt = '/query->.*$/';
+sub handle
+{
+ my ($self, $line) = @_;
+ my $call = $self->call;
+ my @out;
-my($info, $t);
-
-$t = new Net::Telnet;
-$info = $t->open(Host => $target,
- Port => $port,
- Timeout => 15);
+ $line = uc $line;
+ return (1, $self->msg('e24')) unless $Internet::allow;
+ return (1, "SHOW/DB0SDX , e.g. SH/DB0SDX ea7wa") unless $line && is_callsign($line);
+ my $target = $Internet::db0sdx_url || 'www.qslinfo.de';
+ my $path = $Internet::db0sdx_path || '/qslinfo';
+ my $suffix = $Internet::db0sdx_suffix || '.asmx';
+ my $port = 80;
-if (!$info) {
- push @out, $self->msg('e18', 'DB0SDX Database server');
-} else {
+ dbg("db0sdx: contacting $target:$port") if isdbg('db0sdx');
my $s = qq(
-
+
$line
+ DXSpider V$main::version B$main::build ($call\@$main::mycall)
-
-);
-
-
- my $lth = length($s)+7;
-
- dbg("db0sdx out: $s") if isdbg('db0sdx');
-
- $t->print("POST /qslinfo/qslinfo.asmx HTTP/1.0");
- $t->print("Host: dotnet.grossmann.com");
- $t->print("Content-Type: text/xml; charset=utf-8");
- $t->print("Content-Length: $lth");
- $t->print("Connection: Close");
- $t->print("SOAPAction: \"http://dotnet.grossmann.com/qslinfo/qslinfo\"");
- $t->print("");
- $t->put($s);
-
- my $in;
-
- while (my $result = eval { $t->getline(Timeout => 30) } || $@) {
- if ($@) {
- push @out, $self->msg('e18', 'DB0SDX Server');
- last;
- } else {
- $in .= $result;
- }
- }
-
- dbg("db0sdx in: $in") if isdbg('db0sdx');
+);
+# $s .= "\n";
+ my $lth = length($s);
- # Log the lookup
Log('call', "$call: show/db0sdx $line");
- $t->close;
-
- my ($info) = $in =~ m|([^<]*)|;
- my @in = split /[\r\n]/, $info if $info;
- if (@in && $in[0]) {
- push @out, @in;
+ my $conn = AsyncMsg->post($self, $target, "$path$suffix", prefix => 'sdx> ', filter => \&process,
+ 'Content-Type' => 'text/xml; charset=utf-8',
+ 'Content-Length' => $lth,
+ Connection => 'Close',
+ SOAPAction => qq{"http://$target$path"},
+ data => $s,
+ on_disc => \&on_disc);
+
+ if ($conn) {
+ $conn->{sdxline} = $line;
+ push @out, $self->msg('m21', "show/db0sdx");
} else {
- ($info) = $in =~ m|([^<]*)|;
- push @out, $info if $info;
- push @out, $self->msg('e3', 'DB0SDX', $line) unless @out;
+ push @out, $self->msg('e18', 'DB0SDX Database server');
}
+
+ return (1, @out);
}
-return (1, @out);