projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed more 5.004 ambiguities including making the format of data
[spider.git]
/
perl
/
DXUser.pm
diff --git
a/perl/DXUser.pm
b/perl/DXUser.pm
index 97aca375c325bccac68ac9fb609c46a4fc86ca19..9d534ae9d1835f6b2eaaeb4ab6b0fc33a2378260 100644
(file)
--- a/
perl/DXUser.pm
+++ b/
perl/DXUser.pm
@@
-11,7
+11,9
@@
package DXUser;
require Exporter;
@ISA = qw(Exporter);
require Exporter;
@ISA = qw(Exporter);
+use DXLog;
use DB_File;
use DB_File;
+use Data::Dumper;
use Fcntl;
use Carp;
use Fcntl;
use Carp;
@@
-49,6
+51,13
@@
$filename = undef;
hmsgno => '0,Highest Msgno',
group => '0,Access Group,parray', # used to create a group of users/nodes for some purpose or other
isolate => '9,Isolate network,yesno',
hmsgno => '0,Highest Msgno',
group => '0,Access Group,parray', # used to create a group of users/nodes for some purpose or other
isolate => '9,Isolate network,yesno',
+ wantbeep => '0,Rec Beep,yesno',
+ wantann => '0,Rec Announce,yesno',
+ wantwwv => '0,Rec WWV,yesno',
+ wanttalk => '0,Rec Talk,yesno',
+ wantwx => '0,Rec WX,yesno',
+ wantdx => '0,Rec DX Spots,yesno',
+ pingint => '9,Node Ping interval',
);
no strict;
);
no strict;
@@
-63,7
+72,6
@@
sub AUTOLOAD
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
if (@_) {
$self->{$name} = shift;
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
if (@_) {
$self->{$name} = shift;
- # $self->put();
}
return $self->{$name};
}
}
return $self->{$name};
}
@@
-94,6
+102,7
@@
use strict;
sub finish
{
sub finish
{
+ undef $dbm;
untie %u;
}
untie %u;
}
@@
-107,7
+116,7
@@
sub new
my $call = uc shift;
# $call =~ s/-\d+$//o;
my $call = uc shift;
# $call =~ s/-\d+$//o;
-
confess "can't create existing call $call in User\n!" if $u{$call};
+
#
confess "can't create existing call $call in User\n!" if $u{$call};
my $self = bless {}, $pkg;
$self->{call} = $call;
my $self = bless {}, $pkg;
$self->{call} = $call;
@@
-115,7
+124,7
@@
sub new
$self->{dxok} = 1;
$self->{annok} = 1;
$self->{lang} = $main::lang;
$self->{dxok} = 1;
$self->{annok} = 1;
$self->{lang} = $main::lang;
- $
u{call} = $self->encode()
;
+ $
self->put
;
return $self;
}
return $self;
}
@@
-169,6
+178,7
@@
sub get_current
sub put
{
my $self = shift;
sub put
{
my $self = shift;
+ confess "Trying to put nothing!" unless $self && ref $self;
my $call = $self->{call};
$u{$call} = $self->encode();
}
my $call = $self->{call};
$u{$call} = $self->encode();
}
@@
-179,27
+189,11
@@
sub put
sub encode
{
my $self = shift;
sub encode
{
my $self = shift;
- my $out;
- my $f;
-
- $out = "bless( { ";
- for $f (sort keys %$self) {
- my $val = $$self{$f};
- if (ref $val) { # it's an array (we think)
- $out .= "'$f'=>[ ";
- foreach (@$val) {
- my $s = $_;
- $out .= "'$s',";
- }
- $out .= " ],";
- } else {
- $val =~ s/'/\\'/og;
- $val =~ s/\@/\\@/og;
- $out .= "'$f'=>q{$val},";
- }
- }
- $out .= " }, 'DXUser')";
- return $out;
+ my $dd = new Data::Dumper([$self]);
+ $dd->Indent(0);
+ $dd->Terse(1);
+ $dd->Quotekeys($] < 5.005 ? 1 : 0);
+ return $dd->Dumpxs;
}
#
}
#
@@
-211,7
+205,8
@@
sub decode
my $ref;
$s = '$ref = ' . $s;
eval $s;
my $ref;
$s = '$ref = ' . $s;
eval $s;
- confess $@ if $@;
+ Log('DXUser', $@) if $@;
+ $ref = undef if $@;
return $ref;
}
return $ref;
}
@@
-323,5
+318,46
@@
sub sort
my $self = shift;
@_ ? $self->{'sort'} = shift : $self->{'sort'} ;
}
my $self = shift;
@_ ? $self->{'sort'} = shift : $self->{'sort'} ;
}
+
+# some accessors
+sub _want
+{
+ my $n = shift;
+ my $self = shift;
+ my $s = "want$n";
+ return $self->{$n} = shift if @_;
+ return defined $self->{$n} ? $self->{$n} : 1;
+}
+
+sub wantbeep
+{
+ return _want('beep', @_);
+}
+
+sub wantann
+{
+ return _want('ann', @_);
+}
+
+sub wantwwv
+{
+ return _want('wwv', @_);
+}
+
+sub wantwx
+{
+ return _want('wx', @_);
+}
+
+sub wantdx
+{
+ return _want('dx', @_);
+}
+
+sub wanttalk
+{
+ return _want('talk', @_);
+}
+
1;
__END__
1;
__END__