fix sh/mydx, add back qra sq for sh/dxgrid
[spider.git] / perl / DXUser.pm
1 #
2 # DX cluster user routines
3 #
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
5 #
6 #
7 #
8
9 package DXUser;
10
11 use DXLog;
12 use DB_File;
13 use Data::Dumper;
14 use Fcntl;
15 use IO::File;
16 use DXDebug;
17 use DXUtil;
18 use LRU;
19 use File::Copy;
20
21 use strict;
22
23 use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold $v3);
24
25 %u = ();
26 $dbm = undef;
27 $filename = undef;
28 $lastoperinterval = 60*24*60*60;
29 $lasttime = 0;
30 $lrusize = 10000;
31 $tooold = 86400 * 365;          # this marks an old user who hasn't given enough info to be useful
32 $v3 = 0;
33 our $maxconnlist = 3;                   # remember this many connection time (duration) [start, end] pairs
34
35 # hash of valid elements and a simple prompt
36 %valid = (
37                   call => '0,Callsign',
38                   alias => '0,Real Callsign',
39                   name => '0,Name',
40                   qth => '0,Home QTH',
41                   lat => '0,Latitude,slat',
42                   long => '0,Longitude,slong',
43                   qra => '0,Locator',
44                   email => '0,E-mail Address,parray',
45                   priv => '9,Privilege Level',
46                   lastin => '0,Last Time in,cldatetime',
47                   lastseen => '0,Last Seen,cldatetime',
48                   passwd => '9,Password,yesno',
49                   passphrase => '9,Pass Phrase,yesno',
50                   addr => '0,Full Address',
51                   'sort' => '0,Type of User', # A - ak1a, U - User, S - spider cluster, B - BBS
52                   xpert => '0,Expert Status,yesno',
53                   bbs => '0,Home BBS',
54                   node => '0,Last Node',
55                   homenode => '0,Home Node',
56                   lockout => '9,Locked out?,yesno',     # won't let them in at all
57                   dxok => '9,Accept DX Spots?,yesno', # accept his dx spots?
58                   annok => '9,Accept Announces?,yesno', # accept his announces?
59                   lang => '0,Language',
60                   hmsgno => '0,Highest Msgno',
61                   group => '0,Group,parray',    # used to create a group of users/nodes for some purpose or other
62                   buddies => '0,Buddies,parray',
63                   isolate => '9,Isolate network,yesno',
64                   wantbeep => '0,Req Beep,yesno',
65                   wantann => '0,Req Announce,yesno',
66                   wantwwv => '0,Req WWV,yesno',
67                   wantwcy => '0,Req WCY,yesno',
68                   wantecho => '0,Req Echo,yesno',
69                   wanttalk => '0,Req Talk,yesno',
70                   wantwx => '0,Req WX,yesno',
71                   wantdx => '0,Req DX Spots,yesno',
72                   wantemail => '0,Req Msgs as Email,yesno',
73                   pagelth => '0,Current Pagelth',
74                   pingint => '9,Node Ping interval',
75                   nopings => '9,Ping Obs Count',
76                   wantlogininfo => '0,Login Info Req,yesno',
77           wantgrid => '0,Show DX Grid,yesno',
78                   wantann_talk => '0,Talklike Anns,yesno',
79                   wantpc16 => '9,Want Users from node,yesno',
80                   wantsendpc16 => '9,Send PC16,yesno',
81                   wantroutepc19 => '9,Route PC19,yesno',
82                   wantusstate => '0,Show US State,yesno',
83                   wantdxcq => '0,Show CQ Zone,yesno',
84                   wantdxitu => '0,Show ITU Zone,yesno',
85                   wantgtk => '0,Want GTK interface,yesno',
86                   wantpc9x => '0,Want PC9X interface,yesno',
87                   wantrbn => '0,Want RBN spots,yesno',
88                   wantft => '0,Want RBN FT4/8,yesno',
89                   wantcw => '0,Want RBN CW,yesno',
90                   wantrtty => '0,Want RBN RTTY,yesno',
91                   wantpsk => '0,Want RBN PSK,yesno',
92                   wantbeacon => '0,Want (RBN) Beacon,yesno',
93                   lastoper => '9,Last for/oper,cldatetime',
94                   nothere => '0,Not Here Text',
95                   registered => '9,Registered?,yesno',
96                   prompt => '0,Required Prompt',
97                   version => '1,Version',
98                   build => '1,Build',
99                   believe => '1,Believable nodes,parray',
100                   lastping => '1,Last Ping at,ptimelist',
101                   maxconnect => '1,Max Connections',
102                   startt => '0,Start Time,cldatetime',
103                   connlist => '1,Connections,parraydifft',
104                  );
105
106 #no strict;
107 sub AUTOLOAD
108 {
109         no strict;
110         my $name = $AUTOLOAD;
111   
112         return if $name =~ /::DESTROY$/;
113         $name =~ s/^.*:://o;
114   
115         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
116         # this clever line of code creates a subroutine which takes over from autoload
117         # from OO Perl - Conway
118         *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
119        goto &$AUTOLOAD;
120 }
121
122 #use strict;
123
124 #
125 # initialise the system
126 #
127 sub init
128 {
129         my $mode = shift;
130   
131         my $ufn;
132         my $convert;
133         
134         eval {
135                 require Storable;
136         };
137
138         my $fn = "users";
139         
140         if ($@) {
141                 $ufn = localdata("users.v2");
142                 $v3 = $convert = 0;
143                 dbg("the module Storable appears to be missing!!");
144                 dbg("trying to continue in compatibility mode (this may fail)");
145                 dbg("please install Storable from CPAN as soon as possible");
146         } else {
147                 import Storable qw(nfreeze thaw);
148
149                 $ufn = localdata("users.v3");
150                 $v3 = 1;
151                 $convert++ if -e localdata("users.v2") && !-e $ufn;
152         }
153         
154         if ($mode) {
155                 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]";
156         } else {
157                 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]";
158         }
159
160         die "Cannot open $ufn ($!)\n" unless $dbm;
161
162         $lru = LRU->newbase("DXUser", $lrusize);
163         
164         # do a conversion if required
165         if ($dbm && $convert) {
166                 my ($key, $val, $action, $count, $err) = ('','',0,0,0);
167                 
168                 my %oldu;
169                 dbg("Converting the User File to V3 ");
170                 dbg("This will take a while, I suggest you go and have cup of strong tea");
171                 my $odbm = tie (%oldu, 'DB_File', localdata("users.v2"), O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn.v2 ($!) [rebuild it from user_asc?]";
172         for ($action = R_FIRST; !$odbm->seq($key, $val, $action); $action = R_NEXT) {
173                         my $ref;
174                         eval { $ref = asc_decode($val) };
175                         unless ($@) {
176                                 if ($ref) {
177                                         $ref->put;
178                                         $count++;
179                                 } else {
180                                         $err++
181                                 }
182                         } else {
183                                 Log('err', "DXUser: error decoding $@");
184                         }
185                 } 
186                 undef $odbm;
187                 untie %oldu;
188                 dbg("Conversion completed $count records $err errors");
189         }
190         $filename = $ufn;
191 }
192
193 sub del_file
194 {
195         # with extreme prejudice
196         unlink "$main::data/users.v3";
197         unlink "$main::local_data/users.v3";
198 }
199
200 #
201 # periodic processing
202 #
203 sub process
204 {
205         if ($main::systime > $lasttime + 15) {
206                 $dbm->sync if $dbm;
207                 $lasttime = $main::systime;
208         }
209 }
210
211 #
212 # close the system
213 #
214
215 sub finish
216 {
217         $dbm->sync;
218         undef $dbm;
219         untie %u;
220 }
221
222 #
223 # new - create a new user
224 #
225
226 sub alloc
227 {
228         my $pkg = shift;
229         my $call = uc shift;
230         my $self = bless {call => $call, 'sort'=>'U'}, $pkg;
231         return $self;
232 }
233
234 sub new
235 {
236         my $pkg = shift;
237         my $call = shift;
238         #  $call =~ s/-\d+$//o;
239   
240 #       confess "can't create existing call $call in User\n!" if $u{$call};
241
242         my $self = $pkg->alloc($call);
243         $self->{lastseen} = $main::systime;
244         $self->put;
245         return $self;
246 }
247
248 #
249 # get - get an existing user - this seems to return a different reference everytime it is
250 #       called - see below
251 #
252
253 sub get
254 {
255         my $call = uc shift;
256         my $data;
257         
258         # is it in the LRU cache?
259         my $ref = $lru->get($call);
260         if ($ref && ref $ref eq 'DXUser') {
261                 $ref->{lastseen} = $main::systime;
262                 return $ref;
263         }
264         
265         # search for it
266         unless ($dbm->get($call, $data)) {
267                 eval { $ref = decode($data); };
268                 
269                 if ($ref) {
270                         if (!UNIVERSAL::isa($ref, 'DXUser')) {
271                                 dbg("DXUser::get: got strange answer from decode of $call". ref $ref. " ignoring");
272                                 return undef;
273                         }
274                         # we have a reference and it *is* a DXUser
275                 } else {
276                         if ($@) {
277                                 LogDbg('err', "DXUser::get decode error on $call '$@'");
278                         } else {
279                                 dbg("DXUser::get: no reference returned from decode of $call $!");
280                         }
281                         return undef;
282                 }
283                 $ref->{lastseen} = $main::systime;
284                 $lru->put($call, $ref);
285                 return $ref;
286         }
287         return undef;
288 }
289
290 #
291 # get an existing either from the channel (if there is one) or from the database
292 #
293 # It is important to note that if you have done a get (for the channel say) and you
294 # want access or modify that you must use this call (and you must NOT use get's all
295 # over the place willy nilly!)
296 #
297
298 sub get_current
299 {
300         my $call = uc shift;
301   
302         my $dxchan = DXChannel::get($call);
303         if ($dxchan) {
304                 my $ref = $dxchan->user;
305                 return $ref if $ref && UNIVERSAL::isa($ref, 'DXUser');
306
307                 dbg("DXUser::get_current: got invalid user ref for $call from dxchan $dxchan->{call} ". ref $ref. " ignoring");
308         }
309         return get($call);
310 }
311
312 #
313 # get all callsigns in the database 
314 #
315
316 sub get_all_calls
317 {
318         return (sort keys %u);
319 }
320
321 #
322 # put - put a user
323 #
324
325 sub put
326 {
327         my $self = shift;
328         confess "Trying to put nothing!" unless $self && ref $self;
329         my $call = $self->{call};
330
331         $dbm->del($call);
332         delete $self->{annok} if $self->{annok};
333         delete $self->{dxok} if $self->{dxok};
334
335         $lru->put($call, $self);
336         my $ref = $self->encode;
337         $dbm->put($call, $ref);
338 }
339
340 # freeze the user
341 sub encode
342 {
343         goto &asc_encode unless $v3;
344         my $self = shift;
345         return nfreeze($self);
346 }
347
348 # thaw the user
349 sub decode
350 {
351         goto &asc_decode unless $v3;
352         my $ref;
353         $ref = thaw(shift);
354         return $ref;
355 }
356
357
358 # create a string from a user reference (in_ascii)
359 #
360 sub asc_encode
361 {
362         my $self = shift;
363         my $strip = shift;
364         my $p;
365
366         if ($strip) {
367                 my $ref = bless {}, ref $self;
368                 foreach my $k (qw(qth lat long qra sort call homenode node lastoper lastin)) {
369                         $ref->{$k} = $self->{$k} if exists $self->{$k};
370                 }
371                 $ref->{name} = $self->{name} if exists $self->{name} && $self->{name} !~ /selfspot/i;
372                 $p = dd($ref);
373         } else {
374                 $p = dd($self);
375         }
376         return $p;
377 }
378
379 #
380 # create a hash from a string (in ascii)
381 #
382 sub asc_decode
383 {
384         my $s = shift;
385         my $ref;
386         $s =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
387         eval '$ref = ' . $s;
388         if ($@) {
389                 LogDbg('err', "DXUser::asc_decode: on '$s' $@");
390                 $ref = undef;
391         }
392         return $ref;
393 }
394
395 #
396 # del - delete a user
397 #
398
399 sub del
400 {
401         my $self = shift;
402         my $call = $self->{call};
403         $lru->remove($call);
404         $dbm->del($call);
405 }
406
407 #
408 # close - close down a user
409 #
410
411 sub close
412 {
413         my $self = shift;
414         my $startt = shift;
415         my $ip = shift;
416         $self->{lastseen} = $self->{lastin} = $main::systime;
417         # add a record to the connect list
418         my $ref = [$startt || $self->{startt}, $main::systime];
419         push @$ref, $ip if $ip;
420         push @{$self->{connlist}}, $ref;
421         shift @{$self->{connlist}} if @{$self->{connlist}} > $maxconnlist;
422         $self->put();
423 }
424
425 #
426 # sync the database
427 #
428
429 sub sync
430 {
431         $dbm->sync;
432 }
433
434 #
435 # return a list of valid elements 
436
437
438 sub fields
439 {
440         return keys(%valid);
441 }
442
443
444 #
445 # export the database to an ascii file
446 #
447
448 sub export
449 {
450         my $name = shift || 'user_asc';
451         my $basic_info_only = shift;
452
453         my $fn = $name ne 'user_asc' ? $name : "$main::local_data/$name";                       # force use of local
454         
455         # save old ones
456         move "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo";
457         move "$fn.ooo", "$fn.oooo" if -e "$fn.ooo";
458         move "$fn.oo", "$fn.ooo" if -e "$fn.oo";
459         move "$fn.o", "$fn.oo" if -e "$fn.o";
460         move "$fn", "$fn.o" if -e "$fn";
461
462         my $count = 0;
463         my $err = 0;
464         my $del = 0;
465         my $fh = new IO::File ">$fn" or return "cannot open $fn ($!)";
466         if ($fh) {
467                 my $key = 0;
468                 my $val = undef;
469                 my $action;
470                 my $t = scalar localtime;
471                 print $fh q{#!/usr/bin/perl
472 #
473 # The exported userfile for a DXSpider System
474 #
475 # Input file: $filename
476 #       Time: $t
477 #
478                         
479 package main;
480                         
481 # search local then perl directories
482 BEGIN {
483         umask 002;
484                                 
485         # root of directory tree for this system
486         $root = "/spider"; 
487         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
488         
489         unshift @INC, "$root/perl";     # this IS the right way round!
490         unshift @INC, "$root/local";
491         
492         # try to detect a lockfile (this isn't atomic but 
493         # should do for now
494         $lockfn = "$root/local_data/cluster.lck";       # lock file name
495         if (-e $lockfn) {
496                 open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
497                 my $pid = <CLLOCK>;
498                 chomp $pid;
499                 die "Lockfile ($lockfn) and process $pid exists - cluster must be stopped first\n" if kill 0, $pid;
500                 close CLLOCK;
501         }
502 }
503
504 use SysVar;
505 use DXUser;
506
507 if (@ARGV) {
508         $main::userfn = shift @ARGV;
509         print "user filename now $userfn\n";
510 }
511
512 package DXUser;
513
514 del_file();
515 init(1);
516 %u = ();
517 my $count = 0;
518 my $err = 0;
519 while (<DATA>) {
520         chomp;
521         my @f = split /\t/;
522         my $ref = asc_decode($f[1]);
523         if ($ref) {
524                 $ref->put();
525                 $count++;
526         DXUser::sync() unless $count % 10000;
527         } else {
528                 print "# Error: $f[0]\t$f[1]\n";
529                 $err++
530         }
531 }
532 DXUser::sync(); DXUser::finish();
533 print "There are $count user records and $err errors\n";
534 };
535                 print $fh "__DATA__\n";
536
537         for ($action = R_FIRST; !$dbm->seq($key, $val, $action); $action = R_NEXT) {
538                         if (!is_callsign($key) || $key =~ /^0/) {
539                                 my $eval = $val;
540                                 my $ekey = $key;
541                                 $eval =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
542                                 $ekey =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
543                                 LogDbg('DXCommand', "Export Error1: $ekey\t$eval");
544                                 eval {$dbm->del($key)};
545                                 dbg(carp("Export Error1: $ekey\t$eval\n$@")) if $@;
546                                 ++$err;
547                                 next;
548                         }
549                         my $ref;
550                         eval {$ref = decode($val); };
551                         if ($ref) {
552                                 my $t = $ref->{lastin} || 0;
553                                 if ($ref->is_user && !$ref->{priv} && $main::systime > $t + $tooold) {
554                                         unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
555                                                 eval {$dbm->del($key)};
556                                                 dbg(carp("Export Error2: $key\t$val\n$@")) if $@;
557                                                 LogDbg('DXCommand', "$ref->{call} deleted, too old");
558                                                 $del++;
559                                                 next;
560                                         }
561                                 }
562                                 # only store users that are reasonably active or have useful information
563                                 print $fh "$key\t" . $ref->asc_encode($basic_info_only) . "\n";
564                                 ++$count;
565                         } else {
566                                 LogDbg('DXCommand', "Export Error3: $key\t" . carp($val) ."\n$@");
567                                 eval {$dbm->del($key)};
568                                 dbg(carp("Export Error3: $key\t$val\n$@")) if $@;
569                                 ++$err;
570                         }
571                 } 
572         $fh->close;
573     }
574         my $s = qq{Exported users to $fn - $count Users $del Deleted $err Errors ('sh/log Export' for details)};
575         LogDbg('command', $s);
576         return $s;
577 }
578
579 #
580 # group handling
581 #
582
583 # add one or more groups
584 sub add_group
585 {
586         my $self = shift;
587         my $ref = $self->{group} || [ 'local' ];
588         $self->{group} = $ref if !$self->{group};
589         push @$ref, @_ if @_;
590 }
591
592 # remove one or more groups
593 sub del_group
594 {
595         my $self = shift;
596         my $ref = $self->{group} || [ 'local' ];
597         my @in = @_;
598         
599         $self->{group} = $ref if !$self->{group};
600         
601         @$ref = map { my $a = $_; return (grep { $_ eq $a } @in) ? () : $a } @$ref;
602 }
603
604 # does this thing contain all the groups listed?
605 sub union
606 {
607         my $self = shift;
608         my $ref = $self->{group};
609         my $n;
610         
611         return 0 if !$ref || @_ == 0;
612         return 1 if @$ref == 0 && @_ == 0;
613         for ($n = 0; $n < @_; ) {
614                 for (@$ref) {
615                         my $a = $_;
616                         $n++ if grep $_ eq $a, @_; 
617                 }
618         }
619         return $n >= @_;
620 }
621
622 # simplified group test just for one group
623 sub in_group
624 {
625         my $self = shift;
626         my $s = shift;
627         my $ref = $self->{group};
628         
629         return 0 if !$ref;
630         return grep $_ eq $s, $ref;
631 }
632
633 # set up a default group (only happens for them's that connect direct)
634 sub new_group
635 {
636         my $self = shift;
637         $self->{group} = [ 'local' ];
638 }
639
640 # set up empty buddies (only happens for them's that connect direct)
641 sub new_buddies
642 {
643         my $self = shift;
644         $self->{buddies} = [  ];
645 }
646
647 #
648 # return a prompt for a field
649 #
650
651 sub field_prompt
652
653         my ($self, $ele) = @_;
654         return $valid{$ele};
655 }
656
657 # some variable accessors
658 sub sort
659 {
660         my $self = shift;
661         @_ ? $self->{'sort'} = shift : $self->{'sort'} ;
662 }
663
664 # some accessors
665
666 # want is default = 1
667 sub _want
668 {
669         my $n = shift;
670         my $self = shift;
671         my $val = shift;
672         my $s = "want$n";
673         $self->{$s} = $val if defined $val;
674         return exists $self->{$s} ? $self->{$s} : 1;
675 }
676
677 # wantnot is default = 0
678 sub _wantnot
679 {
680         my $n = shift;
681         my $self = shift;
682         my $val = shift;
683         my $s = "want$n";
684         $self->{$s} = $val if defined $val;
685         return exists $self->{$s} ? $self->{$s} : 0;
686 }
687
688 sub wantbeep
689 {
690         return _want('beep', @_);
691 }
692
693 sub wantann
694 {
695         return _want('ann', @_);
696 }
697
698 sub wantwwv
699 {
700         return _want('wwv', @_);
701 }
702
703 sub wantwcy
704 {
705         return _want('wcy', @_);
706 }
707
708 sub wantecho
709 {
710         return _want('echo', @_);
711 }
712
713 sub wantwx
714 {
715         return _want('wx', @_);
716 }
717
718 sub wantdx
719 {
720         return _want('dx', @_);
721 }
722
723 sub wanttalk
724 {
725         return _want('talk', @_);
726 }
727
728 sub wantgrid
729 {
730         return _want('grid', @_);
731 }
732
733 sub wantemail
734 {
735         return _want('email', @_);
736 }
737
738 sub wantann_talk
739 {
740         return _want('ann_talk', @_);
741 }
742
743 sub wantpc16
744 {
745         return _want('pc16', @_);
746 }
747
748 sub wantsendpc16
749 {
750         return _want('sendpc16', @_);
751 }
752
753 sub wantroutepc16
754 {
755         return _want('routepc16', @_);
756 }
757
758 sub wantusstate
759 {
760         return _want('usstate', @_);
761 }
762
763 sub wantdxcq
764 {
765         return _want('dxcq', @_);
766 }
767
768 sub wantdxitu
769 {
770         return _want('dxitu', @_);
771 }
772
773 sub wantgtk
774 {
775         return _want('gtk', @_);
776 }
777
778 sub wantpc9x
779 {
780         return _want('pc9x', @_);
781 }
782
783 sub wantlogininfo
784 {
785         my $self = shift;
786         my $val = shift;
787         $self->{wantlogininfo} = $val if defined $val;
788         return $self->{wantlogininfo};
789 }
790
791 sub is_node
792 {
793         my $self = shift;
794         return $self->{sort} =~ /^[ACRSX]$/;
795 }
796
797 sub is_local_node
798 {
799         my $self = shift;
800         return grep $_ eq 'local_node', @{$self->{group}};
801 }
802
803 sub is_user
804 {
805         my $self = shift;
806         return $self->{sort} =~ /^[UW]$/;
807 }
808
809 sub is_web
810 {
811         my $self = shift;
812         return $self->{sort} eq 'W';
813 }
814
815 sub is_bbs
816 {
817         my $self = shift;
818         return $self->{sort} eq 'B';
819 }
820
821 sub is_spider
822 {
823         my $self = shift;
824         return $self->{sort} eq 'S';
825 }
826
827 sub is_clx
828 {
829         my $self = shift;
830         return $self->{sort} eq 'C';
831 }
832
833 sub is_dxnet
834 {
835         my $self = shift;
836         return $self->{sort} eq 'X';
837 }
838
839 sub is_arcluster
840 {
841         my $self = shift;
842         return $self->{sort} eq 'R';
843 }
844
845 sub is_ak1a
846 {
847         my $self = shift;
848         return $self->{sort} eq 'A';
849 }
850
851 sub is_rbn
852 {
853         my $self = shift;
854         return $self->{sort} eq 'N'
855 }
856
857 sub unset_passwd
858 {
859         my $self = shift;
860         delete $self->{passwd};
861 }
862
863 sub unset_passphrase
864 {
865         my $self = shift;
866         delete $self->{passphrase};
867 }
868
869 sub set_believe
870 {
871         my $self = shift;
872         my $call = uc shift;
873         $self->{believe} ||= [];
874         push @{$self->{believe}}, $call unless grep $_ eq $call, @{$self->{believe}};
875 }
876
877 sub unset_believe
878 {
879         my $self = shift;
880         my $call = uc shift;
881         if (exists $self->{believe}) {
882                 $self->{believe} = [grep {$_ ne $call} @{$self->{believe}}];
883                 delete $self->{believe} unless @{$self->{believe}};
884         }
885 }
886
887 sub believe
888 {
889         my $self = shift;
890         return exists $self->{believe} ? @{$self->{believe}} : ();
891 }
892
893 sub lastping
894 {
895         my $self = shift;
896         my $call = shift;
897         $self->{lastping} ||= {};
898         $self->{lastping} = {} unless ref $self->{lastping};
899         my $b = $self->{lastping};
900         $b->{$call} = shift if @_;
901         return $b->{$call};     
902 }
903 1;
904 __END__
905
906
907
908
909