3 # Local 'autoqsl' module for DXSpider
5 # Copyright (c) 2003 Dirk Koopman G1TLH
17 use vars qw($qslfn $dbm $maxentries);
25 my $ufn = "$main::root/data/$qslfn.v1";
27 Prefix::load() unless Prefix::loaded();
34 dbg("Storable appears to be missing");
35 dbg("In order to use the QSL feature you must");
36 dbg("load Storable from CPAN");
39 import Storable qw(nfreeze freeze thaw);
43 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
45 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
57 my ($pkg, $call) = @_;
58 return bless [uc $call, []], $pkg;
61 # the format of each entry is [manager, times found, last time, last reporter]
71 return unless length $line && $line =~ /\b(?:QSL|VIA)\b/i;
72 foreach my $man (split /\b/, uc $line) {
75 if (is_callsign($man) && !is_qra($man)) {
76 my @pre = Prefix::extract($man);
77 $tok = $man if @pre && $pre[0] ne 'Q';
78 } elsif ($man =~ /^BUR/) {
80 } elsif ($man =~ /^LOTW/) {
82 } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
84 } elsif ($man =~ /^QRZ/) {
90 my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
99 $r = [$tok, 1, $t, $by];
100 unshift @{$self->[1]}, $r;
103 # prune the number of entries
104 pop @{$self->[1]} while (@{$self->[1]} > $maxentries);
107 $self->put if $changed;
112 return undef unless $dbm;
116 my $r = $dbm->get($key, $value);
119 eval { $v = thaw($value) };
121 LogDbg("Error thawing DXQSL key '$key' (now deleted): $@");
122 eval {$dbm->del($key)};
133 my $key = $self->[0];
134 my $value = nfreeze($self);
135 $dbm->put($key, $value);