+
+sub unset_passwd
+{
+ my $self = shift;
+ delete $self->{passwd};
+}
+
+sub unset_passphrase
+{
+ my $self = shift;
+ delete $self->{passphrase};
+}
+
+sub set_believe
+{
+ my $self = shift;
+ my $call = uc shift;
+ $self->{believe} ||= [];
+ push @{$self->{believe}}, $call unless grep $_ eq $call, @{$self->{believe}};
+}
+
+sub unset_believe
+{
+ my $self = shift;
+ my $call = uc shift;
+ if (exists $self->{believe}) {
+ $self->{believe} = [grep {$_ ne $call} @{$self->{believe}}];
+ delete $self->{believe} unless @{$self->{believe}};
+ }
+}
+
+sub believe
+{
+ my $self = shift;
+ return exists $self->{believe} ? @{$self->{believe}} : ();
+}
+
+sub lastping
+{
+ my $self = shift;
+ my $call = shift;
+ $self->{lastping} ||= {};
+ $self->{lastping} = {} unless ref $self->{lastping};
+ my $b = $self->{lastping};
+ $b->{$call} = shift if @_;
+ return $b->{$call};
+}
+
+sub readinjson
+{
+ my $fn = shift || $filename;
+
+ my $ta = [gettimeofday];
+ my $count = 0;
+ my $s;
+ my $err = 0;
+
+ unless (-r $fn) {
+ dbg("DXUser $fn not found - probably about to convert");
+ return;
+ }
+
+ open DATA, "$fn" or die "$fn read error $!";
+ while (<DATA>) {
+ chomp;
+ my @f = split /\t/;
+ my $ref;
+ eval { $ref = json_decode($f[1]); };
+ if ($ref) {
+ $u{$f[0]} = $ref;
+ $count++;
+ } else {
+ LogDbg('DXCommand', "# readinjson Error: '$f[0]\t$f[1]' $@");
+ $err++
+ }
+ }
+ close DATA;
+ $s = _diffms($ta);
+ dbg("DXUser::readinjson $count records $s mS");
+}
+
+sub writeoutjson()
+{
+ my $fn = shift || $filename;
+
+ link $fn, "$fn.o";
+ unlink $fn;
+ open DATA, ">$fn" or die "$fn write error $!";
+ my $fh = new IO::File ">$fn" or return "cannot open $fn ($!)";
+ my $count = 0;
+ if ($fh) {
+ my $key = 0;
+ my $val = undef;
+ foreach my $k (keys %u) { # this is to make it as quick as possible (no sort)
+ my $r = $u{$k};
+ $val = json_encode($r);
+ $fh->print("$k\t$val\n");
+ ++$count;
+ }
+ $fh->close;
+ }
+ close DATA;
+ return $count;
+}